diff --git a/CMakeLists.txt b/CMakeLists.txt index 98583ab9c2..1eaa19e74c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1871,6 +1871,10 @@ if(EXISTS "${INTAKE_PYTHON}") set_tests_properties(startup_gfx2hlsl_capture PROPERTIES TIMEOUT 120) # Two integer operations whose refusal was never reached: v_cvt_i32_f32 with an output # modifier, and v_readfirstlane_b32 without a proven uniform source. + # Source code 253 (src_scc) reads the SCC bit as an integer; the census form refused it (#1820). + add_test(NAME startup_gfx2hlsl_src_scc COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_src_scc_check.py") + set_tests_properties(startup_gfx2hlsl_src_scc PROPERTIES TIMEOUT 60) add_test(NAME startup_gfx2hlsl_op_refusals COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_op_refusals_check.py") set_tests_properties(startup_gfx2hlsl_op_refusals PROPERTIES TIMEOUT 60) diff --git a/tests/startup_gfx2hlsl_src_scc_check.py b/tests/startup_gfx2hlsl_src_scc_check.py new file mode 100644 index 0000000000..55f147a4ec --- /dev/null +++ b/tests/startup_gfx2hlsl_src_scc_check.py @@ -0,0 +1,84 @@ +"""The src_scc scalar operand (source code 253) in tools/startup/gfx2hlsl.py. + +Source code 253 reads the SCC bit as the integer 0 or 1. The translator refused it as an unknown +operand, so `s_mul_i32 s28, 1.0, src_scc` (the census form in #1820) never lowered. The generated +scalar code keeps SCC in `scc`, so the operand becomes `(scc ? 1u : 0u)`. + +Every instruction here is built from the layout tools/disasm_rdna2.py decodes: SOP2 is +`[31:30] == 0b10`, opcode `w0[29:23]`, destination `w0[22:16]`, src1 `w0[15:8]`, src0 `w0[7:0]`; +inline integer 1.0 is source code 242 and src_scc is 253. +""" +import struct +import sys +from pathlib import Path + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE.parent / 'tools')) +sys.path.insert(0, str(HERE.parent / 'tools' / 'startup')) +import disasm_rdna2 as D # noqa: E402 +import gfx2hlsl as G # noqa: E402 + +SRC_SCC = 253 +INLINE_ONE = 242 +S_AND_B32 = 0x0e +S_MUL_I32 = 0x26 + + +def sop2(op, sdst, ssrc0, ssrc1): + return struct.pack('