d3d12: console lanes 32..63 of a wave64 VS/PS where the code proves them (D3D12-SHADER-UPPER-LANES) #2706
Closed
leonida/mandy
spzero12 wants to merge 0 commits from
shader-upper-lanes into main
pull from: shader-upper-lanes
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!2706
Loading…
Reference in a new issue
No description provided.
Delete branch "shader-upper-lanes"
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-SHADER-UPPER-LANES(https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7270183812)Depends on: none
What and why
A 32-lane host runs a wave64 vertex or pixel program as waves of 32, so a
v_readlaneof a console lane >= 32 reads no host lane: today a constant lane is refused outside compute ("a cross-lane operation outside compute") and a computed one is lowered toWaveReadLaneAt(v, lane & 31).emit/upper_lanes.rsis the port planned ind3d12/docs/wave64-upper-lanes.md: a forward pass overcrate::irthat follows what lanes 32..63 hold, and thev_readlaneis lowered from that value instead of the read.wave::section_lanes) or av_writelaneproves a lane; a plain write to the VGPR clears what the pass knew.LEONIDA_UPPER_LANES_WHY=1says how many it resolved and left).LEONIDA_UPPER_LANES=0turns it off for an A/B; the shader cache keys on it (the build script lists everyLEONIDA_*the translator reads).What the pack shows, so nobody expects a picture change from it. Before writing it we assumed the compiler's lane-spill and post-section reads were unfixed. They are not:
ir::unspillalready rewrites a VGPR whose every use is thev_writelane/v_readlanepair with a constant lane into scalar moves, before any lowering.wave::sections'Section.readsalready lowers a same-blockv_readlaneafter a whole-wave section (the reduction's broadcast read included).Over all 26,503 containers of the pack (
D:\leonida-work2\shaders\dxbc,translate_cdxil --census) the pass lowers for 353 graphics programs and resolves 0 reads, 355 left. The programs looked at (!PS_FogComposite_57ae119e,_PS_PropFoliageForwardLit_18b3d403) leave a waterfall read at a computed lane (v_readlane sX, v, s2), which no constant stands in for. No translation changed, and the pack's 202 failures are the same as without the pass (195 containers without a program, 2 no wave32 lowering, 5 a descriptor read only as data).So this adds the exact rule for the cases the pack does not contain — a spill through a lane held in an SGPR, a VGPR with other writes, and a read in another block than its section — and it costs nothing where it proves nothing (a program with no such read is byte-identical with the switch off). A whole-wave reduction over all 64 lanes stays an approximation in VS/PS: those stages have no group-shared memory or barrier to exchange the halves (the separate, larger port in the doc).
Tested
cargo test -p leonida-shader upper_lanes: 9 passed (hand-written pixel programs, no game files): a spill through an SGPR lane drawn to a target, a lower-lane spill, a plain write clearing the knowledge, a lane built in an SGPR, a section's identity and a section's uniform value, a compute program untouched, and a program without such a read byte-identical to the switch off.cargo test -p leonida-shader --lib: 393 passed, 0 failed, 4 ignored (the run started before the ninth upper-lane test was added; that one passes separately, so 394 with it).cargo clippy -p leonida-shader --all-targets: no warning from the new files (the two warnings left are the pre-existing ones inlower.rsandbitcode/opt.rs).spirv-val: this is the d3d12 Rust translator, nottools/rdna2spirv.py; the emitted modules go throughdxil.dllin the tests where it is installed.GPUs tested: NVIDIA GeForce GTX 1070 8 GB, driver 582.78, Windows 11 (hardware and WARP).
AI-assisted: yes (Claude).
Checklist
mainand merges cleanly (branchshader-upper-lanes, one commit on1bb726b30).docs/design.mdcontract table is the Python translator's (tools/rdna2spirv.py); this rule is in the d3d12 Rust translator and is written up with how it was confirmed ind3d12/docs/wave64-upper-lanes.mdandd3d12/docs/findings.md.Independent check of
0bfcb3a1onmain1bb726b30. I found a false resolution inexec_after()inemit/upper_lanes.rs. Thes_and*shortcut preservesHi::Zerofor any destination of EXEC. An ordinarys_and_b64reads two explicit operands, so it can replace EXEC without reading the old mask.This hand-written wave64 pixel fixture reproduces it (assembled with
llvm-mc -arch=amdgcn -mcpu=gfx1030):The AND sets every EXEC bit, so the
v_mov_b32overwrites lane 40 with1.0.analyse()instead resolves the read toSome(Value(Value(4))), the old2.0SGPR value. As a control,s_and_b64 exec, exec, -1really does preserve an empty upper mask and should continue to resolve the spill. A locally tested conservative rule keptHi::Zerofor the explicit AND only if one source was current EXEC (for ANDN2, the first source), and kept the implicit 64-bit AND/ANDN2 SAVEEXEC forms. The overwrite case then returnedNoneand the control still resolved. This report's overwrite evidence is from IR analysis. The separate GPU probe for that case produced neither of the reference colors.Measured under Wine 11.22 / VKD3D-Proton 3.1.0: all nine stock upper-lane tests pass on RTX 4070 SUPER (NVIDIA 620.73.04) and Radeon 610M (RADV 26.3.1). A separate draw that requires a real hardware device read back
[2.0; 4]in all 64 pixels for the ordinary lane-40 spill on both. The conservative local comparison passed 12/12 on each GPU, including both IR cases and the live draw. Native Linuxleonida-shader --libpassed 228 on both trees, 2 ignored.AI-assisted: yes (OpenAI Codex).
Thanks, that is a real one and a good catch. Fixed in
70b273f6aon the branch.exec_after()now keepsHi::Zeroonly where the new EXEC isold EXEC & <anything>:saveexecforms and the ANDN2wrexecforms (the old mask is implicit);s_and_b64with EXEC as either source;s_andn2_b64with EXEC as the first source (S0 & ~S1only clears by S0; yours_andn2_b64 exec, -1, execcase is not preserved).Every other
s_and*, including yours_and_b64 exec, -1, -1, isHi::Anynow. A low-word-only write also leaves the upper word unchanged for every instruction, not justs_mov_b32.Regression tests use your fixture:
s_and_b64 exec, -1, -1leaves the read unresolved;s_and_b64 exec, exec, -1,s_andn2_b64 exec, exec, -1ands_and_saveexec_b64 s[8:9], -1still resolve the spill;s_andn2_b64 exec, -1, execdoes not.cargo test -p leonida-shader upper_lanes: 13 passed (the target-draw test ran on a GTX 1070 and WARP here). The corpus measurement in the description is unchanged (0 reads resolved), so no translation moves.AI-assisted (Claude).
I rebuilt
70b273f6amerged ontomain4014af7feand confirmed that the original explicit-AND reproducer is fixed. All 13 stockupper_lanestests passed under Wine 11.22 / VKD3D-Proton 3.1.0 on RTX 4070 SUPER (620.73.04) and Radeon 610M (RADV 26.3.1).Two implicit-mask forms still produce the same false resolution. AMD's RDNA 2 SOP1 tables specify
new EXEC = S0 & ~old EXECfor boths_andn2_saveexec_b64ands_andn2_wrexec_b64. They differ in the value written to the destination SGPRs. WithS0=-1, each sets the previously clear upper mask bits. Your explicits_andn2_b64 exec, -1, execcontrol has that same effect on EXEC.Using the PR's
spill_readhelper, these are the two additional cases (encodings checked withllvm-mc -arch=amdgcn -mcpu=gfx1030):Both return
Some(Value(Value(4)))at70b273f6a, substituting the stale 2.0 for the overwritten lane 40. I removed the implicit ANDN2 forms fromclears_upperin a local comparison, keeping the explicit AND/ANDN2 operand checks and the AND SAVEEXEC controls. Both new cases returnedNone, and all 15 targeted tests then passed on both machines' adapter paths. This reproduction checks the data-flow analysis. The repository's separate SPIR-Vtest_andn2_exec_b64.pyalso passes 4/4 and agrees with AMD's semantics.AI-assisted: yes (OpenAI Codex).