rhi: d3d: Fix resource binding mismatch with multiple passes

The resetShaderResources() done when starting a render or compute pass
purges all vertex, index, SRV, and UAV bindings. This will be optimized
at a later point, but until then the command buffer's state should be
updated accordingly, otherwise certain use cases end up with incorrect
rendering results due to not binding vertex/index/shader resources
as appropriate.

This fixes the shadowmap example on d3d.

Change-Id: I4d07929b8664b64bc608c6c8df474b0ee7c2ddbb
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
Laszlo Agocs 2019-06-28 15:55:52 +02:00
parent 058c52fc2a
commit 2c289c6c1e
2 changed files with 7 additions and 0 deletions

View File

@ -1480,6 +1480,8 @@ void QRhiD3D11::beginPass(QRhiCommandBuffer *cb,
cbD->recordingPass = QD3D11CommandBuffer::RenderPass;
cbD->currentTarget = rt;
cbD->resetCachedShaderResourceState();
}
void QRhiD3D11::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)
@ -1556,6 +1558,8 @@ void QRhiD3D11::beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch
cbD->commands.append(cmd);
cbD->recordingPass = QD3D11CommandBuffer::ComputePass;
cbD->resetCachedShaderResourceState();
}
void QRhiD3D11::endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)

View File

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