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)")