Repository navigation
d3d12: accept StreamOutput PSOs, implement SOSetTargets, capture draws via VK_EXT_transform_feedback (D3D-STREAMOUTPUT-RUNTIME) - #1884
Conversation
|
Nice work — this is the capture path we were also poking at. Two concrete gaps from our own capture work ( 1. The TF buffer usage bits are missing. if (info.transform_feedback)
result.usage |= VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT |
VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT;2. Counter width. Also, the test passes One semantic question: Vulkan writes a primitive/vertex count to the counter buffer, while D3D12's filled size is bytes. Binding the Coordination: #1891 adopts #1236 (with the Snooozs comment/log fix) and has an NVIDIA LGTM; once it lands, this can rebase onto AI-assisted. |
|
Verified the usage-bit finding end to end on Windows 11 / NVIDIA RTX 3080 Ti (driver 616.64, Vulkan SDK 1.4.363.0, Khronos validation layer), by rebasing the capture commit onto our #1891 foundation and running the new test.
Branch to cherry-pick:
The usage-bit hunk is the same at every site: if (<info>.transform_feedback)
<usage> |= VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT |
VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT;( The counter semantics note from before still stands (Vulkan's counter is a primitive/vertex count; D3D12's filled size is bytes). Happy to open a PR against your branch if that is easier, or you can cherry-pick the two commits. AI-assisted. |
|
Heads-up: this is CONFLICTING with main (our duplicate copy, #1925, is closed, so there is no competing implementation). The (Correction to my first version: #1148 is another older conflicting PR, so this is not the only one; both need a rebase.) |
|
Merge order for the TF cluster is on #1891: #1891 (comment) . This PR is step 3: rebase onto main after #1891 lands (your first commit is #1236, which #1891 adopts, so that copy drops). The TF buffer-usage + 4-byte counter fixes, with the test passing under validation, are in BubsMcgee/leonida:cap-1884-fixed. |
|
Hi @Miici0, thanks for this pull request. It currently conflicts with AI-assisted (Claude Code, Claude Opus 5.5). |
…s via VK_EXT_transform_feedback Builds on D3D-TRANSFORM-FEEDBACK-DEVICE (the device-capability plumbing): a graphics PSO that declares StreamOutput is now accepted instead of refused (the common case only: RasterizedStream 0, NumStrides within the device's maxTransformFeedbackBuffers), SOSetTargets stores the bound buffers on the command list the same way IASetVertexBuffers does, and a draw with a pipeline that has StreamOutput and every declared buffer slot bound wraps itself in vkCmdBindTransformFeedbackBuffersEXT + vkCmdBeginTransformFeedbackEXT / vkCmdEndTransformFeedbackEXT, writing real captured data. Not done, left as follow-up: - RasterizedStream other than 0 (needs VkPipelineRasterizationStateStreamCreateInfoEXT / rasterizerDiscardEnable at pipeline creation) - SO_STATISTICS queries (still stubbed to 0; the real wiring is VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT with the indexed vkCmdBeginQueryIndexedEXT/EndQueryIndexedEXT commands) - Matching a real translated game shader's output semantics to StreamOutput buffer slots, which needs patching Xfb decorations into its SPIR-V at PSO creation time (the translator runs before any PSO exists, so it cannot know this ahead of time) - this PR's own test uses a hand-written GLSL shader with the decorations already in place, not a translated one New test d3d12_stream_output_test.cpp: a StreamOutput PSO with a hand-written vertex shader (runtime/test/glsl/vs_stream_output.vert, Xfb-decorated, writes the fixed vec4 (1,2,3,4)) draws 3 vertices; the buffer SOSetTargets bound is read back and every vertex's 16 bytes are checked against that constant. 0 mismatches on real hardware. Full ctest run (runtime/build, RelWithDebInfo): 307/308 pass (one more test than main, the new one); the only failure is the pre-existing d3d12_execute_indirect_validation (ProjectLeonida#504, fixed by the separate PR ProjectLeonida#1066, unrelated to this change). No regressions. GPU: NVIDIA GeForce RTX 4070 SUPER, driver 621.24, Windows 11 26300.9974. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ge bits BubsMcgee's review on ProjectLeonida#1884: vkCmdBindTransformFeedbackBuffersEXT requires every bound buffer (and the counter buffers Begin/End take) to have been created with VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT and VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT (VUID-vkCmdBindTransformFeedbackBuffersEXT-pBuffers-02360). NVIDIA does not enforce this, so the test passed on the 4070 SUPER without it; stricter drivers (and the Khronos validation layer) catch it. Added at the six buffer creation sites that gate VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT the same way, behind the matching transform_feedback flag. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… on validation errors BubsMcgee's review on ProjectLeonida#1884: the test passed BufferFilledSizeLocation = 0, so the counter path was never exercised. A second draw now captures through a zeroed 4-byte counter (a D3D12 UINT); both buffers must hold the 3 vertices and the counter must read the bytes written. It reads 48 (3 x 16) on an RTX 4070 SUPER, so the position Vulkan's counter buffer records is the same quantity as D3D12's filled size, in bytes, and binding BufferFilledSizeLocation as the Vulkan counter needs no conversion. The test also fails on any validation error when run with LEONIDA_VK_VALIDATION=1, as in BubsMcgee's fixed branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9fc0789 to
6de8bf4
Compare
|
@BubsMcgee thanks for the review and the fixed branch. Both points are in, rebased onto
On the open question about counter semantics: after 3 vertices at a 16-byte stride the counter reads 48. Vulkan's counter is a byte position, the same quantity as D3D12's filled size, so binding
AI-assisted (Claude Code). |
Claimed in the coordination issue as: D3D-STREAMOUTPUT-RUNTIME (#1608 (comment))
Depends on: none (its foundation, #1236, landed through #1891)
What and why
The capture path #1630 (D3D-302) left out: StreamOutput PSOs were refused and
SOSetTargetswas not implemented. This PR adds that capture path.A graphics PSO that declares
StreamOutputis now accepted instead of refused. The supported case isRasterizedStream0 withNumStrideswithin the device'smaxTransformFeedbackBuffers.SOSetTargetsstores the bound buffers on the command list, the wayIASetVertexBuffersalready does. A draw whose pipeline hasStreamOutput, with every declared buffer slot bound, is wrapped invkCmdBindTransformFeedbackBuffersEXT+vkCmdBeginTransformFeedbackEXT/vkCmdEndTransformFeedbackEXT, so the captured data reaches the bound buffers.Rebased onto
mainf44904d21. Three commits:emit_commandsnow keeps a rendering scope open across draws, so Begin/End wrap only the draw call itself. Transform feedback is never active when the scope ends or when the next draw binds its pipeline (VUID-vkCmdBindPipeline-None-02323).VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXTandVK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXTat the six creation sites that gateCONDITIONAL_RENDERINGthe same way (VUID-vkCmdBindTransformFeedbackBuffersEXT-pBuffers-02360). TheBufferFilledSizeLocationcounter is resolved as 4 bytes (a D3D12UINT), not 8.BufferFilledSizeLocationcounter, and it fails on any validation error when run withLEONIDA_VK_VALIDATION=1.The counter test settles the open question from the review. After 3 vertices at a 16-byte stride, the counter reads 48. Vulkan's counter records a byte position, the same quantity as D3D12's filled size. So binding
BufferFilledSizeLocationdirectly as the Vulkan counter buffer needs no conversion.#1630's
SO_STATISTICSpools are onmainnow, and this PR only touches that case's comment: the pool now counts what these draws capture.Left as follow-up:
RasterizedStreamother than 0 is d3d12: support StreamOutput RasterizedStream other than 0 (D3D-STREAMOUTPUT-RASTERIZED-STREAM) #1986, stacked on this PR.Xfbdecorations patched into its SPIR-V at PSO creation, because the translator runs before any PSO exists.Tested
d3d12_stream_outputpasses withLEONIDA_VK_VALIDATION=1(Khronos validation, 0 errors) and without it. Both draws capture 3 vertices with 0 mismatches, and the counter reads 48 bytes.ctest(runtime/build, RelWithDebInfo): 568 of 570 pass. The 2 failures are onmaintoo. I builtmainf44904d21without this PR and ran them there, and they fail the same way:xbox_present(VK_ERROR_FORMAT_NOT_SUPPORTED), already reported in Coordinating who works on what (continued from #1608) #2570.gta6rt_no_tls_callbacks, which only fails with MSVC 19.42. Details in Coordinating who works on what (continued from #1608) #2570.GPU: NVIDIA GeForce RTX 4070 SUPER, driver 621.24, Windows 11 26300.9974, Vulkan SDK 1.4.363.1, MSVC 19.42.34435 (VS 2022 Build Tools).
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly.🤖 Generated with Claude Code