From 2d3894f3565a13bc62ad8c1e1b0434e811e71efc Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 9 May 2022 19:25:39 +0200 Subject: [PATCH] rhi: d3d: Fix not resetting the pipeline tracking between passes Do what all other backends do. If we did not want to reset the pipeline tracking pointer, then more logic would be needed, in order not to end up in trouble with clients that do: loop: create a pipeline // [1] beginpass ... // use the pipeline endpass readback finish destroy the pipeline goto loop ...because we may get the exact same pipeline pointer (with a matching generation even since it's always 1 in this case) in the different passes, just because malloc decided to do so in [1]. This could be solved by checking the global resource id but won't do that now as no other backends do it either. This solves random broken rendering with the Qt Quick 3D lightmapper. The above outline is exactly what the UV rasterization stage does. Pick-to: 6.3 6.2 Change-Id: Id74a0a336634d99092181b09dd7137eaec355d48 Reviewed-by: Andy Nichols --- src/gui/rhi/qrhid3d11.cpp | 4 ++-- src/gui/rhi/qrhid3d11_p_p.h | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 06ce55c52a4..865b7b313d0 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -1842,7 +1842,7 @@ void QRhiD3D11::beginPass(QRhiCommandBuffer *cb, cbD->recordingPass = QD3D11CommandBuffer::RenderPass; cbD->currentTarget = rt; - cbD->resetCachedShaderResourceState(); + cbD->resetCachedState(); } void QRhiD3D11::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) @@ -1928,7 +1928,7 @@ void QRhiD3D11::beginComputePass(QRhiCommandBuffer *cb, cbD->recordingPass = QD3D11CommandBuffer::ComputePass; - cbD->resetCachedShaderResourceState(); + cbD->resetCachedState(); } void QRhiD3D11::endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) diff --git a/src/gui/rhi/qrhid3d11_p_p.h b/src/gui/rhi/qrhid3d11_p_p.h index 76a40ebce6a..200ac5aa142 100644 --- a/src/gui/rhi/qrhid3d11_p_p.h +++ b/src/gui/rhi/qrhid3d11_p_p.h @@ -535,9 +535,6 @@ struct QD3D11CommandBuffer : public QRhiCommandBuffer currentGraphicsPipeline = nullptr; currentComputePipeline = nullptr; currentPipelineGeneration = 0; - resetCachedShaderResourceState(); - } - void resetCachedShaderResourceState() { currentGraphicsSrb = nullptr; currentComputeSrb = nullptr; currentSrbGeneration = 0;