fix(vulkan): avoid stale dynamic UBO offsets for promoted inline constants - #809
Conversation
…UBO offsets after buffer ID reuse. A fix need to be applied to `WriteDynamicBufferOffsets` to mitigate the issue.
Keep the existing upstream UpdateTexture implementation when fixing promoted inline constant offsets. Co-Authored-By: Codex <codex@openai.com>
Seed a provably misaligned vertex allocation before recycling its dynamic buffer ID into an inline UBO. Cover compatible SRBs, pipeline-specific push constant selection, UBO emulation, and ordinary dynamic UBO updates with GPU readback and Vulkan validation. Co-Authored-By: Codex <codex@openai.com>
Co-Authored-By: Codex <codex@openai.com>
Co-Authored-By: Codex <codex@openai.com>
|
Could we pass the promoted resource’s descriptor-set index and SRB cache offset to Both values are already available from Inside Initialize both parameters to |
…-set index and SRB cache offset to WriteDynamicBufferOffsets.
|
Could we also store the descriptor-set index and SRB cache offset in
Please document that DescrSet is local to the signature’s SRB cache, rather than the pipeline-global descriptor-set index. This also works with compatible SRBs because their cache layouts match. |
…et in PushConstantInfo, no more lookup in CommitDescriptorSets().
bcb8b11
into
DiligentGraphics:master
Fixes #808.
Problem
A Vulkan inline constant resource promoted to push constants still occupies a dynamic UBO descriptor slot. Its fallback buffer is not mapped, but descriptor binding previously queried its dynamic offset anyway. If the buffer's recycled ID belonged to a mapped vertex buffer, that query could return a stale offset that violates
minUniformBufferOffsetAlignment, producingVUID-vkCmdBindDescriptorSets-pDynamicOffsets-01971even when GPU output is correct.Fix
PushConstantInfoduring descriptor-set commitment.WriteDynamicBufferOffsetsand emit zero only for its unused fallback UBO.Re-evaluating the selection for the current pipeline is essential: the same SRB may alternate between push constants and UBO emulation.
Regression coverage
Adds two Vulkan cases in
Tests/DiligentCoreAPITest/src/InlineConstantsTest.cpp:InlineConstants.VulkanPromotedUBORecycledDynamicOffsetInlineConstants.VulkanPromotedUBOCompatibleSRBBoth establish a uniform-aligned mapped allocation anchor, then map a small vertex buffer and explicitly verify that its mapped-address difference from the anchor is not UBO-aligned. Releasing that buffer immediately before creating the inline constant signature makes its fallback UBO reuse the poisoned dynamic buffer ID. This avoids assuming a fresh context or a particular absolute heap offset. Devices whose vertex-buffer alignment already satisfies UBO alignment are explicitly skipped.
The first dispatch promotes B to push constants, leaving its recycled fallback UBO unmapped. Without the fix, descriptor binding reports VUID 01971. The existing GPU test environment enables Vulkan validation and converts unexpected validation errors into test failures; the tests do not allow or suppress this error.
Each case then alternates four dispatches between:
Inline values and an ordinary dynamic UBO change between dispatches. GPU readback checks A, B, the ordinary UBO, and their combined result for every dispatch. This catches blanket offset-zeroing and incorrect handling of pipeline changes. The second case uses separate compatible signature instances for the PSOs and the bound B SRB, covering resolution through the bound cache.
Validation
Windows x64 Debug; RTX 5060, driver 610.88; Vulkan/Khronos validation 1.4.350:
DiligentCoreAPITestsuccessfully.InlineConstants.*suite passed 11/11, including GPU readback and no validation errors.InlineConstants.*:UpdateTextureFromBuffer.*passed 16/16;git diff --checkpassed.Run from
Tests/DiligentCoreAPITest/assets:For repeated without-fix verification, launch separate processes: Khronos validation may stop reporting a repeated VUID after its duplicate-message limit is reached. The temporary negative-test backend changes are not included in this PR. Release, other GPUs, and other backends were not validated for this change.