From f6c377b90f0701e7906e89730f40bcd774903590 Mon Sep 17 00:00:00 2001 From: KomaGuy <265821007+KomaGuy@users.noreply.github.com> Date: Wed, 25 Nov 2026 00:57:09 +0300 Subject: [PATCH] shader: lower quad-local DPP16 and DPP8 cvt_flr, cvt_rpi, and cvt_pkrtz in pixel_aot Extend the quad-local conversion DPP16/DPP8 slice (#421) with the three remaining full-32-bit/export conversion opcodes (6 forms total across DPP16 and DPP8 on gfx1013 and rdna2): - v_cvt_flr_i32_f32_dpp and v_cvt_rpi_i32_f32_dpp added to DPP_CVT, reusing the shared cvt_flr_i32_f32 and cvt_rpi_i32_f32 helpers (handling fractional rounding, saturation, infinity, and signed NaNs as in #1885) with DPP16 abs/neg bit modifiers and DPP8 modifier refusal. - v_cvt_pkrtz_f16_f32_dpp lowered as a compressed-export pair matching v_cvt_pkrtz_f16_f32_e32: src0 is quad-swizzled via emit_quad_swizzle_u32, src1 stays on the current lane, DPP16 accepts abs/neg on either source, and non-export reads of the packed destination remain refused. Extend pixel_aot_dpp_cvt_{warp,hardware} with raw-word flr_rpi rows (including fractional half-integers, overflow, infinities, signed NaNs, and 5 mutations) and a compressed-export pkrtz draw (with RTZ-vs-RNE mismatch control and 4 routing/modifier mutations), add both fixtures to check_binary, and update form_coverage_check and docs/experiments.md. --- docs/experiments.md | 4 +- tests/form_coverage_check.py | 14 ++-- tests/pixel_aot_check.py | 134 ++++++++++++++++++++++++++++++++++- tools/pixel_aot.py | 27 +++++++ 4 files changed, 170 insertions(+), 9 deletions(-) diff --git a/docs/experiments.md b/docs/experiments.md index 2c9803daa4..bc99ea9ca8 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -6488,9 +6488,9 @@ The e64 draws use `offscreen_check --check-pixel-batch > 28) * 0.0625f)", None), "cvt_i32_f32": (True, "asfloat(cvt_i32_f32({0}))", "cvt_i32_f32"), "cvt_u32_f32": (True, "asfloat(cvt_u32_f32({0}))", "cvt_u32_f32"), + "cvt_flr_i32_f32": (True, "asfloat(cvt_flr_i32_f32({0}))", "cvt_flr_i32_f32"), + "cvt_rpi_i32_f32": (True, "asfloat(cvt_rpi_i32_f32({0}))", "cvt_rpi_i32_f32"), } DPP_INT32 = { "not_b32": (1, "(~{0})", None), @@ -5584,6 +5586,31 @@ def sample_coord(reg): helpers.add(helper) vector[dst] = f"alu{i}" lines.append(f" precise float alu{i} = {template.format(bits)};") + elif m := match(r"v_cvt_pkrtz_f16_f32_dpp (v\d+), (.+)"): + # Quad-local DPP16/DPP8 compressed-export pack: src0 is swizzled across the quad, + # src1 stays on the current lane, DPP16 allows abs/neg on either source, and the + # destination holds the same (lo, hi) compressed-export pair as v_cvt_pkrtz_f16_f32_e32. + dst, rest = m.groups() + if mask != "entry" or not 0 <= int(dst[1:]) <= 255: + raise ValueError("Invalid pack DPP operation") + if dst in sample_dest: + raise ValueError("Write overlaps an outstanding sample") + tokens, perm, is_dpp8 = parse_dpp(rest, 2) + s0_val, abs0, neg0 = dpp_vgpr(tokens[0], vector, sample_dest, allow_mods=not is_dpp8) + s1_val, abs1, neg1 = dpp_vgpr(tokens[1], vector, sample_dest, allow_mods=not is_dpp8) + s0_bits = emit_quad_swizzle_u32(lines, i, s0_val, perm) + if abs0: + s0_bits = f"({s0_bits} & 0x7fffffffu)" + if neg0: + s0_bits = f"({s0_bits} ^ 0x80000000u)" + s1_bits = f"asuint({s1_val})" + if abs1: + s1_bits = f"({s1_bits} & 0x7fffffffu)" + if neg1: + s1_bits = f"({s1_bits} ^ 0x80000000u)" + lines.append(f" precise float alu{i}_lo = asfloat({s0_bits});") + lines.append(f" precise float alu{i}_hi = asfloat({s1_bits});") + vector[dst] = (f"alu{i}_lo", f"alu{i}_hi") elif m := match(rf"({'|'.join(DPP_EXTRA)}) (v\d+), (.+)"): op, dst, rest = m.groups() if mask != "entry" or not 0 <= int(dst[1:]) <= 255: