Skip to content

Fix Vulkan render-pass resource synchronization - #107

Merged
Try merged 2 commits into
Try:masterfrom
Solessfir:vulkan-render-pass-sync
Sep 13, 2026
Merged

Try merged 2 commits into
Try:masterfrom
Solessfir:vulkan-render-pass-sync

Conversation

@Solessfir

@Solessfir Solessfir commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Register graphics resource accesses before flushing barriers in VCommandBuffer::endRendering().

Previously, onUavUsage() ran after the flush, so dependencies it discovered could be emitted after the render pass that needed them. Keeping state == RenderPass during the flush places these barriers in the preceding command-buffer chunk, before the consuming draws.

Reported and isolated by neocromicon (discord): ambient lighting flickered white on a Pixel 7 Pro (Mali-G710, Vulkan SDR). He reports that this ordering change fixed the affected scene with the original shaders and fog enabled.

Keep the render-pass state while flushing so dependencies are emitted in the preceding command-buffer chunk, before the consuming draws.

Reported and isolated by neocromicon on a Pixel 7 Pro (Mali-G710), where ambient lighting flickered white.
@Try

Try commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Hi, @Solessfir and thanks for the fix.

Generally makes sense. However, I'm always playing with validation layers and haven't had any warnings. Can you provide add a test case for this?
(note: in unit-tests, you can add test to resourcestate_test.cpp)

PS
also need to adjust DxCommandBuffer

@Solessfir

Copy link
Copy Markdown
Contributor Author

Thanks! I'll add a regression test in resourcestate_test.cpp and update DxCommandBuffer too. The original report was based on the rendering issue and before/after testing on Mali, rather than a validation-layer warning.

@Solessfir

Solessfir commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

Added in 1e6b7f7.

The new resourcestate_test.cpp cases assert the compute-write -> graphics-read barrier before the pass's post-render transition, using different sync IDs for the buffer and attachment. Replaying the old flush-before-registration order in that test fails: the dependency arrives in the post-pass flush instead. These are resource-state sequencing tests, not a driver reproduction.

Also found that comp_test.frag had its SSBO read commented out and returned a constant color. Restored the read and added pixel assertions to the existing Vulkan/DirectX dispatch-to-draw test.

Aligned DxCommandBuffer's registration order too. It keeps its existing joinWriters() and pre-pass flush; I didn't add a late flush, since DirectX doesn't use Vulkan's preceding-chunk barrier insertion.

MSVC Release build and all 11 targeted resource-state and Vulkan/DirectX tests passed locally on an NVIDIA GPU.

@Try
Try merged commit f217ea3 into Try:master Sep 13, 2026
4 checks passed
@Try

Try commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Merged, thanks!

@Solessfir
Solessfir deleted the vulkan-render-pass-sync branch September 14, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants