diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 75eb1a59da..919b710ce8 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -70,6 +70,7 @@ jobs: (["tests/mesh_shadow_check.py", *COMMON_LLVM], {}), (["tests/startup_sampler_heap_check.py", "binary", "llvm-mc-15"], {}), (["tests/startup_gfx2hlsl_cvt_alu_check.py", "binary", "llvm-mc-15"], {}), + (["tests/startup_gfx2hlsl_pknorm_u16_check.py", "binary", "llvm-mc-15"], {}), (["tests/startup_image_sample_l_check.py", "binary", "llvm-mc-15"], {}), (["tests/startup_image_sample_c_check.py", "binary", "llvm-mc-15"], {}), (["tests/startup_image_3d_check.py", "binary", "llvm-mc-15"], {}), @@ -175,6 +176,7 @@ jobs: tests/startup_image_2d_array_check.py \ tests/startup_host_cpu_check.py \ tests/startup_gfx2hlsl_cvt_alu_check.py \ + tests/startup_gfx2hlsl_pknorm_u16_check.py \ tests/startup_gfx2hlsl_capture_check.py \ tests/startup_translator_check.py \ tests/startup_gfx2hlsl_smem_offset_check.py \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 335f829a3a..47f2fc7f6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1755,6 +1755,16 @@ if(EXISTS "${INTAKE_PYTHON}") "$" ${adapter} $<$:${STARTUP_FXC}>) set_tests_properties(startup_gfx2hlsl_cvt_alu_${adapter} PROPERTIES TIMEOUT 300 SKIP_RETURN_CODE 77) endforeach() + # v_cvt_pknorm_u16_f32: translation controls, then a draw of the translated pairs with reference words and + # three mutated lowerings (rounding, upper clamp, order of the halves). + add_test(NAME startup_gfx2hlsl_pknorm_u16_controls COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_SOURCE_DIR}/tests/startup_gfx2hlsl_pknorm_u16_check.py") + foreach(adapter IN ITEMS warp hardware) + add_test(NAME startup_gfx2hlsl_pknorm_u16_${adapter} COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_SOURCE_DIR}/tests/startup_gfx2hlsl_pknorm_u16_check.py" draw "${DXC_EXECUTABLE}" + "$" ${adapter} $<$:${STARTUP_FXC}>) + set_tests_properties(startup_gfx2hlsl_pknorm_u16_${adapter} PROPERTIES TIMEOUT 300 SKIP_RETURN_CODE 77) + endforeach() add_test(NAME startup_sampler_heap_controls COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_SOURCE_DIR}/tests/startup_sampler_heap_check.py") add_test(NAME startup_vertex_fetch_formats_controls COMMAND "${INTAKE_PYTHON}" -B diff --git a/tests/startup_gfx2hlsl_pknorm_u16_check.py b/tests/startup_gfx2hlsl_pknorm_u16_check.py new file mode 100644 index 0000000000..bbd0645f44 --- /dev/null +++ b/tests/startup_gfx2hlsl_pknorm_u16_check.py @@ -0,0 +1,167 @@ +"""v_cvt_pknorm_u16_f32 of tools/startup/gfx2hlsl.py. + + (no arguments) translation controls, pure Python + binary reassemble the pixel body and compare it with the recorded words + draw [fxc] + draw one pixel per four input sets and compare the four result words + +The instruction is VOP3 only (opcode 0x369, no e32 form): bits 15:0 of the result hold clamp(S0, 0, 1) * 65535 and +bits 31:16 hold clamp(S1, 0, 1) * 65535, each rounded to nearest even, with a NaN reading 0. Source neg and abs apply +to the float inputs. An output modifier or op_sel changes the packed words and is refused. The fixture and runner are +startup_gfx2hlsl_lane_alu.py. + +The reference rounds the binary32 product clamp(x) * 65535, which is what the translated shader computes. For 1.5/65535 +that product is exactly 1.5 and ties to 2, while the exact rational value of the nearest binary32 input is just below +1.5; the reference follows the binary32 product. No hardware run of this instruction was available when this check was +written, so the draw mode (WARP and GPU) is what confirms it. + +A result with a high half of 0 is a binary32 denormal when the fixture exports it to the float target, and FXC ps_5_1 +reads such a word as 0 (see startup_gfx2hlsl_cvt_alu_check.py), so the draw goes through DXC ps_6_0 only; an optional FXC +argument is accepted and ignored. + +Three mutated lowerings are checked, one per rule: the rounding of the low half, the upper clamp of the high half, and +the order of the two halves. +""" +import re +import struct +import sys +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import startup_gfx2hlsl_lane_alu as lane # noqa: E402 +from startup_gfx2hlsl_lane_alu import check_draw, words # noqa: E402 + +OP = 'v_cvt_pknorm_u16_f32' + + +def f32(value): + """The binary32 word of a Python number, rounded to nearest even.""" + return struct.unpack('