nir: pack_(s|u)norm_2x16 support float16 as input

For AMD GPU which has instruction to normalize and pack two float16
inputs, and used when fragment shader export color output.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21552>
This commit is contained in:
Qiang Yu 2023-02-24 13:57:33 +08:00 committed by Marge Bot
parent c30194e9ec
commit 6848e05f9c

View file

@ -328,8 +328,8 @@ unop("fddy_coarse", tfloat, "0.0")
# Floating point pack and unpack operations.
def pack_2x16(fmt):
unop_horiz("pack_" + fmt + "_2x16", 1, tuint32, 2, tfloat32, """
def pack_2x16(fmt, in_type):
unop_horiz("pack_" + fmt + "_2x16", 1, tuint32, 2, in_type, """
dst.x = (uint32_t) pack_fmt_1x16(src0.x);
dst.x |= ((uint32_t) pack_fmt_1x16(src0.y)) << 16;
""".replace("fmt", fmt))
@ -357,11 +357,11 @@ dst.w = unpack_fmt_1x8((uint8_t)(src0.x >> 24));
""".replace("fmt", fmt))
pack_2x16("snorm")
pack_2x16("snorm", tfloat)
pack_4x8("snorm")
pack_2x16("unorm")
pack_2x16("unorm", tfloat)
pack_4x8("unorm")
pack_2x16("half")
pack_2x16("half", tfloat32)
unpack_2x16("snorm")
unpack_4x8("snorm")
unpack_2x16("unorm")