From fd9c6e8acff66055d4d647d3ffca21ed60ae7a3e Mon Sep 17 00:00:00 2001 From: Luuk Motz Date: Tue, 1 Dec 2026 09:06:24 +0100 Subject: [PATCH 1/2] shader: lower v_rcp_iflag_f32 and v_ashrrev_i32 in the mesh frontend Both are already lowered by the shared ALU (the reciprocal as v_rcp_f32, the shift as an arithmetic right shift by src0 & 31). The mesh lane ALU list now admits them, so the full_exec || exec_skip rule and the partial-write merge apply unchanged. Co-Authored-By: Claude Opus 5.5 --- src/gfx1013_direct_mesh.inl | 4 ++-- tests/native_direct_mesh_check.py | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gfx1013_direct_mesh.inl b/src/gfx1013_direct_mesh.inl index abc97056b8..ed9c7c6853 100644 --- a/src/gfx1013_direct_mesh.inl +++ b/src/gfx1013_direct_mesh.inl @@ -2100,8 +2100,8 @@ NativeComputeShader lower_mesh(const string &code, const MeshStageLayout &layout i.name=="v_mad_f32" || i.name=="v_mul_lo_u32" || i.name=="v_mul_hi_u32" || i.name=="v_mac_f32" || i.name=="v_mul_legacy_f32" || i.name=="v_sub_f32" || i.name=="v_subrev_f32" || i.name=="v_fmac_f32" || i.name=="v_fmaak_f32" || - i.name=="v_rsq_f32" || i.name=="v_rcp_f32" || i.name=="v_sqrt_f32" || - i.name=="v_fma_mixlo_f16" || i.name=="v_fma_mixhi_f16" || i.name=="v_fma_mix_f32" || i.name=="v_pack_b32_f16" || + i.name=="v_rsq_f32" || i.name=="v_rcp_f32" || i.name=="v_rcp_iflag_f32" || i.name=="v_sqrt_f32" || + i.name=="v_ashrrev_i32" || i.name=="v_fma_mixlo_f16" || i.name=="v_fma_mixhi_f16" || i.name=="v_fma_mix_f32" || i.name=="v_pack_b32_f16" || i.name=="v_sin_f32" || i.name=="v_cos_f32" || i.name.substr(0,15)=="v_cvt_f32_ubyte" || i.name=="v_min_u32" || i.name=="v_max_f32" || i.name=="v_mad_u32_u24" || i.name=="v_add3_u32" || i.name=="v_bfe_u32" || i.name=="v_mov_b32" || i.name=="v_add_nc_u32" || i.name=="v_sub_nc_u32" || i.name=="v_subrev_nc_u32" || i.name=="v_add_co_ci_u32" || i.name=="v_lshlrev_b32" || diff --git a/tests/native_direct_mesh_check.py b/tests/native_direct_mesh_check.py index 0816a19356..a8a74e0878 100644 --- a/tests/native_direct_mesh_check.py +++ b/tests/native_direct_mesh_check.py @@ -299,6 +299,15 @@ def run(name, words, expected=None): text = run('v-mad-f32', program[:5] + program[6:7] + mad + program[7:]) assert re.search(r'fmul float', text) and re.search(r'fadd float', text), text assert '@dx.op.tertiary.f32' not in text, text + # VOP2 0x18: v_ashrrev_i32 v1, 2, v0 shifts v0 right by 2, keeping the sign (ashr, not lshr). + text = run('v-ashrrev-i32', program[:5] + program[6:7] + [0x30020082] + program[7:]) + shifted = re.search(rf'(?P{value}) = and i32 2, 31\n\s*(?P{value}) = ashr i32 {value}, (?P=amount)\n', text) + assert shifted, text + assert_position_x(text, rf'ashr i32 {value}, {re.escape(shifted["amount"])}') + # VOP1 0x2b: v_rcp_iflag_f32 v1, v0 is the same reciprocal as v_rcp_f32; the flag only + # changes IEEE exception reporting, which DXIL does not expose. + text = run('v-rcp-iflag-f32', program[:5] + program[6:7] + [0x7e025700] + program[7:]) + assert re.search(rf'{value} = fdiv float 1\.000000e\+00, {value}\n', text), text # Pack the thread ID, the inline constant 2 and the sign-extended immediate in s7. pack_position = [0xb0078000, 0xd7720001, 256 | (130 << 9) | (7 << 18)] text = run('v-or3-b32', program[:5] + program[6:7] + pack_position + program[7:]) From 95e4d369cf1bef6366c05605d50852bd557c6e56 Mon Sep 17 00:00:00 2001 From: Luuk Motz Date: Tue, 1 Dec 2026 09:34:21 +0100 Subject: [PATCH 2/2] tests: follow v_rcp_iflag_f32 to the exported position Review follow-up on #3709: v-rcp-iflag-f32 now checks that the reciprocal's bits reach the exported X, as v-ashrrev-i32 already does. Co-Authored-By: Claude Opus 5.5 --- tests/native_direct_mesh_check.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/native_direct_mesh_check.py b/tests/native_direct_mesh_check.py index a8a74e0878..9e5f88046f 100644 --- a/tests/native_direct_mesh_check.py +++ b/tests/native_direct_mesh_check.py @@ -307,7 +307,10 @@ def run(name, words, expected=None): # VOP1 0x2b: v_rcp_iflag_f32 v1, v0 is the same reciprocal as v_rcp_f32; the flag only # changes IEEE exception reporting, which DXIL does not expose. text = run('v-rcp-iflag-f32', program[:5] + program[6:7] + [0x7e025700] + program[7:]) - assert re.search(rf'{value} = fdiv float 1\.000000e\+00, {value}\n', text), text + reciprocal = re.search(rf'(?P{value}) = fdiv float 1\.000000e\+00, {value}\n', text) + assert reciprocal, text + # The reciprocal's bits are v1, which the fixture converts and exports as X. + assert_position_x(text, rf'bitcast float {re.escape(reciprocal["rcp"])} to i32') # Pack the thread ID, the inline constant 2 and the sign-extended immediate in s7. pack_position = [0xb0078000, 0xd7720001, 256 | (130 << 9) | (7 << 18)] text = run('v-or3-b32', program[:5] + program[6:7] + pack_position + program[7:])