diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index db21607e12..5d676d0b8b 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -332,6 +332,7 @@ jobs: tests/startup_gfx2hlsl_s_bitset_check.py \ tests/startup_gfx2hlsl_s_flbit_check.py \ tests/startup_gfx2hlsl_s_ff1_check.py \ + tests/startup_gfx2hlsl_src_scc_check.py \ tests/startup_gfx2hlsl_s_quadmask_check.py \ tests/startup_gfx2hlsl_fma_mix_check.py \ tests/startup_gfx2hlsl_shift64_check.py \ diff --git a/CMakeLists.txt b/CMakeLists.txt index fc51abd423..29b10b499e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3441,6 +3441,14 @@ if(EXISTS "${INTAKE_PYTHON}") # The src_scc scalar source (#1820). add_test(NAME startup_gfx2hlsl_src_scc COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_src_scc_check.py") + # D3D12 UAV readback of s_cmp_eq_u32 + s_mov_b32 sX, src_scc on WARP/hardware vs the CPU reference, + # with a mutated-lowering negative control (same dispatch pattern as s_ff1). + foreach(adapter IN ITEMS warp hardware) + add_test(NAME startup_gfx2hlsl_src_scc_dispatch_${adapter} COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_src_scc_check.py" dispatch "${DXC_EXECUTABLE}" + "$" ${adapter}) + set_tests_properties(startup_gfx2hlsl_src_scc_dispatch_${adapter} PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77) + endforeach() # src_scc at a branch target that one uniform SCC write reaches on every path. add_test(NAME startup_gfx2hlsl_src_scc_join COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_src_scc_join_check.py") diff --git a/docs/experiments.md b/docs/experiments.md index 4346e02bce..d315a96d0f 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -16874,3 +16874,7 @@ or `scalar_wide_op()`). Reads where incoming SCC is unverified are refused: at s control-flow joins/branch targets, after descriptor-elided SCC writes, and after unmodeled SCC writers in `SCC_UNMODELLED` such as `s_add_u32` (after `s_add_u32` finishes reading its own sources). Run `ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_src_scc$' -V`. +The `_dispatch_warp` and `_dispatch_hardware` tests run `s_cmp_eq_u32` then `s_mov_b32 sX, src_scc` on a D3D12 +UAV dispatch and compare each lane with the CPU reference (SCC 0 and SCC 1, distinct per-case data). A copy of the +lowering mutated to `(scc ? 0u : 1u)` must read back wrong. Run +`ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_src_scc_dispatch_warp$' -V`. diff --git a/tests/startup_gfx2hlsl_src_scc_check.py b/tests/startup_gfx2hlsl_src_scc_check.py index e97bb05957..9a6c64a910 100644 --- a/tests/startup_gfx2hlsl_src_scc_check.py +++ b/tests/startup_gfx2hlsl_src_scc_check.py @@ -1,6 +1,7 @@ """The `src_scc` scalar source in tools/startup/gfx2hlsl.py (issue #1820). usage: startup_gfx2hlsl_src_scc_check.py + startup_gfx2hlsl_src_scc_check.py dispatch The census contained `s_mul_i32 s28, 1.0, src_scc`, refused as `operand 'src_scc'` (#870, issue #1820). Source code 253 reads the SCC bit as the integer value 0 or 1; the generated shader carries SCC as a @@ -18,7 +19,10 @@ """ import os import struct +import subprocess import sys +import tempfile +from pathlib import Path here = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(here, '..', 'tools')) @@ -106,6 +110,110 @@ def refused_reason(code): return None +MASK = 0xFFFFFFFF +SOP1_MOV_B32 = 0x03 +# (a, b) pairs: s_cmp_eq_u32 sets SCC = (a == b), then s_mov_b32 s3, src_scc stores it. +DISPATCH_CASES = ((0, 0), (1, 1), (0xFFFFFFFF, 0xFFFFFFFF), (0x12345678, 0x12345678), + (0, 1), (1, 0), (0x80000000, 0x00000001), (0xFFFFFFFF, 0xFFFFFFFE)) + + +def encode_sop1(op, sdst, ssrc): + return struct.pack('