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 <samuel.pitoiset@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15231>
This commit is contained in:
Samuel Pitoiset 2022-03-03 08:37:29 +01:00 committed by Marge Bot
parent 4d81c60e11
commit 6532307555
2 changed files with 13 additions and 0 deletions

View File

@ -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"
/**

View File

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