wave64_halves: v_sat_pk_u8_i16 keeps its high half (SHADER-SATPK-HALVES) #508
Closed
leonida/mandy
milk4sale wants to merge 0 commits from
shader-satpk-halves into main
pull from: shader-satpk-halves
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!508
Loading…
Reference in a new issue
No description provided.
Delete branch "shader-satpk-halves"
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: SHADER-SATPK-HALVES
Depends on: #338
What and why
#265 added
v_sat_pkto_FULL32_V16_PREFIXESintools/wave64_halves.py, so_preserves_dsttreatsv_sat_pk_u8_i16as a full 32-bit write.partial_writealso read the op's first type,u8, as an 8-bit result. #338 translates the op and writes the two saturated bytes withwrite_lo16, which keeps the high half in the_e32,_e64and DPP forms. With both merged, a high half that depends on the lane lost its taint, and a wave64 VS/PS/GS passed as tier A, or tier B throughreadlane-uniform, although its export changes when the wave is cut into two 32-lane halves. NolanCotter reported this in #14.This change removes
v_sat_pkfrom the tuple, so the op falls to the_i16rule, and makespartial_writesay partial for it. Per encoding:_e32(VOP1 0x62),_e64(VOP3 0x1e2) and DPP keep the high half.BYTE/WORDdst_selandUNUSED_PRESERVE;dst_sel:DWORD,UNUSED_PADandUNUSED_SEXTwrite the whole register. This was already right.op_selon the_e64form for gfx1030.References. Neither compiler says the high half is kept on GFX10, and the cited references don't either:
instr_is_16bitis false for the op before GFX11. It is not in the list, andcan_use_opselfalls through toget_gfx11_true16_mask, which lists it next tov_cvt_f16_f32for GFX11+ only (aco_ir.cpp, Mesa99abc485).VOP1Inst_t16is the plain VOP1 instruction on GFX10, with the true16 forms GFX11+ only.GCNSubtarget::zeroesHigh16BitsOfDestdoes not list the op (LLVMe2b0a1e1).The rule here follows what the translator emits. If RDNA2 turns out to zero the high half, calling the op partial is still the safe side: it costs tier A at most, never exactness. The RDNA2 behaviour is not measured. The contract row in
docs/design.mdsays so.#338's own
v_sat_pk_u8_i16row cited ACOinstr_is_16bitfor the kept high half, which the halves row contradicts (review on this PR). This branch rewords that row: the keep is the translator's choice (write_lo16), not measured on RDNA2, with a pointer to the halves row's references. If #338 rewords the row first, take #338's wording when merging. #338's translator comment and thetest_alu_sat_pk_u8_i16.pydocstring cite ACO the same way; they are left to #338, where this was raised.The halves analysis runs only for wave64 VS/PS/GS, never for compute or under
--wave64-emulate(halves_analysisinrdna2spirv.py). So the GPU fixtures areps_w64_*ones run byw64_graphics.py, notcs_*:ps_w64_a_sat_pk_hi, tier A: the four encodings that keep the high half, a different high half per pixel, and both halves of SRC0 saturating below 0 and above 255 across the target. Every word is a function of the pixel, so a 32-only GPU checks all of them.ps_w64_c_sat_pk_hi, tier C: the high half is the lane id. It is pinned to tier C,lane-id, intests/test_wave64_halves_fixtures.py. On a GPU it needs both subgroup sizes, orW64G_REF.Tested
tests/semantic/test_wave64_halves_sat_pk.pywith the hand-writtentests/semantic/fixtures/w64_sat_pk_hi.asm: 5 OK. It runs on the strict wave interpreter as 64 lanes and as two waves of 32, covers every encoding and thereadlane-uniformcase, and checksoperands()andpartial_writeper encoding.6446e3ce7): 12 subtests fail. That head predates #265, so it has no partial-destination handling at all.mainwithout this change: 9 fail (e32/e64/DPP tier A instead of C, readlane tier B instead of C).python -I scripts/run_semantic_tests.py tests/semantic: 467 files, 6114 tests, 0 failed (70 s, 24 jobs).python -m pytest tests/test_wave64_halves_fixtures.py tests/test_w64_graphics_args.py tests/test_w64_graphics_probe.py tests/test_w64_graphics_reference.py: 22 passed. Without the fix,test_fixtures_are_classified_as_their_headers_sayfails:ps_w64_c_sat_pk_hiis tier A instead of C.tests/test_design_contract_rows.py,tests/test_docs_design_rows.py,tests/test_text_write_line_endings.pyandtests/test_semantic_translator_use.pypass. So dopython -m compileall -q make_game.py tools testsandpython -I scripts/check_no_game_data.pyon every added or changed file.232a2ce6d, docs only): the four tests above,tests/test_wave64_halves_fixtures.pyand the twosat_pksemantic test files pass again, andcheck_no_game_data.py docs/design.mdexits 0.w64_graphics.pyon the RTX 4070 Ti:ps_w64_a_sat_pk_hiA ok,ps_w64_c_sat_pk_hiC SKIP (32 is the only fragment subgroup size). The verdicts are the same without the fix: a 32-only GPU cannot see the classification, so the tests above catch it. NVIDIA runs the translated SPIR-V, so this confirms the translator's semantics, not the AMD instruction. The expected low half comes from the ISA pseudocode's SAT8 packing; the expected high half is the translator's rule.python -I scripts/run_gpu_tests.pyon the RTX 4070 Ti, #338's head against this branch, each with its own runtime build. Both: 257 shaders, 257 translated, 257 pass spirv-val.LEONIDA_W64_EMULATE=1: 229/248 passed, 17 skipped.cs_imgload_tfeandcs_imgload_d16_tfe, fail on #338's head too. They are the pair reported on an RTX 3080 Ti in #338's review.GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 620.70.06, Vulkan 1.4.357, CachyOS Linux (kernel 7.3.3), pinned with
VK_LOADER_DRIVERS_SELECT=*nvidia*andLEONIDA_VK_DEVICE=4070. llvm-mc 23.1.4, SPIRV-Tools v2026.4.AI-assisted: yes (Claude Code)
Checklist
6446e3ce7) plusmain1c93c8697, merged in rather than rebased so #338's commit keeps its SHA. Once #338 lands, the diff is this change only.docs/design.md, with how it was confirmed.🤖 Generated with Claude Code
Tested 42344493 on NVIDIA GeForce RTX 4070, driver 617.42, Windows 11 10.0.26300, MSVC (VS 2022), Vulkan SDK 1.4.363.0, Ninja RelWithDebInfo: pass for what I could run, with one gap.
tests/semantic/test_alu_sat_pk_u8_i16.pyandtest_wave64_halves_sat_pk.py: 10/10.tests/test_wave64_halves_fixtures.py,tests/test_translate.pyandtests/test_f16_op_sel.pyimportpytest, which is not installed here, so those three (two of them edited by this PR) were not exercised.--filter sat_pkmatches nothing), so nothing GPU-side was checked; the docs row says the same.ctest: 302/303 passed; the one failure isd3d12_execute_indirect_validation, which is the red-on-main case in #504 and fails the same way on all three PRs. I did not rerun it onmainitself.run_gpu_tests.py: 197/248 passed, 49 skipped; withLEONIDA_W64_EMULATE=1: 229/248 passed, 17 skipped, the same totals as my unmodified-mainrecord in #534.One docs point (not blocking): the two new
docs/design.mdrows disagree about the Mesa ACO citation; details in my review: https://github.com/ubiquitarianism/leonida/pull/508#pullrequestreview-6035356795AI-assisted: review by Codex (gpt-6.1-terra).
Tested 232a2ce6 on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass for what a 32-only device can run
Runtime built at this head with
scripts\build_runtime.ps1(MSVC 19.51); shaders fromruntime/test/shaders/build.pyat this head (llvm-mc23.1.6, SPIRV-Tools 2026.4); thenpython -I runtime/test/shaders/w64_graphics.py <spirv dir> runtime\build, exit 0. No game files.ps_w64_a_sat_pk_hi A ok.ok.ps_w64_c_sat_pk_hi) allSKIP (tier C needs a device that can require both 64 and 32, or W64G_REF), so the tier C half of this change needs a 64-and-32 device or aW64G_REFcapture.@pwu2775-dev thanks, you were right that the first row's citation did not establish it. Reworded in 232a2ce6: the
v_sat_pk_u8_i16row no longer cites ACOinstr_is_16bitfor the kept high half. It now says the translator writes the result withwrite_lo16, that keeping the high half is the translator's choice and is not measured on RDNA2, and it points to the next row's references. The two rows agree now.@Sangonapou thanks for the run at 232a2ce6. The tier C half is still unrun: it needs a device that can require both 64 and 32, or a
W64G_REFcapture, as you say.AI-assisted.
The red
windows,linux-gpu-toolsandmacosjobs come frommainas it was when this run was created, not from this change. Their checkout step saysMerge 232a2ce6d into a28927849, anda28927849is older than two fixes:windows: linkinggta6rt.exefails with__imp_WaitOnAddress,__imp_WakeByAddressSingleand__imp_WakeByAddressAllunresolved inleonida_xma2_decoder.lib. #877 (merged 16:58 UTC) addssynchronizationto that library's link libraries.linux-gpu-toolsandmacos:cs_imgload_tfeandcs_imgload_d16_tfefail (on Linux:r32 sint (sint view): 64 bad, texel(5,3) = 2071). #892 (merged 17:15 UTC) corrected those two fixtures' expected TFE status.This pull request touches none of the files #877 and #892 change, and it merges into current
main(58be9cdf8) without conflict. Re-running the failed jobs would test the same old merge, so I'm leaving232a2ce6d, the head tested above, as it is rather than pushing just to restart CI. I haven't found a finished run of these jobs on amainthat has both fixes yet.AI-assisted.
Tested head
38623a957merged ontomain57ba40bd6(clean merge) on NVIDIA GeForce RTX 4060 (Ada, subgroup 32 only), driver 621.14, Windows 11 Pro 26300, VS 2022, Vulkan SDK 1.4.363.0: pass.build.pyon the 34 wave64 graphics fixtures: 34 translated, 34 pass spirv-val.w64_graphics.py: 19 ok, 13 tier C SKIP (expected on a 32-only device), 0 failed.ps_w64_a_sat_pk_hiok;ps_w64_c_sat_pk_hiSKIP.test_alu_sat_pk_u8_i16.py5,test_wave64_halves_sat_pk.py5,test_f16_op_sel.py40,test_wave64_halves_fixtures.py10 passed.test_translate.py707 passed, 2 failed (cs_dpp_cmp.asm, the same 2 fail on plainmain).No game files. AI-assisted (Claude Code), run for a non-developer tester.
#508 | head
38623a957c0fc7d32833cb0f7c1d46b72cf539e7|python3 -m unittest discover -s tests/semantic -p test_alu_sat_pk_u8_i16.py -v,python3 -m unittest discover -s tests/semantic -p test_wave64_halves_sat_pk.py -v,python3 -m pytest -q -rA tests/test_f16_op_sel.py,python3 -m pytest -q -rA tests/test_translate.py,python3 -m pytest -q -rA tests/test_wave64_halves_fixtures.py| red: 776 run, 9 failures, 12 errors | green: 786 passed | Red → green. Vulkan Tier A passed, Tier C skippedThe PR includes the opcode introduced in #338. As a dependency control I applied only the #508 test inputs to #338 merged with the same main. The five high-half tests recorded nine failing subtests there and all five passed on merged #508. This isolates the high-half change from the new opcode.
Captured 6 distinct complete SPIR-V module(s) emitted while rerunning test_wave64_halves_sat_pk.py on the merged tree. All assembled and passed spirv-val for Vulkan 1.2 with --allow-offset-texture-operand.
Main could not build these two fragment fixtures. After merging, both assembled and validated. ps_w64_a_sat_pk_hi (Tier A) passed on both adapters. ps_w64_c_sat_pk_hi (Tier C) skipped on both: the harness needs selectable fragment subgroup widths 64 and 32 or a reference from a forced 64-wide draw. No such reference was available.
Windows Vulkan adapters: AMD Radeon(TM) Graphics (26.11.2) and NVIDIA GeForce RTX 5070 Ti (610.74).
tests/semantic/test_alu_sat_pk_u8_i16.pytests/semantic/test_wave64_halves_sat_pk.pytests/test_f16_op_sel.pytests/test_translate.pytests/test_wave64_halves_fixtures.pyAdditional commands
python runtime/test/shaders/build.py <work> vs_ids ps_w64_a_sat_pk_hi ps_w64_c_sat_pk_hipython runtime/test/shaders/w64_graphics.py <work> <build> ps_w64_a_sat_pk_hi ps_w64_c_sat_pk_hiBase
3bd936ecd98995bca3e1da83d5e28d2343001aefwas merged into the recorded PR head for the second run. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Native runs used Windows 11, Python 3.12.10. Counts include unittest subtest events where applicable. AI-assisted with OpenAI Codex. Batch claim.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.