From 12652cc54932ae1f2b2d8c71ce6c613f93283498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Tue, 24 Jan 2023 18:53:52 +0100 Subject: [PATCH] nir: Add pack_half_2x16_rtz_split opcode. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same as pack_half_2x16_rtz_split, but always uses RTZ mode. Note that pack_half_2x16 rounding mode is unspecified. Signed-off-by: Timur Kristóf Acked-by: Alyssa Rosenzweig Reviewed-by: Georg Lehmann Reviewed-by: Jason Ekstrand Part-of: --- src/compiler/nir/nir.h | 3 +++ src/compiler/nir/nir_constant_expressions.py | 9 +++++++++ src/compiler/nir/nir_opcodes.py | 3 +++ 3 files changed, 15 insertions(+) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 1317b16629b..c7559f9ea2f 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3669,6 +3669,9 @@ typedef struct nir_shader_compiler_options { /** Backend supports 32bit ufind_msb_rev and ifind_msb_rev. */ bool has_find_msb_rev; + /** Backend supports pack_half_2x16_rtz_split. */ + bool has_pack_half_2x16_rtz; + /** * Is this the Intel vec4 backend? * diff --git a/src/compiler/nir/nir_constant_expressions.py b/src/compiler/nir/nir_constant_expressions.py index b82d96d6070..a11a784d3e6 100644 --- a/src/compiler/nir/nir_constant_expressions.py +++ b/src/compiler/nir/nir_constant_expressions.py @@ -251,6 +251,15 @@ pack_half_1x16(float x) return _mesa_float_to_half(x); } +/** + * Evaluate one component of packHalf2x16, RTZ mode. + */ +static uint16_t +pack_half_1x16_rtz(float x) +{ + return _mesa_float_to_float16_rtz(x); +} + /** * Evaluate one component of unpackHalf2x16. */ diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index 5b58dd45f4f..2a3ea791463 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -912,6 +912,9 @@ binop("fpow", tfloat, "", "bit_size == 64 ? powf(src0, src1) : pow(src0, src1)") binop_horiz("pack_half_2x16_split", 1, tuint32, 1, tfloat32, 1, tfloat32, "pack_half_1x16(src0.x) | (pack_half_1x16(src1.x) << 16)") +binop_horiz("pack_half_2x16_rtz_split", 1, tuint32, 1, tfloat32, 1, tfloat32, + "pack_half_1x16_rtz(src0.x) | (pack_half_1x16_rtz(src1.x) << 16)") + binop_convert("pack_64_2x32_split", tuint64, tuint32, "", "src0 | ((uint64_t)src1 << 32)")