From 6532307555775550ae92db62f983ecb65e15b0cd Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 3 Mar 2022 08:37:29 +0100 Subject: [PATCH] nir: introduce nir_pack_{sint,uint}_2x16 instructions These instructions have AMD hardware equivalent and they will be used to lower fragment shader outputs in NIR. Signed-off-by: Samuel Pitoiset Reviewed-by: Jason Ekstrand Reviewed-by: Rhys Perry Part-of: --- src/compiler/nir/nir_constant_expressions.py | 1 + src/compiler/nir/nir_opcodes.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/compiler/nir/nir_constant_expressions.py b/src/compiler/nir/nir_constant_expressions.py index 3876b68..b82d96d 100644 --- a/src/compiler/nir/nir_constant_expressions.py +++ b/src/compiler/nir/nir_constant_expressions.py @@ -64,6 +64,7 @@ template = """\ #include "util/double.h" #include "util/softfloat.h" #include "util/bigmath.h" +#include "util/format/format_utils.h" #include "nir_constant_expressions.h" /** diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index a490ea3..d23420a3 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -367,6 +367,18 @@ unpack_2x16("unorm") unpack_4x8("unorm") unpack_2x16("half") +# Convert two unsigned integers into a packed unsigned short (clamp is applied). +unop_horiz("pack_uint_2x16", 1, tuint32, 2, tuint32, """ +dst.x = _mesa_unsigned_to_unsigned(src0.x, 16); +dst.x |= _mesa_unsigned_to_unsigned(src0.y, 16) << 16; +""") + +# Convert two signed integers into a packed signed short (clamp is applied). +unop_horiz("pack_sint_2x16", 1, tint32, 2, tint32, """ +dst.x = _mesa_signed_to_signed(src0.x, 16) & 0xffff; +dst.x |= _mesa_signed_to_signed(src0.y, 16) << 16; +""") + unop_horiz("pack_uvec2_to_uint", 1, tuint32, 2, tuint32, """ dst.x = (src0.x & 0xffff) | (src0.y << 16); """) -- 2.7.4