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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.