WIP: fix: rdna2spirv decodes scalar, image and buffer tuples that run into vcc, so the pipeline-library shaders translate #327
Closed
leonida/mandy
Andretuta wants to merge 0 commits from
old-pr/10062 into main
pull from: old-pr/10062
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!327
Loading…
Reference in a new issue
No description provided.
Delete branch "old-pr/10062"
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.
Original description (mentions and
#Nreferences are disabled; the numbers refer to the old repository):What
tools/rdna2spirv.py: a scalar-memory, image or buffer instruction whose register tuple runs intovcc(SGPRs 106 and 107) is now decoded from the shader blob when llvm-mc rejects it. Newrestore_vcc_tuplesreads the blob dwords of the code range that no matched instruction covers with the existing pure-Pythonrdna2_decode, keeps an instruction only if one of its operands is a[s100,...,vcc_lo,vcc_hi]list (the form the translator already takes), and drops the junk instructions llvm-mc printed inside its two words. Every other undecodable word behaves as before.Why
docs/shader_library.mdsection 5 lists this as the largest refusal in the pipeline library: "reachable instruction with normalized encoding",s_load_dwordx8/x4/x16intos[100:107]/s[104:107]/s[92:107], and image or buffer resources in those tuples (about 2,533 programs per that document; I cannot measure the realshaders.rpfand did not try). llvm-mc skips the first word as invalid and prints the second as junk, sotranslate()refused the shader, or, when the junk matched the blob, translated it with the load silently missing.Tested
Synthetic words only, no game files.
tests/semantic/test_vcc_tuple_fallback.py(new): llvm-mc 19 encodings with the register field patched into vcc, run on the CPU interpreter. Three shapes, each with the three ways the listing can show the rejected words (both invalid, second word printed as a matching junk instruction, second word printed with another encoding):s_buffer_load_dwordx8 [s100..s105,vcc_lo,vcc_hi]: the store of s100, s105, vcc_lo, vcc_hi gives the four expected words (9 sub-cases across the file, 4 tests).[s104,s105,vcc_lo,vcc_hi]read bys_buffer_load_dwordand bybuffer_load_dword: loads 0xCAFE1234 and 0xBEEF5678.image_loadwith the T# in[s100..vcc_hi]: translates through the descriptor lookup.Results: the new file 4 tests, 9 translations also pass
spirv-as+spirv-val --target-env vulkan1.2(0 errors). Neighbours:test_fspx_rules.py9 OK,test_printed_encoding.py7 OK,tests/test_rdna2spirv_decode.py25 OK,tests/test_rdna2_decode.py17 OK (1 skipped),test_fma_mix_literal.py18 OK,tests/test_shader_library.py13 OK, fivetest_docs_*files OK.Negative control: with the one-line call to
restore_vcc_tuplesremoved (that is the behaviour of main), 9 sub-cases fail: "fall-through into undecodable words" for the two listings with no or matching junk and "reachable instruction with normalized encoding" for the third, the message the doc reports.Not verified: llvm-mc 23 is not available here (only 19, which rejects these words as invalid), so a listing where llvm-mc 23 prints the tuple one lower with another encoding (not "invalid") goes through
check_printed_encodingsand is not covered by this PR. The translated shaders were not run on a GPU. The real library counts were not re-measured.Lane:
tools/rdna2spirv.pyand a doc sentence only.I compared six synthetic gfx1013 FSPX programs with real llvm-mc 19.1.7 and 23.1.5. LLVM 23 printed the explicit VCC register lists and preserved their bytes. LLVM 19 exposed a missing case in the submitted patch. After rejecting a scalar load, it can decode the second dword as
expand consume the first dword of the following instruction. Restoring the load alone leaves a gap. All six LLVM 19 listings were refused on the submitted code, including a load followed by a literal move that supplies the output address.I published a follow-up that recovers that successor and keeps variable-length image recovery inside the declared code range. All six modules validated for Vulkan 1.2 under both toolchains. The five buffer cases returned the expected words on an RTX 4070 Ti. The image case verified descriptor lookup and module validity. I did not measure the retail corpus.
Fixture, measured outputs and patch instructions. The second mailbox commit applies on top of tedin7’s change.
Measured on a real
shaders.rpf(own 1.0.2.1 copy). The pipeline-library stage from #19/#321 wrote 2,684 compute programs. Their listings came from llvm-mc 21.1.8,-mcpu=gfx1013, on Windows 11. I then translated<work>/shaders/library/disasmwith this branch at its current head (063f14dcd):rdna2spirv.py --wave64-emulate.spirv-val)e0d4fd2b8translator (no #327)This branch is based on
main, which lacks some translator fixes that #321 has, so the totals aren't directly comparable. The refusals are what matter here. On this branch:976 of the 2,684 listings have invalid words. In a sample of 40 refused programs, the invalid words I decoded by hand are SMEM loads whose tuple runs into vcc:
s_load_dwordx8intos[100:107],s_load_dwordx4/s_buffer_load_dword*into or froms[104:107]. That's the case this PR targets. Yet nearly all of them are still refused asfall-through into undecodable words, sorestore_vcc_tuplesdoesn't seem to reach that path. Only one program got as far as theoperands sgpr vcccheck. In the #321 runtime, 64DeserializeComputePipelineStateX(slot 67) calls fail with "no translated compute shader", so these programs are on the boot path.I'm happy to rerun on the real corpus if you push changes. AI-assisted (Claude Code).
Follow-up on top of this PR, for you to take if useful:
github.com/Tyrannys/leonida@07f4dd738(branchTyrannys:pr327-vcc-followup, one commit on063f14dcd).vcc_hiis SGPR 107 (vcc_hi_as_sgpr,Gen.vcc_hi_sgprmakes%vcc_hithe%sgpr[107]element, andemit()drops the cached SGPR 107 state on a direct%vcc_histore).Numbers, 1.0.2.1 pipeline library (2,684 programs,
--wave64-emulate): 2,396 translated andspirv-val-valid with it. Of the 25 compute programs the retail boot asked for and lacked, 21 now translate; the other 4 were a separate unpack bug (#583).Suite:
run_semantic_tests.py tests/semantic460 files / 6,050 tests; 3 files fail (test_exec_computed,test_image_atomics_guard,test_image_cube_store_glc) and they fail the same at063f14dcdwithout the commit.Left in the library after both: 91 "CS thread-group-size SGPR", 73 "s_load_dwordx4 operands sgpr vcc", 51 "fall-through into undecodable words", 28
ds_append, 26s_bitreplicate_b64_b32on a lane mask, 9 "cannot re-anchor", 6s_load_dwordx8vcc, 3s_flbit_i32_b64of a lane mask.AI-assisted (Claude Code).
Tested
063f14dcdon Windows 11 (Python 3.15,llvm-mc21.1.8,SPIRV-Toolsv2026.4):tests/semantic/test_vcc_tuple_fallback.py: 4/4 passed (0.317s).--stages cs --wave64-emulate): increased translated &spirv-val-passing programs from 1,684 / 2,684 to 1,768 / 2,684 (+84 programs).fall-through into undecodable words, 18s_flbit_i32_b64 of a lane mask, 9undecodable words (cannot re-anchor), 6s_bitreplicate_b64_b32 on a lane mask, 1s_load_dwordx4 operands sgpr vcc, 1reachable instruction with normalized encoding.A follow-up measured on top of this branch (063f14dcd), Windows 11, llvm-mc 21.1.8,
--wave64-emulate, on the retail pipeline library (no game data here, counts only).What still fails, and why. Of the library programs this branch still refuses, nearly all report
fall-through into undecodable words. The rejected words are almost all the vcc-tuple forms this PR targets (SMEMs_load_dwordx8/x4intos[100:107]/s[104:107],s_buffer_load_dwordx16intos[92:107], MIMG withsrsrc/ssampreaching s106/s107). In many of them the instruction is restored, but llvm-mc's junk from the second word was a 64-bit instruction that ran past it and swallowed the first word of the next real instruction.restore_vcc_tuplesdrops that junk, but its words were incovered, so the swallowed instruction is never offered to the decoder and the path falls into a hole right after the restored one.Suggested change: after restoring, decode from the end of each restored instruction with
rdna2_decodeuntil the stream meets the start (or any word) of a kept instruction again:Measured: two random samples of the programs this branch still refuses, 40 and 120 programs: 8/40 and 11/120 now translate, all passing
spirv-val(19/160, about 12%).tests/semantic/test_vcc_tuple_fallback.pystill passes.What the rest is. Every remaining failure in both samples falls through right after an
expthat llvm-mc (andrdna2_decodetoo) prints from a word like0xf8000d60(EXP, target 22,done compr, no channels) inside a compute program. Its second dword decodes cleanly on its own ass_mov_b32 exec_lo, s32, so I suspect a 32-bit console instruction in the EXP encoding space rather than a real 64-bit export, but I have not confirmed that; it is a separate question from this PR.AI-assisted (Claude Code); measured on our copy, nothing of the game posted.
Tested
063f14dcdwith a newerllvm-mcthan earlier runs here. Setup: Windows 11 Pro 26300, nativellvm-mc23.1.5,--wave64-emulate, on the retail pipeline library (2,684 programs, my own copy). Only counts are given here, no game data.de4c373833aa975421With LLVM 23.1.5 listings the change has no effect on either base. The listings are identical and so is the output.
s_load_dwordx4/x8 ... operands sgpr vccrefusals (73 + 6 + 1 on my listings) are gone because of #647 (a4c00f4f4, vcc as a 64-bit base fors_load_dword*). That change covers the part of this PR that still mattered on 23.1.5.On 23.1.5, main still refuses 76 programs, and none of the refusals is a vcc tuple.
So whatever this PR still adds would show up only with older
llvm-mc(21.x, as in the runs above). I have not rerun 21.x on current main. Someone with 21.1.8 could rebase onto main and recount, which would show what is left after #647. If nothing is left, a note in the docs that LLVM 23+ prints these tuples may be enough.AI-assisted.
This carry-over of old upstream PR 10062 has been taken over in #596, so I'm closing this draft as #17 describes. The branch
old-pr/10062stays.AI-assisted (Claude Code, Claude Opus 5.5).