Repository navigation
rdna2spirv: v_med3_i16 / v_med3_u16 as the sum minus the smallest and the largest (AMD driver returns a bound) - #6484
evilclanker9000 wants to merge 3 commits into
Conversation
… the largest pk16_diff --oracle hw,vk (ItsNotRexed#6306) found v_med3_i16 with a constant operand coming out as a bound of the three values on the AMD Windows driver (Radeon iGPU 26.10.1, wave32 and wave64): 17, -32768 and 29 gave -32768. The translated SClamp, and min/max and select forms of the same median, all did it; the sum minus Min3 and Max3 is right there, on the RTX 5080 and in the interpreter. 16-bit values fit 32 bits, so the sum cannot overflow. New GPU test cs_med3_i16 (four medians with an SGPR, an inline and a literal constant, words measured on gfx1036). It fails on main on the Radeon and passes with the change on both GPUs; the semantic test checks the value and that no clamp is left. AI-assisted.
docs/design.md AI-assisted.
|
This is a second AMD data point, from a newer GPU on a newer driver. The PR passes. The driver bug does not reproduce here: the Tested d948a6b on its parent, main 561b65a. Hardware and software: AMD Radeon RX 9070 XT (RDNA4), Adrenalin 26.11.2 (LLPC, Vulkan 1.4.359), Windows 11 build 26300, llvm-mc 21.1.8, Vulkan SDK 1.4.363.0. The runtime was built at 561b65a with
There was no With this PR (no
All 252 other SPIR-V modules of the suite are byte-identical to main, native and emulated, and all 239 translated fixtures pass The only other difference from main is (AI-assisted test run.) |
Keep both the cs_med3_i16 and the new cs_pk_mul_lo_const entries in the GPU runner, check.py, regen_fixtures and the shader-check mock. AI-assisted.
|
Tested MSVC (VS 18) Vulkan test programs built from
Every module translated and passed No game files. AI-assisted (Claude Code). |
|
Tested
Commands (each tree built with No game files. AI-assisted. |
|
Independent Windows 11 check at
The incorrect median reported on the older AMD configuration did not reproduce on this RDNA3 card and driver. Synthetic inputs only. AI-assisted validation. |
Requested by Lucas · project thread
Claimed in the coordination issue as: EGEN-MED3-I16, #5032 (comment)
What and why
pk16_diff --oracle hw,vk(#6306) ran the translated programs on a real GPU and foundv_med3_i16with a constant operand giving a bound instead of the median on the AMD Windows driver (Radeon iGPU gfx1036, driver 26.10.1, wave32 and wave64):v_med3_i16 v7, s4, v12, v3 op_sel:[1,0,0,0]with s4.hi = 17, v12 = -32768, v3 = 29 gave -32768 (hardware: 17). It was 5 of 8 mismatches of a 500-program wave32 run and 7 of 8 of a wave64 run. The translatedSClamp(z, min(x,y), max(x,y))did it, and so did a min/max composition and a select composition of the same median; the RTX 5080 andspirv_mini_interpare right with all of them. The median is now the sum minus the smallest and the largest (Min/Maxof three, thenx + y + z - min - max; 16-bit values fit 32 bits), which the Radeon computes correctly, also forv_med3_u16.Tested
cs_med3_i16(four medians with an SGPR constant, an inline constant and a literal, one with the destination high half; the other two operands come from the buffer fill at run time; words measured natively on gfx1036 in game MODE:0xe78a0011 0x12340018 0x1234001d 0xc000abcd). Passes on the AMD Radeon iGPU (26.10.1) and the NVIDIA RTX 5080 (616.92) with the change. On main: the Radeon fails (0xe78a001d 0x1234001d 0x1234001d 0xc000abcd), the RTX 5080 passes (the problem is the AMD driver's).tests/semantic/test_med3_i16.pyruns the same shader through the interpreter and asserts the words and that noClampis left in the SPIR-V (red on main for that assertion, green now). The values themselves cannot go red in the interpreter.pk16_diff --oracle hw,vkbefore/after on the Radeon, 500 programs per wave size: allv_med3_i16mismatches gone in wave32 (seed 201: 8 to 1; the one left is av_pk_mul_lo_u16that is not this) and in wave64 (seed 202: 8 to 0).python -m unittest discover -s tests/semantic(6,151 tests, OK),regen_fixtures.py --check,tests/test_shader_checks.py(fixture count and canned dump updated),test_docs_*.v_min3/v_max3/v_med316-bit row gains the median form and why.AI-assisted: yes.
Checklist
docs/design.md, with how it was confirmed.