d3d12: pixel shaders read barycentrics through a geometry stage on a GPU without them (D3D12-BARYCENTRICS-FALLBACK) #2581
Closed
leonida/mandy
qhukz13 wants to merge 0 commits from
cont/d3d12-bary-fallback into main
pull from: cont/d3d12-bary-fallback
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!2581
Loading…
Reference in a new issue
No description provided.
Delete branch "cont/d3d12-bary-fallback"
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: D3D12-BARYCENTRICS-FALLBACK (#2570#issuecomment-7242150584)
Depends on: #2580 (built on it; the shader-cache key words follow on).
What and why
Without D3D12 barycentrics (before Turing) every pixel shader that reads
SV_BarycentricsorattributeAtVertexis refused at pipeline creation. The debug layer saysShader uses Barycentrics, but the device does not support this. On a GTX 1050 Ti that is 369 refused pipelines (bloom and more).set_host_barycentrics(false):LEONIDA_BARY(a float3 per interpolation mode), andLEONIDA_VTX(constant values at vertices 1 and 2 forattributeAtVertex), packed past the title's own rows;bary_gs():OPTIONS3.BarycentricsSupporteddecides (LEONIDA_BARY_FALLBACK=1forces it);Tested
attributeAtVertex; packed, 54 would need more than 32 rows.host pipeline refused369 → 0;Shader uses Barycentrics435 → 0;cargo test -p leonida-shader --lib barycentric): 18 pass on the 1050 Ti.GPUs tested: GTX 1050 Ti 4 GB (Pascal, profile S), 582.66, Windows 10.
AI-assisted (Claude Code).
🤖 Generated with Claude Code
Pushed d16847611: mesh_vs now writes the barycentrics stand-ins itself.
On the mesh-as-compute path (#2580) the pixel shader behind a mesh program still read
LEONIDA_BARY/LEONIDA_VTX, but no geometry stage wrote them there, so they read zero. mesh_vs writes them now:MEASURED on the 1050 Ti:
NOT measured: the visual difference in game (no side-by-side capture yet).
AI-assisted (Claude Code).
Windows 11 + RTX 3090 D3D12 & WARP Verification (
d168476112) — GPU Verified + Inherits#2580mainRebase (E0063)Verified commit
d168476112dee576bb6146de4b77f2a112bc9e8a(stacked on#2580) on Windows 11 (x86_64-pc-windows-msvc) with physical NVIDIA GeForce RTX 3090 (Ampere, D3D12 driver610.88,BarycentricsSupported == trueand SM 6.6 mesh shaders enabled for direct hardware comparison) and WARP +dxil.dll.1. Red -> Green Physical GPU & DXIL Verification
#2580094e948e99without#2581):barycentricstand-in /bary_gs/mesh_vstests fail to compile (bary_gs,needs_bary_gs,BARY_INPUT,VERTEX_INPUT, andvertex_sourceabsent).d168476112standalone & merged ontomain1bc055e6c2with#2580's 2-fieldTranslatedrebase update):cargo test --locked -p leonida-shader --lib -- --nocapture --test-threads=4 barycentric:19/19passed (1.37s):without_host_barycentrics_pixel_programs_read_stand_ins&the_barycentrics_stage_is_a_valid_geometry_shader: all 7 barycentric pixel programs (values,two modes,interpolation and a value,computed i,constant weights,computed and loaded,p10) and their generatedgs_6_6bary_gsgeometry shaders validated cleanly withdxil.dllwith0SV_Barycentrics/Barycentricsfeature flags.the_barycentrics_stage_draws_what_host_barycentrics_draw: passed texel-for-texel against both analytical reference values and nativeSV_Barycentrics/attributeAtVertexacross all 7 pixel programs on physical RTX 3090 (the barycentrics stage draws on hardware (compared: true)) and WARP (the barycentrics stage draws on WARP (compared: true)).cargo test --locked -p leonida-shader --lib -- --nocapture --test-threads=4 mesh:8/8passed (0.72s), includingmesh_vs_writes_the_barycentrics_stand_ins(dxil.dllvalidated for all 7 programs) anda_mesh_program_run_as_compute_draws_what_the_mesh_pipeline_drawson both RTX 3090 (hardware) andwarp.cargo test --locked -p leonida-gpu --lib -- --nocapture --test-threads=4 shader_cache:2/2passed (host_settings()6-element key updated cleanly).LEONIDA_BARY_FALLBACK=1 LEONIDA_MESH_COMPUTE=1 LEONIDA_D3D12_DEBUG=1 cargo test --locked -p leonida-gpu --features diagnostics --lib -- --nocapture --test-threads=4 pipeline::host::tests:9/9passed on RTX 3090 (0D3D12 debug-layer errors) and8/8applicable tests passed on WARP (LEONIDA_D3D12_WARP=1).python -I scripts/check_no_game_data.py(0issues) andgit diff --checkclean.2. Rebase Note Against Current
main(aa918e5d9f)Because
#2581stacks on#2580(094e948e99), mergingd168476112directly into currentmain(aa918e5d9f) hits the sameE0063inShader::mesh_fallback(d3d12/crates/leonida-gpu/src/pipeline.rs:224:missing fields bound and stores_past_views in initializer of Translated). Verified that addingstores_past_views: false, bound: Default::default()inShader::mesh_fallbackmakes#2581 + maincompile cleanly and pass all GPU tests above.AI-assisted.
Rebased onto
maina9e247cd6.E0063the reviewers hit is fixed: the vertex half of a mesh program run as compute builds itsTranslatedwith the two fieldsmainadded (stores_past_views: false,bound).draw.rs:main'sis_depth_companionis kept besidemesh_buffer.MEASURED on a GTX 1050 Ti (582.66), Windows 10, with Agility 1.614.1 for the test binary:
leonida-shader: 356/356 passed.leonida-gpu: 516 passed; 3 WARP/device tests fail onmaintoo.Thanks @lixonik, @zmasi and @merzleckeier for the runs.
AI-assisted (Claude Code).
Mechanical note, no review: this branch conflicts with
main(4364a4fa6) on a rebase, and the conflict is smaller than it sounds.git merge-tree --write-tree origin/main refs/pull/2581/headreports 1 conflicted file(s):d3d12/crates/leonida-shader/src/emit/mod.rsmainhas changed that file in three recent commits (0bc6e21a1,804280d80,0807f9cba), which is the whole reason. #2580 touches the same file, and I checked: the two branches merge with each other without conflict, so they do not fight over the order - each one only needs its own rebase.So a rebase is all it needs - the change itself may well be fine, I have not looked at its content, only at whether git can apply it.
Written with an AI assistant.
Thanks, @timbot103. Fixed in 7e691b652, 8bd30f5b8 and 66afbce62 (rebased on #2580; the sink and topology points are fixed there):
bary_gstakes the vertex shader's interpolation from its PSV0;mesh_vswrites them);rect_bary_gs. It completes the rectangle and writes the stand-ins for both triangles (six vertices), so indexed and indirect rectangles draw too. The shortcut is gone.bary_gs_adjacency, takes six vertices (DXIL input primitive 7) and draws the triangle at 0, 2, 4. It is made lazily at the first such draw, on the same chain as the per-format variants, so barycentrics pipelines are not all made twice. The flag is in the pipeline's description and in the pipeline book (bit 1 of the depth-bounds byte; older books read as without), so the next run makes it ahead of time.New tests:
the_rectangle_barycentrics_stage_writes_the_stand_insandthe_adjacency_stage_takes_triangles_with_adjacency(portable);the_rectangle_barycentrics_stage_is_a_valid_geometry_shaderand..._draws_what_host_barycentrics_draw(Windows);Tested on GTX 1050 Ti 4 GB / NVIDIA 582.66 / Windows 10 (no SV_Barycentrics, so the stand-ins path):
--libwith the Agility SDK: 243 passed, 0 failed; the validator accepts both new stages;--lib: 517 passed, 3 failed: the same 3 that fail on the base without these PRs on this card (see #2580);Not run here: a pixel-for-pixel comparison against hardware barycentrics. The 1050 Ti has none, so on it those tests check the stand-in path's output only.
AI-assisted (Claude Code).
Merged main (through #2580's merge) in ae1ecd264, d5f666aad and 1e13fef64.
Conflicts:
graphics_pipeline()now picks the sample mask's twin. A draw of triangles with adjacency takes the barycentrics variant, which draws every pixel, as the title's pipeline does while the masked twin is made.host_pipeline_adjacencysits beside main'shost_pipeline_masked.masked_forcallsvariant(…, false): a masked twin in other formats is no adjacency variant.GTX 1050 Ti / 582.66 / Windows 10:
mesh_runs_in_one_list…passes;--lib: 542 passed, 3 failed, the same 3 as clean main on this card (3 runs each).Linux: leonida-shader 232 passed. AI-assisted (Claude Code).
this makes it work on VEGA64 / Radeon MI25 / Radeon Pro WX9100 👍
One follow-up on the
1e13fef64merge. The adjacency case appears to bypassOMSetSampleMaskXeven after the masked twin is ready.graphics_pipeline()can return that twin, butprepare_for()then replaces it viahost_pipeline_adjacency(self.pipeline, ...), which builds the variant frompipeline(this).hostand the masked pipeline lives in a separate field. Could the ready masked pipeline supply the six-vertex variant, with the unmasked one used only while it builds? A masked adjacency draw with both PSOs already warm would distinguish the two cases.Static review of this interaction. AI-assisted.
Partial check by OreoFR on macOS 27.2.1 (26B131), Apple M5, Rust 1.98.1 (d3d12/rust-toolchain.toml), main 060c47160 (merges cleanly; does not force a rebase of #2566 at eade9562c), PR head 1e13fef64 (stacked on #2580)
queue.rs:1417/1446,list.rs:2556/2562use#[cfg(windows)]modules fromlib.rs:53/126,resource.rs:712), so its tests (incl. GPU tests) are not covered here. In-game behaviour is not covered either.emit::bary_gs::tests::the_adjacency_stage_takes_triangles_with_adjacency,emit::bary_gs::tests::the_vertex_shaders_interpolation_comes_from_its_psv0,emit::barycentric_tests::mesh_vs_writes_the_barycentrics_stand_ins,emit::barycentric_tests::without_host_barycentrics_pixel_programs_read_stand_ins,emit::rect::tests::the_rectangle_barycentrics_stage_writes_the_stand_ins,emit::tests::moved_outputs_take_the_lowest_free_register.draw.rs:2738-2745swaps the masked pipeline forhost_pipeline_adjacency()built from the unmasked one, soOMSetSampleMaskXis ignored there (documented in a comment; the "both PSOs ready" case is still to decide). No game data.Verdict: leonida-shader part green (no red possible); leonida-gpu not buildable on macOS; one open review question.
AI-assisted: Claude Code
Verified by OreoFR (Windows part: leonida-gpu, plus leonida-shader's Windows-only tests; oreofr-mac covered leonida-shader on macOS)
PR head
1e13fef64(stacked on #2580) merged withgit merge --no-ffonto main060c47160, no conflict. Windows 11 Pro 10.0.26300, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Rust 1.98.1. The GPU is used by the D3D12 host tests.cargo test -p leonida-gpu --locked: 550 passed / 0 failed / 47 ignored (main 549/0/47; the +1 is #2580's mesh-fallback GPU test, which passes; this PR adds no leonida-gpu test).cargo test -p leonida-shader --lockedon Windows (where theemit::hostD3D12 tests also run): 382 passed / 0 failed / 4 ignored (main 368/0/4; #2580 alone 372).--all-targets, leonida-gpu): no new lint in the files the PR touches.eade9562c) rebase needed after this: no (git merge-treeis clean).OMSetSampleMaskX) would be ignored even once the masked twin is ready.Verdict: NO RED (green on Windows, no failing test possible without the change).
This verification was AI-assisted (Claude Code, oreofr-agent).
Measured on Windows 11 with the Windows SDK's
dxil.dll(101.7.2308.24), and the result is worth passing on: this pull request's head fails the DXIL validator for the same reasonmaindoes, and one small change makes all of those failures go away.On this pull request's head (
1e13fef64),cargo test -p leonida-shader --lib --locked -- emit::givesand every one of the 11 says the same thing:
The cause is not in the geometry stage this pull request builds: the
PSV0part's name table holds one copy of a semantic's name for all the elements that share it, while the validator computes the table from the module with a copy per element. Every element after the first then carries a name offset the module's table does not have, and the validator refuses the program. #2864 writes the table the way DXC writes it (one copy per element, in element order).With that change applied to this pull request's head (the patch applies cleanly to
emit/container.rs, the same file this pull request touches, in another part of it):All the validator failures are gone; the one that is left is not the validator:
It fails on this pull request's head without #2864 as well, and it passes on the current
main(bf30e2585), so it comes from this branch's own work rather than from the container - flagged here only because it is red.One thing to know before reading a green CI run as a check of the container: the
windows-latestjob cannot see any of this.validate()(d3d12/crates/leonida-shader/src/emit/mod.rs) is#[cfg(windows)]and only validates when adxil.dllloads; without one it returns without validating and the test passes. Nodxil.dllloads on the runner - it is in the log ofmain's run 46634364807:emit::rect::tests::rectangles_are_drawn_whole ... okandemit::rect::tests::the_rectangle_stage_is_a_geometry_shader ... ok, i.e. the tests pass without validating anything.LEONIDA_DXILpoints the validator at a specificdxil.dll, so it can be checked by hand in a minute on a machine that has one.No game files and no GPU were needed for this check; the validator is the Windows SDK's
dxil.dll.Closing: this pull request no longer applies to current
main(merge conflict ind3d12/crates/leonida-gpu/src/pipeline/host.rs,d3d12/crates/leonida-gpu/src/pipeline/make.rs,d3d12/crates/leonida-gpu/src/shader_cache.rs,d3d12/crates/leonida-shader/src/emit/lower.rs,d3d12/crates/leonida-shader/src/emit/mod.rs,d3d12/crates/leonida-shader/src/emit/shader.rs), and open pull requests that have fallen out of step withmainare being closed so the list stays workable. If you still want this change, rebase it on currentmainand reopen it (or open a new pull request); it will be looked at again.AI-assisted (Claude Code).