diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-09-09 17:07:17 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-17 16:16:36 +0000 |
commit | 42e1abccd0d3d1a327a3a7b9d5e7fc5e4e296716 (patch) | |
tree | 09f24ba14f996f946424d67f5d92e669bb2f1e24 /src/gui | |
parent | 03224fa6de9a606b828ae1c6698124f6cea4fe7d (diff) |
rhi: vulkan: Reset state more aggressively
...when starting a render/compute pass.
This matches most other backends in fact, the Vulkan backend has
just certain historical differences, and is complicated due to the
fact that it has the option of using secondary command buffers for
passes that specify ExternalContents (to support the case of wanting
to issue direct Vulkan commands in a code block surrounded by calls
to beginExternal and endExternal).
Not resetting state such as the currently bound index buffer when
starting a pass quickly blows up when two consecutive render passes
use different settings, one targeting the primary while the other
the secondary command buffer. Instead of further complicating the
logic, just reset the relevant state in every begin(Compute)Pass.
Comes with an autotest that is crafted so that it manages to
downright crash when run with Vulkan without the fix to the backend.
Fixes: QTBUG-89765
Change-Id: I8dc47bd179c17d45a0556ec31200dc90c4b67ca5
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 0dbed05bbc16c37483bea90b3eff3db899a0bf07)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/rhi/qrhivulkan.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index c59b459a5b..7180545678 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -2371,6 +2371,8 @@ void QRhiVulkan::beginPass(QRhiCommandBuffer *cb, if (cbD->passUsesSecondaryCb) cbD->activeSecondaryCbStack.append(startSecondaryCommandBuffer(rtD)); + + cbD->resetCachedState(); } void QRhiVulkan::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) @@ -2382,7 +2384,6 @@ void QRhiVulkan::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourc VkCommandBuffer secondaryCb = cbD->activeSecondaryCbStack.last(); cbD->activeSecondaryCbStack.removeLast(); endAndEnqueueSecondaryCommandBuffer(secondaryCb, cbD); - cbD->resetCachedState(); } QVkCommandBuffer::Command &cmd(cbD->commands.get()); @@ -2414,6 +2415,8 @@ void QRhiVulkan::beginComputePass(QRhiCommandBuffer *cb, if (cbD->passUsesSecondaryCb) cbD->activeSecondaryCbStack.append(startSecondaryCommandBuffer()); + + cbD->resetCachedState(); } void QRhiVulkan::endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) @@ -2425,7 +2428,6 @@ void QRhiVulkan::endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch * VkCommandBuffer secondaryCb = cbD->activeSecondaryCbStack.last(); cbD->activeSecondaryCbStack.removeLast(); endAndEnqueueSecondaryCommandBuffer(secondaryCb, cbD); - cbD->resetCachedState(); } cbD->recordingPass = QVkCommandBuffer::NoPass; |