From aeb58e09e000a030db62ac8931a8ac758bd3b478 Mon Sep 17 00:00:00 2001 From: seedds Date: Wed, 11 Nov 2026 23:54:30 +0100 Subject: [PATCH] shader: report a one-pixel fragment size Report Ampere special register 0x84 as a 1 x 1 fragment and make other unknown special registers visible in translator notes. Cover S2R, S2UR, byte extraction, and the diagnostic with Linux SPIR-V tests.\n\nAdapted from seedds/nxnative#2373. --- dm/gfx/tests/test_dmsh_fragment_size.py | 102 ++++++++++++++++++ .../Instructions/InstEmitAmpereAlu.cs | 19 +++- 2 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 dm/gfx/tests/test_dmsh_fragment_size.py diff --git a/dm/gfx/tests/test_dmsh_fragment_size.py b/dm/gfx/tests/test_dmsh_fragment_size.py new file mode 100644 index 00000000..2c85cf8c --- /dev/null +++ b/dm/gfx/tests/test_dmsh_fragment_size.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python3 +"""Ampere S2UR special register 0x84 through the offline translator. + +Bytes 1 and 2 are the variable-rate-shading fragment width and height. The +host shades one pixel per fragment, so the register must be 0x00010100 and its +width-times-height product must fold to one. Needs DMSH_TEST_XLATE and the +SPIR-V tools on PATH. +""" +import json +import os +import re +import shutil +import struct +import subprocess +import tempfile +import unittest +from pathlib import Path + + +EXIT = (0x000fea0003800000, 0x000000000000794d) +S2UR = (0x000ea20000008400, 0x00000000000479c3) # S2UR UR4, SR 0x84 +S2UR_UNKNOWN = (0x000ea20000008500, S2UR[1]) # S2UR UR4, SR 0x85 +S2R = (0x000e260000008400, 0x0000000000067919) # S2R R6, SR 0x84 +BYTE2 = (0x004fe2000800003f, 0x0000777204057896) # UPRMT UR5, UR4, 0x7772 +BYTE1 = (0x000fc4000800003f, 0x0000777104047896) # UPRMT UR4, UR4, 0x7771 +PRODUCT = (0x000fe2000f8e023f, 0x00000004050472a4) # UIMAD UR4, UR5, UR4, URZ +MOV_UR4 = (0x000fe20000000f00, 0x0000000400067c02) # MOV R6, UR4 +STORE = (0x000fe8000000c800, 0x0000080609008388) # STS.U32 [R9 * 16 + 8], R6 + + +def inst(hi, lo): + return struct.pack('