Commit Graph

2 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
a55a471f2c rdna2spirv: write a mesh shader's CullPrimitiveEXT as a constant behind a branch (SHADER-575)
The mesh epilogue stored the per-primitive cull bool computed from the primitive export. llvmpipe (Mesa 25.2.8,
LLVM 20) aborts compiling that store in the wave64-emulated epilogue ("Cannot emit physreg copy instruction"), and
Mesa 26.3.1 drew no primitives for ms_tri and ms_clip translated with --wave64-emulate. A hand-written mesh shader
with only a computed CullPrimitiveEXT store aborts llvmpipe the same way, so it is the driver; the translator now
branches on the bool and stores %true or %false, which means the same on every driver. On llvmpipe ms_tri,
ms_clip and ms_w64x_ballot pass with --wave64-emulate, and every mesh test still passes natively.

tests/semantic/test_mesh_cull_store.py translates runtime/test/shaders/ms_tri.asm natively and emulated and checks
that only constants reach CullPrimitiveEXT (fails on the old translation), and spirv-val on both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J5F7hCPobvvk4Q3kU5EB13
2026-11-22 20:18:18 +00:00