From fcbc022787d4fdfcfdf843d9f720a587e1f0579d Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 13 May 2020 13:51:06 -0400 Subject: [PATCH] nir: Add un/pack_32_4x8 opcodes Complement the existing un/pack_32_2x16 opcodes. These are useful for 8-bit format packing. On Midgard, they are equivalent to just a 32-bit move, but other GPUs could lower to other packs if needed. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Eric Anholt Part-of: --- src/compiler/nir/nir_opcodes.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index 03f00d12639..142d7a427d5 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -99,6 +99,7 @@ tbool8 = "bool8" tbool16 = "bool16" tbool32 = "bool32" tuint = "uint" +tuint8 = "uint8" tuint16 = "uint16" tfloat16 = "float16" tfloat32 = "float32" @@ -357,6 +358,9 @@ dst.x = (src0.x << 0) | (src0.w << 24); """) +unop_horiz("pack_32_4x8", 1, tuint32, 4, tuint8, + "dst.x = src0.x | ((uint32_t)src0.y << 8) | ((uint32_t)src0.z << 16) | ((uint32_t)src0.w << 24);") + unop_horiz("pack_32_2x16", 1, tuint32, 2, tuint16, "dst.x = src0.x | ((uint32_t)src0.y << 16);") @@ -375,6 +379,9 @@ unop_horiz("unpack_64_4x16", 4, tuint16, 1, tuint64, unop_horiz("unpack_32_2x16", 2, tuint16, 1, tuint32, "dst.x = src0.x; dst.y = src0.x >> 16;") +unop_horiz("unpack_32_4x8", 4, tuint8, 1, tuint32, + "dst.x = src0.x; dst.y = src0.x >> 8; dst.z = src0.x >> 16; dst.w = src0.x >> 24;") + unop_horiz("unpack_half_2x16_flush_to_zero", 2, tfloat32, 1, tuint32, """ dst.x = unpack_half_1x16_flush_to_zero((uint16_t)(src0.x & 0xffff)); dst.y = unpack_half_1x16_flush_to_zero((uint16_t)(src0.x << 16)); -- 2.30.2