Resolve read-after-write hazard in api samples [hpp_]oit_linked_lists.#1510
Open
asuessenbach wants to merge 2 commits intoKhronosGroup:mainfrom
Open
Resolve read-after-write hazard in api samples [hpp_]oit_linked_lists.#1510asuessenbach wants to merge 2 commits intoKhronosGroup:mainfrom
asuessenbach wants to merge 2 commits intoKhronosGroup:mainfrom
Conversation
76310c3 to
1bc17c9
Compare
gary-sweet
previously approved these changes
Apr 8, 2026
| .offset = 0, | ||
| .size = vk::WholeSize}; | ||
| vk::DependencyInfo dependency_info{.dependencyFlags = vk::DependencyFlagBits::eByRegion, .bufferMemoryBarrierCount = 1, .pBufferMemoryBarriers = &buffer_barrier}; | ||
| command_buffer.pipelineBarrier2(dependency_info); |
Collaborator
There was a problem hiding this comment.
Even though this works (due to the version baseline we use), shouldn't this be pipelineBarrier2KHR instead, as the sample explicitly requests the KHR sync2 extension? If this is supposed to use the non-KHR function, then there's no need to request the sync 2 KHR extension.
Contributor
Author
There was a problem hiding this comment.
Good catch!
It needs to be pipelineBarrier2KHR.
And it did not work due to the version baseline we use (we're using VK_API_VERSION_1_1 by default, not VK_API_VERSION_1_3), but because the one function is an alias of the other. Both of them work with Vulkan-Hpp, as soon as either the VK_KHR_synchronization2 is enabled or VK_VERSION_1_3 is used.
-> Changed to pipelineBarrier2KHR.
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.
Description
The gather pass writes values into the
fragment_buffer, while the combine pass reads from that buffer to sort the fragments.Without the buffer barrier, that leads to a read-after-write hazard.
Build tested on Win11 with VS2022. Run tested on Win11 with NVidia GPU.
General Checklist:
Please ensure the following points are checked:
Note: The Samples CI runs a number of checks including:
If this PR contains framework changes:
batchcommand line argument to make sure all samples still work properlySample Checklist
If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist: