panfrost: Flesh out dispatch
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 13 May 2020 18:53:21 +0000 (14:53 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 1 Jun 2020 15:46:23 +0000 (15:46 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5265>

src/panfrost/util/pan_lower_framebuffer.c

index dc0aa9ab84706dc239e5dfc9636540d2d7bc37a6..4d85e8a47edd60647ec006307dfc759f107cce64 100644 (file)
@@ -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