Files
mandy/tests/semantic/test_permlane_fi.py
SirAmong 71d8f86853 Translator: v_permlane16/x16 FI=0 and BOUND_CTRL for source lanes off in EXEC (SHADER-74)
op_sel:[FI, BOUND_CTRL] decides what a lane gets when the lane it reads is off in EXEC (or absent from a
workgroup smaller than the wave): FI=1 reads its value, FI=0 keeps the destination (BOUND_CTRL=0) or writes 0
(BOUND_CTRL=1). Measured on RDNA2 (issue #374). The activity of the source lane is shuffled with absent lanes
redirected first, as ds_lane_read does, and the old destination is a plain load, as dst() does.
cs_w32_permlane_fi (GPU) and test_permlane_fi (CPU); the shuffle-count and destination-select controls of
test_valu_permlane16 follow the extra activity shuffle on the FI=0 path.

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

46 lines
1.9 KiB
Python

"""v_permlane16_b32 / v_permlanex16_b32 with the source lane off in EXEC (SHADER-74), wave32, CPU values.
The input is the GPU test runtime/test/shaders/cs_w32_permlane_fi (hand-written, no game data; fixture from
regen_fixtures.py). EXEC is 0x55555555, so the source lane of every active lane is off, except in the identity
case. Expected words are the RDNA2 measurement from issue #374 (op_sel:[FI, BOUND_CTRL]):
FI=1 returns the off lane's value; FI=0 leaves the destination alone (BOUND_CTRL=0) or writes 0 (BOUND_CTRL=1);
a source lane that is on gives its value whatever FI / BOUND_CTRL are.
"""
import struct
import unittest
import support
import spirv_mini_interp as si
# 4 user SGPRs (the output V#), 32x1x1 threads: build.py's default header with a 32-wide group.
FSSM = bytearray(0x148)
struct.pack_into("<4I", FSSM, 0x138, 0x8088, 32, 1, 1)
FSSM = bytes(FSSM)
VSHARP = [0, 0, 0x1000, 0x31016FAC]
# permlane16 / permlanex16 x (FI=0 BC=0, FI=0 BC=1, FI=1 BC=0, source on); see the .asm header.
EXPECTED = [1000, 0, 4, 1, 1000, 0, 52, 49]
NAMES = ["permlane16 FI=0 BC=0 (not written)", "permlane16 FI=0 BC=1 (0)", "permlane16 FI=1 (value)",
"permlane16 source on", "permlanex16 FI=0 BC=0 (not written)", "permlanex16 FI=0 BC=1 (0)",
"permlanex16 FI=1 (value)", "permlanex16 source on"]
def run(spv):
memory = si.run_workgroup(
spv, 32, 32,
inputs_for=lambda i: {"%wg_id": (0, 0, 0), "%local_id": (i, 0, 0), "%sg_lane": i},
push_constants=VSHARP + [0] * 28, memory={})
return [memory.get(4 * k) for k in range(8)]
class PermlaneSourceOff(unittest.TestCase):
def test_all_cases(self):
got = run(support.translate_fixture("cs_w32_permlane_fi", fssm=FSSM))
for i, name in enumerate(NAMES):
with self.subTest(case=name):
self.assertEqual(got[i], EXPECTED[i])
if __name__ == "__main__":
unittest.main()