panfrost: Calculate varying size by format
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 10 Jun 2020 19:35:41 +0000 (15:35 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 12 Jun 2020 14:45:50 +0000 (14:45 +0000)
Will enable <16-byte varyings.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5423>

src/gallium/drivers/panfrost/pan_cmdstream.c
src/panfrost/include/panfrost-job.h

index 1533494c7f047615ba3e9c651f5b05088816f8e3..5c0d7f4d0e9e7c0af55a85ebc9d9c82ce3fef155 100644 (file)
@@ -1721,6 +1721,32 @@ pan_get_so(struct pipe_stream_output_info *info, gl_varying_slot loc)
         unreachable("Varying not captured");
 }
 
+static unsigned
+pan_varying_size(enum mali_format fmt)
+{
+        unsigned type = MALI_EXTRACT_TYPE(fmt);
+        unsigned chan = MALI_EXTRACT_CHANNELS(fmt);
+        unsigned bits = MALI_EXTRACT_BITS(fmt);
+        unsigned bpc = 0;
+
+        if (bits == MALI_CHANNEL_FLOAT) {
+                /* No doubles */
+                bool fp16 = (type == MALI_FORMAT_SINT);
+                assert(fp16 || (type == MALI_FORMAT_UNORM));
+
+                bpc = fp16 ? 2 : 4;
+        } else {
+                assert(type >= MALI_FORMAT_SNORM && type <= MALI_FORMAT_SINT);
+
+                /* See the enums */
+                bits = 1 << bits;
+                assert(bits >= 8);
+                bpc = bits / 8;
+        }
+
+        return bpc * chan;
+}
+
 void
 panfrost_emit_varying_descriptor(struct panfrost_batch *batch,
                                  unsigned vertex_count,
index 0829b9bfb5791bd1048fe0a1b441c319b8cee1ba..d6f1fc861da0bafaef3d301adf35fe9d60a63935 100644 (file)
@@ -251,6 +251,7 @@ struct mali_channel_swizzle {
  * for Bifrost framebuffer output.
  */
 #define MALI_FORMAT_SPECIAL2 (7 << 5)
+#define MALI_EXTRACT_TYPE(fmt) ((fmt) & 0xe0)
 
 /* If the high 3 bits are 3 to 6 these two bits say how many components
  * there are.
@@ -274,6 +275,7 @@ struct mali_channel_swizzle {
  * MALI_FORMAT_UNORM, it means a 32-bit float.
  */
 #define MALI_CHANNEL_FLOAT 7
+#define MALI_EXTRACT_BITS(fmt) (fmt & 0x7)
 
 enum mali_format {
        MALI_ETC2_RGB8       = MALI_FORMAT_COMPRESSED | 0x1,