diff --git a/docs/design.md b/docs/design.md index 7b7797ae67..f330ab17bb 100644 --- a/docs/design.md +++ b/docs/design.md @@ -360,7 +360,7 @@ How the generated SPIR-V expects the runtime to work: | Two-byte typed buffer load alignment | On gfx1036, MUBUF and MTBUF two-byte format loads at an odd effective byte address give zero for a fetched channel. A constant-one descriptor selector still gives one. Native wave32 and wave64 tests on AMD Radeon Graphics (Windows driver 32.0.21042.62) compared aligned and odd loads for every two-byte format (codes 7–19). Moving the base by one byte reversed which offsets returned data for 16_UINT. Regression fixture: `tests/semantic/fixtures/typed_load_alignment.asm`. | | Buffer format store rounding and 2-component `DST_SEL` (SHADER-364) | UNORM/SNORM stores (`Gen.encode_norm_bits`) round the exact product `clamp(x) * scale` once in 64-bit integer arithmetic with ties away from zero, instead of double-rounding through `OpFMul` + `RoundEven` (`UNORM16(0.3)` stores 19661, not 19660; `SNORM2(±0.5)` stores ±1). MUBUF `buffer_store_format_*` (and `_d16_*`) into 2-component formats infer `COMP_SWAP` from V# `DST_SEL_X/Y/Z`: `use_y = (sy >= 4) and (sz < 4)`, `rev = (sx != 4) and (sy >= 4 or sz >= 4)` (`XY01` → `(x, y)`, `YX01` → `(y, x)`, `XYZW` → `(x, w)` so `_xy` writes `(x, 0)`, `YXZW`/`ZYXW` → `(w, x)`); MTBUF `tbuffer_store_format_*` ignores `DST_SEL` and always stores `(x, y)`. Measured natively on RDNA2 (`gfx1036`, AMD Ryzen 7 9800X3D iGPU, Linux AMDGPU DRM via `tools/hw_oracle`, wave32 and wave64) with `tools/buffer_store_probe.py`: 0 mismatches across 5 UNORM/SNORM formats (2,474 inputs × MUBUF/MTBUF × wave32/64 = 9,896 runs) + SNORM2 ties, all 12 2-component formats (`XY01` vs `XYZW`), and all 216 `(sx, sy, sz)` triples on `32_32_UINT`. Checked on CPU + `spirv-val` by `tests/semantic/test_buffer_store_rdna2.py` and `tests/test_buffer_store_probe.py`. | | `_d16_hi_` typed buffer forms (SHADER-755) | Only the single-component forms are instructions. `buffer_load_format_d16_hi_x` and `buffer_store_format_d16_hi_x` are the `_x` forms of the d16 load and store with their one component in bits 31:16 instead of 15:0; #1885 (SHADER-320) adds them. The multi-component spellings (`buffer_load_format_d16_hi_xy`, `_xyz`, `_xyzw`, and `buffer_store_format_d16_hi_*`) name no RDNA instruction and stay `Unsupported`: AMD's machine-readable [RDNA1 and RDNA2 ISA XML](isa_coverage.md) lists `BUFFER_LOAD_FORMAT_D16_HI_X` and `BUFFER_STORE_FORMAT_D16_HI_X` (MUBUF opcodes 0x026 and 0x027) as the only format D16 high-half instructions, and the packed widths `BUFFER_*_FORMAT_D16_X` to `_XYZW` (0x080-0x087) have no high-half counterpart; LLVM's gfx10 to gfx12 MUBUF tables define the same two, and the console's gfx1013 decodes through the gfx10 table, so no listing can carry one (the 25,735-shader corpus has none, reported in #4084). CPU-checked by `tests/semantic/test_buffer_format_d16_hi_absent.py`: every multi-component spelling raises `Unsupported`, and the packed forms translate as a control. | -| `s_lshl1..4_add_u32` | D = (S0 << N) + S1. SCC = the sum taken in 64 bits is ≥ 2³², so a bit shifted out of S0 sets it as well as a carry out of the add (RDNA ISA pseudocode: `tmp = (64'U(S0) << N) + 64'U(S1)`). Checked on the CPU by `tests/semantic/test_salu_lshl_add.py`. **Hardware-verified** on the same gfx1100 part through `tools/hw_oracle`: `s_lshl1_add_u32(0x80000000, 0)` = 0 with SCC = 1 (the bit shifted out of S0 sets it, with no carry out of the add), `s_lshl2_add_u32(5, 3)` = 0x17 with SCC = 0, `s_lshl4_add_u32(1, 0)` = 0x10. Also verified on native RDNA2 (gfx1036, AMD Radeon Graphics): 500 programs in `tools/salu_diff.py` (`--oracle translator,hw`) matched bit-for-bit with 0 mismatches across shift amounts 1–4, confirming that bits shifted out of S0 set SCC as well as sum overflow. | +| `s_lshl1..4_add_u32` | D = (S0 << N) + S1. SCC = the sum taken in 64 bits is ≥ 2³², so a bit shifted out of S0 sets it as well as a carry out of the add (RDNA ISA pseudocode: `tmp = (64'U(S0) << N) + 64'U(S1)`). Checked on the CPU by `tests/semantic/test_salu_lshl_add.py`. **Hardware-verified** on the same gfx1100 part through `tools/hw_oracle`: `s_lshl1_add_u32(0x80000000, 0)` = 0 with SCC = 1 (the bit shifted out of S0 sets it, with no carry out of the add), `s_lshl2_add_u32(5, 3)` = 0x17 with SCC = 0, `s_lshl4_add_u32(1, 0)` = 0x10. Also verified on native RDNA2 (gfx1036, AMD Radeon Graphics): 500 programs in `tools/salu_diff.py` (`--oracle translator,hw`) matched bit-for-bit with 0 mismatches across shift amounts 1–4, confirming that bits shifted out of S0 set SCC as well as sum overflow. GPU-checked for N = 3 and 4 on run-time operands by `runtime/test/shaders/cs_w32_salu_ext.asm` (a bit shifted out of S0 setting SCC over a zero sum, a 64-bit sum past 2³², and two sums that stay below it): exact on an RTX 4070 Ti (NVIDIA 620.70.06, Linux) and on llvmpipe. | | Other additions | `image_gather4_l(_o)`: no explicit-LOD gather in core Vulkan, so four `OpImageFetch` at the mip the "Gather sampler LOD" row chooses, in gather order. `image_gather4_l(_o)`: no explicit-LOD gather in core Vulkan, so four `OpImageFetch` at mip `Floor(clamp(LOD, S# MIN_LOD, MAX_LOD) + 0.5)` (ties up, as native) in gather order. With `d16` those four taps round to binary16 and pack low half first into two consecutive VGPRs. The packed words and the first untouched VGPR were checked with `ps_gather_wrap.asm` on RTX 5080 and Radeon Graphics. Each of the four texel coordinates goes through the S#'s own address mode, read from S# word0 (`CLAMP_X` = bits [2:0], `CLAMP_Y` = [5:3]; fields from Mesa `src/amd/registers/gfx10-rsrc.json`, values `SQ_TEX_*` in Mesa `gfx6.json`, matching RADV's `radv_tex_wrap` mapping of Vulkan address modes): 0 wrap (`c mod n`), 1 mirror (`c mod 2n`, reflected), 2 clamp to the last texel, 3 mirror-once (`-1-c` for negative `c`, then clamped), as in Vulkan's address-mode definitions. The modulo is `OpSRem` plus the period when the remainder is negative, not `OpSMod`. On a Ryzen 5 7600's iGPU (RDNA2) with AMD's Windows driver 24.10.24, `OpSMod` of a negative coordinate came out with the dividend's sign: the three `ps_gather_wrap` cases whose wrap or mirror coordinate is negative (1, 2 and 6) fetched outside the image and read zeros, while the same module passed on an RTX 4070 SUPER. With `OpSRem` and the fix-up, all 4096 pixels are exact on both. A literal S# (`s_mov_b32` earlier in the block) is decoded at translation time; otherwise the mode is read from the SGPR at run time. Modes 6 (clamp border) and 7 (mirror once border) give a tap whose coordinate, before the clamp, is outside [0, n-1] on either axis the S# border colour's channel instead of the fetched texel: BORDER_COLOR_TYPE = word 3 [31:30] (Mesa `gfx10-rsrc.json` `SQ_IMG_SAMP_WORD3`, `SQ_TEX_BORDER_COLOR_*` in `gfx6.json`), 0 transparent black, 1 opaque black (alpha 1), 2 opaque white; 1 for an integer format, as Vulkan's `INT_OPAQUE_*`. Type 3 (a colour from the border-colour table, `BORDER_COLOR_PTR`) is `Unsupported` on a literal S# and transparent black at run time (SHADER-348: since #1567 made the game's S# words literals, 16 of the corpus's mode-6 gathers failed as `Unsupported`; before that they ran as clamp-to-edge). A literal S# with a half-border mode (4, 5) or `FORCE_UNNORMALIZED` is `Unsupported`; a run-time S# can't be judged, so modes 4 and 5 act as clamp-to-edge there and `FORCE_UNNORMALIZED` (word0 bit 15) is not applied (coordinates are still scaled by the image size). Those two, and a table border colour (BORDER_COLOR_TYPE 3) on a run-time S#, which gives transparent black, are the remaining approximations; the unnormalized rules (texel-unit coordinates, mip 0) weren't confirmed on hardware, so they were not guessed. GPU-checked with `runtime/test/shaders/ps_gather_wrap.asm` (`vk_texture_test`; expected values derived by hand in its header; six border cases, three literal and three run-time S#) on AMD (Radeon 880M, wave64) and NVIDIA RTX 5070; the border modes with `runtime/test/shaders/ps_gather_border.asm` (two literal and two run-time S#s, opaque white and transparent black, modes 6 and 7) on NVIDIA RTX 4070 SUPER (driver 621.01), with `tests/test_translate.py`'s `test_gather4_l_*border*`. `image_gather4_lz_o`: `OpImageGather … Offset`. `image_store` on 1D (bindings 17–19, `Image1D`) and with a16 coordinates. `ds_swizzle BITMASK_PERM` ("pippi" masks; GPU-checked). `v_add_f64`, `v_cvt_f32_f64` (`Float64`). `v_mul/mad_i32_i24`, `v_alignbyte_b32`, `v_xnor_b32`, `v_ffbh_i32`, `v_swap_b32`, `s_abs_i32`, `s_bfm_b32/b64`, 64-bit ordered and `v_cmpx` compares, 16-bit compares, 8/16-bit global loads, `neg(…)` constant operands (GPU-checked where listed in `runtime/test/shaders`). | | `v_mad_u64_u32`, `v_mad_i64_i32` | {sdst, D} = S0 × S1 + S2 as a 65-bit result (RDNA ISA pseudocode), the product unsigned or signed. sdst (a lane mask) gets bit 64 for active lanes and 0 for lanes off in EXEC (`EXEC[lane] ? bit64 : 0`, matching `v_cmp_*` and `*_co_*`): the carry out for u64, and for i64 the sign of the exact sum (bit 64 of a 65-bit two's-complement value), not a signed-overflow flag. `tools/lane_masks.py` tracks sdst as a lane mask (until 2026-11-22 it only matched `*_co_*`, so `s_bcnt1`/`s_ff1`/`v_mbcnt` on sdst read each lane's own mask word as plain data). `clamp` is rejected. Checked on the CPU by `tests/test_lane_masks.py`, `tests/semantic/test_alu_mad64.py` (including 64-lane `s_bcnt1_i32_b64`/`s_ff1_i32_b64` ballot tests), and `tests/semantic/test_carry_exec_mask.py` (EXEC masking on inactive lanes). **Hardware-verified on RDNA2** (AMD Radeon 680M, `gfx1035`, wave32 and wave64 via `tools/int_hw_probe.py --oracle both`, SHADER-137): unsigned carry, signed positive overflow `(-2³¹)² + INT64_MAX` giving `sdst = 0`, negative sum giving `sdst = 1`, and inactive EXEC lane leaving D untouched with `sdst = 0` all match bit-for-bit. | | Ray tracing | `image_bvh_intersect_ray` / `image_bvh64_intersect_ray` (64 CS: RT shadows) are one traversal step against AMD's hardware BVH node format. The traversal loop lives in the game's shader. The step is emulated over buffer reads following Mesa RADV's software path (`radv_nir_rt_common.c`, `intersect_ray_amd_software_box/_tri`; node layouts from `bvh_defines.h`). Node id = address >> 3 \| type (0–3 triangle, 4 box16, 5 box32). Box nodes give the four child ids, with misses and NaN boxes = `0xFFFFFFFF`, sorted by entry distance when descriptor bit 63 (box_sort_enable) is set. **The box test is the native one, measured on RDNA2** (SHADER-650; RX 6900 XT, gfx1030, `tools/hw_oracle` raw kernels, 338 cases: BOX32 and BOX16, four rays including negative directions, NaN in every position, empty boxes, planes on the origin, and every tie order of four children; the translator now matches all 338 bit for bit, `main` before it 43, and all 811 rounding cases below): per axis, the near plane is min and the far plane max when the inverse direction (taken as given, not clamped) is ≥ 0, swapped otherwise; t = (plane − origin) × inverse direction, so `0 × inf` is NaN. **Both the subtraction and the multiply round toward zero** (811 more cases, 800 randomized slabs at origins 2^18 to 2^27 away plus 11 ties: round-to-nearest predicts 769 of them, round-toward-zero all 811; among the ties, a box with min.x = 1 > max.x = 0 at origin.x = −2^25 is a hit on hardware because both planes round to the same t). The translator emulates this exactly: the subtraction's error comes from TwoSum, the product's error sign from a Dekker split of the two mantissas scaled to [1, 2), and a result rounded away from zero steps one ulp back; a finite overflow gives ±FLT_MAX. tnear = max of the three near t, tfar = min of the three far t, **each skipping NaN**; all three near or all three far NaN is a miss. Hit when max(tnear, 0) ≤ tfar and tnear < extent (the extent boundary itself was not measured). So a lone NaN bound leaves its own plane open (a box with min.x = NaN is hit wherever x ≤ max.x), an empty box (min > max on any axis, ±inf or ±65504 included) is a miss without a separate check, and a plane exactly on the origin along a zero-direction axis is open. The sort key is max(tnear, 0), so boxes around the origin tie at 0, ordered by the network (0,2) (1,3) (0,1) (2,3) (1,2) with a strict `<` swap (all 88 measured tie orders). `tests/semantic/test_image_bvh_box_hw.py` holds measured words. Triangle nodes read their three vertices from the slots the node type picks: TRI0 (0,1,2), TRI1 (1,3,2), TRI2 (2,3,4), TRI3 (2,4,0), 12 bytes each. They use the watertight test with RADV's shared edge/vertex tie-breaks and give (t/\|det\|, sign(det), b_i/\|det\|, b_j/\|det\|), or (inf, 1, 0, 0) on a miss. The weights i and j are chosen by the node type's byte of the triangle-ID word at +60: bits [1:0] and [3:2], 0/1/2 = vertex 0/1/2 and 3 = vertex 0, bits [7:4] ignored; `0x09` gives RADV's (v, w). Vertex slots and remap follow AMD GPURT (`CalcTriangleCompressionVertexIndices`, `SwizzleBarycentrics`) and the public XDXR software path ([bvh.md](bvh.md) §7a), and the hardware agrees. **The triangle step is the native one, measured on RDNA2** (AMD Radeon RX 6800, gfx1030, AMD Windows driver 26.11.2, Windows 11, 2026-11-22; the `tools/hw_oracle` kernels `tools/bvh_tri_probe.py` builds, hand-built nodes and rays: 14 kernels, 308 single-lane cases and 7 cases on 64 lanes, 1,204 results, each in both forms; the 32-bit form with the descriptor base at the node and the 64-bit form with base 0, wave32 and wave64, NSA and contiguous operands all gave the same words). A NaN anywhere in t max, the origin, the direction or the inverse direction, or an infinite origin, returns (+inf, 1.0, +0, +0). Otherwise the watertight test runs with its shear taken from the direction (kz = the axis of the largest \|d\|, ties x, y, z; kx and ky swapped when d[kz] < 0; Sz = 1/d[kz]): **the supplied inverse direction is not used**. With the edge functions U, V, W, det = U + V + W, T = t·det and k = \|d[kz]\|³, a hit returns (k·T, k·det, k·b_i, k·b_j) and a miss (copysign(inf, k·det), k·det, k·b_i, k·b_j): numerators over the denominator k·det, and a miss keeps the plane's barycentric numerators. det = 0 is a miss with word 0 = +inf. The hit needs t ≥ 0 (t = 0 hits); there is no test against t max. Every zero word is +0 and every NaN word 0xFFC00000, so a NaN det gives word 0 = −inf. An edge function of 0 is inside when its edge passes RDNA2's tie rule, which is not RADV's: the edge from P to Q (U: B→C, V: C→A, W: A→B), with (tx, ty) = Q′ − P′ in the sheared frame with the d[kz] < 0 swap of kx and ky undone, passes when ty = 0 ? sign(det)·tx > 0 : sign(d[kz])·sign(det)·ty > 0, and every zero edge must pass. Every shared edge and shared vertex gave exactly one hit. How this rule was found: the first fit (ty = 0 ? tx < 0 : sign(det)·ty > 0, on the 49 tie rows of the first measurement, all z dominant) was confounded, because every one of those rows had det < 0 with d[kz] > 0 or det > 0 with d[kz] < 0, and it was wrong in the cells it never saw. A second measurement (2026-11-23, same part and driver; 8 more kernels, 256 rows: ties with x, y and z dominant, both windings, both signs of d[kz], every edge direction class in each of those cells, tilted triangles with oblique rays, equal \|d\| components) fitted none of the eight rules registered before it ran. The rule above was then read off its x/y rows (post hoc), and it predicted the z-dominant bridge kernel `tri_t8` before that ran: 32 of 32 cases, 10 of them rows where it and the first fit disagree. The translator computes these words without a division, with the shear multiplied through by \|d[kz]\| (a shear divided by d[kz] gives the same words on every measured row but d.z = +inf, and divides by zero at d = 0; this form gives d = 0 → (+inf, 0, 0, 0) and d.z = +inf → (−inf, NaN, −inf, −inf) as measured, a fit after the runs), and fixes zero signs and NaN bits with integer selects, so every measured input is defined SPIR-V. `tests/semantic/test_image_bvh_tri_hw.py` asserts all 308 rows and 84 lane results of the first measurement and the 256 rows of the second bit for bit (the translator before it: 129 of the first 308; the first fit: 210 of the 256); `tests/semantic/test_image_bvh_tri.py` runs every node type and remap byte on the interpreter. **A consumer that divides by word 1** (t = w0/w1, weights w2/w1 and w3/w1) gets t and the weights on a hit (k cancels; word 1 keeps det's sign); +inf for t on a miss of either winding, with the plane's weights; t = +inf/+0 = +inf and weights 0/0 on a zero-area triangle; t = NaN with a NaN or inf vertex, so a `t < t max` test fails as on a miss; t = +inf with a NaN in the ray or an infinite origin. It must compare t with t max itself. The translator's earlier normalised words (t/\|det\|, sign(det), b_i/\|det\|, b_j/\|det\|; a miss (inf, 1, 0, 0)) gave such a consumer the same t on every row and the same weights on every hit except on 14 shared-edge rows (RADV's tie rule), 3 rows whose inverse direction is not 1/d, 3 rows with a NaN in the ray (it reported a hit or other words), the v0.x = −inf and d.z = +inf rows, and 14 rows that were undefined SPIR-V there (zero area, a NaN or inf vertex, a NaN, inf or zero ray). **Not measured:** gfx1013 (the console); node types 6 and 7; the box extent boundary; descriptor words other than w2 = 0xFFFFFFFF, w3 = 0x81000000 (return mode 0 included); the dominant axis on equal \|d\| components except where a measured tie row tells the axes apart: x for \|dx\| = \|dy\| > \|dz\| (only with dx, dy > 0), x for \|dx\| = \|dz\| > \|dy\| (not with dx > 0 > dz), y for \|dy\| = \|dz\| > \|dx\| (only with dy, dz of the same sign) and x with all three equal (in the four of the eight sign patterns that ran), which is the translator's `>=` order (a non-tie row gives the same words whatever the choice, and every sign pattern could show it with the right tie); rounding-sensitive inputs (every input is dyadic, so the divided versus multiplied-through shear and fused versus separate rounding are not told apart); d = 0 and infinite d beyond one row each; the remap's high nibble on TRI1–TRI3. These two references agree; one real pack BLAS is now matched, rehydrated and traversed (§7b), though the rule has not been counted over the whole corpus. The triangle rule has not been measured on the native instruction yet: `tools/hw_oracle` can run it on RDNA2, and box32 nodes were measured that way (gfx1036, address = base × 256 + (node & ~7) × 8 in both instruction widths, §7b), so the triangle counterpart is a possible follow-up rather than an impossibility. These two references agree; no game BVH is decoded yet to count over. The triangle rule has not been run natively yet; the box rule above has (`tools/hw_oracle` on an AMD RDNA2 card runs the instruction itself). `tests/semantic/test_image_bvh_tri.py` runs every node type and remap byte on the interpreter, including the descriptor-base case. The game's code divides by `.y` exactly as for the hardware's numerator/denominator. Address = descriptor base + ((node & ~7) << 3). The descriptor's dword0 is the base in 256-byte units: the game passes `ptr >> 8` there, and the `\| 0x30` its shader ORs is only the temporary address it uses to load `rootNodePtr`, not the descriptor base. Measured at base 0 and at base 0x1000 (structure at VA 0x1000, dword0 `0x10`): the GPU returns the CPU walker's children in the same order at both, so the `<< 8` is correct and a nonzero base needs no masking. `tests/semantic/test_image_bvh_tri.py` runs the nonzero base (`0x10` → `0x1000`). Address = descriptor base + ((node & ~7) << 3), base = descriptor bits [39:0] in 256-byte units (measured on gfx1030: the 32-bit form with a non-zero base and the 64-bit form with base 0 and the full address gave the same words in 71 cases). **The runtime must build the game's acceleration structures in this AMD node format** (RADV's GPU BVH builder produces it) wherever the game's D3D12 calls build them. Far branches with `s_sub_u32`/`s_subb_u32` (backward) are folded too. GPU-checked with `runtime/test/shaders/cs_bvh.asm`: sorted box children and the triangle result are exact; its box with a NaN min.x is entered at t = 0 and sorts first (`0x68 0x48 0x40 0xffffffff`), as native gfx1030 returns for that scene. The 32-bit form (11 address dwords: the node id has no high dword) runs the same scene in `cs_bvh32.asm` and gives the same eight words. Corpus counts (`tools/image_bvh_census.py`, static, [bvh.md](bvh.md) §7): 716 sites, 638 32-bit and 78 64-bit; the descriptor has box_sort_en 1, big_page 1, size all ones and type 8 at every site; on every path from the call, 397 sites take `v_rcp_f32` of word 1, multiply word 0 (335 also words 2 and 3) by it and read `sext(w1[31:16])`, all 716 read the words as integers (397 through shifts and `v_and_or_b32`/`v_lshl_or_b32`/`v_or3_b32`, 319 through `v_cmp_eq_u32` only), and none reads a word undivided as a float; 633 sites also have reads on some paths only, which the census leaves unclassified. | @@ -446,7 +446,7 @@ How the generated SPIR-V expects the runtime to work: | Sum of absolute differences (`v_sad_u8`, `v_sad_hi_u8`, `v_sad_u16`, `v_sad_u32`, `v_msad_u8`) | Unsigned, wrapping at 32 bits, with ABSDIFF(x, y) = `UMax − UMin`: `v_sad_u8` = S2 + the sum over the four bytes; `v_sad_hi_u8` = (that byte sum << 16) + S2; `v_sad_u16` = S2 + the sum over the two halves; `v_sad_u32` = \ \| S0 − S1\ \| + S2; `v_msad_u8` skips a byte where S1's byte is 0. `clamp` raises `Unsupported`: the ISA pseudocode doesn't say what it does to these ops. Source: RDNA2 ISA VOP3 opcodes 346–349 and 369 (pseudocode re-read for this row). CPU-checked by `tests/semantic/test_alu_sad.py` (#544): a 9×9 grid of edge words per op, 40 seeded cases, masked bytes, an SGPR source, `clamp` rejected; the PR also reports a 300-case differential run per op with 0 mismatches. None of them is in the translated corpus, and none is GPU-checked. **Hardware-verified on RDNA2** (`gfx1035`, wave32 and wave64 via `tools/int_hw_probe.py --oracle both`, SHADER-137). Measured on native gfx1036 (AMD Radeon Graphics, RDNA2) through tools/hw_oracle across edge byte/half patterns, zero masks, and wrap cases: all match the ISA reference with 0 mismatches. | | Quad-byte SAD 64-bit source operands | The GFX10.3 `null` operand supplies zero for the 64-bit input window in all three quad-byte SAD operations and for the 64-bit addend of the two packed forms. Confirmed with LLVM gfx1030 assembly and scalar byte-difference references in `tests/semantic/test_alu_qsad.py` (`test_null_pixel_source_and_null_accumulator`) and `tests/semantic/test_alu_mqsad_u32.py` (`test_null_pixel_source`). | | `v_mqsad_u32_u8` | Four masked byte-SADs with full 32-bit accumulators: D[k] = S2[k] + `v_msad_u8` of the 32-bit window S0[8k+31:8k] of the 64-bit S0 against S1, wrapping at 32 bits (S2 and D are four VGPRs). Every source is read before the first write; `clamp` raises `Unsupported`. Source: RDNA ISA pseudocode. CPU-checked by `tests/semantic/test_alu_mqsad_u32.py`. **Hardware-verified on RDNA2** (`gfx1035`, wave32 and wave64 via `tools/int_hw_probe.py --oracle both`, SHADER-137). Measured on native gfx1036 (AMD Radeon Graphics, RDNA2) through tools/hw_oracle across 64-bit sliding window and masked byte values against the 32-bit accumulators: bit-exact with the ISA reference. | -| `s_sext_i32_i8`, `s_sext_i32_i16`, `s_flbit_i32` | The first two sign-extend the low byte or the low half of S0 to 32 bits (`OpBitFieldSExtract`). `s_flbit_i32` counts how many bits in a row from the MSB equal the sign bit, and gives −1 when all bits are the same (0 and −1); it is the scalar form of `v_ffbh_i32` and goes through the same code. None of the three writes SCC. Source: RDNA2 ISA SOP1 opcodes 23, 25 and 26. CPU-checked by `tests/semantic/test_salu_sext_flbit.py` (#549): edge words with SCC starting at 0 and at 1, and 30 seeded values with long runs of sign bits. Not in the translated corpus, not GPU-checked. **Hardware-verified on RDNA2** (`gfx1035`, wave32 and wave64 via `tools/int_hw_probe.py --oracle both`, SHADER-137, SCC kept). Measured on native gfx1036 (AMD Radeon Graphics, RDNA2) through tools/hw_oracle and tools/salu_diff.py (500 programs, --oracle translator,hw): 500 pass, 0 mismatches against the reference; confirmed s_flbit_i32 gives 0xFFFFFFFF for 0 and -1. | +| `s_sext_i32_i8`, `s_sext_i32_i16`, `s_flbit_i32` | The first two sign-extend the low byte or the low half of S0 to 32 bits (`OpBitFieldSExtract`). `s_flbit_i32` counts how many bits in a row from the MSB equal the sign bit, and gives −1 when all bits are the same (0 and −1); it is the scalar form of `v_ffbh_i32` and goes through the same code. None of the three writes SCC. Source: RDNA2 ISA SOP1 opcodes 23, 25 and 26. CPU-checked by `tests/semantic/test_salu_sext_flbit.py` (#549): edge words with SCC starting at 0 and at 1, and 30 seeded values with long runs of sign bits. Not in the translated corpus. `s_sext_i32_i8` and `s_flbit_i32` are GPU-checked on run-time operands by `runtime/test/shaders/cs_w32_salu_ext.asm` (exact on an RTX 4070 Ti, NVIDIA 620.70.06, Linux, and on llvmpipe). **Hardware-verified on RDNA2** (`gfx1035`, wave32 and wave64 via `tools/int_hw_probe.py --oracle both`, SHADER-137, SCC kept). Measured on native gfx1036 (AMD Radeon Graphics, RDNA2) through tools/hw_oracle and tools/salu_diff.py (500 programs, --oracle translator,hw): 500 pass, 0 mismatches against the reference; confirmed s_flbit_i32 gives 0xFFFFFFFF for 0 and -1. | | `v_lerp_u8` | Per byte i: `D.b[i] = (S0.b[i] + S1.b[i] + (S2.b[i] & 1)) >> 1`, an unsigned average where bit 0 of S2's byte decides whether 0.5 rounds up. The translator uses the per-byte identity `x + y = 2*(x & y) + (x ^ y)`. It clears each byte's low bit before shifting, then adds the rounding bit only to an odd sum. Each result fits in one byte, so the packed additions do not carry across bytes. The 9-bit sum shifted right by 1 fits back in its byte, so nothing carries between bytes. `clamp` raises `Unsupported` (the ISA doesn't define it for this op). Source: RDNA2 ISA VOP3 opcode 333. CPU-checked by `tests/semantic/test_alu_lerp_u8.py` (#577): a 9×9×5 grid of edge and rounding words, 40 seeded cases, an SGPR source with an inline S2, `clamp` rejected. The synthetic `tests/semantic/fixtures/lerp_packed_bytes.asm` gives exact words across a 64x64 draw on an RTX 3070 (NVIDIA 591.86). Not in the translated corpus, not GPU-checked. **Hardware-verified on RDNA2** (`gfx1035`, wave32 and wave64 via `tools/int_hw_probe.py --oracle both`, SHADER-137). Measured on native gfx1036 (AMD Radeon Graphics, RDNA2) through tools/hw_oracle across byte edge values and rounding bit variations: 0 mismatches against the ISA reference. | | Scalar select and pack (`s_cmov_b32`, `s_cmovk_i32`, `s_cmov_b64`, `s_pack_ll/lh/hh_b32_b16`) | `s_cmov_b32` / `s_cmovk_i32`: D = SCC ? S0 : D (`s_cmovk_i32`'s S0 is the 16-bit immediate, sign-extended); SCC is read, not written; the destination must be an SGPR (a lane-mask destination stays `Unsupported`, #210). `s_cmov_b64`: D[63:0] = SCC ? S0[63:0] : D[63:0] on plain 64-bit data pairs (SGPR pair, immediate or `null`), SCC read and not written; a pair that is or has been a lane mask (EXEC, VCC or a mask SGPR) stays `Unsupported` (#210) — conservatively, because a CFG join can drop a register that is a mask on only one path — while 0/-1 EITHER constants are data; selecting a per-lane bit as data would silently return a bool instead of the wave's mask. D[63:0] on plain 64-bit data pairs (SGPR pair, immediate or `null`), SCC read and not written; a pair that is or has been a lane mask stays `Unsupported` (#210). D[63:0], SCC read and not written, on plain 64-bit data pairs (SGPR pair, immediate or `null`); any dword that is or has been a lane mask (EXEC, VCC or a mask SGPR) makes the pair `Unsupported` — conservatively, because a CFG join can drop a register that is a mask on only one path — while 0/-1 EITHER constants are data; selecting a per-lane bit as data would silently return a bool instead of the wave's mask (#210). `s_pack_*`: the low half of D from S0, the high half from S1, the letters naming the half of each (l = 15:0, h = 31:16), S0 first; GFX10 has no `s_pack_hl`; SCC not written. Source: RDNA2 ISA SOP1/SOP2/SOPK and LLVM AMDGPU `SOPInstructions.td` (`S_CMOV_B64 : RDNA2 ISA SOP1/SOP2/SOPK. CPU-checked by `tests/semantic/test_salu_cmov.py` and `test_salu_pack.py`; the translated shaders were run on NVIDIA by reviewers (`s_cmov*`: RDNA2 ISA SOP1/SOP2/SOPK and LLVM AMDGPU [SOPInstructions.td](https://github.com/llvm/llvm-project/blob/2bfedf3338162e2c841a73cd7cd9e98d00add608/llvm/lib/Target/AMDGPU/SOPInstructions.td) (`S_CMOV_B64 : SOP1_64` under `Uses = [SCC]`). CPU-checked by `tests/semantic/test_salu_cmov.py`, `tests/semantic/test_salu_cmov_b64.py` and `test_salu_pack.py`; no corpus count; **not GPU-verified, no corpus count**; the translated shaders were run on NVIDIA by reviewers (`s_cmov_b32/k_i32`: **no corpus count**; Hardware: on native `gfx1036` (Ryzen 9 9950X3D iGPU, Windows 11, driver 26.10.1) `tools/int_hw_probe.py --oracle both --wave both` matches the translator in wave32 and wave64 for all five `salu_cmov_pack` cases and for the 14 `s_cmov_b64` cases (`--group salu_cmov_b64`: GPU-checked for `s_cmov_b32` (`cs_w32_salu64.asm`, SCC = 1 selects S0) and `s_pack_lh_b32_b16` (`cs_w32_int_ext.asm`) on the Radeon iGPU of a Ryzen 9 9950X3D (RDNA2, `gfx1036`, driver 26.10.1) and an RTX 5080 (driver 616.92); `s_cmovk_i32`, `s_cmov_b64` and the other `s_pack_*` forms have no GPU test on main; the translated shaders were also run on NVIDIA by reviewers (`s_cmov_b32/k_i32`: RTX 5090, RTX 4050 and Radeon 740M in #613; `s_pack_*`: RTX 5090 in #449). **Hardware-verified on RDNA2** (`gfx1035`, wave32 and wave64 via `tools/int_hw_probe.py --oracle both`, SHADER-137, SCC kept), and on native gfx1036 (AMD Radeon Graphics, Windows 11, driver 26.10.1) through `tools/hw_oracle`: all five `salu_cmov_pack` cases and the 14 `s_cmov_b64` cases match the translator in wave32 and wave64 (SCC 0 and 1; an SGPR pair, the inline constants -1/-16/64, the literal 0x89abcdef, `null` and the destination itself; SCC = 1 takes S0, 0 keeps D, SCC is never written), `s_cmov_b32` matches under SCC=0 and SCC=1, and `s_pack_ll/lh/hh_b32_b16` is bit-exact on 500 random programs with 0 mismatches (`--oracle translator,hw`). **Hardware-verified on RDNA2** (`gfx1035`, wave32 and wave64 via `tools/int_hw_probe.py --oracle both`, SHADER-137, SCC kept). Also **measured on RDNA2 gfx1036** (Radeon iGPU of a Ryzen 9 9950X3D, Windows 11, driver 26.10.1, `tools/hw_oracle` HIP launcher, rocm-sdk-core clang): `tools/int_hw_probe.py --oracle both --wave both` gives the same words as the translator for all five `salu_cmov_pack` cases in wave32 and wave64, and the 14 `s_cmov_b64` cases of the `salu_cmov_b64` group (`python -I tools/int_hw_probe.py --oracle both --wave both --group salu_cmov_b64`; SCC 0 and 1; source an SGPR pair, the inline constants -1, -16 and 64, the literal 0x89abcdef, `null`, and the destination itself; SCC preset and read back after): SCC preset and read back after) match the translator in wave32 and wave64: SCC = 1 takes S0 (a literal zero-extended, an inline constant sign-extended, `null` gives 0), SCC = 0 keeps D, SCC is never written. Also on `gfx1035` via `int_hw_probe` (SHADER-137, SCC kept), and on `gfx1036` and an RTX 5080 through the fixtures `cs_w32_salu64.asm` (`s_cmov_b32`) and `cs_w32_int_ext.asm` (`s_pack_lh_b32_b16`). `tools/hw_oracle` + `tools/salu_diff.py` verify `s_cmov_b32` under SCC 0/1 and `s_pack_ll/lh/hh_b32_b16` bit-exact on 500 random programs with 0 mismatches. Reviewers ran `s_cmov*` on an RTX 5090, an RTX 4050 and a Radeon 740M (#613) and `s_pack_*` on an RTX 5090 (#449). Measured on native gfx1036 (AMD Radeon Graphics, RDNA2) through tools/hw_oracle and tools/salu_diff.py: s_cmov_b32 verified under SCC=0 and SCC=1 (preserving destination and updating respectively); s_pack_ll/lh/hh_b32_b16 verified bit-exact on 500 random programs with 0 mismatches (--oracle translator,hw). **Not measured on RDNA2.** | | `v_bfi_b32` | `(S0 & S1) \| (~S0 & S2)` (RDNA2 ISA, VOP3 opcode 330). A literal or known same-block SGPR mask of zero or all ones selects S2 or S1 directly. A contiguous mask uses `OpBitFieldInsert` with S1 shifted down by the field offset, since RDNA2 reads the bits in place. For sparse constant masks the translator precomputes the complement. Runtime masks use the full bitwise expression. Checked by the hand-written `bfi_known_mask.asm` and `tests/semantic/test_bfi_known_mask.py`. | diff --git a/docs/testing.md b/docs/testing.md index 46da2eba79..1d1d3ee808 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -336,6 +336,28 @@ on an Apple M3 Max (MoltenVK 1.4.2 and 1.4.3): 17 workgroup shapes from 1 to 102 subgroups, with and without full subgroups and register pressure, all 32 lanes in order. A device whose default isn't the requested size still prints `not available`, and those tests skip. +`cs_w32_salu_ext` runs 38 scalar ALU ops that no other fixture runs: `s_sub_i32`, `s_andn2_b32`, `s_orn2_b32`, +`s_xor_b32`, `s_ashr_i32`, `s_mul_hi_u32`, `s_lshl3_add_u32`, `s_lshl4_add_u32`, `s_pack_ll_b32_b16`, +`s_pack_hh_b32_b16`, `s_abs_i32`, `s_bcnt0_i32_b32`, `s_bitset0_b32`, `s_bitset1_b32`, `s_brev_b32`, `s_flbit_i32`, +`s_flbit_i32_b32`, `s_sext_i32_i8`, the six `s_cmp_*_i32`, `s_cmp_gt_u32`, `s_cmp_le_u32`, `s_bitcmp0_b32`, +`s_bitcmp1_b32`, `s_addk_i32`, `s_mulk_i32`, `s_cmovk_i32`, `s_ashr_i64`, `s_lshl_b64`, `s_lshr_b64`, +`s_bcnt0_i32_b64`, `s_bitset0_b64`, `s_cmov_b64` and `s_ff0_i32_b64`. Its sixteen operand words arrive in `s4..s19` +through `VKC_SGPRS`, so each op reaches the driver as SPIR-V: a scalar op on literals is folded by the translator +(the "Chained scalar constant folding" row of [design.md](design.md)) and only its result is stored. One thread stores +every destination and four words of SCC bits: SCC after each op that writes it, each run on operands that set it +and on operands that clear it; each compare and bit test both ways, the signed and the unsigned ones on words that +tell the two apart; and SCC after each op that must keep it, set to 1 and to 0 in turn before them. The 73 expected +words are literals in `check.py`, derived in the fixture's header, and `tests/test_gpu_salu_ext.py` recomputes them +from the fixture's own instruction lines with the reference of `tools/salu_diff.py`, the model that was compared +with hardware. Both GPU runners compare the whole 80-word heap, the untouched fill after the results included. Run +it alone with `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_salu_ext --require-pass`. +On an RTX 4070 Ti (NVIDIA 620.70.06, Linux) and on llvmpipe (Mesa 26.2.6, LLVM 23.1.4) all 80 words match. Nine +translator rules broken one at a time each failed it on both: `s_ashr_i32` shifting in zeros (word 8), +`s_lshlN_add_u32` taking SCC from the add's carry alone (word 69), `s_abs_i32` negating (word 17), `s_mulk_i32` and +`s_addk_i32` zero-extending their immediate (words 37 and 21), `s_cmovk_i32` ignoring SCC (word 38), the 64-bit +shifts taking their count modulo 32 and `s_ashr_i64` shifting in zeros (word 51), and the 64-bit shifts taking SCC +from the low dword alone (word 72). + `cs_w32_shift64` checks `v_lshlrev_b64`, `v_lshrrev_b64` and `v_ashrrev_i64` with 64 memory-fed cases: eight boundary values crossed with counts 0, 1, 31, 32, 33, 63, 64 and 65. The expected values come from Python integers using the low six count bits, as specified by the [RDNA2 ISA, VOP3 opcodes 767–769](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content). diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py index 34d56ddd02..44214c49eb 100644 --- a/runtime/test/shaders/check.py +++ b/runtime/test/shaders/check.py @@ -391,6 +391,33 @@ def shift64_test(tools, spirv, env=None): USER_SGPRS = [0x4F000000, 0xDEADBEEF, 7, 0xFFFFFFFF] USER_SGPRS_ENV = {"VKC_SGPRS": ",".join(hex(w) for w in USER_SGPRS)} USER_SGPRS_WORDS = USER_SGPRS + [0xEEEEEEEE] * 4 +# cs_w32_salu_ext.asm: the sixteen operand words vk_compute_test puts in s4..s19, and the 73 words the shader stores +# (each derived in its header; tests/test_gpu_salu_ext.py recomputes them with the reference of tools/salu_diff.py). +SALU_EXT_SGPRS = [0x7FFFFFFF, 0x80000000, 0xFFFFFFFF, 0x00000001, 0x12345678, 0xDEADBEEF, 0x0000FF80, 0x00000025, + 0x00000040, 0x00000000, 0x00000001, 0x80000001, 0xFFFF0000, 0xFFFFFFFF, 0x00000000, 0x00000047] +SALU_EXT_WORDS = [ + 0xFFFFFFFF, 0x12345677, 0xCC89A887, 0x00000000, 0x33765778, 0x00000000, 0xCC99E897, 0x00000000, + 0xFC000000, 0x00000000, 0x00000000, 0x12345680, 0x01F3266F, 0x00000011, 0x80000000, 0x00000001, + 0x00000000, 0x12345678, 0x00000008, 0x00000000, 0x80000000, 0x1233D678, 0x7FFFFFFF, 0x0FD5BDEE, + 0xBEEF5678, 0xDEAD1234, 0x1E6A2C48, 0x00000001, 0xFFFFFFFF, 0x0000001F, 0x00000010, 0xFFFFFFFF, + 0x00000000, 0xFFFFFF80, 0x00000078, 0xFFFFFFDF, 0x00000020, 0xC962FC98, 0x12345678, 0xFFFF8000, + 0x00000040, 0x00000000, 0x00000001, 0x80000001, 0xFFFF0000, 0xFFFFFFDF, 0xFFFFFF7F, 0xFFFFFFFF, + 0x00000000, 0x00000020, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x02000000, 0xFF000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000020, 0x00000080, 0x00000080, 0x00000000, 0x00000000, 0x07FFFFFF, + 0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000000, 0x0056D555, 0x000D5555, 0x00555555, + 0x0000015B] +SALU_EXT_HEAP_WORDS = 80 # the 73 results, then words that must keep the harness's fill + + +def salu_ext_test(tools, spirv, env=None): + """cs_w32_salu_ext: 38 scalar ALU ops on the operands of SALU_EXT_SGPRS, every destination and SCC stored. The + whole 80-word heap is compared: the 73 results and the untouched fill after them.""" + child = dict(os.environ if env is None else env, VKC_SGPRS=",".join(f"{w:#x}" for w in SALU_EXT_SGPRS)) + child.setdefault("VKC_SUBGROUP_SIZE", str(subgroup_size(spirv, "cs_w32_salu_ext") or 32)) + expected = SALU_EXT_WORDS + [0xEEEEEEEE] * (SALU_EXT_HEAP_WORDS - len(SALU_EXT_WORDS)) + return dump_test(tools, spirv, "cs_w32_salu_ext", expected, SALU_EXT_HEAP_WORDS, child) + + # cs_fma_fused.asm: single-rounded f32 multiply-adds (and one f16). The operands arrive in s4..s7 so no driver can fold # them; FMA_FUSED are the exact single-rounded words and FMA_SPLIT are the exact split-rounded words (derivations in # the .asm header; out[7] is f16 round-to-odd, never GLSL Fma, so it is always 0x7351). Under --fma khr @@ -1880,6 +1907,7 @@ def main(): results.append((name, compute_test(tools, spirv, name, groups, "dump", expected_words=want))) results.append(("cs_user_sgprs", compute_test(tools, spirv, "cs_user_sgprs", "1", "dump", expected_words=USER_SGPRS_WORDS, env=USER_SGPRS_ENV))) + results.append(("cs_w32_salu_ext", salu_ext_test(tools, spirv))) results.append(("cs_heap_init", compute_test(tools, spirv, "cs_heap_init", "1", "dump", expected_words=HEAP_INIT_EXPECTED, env=heap_init_env()))) results.append(("cs_w32_shift64", shift64_test(tools, spirv))) diff --git a/runtime/test/shaders/cs_w32_salu_ext.asm b/runtime/test/shaders/cs_w32_salu_ext.asm new file mode 100644 index 0000000000..9d74cbd2cb --- /dev/null +++ b/runtime/test/shaders/cs_w32_salu_ext.asm @@ -0,0 +1,516 @@ +; GPU-SALU-EXT: 38 scalar ALU ops on operands that arrive at run time. +; group: 1,1,1 +; rsrc2: 0x80a8 +; mattr: +wavefrontsize32,-wavefrontsize64 +; Twenty user SGPRs: s[0:3] are the output V#, and s4..s19 are sixteen operand words that vk_compute_test seeds +; from VKC_SGPRS (check.py's SALU_EXT_SGPRS), so the translator cannot fold a scalar op as it folds one whose +; operands are literals: +; s4 0x7fffffff s5 0x80000000 s6 0xffffffff s7 1 s8 0x12345678 s9 0xdeadbeef s10 0x0000ff80 +; s11 37 (a count) s[12:13] 0x00000000_00000040 s[14:15] 0x80000001_00000001 +; s[16:17] 0xffffffff_ffff0000 s18 0 s19 71 (a count) +; One thread runs every op and stores 73 words, out[i] at byte 4 * i. A result that is a pair takes two words, low +; first. The values are the RDNA2 ISA's (docs/design.md); tests/test_gpu_salu_ext.py recomputes them from the +; instructions below with the reference of tools/salu_diff.py. +; out[0] s_sub_i32 s32, s4, s5 0xffffffff signed overflow +; out[1] s_sub_i32 s33, s8, s7 0x12345677 +; out[2] s_andn2_b32 s34, s9, s8 0xcc89a887 +; out[3] s_andn2_b32 s35, s8, s6 0x00000000 zero +; out[4] s_orn2_b32 s36, s8, s9 0x33765778 +; out[5] s_orn2_b32 s37, s18, s6 0x00000000 zero +; out[6] s_xor_b32 s38, s8, s9 0xcc99e897 +; out[7] s_xor_b32 s39, s9, s9 0x00000000 zero +; out[8] s_ashr_i32 s40, s5, s11 0xfc000000 the count 37 is taken modulo 32 +; out[9] s_ashr_i32 s41, s7, s11 0x00000000 zero +; out[10] s_lshl3_add_u32 s42, s5, s18 0x00000000 zero, with SCC from the bit shifted out +; out[11] s_lshl3_add_u32 s43, s7, s8 0x12345680 +; out[12] s_lshl4_add_u32 s44, s8, s9 0x01f3266f the 64-bit sum passes 2^32 +; out[13] s_lshl4_add_u32 s45, s7, s7 0x00000011 +; out[14] s_abs_i32 s46, s5 0x80000000 -2^31 stays +; out[15] s_abs_i32 s47, s6 0x00000001 +; out[16] s_abs_i32 s48, s18 0x00000000 zero +; out[17] s_abs_i32 s26, s8 0x12345678 a positive word stays +; out[18] s_bcnt0_i32_b32 s49, s9 0x00000008 +; out[19] s_bcnt0_i32_b32 s50, s6 0x00000000 zero +; out[20] s_addk_i32 s51, 0x1 on a copy of s4 0x80000000 signed overflow +; out[21] s_addk_i32 s52, 0x8000 on a copy of s8 0x1233d678 the immediate is -32768 +; out[22] s_addk_i32 s53, 0xffff on a copy of s5 0x7fffffff the immediate is -1: signed overflow +; out[23] s_mul_hi_u32 s54, s9, s8 0x0fd5bdee +; out[24] s_pack_ll_b32_b16 s55, s8, s9 0xbeef5678 +; out[25] s_pack_hh_b32_b16 s56, s8, s9 0xdead1234 +; out[26] s_brev_b32 s57, s8 0x1e6a2c48 +; out[27] s_flbit_i32 s58, s5 0x00000001 one bit like the sign +; out[28] s_flbit_i32 s59, s6 0xffffffff -1: every bit is the sign +; out[29] s_flbit_i32 s60, s7 0x0000001f +; out[30] s_flbit_i32_b32 s61, s10 0x00000010 +; out[31] s_flbit_i32_b32 s62, s18 0xffffffff -1 for zero +; out[32] s_flbit_i32_b32 s27, s5 0x00000000 the top bit is set +; out[33] s_sext_i32_i8 s63, s10 0xffffff80 +; out[34] s_sext_i32_i8 s64, s8 0x00000078 +; out[35] s_bitset0_b32 s65, s11 on s65 = s6 0xffffffdf bit 37 modulo 32 +; out[36] s_bitset1_b32 s66, s11 on s66 = s18 0x00000020 +; out[37] s_mulk_i32 s67, 0xfffd on s67 = s8 0xc962fc98 times -3 +; out[38] s_cmovk_i32 s68, 0x8000 on s68 = s8 0x12345678 SCC 0: keeps +; out[39] s_cmovk_i32 s69, 0x8000 on s69 = s8 0xffff8000 SCC 1: takes -32768 +; out[40,41] s_cmov_b64 s[70:71], s[14:15] on s70 = s12, s71 = s13 0x00000040 0x00000000 SCC 0: keeps +; out[42,43] s_cmov_b64 s[72:73], s[14:15] on s72 = s12, s73 = s13 0x00000001 0x80000001 SCC 1: takes +; out[44,45] s_bitset0_b64 s[74:75], s11 on s74 = s16, s75 = s17 0xffff0000 0xffffffdf bit 37 +; out[46,47] s_bitset0_b64 s[28:29], s19 on s28 = s6, s29 = s6 0xffffff7f 0xffffffff bit 71 modulo 64 +; out[48] s_ff0_i32_b64 s76, s[16:17] 0x00000000 +; out[49] s_ff0_i32_b64 s77, s[78:79] on s78 = s6, s79 = s10 0x00000020 the first 0 is in the high dword +; out[50] s_ff0_i32_b64 s82, s[80:81] on s80 = s6, s81 = s6 0xffffffff -1: no 0 bit +; out[51,52] s_ashr_i64 s[84:85], s[16:17], s11 0xffffffff 0xffffffff +; out[53,54] s_ashr_i64 s[86:87], s[14:15], s19 0x02000000 0xff000000 the count 71 is taken modulo 64 +; out[55,56] s_ashr_i64 s[88:89], s[12:13], s11 0x00000000 0x00000000 zero +; out[57,58] s_lshl_b64 s[90:91], s[14:15], s11 0x00000000 0x00000020 +; out[59,60] s_lshl_b64 s[92:93], s[14:15], s19 0x00000080 0x00000080 the count 71 is taken modulo 64 +; out[61,62] s_lshl_b64 s[94:95], s[22:23], s11 on s22 = s18, s23 = s5 0x00000000 0x00000000 zero: its one bit leaves +; out[63,64] s_lshr_b64 s[96:97], s[16:17], s11 0x07ffffff 0x00000000 +; out[65,66] s_lshr_b64 s[98:99], s[12:13], s19 0x00000000 0x00000000 zero +; out[67] s_bcnt0_i32_b64 s24, s[16:17] 0x00000010 +; out[68] s_bcnt0_i32_b64 s25, s[80:81] 0x00000000 zero +; out[69] SCC after each of the 23 ops of out[0..22], op n in bit n: 0x0056d555 (set by a signed overflow, +; by a non-zero result, and by the sum of s_lshlN_add_u32 passing 2^32 in 64 bits) +; out[70] SCC of 21 compares and bit tests, in program order from bit 0: 0x000d5555. The eight s_cmp_ forms, +; each on a pair that makes it true and then on one that makes it false: the signed ones tell +; 0x7fffffff from 0x80000000 and -1 from 1 as signed words, s_cmp_gt_u32 and s_cmp_le_u32 the same +; words as unsigned ones, and s_cmp_le_u32 is true once more on equal words. Then s_bitcmp0_b32 on +; bit 37 modulo 32 (set: false) and on bit 1 (clear: true), and s_bitcmp1_b32 on the same two bits. +; out[71] SCC after each of the 24 ops of out[23..50], none of which writes it: 0x00555555. It is set to 1 +; before the first, to 0 before the second and so on in turn, by s_cmp_eq_u32 / s_cmp_lg_u32 of s4 +; with itself; s_cmovk_i32 and s_cmov_b64 read it. +; out[72] SCC after each of the 10 ops of out[51..68], op n in bit n: 0x0000015b (a non-zero result) +; Words 73..79 of the 80-word heap must keep the harness's 0xeeeeeeee. +; Run: VKC_SGPRS= VKC_OUT_WORDS=80 vk_compute_test cs_w32_salu_ext.spv 1 dump, as check.py's +; salu_ext_test does; all 80 words are compared. +s_mov_b32 s100, 0 +s_mov_b32 s101, 0 +s_mov_b32 s102, 0 +s_mov_b32 s103, 0 +s_sub_i32 s32, s4, s5 +s_cselect_b32 s104, 0x1, 0 +s_or_b32 s100, s100, s104 +s_sub_i32 s33, s8, s7 +s_cselect_b32 s104, 0x2, 0 +s_or_b32 s100, s100, s104 +s_andn2_b32 s34, s9, s8 +s_cselect_b32 s104, 0x4, 0 +s_or_b32 s100, s100, s104 +s_andn2_b32 s35, s8, s6 +s_cselect_b32 s104, 0x8, 0 +s_or_b32 s100, s100, s104 +s_orn2_b32 s36, s8, s9 +s_cselect_b32 s104, 0x10, 0 +s_or_b32 s100, s100, s104 +s_orn2_b32 s37, s18, s6 +s_cselect_b32 s104, 0x20, 0 +s_or_b32 s100, s100, s104 +s_xor_b32 s38, s8, s9 +s_cselect_b32 s104, 0x40, 0 +s_or_b32 s100, s100, s104 +s_xor_b32 s39, s9, s9 +s_cselect_b32 s104, 0x80, 0 +s_or_b32 s100, s100, s104 +s_ashr_i32 s40, s5, s11 +s_cselect_b32 s104, 0x100, 0 +s_or_b32 s100, s100, s104 +s_ashr_i32 s41, s7, s11 +s_cselect_b32 s104, 0x200, 0 +s_or_b32 s100, s100, s104 +s_lshl3_add_u32 s42, s5, s18 +s_cselect_b32 s104, 0x400, 0 +s_or_b32 s100, s100, s104 +s_lshl3_add_u32 s43, s7, s8 +s_cselect_b32 s104, 0x800, 0 +s_or_b32 s100, s100, s104 +s_lshl4_add_u32 s44, s8, s9 +s_cselect_b32 s104, 0x1000, 0 +s_or_b32 s100, s100, s104 +s_lshl4_add_u32 s45, s7, s7 +s_cselect_b32 s104, 0x2000, 0 +s_or_b32 s100, s100, s104 +s_abs_i32 s46, s5 +s_cselect_b32 s104, 0x4000, 0 +s_or_b32 s100, s100, s104 +s_abs_i32 s47, s6 +s_cselect_b32 s104, 0x8000, 0 +s_or_b32 s100, s100, s104 +s_abs_i32 s48, s18 +s_cselect_b32 s104, 0x10000, 0 +s_or_b32 s100, s100, s104 +s_abs_i32 s26, s8 +s_cselect_b32 s104, 0x20000, 0 +s_or_b32 s100, s100, s104 +s_bcnt0_i32_b32 s49, s9 +s_cselect_b32 s104, 0x40000, 0 +s_or_b32 s100, s100, s104 +s_bcnt0_i32_b32 s50, s6 +s_cselect_b32 s104, 0x80000, 0 +s_or_b32 s100, s100, s104 +s_mov_b32 s51, s4 +s_addk_i32 s51, 0x1 +s_cselect_b32 s104, 0x100000, 0 +s_or_b32 s100, s100, s104 +s_mov_b32 s52, s8 +s_addk_i32 s52, 0x8000 +s_cselect_b32 s104, 0x200000, 0 +s_or_b32 s100, s100, s104 +s_mov_b32 s53, s5 +s_addk_i32 s53, 0xffff +s_cselect_b32 s104, 0x400000, 0 +s_or_b32 s100, s100, s104 +s_cmp_eq_i32 s5, s5 +s_cselect_b32 s104, 0x1, 0 +s_or_b32 s101, s101, s104 +s_cmp_eq_i32 s4, s5 +s_cselect_b32 s104, 0x2, 0 +s_or_b32 s101, s101, s104 +s_cmp_lg_i32 s4, s5 +s_cselect_b32 s104, 0x4, 0 +s_or_b32 s101, s101, s104 +s_cmp_lg_i32 s6, s6 +s_cselect_b32 s104, 0x8, 0 +s_or_b32 s101, s101, s104 +s_cmp_gt_i32 s4, s5 +s_cselect_b32 s104, 0x10, 0 +s_or_b32 s101, s101, s104 +s_cmp_gt_i32 s6, s7 +s_cselect_b32 s104, 0x20, 0 +s_or_b32 s101, s101, s104 +s_cmp_ge_i32 s5, s5 +s_cselect_b32 s104, 0x40, 0 +s_or_b32 s101, s101, s104 +s_cmp_ge_i32 s6, s7 +s_cselect_b32 s104, 0x80, 0 +s_or_b32 s101, s101, s104 +s_cmp_lt_i32 s6, s7 +s_cselect_b32 s104, 0x100, 0 +s_or_b32 s101, s101, s104 +s_cmp_lt_i32 s4, s5 +s_cselect_b32 s104, 0x200, 0 +s_or_b32 s101, s101, s104 +s_cmp_le_i32 s5, s4 +s_cselect_b32 s104, 0x400, 0 +s_or_b32 s101, s101, s104 +s_cmp_le_i32 s7, s6 +s_cselect_b32 s104, 0x800, 0 +s_or_b32 s101, s101, s104 +s_cmp_gt_u32 s6, s7 +s_cselect_b32 s104, 0x1000, 0 +s_or_b32 s101, s101, s104 +s_cmp_gt_u32 s4, s5 +s_cselect_b32 s104, 0x2000, 0 +s_or_b32 s101, s101, s104 +s_cmp_le_u32 s7, s6 +s_cselect_b32 s104, 0x4000, 0 +s_or_b32 s101, s101, s104 +s_cmp_le_u32 s5, s4 +s_cselect_b32 s104, 0x8000, 0 +s_or_b32 s101, s101, s104 +s_cmp_le_u32 s8, s8 +s_cselect_b32 s104, 0x10000, 0 +s_or_b32 s101, s101, s104 +s_bitcmp0_b32 s8, s11 +s_cselect_b32 s104, 0x20000, 0 +s_or_b32 s101, s101, s104 +s_bitcmp0_b32 s8, s7 +s_cselect_b32 s104, 0x40000, 0 +s_or_b32 s101, s101, s104 +s_bitcmp1_b32 s8, s11 +s_cselect_b32 s104, 0x80000, 0 +s_or_b32 s101, s101, s104 +s_bitcmp1_b32 s8, s7 +s_cselect_b32 s104, 0x100000, 0 +s_or_b32 s101, s101, s104 +s_cmp_eq_u32 s4, s4 +s_mul_hi_u32 s54, s9, s8 +s_cselect_b32 s104, 0x1, 0 +s_or_b32 s102, s102, s104 +s_cmp_lg_u32 s4, s4 +s_pack_ll_b32_b16 s55, s8, s9 +s_cselect_b32 s104, 0x2, 0 +s_or_b32 s102, s102, s104 +s_cmp_eq_u32 s4, s4 +s_pack_hh_b32_b16 s56, s8, s9 +s_cselect_b32 s104, 0x4, 0 +s_or_b32 s102, s102, s104 +s_cmp_lg_u32 s4, s4 +s_brev_b32 s57, s8 +s_cselect_b32 s104, 0x8, 0 +s_or_b32 s102, s102, s104 +s_cmp_eq_u32 s4, s4 +s_flbit_i32 s58, s5 +s_cselect_b32 s104, 0x10, 0 +s_or_b32 s102, s102, s104 +s_cmp_lg_u32 s4, s4 +s_flbit_i32 s59, s6 +s_cselect_b32 s104, 0x20, 0 +s_or_b32 s102, s102, s104 +s_cmp_eq_u32 s4, s4 +s_flbit_i32 s60, s7 +s_cselect_b32 s104, 0x40, 0 +s_or_b32 s102, s102, s104 +s_cmp_lg_u32 s4, s4 +s_flbit_i32_b32 s61, s10 +s_cselect_b32 s104, 0x80, 0 +s_or_b32 s102, s102, s104 +s_cmp_eq_u32 s4, s4 +s_flbit_i32_b32 s62, s18 +s_cselect_b32 s104, 0x100, 0 +s_or_b32 s102, s102, s104 +s_cmp_lg_u32 s4, s4 +s_flbit_i32_b32 s27, s5 +s_cselect_b32 s104, 0x200, 0 +s_or_b32 s102, s102, s104 +s_cmp_eq_u32 s4, s4 +s_sext_i32_i8 s63, s10 +s_cselect_b32 s104, 0x400, 0 +s_or_b32 s102, s102, s104 +s_cmp_lg_u32 s4, s4 +s_sext_i32_i8 s64, s8 +s_cselect_b32 s104, 0x800, 0 +s_or_b32 s102, s102, s104 +s_mov_b32 s65, s6 +s_cmp_eq_u32 s4, s4 +s_bitset0_b32 s65, s11 +s_cselect_b32 s104, 0x1000, 0 +s_or_b32 s102, s102, s104 +s_mov_b32 s66, s18 +s_cmp_lg_u32 s4, s4 +s_bitset1_b32 s66, s11 +s_cselect_b32 s104, 0x2000, 0 +s_or_b32 s102, s102, s104 +s_mov_b32 s67, s8 +s_cmp_eq_u32 s4, s4 +s_mulk_i32 s67, 0xfffd +s_cselect_b32 s104, 0x4000, 0 +s_or_b32 s102, s102, s104 +s_mov_b32 s68, s8 +s_cmp_lg_u32 s4, s4 +s_cmovk_i32 s68, 0x8000 +s_cselect_b32 s104, 0x8000, 0 +s_or_b32 s102, s102, s104 +s_mov_b32 s69, s8 +s_cmp_eq_u32 s4, s4 +s_cmovk_i32 s69, 0x8000 +s_cselect_b32 s104, 0x10000, 0 +s_or_b32 s102, s102, s104 +s_mov_b32 s70, s12 +s_mov_b32 s71, s13 +s_cmp_lg_u32 s4, s4 +s_cmov_b64 s[70:71], s[14:15] +s_cselect_b32 s104, 0x20000, 0 +s_or_b32 s102, s102, s104 +s_mov_b32 s72, s12 +s_mov_b32 s73, s13 +s_cmp_eq_u32 s4, s4 +s_cmov_b64 s[72:73], s[14:15] +s_cselect_b32 s104, 0x40000, 0 +s_or_b32 s102, s102, s104 +s_mov_b32 s74, s16 +s_mov_b32 s75, s17 +s_cmp_lg_u32 s4, s4 +s_bitset0_b64 s[74:75], s11 +s_cselect_b32 s104, 0x80000, 0 +s_or_b32 s102, s102, s104 +s_mov_b32 s28, s6 +s_mov_b32 s29, s6 +s_cmp_eq_u32 s4, s4 +s_bitset0_b64 s[28:29], s19 +s_cselect_b32 s104, 0x100000, 0 +s_or_b32 s102, s102, s104 +s_cmp_lg_u32 s4, s4 +s_ff0_i32_b64 s76, s[16:17] +s_cselect_b32 s104, 0x200000, 0 +s_or_b32 s102, s102, s104 +s_mov_b32 s78, s6 +s_mov_b32 s79, s10 +s_cmp_eq_u32 s4, s4 +s_ff0_i32_b64 s77, s[78:79] +s_cselect_b32 s104, 0x400000, 0 +s_or_b32 s102, s102, s104 +s_mov_b32 s80, s6 +s_mov_b32 s81, s6 +s_cmp_lg_u32 s4, s4 +s_ff0_i32_b64 s82, s[80:81] +s_cselect_b32 s104, 0x800000, 0 +s_or_b32 s102, s102, s104 +s_ashr_i64 s[84:85], s[16:17], s11 +s_cselect_b32 s104, 0x1, 0 +s_or_b32 s103, s103, s104 +s_ashr_i64 s[86:87], s[14:15], s19 +s_cselect_b32 s104, 0x2, 0 +s_or_b32 s103, s103, s104 +s_ashr_i64 s[88:89], s[12:13], s11 +s_cselect_b32 s104, 0x4, 0 +s_or_b32 s103, s103, s104 +s_lshl_b64 s[90:91], s[14:15], s11 +s_cselect_b32 s104, 0x8, 0 +s_or_b32 s103, s103, s104 +s_lshl_b64 s[92:93], s[14:15], s19 +s_cselect_b32 s104, 0x10, 0 +s_or_b32 s103, s103, s104 +s_mov_b32 s22, s18 +s_mov_b32 s23, s5 +s_lshl_b64 s[94:95], s[22:23], s11 +s_cselect_b32 s104, 0x20, 0 +s_or_b32 s103, s103, s104 +s_lshr_b64 s[96:97], s[16:17], s11 +s_cselect_b32 s104, 0x40, 0 +s_or_b32 s103, s103, s104 +s_lshr_b64 s[98:99], s[12:13], s19 +s_cselect_b32 s104, 0x80, 0 +s_or_b32 s103, s103, s104 +s_bcnt0_i32_b64 s24, s[16:17] +s_cselect_b32 s104, 0x100, 0 +s_or_b32 s103, s103, s104 +s_bcnt0_i32_b64 s25, s[80:81] +s_cselect_b32 s104, 0x200, 0 +s_or_b32 s103, s103, s104 +v_mov_b32_e32 v21, 0 +v_mov_b32_e32 v20, s32 +buffer_store_dword v20, v21, s[0:3], 0 offen +v_mov_b32_e32 v20, s33 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:4 +v_mov_b32_e32 v20, s34 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:8 +v_mov_b32_e32 v20, s35 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:12 +v_mov_b32_e32 v20, s36 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:16 +v_mov_b32_e32 v20, s37 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:20 +v_mov_b32_e32 v20, s38 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:24 +v_mov_b32_e32 v20, s39 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:28 +v_mov_b32_e32 v20, s40 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:32 +v_mov_b32_e32 v20, s41 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:36 +v_mov_b32_e32 v20, s42 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:40 +v_mov_b32_e32 v20, s43 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:44 +v_mov_b32_e32 v20, s44 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:48 +v_mov_b32_e32 v20, s45 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:52 +v_mov_b32_e32 v20, s46 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:56 +v_mov_b32_e32 v20, s47 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:60 +v_mov_b32_e32 v20, s48 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:64 +v_mov_b32_e32 v20, s26 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:68 +v_mov_b32_e32 v20, s49 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:72 +v_mov_b32_e32 v20, s50 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:76 +v_mov_b32_e32 v20, s51 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:80 +v_mov_b32_e32 v20, s52 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:84 +v_mov_b32_e32 v20, s53 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:88 +v_mov_b32_e32 v20, s54 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:92 +v_mov_b32_e32 v20, s55 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:96 +v_mov_b32_e32 v20, s56 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:100 +v_mov_b32_e32 v20, s57 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:104 +v_mov_b32_e32 v20, s58 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:108 +v_mov_b32_e32 v20, s59 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:112 +v_mov_b32_e32 v20, s60 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:116 +v_mov_b32_e32 v20, s61 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:120 +v_mov_b32_e32 v20, s62 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:124 +v_mov_b32_e32 v20, s27 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:128 +v_mov_b32_e32 v20, s63 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:132 +v_mov_b32_e32 v20, s64 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:136 +v_mov_b32_e32 v20, s65 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:140 +v_mov_b32_e32 v20, s66 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:144 +v_mov_b32_e32 v20, s67 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:148 +v_mov_b32_e32 v20, s68 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:152 +v_mov_b32_e32 v20, s69 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:156 +v_mov_b32_e32 v20, s70 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:160 +v_mov_b32_e32 v20, s71 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:164 +v_mov_b32_e32 v20, s72 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:168 +v_mov_b32_e32 v20, s73 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:172 +v_mov_b32_e32 v20, s74 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:176 +v_mov_b32_e32 v20, s75 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:180 +v_mov_b32_e32 v20, s28 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:184 +v_mov_b32_e32 v20, s29 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:188 +v_mov_b32_e32 v20, s76 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:192 +v_mov_b32_e32 v20, s77 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:196 +v_mov_b32_e32 v20, s82 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:200 +v_mov_b32_e32 v20, s84 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:204 +v_mov_b32_e32 v20, s85 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:208 +v_mov_b32_e32 v20, s86 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:212 +v_mov_b32_e32 v20, s87 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:216 +v_mov_b32_e32 v20, s88 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:220 +v_mov_b32_e32 v20, s89 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:224 +v_mov_b32_e32 v20, s90 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:228 +v_mov_b32_e32 v20, s91 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:232 +v_mov_b32_e32 v20, s92 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:236 +v_mov_b32_e32 v20, s93 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:240 +v_mov_b32_e32 v20, s94 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:244 +v_mov_b32_e32 v20, s95 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:248 +v_mov_b32_e32 v20, s96 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:252 +v_mov_b32_e32 v20, s97 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:256 +v_mov_b32_e32 v20, s98 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:260 +v_mov_b32_e32 v20, s99 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:264 +v_mov_b32_e32 v20, s24 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:268 +v_mov_b32_e32 v20, s25 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:272 +v_mov_b32_e32 v20, s100 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:276 +v_mov_b32_e32 v20, s101 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:280 +v_mov_b32_e32 v20, s102 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:284 +v_mov_b32_e32 v20, s103 +buffer_store_dword v20, v21, s[0:3], 0 offen offset:288 +s_endpgm diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py index 8f17a4028b..8798cdbdc2 100644 --- a/scripts/run_gpu_tests.py +++ b/scripts/run_gpu_tests.py @@ -35,6 +35,7 @@ pick_build_dir, start_failure, table_fetch_test, texture_gradient_a16_test, texture_mip_test) from check import SIGNED_MIP_TEST, UINT_MIP_TEST from check import cbv_modulate_test +from check import salu_ext_test # 38 scalar ALU ops on operands seeded through VKC_SGPRS from check import HEAP_INIT_EXPECTED, heap_init_env # cs_heap_init: vk_compute_test's VKC_HEAP_INIT from check import shift64_test # dynamic 64-bit vector shifts and overlapping destinations from check import judged_words, words_match # dump words not judged on some devices (cs_signed_zero_nan) @@ -1109,6 +1110,10 @@ def run_suite(a, work: str) -> int: vals = words[:len(USER_SGPRS_WORDS)] if words else [] results.append((name,) + compute_result(rc, msg, rc == 0 and vals == USER_SGPRS_WORDS, " ".join(hex(x) for x in vals) if vals else msg)) + elif name == "cs_w32_salu_ext": + detail = salu_ext_test(a.build, spirv_dir, cs_env) + results.append((name, None if isinstance(detail, Skip) else not detail, + detail or "80 words exact (73 results of 38 scalar ops and the untouched fill)")) elif name == "cs_f64_add": rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=cs_env) if rc == 77: # Float64, or Int64 where the module declares both: quote whichever it names diff --git a/tests/test_gpu_salu_ext.py b/tests/test_gpu_salu_ext.py new file mode 100644 index 0000000000..8ad5e87e53 --- /dev/null +++ b/tests/test_gpu_salu_ext.py @@ -0,0 +1,270 @@ +"""GPU-SALU-EXT: the scalar fixture's expected words against the ISA reference, its readback and the runner verdicts, +without needing a GPU.""" +import contextlib +import io +from pathlib import Path +import re +import struct +import sys +import tempfile +from types import SimpleNamespace +import unittest +from unittest.mock import patch + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT / "scripts")) +sys.path.insert(0, str(ROOT / "tools")) +import run_gpu_tests as rgt +import check +import salu_diff + +FIXTURE = ROOT / "runtime" / "test" / "shaders" / "cs_w32_salu_ext.asm" +HEAP = 80 +# The ops the fixture is for: none of them is run by another fixture in runtime/test/shaders. +OPS = ("s_sub_i32", "s_andn2_b32", "s_orn2_b32", "s_xor_b32", "s_ashr_i32", "s_mul_hi_u32", "s_lshl3_add_u32", + "s_lshl4_add_u32", "s_pack_ll_b32_b16", "s_pack_hh_b32_b16", "s_abs_i32", "s_bcnt0_i32_b32", "s_bitset0_b32", + "s_bitset1_b32", "s_brev_b32", "s_flbit_i32", "s_flbit_i32_b32", "s_sext_i32_i8", "s_cmp_eq_i32", + "s_cmp_lg_i32", "s_cmp_gt_i32", "s_cmp_ge_i32", "s_cmp_lt_i32", "s_cmp_le_i32", "s_cmp_gt_u32", "s_cmp_le_u32", + "s_bitcmp0_b32", "s_bitcmp1_b32", "s_addk_i32", "s_mulk_i32", "s_cmovk_i32", "s_ashr_i64", "s_lshl_b64", + "s_lshr_b64", "s_bcnt0_i32_b64", "s_bitset0_b64", "s_cmov_b64", "s_ff0_i32_b64") +# What the fixture uses besides them: copies, the SCC it sets before an op that must keep it, and the SCC capture. +HELPERS = ("s_mov_b32", "s_cmp_eq_u32", "s_cmp_lg_u32", "s_cselect_b32", "s_or_b32") + + +def fixture(): + """(header lines, the scalar program, the SGPRs stored in order, the offsets they are stored at).""" + lines = [ln.strip() for ln in FIXTURE.read_text(encoding="utf-8").splitlines()] + header = [ln for ln in lines if ln.startswith(";")] + code = [ln for ln in lines if ln and not ln.startswith(";")] + first_store = code.index("v_mov_b32_e32 v21, 0") + registers, offsets = [], [] + stores = code[first_store + 1:-1] + for move, store in zip(stores[0::2], stores[1::2]): + registers.append(int(re.fullmatch(r"v_mov_b32_e32 v20, s(\d+)", move).group(1))) + offset = re.fullmatch(r"buffer_store_dword v20, v21, s\[0:3\], 0 offen(?: offset:(\d+))?", store).group(1) + offsets.append(int(offset or 0)) + return header, code[:first_store], registers, offsets, code[-1] + + +def reference_words(program, registers, seeds=None): + """The words tools/salu_diff.py's reference gives for the stored SGPRs: the program runs after `s_mov_b32` of + the sixteen operand words into s4..s19, which is how the reference takes what the GPU run gets from VKC_SGPRS.""" + seeds = check.SALU_EXT_SGPRS if seeds is None else seeds + start = [f"s_mov_b32 s{4 + n}, {word:#x}" for n, word in enumerate(seeds)] + words = [] + for at in range(0, len(registers), 4): # the reference exports four words a run, v8..v11 + chunk = registers[at:at + 4] + watch = [f"v_mov_b32 v{8 + n}, s{register}" for n, register in enumerate(chunk)] + words += salu_diff.reference(start + program + watch)[:len(chunk)] + return words + + +class SaluExtOracle(unittest.TestCase): + def test_expected_words_are_the_reference_s(self): + _, program, registers, _, _ = fixture() + self.assertEqual(len(registers), 73) + self.assertEqual(len(set(registers)), 73) + self.assertEqual(reference_words(program, registers), check.SALU_EXT_WORDS) + + def test_the_words_depend_on_the_operands(self): + """With other operand words the reference gives other results, so the literals are not a property of the + program alone: a run that lost VKC_SGPRS cannot pass.""" + _, program, registers, _, _ = fixture() + zeros = reference_words(program, registers, [0] * 16) + self.assertNotEqual(zeros, check.SALU_EXT_WORDS) + self.assertGreater(sum(a != b for a, b in zip(zeros, check.SALU_EXT_WORDS)), 40) + + def test_every_op_is_run_and_nothing_unmodelled(self): + _, program, _, _, _ = fixture() + used = [ln.split(" ", 1)[0] for ln in program] + self.assertEqual(sorted(set(used) - set(HELPERS)), sorted(OPS)) + self.assertEqual(len(OPS), 38) + for op in set(used): + self.assertIn(op, salu_diff.OPS, op) + + def test_both_values_of_scc_are_seen_for_every_op_that_writes_it(self): + """Each op that writes SCC is run on operands that make it 1 and on operands that make it 0, and each + compare both ways; the bit captured right after the op is what is checked.""" + _, program, _, _, _ = fixture() + start = [f"s_mov_b32 s{4 + n}, {word:#x}" for n, word in enumerate(check.SALU_EXT_SGPRS)] + seen = {} + for at, line in enumerate(program): + op = line.split(" ", 1)[0] + if op not in OPS or not salu_diff.writes_scc(op): + continue + self.assertRegex(program[at + 1], r"s_cselect_b32 s104, 0x[0-9a-f]+, 0", line) + scc = salu_diff.reference(start + program[:at + 1] + ["s_cselect_b32 s30, 1, 0", "v_mov_b32 v8, s30"])[0] + seen.setdefault(op, set()).add(scc) + writers = [op for op in OPS if salu_diff.writes_scc(op)] + self.assertEqual(len(writers), 24) + self.assertEqual({op: seen.get(op) for op in writers}, {op: {0, 1} for op in writers}) + + def test_scc_is_set_both_ways_before_the_ops_that_keep_it(self): + _, program, _, _, _ = fixture() + keepers = [op for op in OPS if not salu_diff.writes_scc(op)] + self.assertEqual(len(keepers), 14) + before = {} + for at, line in enumerate(program): + op = line.split(" ", 1)[0] + if op in keepers: + self.assertIn(program[at - 1], ("s_cmp_eq_u32 s4, s4", "s_cmp_lg_u32 s4, s4"), line) + before.setdefault(op, []).append(program[at - 1]) + self.assertEqual(sorted(before), sorted(keepers)) + # The two that read SCC run once with it set and once with it clear. + for op in ("s_cmovk_i32", "s_cmov_b64"): + self.assertEqual(sorted(before[op]), ["s_cmp_eq_u32 s4, s4", "s_cmp_lg_u32 s4, s4"]) + + def test_values_worked_out_by_hand(self): + """A word of each kind, by the SGPR it is stored from, so the check does not depend on the store order.""" + _, _, registers, _, _ = fixture() + word = dict(zip(registers, check.SALU_EXT_WORDS)) + pair = lambda low: word[low] | word[low + 1] << 32 # noqa: E731 + self.assertEqual(word[32], 0xFFFFFFFF) # 0x7fffffff - 0x80000000, wrapped + self.assertEqual(word[40], 0xFC000000) # 0x80000000 >> (37 & 31), arithmetic + self.assertEqual((word[42], word[44]), (0, (0x123456780 + 0xDEADBEEF) & 0xFFFFFFFF)) + self.assertEqual((word[46], word[47], word[48], word[26]), (0x80000000, 1, 0, 0x12345678)) # s_abs_i32 + self.assertEqual((word[51], word[52], word[53]), (0x80000000, 0x12345678 - 0x8000, 0x7FFFFFFF)) + self.assertEqual(word[54], (0xDEADBEEF * 0x12345678) >> 32) + self.assertEqual((word[55], word[56]), (0xBEEF5678, 0xDEAD1234)) + self.assertEqual(word[57], int(f"{0x12345678:032b}"[::-1], 2)) + self.assertEqual((word[58], word[59], word[60]), (1, 0xFFFFFFFF, 31)) # s_flbit_i32 + self.assertEqual((word[61], word[62], word[27]), (16, 0xFFFFFFFF, 0)) # s_flbit_i32_b32 + self.assertEqual(word[67], (0x12345678 * -3) & 0xFFFFFFFF) + # The two ops that read SCC: the run with SCC set takes its source, the other keeps what was there. + _, program, _, _, _ = fixture() + took = {line: program[program.index(line) - 1] == "s_cmp_eq_u32 s4, s4" + for line in ("s_cmovk_i32 s68, 0x8000", "s_cmovk_i32 s69, 0x8000", + "s_cmov_b64 s[70:71], s[14:15]", "s_cmov_b64 s[72:73], s[14:15]")} + self.assertEqual(sorted(took.values()), [False, False, True, True]) + self.assertNotEqual(took["s_cmovk_i32 s68, 0x8000"], took["s_cmovk_i32 s69, 0x8000"]) + self.assertNotEqual(took["s_cmov_b64 s[70:71], s[14:15]"], took["s_cmov_b64 s[72:73], s[14:15]"]) + for register in (68, 69): + self.assertEqual(word[register], + 0xFFFF8000 if took[f"s_cmovk_i32 s{register}, 0x8000"] else 0x12345678) + for low in (70, 72): + self.assertEqual(pair(low), 0x8000000100000001 + if took[f"s_cmov_b64 s[{low}:{low + 1}], s[14:15]"] else 0x40) + self.assertEqual(pair(74), 0xFFFFFFFFFFFF0000 & ~(1 << 37)) + self.assertEqual(pair(28), 0xFFFFFFFFFFFFFFFF & ~(1 << (71 & 63))) + self.assertEqual((word[76], word[77], word[82]), (0, 32, 0xFFFFFFFF)) # s_ff0_i32_b64 + value, mask = 0x8000000100000001, (1 << 64) - 1 + self.assertEqual(pair(84), mask) # a negative pair >> 37 + self.assertEqual(pair(86), ((value - (1 << 64)) >> (71 & 63)) & mask) + self.assertEqual((pair(88), pair(94), pair(98)), (0, 0, 0)) # the three zero results + self.assertEqual((pair(90), pair(92)), ((value << 37) & mask, (value << 7) & mask)) + self.assertEqual(pair(96), 0xFFFFFFFFFFFF0000 >> 37) + self.assertEqual((word[24], word[25]), (16, 0)) # zeros of the two pairs + # SCC words: 23 results of which 13 set it, 21 compares, 24 kept values in turn from 1, ten 64-bit results. + self.assertEqual([bin(word[r]).count("1") for r in (100, 101, 102, 103)], [13, 11, 12, 6]) + self.assertEqual(word[102], 0x555555) + + +class SaluExtFixture(unittest.TestCase): + def test_header_and_layout(self): + header, program, registers, offsets, last = fixture() + self.assertIn("; group: 1,1,1", header) + self.assertIn("; rsrc2: 0x80a8", header) # twenty user SGPRs: the V# and s4..s19 + self.assertEqual(offsets, [4 * n for n in range(73)]) + self.assertEqual(last, "s_endpgm") + self.assertEqual(registers[-4:], [100, 101, 102, 103]) + self.assertEqual(program[:4], [f"s_mov_b32 s{n}, 0" for n in (100, 101, 102, 103)]) + # No operand is a literal: every source of the 38 ops is an SGPR, apart from the immediate of the three SOPK + # forms, whose other operand is the register they change. + for line in program: + op, _, rest = line.partition(" ") + if op not in OPS: + continue + sources = rest.split(", ")[1:] if not op.startswith(("s_cmp_", "s_bitcmp")) else rest.split(", ") + if op in ("s_addk_i32", "s_mulk_i32", "s_cmovk_i32"): + self.assertRegex(sources[0], r"0x[0-9a-f]+", line) + continue + for source in sources: + self.assertRegex(source, r"s\d+|s\[\d+:\d+\]", line) + # The header's table names every stored word with the value check.py expects. + table = "\n".join(header) + for register in (32, 40, 54, 67, 82, 25): + index = registers.index(register) + self.assertRegex(table, rf"out\[{index}\] +s_\w+ s{register}, .*0x{check.SALU_EXT_WORDS[index]:08x}") + for low in (70, 84, 98): + index = registers.index(low) + self.assertRegex(table, rf"out\[{index},{index + 1}\] +s_\w+ s\[{low}:{low + 1}\], .*" + rf"0x{check.SALU_EXT_WORDS[index]:08x} 0x{check.SALU_EXT_WORDS[index + 1]:08x}") + for remark, line in (("takes", "s_cmp_eq_u32 s4, s4"), ("keeps", "s_cmp_lg_u32 s4, s4")): + for op in ("s_cmovk_i32 s68, 0x8000", "s_cmovk_i32 s69, 0x8000"): + said = next(ln for ln in header if op in ln) + self.assertEqual(remark in said, program[program.index(op) - 1] == line, said) + for word in check.SALU_EXT_WORDS[-4:]: + self.assertIn(f"0x{word:08x}", table) + + +class SaluExtReadback(unittest.TestCase): + def run_readback(self, mutate=None, code=0, output="", missing=False, lose_sgprs=False): + seen = [] + + def launch(*args, env): + seen.append(env) + self.assertEqual(args[1:], (str(Path("unused") / "cs_w32_salu_ext.spv"), "1", "dump")) + self.assertEqual(env["VKC_SGPRS"], ",".join(f"{w:#x}" for w in check.SALU_EXT_SGPRS)) + self.assertEqual(env["VKC_SUBGROUP_SIZE"], "32") + self.assertEqual(env["VKC_OUT_WORDS"], str(HEAP)) + self.assertEqual(env["LEONIDA_VK_DEVICE"], "synthetic device") + words = list(check.SALU_EXT_WORDS) + [0xEEEEEEEE] * (HEAP - len(check.SALU_EXT_WORDS)) + if lose_sgprs: + _, program, registers, _, _ = fixture() + words[:len(registers)] = reference_words(program, registers, [0] * 16) + if mutate: + mutate(words) + if not missing: + Path(env["VKC_DUMP"]).write_bytes(struct.pack(f"<{len(words)}I", *words)) + return code, output + + with patch.object(check, "run", side_effect=launch): + result = check.salu_ext_test("unused", "unused", {"LEONIDA_VK_DEVICE": "synthetic device"}) + self.assertEqual(len(seen), 1) + return result + + def test_complete_readback_passes(self): + self.assertEqual(self.run_readback(), "") + + def test_one_wrong_word_fails(self): + for index in (0, 37, 69, 72, 73, HEAP - 1): # results, SCC words, and the fill after them + with self.subTest(word=index): + output = self.run_readback(lambda data: data.__setitem__(index, data[index] ^ 4)) + self.assertIn(f"word {index}:", output) + + def test_a_run_without_the_operands_fails(self): + self.assertIn("word 0: expected 0xffffffff, got 0x00000000", self.run_readback(lose_sgprs=True)) + + def test_truncated_and_missing_dump_fail(self): + self.assertIn(f"expected {4 * HEAP} dump bytes, got {4 * HEAP - 4}", self.run_readback(lambda data: data.pop())) + self.assertIn("no VKC_DUMP", self.run_readback(missing=True)) + + def test_unsupported_module_skips_but_nonzero_exit_fails(self): + self.assertIsInstance(self.run_readback(code=77, output="unsupported: no Int64\n"), check.Skip) + self.assertIn("exit 1", self.run_readback(code=1, output="dispatch failed")) + + +class SaluExtRunner(unittest.TestCase): + def test_filtered_runner_counts_pass_failure_and_skip(self): + for detail, expected, verdict in (("", 0, "1/1 passed"), ("word 69: mismatch", 1, "0/1 passed"), + (check.Skip("SKIP (no Int64)"), 0, "0/1 passed, 1 skipped")): + with self.subTest(detail=detail), tempfile.TemporaryDirectory() as tmp: + args = SimpleNamespace(filter="cs_w32_salu_ext", build=tmp, llvm_mc="unused") + + def translate(_cmd, **_kwargs): + (Path(tmp) / "spirv" / "cs_w32_salu_ext.spv").touch() + return 0, "" + + output = io.StringIO() + with (patch.object(rgt, "assemble_to_s", side_effect=lambda _mc, _src, dst, _name: Path(dst).touch()), + patch.object(rgt, "spirv_as"), patch.object(rgt, "run_cmd", side_effect=translate), + patch.object(rgt, "salu_ext_test", return_value=detail) as readback, + contextlib.redirect_stdout(output)): + self.assertEqual(rgt.run_suite(args, tmp), expected) + readback.assert_called_once() + self.assertIn(verdict, output.getvalue()) + self.assertIn("cs_w32_salu_ext", output.getvalue()) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_rdna2_decode.py b/tests/test_rdna2_decode.py index 81dcad21ca..c1f48fd462 100644 --- a/tests/test_rdna2_decode.py +++ b/tests/test_rdna2_decode.py @@ -382,12 +382,34 @@ def test_flat_scratch_vaddr_off_and_lds_loads(self): for field in ("op", "args", "mods"): self.assertEqual(reparsed[field], expected[field]) + def test_sopk_imm16_is_sign_extended_for_the_signed_ops_only(self): + # SOPK word: 0xB << 28 | op << 23 | sdst << 16 | simm16. The ten signed ops give the 16 bits sign-extended, + # the six unsigned compares give them as they are, and the printed line reads back as the same value. + signed = {0: "s_movk_i32", 2: "s_cmovk_i32", 3: "s_cmpk_eq_i32", 4: "s_cmpk_lg_i32", 5: "s_cmpk_gt_i32", + 6: "s_cmpk_ge_i32", 7: "s_cmpk_lt_i32", 8: "s_cmpk_le_i32", 15: "s_addk_i32", 16: "s_mulk_i32"} + unsigned = {9: "s_cmpk_eq_u32", 10: "s_cmpk_lg_u32", 11: "s_cmpk_gt_u32", 12: "s_cmpk_ge_u32", + 13: "s_cmpk_lt_u32", 14: "s_cmpk_le_u32"} + for table, sign_extends in ((signed, True), (unsigned, False)): + for opcode, name in table.items(): + for simm16 in (0x0001, 0x7FFF, 0x8000, 0xFFFD, 0xFFFF): + with self.subTest(op=name, simm16=hex(simm16)): + code = words(0xB << 28 | opcode << 23 | 5 << 16 | simm16) + ins, = rdna2_decode.decode_bytes(code)["insns"] + want = simm16 - 0x10000 if sign_extends and simm16 & 0x8000 else simm16 + self.assertEqual((ins["op"], ins["args"][0]["r"], ins["args"][1]), + (name, 5, {"k": "imm", "v": want})) + text, bad = rdna2_decode.disasm_bytes(code) + self.assertEqual(bad, 0) + self.assertEqual(shader_ir.parse_line(text.strip())["args"], ins["args"]) + def test_parity_with_llvm_mc_on_shader_fixtures(self): mc = os.environ.get("LLVM_MC") or shutil.which("llvm-mc") or shutil.which("llvm-mc-18") if not mc: self.skipTest("llvm-mc not available") asms = sorted(glob.glob(os.path.join(ROOT, "runtime", "test", "shaders", "*.asm"))) self.assertGreater(len(asms), 50) + sopk_signed = {"s_movk_i32", "s_cmovk_i32", "s_addk_i32", "s_mulk_i32"} | { + f"s_cmpk_{cond}_i32" for cond in ("eq", "lg", "gt", "ge", "lt", "le")} def norm_op(op): for suf in ("_e32", "_e64", "_sdwa", "_dpp"): @@ -401,7 +423,10 @@ def norm_arg(a, op=""): return (k, a["r"], a.get("n", 1), bool(a.get("neg")), bool(a.get("abs")), bool(a.get("sext"))) if k == "imm": # LLVM 18 disassembles SOPP branch offsets unsigned (0xfff0), LLVM 21/22 signed (-16). - mask = 0xFFFF if op in rdna2_decode._SOPP_BRANCHES else 0xFFFFFFFF + # The signed SOPK ops hold 16 bits as well: the decoder gives them sign-extended (s_addk_i32 s52, + # -32768; the test above), llvm-mc 23.1.4 prints the same word as 0x8000, and the translator reads + # the low 16 bits of either. cs_w32_salu_ext is the first fixture with bit 15 set in one. + mask = 0xFFFF if op in rdna2_decode._SOPP_BRANCHES or op in sopk_signed else 0xFFFFFFFF return ("imm", a["v"] & mask, bool(a.get("neg")), bool(a.get("abs"))) if k == "fimm": return ("fimm", round(a["v"], 6), bool(a.get("neg")), bool(a.get("abs"))) diff --git a/tests/test_shader_checks.py b/tests/test_shader_checks.py index b700f91018..d3298290b1 100644 --- a/tests/test_shader_checks.py +++ b/tests/test_shader_checks.py @@ -31,8 +31,8 @@ # All check.py cases, including the seven vk_store_test shaders and the three mesh fixtures, and TEST-184's -# vk_store_test "words" fixtures and image_get_lod draws. -TOTAL = (len(check.COMPUTE) + 7 + len(check.CS_DUMPS) + len(check.W64X_DUMPS) + len(check.W64X_PARTIAL) + 7 +# vk_store_test "words" fixtures and image_get_lod draws. One of the eight next to COMPUTE is cs_w32_salu_ext. +TOTAL = (len(check.COMPUTE) + 8 + len(check.CS_DUMPS) + len(check.W64X_DUMPS) + len(check.W64X_PARTIAL) + 7 + len(check.PIXEL_TESTS) + len(check.CLIP_TESTS) + len(check.BOUNDS) + len(check.GLOBAL_OFFSET) + len(check.MIP_TEST_PASSES) + len(check.GRADIENT_TESTS) + len(check.STORE_WORDS) + len(check.GET_LOD_TESTS) @@ -110,6 +110,14 @@ def harness(_tool, shader, *args, env=None): seeded = (env or {}).get("VKC_SGPRS") == check.USER_SGPRS_ENV["VKC_SGPRS"] words = check.USER_SGPRS_WORDS if seeded else [0] * 4 + [0xEEEEEEEE] * 4 return 0, "out[0..7] = " + " ".join(map(str, words)) + "\n" + if name == "cs_w32_salu_ext": + # The scalar results come back only if check.py passed the sixteen operand words in VKC_SGPRS. + self.assertEqual((args, env["VKC_OUT_WORDS"]), (("1", "dump"), str(check.SALU_EXT_HEAP_WORDS))) + seeded = env.get("VKC_SGPRS") == ",".join(f"{w:#x}" for w in check.SALU_EXT_SGPRS) + words = check.SALU_EXT_WORDS if seeded else [0] * len(check.SALU_EXT_WORDS) + words = words + [0xEEEEEEEE] * (check.SALU_EXT_HEAP_WORDS - len(words)) + Path(env["VKC_DUMP"]).write_bytes(struct.pack(f"<{len(words)}I", *words)) + return 0, "" if name == "cs_cvt_f32_sat": return cvt_answer(env) if name == "cs_fma_fused":