d3d12: accept StreamOutput PSOs, implement SOSetTargets, capture draws via VK_EXT_transform_feedback (D3D-STREAMOUTPUT-RUNTIME) #1884
Closed
leonida/mandy
Miici0 wants to merge 0 commits from
feat/d3d-stream-output-runtime into main
pull from: feat/d3d-stream-output-runtime
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!1884
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/d3d-stream-output-runtime"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
Claimed in the coordination issue as: D3D-STREAMOUTPUT-RUNTIME (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7164990951)
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 #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 #2570.gta6rt_no_tls_callbacks, which only fails with MSVC 19.42. Details in #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
Nice work — this is the capture path we were also poking at. Two concrete gaps from our own capture work (
BubsMcgee/leonida:stream-output-capture-wip, commit4f05ff666), both static (I couldn't run this branch: it conflicts with currentmain).1. The TF buffer usage bits are missing.
vkCmdBindTransformFeedbackBuffersEXTrequires every bound buffer to have been created withVK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT, and the counter buffers passed to begin/end withVK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT. Currentmainhas noTRANSFORM_FEEDBACK_*_BIT_EXTusage anywhere (git grepoverruntime/), and this PR binds theSOSetTargetsbuffers and the filled-size counters without adding them. The new test creates its SO buffer directly inD3D12_RESOURCE_STATE_STREAM_OUT, but that is only a barrier layout (s::stream_outincommand_list.h/vulkan_replay.h), not a creation usage, so it does not get the bit either. The test passes on the 4070 SUPER because NVIDIA does not enforce it; withLEONIDA_VK_VALIDATION=1(and on stricter drivers / the real title's buffers, which are created in other states) the bind is invalid. Fix: add both bits to every buffer wheninfo.transform_feedbackis on. Our WIP commit has the six creation sites inruntime/shims/d3d12_vulkan_device.cpp:2. Counter width.
D3D12_STREAM_OUTPUT_BUFFER_VIEW::BufferFilledSizeLocationpoints to a 32-bit UINT, socounter_sizeshould besizeof(std::uint32_t), notsizeof(std::uint64_t); with 8,buffer_atcan reject a 4-byte counter buffer. (Our WIP used 4.)Also, the test passes
BufferFilledSizeLocation = 0, so the counter path is not exercised at all — worth a second case with a real 4-byte filled-size buffer, under validation.One semantic question: Vulkan writes a primitive/vertex count to the counter buffer, while D3D12's filled size is bytes. Binding the
BufferFilledSizeLocationas the Vulkan counter writes a different quantity, so if the title reads the filled size it needs its own mapping. (Our WIP made the same binding, so this is an open question we share, not a regression you introduced.)Coordination: #1891 adopts #1236 (with the Snooozs comment/log fix) and has an NVIDIA LGTM; once it lands, this can rebase onto
mainand drop the #1236 copy. #1630 (SO_STATISTICS) is also stacked and touches the same files, so one of us rebases after the other. Happy to hand over the WIP commit or test this once it rebases.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.
d3d12_stream_outputfails underLEONIDA_VK_VALIDATION=1withVUID-vkCmdBindTransformFeedbackBuffersEXT-pBuffers-02360— "pBuffers[0] was created with ..." and noVK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT.d3d12_vulkan_device.cpp,counter_size = sizeof(std::uint32_t), andEXPECT(vk.validation_errors() == 0)in the test): passes plain and with validation, no errors.Branch to cherry-pick:
BubsMcgee/leonida:cap-1884-fixed(heade79908b9e):2fc3f1f0e— the capture commit rebased onto #1891's foundation (adopted #1236 +vk_pipeline_check+ Snooozs's comment fix), with the six usage-bit sites and the 4-byte counter.e79908b9e— the test now assertsvalidation_errors() == 0.The usage-bit hunk is the same at every site:
(
result.usageinDeviceState,create.usagefor the heap,info.usageat the three resource sites,state_.infofor the default-heap buffers.)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
vk_pipeline_checkparity hunk this feature needs is already in #1891; everything else here — StreamOutput PSO acceptance,SOSetTargets, the capture path and the tests — is unique to this branch. A rebase onto current main should be all that is left.(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: https://github.com/ubiquitarianism/leonida/pull/1891#issuecomment-7167501016 . 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
main(conflicting file(s):runtime/shims/d3d12_com.h,runtime/shims/d3d12_vulkan_device.cpp,runtime/src/vulkan_backend.h,runtime/src/vulkan_replay.h,runtime/test/vk_test_device.h), so it carries theneeds rebaselabel. CONTRIBUTING.md asks authors to rebase their branch onmain; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.AI-assisted (Claude Code, Claude Opus 5.5).
@BubsMcgee thanks for the review and the fixed branch. Both points are in, rebased onto
mainf44904d21. #1236's copy is dropped since #1891 landed.79ad1c0e9adds the transform-feedback buffer and counter usage bits at the six creation sites you listed, behind the sametransform_feedbackflag that gatesCONDITIONAL_RENDERING.6de8bf43badds a second draw through a real, zeroed 4-byteBufferFilledSizeLocation, and the test now fails on any validation error.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
BufferFilledSizeLocationdirectly as the counter buffer needs no conversion.d3d12_stream_outputpasses withLEONIDA_VK_VALIDATION=1(0 validation errors) on an RTX 4070 SUPER (driver 621.24). The full suite is 568 of 570. The 2 failures are onmaintoo; see the PR description.AI-assisted (Claude Code).
Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (
d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools,d3d12/, or general docs), please feel free to reopen it.