Repository navigation
Conversation
The VOP1/VOP3 op saturates each signed i16 half of SRC0 to unsigned 8-bit and packs the pair into the low 16 bits of VDST, preserving the high half (GFX9+ partial write; LLVM VOP1Inst_t16, Mesa ACO instr_is_16bit). Neg/abs/clamp/omod are refused; _sdwa restricts to the documented source/destination selects; _e32 rejects all modifiers. Adds a hand-written fixture and a semantic test driving the SPIR-V through spirv_mini_interp against a plain-Python reference (lane edge values, SGPR/literal sources, sdwa selects, refused modifiers), the docs/design.md contract row, and drops the op from the fssm_crosscheck unhandled list. The two tests that used the mnemonic as the still-unsupported canary now use v_mullit_f32. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…alves partial-write code of ProjectLeonida#265 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ProjectLeonida#265 put v_sat_pk in _FULL32_V16_PREFIXES, so _preserves_dst took v_sat_pk_u8_i16 for a whole 32-bit write, and partial_write read its first type, u8, as an 8-bit result. The translator from ProjectLeonida#338 writes the two saturated bytes with write_lo16, which keeps the high half in the _e32, _e64 and DPP forms, so a high half that depends on the lane lost its taint: the shader passed as tier A (or tier B through readlane-uniform) although its export changes when the wave is cut in two. SDWA was already right (dst_sel/dst_unused decide). Neither Mesa ACO nor LLVM says the high half is kept on GFX10: ACO's instr_is_16bit is false for the op before GFX11 (only get_gfx11_true16_mask has it), and LLVM's zeroesHigh16BitsOfDest does not list it. The rule follows what the translator emits, and calling the op partial is the safe side if RDNA2 zeroes the high half. The RDNA2 behaviour is not measured. - tests/semantic/test_wave64_halves_sat_pk.py with the hand-written fixtures/w64_sat_pk_hi.asm: high half = lane id, 64 lanes against two waves of 32 on the wave interpreter, every encoding, the readlane-uniform case, operands()/partial_write per encoding. - runtime/test/shaders/ps_w64_a_sat_pk_hi (tier A, judged on 32-only GPUs) and ps_w64_c_sat_pk_hi (tier C, pinned in test_wave64_halves_fixtures). - docs/design.md contract row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pwu2775-dev
left a comment
There was a problem hiding this comment.
Code read of 4234449 against main. One docs point, not blocking.
The two docs/design.md rows this PR adds disagree. The first row (v_sat_pk_u8_i16) gives Mesa ACO's instr_is_16bit as the reason the destination's high half is kept; the second row (the wave64 halves path) says that function is false for this opcode before GFX11 and that what RDNA2 does with the high half is not measured. The translator behaviour and the wave64 classification are consistent with each other and the second row is candid, but the first row's citation does not establish the hardware behaviour. Suggest rewording the first row to say the preservation is the translator's choice (unverified on RDNA2) and point to the second row.
I did not find other problems in the changed translator and tool code.
AI-assisted: review by Codex (gpt-6.1-terra); the docs point was checked against both rows before posting.
|
Tested 4234449 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.
One docs point (not blocking): the two new AI-assisted: review by Codex (gpt-6.1-terra). |
… high half (SHADER-SATPK-HALVES)
…ice (SHADER-SATPK-HALVES) The op's row cited Mesa ACO instr_is_16bit for the kept high half, but the next row (the wave64 halves path) records that instr_is_16bit is false for the op before GFX11 and that RDNA2's behaviour is not measured. Say that write_lo16 keeps it by the translator's choice and point to that row's references (review on ProjectLeonida#508). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested 232a2ce 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
|
|
@pwu2775-dev thanks, you were right that the first row's citation did not establish it. Reworded in 232a2ce: the @Sangonapou thanks for the run at 232a2ce. The tier C half is still unrun: it needs a device that can require both 64 and 32, or a AI-assisted. |
|
The red
This pull request touches none of the files #877 and #892 change, and it merges into current AI-assisted. |
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Tested head
No game files. AI-assisted (Claude Code), run for a non-developer tester. |
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 rdna2spirv: fix Wave64 halves partial destination read-modify-write #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, rdna2spirv: translate v_sat_pk_u8_i16 (SHADER-SATPK-U8) #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 rdna2spirv: translate v_sat_pk_u8_i16 (SHADER-SATPK-U8) #338's head too. They are the pair reported on an RTX 3080 Ti in rdna2spirv: translate v_sat_pk_u8_i16 (SHADER-SATPK-U8) #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 rdna2spirv: translate v_sat_pk_u8_i16 (SHADER-SATPK-U8) #338's commit keeps its SHA. Once rdna2spirv: translate v_sat_pk_u8_i16 (SHADER-SATPK-U8) #338 lands, the diff is this change only.docs/design.md, with how it was confirmed.🤖 Generated with Claude Code