pixel_aot_dpp_extra_hardware fails on RX 9060 XT: the dpp8 lane rotation reads 0 #1017

Closed
opened 2026-11-23 21:56:54 +00:00 by lantiumBot · 7 comments
lantiumBot commented 2026-11-23 21:56:54 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by lantiumBot on 2026-11-23T21:56:54Z.


Summary

pixel_aot_dpp_extra_hardware fails on an AMD Radeon RX 9060 XT at current main. pixel_aot_dpp_extra_warp passes on the same machine and build. The failing draw is the 32-bit wrap-around check for v_dot4c_i32_i8_dpp ... dpp8:[1,2,3,0,5,6,7,4] added with #423. A reduced shader shows the generated lane rotation returning 0 for a value that is the same in every lane.

Identical in 9 of 9 runs of the test (5 at 44c7a7b, then 4 at cd87907: two in the dev preset and two in release) and 4 of 4 runs of the probe.

Environment

  • Commit: cd87907670e56cf9767d13c2248461b98aeedcec (main), clean tree, dev (Debug) and release presets; first seen at 44c7a7b
  • Adapter: AMD Radeon RX 9060 XT (vendor=1002 device=7590), driver 32.0.32029.2010, 64-lane waves (WaveGetLaneCount() = 64)
  • WARP: Microsoft Basic Render Driver (1414:008c), in-box, driver 10.0.26100.10068 (WaveGetLaneCount() = 4)
  • Windows build: 26300.10075, D3D12 debug layer unavailable
  • DXC 1.9.2602.17 (21d28f727) from Windows SDK 10.0.26100.0

Command

ctest --preset dev --no-tests=error -R '^pixel_aot_dpp_extra_(hardware|warp)$' --output-on-failure
ctest --preset release --no-tests=error -R '^pixel_aot_dpp_extra_(hardware|warp)$' --output-on-failure

Expected

Both tests pass.

Observed

pixel_aot_dpp_extra_warp passed in every run. pixel_aot_dpp_extra_hardware failed in check_dpp_extra_subnormal_draw, on dpp_dotc_wrap.cso (subprocess.CalledProcessError, renderer exit status 1). The draws before it in that test passed. First mismatch:

pixel_mismatch x=0 y=0
channel=0 expected_bits=80000010 actual_bits=80000010
channel=1 expected_bits=80000010 actual_bits=80000010
channel=2 expected_bits=7ffffff0 actual_bits=80000010
channel=3 expected_bits=7ffffff0 actual_bits=7ffffff0
AOT color export differs from CPU reference

Channel 2 is v_dot4c_i32_i8_dpp v14, v22, v21 dpp8:[1,2,3,0,5,6,7,4] with v22 = s44 = 0xf8f8f8f8. Its accumulator 0x80000010 comes back unchanged, so the dot term was 0 instead of -32. Channel 3 is the _e32 form of the same instruction on the same input and is correct, and channel 0 (quad_perm:[1,0,3,2], emitted as QuadReadAcrossX) is correct.

Reduction

The translator emits this for the dpp8 rotation (out naming mine):

uint u = params[0].w;                      // 0xf8f8f8f8 in every lane
uint q = WaveGetLaneIndex() & 3u;
uint l0 = QuadReadLaneAt(u, 0);
uint l1 = QuadReadLaneAt(u, 1);
uint l2 = QuadReadLaneAt(u, 2);
uint l3 = QuadReadLaneAt(u, 3);
uint s = (q == 0u ? l1 : (q == 1u ? l2 : (q == 2u ? l3 : l0)));

Since u is uniform, s must be 0xf8f8f8f8 whatever the lane order. Words of pixel (0, 0) from the renderer's R32G32B32A32_UINT target, ps_6_2, -Gis -denorm preserve, renderer from the dev preset:

Shader returns RX 9060 XT all 64 px equal In-box WARP all 64 px equal
uint4(u, u, u, u) f8f8f8f8 x4 yes f8f8f8f8 x4 yes
uint4(l0, l1, l2, l3) (no select) f8f8f8f8 x4 yes f8f8f8f8 x4 yes
QuadReadAcrossX/Y/Diagonal(u), u f8f8f8f8 x4 yes f8f8f8f8 x4 yes
uint4(s, s, s, s) 00000000 x4 no f8f8f8f8 x4 yes
uint4(s, l2, l3, q) 00000000,f8f8f8f8,f8f8f8f8,00000000 no f8f8f8f8,f8f8f8f8,f8f8f8f8,00000000 no
uint4(s, l0, l1, q) f8f8f8f8,f8f8f8f8,f8f8f8f8,00000000 no same no
s = (q == 0u ? l1 : u), uint4(s, s, s, s) f8f8f8f8 x4 yes f8f8f8f8 x4 yes
four-way select with u in every arm, no quad read f8f8f8f8 x4 yes f8f8f8f8 x4 yes

(The rows that export q are not uniform by construction.)

What was measured, and what was not

  • Measured: on this adapter the four-way select over four QuadReadLaneAt results returns 0 at pixel (0, 0), and uint4(s, s, s, s) is not uniform across the 64 pixels. The same select is correct when l0 and l1 are also written to the render target. Each QuadReadLaneAt alone, the select alone, and a one-arm select are correct.
  • Not measured: which of the 64 pixels read 0 (the renderer reports the first mismatch only), the ISA the driver emits, any other RDNA 4 device or driver, and any NVIDIA adapter with this probe. On #423 the maintainer reported the focused Release draws passing 2/2 on an RTX 4060 Laptop and in-box WARP at 8868f7c.
  • Hypothesis, not established: a driver code-generation defect for this pattern at wave64, in the same family as the other RDNA 4 rows. It could also be an assumption in the emitted HLSL that I have not identified; WaveGetLaneIndex() & 3u as the quad-local index is one candidate, although it cannot explain a 0 when every lane holds the same value.

The other _hardware results, from the full run at 44c7a7b: 148 tests, 143 passed, 1 capability skip (bc7_mode6_multiblock_hardware), 4 failed. The other three failures are the rows already recorded for RDNA 4 (dxr_opacity_hardware, gpu_alias_lookup_writes_hardware, pixel_aot_comparisons_hardware, #958).

quad_lane_probe.py (uncommitted)
python -B quad_lane_probe.py <dxc.exe> <repo>/out/build/dev/offscreen_check.exe hardware
python -B quad_lane_probe.py <dxc.exe> <repo>/out/build/dev/offscreen_check.exe warp
"""Local, uncommitted probe: QuadReadLaneAt on a constant-buffer word in a pixel shader.

Reduces the dpp8 rotation of pixel_aot_dpp_extra (v_dot4c_i32_i8_dpp ... dpp8:[1,2,3,0,5,6,7,4]).
u = params[0].w = 0xf8f8f8f8, the same for every lane. Each shader is drawn twice through the
repository renderer's R32G32B32A32_UINT target: once against a sentinel to read the words of
pixel (0, 0), once with those words as the expectation to check all 64 pixels.

Usage: quad_lane_probe.py <dxc> <offscreen_check> <hardware|warp>
"""
from pathlib import Path
import struct
import subprocess
import sys
import tempfile

HEADER = ("cbuffer Constants : register(b0) { uint4 params[16]; };\n"
          "uint4 main(float2 uv : TEXCOORD0) : SV_Target0 {\n"
          "    uint u = params[0].w;\n")
ROTATE = ("    uint q = WaveGetLaneIndex() & 3u;\n"
          "    uint l0 = QuadReadLaneAt(u, 0);\n    uint l1 = QuadReadLaneAt(u, 1);\n"
          "    uint l2 = QuadReadLaneAt(u, 2);\n    uint l3 = QuadReadLaneAt(u, 3);\n"
          "    uint s = (q == 0u ? l1 : (q == 1u ? l2 : (q == 2u ? l3 : l0)));\n")
SHADERS = (  # (name, body, IEEE-independent expected words)
    ("passthrough", "    return uint4(u, u, u, u);\n", (0xf8f8f8f8,) * 4),
    ("lane-at-0123", "    return uint4(QuadReadLaneAt(u, 0), QuadReadLaneAt(u, 1), QuadReadLaneAt(u, 2), QuadReadLaneAt(u, 3));\n",
     (0xf8f8f8f8,) * 4),
    ("across-x-y-diag", "    return uint4(QuadReadAcrossX(u), QuadReadAcrossY(u), QuadReadAcrossDiagonal(u), u);\n",
     (0xf8f8f8f8,) * 4),
    ("rotate-select", ROTATE + "    return uint4(s, l0, l1, q);\n", (0xf8f8f8f8, 0xf8f8f8f8, 0xf8f8f8f8, None)),
    ("rotate-lanes-23", ROTATE + "    return uint4(s, l2, l3, q);\n", (0xf8f8f8f8, 0xf8f8f8f8, 0xf8f8f8f8, None)),
    ("rotate-only", ROTATE + "    return uint4(s, s, s, s);\n", (0xf8f8f8f8,) * 4),
    ("rotate-only-l1", "    uint q = WaveGetLaneIndex() & 3u;\n    uint l1 = QuadReadLaneAt(u, 1);\n"
     "    uint s = (q == 0u ? l1 : u);\n    return uint4(s, s, s, s);\n", (0xf8f8f8f8,) * 4),
    ("select-no-quad", "    uint q = WaveGetLaneIndex() & 3u;\n"
     "    uint s = (q == 0u ? u : (q == 1u ? u : (q == 2u ? u : u)));\n    return uint4(s, s, s, s);\n",
     (0xf8f8f8f8,) * 4),
    ("lane-index", "    return uint4(WaveGetLaneIndex(), WaveGetLaneCount(), WaveGetLaneIndex() & 3u, u);\n",
     (None, None, None, 0xf8f8f8f8)),
)
SENTINEL = 0x5a5a5a5a


def case(expected):
    constants = bytearray(256)
    struct.pack_into("<I", constants, 12, 0xf8f8f8f8)  # params[0].w
    return bytes(constants) + struct.pack("<4I", *expected) * 64 + bytes([1])  # flags bit 0: integer target


def main(dxc, renderer, backend):
    version = subprocess.run([dxc, "--version"], capture_output=True, text=True)
    print("dxc=" + (version.stdout + version.stderr).strip().splitlines()[0])
    with tempfile.TemporaryDirectory() as tmp:
        path = Path(tmp)
        printed = False
        for name, body, expected in SHADERS:
            source, cso, probe = (path / f"s.{ext}" for ext in ("hlsl", "cso", "case"))
            source.write_text(HEADER + body + "}\n", encoding="ascii")
            subprocess.run([dxc, "-Gis", "-denorm", "preserve", "-T", "ps_6_2", "-E", "main", "-Fo", cso, source],
                           check=True, capture_output=True)
            probe.write_bytes(case([SENTINEL] * 4))
            first = subprocess.run([renderer, backend, "--check-pixel-case", cso, probe], capture_output=True, text=True)
            output = first.stdout + first.stderr
            if not printed:
                print("\n".join(line for line in output.splitlines() if line.startswith(("backend=", "adapter=", "driver="))))
                printed = True
            words = [int(line.rsplit("actual_bits=", 1)[1], 16) for line in output.splitlines() if line.startswith("channel=")]
            if len(words) != 4:
                raise RuntimeError(output)
            probe.write_bytes(case(words))
            second = subprocess.run([renderer, backend, "--check-pixel-case", cso, probe], capture_output=True, text=True)
            uniform = second.returncode == 0
            verdict = all(want is None or got == want for got, want in zip(words, expected))
            print(f"shader={name} words=" + ",".join(f"{w:08x}" for w in words)
                  + f" all_64_pixels_equal={str(uniform).lower()} as_expected={str(verdict).lower()}")
    return 0


if __name__ == "__main__":
    sys.exit(main(*sys.argv[1:]))

AI-assisted (Claude Code - Fable 5.2); runs executed locally on the adapter above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6569643571 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1024). Originally posted by [lantiumBot](https://github.com/lantiumBot) on 2026-11-23T21:56:54Z. --- ### Summary `pixel_aot_dpp_extra_hardware` fails on an AMD Radeon RX 9060 XT at current `main`. `pixel_aot_dpp_extra_warp` passes on the same machine and build. The failing draw is the 32-bit wrap-around check for `v_dot4c_i32_i8_dpp ... dpp8:[1,2,3,0,5,6,7,4]` added with #423. A reduced shader shows the generated lane rotation returning 0 for a value that is the same in every lane. Identical in 9 of 9 runs of the test (5 at `44c7a7b`, then 4 at `cd87907`: two in the `dev` preset and two in `release`) and 4 of 4 runs of the probe. ### Environment - Commit: `cd87907670e56cf9767d13c2248461b98aeedcec` (`main`), clean tree, `dev` (Debug) and `release` presets; first seen at `44c7a7b` - Adapter: AMD Radeon RX 9060 XT (vendor=1002 device=7590), driver 32.0.32029.2010, 64-lane waves (`WaveGetLaneCount()` = 64) - WARP: Microsoft Basic Render Driver (1414:008c), in-box, driver 10.0.26100.10068 (`WaveGetLaneCount()` = 4) - Windows build: 26300.10075, D3D12 debug layer unavailable - DXC 1.9.2602.17 (21d28f727) from Windows SDK 10.0.26100.0 ### Command ```powershell ctest --preset dev --no-tests=error -R '^pixel_aot_dpp_extra_(hardware|warp)$' --output-on-failure ctest --preset release --no-tests=error -R '^pixel_aot_dpp_extra_(hardware|warp)$' --output-on-failure ``` ### Expected Both tests pass. ### Observed `pixel_aot_dpp_extra_warp` passed in every run. `pixel_aot_dpp_extra_hardware` failed in `check_dpp_extra_subnormal_draw`, on `dpp_dotc_wrap.cso` (`subprocess.CalledProcessError`, renderer exit status 1). The draws before it in that test passed. First mismatch: ```text pixel_mismatch x=0 y=0 channel=0 expected_bits=80000010 actual_bits=80000010 channel=1 expected_bits=80000010 actual_bits=80000010 channel=2 expected_bits=7ffffff0 actual_bits=80000010 channel=3 expected_bits=7ffffff0 actual_bits=7ffffff0 AOT color export differs from CPU reference ``` Channel 2 is `v_dot4c_i32_i8_dpp v14, v22, v21 dpp8:[1,2,3,0,5,6,7,4]` with `v22 = s44 = 0xf8f8f8f8`. Its accumulator `0x80000010` comes back unchanged, so the dot term was 0 instead of -32. Channel 3 is the `_e32` form of the same instruction on the same input and is correct, and channel 0 (`quad_perm:[1,0,3,2]`, emitted as `QuadReadAcrossX`) is correct. ### Reduction The translator emits this for the dpp8 rotation (`out` naming mine): ```hlsl uint u = params[0].w; // 0xf8f8f8f8 in every lane uint q = WaveGetLaneIndex() & 3u; uint l0 = QuadReadLaneAt(u, 0); uint l1 = QuadReadLaneAt(u, 1); uint l2 = QuadReadLaneAt(u, 2); uint l3 = QuadReadLaneAt(u, 3); uint s = (q == 0u ? l1 : (q == 1u ? l2 : (q == 2u ? l3 : l0))); ``` Since `u` is uniform, `s` must be `0xf8f8f8f8` whatever the lane order. Words of pixel (0, 0) from the renderer's R32G32B32A32_UINT target, `ps_6_2`, `-Gis -denorm preserve`, renderer from the `dev` preset: | Shader returns | RX 9060 XT | all 64 px equal | In-box WARP | all 64 px equal | |---|---|---|---|---| | `uint4(u, u, u, u)` | `f8f8f8f8` x4 | yes | `f8f8f8f8` x4 | yes | | `uint4(l0, l1, l2, l3)` (no select) | `f8f8f8f8` x4 | yes | `f8f8f8f8` x4 | yes | | `QuadReadAcrossX/Y/Diagonal(u)`, `u` | `f8f8f8f8` x4 | yes | `f8f8f8f8` x4 | yes | | `uint4(s, s, s, s)` | **`00000000` x4** | **no** | `f8f8f8f8` x4 | yes | | `uint4(s, l2, l3, q)` | **`00000000`**`,f8f8f8f8,f8f8f8f8,00000000` | no | `f8f8f8f8,f8f8f8f8,f8f8f8f8,00000000` | no | | `uint4(s, l0, l1, q)` | `f8f8f8f8,f8f8f8f8,f8f8f8f8,00000000` | no | same | no | | `s = (q == 0u ? l1 : u)`, `uint4(s, s, s, s)` | `f8f8f8f8` x4 | yes | `f8f8f8f8` x4 | yes | | four-way select with `u` in every arm, no quad read | `f8f8f8f8` x4 | yes | `f8f8f8f8` x4 | yes | (The rows that export `q` are not uniform by construction.) ### What was measured, and what was not - Measured: on this adapter the four-way select over four `QuadReadLaneAt` results returns 0 at pixel (0, 0), and `uint4(s, s, s, s)` is not uniform across the 64 pixels. The same select is correct when `l0` and `l1` are also written to the render target. Each `QuadReadLaneAt` alone, the select alone, and a one-arm select are correct. - Not measured: which of the 64 pixels read 0 (the renderer reports the first mismatch only), the ISA the driver emits, any other RDNA 4 device or driver, and any NVIDIA adapter with this probe. On #423 the maintainer reported the focused Release draws passing 2/2 on an RTX 4060 Laptop and in-box WARP at `8868f7c`. - Hypothesis, not established: a driver code-generation defect for this pattern at wave64, in the same family as the other RDNA 4 rows. It could also be an assumption in the emitted HLSL that I have not identified; `WaveGetLaneIndex() & 3u` as the quad-local index is one candidate, although it cannot explain a 0 when every lane holds the same value. The other `_hardware` results, from the full run at `44c7a7b`: 148 tests, 143 passed, 1 capability skip (`bc7_mode6_multiblock_hardware`), 4 failed. The other three failures are the rows already recorded for RDNA 4 (`dxr_opacity_hardware`, `gpu_alias_lookup_writes_hardware`, `pixel_aot_comparisons_hardware`, #958). <details> <summary>quad_lane_probe.py (uncommitted)</summary> ```powershell python -B quad_lane_probe.py <dxc.exe> <repo>/out/build/dev/offscreen_check.exe hardware python -B quad_lane_probe.py <dxc.exe> <repo>/out/build/dev/offscreen_check.exe warp ``` ```python """Local, uncommitted probe: QuadReadLaneAt on a constant-buffer word in a pixel shader. Reduces the dpp8 rotation of pixel_aot_dpp_extra (v_dot4c_i32_i8_dpp ... dpp8:[1,2,3,0,5,6,7,4]). u = params[0].w = 0xf8f8f8f8, the same for every lane. Each shader is drawn twice through the repository renderer's R32G32B32A32_UINT target: once against a sentinel to read the words of pixel (0, 0), once with those words as the expectation to check all 64 pixels. Usage: quad_lane_probe.py <dxc> <offscreen_check> <hardware|warp> """ from pathlib import Path import struct import subprocess import sys import tempfile HEADER = ("cbuffer Constants : register(b0) { uint4 params[16]; };\n" "uint4 main(float2 uv : TEXCOORD0) : SV_Target0 {\n" " uint u = params[0].w;\n") ROTATE = (" uint q = WaveGetLaneIndex() & 3u;\n" " uint l0 = QuadReadLaneAt(u, 0);\n uint l1 = QuadReadLaneAt(u, 1);\n" " uint l2 = QuadReadLaneAt(u, 2);\n uint l3 = QuadReadLaneAt(u, 3);\n" " uint s = (q == 0u ? l1 : (q == 1u ? l2 : (q == 2u ? l3 : l0)));\n") SHADERS = ( # (name, body, IEEE-independent expected words) ("passthrough", " return uint4(u, u, u, u);\n", (0xf8f8f8f8,) * 4), ("lane-at-0123", " return uint4(QuadReadLaneAt(u, 0), QuadReadLaneAt(u, 1), QuadReadLaneAt(u, 2), QuadReadLaneAt(u, 3));\n", (0xf8f8f8f8,) * 4), ("across-x-y-diag", " return uint4(QuadReadAcrossX(u), QuadReadAcrossY(u), QuadReadAcrossDiagonal(u), u);\n", (0xf8f8f8f8,) * 4), ("rotate-select", ROTATE + " return uint4(s, l0, l1, q);\n", (0xf8f8f8f8, 0xf8f8f8f8, 0xf8f8f8f8, None)), ("rotate-lanes-23", ROTATE + " return uint4(s, l2, l3, q);\n", (0xf8f8f8f8, 0xf8f8f8f8, 0xf8f8f8f8, None)), ("rotate-only", ROTATE + " return uint4(s, s, s, s);\n", (0xf8f8f8f8,) * 4), ("rotate-only-l1", " uint q = WaveGetLaneIndex() & 3u;\n uint l1 = QuadReadLaneAt(u, 1);\n" " uint s = (q == 0u ? l1 : u);\n return uint4(s, s, s, s);\n", (0xf8f8f8f8,) * 4), ("select-no-quad", " uint q = WaveGetLaneIndex() & 3u;\n" " uint s = (q == 0u ? u : (q == 1u ? u : (q == 2u ? u : u)));\n return uint4(s, s, s, s);\n", (0xf8f8f8f8,) * 4), ("lane-index", " return uint4(WaveGetLaneIndex(), WaveGetLaneCount(), WaveGetLaneIndex() & 3u, u);\n", (None, None, None, 0xf8f8f8f8)), ) SENTINEL = 0x5a5a5a5a def case(expected): constants = bytearray(256) struct.pack_into("<I", constants, 12, 0xf8f8f8f8) # params[0].w return bytes(constants) + struct.pack("<4I", *expected) * 64 + bytes([1]) # flags bit 0: integer target def main(dxc, renderer, backend): version = subprocess.run([dxc, "--version"], capture_output=True, text=True) print("dxc=" + (version.stdout + version.stderr).strip().splitlines()[0]) with tempfile.TemporaryDirectory() as tmp: path = Path(tmp) printed = False for name, body, expected in SHADERS: source, cso, probe = (path / f"s.{ext}" for ext in ("hlsl", "cso", "case")) source.write_text(HEADER + body + "}\n", encoding="ascii") subprocess.run([dxc, "-Gis", "-denorm", "preserve", "-T", "ps_6_2", "-E", "main", "-Fo", cso, source], check=True, capture_output=True) probe.write_bytes(case([SENTINEL] * 4)) first = subprocess.run([renderer, backend, "--check-pixel-case", cso, probe], capture_output=True, text=True) output = first.stdout + first.stderr if not printed: print("\n".join(line for line in output.splitlines() if line.startswith(("backend=", "adapter=", "driver=")))) printed = True words = [int(line.rsplit("actual_bits=", 1)[1], 16) for line in output.splitlines() if line.startswith("channel=")] if len(words) != 4: raise RuntimeError(output) probe.write_bytes(case(words)) second = subprocess.run([renderer, backend, "--check-pixel-case", cso, probe], capture_output=True, text=True) uniform = second.returncode == 0 verdict = all(want is None or got == want for got, want in zip(words, expected)) print(f"shader={name} words=" + ",".join(f"{w:08x}" for w in words) + f" all_64_pixels_equal={str(uniform).lower()} as_expected={str(verdict).lower()}") return 0 if __name__ == "__main__": sys.exit(main(*sys.argv[1:])) ``` </details> AI-assisted (Claude Code - Fable 5.2); runs executed locally on the adapter above.
MasterDomino commented 2026-11-24 06:49:45 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-23T22:00:30Z.


Second RDNA 4 device on a different driver, plus the driver's ISA, which shows where the 0 comes from. Measurement only, no project change.

Environment

  • AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31044.16
  • In-box WARP 10.0.26100.9818
  • Windows 11 26H2, build 26300.9974
  • Commit cd87907, dev preset, DXC 1.8.2502.11, -Gis -denorm preserve -T ps_6_2
  • D3D12 debug layer enabled, debug_errors=0 debug_warnings=0

Same failure

pixel_aot_dpp_extra_hardware fails with the same first mismatch (channel=2 expected_bits=7ffffff0 actual_bits=80000010) in every run on this adapter (dev preset, 3 full-suite runs and 2 single runs). _warp passes.

I reduced it on the fixture's own generated HLSL rather than a hand-written shader, replacing only the final return:

Exported RX 9070 XT, pixel (0,0) all 64 equal WARP
QuadReadLaneAt(u, 0..3) f8f8f8f8 ×4 yes same
s (the four-way select), u, fixture result 00000000,f8f8f8f8,80000010 no f8f8f8f8,f8f8f8f8,7ffffff0, all equal

The driver's ISA

The s-exporting shader compiled for gfx1201 through the installed driver with Radeon GPU Analyzer 2.15.0.30 (official rga-windows-x64-2.15.zip, SHA-256 matched the release digest). The pipeline pairs it with a pass-through vs_6_2, an R32G32B32A32_UINT target and RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT), CBV(b0), DescriptorTable(SRV(t0)), StaticSampler(s0). The DXIL is straight-line: four dx.op.quadReadLaneAt.i32 on the same value, then the select. The ISA, with scheduling waits removed (v1 = WaveGetLaneIndex() & 3, s0 = params[0].w):

	v_cmpx_ne_i32_e64 0, v1                         ; lanes with q != 0
	s_cbranch_execz L5
	v_cmpx_ne_i32_e64 1, v1                         ; lanes with q in {2,3}
	s_cbranch_execz L3
	v_mov_b32_e32 v2, s0                            ; u, written only in lanes 2 and 3
	ds_swizzle_b32 v3, v2 offset:swizzle(QUAD_PERM,3,3,3,3)
	ds_swizzle_b32 v2, v2 offset:swizzle(QUAD_PERM,0,0,0,0)   ; reads lane 0's v2: not written here
	v_cmp_eq_i32_e32 vcc_lo, 2, v1
	v_cndmask_b32_e32 v1, v2, v3, vcc_lo
L3:	s_and_not1_b64 exec, s[4:5], exec             ; q == 1
	v_mov_b32_e32 v1, s0                            ; written only in lane 1
	ds_swizzle_b32 v1, v1 offset:swizzle(QUAD_PERM,2,2,2,2)   ; reads lane 2's v1: holds something else
L4:	s_mov_b64 exec, s[4:5]
L5:	s_and_not1_b64 exec, s[2:3], exec             ; q == 0
	v_mov_b32_e32 v1, s0                            ; written only in lane 0
	ds_swizzle_b32 v1, v1 offset:swizzle(QUAD_PERM,1,1,1,1)   ; reads lane 1's v1

Each quad read has moved into the branch of the select arm that uses it, and the uniform value is put into a VGPR only in that branch's active lanes. Lanes of one quad take different arms, so every ds_swizzle reads a source lane that is inactive in its branch and still holds an unrelated value. This explains the 0 at a uniform input, and the pixel-to-pixel variation. It also explains why your uint4(s, l0, l1, q) row is correct. When l0 and l1 are also used outside the select, those reads cannot move into its branches.

Control: a source the compiler cannot prove uniform

This is the same generated shader with uint dpp29_in = asuint(alu26) ^ (asuint(uv.x) & 0x80000000u);. uv is in [0, 1], so the value is unchanged.

  • RX 9070 XT: the fixture output is 80000010,80000010,7ffffff0,7ffffff0 on all 64 pixels, and the select is f8f8f8f8, in 3 of 3 runs. That is correct.
  • WARP: identical, 3 of 3.
  • ISA: four unconditional v_mov_b32_dpp vN, v0 quad_perm:[n,n,n,n] row_mask:0xf bank_mask:0xf bound_ctrl:1 and no branches.

So the wrong result needs a source the driver treats as uniform. That matches your hypothesis of a driver code-generation defect. The emitted WaveGetLaneIndex() & 3u quad index is not the cause, since the same HLSL with a non-uniform source is correct.

Limits

  • Two RDNA 4 devices and two drivers between this report and yours. No other generations tested.
  • The ISA comes from RGA's own pipeline around the blob, not a capture of the pipeline offscreen_check creates. The runtime pattern matches it: individual reads correct, select wrong, varying source correct.
  • I have not looked at the driver's code to find where the reads are moved.
  • This says nothing about gfx1013 DPP behaviour on the console.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7115205080 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1024#issuecomment-7115205080). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-23T22:00:30Z. --- Second RDNA 4 device on a different driver, plus the driver's ISA, which shows where the 0 comes from. Measurement only, no project change. ## Environment - AMD Radeon RX 9070 XT (`1002:7550`), driver `32.0.31044.16` - In-box WARP `10.0.26100.9818` - Windows 11 26H2, build 26300.9974 - Commit `cd87907`, `dev` preset, DXC `1.8.2502.11`, `-Gis -denorm preserve -T ps_6_2` - D3D12 debug layer **enabled**, `debug_errors=0 debug_warnings=0` ## Same failure `pixel_aot_dpp_extra_hardware` fails with the same first mismatch (`channel=2 expected_bits=7ffffff0 actual_bits=80000010`) in every run on this adapter (`dev` preset, 3 full-suite runs and 2 single runs). `_warp` passes. I reduced it on the fixture's own generated HLSL rather than a hand-written shader, replacing only the final `return`: | Exported | RX 9070 XT, pixel (0,0) | all 64 equal | WARP | |---|---|---|---| | `QuadReadLaneAt(u, 0..3)` | `f8f8f8f8` ×4 | yes | same | | `s` (the four-way select), `u`, fixture result | **`00000000`**`,f8f8f8f8,80000010` | no | `f8f8f8f8,f8f8f8f8,7ffffff0`, all equal | ## The driver's ISA The `s`-exporting shader compiled for gfx1201 through the installed driver with Radeon GPU Analyzer 2.15.0.30 (official `rga-windows-x64-2.15.zip`, SHA-256 matched the release digest). The pipeline pairs it with a pass-through `vs_6_2`, an `R32G32B32A32_UINT` target and `RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT), CBV(b0), DescriptorTable(SRV(t0)), StaticSampler(s0)`. The DXIL is straight-line: four `dx.op.quadReadLaneAt.i32` on the same value, then the select. The ISA, with scheduling waits removed (`v1` = `WaveGetLaneIndex() & 3`, `s0` = `params[0].w`): ```text v_cmpx_ne_i32_e64 0, v1 ; lanes with q != 0 s_cbranch_execz L5 v_cmpx_ne_i32_e64 1, v1 ; lanes with q in {2,3} s_cbranch_execz L3 v_mov_b32_e32 v2, s0 ; u, written only in lanes 2 and 3 ds_swizzle_b32 v3, v2 offset:swizzle(QUAD_PERM,3,3,3,3) ds_swizzle_b32 v2, v2 offset:swizzle(QUAD_PERM,0,0,0,0) ; reads lane 0's v2: not written here v_cmp_eq_i32_e32 vcc_lo, 2, v1 v_cndmask_b32_e32 v1, v2, v3, vcc_lo L3: s_and_not1_b64 exec, s[4:5], exec ; q == 1 v_mov_b32_e32 v1, s0 ; written only in lane 1 ds_swizzle_b32 v1, v1 offset:swizzle(QUAD_PERM,2,2,2,2) ; reads lane 2's v1: holds something else L4: s_mov_b64 exec, s[4:5] L5: s_and_not1_b64 exec, s[2:3], exec ; q == 0 v_mov_b32_e32 v1, s0 ; written only in lane 0 ds_swizzle_b32 v1, v1 offset:swizzle(QUAD_PERM,1,1,1,1) ; reads lane 1's v1 ``` Each quad read has moved into the branch of the select arm that uses it, and the uniform value is put into a VGPR only in that branch's active lanes. Lanes of one quad take different arms, so every `ds_swizzle` reads a source lane that is inactive in its branch and still holds an unrelated value. This explains the 0 at a uniform input, and the pixel-to-pixel variation. It also explains why your `uint4(s, l0, l1, q)` row is correct. When `l0` and `l1` are also used outside the select, those reads cannot move into its branches. ## Control: a source the compiler cannot prove uniform This is the same generated shader with `uint dpp29_in = asuint(alu26) ^ (asuint(uv.x) & 0x80000000u);`. `uv` is in [0, 1], so the value is unchanged. - RX 9070 XT: the fixture output is `80000010,80000010,7ffffff0,7ffffff0` on all 64 pixels, and the select is `f8f8f8f8`, in 3 of 3 runs. That is correct. - WARP: identical, 3 of 3. - ISA: four unconditional `v_mov_b32_dpp vN, v0 quad_perm:[n,n,n,n] row_mask:0xf bank_mask:0xf bound_ctrl:1` and no branches. So the wrong result needs a source the driver treats as uniform. That matches your hypothesis of a driver code-generation defect. The emitted `WaveGetLaneIndex() & 3u` quad index is not the cause, since the same HLSL with a non-uniform source is correct. ## Limits - Two RDNA 4 devices and two drivers between this report and yours. No other generations tested. - The ISA comes from RGA's own pipeline around the blob, not a capture of the pipeline `offscreen_check` creates. The runtime pattern matches it: individual reads correct, select wrong, varying source correct. - I have not looked at the driver's code to find where the reads are moved. - This says nothing about gfx1013 DPP behaviour on the console. AI-assisted.
R0Y00 commented 2026-11-24 06:49:46 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T22:04:35Z.


The current evidence points to the compiler moving quad reads into divergent select arms. The uniform word must survive every permutation, so this is separate from lane numbering. Please keep the existing test strict. As the next comparison, keep the four constant-index reads and replace the ternary with integer masks:

uint even = (q & 1u) - 1u;
uint top = (q >> 1u) - 1u;  // q is already 0..3
uint s = (((l1 & even) | (l2 & ~even)) & top)
       | (((l3 & even) | (l0 & ~even)) & ~top);

On the same adapter and compiler, compare the original and changed shaders in the existing wrap fixture and the reduction. Include a distinct four-lane input so a wrong rotation cannot pass, plus all 64 pixel words or a strict full-buffer count. Please note if the AMD compiler still introduces control flow. Use constant quad-lane indices throughout. #421 shares this path, so its hardware acceptance needs the outcome too.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7115292786 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1024#issuecomment-7115292786). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T22:04:35Z. --- The current evidence points to the compiler moving quad reads into divergent select arms. The uniform word must survive every permutation, so this is separate from lane numbering. Please keep the existing test strict. As the next comparison, keep the four constant-index reads and replace the ternary with integer masks: ```hlsl uint even = (q & 1u) - 1u; uint top = (q >> 1u) - 1u; // q is already 0..3 uint s = (((l1 & even) | (l2 & ~even)) & top) | (((l3 & even) | (l0 & ~even)) & ~top); ``` On the same adapter and compiler, compare the original and changed shaders in the existing wrap fixture and the reduction. Include a distinct four-lane input so a wrong rotation cannot pass, plus all 64 pixel words or a strict full-buffer count. Please note if the AMD compiler still introduces control flow. Use constant quad-lane indices throughout. #421 shares this path, so its hardware acceptance needs the outcome too.
R0Y00 commented 2026-11-24 06:49:46 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T22:12:04Z.


The general DPP mask change is available in draft #1030 at 364eb996. The strict DPP readback passed on WARP and RTX 4060 Laptop, and the compiled minimal helper contains four fixed quad reads and integer masks. Could either AMD reporter rerun draw-dpp-extra on this head with the original strict comparison? Please include the adapter, driver and mismatch count. The draft stays open for that hardware check.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7115454409 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1024#issuecomment-7115454409). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T22:12:04Z. --- The general DPP mask change is available in draft #1030 at 364eb996. The strict DPP readback passed on WARP and RTX 4060 Laptop, and the compiled minimal helper contains four fixed quad reads and integer masks. Could either AMD reporter rerun `draw-dpp-extra` on this head with the original strict comparison? Please include the adapter, driver and mismatch count. The draft stays open for that hardware check.
lantiumBot commented 2026-11-24 06:49:47 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by lantiumBot on 2026-11-23T22:30:11Z.


Hardware check of draft #1030, then the comparison requested earlier. Data only, no project change.

Draft #1030 at 364eb996 on the RX 9060 XT

draw-dpp-extra with the original strict comparison, run from a detached worktree of the draft head. The renderer is the existing dev build, made at f8e80e5; no source of the offscreen_check target differs between f8e80e5 and 364eb996, and ee04692..364eb996 touches only tools/pixel_aot.py and docs/experiments.md, so the two trees differ in the translator alone.

python -B tests/pixel_aot_check.py draw-dpp-extra <dxc.exe> <repo>/out/build/dev/offscreen_check.exe hardware
python -B tests/pixel_aot_check.py draw-dpp-extra <dxc.exe> <repo>/out/build/dev/offscreen_check.exe warp
Tree Backend Runs Exit Mismatch count Detail
#1030 364eb996 RX 9060 XT 3 0, 0, 0 0 7 strict draws printed per run, each pixels=4096 channels=16384 max_absolute_error=0; all 18 wrong-reference and mutation controls of the mode caught
#1030 364eb996 In-box WARP 3 0, 0, 0 0 same
ee04692 (the draft's parent commit on main) RX 9060 XT 3 1, 1, 1 not available, see below 6 strict draws pass, then dpp_dotc_wrap fails at pixel (0,0), channel=2 expected_bits=7ffffff0 actual_bits=80000010
ee04692 In-box WARP 3 0, 0, 0 0 7 strict draws per run
  • Adapter: AMD Radeon RX 9060 XT (vendor=1002 device=7590), driver 32.0.32029.2010. WARP: Microsoft Basic Render Driver (1414:008c), driver 10.0.26100.10068. Windows build 26300.10075, D3D12 debug layer unavailable, DXC 1.9.2602.17 (21d28f727).
  • Mismatch count: a passing draw is a bit-for-bit comparison of the raw 32-bit words of all 4096 pixels of the 64x64 target, with no tolerance (two integer-target draws, dpp_extra_subn and dpp_dotc_wrap, and five float-target draws), so the count is 0 for every draw of the #1030 runs. The renderer stops at the first mismatching pixel, so for the failing ee04692 draw I can give the first mismatch only, not a count.
  • With 364eb996 the HLSL generated for DPP_DOTC_WRAP_BODY has the four fixed QuadReadLaneAt(dpp29_in, 0..3) reads followed by dpp29_even / dpp29_top masks, and no ?: on the dpp29 lines.
  • The first run of each row is saved; runs 2 and 3 gave the same exit code and line counts. The rest of the _hardware set was not rerun on this head.

The sections below were measured before the draft existed, with the mask line substituted by hand into the ee04692 output. They explain the result and answer the earlier questions.

1. The wrap fixture, ternary against masks

The HLSL the translator emits for DPP_DOTC_WRAP_BODY, unchanged, and the same text with only the dpp29_s line replaced by the mask form above (names prefixed dpp29_). Constant quad-lane indices in both. Fixture expectation 80000010,80000010,7ffffff0,7ffffff0, then its clamped wrong reference. Three runs each.

Shader RX 9060 XT, strict RX 9060 XT, clamped reference WARP, strict WARP, clamped reference
ternary (as emitted) FAIL, first pixel (0,0) 80000010,80000010,80000010,7ffffff0 not an independent control here, the shader already fails strict pass caught
masks pass caught pass caught

2. Reduction, with a distinct word per lane

Each shader keeps the four constant-index reads and exports uint4(s ^ want_s, v ^ want_v, q ^ lane, 0), where lane = (x & 1) | ((y & 1) << 1) from SV_Position and want_* is the [1,2,3,0] rotation computed from it. A correct rotation writes zero everywhere, so one all-zero expectation is a strict check of the whole target (the renderer compares 4096 pixels). Inputs: uniform is params[0].w = 0xf8f8f8f8; distinct is 0xd0 | lane; distinct-data is params[1][lane] with params[1] = (0xd0, 0xd1, 0xd2, 0xd3). With the distinct inputs a wrong rotation, or a q that disagrees with the pixel position, cannot pass. Three runs each, identical.

Input Select RX 9060 XT In-box WARP Branches in the gfx1200 ISA Quad reads in the ISA
uniform ternary FAIL, first pixel (0,0), s = 00000000 pass, 4096 pixels 2 v_cmpx, 4 s_cbranch_execz 4 ds_swizzle_b32, each inside an arm
uniform masks pass, 4096 pixels pass, 4096 pixels none 4 ds_swizzle_b32, straight-line
distinct ternary pass, 4096 pixels pass, 4096 pixels none 4 v_mov_b32_dpp quad_perm
distinct masks pass, 4096 pixels pass, 4096 pixels none 4 v_mov_b32_dpp quad_perm
distinct-data ternary pass, 4096 pixels pass, 4096 pixels none 4 v_mov_b32_dpp quad_perm
distinct-data masks pass, 4096 pixels pass, 4096 pixels none 4 v_mov_b32_dpp quad_perm

q ^ lane was zero on every pixel that was compared, on both adapters, so WaveGetLaneIndex() & 3 matched the position-derived quad lane here. That is an observation on fully covered quads (one full-target triangle), not a guarantee; each pixel checks the one read its lane selects, and helper lanes of partial quads are not exercised.

3. Does the AMD compiler still introduce control flow?

Not with the masks. Radeon GPU Analyzer 2.15.0.30, DX12 mode, gfx1200, pipeline as draw_verified() builds it (tests/pixel_aot_vs.hlsl as vs_6_0, its root signature, one R32G32B32A32_UINT target). These are RGA's compiles for gfx1200, not captures from the running pipeline. In both listings below only s_wait_* and s_delay_alu lines are removed, and the prologue before the cbuffer load and the trailing s_code_end padding are cut.

Uniform input, masks, from the load of u to the export. No v_cmpx, no branch, no v_cndmask:

	s_buffer_load_b32 s0, s[0:3], 0xc
	v_cvt_u32_f32_e32 v0, v2
	v_and_b32_e32 v0, 1, v0
	v_cvt_u32_f32_e32 v1, v3
	v_lshlrev_b32_e32 v2, 1, v1
	v_bfi_b32 v0, 2, v2, v0
	v_mbcnt_lo_u32_b32 v1, -1, 0
	v_mbcnt_hi_u32_b32 v1, -1, v1
	v_and_b32_e32 v2, 3, v1
	v_mov_b32_e32 v3, s0                                      ; u, in every lane
	v_xor_b32_e32 v6, v0, v2
	ds_swizzle_b32 v7, v3 offset:swizzle(QUAD_PERM,0,0,0,0)
	ds_swizzle_b32 v0, v3 offset:swizzle(QUAD_PERM,1,1,1,1)
	ds_swizzle_b32 v4, v3 offset:swizzle(QUAD_PERM,2,2,2,2)
	ds_swizzle_b32 v3, v3 offset:swizzle(QUAD_PERM,3,3,3,3)
	s_and_b64 exec, exec, s[8:9]
	v_and_b32_e32 v1, 1, v1
	v_lshrrev_b32_e32 v2, 1, v2
	v_add_nc_u32_e32 v5, -1, v1
	v_sub_nc_u32_e32 v1, 0, v1
	v_add_nc_u32_e32 v8, -1, v2
	v_sub_nc_u32_e32 v2, 0, v2
	v_and_b32_e32 v4, v4, v1
	v_and_b32_e32 v1, v7, v1
	v_and_or_b32 v7, v0, v5, v4
	v_and_or_b32 v0, v3, v5, v1
	v_and_b32_e32 v0, v0, v2
	v_and_or_b32 v0, v8, v7, v0
	v_xor_b32_e32 v2, s0, v0
	v_mov_b32_e32 v0, 0
	s_mov_b64 exec, s[8:9]
	export mrt0, v2, v0, v6, v0 done

Uniform input, ternary, from the load of u to the join. It has the structure of the gfx1201 listing above, with one more s_cbranch_execz after L3:

	s_buffer_load_b32 s0, s[0:3], 0xc
	s_mov_b64 s[2:3], exec
	v_cmpx_ne_i32_e64 0, v0
	s_cbranch_execz L5
	s_mov_b64 s[4:5], exec
	v_cmpx_ne_i32_e64 1, v0
	s_cbranch_execz L3
	v_mov_b32_e32 v1, s0
	ds_swizzle_b32 v4, v1 offset:swizzle(QUAD_PERM,3,3,3,3)
	ds_swizzle_b32 v1, v1 offset:swizzle(QUAD_PERM,0,0,0,0)
	v_cmp_eq_i32_e32 vcc_lo, 2, v0
	v_cndmask_b32_e32 v1, v1, v4, vcc_lo
L3:	s_and_not1_b64 exec, s[4:5], exec
	s_cbranch_execz L4
	v_mov_b32_e32 v1, s0
	ds_swizzle_b32 v1, v1 offset:swizzle(QUAD_PERM,2,2,2,2)
L4:	s_mov_b64 exec, s[4:5]
L5:	s_and_not1_b64 exec, s[2:3], exec
	s_cbranch_execz L6
	v_mov_b32_e32 v1, s0
	ds_swizzle_b32 v1, v1 offset:swizzle(QUAD_PERM,1,1,1,1)
L6:	s_and_b64 exec, s[2:3], s[8:9]

With a per-lane value the driver reads through v_mov_b32_dpp ... quad_perm:[k,k,k,k] in both forms. The ternary then becomes v_cndmask, the masks stay v_and / v_and_or, and neither listing has a branch. So in these six shaders the failure appears only where the driver kept the branches and the source was a uniform value in an SGPR, materialized with v_mov_b32_e32 inside each arm. I did not find a per-lane case where the driver keeps the branches, and I did not try a literal, a uniform value already in a VGPR, or reads that are also used outside the select, so I cannot separate "uniform source" from "branches kept" as the cause.

On where the control flow comes from: with DXC 1.9.2602.17 the ternary is not straight-line DXIL. The four quadReadLaneAt calls are in the entry block, followed by br i1 on q == 0, br i1 on q == 1, one select on q == 2 and a phi. The unmodified fixture HLSL compiles to the same shape with this DXC. So here the branches come from DXC; the AMD compiler preserves them for the uniform source and sinks the four reads into them, and removes them for a per-lane source. The gfx1201 report above describes straight-line DXIL from DXC 1.8.2502.11; I did not run that DXC.

Correction to my report above

The table in the issue has a column "all 64 px equal". The render target is 64x64: the case file holds 64 expected texels, each covering 8x8 pixels, and the renderer compares 4096 pixels. The column should read "whole target equal". The words and verdicts are unchanged.

Environment

  • offscreen_check from the dev preset, built at f8e80e5; tests/offscreen_check.cpp, tests/pixel_aot_render.cpp and tests/pixel_aot_vs.hlsl are unchanged from there through ee04692. Translator and tests/pixel_aot_check.py from ee04692; the HLSL generated for DPP_DOTC_WRAP_BODY is identical at cd87907
  • Adapter: AMD Radeon RX 9060 XT (vendor=1002 device=7590), driver 32.0.32029.2010; WaveGetLaneCount() read back as 64 in the probe of the report above, and the RGA listings are wave64
  • WARP: Microsoft Basic Render Driver (1414:008c), in-box, driver 10.0.26100.10068
  • Windows build: 26300.10075, D3D12 debug layer unavailable
  • DXC 1.9.2602.17 (21d28f727), -Gis -denorm preserve -T ps_6_2; RGA 2.15.0.30

Limits

  • A pass is a strict bit-for-bit comparison of all 4096 pixels, so the mismatch count is 0 there. A failure reports the first mismatching pixel only, so I have no count of wrong pixels for the two failing shaders; that part of the request is not met.
  • The driver compiled both distinct inputs without ds_swizzle, so the ds_swizzle path is exercised by the uniform input only. A per-lane value that reaches ds_swizzle was not found.
  • RGA compiles its own pipeline object around the blobs. The draws are the renderer's pipeline and agree with the listings.
  • One device, one driver, one mask formulation. #421 was not run.
quad_rotate_compare.py and quad_rotate_fixture.py (uncommitted)
python -B quad_rotate_compare.py <dxc.exe> <repo>/out/build/dev/offscreen_check.exe hardware <reduction-dir>
python -B quad_rotate_fixture.py <repo> <dxc.exe> <repo>/out/build/dev/offscreen_check.exe hardware <rga.exe> gfx1200 <reduction-dir> <isa-dir>
"""Local, uncommitted comparison for issue #1024: ternary select versus integer masks.

The dpp8 rotation [1,2,3,0] as the translator emits it (four constant-index QuadReadLaneAt reads and
a four-way ternary) against the same four reads combined with integer masks. Two inputs: the uniform
word 0xf8f8f8f8, and a distinct word per quad lane, 0xd0 | (x & 1) | ((y & 1) << 1), derived from
SV_Position so a wrong rotation cannot pass. A third input loads those distinct words from the
constant buffer by lane (params[1][lane]), because the compiler can fold the position-derived one.

Every shader returns uint4(s ^ want_s, v ^ want_v, q ^ lane, 0), where lane is the quad lane taken
from SV_Position and want_* the rotation computed from it. A correct rotation writes zero in every
word of every pixel, so one all-zero expectation is a strict check of the whole render target. On a
failure the renderer reports the first mismatching pixel; s is then xor_word0 ^ want_s.

Usage: quad_rotate_compare.py <dxc> <offscreen_check> <hardware|warp> [outdir]
"""
from pathlib import Path
import re
import struct
import subprocess
import sys
import tempfile

HEADER = ("cbuffer Constants : register(b0) { uint4 params[16]; };\n"
          "uint4 main(float4 uv : TEXCOORD0, float4 pos : SV_Position) : SV_Target0 {\n")
INPUTS = {
    "uniform": "    uint v = params[0].w;\n",
    "distinct": "    uint v = 0xd0u | (uint(pos.x) & 1u) | ((uint(pos.y) & 1u) << 1u);\n",
    # The same words loaded from the constant buffer by lane, so the compiler cannot derive them from the position.
    "distinct-data": "    uint v = params[1][lane];\n",
}
READS = ("    uint q = WaveGetLaneIndex() & 3u;\n"
         "    uint l0 = QuadReadLaneAt(v, 0);\n    uint l1 = QuadReadLaneAt(v, 1);\n"
         "    uint l2 = QuadReadLaneAt(v, 2);\n    uint l3 = QuadReadLaneAt(v, 3);\n")
SELECTS = {
    "ternary": "    uint s = (q == 0u ? l1 : (q == 1u ? l2 : (q == 2u ? l3 : l0)));\n",
    "masks": ("    uint even = (q & 1u) - 1u;\n    uint top = (q >> 1u) - 1u;\n"
              "    uint s = (((l1 & even) | (l2 & ~even)) & top)\n"
              "           | (((l3 & even) | (l0 & ~even)) & ~top);\n"),
}
LANE = "    uint lane = (uint(pos.x) & 1u) | ((uint(pos.y) & 1u) << 1u);\n"
WANT = {
    "uniform": "    uint want_s = params[0].w;\n    uint want_v = params[0].w;\n",
    "distinct": "    uint want_s = 0xd0u | ((lane + 1u) & 3u);\n    uint want_v = 0xd0u | lane;\n",
    "distinct-data": "    uint want_s = 0xd0u | ((lane + 1u) & 3u);\n    uint want_v = 0xd0u | lane;\n",
}
# Every word is 0 when the rotation is right, so one all-zero expectation checks the whole target.
FOOTER = "    return uint4(s ^ want_s, v ^ want_v, q ^ lane, 0u);\n}\n"
UNIFORM = 0xf8f8f8f8


def case():
    constants = bytearray(256)
    struct.pack_into("<I", constants, 12, UNIFORM)  # params[0].w
    struct.pack_into("<4I", constants, 16, 0xd0, 0xd1, 0xd2, 0xd3)  # params[1], one word per quad lane
    return bytes(constants) + struct.pack("<4I", 0, 0, 0, 0) * 64 + bytes([1])  # flags bit 0: integer target


def main(dxc, renderer, backend, outdir=None):
    version = subprocess.run([dxc, "--version"], capture_output=True, text=True)
    print("dxc=" + (version.stdout + version.stderr).strip().splitlines()[0])
    with tempfile.TemporaryDirectory() as tmp:
        path = Path(outdir) if outdir else Path(tmp)
        path.mkdir(parents=True, exist_ok=True)
        probe = path / "zero.case"
        probe.write_bytes(case())
        printed = False
        for input_name, input_text in INPUTS.items():
            for select_name, select_text in SELECTS.items():
                name = f"{input_name}-{select_name}"
                source, cso, listing = (path / f"{name}.{ext}" for ext in ("hlsl", "cso", "ll"))
                source.write_text(HEADER + LANE + input_text + READS + select_text + WANT[input_name] + FOOTER,
                                  encoding="ascii")
                subprocess.run([dxc, "-Gis", "-denorm", "preserve", "-T", "ps_6_2", "-E", "main", "-Fo", cso,
                                "-Fc", listing, source], check=True, capture_output=True)
                dxil = listing.read_text(encoding="utf-8", errors="replace")
                shape = (f"quadReadLaneAt={dxil.count('@dx.op.quadReadLaneAt.i32(i32')} select={dxil.count(' select ')} "
                         f"br={dxil.count(' br ')} phi={dxil.count(' phi ')}")
                results = []
                for _ in range(3):
                    done = subprocess.run([renderer, backend, "--check-pixel-case", cso, probe],
                                          capture_output=True, text=True)
                    output = done.stdout + done.stderr
                    if not printed:
                        print("\n".join(l for l in output.splitlines()
                                        if l.startswith(("backend=", "adapter=", "driver="))))
                        printed = True
                    if done.returncode == 0:
                        size = next((l for l in output.splitlines() if l.startswith("pixels=")), "pixels=?")
                        results.append(f"pass ({size})")
                    elif done.returncode == 1 and "pixel_mismatch" in output:
                        where = re.search(r"pixel_mismatch x=(\d+) y=(\d+)", output)
                        words = re.findall(r"actual_bits=([0-9a-f]{8})", output)
                        results.append(f"FAIL first=({where.group(1)},{where.group(2)}) xor_words={','.join(words)}")
                    else:
                        raise RuntimeError(output)
                verdict = results[0] if len(set(results)) == 1 else " / ".join(results)
                print(f"shader={name} dxil[{shape}] runs=3 result={verdict}")
    return 0


if __name__ == "__main__":
    sys.exit(main(*sys.argv[1:]))
"""Local, uncommitted: the #1024 wrap fixture with the ternary rotation and with integer masks.

Takes the HLSL the translator emits for DPP_DOTC_WRAP_BODY (tests/pixel_aot_check.py), draws it against
the fixture's own expectation and wrong-reference control, then repeats with only the dpp8 select line
replaced by the mask form. Optionally compiles the reduction shaders through Radeon GPU Analyzer.

Usage: quad_rotate_fixture.py <repo> <dxc> <offscreen_check> <hardware|warp> [<rga> <asic> <reduction-dir> <outdir>]
"""
from pathlib import Path
import re
import struct
import subprocess
import sys
import tempfile

TERNARY = "uint dpp29_s = (dpp29_q == 0u ? dpp29_l1 : (dpp29_q == 1u ? dpp29_l2 : (dpp29_q == 2u ? dpp29_l3 : dpp29_l0)));"
MASKS = ("uint dpp29_even = (dpp29_q & 1u) - 1u; uint dpp29_top = (dpp29_q >> 1u) - 1u; "
         "uint dpp29_s = (((dpp29_l1 & dpp29_even) | (dpp29_l2 & ~dpp29_even)) & dpp29_top) "
         "| (((dpp29_l3 & dpp29_even) | (dpp29_l0 & ~dpp29_even)) & ~dpp29_top);")
GPSO = ("# schemaVersion\n1.0\n\n# InputLayoutNumElements\n0\n\n# InputLayout\n\n\n#PrimitiveTopologyType\n"
        "D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE\n\n# NumRenderTargets\n1\n\n# RTVFormats\n"
        "{ DXGI_FORMAT_R32G32B32A32_UINT }\n")


def run(args):
    done = subprocess.run([str(a) for a in args], capture_output=True, text=True)
    return done.returncode, done.stdout + done.stderr


def main(repo, dxc, renderer, backend, rga=None, asic=None, reduction=None, outdir=None):
    sys.path.insert(0, str(Path(repo) / "tests"))
    argv, sys.argv = sys.argv, ["x"]
    import pixel_aot_check as p
    sys.argv = argv
    hlsl = p.translate_int(p.uncompressed_export(p.DPP_DOTC_WRAP_BODY))
    assert hlsl.count(TERNARY) == 1
    constants = bytearray(256)
    struct.pack_into("<I", constants, 12, 0xf8f8f8f8)
    good = bytes(constants) + struct.pack("<4I", 0x80000010, 0x80000010, 0x7ffffff0, 0x7ffffff0) * 64 + b"\x01"
    clamped = bytes(constants) + struct.pack("<4I", 0x7fffffff, 0x7fffffff, 0x80000000, 0x80000000) * 64 + b"\x01"
    with tempfile.TemporaryDirectory() as tmp:
        path = Path(tmp)
        for name, text in (("fixture-ternary", hlsl), ("fixture-masks", hlsl.replace(TERNARY, MASKS))):
            source, cso, case = (path / f"{name}.{ext}" for ext in ("hlsl", "cso", "case"))
            source.write_text(text, encoding="ascii")
            p.compile_shader(dxc, source, cso)
            results = []
            for _ in range(3):
                case.write_bytes(good)
                code, output = run([renderer, backend, "--check-pixel-case", cso, case])
                words = re.findall(r"actual_bits=([0-9a-f]{8})", output)
                where = re.search(r"pixel_mismatch x=(\d+) y=(\d+)", output)
                strict = "pass" if code == 0 else f"FAIL first=({where.group(1)},{where.group(2)}) words={','.join(words)}"
                case.write_bytes(clamped)
                code, output = run([renderer, backend, "--check-pixel-case", cso, case])
                control = "caught" if code == 1 and "pixel_mismatch" in output else f"ESCAPED exit={code}"
                results.append(f"strict={strict} clamped_reference={control}")
            print(f"{backend} shader={name} runs=3 " + (results[0] if len(set(results)) == 1 else " / ".join(results)))
    if rga:
        out = Path(outdir)
        out.mkdir(parents=True, exist_ok=True)
        vs, rs, gpso = out / "vs.cso", out / "rs.bin", out / "state.gpso"
        assert run([dxc, "-T", "vs_6_0", "-E", "main", "-Fo", vs, Path(repo) / "tests" / "pixel_aot_vs.hlsl"])[0] == 0
        assert run([dxc, "-dumpbin", vs, "-extractrootsignature", "-Fo", rs])[0] == 0
        gpso.write_text(GPSO, encoding="ascii")
        print("rga=" + run([rga, "-s", "dx12", "--version"])[1].strip().splitlines()[0])
        for cso in sorted(Path(reduction).glob("*.cso")):
            isa = out / f"{cso.stem}.isa"
            code, text = run([rga, "-s", "dx12", "-c", asic, "--vs-blob", vs, "--ps-blob", cso, "--rs-bin", rs,
                              "--gpso", gpso, "--isa", isa])
            print(f"rga shader={cso.stem} exit={code} " + " ".join(text.split())[:200])
    return 0


if __name__ == "__main__":
    sys.exit(main(*sys.argv[1:]))

AI-assisted (Claude Code - Fable 5.2); runs executed locally on the adapter above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7115834703 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1024#issuecomment-7115834703). Originally posted by [lantiumBot](https://github.com/lantiumBot) on 2026-11-23T22:30:11Z. --- Hardware check of draft #1030, then the comparison requested earlier. Data only, no project change. ### Draft #1030 at `364eb996` on the RX 9060 XT `draw-dpp-extra` with the original strict comparison, run from a detached worktree of the draft head. The renderer is the existing `dev` build, made at `f8e80e5`; no source of the `offscreen_check` target differs between `f8e80e5` and `364eb996`, and `ee04692..364eb996` touches only `tools/pixel_aot.py` and `docs/experiments.md`, so the two trees differ in the translator alone. ```powershell python -B tests/pixel_aot_check.py draw-dpp-extra <dxc.exe> <repo>/out/build/dev/offscreen_check.exe hardware python -B tests/pixel_aot_check.py draw-dpp-extra <dxc.exe> <repo>/out/build/dev/offscreen_check.exe warp ``` | Tree | Backend | Runs | Exit | Mismatch count | Detail | |---|---|---|---|---|---| | #1030 `364eb996` | RX 9060 XT | 3 | 0, 0, 0 | 0 | 7 strict draws printed per run, each `pixels=4096 channels=16384 max_absolute_error=0`; all 18 wrong-reference and mutation controls of the mode caught | | #1030 `364eb996` | In-box WARP | 3 | 0, 0, 0 | 0 | same | | `ee04692` (the draft's parent commit on `main`) | RX 9060 XT | 3 | 1, 1, 1 | not available, see below | 6 strict draws pass, then `dpp_dotc_wrap` fails at pixel (0,0), `channel=2 expected_bits=7ffffff0 actual_bits=80000010` | | `ee04692` | In-box WARP | 3 | 0, 0, 0 | 0 | 7 strict draws per run | - Adapter: AMD Radeon RX 9060 XT (vendor=1002 device=7590), driver 32.0.32029.2010. WARP: Microsoft Basic Render Driver (1414:008c), driver 10.0.26100.10068. Windows build 26300.10075, D3D12 debug layer unavailable, DXC 1.9.2602.17 (21d28f727). - Mismatch count: a passing draw is a bit-for-bit comparison of the raw 32-bit words of all 4096 pixels of the 64x64 target, with no tolerance (two integer-target draws, `dpp_extra_subn` and `dpp_dotc_wrap`, and five float-target draws), so the count is 0 for every draw of the #1030 runs. The renderer stops at the first mismatching pixel, so for the failing `ee04692` draw I can give the first mismatch only, not a count. - With `364eb996` the HLSL generated for `DPP_DOTC_WRAP_BODY` has the four fixed `QuadReadLaneAt(dpp29_in, 0..3)` reads followed by `dpp29_even` / `dpp29_top` masks, and no `?:` on the `dpp29` lines. - The first run of each row is saved; runs 2 and 3 gave the same exit code and line counts. The rest of the `_hardware` set was not rerun on this head. The sections below were measured before the draft existed, with the mask line substituted by hand into the `ee04692` output. They explain the result and answer the earlier questions. ### 1. The wrap fixture, ternary against masks The HLSL the translator emits for `DPP_DOTC_WRAP_BODY`, unchanged, and the same text with only the `dpp29_s` line replaced by the mask form above (names prefixed `dpp29_`). Constant quad-lane indices in both. Fixture expectation `80000010,80000010,7ffffff0,7ffffff0`, then its clamped wrong reference. Three runs each. | Shader | RX 9060 XT, strict | RX 9060 XT, clamped reference | WARP, strict | WARP, clamped reference | |---|---|---|---|---| | ternary (as emitted) | **FAIL**, first pixel (0,0) `80000010,80000010,80000010,7ffffff0` | not an independent control here, the shader already fails strict | pass | caught | | masks | pass | caught | pass | caught | ### 2. Reduction, with a distinct word per lane Each shader keeps the four constant-index reads and exports `uint4(s ^ want_s, v ^ want_v, q ^ lane, 0)`, where `lane = (x & 1) | ((y & 1) << 1)` from `SV_Position` and `want_*` is the `[1,2,3,0]` rotation computed from it. A correct rotation writes zero everywhere, so one all-zero expectation is a strict check of the whole target (the renderer compares 4096 pixels). Inputs: `uniform` is `params[0].w` = `0xf8f8f8f8`; `distinct` is `0xd0 | lane`; `distinct-data` is `params[1][lane]` with `params[1] = (0xd0, 0xd1, 0xd2, 0xd3)`. With the distinct inputs a wrong rotation, or a `q` that disagrees with the pixel position, cannot pass. Three runs each, identical. | Input | Select | RX 9060 XT | In-box WARP | Branches in the gfx1200 ISA | Quad reads in the ISA | |---|---|---|---|---|---| | uniform | ternary | **FAIL**, first pixel (0,0), `s` = `00000000` | pass, 4096 pixels | 2 `v_cmpx`, 4 `s_cbranch_execz` | 4 `ds_swizzle_b32`, each inside an arm | | uniform | masks | pass, 4096 pixels | pass, 4096 pixels | none | 4 `ds_swizzle_b32`, straight-line | | distinct | ternary | pass, 4096 pixels | pass, 4096 pixels | none | 4 `v_mov_b32_dpp quad_perm` | | distinct | masks | pass, 4096 pixels | pass, 4096 pixels | none | 4 `v_mov_b32_dpp quad_perm` | | distinct-data | ternary | pass, 4096 pixels | pass, 4096 pixels | none | 4 `v_mov_b32_dpp quad_perm` | | distinct-data | masks | pass, 4096 pixels | pass, 4096 pixels | none | 4 `v_mov_b32_dpp quad_perm` | `q ^ lane` was zero on every pixel that was compared, on both adapters, so `WaveGetLaneIndex() & 3` matched the position-derived quad lane here. That is an observation on fully covered quads (one full-target triangle), not a guarantee; each pixel checks the one read its lane selects, and helper lanes of partial quads are not exercised. ### 3. Does the AMD compiler still introduce control flow? Not with the masks. Radeon GPU Analyzer 2.15.0.30, DX12 mode, `gfx1200`, pipeline as `draw_verified()` builds it (`tests/pixel_aot_vs.hlsl` as `vs_6_0`, its root signature, one `R32G32B32A32_UINT` target). These are RGA's compiles for `gfx1200`, not captures from the running pipeline. In both listings below only `s_wait_*` and `s_delay_alu` lines are removed, and the prologue before the cbuffer load and the trailing `s_code_end` padding are cut. Uniform input, masks, from the load of `u` to the export. No `v_cmpx`, no branch, no `v_cndmask`: ```text s_buffer_load_b32 s0, s[0:3], 0xc v_cvt_u32_f32_e32 v0, v2 v_and_b32_e32 v0, 1, v0 v_cvt_u32_f32_e32 v1, v3 v_lshlrev_b32_e32 v2, 1, v1 v_bfi_b32 v0, 2, v2, v0 v_mbcnt_lo_u32_b32 v1, -1, 0 v_mbcnt_hi_u32_b32 v1, -1, v1 v_and_b32_e32 v2, 3, v1 v_mov_b32_e32 v3, s0 ; u, in every lane v_xor_b32_e32 v6, v0, v2 ds_swizzle_b32 v7, v3 offset:swizzle(QUAD_PERM,0,0,0,0) ds_swizzle_b32 v0, v3 offset:swizzle(QUAD_PERM,1,1,1,1) ds_swizzle_b32 v4, v3 offset:swizzle(QUAD_PERM,2,2,2,2) ds_swizzle_b32 v3, v3 offset:swizzle(QUAD_PERM,3,3,3,3) s_and_b64 exec, exec, s[8:9] v_and_b32_e32 v1, 1, v1 v_lshrrev_b32_e32 v2, 1, v2 v_add_nc_u32_e32 v5, -1, v1 v_sub_nc_u32_e32 v1, 0, v1 v_add_nc_u32_e32 v8, -1, v2 v_sub_nc_u32_e32 v2, 0, v2 v_and_b32_e32 v4, v4, v1 v_and_b32_e32 v1, v7, v1 v_and_or_b32 v7, v0, v5, v4 v_and_or_b32 v0, v3, v5, v1 v_and_b32_e32 v0, v0, v2 v_and_or_b32 v0, v8, v7, v0 v_xor_b32_e32 v2, s0, v0 v_mov_b32_e32 v0, 0 s_mov_b64 exec, s[8:9] export mrt0, v2, v0, v6, v0 done ``` Uniform input, ternary, from the load of `u` to the join. It has the structure of the gfx1201 listing above, with one more `s_cbranch_execz` after `L3`: ```text s_buffer_load_b32 s0, s[0:3], 0xc s_mov_b64 s[2:3], exec v_cmpx_ne_i32_e64 0, v0 s_cbranch_execz L5 s_mov_b64 s[4:5], exec v_cmpx_ne_i32_e64 1, v0 s_cbranch_execz L3 v_mov_b32_e32 v1, s0 ds_swizzle_b32 v4, v1 offset:swizzle(QUAD_PERM,3,3,3,3) ds_swizzle_b32 v1, v1 offset:swizzle(QUAD_PERM,0,0,0,0) v_cmp_eq_i32_e32 vcc_lo, 2, v0 v_cndmask_b32_e32 v1, v1, v4, vcc_lo L3: s_and_not1_b64 exec, s[4:5], exec s_cbranch_execz L4 v_mov_b32_e32 v1, s0 ds_swizzle_b32 v1, v1 offset:swizzle(QUAD_PERM,2,2,2,2) L4: s_mov_b64 exec, s[4:5] L5: s_and_not1_b64 exec, s[2:3], exec s_cbranch_execz L6 v_mov_b32_e32 v1, s0 ds_swizzle_b32 v1, v1 offset:swizzle(QUAD_PERM,1,1,1,1) L6: s_and_b64 exec, s[2:3], s[8:9] ``` With a per-lane value the driver reads through `v_mov_b32_dpp ... quad_perm:[k,k,k,k]` in both forms. The ternary then becomes `v_cndmask`, the masks stay `v_and` / `v_and_or`, and neither listing has a branch. So in these six shaders the failure appears only where the driver kept the branches and the source was a uniform value in an SGPR, materialized with `v_mov_b32_e32` inside each arm. I did not find a per-lane case where the driver keeps the branches, and I did not try a literal, a uniform value already in a VGPR, or reads that are also used outside the select, so I cannot separate "uniform source" from "branches kept" as the cause. On where the control flow comes from: with DXC 1.9.2602.17 the ternary is not straight-line DXIL. The four `quadReadLaneAt` calls are in the entry block, followed by `br i1` on `q == 0`, `br i1` on `q == 1`, one `select` on `q == 2` and a `phi`. The unmodified fixture HLSL compiles to the same shape with this DXC. So here the branches come from DXC; the AMD compiler preserves them for the uniform source and sinks the four reads into them, and removes them for a per-lane source. The gfx1201 report above describes straight-line DXIL from DXC 1.8.2502.11; I did not run that DXC. ### Correction to my report above The table in the issue has a column "all 64 px equal". The render target is 64x64: the case file holds 64 expected texels, each covering 8x8 pixels, and the renderer compares 4096 pixels. The column should read "whole target equal". The words and verdicts are unchanged. ### Environment - `offscreen_check` from the `dev` preset, built at `f8e80e5`; `tests/offscreen_check.cpp`, `tests/pixel_aot_render.cpp` and `tests/pixel_aot_vs.hlsl` are unchanged from there through `ee04692`. Translator and `tests/pixel_aot_check.py` from `ee04692`; the HLSL generated for `DPP_DOTC_WRAP_BODY` is identical at `cd87907` - Adapter: AMD Radeon RX 9060 XT (vendor=1002 device=7590), driver 32.0.32029.2010; `WaveGetLaneCount()` read back as 64 in the probe of the report above, and the RGA listings are wave64 - WARP: Microsoft Basic Render Driver (1414:008c), in-box, driver 10.0.26100.10068 - Windows build: 26300.10075, D3D12 debug layer unavailable - DXC 1.9.2602.17 (21d28f727), `-Gis -denorm preserve -T ps_6_2`; RGA 2.15.0.30 ### Limits - A pass is a strict bit-for-bit comparison of all 4096 pixels, so the mismatch count is 0 there. A failure reports the first mismatching pixel only, so I have no count of wrong pixels for the two failing shaders; that part of the request is not met. - The driver compiled both distinct inputs without `ds_swizzle`, so the `ds_swizzle` path is exercised by the uniform input only. A per-lane value that reaches `ds_swizzle` was not found. - RGA compiles its own pipeline object around the blobs. The draws are the renderer's pipeline and agree with the listings. - One device, one driver, one mask formulation. #421 was not run. <details> <summary>quad_rotate_compare.py and quad_rotate_fixture.py (uncommitted)</summary> ```powershell python -B quad_rotate_compare.py <dxc.exe> <repo>/out/build/dev/offscreen_check.exe hardware <reduction-dir> python -B quad_rotate_fixture.py <repo> <dxc.exe> <repo>/out/build/dev/offscreen_check.exe hardware <rga.exe> gfx1200 <reduction-dir> <isa-dir> ``` ```python """Local, uncommitted comparison for issue #1024: ternary select versus integer masks. The dpp8 rotation [1,2,3,0] as the translator emits it (four constant-index QuadReadLaneAt reads and a four-way ternary) against the same four reads combined with integer masks. Two inputs: the uniform word 0xf8f8f8f8, and a distinct word per quad lane, 0xd0 | (x & 1) | ((y & 1) << 1), derived from SV_Position so a wrong rotation cannot pass. A third input loads those distinct words from the constant buffer by lane (params[1][lane]), because the compiler can fold the position-derived one. Every shader returns uint4(s ^ want_s, v ^ want_v, q ^ lane, 0), where lane is the quad lane taken from SV_Position and want_* the rotation computed from it. A correct rotation writes zero in every word of every pixel, so one all-zero expectation is a strict check of the whole render target. On a failure the renderer reports the first mismatching pixel; s is then xor_word0 ^ want_s. Usage: quad_rotate_compare.py <dxc> <offscreen_check> <hardware|warp> [outdir] """ from pathlib import Path import re import struct import subprocess import sys import tempfile HEADER = ("cbuffer Constants : register(b0) { uint4 params[16]; };\n" "uint4 main(float4 uv : TEXCOORD0, float4 pos : SV_Position) : SV_Target0 {\n") INPUTS = { "uniform": " uint v = params[0].w;\n", "distinct": " uint v = 0xd0u | (uint(pos.x) & 1u) | ((uint(pos.y) & 1u) << 1u);\n", # The same words loaded from the constant buffer by lane, so the compiler cannot derive them from the position. "distinct-data": " uint v = params[1][lane];\n", } READS = (" uint q = WaveGetLaneIndex() & 3u;\n" " uint l0 = QuadReadLaneAt(v, 0);\n uint l1 = QuadReadLaneAt(v, 1);\n" " uint l2 = QuadReadLaneAt(v, 2);\n uint l3 = QuadReadLaneAt(v, 3);\n") SELECTS = { "ternary": " uint s = (q == 0u ? l1 : (q == 1u ? l2 : (q == 2u ? l3 : l0)));\n", "masks": (" uint even = (q & 1u) - 1u;\n uint top = (q >> 1u) - 1u;\n" " uint s = (((l1 & even) | (l2 & ~even)) & top)\n" " | (((l3 & even) | (l0 & ~even)) & ~top);\n"), } LANE = " uint lane = (uint(pos.x) & 1u) | ((uint(pos.y) & 1u) << 1u);\n" WANT = { "uniform": " uint want_s = params[0].w;\n uint want_v = params[0].w;\n", "distinct": " uint want_s = 0xd0u | ((lane + 1u) & 3u);\n uint want_v = 0xd0u | lane;\n", "distinct-data": " uint want_s = 0xd0u | ((lane + 1u) & 3u);\n uint want_v = 0xd0u | lane;\n", } # Every word is 0 when the rotation is right, so one all-zero expectation checks the whole target. FOOTER = " return uint4(s ^ want_s, v ^ want_v, q ^ lane, 0u);\n}\n" UNIFORM = 0xf8f8f8f8 def case(): constants = bytearray(256) struct.pack_into("<I", constants, 12, UNIFORM) # params[0].w struct.pack_into("<4I", constants, 16, 0xd0, 0xd1, 0xd2, 0xd3) # params[1], one word per quad lane return bytes(constants) + struct.pack("<4I", 0, 0, 0, 0) * 64 + bytes([1]) # flags bit 0: integer target def main(dxc, renderer, backend, outdir=None): version = subprocess.run([dxc, "--version"], capture_output=True, text=True) print("dxc=" + (version.stdout + version.stderr).strip().splitlines()[0]) with tempfile.TemporaryDirectory() as tmp: path = Path(outdir) if outdir else Path(tmp) path.mkdir(parents=True, exist_ok=True) probe = path / "zero.case" probe.write_bytes(case()) printed = False for input_name, input_text in INPUTS.items(): for select_name, select_text in SELECTS.items(): name = f"{input_name}-{select_name}" source, cso, listing = (path / f"{name}.{ext}" for ext in ("hlsl", "cso", "ll")) source.write_text(HEADER + LANE + input_text + READS + select_text + WANT[input_name] + FOOTER, encoding="ascii") subprocess.run([dxc, "-Gis", "-denorm", "preserve", "-T", "ps_6_2", "-E", "main", "-Fo", cso, "-Fc", listing, source], check=True, capture_output=True) dxil = listing.read_text(encoding="utf-8", errors="replace") shape = (f"quadReadLaneAt={dxil.count('@dx.op.quadReadLaneAt.i32(i32')} select={dxil.count(' select ')} " f"br={dxil.count(' br ')} phi={dxil.count(' phi ')}") results = [] for _ in range(3): done = subprocess.run([renderer, backend, "--check-pixel-case", cso, probe], capture_output=True, text=True) output = done.stdout + done.stderr if not printed: print("\n".join(l for l in output.splitlines() if l.startswith(("backend=", "adapter=", "driver=")))) printed = True if done.returncode == 0: size = next((l for l in output.splitlines() if l.startswith("pixels=")), "pixels=?") results.append(f"pass ({size})") elif done.returncode == 1 and "pixel_mismatch" in output: where = re.search(r"pixel_mismatch x=(\d+) y=(\d+)", output) words = re.findall(r"actual_bits=([0-9a-f]{8})", output) results.append(f"FAIL first=({where.group(1)},{where.group(2)}) xor_words={','.join(words)}") else: raise RuntimeError(output) verdict = results[0] if len(set(results)) == 1 else " / ".join(results) print(f"shader={name} dxil[{shape}] runs=3 result={verdict}") return 0 if __name__ == "__main__": sys.exit(main(*sys.argv[1:])) ``` ```python """Local, uncommitted: the #1024 wrap fixture with the ternary rotation and with integer masks. Takes the HLSL the translator emits for DPP_DOTC_WRAP_BODY (tests/pixel_aot_check.py), draws it against the fixture's own expectation and wrong-reference control, then repeats with only the dpp8 select line replaced by the mask form. Optionally compiles the reduction shaders through Radeon GPU Analyzer. Usage: quad_rotate_fixture.py <repo> <dxc> <offscreen_check> <hardware|warp> [<rga> <asic> <reduction-dir> <outdir>] """ from pathlib import Path import re import struct import subprocess import sys import tempfile TERNARY = "uint dpp29_s = (dpp29_q == 0u ? dpp29_l1 : (dpp29_q == 1u ? dpp29_l2 : (dpp29_q == 2u ? dpp29_l3 : dpp29_l0)));" MASKS = ("uint dpp29_even = (dpp29_q & 1u) - 1u; uint dpp29_top = (dpp29_q >> 1u) - 1u; " "uint dpp29_s = (((dpp29_l1 & dpp29_even) | (dpp29_l2 & ~dpp29_even)) & dpp29_top) " "| (((dpp29_l3 & dpp29_even) | (dpp29_l0 & ~dpp29_even)) & ~dpp29_top);") GPSO = ("# schemaVersion\n1.0\n\n# InputLayoutNumElements\n0\n\n# InputLayout\n\n\n#PrimitiveTopologyType\n" "D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE\n\n# NumRenderTargets\n1\n\n# RTVFormats\n" "{ DXGI_FORMAT_R32G32B32A32_UINT }\n") def run(args): done = subprocess.run([str(a) for a in args], capture_output=True, text=True) return done.returncode, done.stdout + done.stderr def main(repo, dxc, renderer, backend, rga=None, asic=None, reduction=None, outdir=None): sys.path.insert(0, str(Path(repo) / "tests")) argv, sys.argv = sys.argv, ["x"] import pixel_aot_check as p sys.argv = argv hlsl = p.translate_int(p.uncompressed_export(p.DPP_DOTC_WRAP_BODY)) assert hlsl.count(TERNARY) == 1 constants = bytearray(256) struct.pack_into("<I", constants, 12, 0xf8f8f8f8) good = bytes(constants) + struct.pack("<4I", 0x80000010, 0x80000010, 0x7ffffff0, 0x7ffffff0) * 64 + b"\x01" clamped = bytes(constants) + struct.pack("<4I", 0x7fffffff, 0x7fffffff, 0x80000000, 0x80000000) * 64 + b"\x01" with tempfile.TemporaryDirectory() as tmp: path = Path(tmp) for name, text in (("fixture-ternary", hlsl), ("fixture-masks", hlsl.replace(TERNARY, MASKS))): source, cso, case = (path / f"{name}.{ext}" for ext in ("hlsl", "cso", "case")) source.write_text(text, encoding="ascii") p.compile_shader(dxc, source, cso) results = [] for _ in range(3): case.write_bytes(good) code, output = run([renderer, backend, "--check-pixel-case", cso, case]) words = re.findall(r"actual_bits=([0-9a-f]{8})", output) where = re.search(r"pixel_mismatch x=(\d+) y=(\d+)", output) strict = "pass" if code == 0 else f"FAIL first=({where.group(1)},{where.group(2)}) words={','.join(words)}" case.write_bytes(clamped) code, output = run([renderer, backend, "--check-pixel-case", cso, case]) control = "caught" if code == 1 and "pixel_mismatch" in output else f"ESCAPED exit={code}" results.append(f"strict={strict} clamped_reference={control}") print(f"{backend} shader={name} runs=3 " + (results[0] if len(set(results)) == 1 else " / ".join(results))) if rga: out = Path(outdir) out.mkdir(parents=True, exist_ok=True) vs, rs, gpso = out / "vs.cso", out / "rs.bin", out / "state.gpso" assert run([dxc, "-T", "vs_6_0", "-E", "main", "-Fo", vs, Path(repo) / "tests" / "pixel_aot_vs.hlsl"])[0] == 0 assert run([dxc, "-dumpbin", vs, "-extractrootsignature", "-Fo", rs])[0] == 0 gpso.write_text(GPSO, encoding="ascii") print("rga=" + run([rga, "-s", "dx12", "--version"])[1].strip().splitlines()[0]) for cso in sorted(Path(reduction).glob("*.cso")): isa = out / f"{cso.stem}.isa" code, text = run([rga, "-s", "dx12", "-c", asic, "--vs-blob", vs, "--ps-blob", cso, "--rs-bin", rs, "--gpso", gpso, "--isa", isa]) print(f"rga shader={cso.stem} exit={code} " + " ".join(text.split())[:200]) return 0 if __name__ == "__main__": sys.exit(main(*sys.argv[1:])) ``` </details> AI-assisted (Claude Code - Fable 5.2); runs executed locally on the adapter above.
R0Y00 commented 2026-11-24 06:49:48 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T22:34:33Z.


Thanks for the same-adapter verification. The exact #1030 head passed three runs of the original strict fixture on RX 9060 XT, including all 18 controls, while its parent reproduced the channel-2 mismatch three times. The distinct-lane readback also checks the rotation independently. I've moved #1030 out of draft for CI. The RGA output is a useful explanation for this reproducer; it stays separate from the D3D12 readback. RX 9070 XT remains a useful independent check.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7115924055 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1024#issuecomment-7115924055). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T22:34:33Z. --- Thanks for the same-adapter verification. The exact #1030 head passed three runs of the original strict fixture on RX 9060 XT, including all 18 controls, while its parent reproduced the channel-2 mismatch three times. The distinct-lane readback also checks the rotation independently. I've moved #1030 out of draft for CI. The RGA output is a useful explanation for this reproducer; it stays separate from the D3D12 readback. RX 9070 XT remains a useful independent check.
R0Y00 commented 2026-11-24 06:49:48 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T22:36:50Z.


Fixed by #1030 on main at 4bc40d05. The original RX 9060 XT reproducer passed three strict runs with zero mismatches, including its 18 controls. Please add any RX 9070 XT retest here; a remaining mismatch can reopen this report.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7115971321 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1024#issuecomment-7115971321). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T22:36:50Z. --- Fixed by #1030 on main at 4bc40d05. The original RX 9060 XT reproducer passed three strict runs with zero mismatches, including its 18 controls. Please add any RX 9070 XT retest here; a remaining mismatch can reopen this report.
thepatrickworld commented 2026-11-24 06:49:49 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-23T22:42:30Z.


RX 9070 XT retest of the fix

Third adapter, as asked in the closing note. I ran at d1ea7d5, which merges 4bc40d05 (#1030) into the #419 branch, so the quad routing under test is #1030's.

  • Adapter: AMD Radeon RX 9070 XT 1002:7550, driver 32.0.32029.2010, debug_layer=unavailable
  • DXC 1.9.2602.17, preset dev, XBOX2WINDOWS_ADAPTER="AMD Radeon RX 9070 XT", clean tree
  • ctest --preset dev -R "^pixel_aot_dpp_extra_hardware$", original strict comparison, three runs
run exit pixel_mismatch lines
1 0 0
2 0 0
3 0 0

A verbose run of the same entry prints each draw as pixels=4096 channels=16384 max_absolute_error=0, so the full buffer is compared, not a count of matching pixels.

Same test on the parent commit 2d8a0cc, same adapter, same driver, same build settings: failed 3 of 3, channel 2, expected_bits=7ffffff0 actual_bits=80000010. So the fix holds on this adapter and the report can stay closed.

For completeness: pixel_aot_dpp_f16_hardware passes on the same head (2.47 s), and both warp entries pass (1.72 s / 2.68 s).

AI-assisted; one machine, one adapter.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7116085408 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1024#issuecomment-7116085408). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-23T22:42:30Z. --- ### RX 9070 XT retest of the fix Third adapter, as asked in the closing note. I ran at `d1ea7d5`, which merges `4bc40d05` (#1030) into the #419 branch, so the quad routing under test is #1030's. - Adapter: AMD Radeon RX 9070 XT `1002:7550`, driver `32.0.32029.2010`, `debug_layer=unavailable` - DXC `1.9.2602.17`, preset `dev`, `XBOX2WINDOWS_ADAPTER="AMD Radeon RX 9070 XT"`, clean tree - `ctest --preset dev -R "^pixel_aot_dpp_extra_hardware$"`, original strict comparison, three runs | run | exit | `pixel_mismatch` lines | |---|---|---| | 1 | 0 | 0 | | 2 | 0 | 0 | | 3 | 0 | 0 | A verbose run of the same entry prints each draw as `pixels=4096 channels=16384 max_absolute_error=0`, so the full buffer is compared, not a count of matching pixels. Same test on the parent commit `2d8a0cc`, same adapter, same driver, same build settings: failed 3 of 3, channel 2, `expected_bits=7ffffff0 actual_bits=80000010`. So the fix holds on this adapter and the report can stay closed. For completeness: `pixel_aot_dpp_f16_hardware` passes on the same head (2.47 s), and both warp entries pass (1.72 s / 2.68 s). _AI-assisted; one machine, one adapter._
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#1017
No description provided.