From 347310eb21facbd03d2168d67d83fdbfd6f6888c Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 27 May 2021 18:23:18 +0200 Subject: [PATCH] rhi: d3d: Avoid debug layer warning when having no vertex inputs Pick-to: 6.1 Fixes: QTBUG-94064 Change-Id: I03237fcff06225ba41c65c0171d77fb6ae75fcd3 Reviewed-by: Andy Nichols --- src/gui/rhi/qrhid3d11.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index d16332e5b96..35118a4d81f 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -2548,7 +2548,7 @@ void QRhiD3D11::executeCommandBuffer(QD3D11CommandBuffer *cbD, QD3D11SwapChain * context->VSSetShader(psD->vs.shader, nullptr, 0); context->PSSetShader(psD->fs.shader, nullptr, 0); context->IASetPrimitiveTopology(psD->d3dTopology); - context->IASetInputLayout(psD->inputLayout); + context->IASetInputLayout(psD->inputLayout); // may be null, that's ok context->OMSetDepthStencilState(psD->dsState, stencilRef); context->OMSetBlendState(psD->blendState, blendConstants, 0xffffffff); context->RSSetState(psD->rastState); @@ -4142,12 +4142,14 @@ bool QD3D11GraphicsPipeline::create() } inputDescs.append(desc); } - hr = rhiD->dev->CreateInputLayout(inputDescs.constData(), UINT(inputDescs.count()), - vsByteCode, SIZE_T(vsByteCode.size()), &inputLayout); - if (FAILED(hr)) { - qWarning("Failed to create input layout: %s", qPrintable(comErrorMessage(hr))); - return false; - } + if (!inputDescs.isEmpty()) { + hr = rhiD->dev->CreateInputLayout(inputDescs.constData(), UINT(inputDescs.count()), + vsByteCode, SIZE_T(vsByteCode.size()), &inputLayout); + if (FAILED(hr)) { + qWarning("Failed to create input layout: %s", qPrintable(comErrorMessage(hr))); + return false; + } + } // else leave inputLayout set to nullptr; that's valid and it avoids a debug layer warning about an input layout with 0 elements } generation += 1;