Commit Graph

7 Commits

Author SHA1 Message Date
cd5ee11079 rdna2spirv(r9b): unconditional CS/MS LDS bounds, PS EarlyFragmentTests, mesh epilogue & PS quad swizzle
Round 9b translator fixes for rendering correctness and Mandy d3d12/ parity:

1. Unconditional CS & MS LDS OOB bounds (Mandy 21633b328 parity):
   - Record g.lds_declared from PSV0.shared for MS and RSRC2.LDS_SIZE for CS.
   - Whenever g.lds_declared > 0 (opt-out --no-lds-bounds), set
     g.lds_dwords = g.lds_bound = min(g.lds_declared, 16384) so every LDS
     read, write, sub-dword, wide, and atomic op goes through lds_access()
     (OOB reads return 0, OOB writes/atomics dropped instead of wrapping).

2. PS DB_SHADER_CONTROL bit 12 EarlyFragmentTests (Mandy f33940415/bf479a3cd):
   - Add fssm_header.db_shader_control() reading u32 at E + 0x138 (0x24C for
     rec = 0xB0; 3,023/12,101 corpus PS have bit 12 DEPTH_BEFORE_SHADER set).
   - Emit OpExecutionMode %main EarlyFragmentTests (opt-out --no-early-depth)
     and record early_depth in shader_meta when bit 12 is set and the PS does
     not export depth/stencil (no exp mrtz, DB_SHADER_CONTROL & 0x7 == 0, no
     OSG1 SV_Depth*/SV_StencilRef).

3. Defensive mesh epilogue & PS helper-lane quad swizzle:
   - MeshEXT and --mesh-compute epilogues explicitly write CullPrimitiveEXT =
     true (1) and (0, 0, 0) when %mli < %msp and !%ms_has_prim.
   - Lower quad-local ds_swizzle_b32 in PS via OpGroupNonUniformQuadBroadcast /
     OpGroupNonUniformQuadSwap (GroupNonUniformQuad capability) so Vulkan 2x2
     helper invocations participate on AMD RADV while EXEC-masked lanes still
     read 0.

Verified: compileall, check_no_game_data.py, 6,674/6,674 semantic tests (0
failures), 200/200 corpus slice (200/200 spirv-val), plus targeted LDS MS
(5/5), LDS CS (60/60), early-depth PS (120/120), and PS quad-swizzle (50/50)
corpus slices (100% spirv-val). AI-assisted.
2026-11-29 09:25:40 -05:00
2d4dce41e7 rdna2spirv: redirect absent subgroup lanes before OpGroupNonUniformShuffle in ds_permute 2026-11-24 13:38:00 -05:00
dc612fdcd9 docs(shader): qualify the absent-lane swizzle result
The hardware runs control EXEC in full waves. The seven-invocation interpreter case instead selects an absent lane. Distinguish those observations so the CPU fixture cannot be mistaken for a measurement on silicon.
2026-11-22 20:38:16 +01:00
39f2264f18 Merge remote-tracking branch 'upstream/main' into codex/ds-swizzle-exec
# Conflicts:
#	docs/design.md
2026-11-22 19:15:19 +01:00
4618927591 fix(shader): return zero for inactive swizzle sources
Neighbor colors can remain in a disabled lane. Use the same masked lane read as backward permute so an active fragment gets zero for a disabled or absent neighbor while a disabled destination keeps its previous value.
2026-11-22 19:10:14 +01:00
14887e6828 Translator: honour V# OOB_SELECT in MUBUF/MTBUF bounds checks
buffer_address() picked the bounds check from the stride alone and never read
word3. It now reads OOB_SELECT (bits 29:28) and applies the rule measured
natively on RDNA2 (gfx1036, docs/buffer_bounds.md; Mesa's GFX11 column): a
dword is out of range in mode 0 at idx >= NR or off + 4 > stride, mode 1 at
idx >= NR, mode 2 at NR == 0, mode 3 (RAW) at offs + 4 > NR, where off is
inst_offset + vaddr and offs adds soffset. A literal word3 folds the mode, a
run-time one selects with OpSelect.

Builds on the raw tail rule of #443 (per-dword loads): x2..x4 loads AND stores
are per dword in modes 0 and 3 (a store that straddled the edge used to write
past it), modes 1 and 2 take the whole access, a typed element
(buffer_load/store_format) is all or nothing at its format's size, an atomic
checks its dword's end. Measured on a Radeon 880M (gfx1150), a valid proxy for
RDNA2: 504 buffer_load_dword cases over idxen/offen/inst_offset/soffset at the
stride and record edges agree with the rules, plus the x2/x4, typed and atomic
edges.

Swizzle (V# word1 bit 31 SWIZZLE_ENABLE, word3 bit 23 ADD_TID_ENABLE; Mesa
gfx10-rsrc.json lines 326 and 337): a literal V# with either is Unsupported in
every mode; a run-time one is translated unswizzled (documented known gap).

A V# with word3 = 0 is mode 0 / stride 0 and so always out of range, as on
hardware: the harness output V# (vk_compute_test, interpreter push constants),
cs_bounds, cs_fmt_1010102, cs_store, mem_diff and the format tests now say
OOB_SELECT 3 (or 1 with a stride) explicitly.

Tests: tests/semantic/test_buffer_oob_select.py (33 hand-tabulated cases plus
multi-dword stores, typed elements and the swizzle gate, literal and run-time
V#), GPU tests cs_oob_select.asm and cs_oob_tail.asm (the second tells the end
check from Mesa's GFX10 start check). docs/design.md, Buffer bounds checking,
has the per-mode rule; docs/buffer_bounds.md notes the translator reads it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 07:40:20 +01:00
0726e3f26b Translator: ds_permute_b32, the forward (scatter) cross-lane permute (SHADER-90)
Each source lane on in EXEC sends its data to lane ((addr + offset) >> 2) mod 32
of its own half (like ds_bpermute_b32); a destination nobody targets gets 0, an
off destination keeps its VDST. Highest-numbered source wins a collision.
Native: per-source shuffles with a ballot guard for missing lanes; wave64
emulation: two buffer rounds and a %x_perm variable.

Tests: tests/semantic/test_ds_permute.py, GPU tests cs_w32_permute and
cs_w64x_permute. Contract row in docs/design.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 20:22:15 -05:00