mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 19:58:36 +00:00
After the merge the tree held this branch's older states of files main maintains. Run against main's code, tests/test_acphal_abi.py and 11 of the 15 translator tests that differed failed, and the C++ runtime would have been built from two generations of its sources. So that the merge cannot break what main builds and tests: - runtime/ is main's, file for file (68 files only this branch had are not carried over); - every file under tools/, tests/ and docs/ that both sides have is main's (80 files); - ten translator tests only this branch has, which test rules main's translator does not have, and their fixtures are left out. What main gains: d3d12/ (the Rust D3D12 runtime), its launchers and helpers (Launcher.bat, scripts/play*.ps1, play-linux.sh, port_ctl.py, smooth-motion.ps1, fetch_vkd3d_proton.py, sync_victory.py), mods/example_lua, eleven notes under docs/, seven tools and the tests that pass with main's code, the README's sections and credits, and the "Runtime traps" section of AGENTS.md. Everything left out here is on the branch port/d3d12-nvidia. Checked: compileall; make_game.py --help; check_no_game_data.py over every file this adds to main; the line-ending, docs-encoding, CI-registration and docs tests; each test file that differs from main, on its own. Not run: the whole translator suite, the C++ build, cargo over d3d12/ after the merge (d3d12/ is byte for byte the branch's), CI. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
63 lines
3.3 KiB
Python
63 lines
3.3 KiB
Python
"""SHADER-1264: a computed 32-bit value written to exec_lo / exec_hi turns on the lanes whose bit is set.
|
|
|
|
runtime/test/shaders/cs_w32_exec_computed.asm and cs_w64_exec_computed.asm write values the translator can't fold
|
|
(built from v_readfirstlane_b32) into EXEC with s_lshl_b32, s_add_u32, s_bfm_b32, s_not_b32, s_mov_b32 and a lane
|
|
mask s_and_b32 a number. Each lane of that half takes its own bit of the value; testing the value for non-zero turns
|
|
on the whole half. Run on all lanes of one wave (32, and 64 without --wave64-emulate) with a heap of 0xee bytes; the
|
|
words are the GPU check's (check.py CS_DUMPS, run_gpu_tests.py), derived by hand in each .asm header.
|
|
"""
|
|
import os
|
|
import sys
|
|
import unittest
|
|
|
|
import support
|
|
import spirv_mini_interp as si
|
|
|
|
|
|
class ExecComputed(unittest.TestCase):
|
|
WANT = {"cs_w32_exec_computed": (32, [259, 1028, 3088, 7682, 512, 4100, 0, 3]),
|
|
"cs_w64_exec_computed": (64, [291, 1028, 11264, 771, 8192, 4132, 0, 3])}
|
|
# The words with the value tested for non-zero (main before SHADER-1264, measured on the GPU): the first three
|
|
# cases of cs_w32 and the first four of cs_w64 turn on every lane of the half they write.
|
|
OLD_PREFIX = {"cs_w32_exec_computed": [8192, 8192, 8192],
|
|
"cs_w64_exec_computed": [8224, 8192, 16384, 16384]}
|
|
|
|
def run_words(self, name, lanes):
|
|
sys.path.insert(0, os.path.join(support.ROOT, "runtime", "test", "shaders"))
|
|
from compute_fixture import compute_header
|
|
header = compute_header(os.path.join(support.ROOT, "runtime", "test", "shaders", name + ".asm"))
|
|
spv = support.translate_fixture(name, fssm=bytes(header))
|
|
memory = {a: 0xEEEEEEEE for a in range(0, 0x100, 4)}
|
|
si.run_workgroup(spv, lanes, lanes,
|
|
inputs_for=lambda i: {"%wg_id": (0, 0, 0), "%local_id": (i, 0, 0), "%sg_lane": i},
|
|
push_constants=[0, 0, 0xFFFFFFFF, 0x31016FAC] + [0] * 28, memory=memory)
|
|
self.assertEqual(set(memory), set(range(0, 0x100, 4)), "nothing written outside the heap")
|
|
return [memory[4 * i] for i in range(8)]
|
|
|
|
def test_words(self):
|
|
for name, (lanes, want) in self.WANT.items():
|
|
with self.subTest(shader=name):
|
|
got = self.run_words(name, lanes)
|
|
self.assertEqual(got, want)
|
|
old = self.OLD_PREFIX[name]
|
|
self.assertNotEqual(got[:len(old)], old)
|
|
|
|
def test_words_follow_from_the_masks(self):
|
|
# Plain-Python reference: word = set lanes << 8 | lowest lane of each case's resulting EXEC.
|
|
def word(m):
|
|
return bin(m).count("1") << 8 | ((m & -m).bit_length() - 1)
|
|
m32 = 0xFFFFFFFF
|
|
base, s5 = 0, 3
|
|
w32 = [word(1 << s5), word(base + 0xF0), word(((1 << 12) - 1) << 16), word(~s5 & m32),
|
|
word(base + 0x81), word(0x000FFFFF & (base + 0xFFFF0)), base, s5]
|
|
lo, hi = m32, m32 << 32
|
|
w64 = [word((1 << s5) << 32), word(base + 0xF0), word(lo | (((1 << 12) - 1) << 16) << 32),
|
|
word((1 << s5) | (base + 0x81) << 32), word((base + 0x81) | (~s5 & m32) << 32),
|
|
word((((1 << 52) - 1) & hi) & ((base + 0xFFFF0) << 32)), base, s5]
|
|
self.assertEqual(w32, self.WANT["cs_w32_exec_computed"][1])
|
|
self.assertEqual(w64, self.WANT["cs_w64_exec_computed"][1])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|