Repository navigation
fix(runtime): support IBStripCutValue via dynamic primitive restart - #1583
evilclanker9000 wants to merge 1 commit into
Conversation
CreateGraphicsPipelineState previously logged that index-buffer strip cuts (primitive restart) were not modelled and left primitiveRestartEnable disabled. Load Vulkan 1.3 vkCmdSetPrimitiveRestartEnable in vulkan_backend.h, declare VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE on graphics pipelines, record IBStripCutValue on GraphicsPipeline, and enable primitive restart during replay only for indexed strip topologies whose index format matches the PSO strip-cut value (0xFFFF with UINT16, 0xFFFFFFFF with UINT32). Add synthetic 16-bit/32-bit triangle-strip cut and no-cut negative-control GPU draw tests in d3d12_draw_test.
|
Coordination check: this covers the same D3D-57 / IBStripCutValue primitive-restart behavior as the still-open #572. #572 is stale against the post-#291 main and carries the larger restart test matrix; this PR is a fresh targeted branch on current main. Please mark one explicitly as the successor and port any unique tests before both stay active, so maintainers don't review or merge the same runtime change twice. |
|
Closing in favor of #572 (D3D-57) by @ezwinxdlmao, which already owns IBStripCutValue primitive restart. Thanks @Flyander for catching the overlap! (AI-assisted, operated by Vonsek.) |
|
Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): pass. |
#1583's strip-cut passes leave the fence at 20, and #1660's bundle blend block then signalled 4. SetEventOnCompletion(4) returns at once when the fence has already passed 4, on native D3D12 too, so the check read the readback buffer before the draws had run. It saw the last strip-cut pass's red quad: "bundle blend pixel (0, 0): got 255,0,0,255, expected red 64", on every GPU. Signal 21 instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claimed in the coordination issue as: #1380 (comment)
What and why
CreateGraphicsPipelineStatepreviously loggedindex-buffer strip cuts (primitive restart) are not modelledand left primitive restart disabled on all graphics pipelines.This change:
vkCmdSetPrimitiveRestartEnableinruntime/src/vulkan_backend.hand wires it intoReplayCallbacks.VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLEto graphics pipelines inruntime/shims/d3d12_vulkan_device.cpp(beforeVK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDEso pipelines with no vertex bindings still omit only the stride state) and recordsIBStripCutValueonleonida::GraphicsPipeline.runtime/src/vulkan_replay.h, callsvkCmdSetPrimitiveRestartEnableon every draw, enabling primitive restart only when the draw is indexed, the dynamic topology is a strip (LINE_STRIP,TRIANGLE_STRIP, or their adjacency forms), and the bound index format matches the PSO'sIBStripCutValue(0xFFFFwithVK_INDEX_TYPE_UINT16,0xFFFFFFFFwithVK_INDEX_TYPE_UINT32).runtime/test/d3d12_draw_test.cppdrawing two disjoint quads (top-left and bottom-right) in a singleTRIANGLESTRIPDrawIndexedInstancedcall with0xFFFF(UINT16),0xFFFFFFFF(UINT32), and a no-cut negative control (DISABLED).AI-assisted (Antigravity / Gemini, operated by Vonsek).
Tested
Synthetic scene only (no game files or game shaders were run). Built from commit
432d9ab1(based onupstream/main99f99890) on Windows 11 with VS 2022 Build Tools (MSVC 19.44.35230.0), Ninja,-DLEONIDA_VULKAN_HEADERS_FETCH=ON, and Khronosglslang 16.6.0.VK_LOADER_LAYERS_DISABLE=~implicit~was set;VK_LAYER_KHRONOS_validationis not installed locally on this host (CI runs validation).Before the fix (
99f99890):CreateGraphicsPipelineStateloggedindex-buffer strip cuts (primitive restart) are not modelledand left primitive restart disabled.Commands and measured outcomes on
432d9ab1:0x10de:0x2c02), driver616.92, Vulkan1.4.351(LEONIDA_VK_DEVICE=5080):ctest --test-dir build-strip-cut -R "^(d3d12_draw|d3d12_vulkan_device)$" --output-on-failure -V-> 2/2 passed.strip cut (0xFFFF & 0xFFFFFFFF): 4096/4096 pixels matched each (no-cut negative control painted 256 bridge pixels in bottom-left)0x1002:0x13c0), driver26.10.1, Vulkan1.4.315(LEONIDA_VK_DEVICE=Radeon):ctest --test-dir build-strip-cut -R "^d3d12_draw$" --output-on-failure -V-> 1/1 passed.strip cut (0xFFFF & 0xFFFFFFFF): 4096/4096 pixels matched each (no-cut negative control painted 256 bridge pixels in bottom-left)((-1,0), (0,0), (1,-1))), whereas both0xFFFFand0xFFFFFFFFstrip-cut draws kept all 1,024 bottom-left pixels pure blue(0, 0, 255, 255)on both GPUs.Checklist
docs/design.md, with how it was confirmed. (N/A — runtime graphics pipeline/replay change only.)