Repository navigation
Runtime: barriers into PREDICATION cover conditional rendering's read (D3D-15/D3D-18 follow-up) - #858
Conversation
D3D12_RESOURCE_STATE_PREDICATION is the same bit as INDIRECT_ARGUMENT (and SYNC/ACCESS_PREDICATION the same as EXECUTE_INDIRECT / INDIRECT_ARGUMENT), and the layer mapped that bit only to INDIRECT_COMMAND_READ at DRAW_INDIRECT. vkCmdBeginConditionalRenderingEXT reads the predicate with CONDITIONAL_RENDERING_READ at the CONDITIONAL_RENDERING stage, so ResolveQueryData -> COPY_DEST to PREDICATION barrier -> SetPredication had no dependency from the copy's write to the predicate read (and none the other way before the next resolve). With the extension enabled (the only case those flags are valid), vulkan_access and vulkan_barrier_scope now add the conditional-rendering access and stage for that bit; GENERIC_READ, which contains it, gets them too. The replay passes the flag from its conditional-rendering entry points. d3d12_vulkan_device_test now enables conditional rendering on its device and runs an occlusion query resolved into a predicate: EQUAL_ZERO skips a clear, NOT_EQUAL_ZERO runs one, and the predicate is resolved into again after the read, once through legacy barriers and once through enhanced buffer barriers. d3d12_state_map_test checks both mappings with and without the extension. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
Code read, as the author of #258: the mapping is right. Two small things:
AI-assisted (Claude Code). |
quackottu
left a comment
There was a problem hiding this comment.
Tested d868cba on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan: pass
ctest -C RelWithDebInfo: 100% tests passed, 0 tests failed out of 32d3d12_state_map_test(changed here): exit=0 validation=0 | state map, enhanced barriers, subresource decoding, layout tracking and BAR detection OKd3d12_vulkan_device_test(changed here): exit=0 validation=0 | [rt] d3d12: upload heaps in VRAM (DEVICE_LOCAL | HOST_VISIBLE, Resizable BAR)- 33 test programs in the build pass with 0 validation errors
d3d12_clear_testfails (R8G8B8A8_UNORM/SNORM 0.5 ties and a D16 clear byte differ from WARP) exactly as onmain4a36bb1 here, so not from this PR; #521 addresses it
Implicit Vulkan layers (overlays) were off through an empty VK_IMPLICIT_LAYER_PATH.
…d_wait #850 moved the waits to a counter, but the 1D-texture block still signalled 8 and #858's predication block 12/13. Once the counter had passed those values, SetEventOnCompletion returned at once and the blocks read results the GPU had not written yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…longer hides heap_desc (C4456) The occlusion-query block from #858 declared a D3D12_QUERY_HEAP_DESC named heap_desc inside the function that already has a D3D12_DESCRIPTOR_HEAP_DESC heap_desc (line 2107), and MSVC /W4 warned C4456. Rename it to query_heap_desc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New D3D item, a follow-up to D3D-15 (#278) and D3D-18 (claim).
The problem
D3D12_RESOURCE_STATE_PREDICATIONis the same bit asINDIRECT_ARGUMENT(0x200). Likewise,SYNC_PREDICATION/ACCESS_PREDICATIONare the same bits asEXECUTE_INDIRECT/INDIRECT_ARGUMENT. The layer mapped that bit only toINDIRECT_COMMAND_READatDRAW_INDIRECT. ButvkCmdBeginConditionalRenderingEXTreads the predicate withVK_ACCESS_CONDITIONAL_RENDERING_READ_BIT_EXTatVK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT, and the replay adds no barrier of its own atSetPredication. So the usual occlusion-culling sequence:had no dependency from the resolve's write to the predicate read. Nothing ordered the read before the next resolve either (
PREDICATION -> COPY_DEST).The change
vulkan_access(states, presentable, conditional_rendering)andvulkan_barrier_scope(sync, access, conditional_rendering): when the extension is enabled, thePREDICATIONbit also adds the conditional-rendering access and stage. That's the only case those flags are valid.GENERIC_READcontains the bit, so it gets them too.access_stageslearns which stages can performCONDITIONAL_RENDERING_READ, so a scope likeSYNC_COPYwithACCESS_PREDICATIONwidens correctly. Without the extension the mappings are unchanged, and the new parameter defaults to off.emitpasses the flag (vk.begin_conditional_rendering != nullptr, set only when the extension is enabled).d3d12_state::predicationnames the state alias, with astatic_assertagainst the SDK.Tests
d3d12_state_map_test: both mappings with and without the extension, theGENERIC_READcase, a pair that has to widen, and the unchanged pairs.d3d12_vulkan_device_testnow enables conditional rendering on its device (info.conditional_rendering), soSetPredicationruns through the D3D12 device for the first time. A new block resolves an occlusion query into a predicate.EQUAL_ZEROskips a clear andNOT_EQUAL_ZEROruns one, since there are no draws yet and the count is 0. The predicate is then resolved into again after the read. This runs once through legacy barriers and once through enhanced buffer barriers, with fence values 12 and 13.To be clear about what the GPU test does and doesn't show: the hazard doesn't show up on NVIDIA, and the validation layer's synchronization checks report nothing on it even before the fix. So the new device-test block passes before and after this change. The regression guard is the state-map unit test. The GPU block is the first end-to-end check of queries plus predication, and it proves the new stage and access masks are accepted by the validation layer in both barrier models.
Tested on an NVIDIA GeForce RTX 5070, driver 621.01, Windows 11, MSVC 14.44 (VS 2022 Build Tools), Vulkan SDK 1.4.363, at
4a36bb1:ctest -E loader: 28/28.loader_testis excluded because it hangs on this PC; that's unrelated and also happens onmain.d3d12_vulkan_device_testandd3d12_com_testwithLEONIDA_VK_VALIDATION=1: pass, 0 validation errors.AI-assisted (Claude Code).
🤖 Generated with Claude Code