From eab8701e7c23cd11e991624804487ecb393c54eb Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 13 May 2020 14:53:21 -0400 Subject: [PATCH] panfrost: Flesh out dispatch Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/util/pan_lower_framebuffer.c | 52 +++++++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/src/panfrost/util/pan_lower_framebuffer.c b/src/panfrost/util/pan_lower_framebuffer.c index dc0aa9ab847..4d85e8a47ed 100644 --- a/src/panfrost/util/pan_lower_framebuffer.c +++ b/src/panfrost/util/pan_lower_framebuffer.c @@ -258,8 +258,30 @@ pan_unpack(nir_builder *b, const struct util_format_description *desc, nir_ssa_def *packed) { - /* Stub */ - return packed; + if (util_format_is_unorm8(desc)) + return pan_unpack_unorm_8(b, packed, desc->nr_channels); + + if (desc->is_array) { + int c = util_format_get_first_non_void_channel(desc->format); + assert(c >= 0); + struct util_format_channel_description d = desc->channel[c]; + + if (d.size == 32 || d.size == 16) { + assert(!d.normalized); + assert(d.type == UTIL_FORMAT_TYPE_FLOAT || d.pure_integer); + + return d.size == 32 ? pan_unpack_pure_32(b, packed, desc->nr_channels) : + pan_unpack_pure_16(b, packed, desc->nr_channels); + } else if (d.size == 8) { + assert(d.pure_integer); + return pan_unpack_pure_8(b, packed, desc->nr_channels); + } else { + unreachable("Unrenderable size"); + } + } + + fprintf(stderr, "%s\n", desc->name); + unreachable("Unknown format"); } static nir_ssa_def * @@ -267,8 +289,30 @@ pan_pack(nir_builder *b, const struct util_format_description *desc, nir_ssa_def *unpacked) { - /* Stub */ - return unpacked; + if (util_format_is_unorm8(desc)) + return pan_pack_unorm_8(b, unpacked); + + if (desc->is_array) { + int c = util_format_get_first_non_void_channel(desc->format); + assert(c >= 0); + struct util_format_channel_description d = desc->channel[c]; + + if (d.size == 32 || d.size == 16) { + assert(!d.normalized); + assert(d.type == UTIL_FORMAT_TYPE_FLOAT || d.pure_integer); + + return d.size == 32 ? pan_pack_pure_32(b, unpacked) : + pan_pack_pure_16(b, unpacked); + } else if (d.size == 8) { + assert(d.pure_integer); + return pan_pack_pure_8(b, unpacked); + } else { + unreachable("Unrenderable size"); + } + } + + fprintf(stderr, "%s\n", desc->name); + unreachable("Unknown format"); } static void -- 2.30.2