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 <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2022-05-09 19:25:39 +02:00
parent a1903eb941
commit 2d3894f356
2 changed files with 2 additions and 5 deletions

View File

@ -1842,7 +1842,7 @@ void QRhiD3D11::beginPass(QRhiCommandBuffer *cb,
cbD->recordingPass = QD3D11CommandBuffer::RenderPass; cbD->recordingPass = QD3D11CommandBuffer::RenderPass;
cbD->currentTarget = rt; cbD->currentTarget = rt;
cbD->resetCachedShaderResourceState(); cbD->resetCachedState();
} }
void QRhiD3D11::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) void QRhiD3D11::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)
@ -1928,7 +1928,7 @@ void QRhiD3D11::beginComputePass(QRhiCommandBuffer *cb,
cbD->recordingPass = QD3D11CommandBuffer::ComputePass; cbD->recordingPass = QD3D11CommandBuffer::ComputePass;
cbD->resetCachedShaderResourceState(); cbD->resetCachedState();
} }
void QRhiD3D11::endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) void QRhiD3D11::endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)

View File

@ -535,9 +535,6 @@ struct QD3D11CommandBuffer : public QRhiCommandBuffer
currentGraphicsPipeline = nullptr; currentGraphicsPipeline = nullptr;
currentComputePipeline = nullptr; currentComputePipeline = nullptr;
currentPipelineGeneration = 0; currentPipelineGeneration = 0;
resetCachedShaderResourceState();
}
void resetCachedShaderResourceState() {
currentGraphicsSrb = nullptr; currentGraphicsSrb = nullptr;
currentComputeSrb = nullptr; currentComputeSrb = nullptr;
currentSrbGeneration = 0; currentSrbGeneration = 0;