panfrost: Squash 22-bit format field in attr_meta
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 12 Aug 2020 02:26:03 +0000 (22:26 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 17 Aug 2020 11:43:52 +0000 (11:43 +0000)
This is an intermediate step to support v7 style formats. Now we don't
see the mali_format alone, instead together with the swizzle (and sRGB
flag, unused for attributes of course).

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6326>

src/gallium/drivers/panfrost/pan_cmdstream.c
src/gallium/drivers/panfrost/pan_context.c
src/panfrost/include/panfrost-job.h
src/panfrost/lib/decode.c
src/panfrost/lib/pan_blit.c

index 31c19679b6a80f3c6765b0f1ec7b1ec34bf49848..3e260bca0c60d0a741eec2d5c76e18869219924c 100644 (file)
@@ -1657,14 +1657,14 @@ pan_emit_vary(unsigned present, enum pan_special_varying buf,
                 unsigned offset)
 {
         unsigned nr_channels = MALI_EXTRACT_CHANNELS(format);
+        unsigned swizzle = quirks & HAS_SWIZZLES ?
+                        panfrost_get_default_swizzle(nr_channels) :
+                        panfrost_bifrost_swizzle(nr_channels);
 
         struct mali_attr_meta meta = {
                 .index = pan_varying_index(present, buf),
                 .unknown1 = quirks & IS_BIFROST ? 0x0 : 0x2,
-                .swizzle = quirks & HAS_SWIZZLES ?
-                        panfrost_get_default_swizzle(nr_channels) :
-                        panfrost_bifrost_swizzle(nr_channels),
-                .format = format,
+                .format = (format << 12) | swizzle,
                 .src_offset = offset
         };
 
@@ -1718,6 +1718,10 @@ pan_emit_vary_xfb(unsigned present,
                 enum mali_format format,
                 struct pipe_stream_output o)
 {
+        unsigned swizzle = quirks & HAS_SWIZZLES ?
+                        panfrost_get_default_swizzle(o.num_components) :
+                        panfrost_bifrost_swizzle(o.num_components);
+
         /* Otherwise construct a record for it */
         struct mali_attr_meta meta = {
                 /* XFB buffers come after everything else */
@@ -1726,13 +1730,8 @@ pan_emit_vary_xfb(unsigned present,
                 /* As usual unknown bit */
                 .unknown1 = quirks & IS_BIFROST ? 0x0 : 0x2,
 
-                /* Override swizzle with number of channels */
-                .swizzle = quirks & HAS_SWIZZLES ?
-                        panfrost_get_default_swizzle(o.num_components) :
-                        panfrost_bifrost_swizzle(o.num_components),
-
                 /* Override number of channels and precision to highp */
-                .format = pan_xfb_format(format, o.num_components),
+                .format = (pan_xfb_format(format, o.num_components) << 12) | swizzle,
 
                 /* Apply given offsets together */
                 .src_offset = (o.dst_offset * 4) /* dwords */
index 0efe0a90fc39e188fab80296c4b9f63a3d12c4fd..736954745e9b521f9784c05c9343a2554ae71b9b 100644 (file)
@@ -507,28 +507,28 @@ panfrost_create_vertex_elements_state(
                 const struct util_format_description *desc = util_format_description(fmt);
                 so->hw[i].unknown1 = 0x2;
 
+                unsigned swizzle = 0;
                 if (dev->quirks & HAS_SWIZZLES)
-                        so->hw[i].swizzle = panfrost_translate_swizzle_4(desc->swizzle);
+                        swizzle = panfrost_translate_swizzle_4(desc->swizzle);
                 else
-                        so->hw[i].swizzle = panfrost_bifrost_swizzle(desc->nr_channels);
+                        swizzle = panfrost_bifrost_swizzle(desc->nr_channels);
 
                 enum mali_format hw_format = panfrost_pipe_format_table[desc->format].hw;
-                so->hw[i].format = hw_format;
+                so->hw[i].format = (hw_format << 12) | swizzle;
                 assert(hw_format);
         }
 
         /* Let's also prepare vertex builtins */
         so->hw[PAN_VERTEX_ID].format = MALI_R32UI;
         if (dev->quirks & HAS_SWIZZLES)
-                so->hw[PAN_VERTEX_ID].swizzle = panfrost_get_default_swizzle(1);
+                so->hw[PAN_VERTEX_ID].format = (MALI_R32UI << 12) | panfrost_get_default_swizzle(1);
         else
-                so->hw[PAN_VERTEX_ID].swizzle = panfrost_bifrost_swizzle(1);
+                so->hw[PAN_VERTEX_ID].format = (MALI_R32UI << 12) | panfrost_bifrost_swizzle(1);
 
-        so->hw[PAN_INSTANCE_ID].format = MALI_R32UI;
         if (dev->quirks & HAS_SWIZZLES)
-                so->hw[PAN_INSTANCE_ID].swizzle = panfrost_get_default_swizzle(1);
+                so->hw[PAN_INSTANCE_ID].format = (MALI_R32UI << 12) | panfrost_get_default_swizzle(1);
         else
-                so->hw[PAN_INSTANCE_ID].swizzle = panfrost_bifrost_swizzle(1);
+                so->hw[PAN_INSTANCE_ID].format = (MALI_R32UI << 12) | panfrost_bifrost_swizzle(1);
 
         return so;
 }
index 5be15a5f42f54447c8156adb251469b7d1e78d47..34d3e98f5c41fcffd05ccf405cb0aa2e1ad5674d 100644 (file)
@@ -730,11 +730,7 @@ struct mali_attr_meta {
         u8 index;
 
         unsigned unknown1 : 2;
-        unsigned swizzle : 12;
-        enum mali_format format : 8;
-
-        /* Always observed to be zero at the moment */
-        unsigned unknown3 : 2;
+        unsigned format : 22;
 
         /* When packing multiple attributes in a buffer, offset addresses by
          * this value. Obscurely, this is signed. */
index 54f84742b71200a1eb628bccd4b844d3c26ea715..06b381626dc15a91faa23b2da0ce3b6e56e34f95 100644 (file)
@@ -1551,38 +1551,6 @@ pandecode_attribute_meta(int job_no, int count, const struct mali_vertex_tiler_p
                 attr_meta = pandecode_fetch_gpu_mem(attr_mem, p,
                                                     sizeof(*attr_mem));
 
-                /* If the record is discard, it should be zero for everything else */
-
-                if (attr_meta->format == MALI_VARYING_DISCARD) {
-                        uint64_t zero =
-                                attr_meta->index |
-                                attr_meta->unknown1 |
-                                attr_meta->unknown3 |
-                                attr_meta->src_offset;
-
-                        if (zero)
-                                pandecode_msg("XXX: expected empty record for varying discard\n");
-
-                        /* We want to look for a literal 0000 swizzle -- this
-                         * is not encoded with all zeroes, however */
-
-                        enum mali_channel z = MALI_CHANNEL_ZERO;
-                        unsigned zero_swizzle = z | (z << 3) | (z << 6) | (z << 9);
-                        bool good_swizzle = attr_meta->swizzle == zero_swizzle;
-
-                        if (!good_swizzle)
-                                pandecode_msg("XXX: expected zero swizzle for discard\n");
-
-                        if (!varying)
-                                pandecode_msg("XXX: cannot discard attribute\n");
-
-                        /* If we're all good, omit the record */
-                        if (!zero && varying && good_swizzle) {
-                                pandecode_log("/* discarded varying */\n");
-                                continue;
-                        }
-                }
-
                 if (attr_meta->index > max_index)
                         max_index = attr_meta->index;
 
@@ -1591,17 +1559,12 @@ pandecode_attribute_meta(int job_no, int count, const struct mali_vertex_tiler_p
                         pandecode_prop("unknown1 = 0x%" PRIx64, (u64) attr_meta->unknown1);
                 }
 
-                if (attr_meta->unknown3) {
-                        pandecode_msg("XXX: unexpected unknown3 set\n");
-                        pandecode_prop("unknown3 = 0x%" PRIx64, (u64) attr_meta->unknown3);
-                }
-
-                pandecode_log_cont("%s %s_%u", mali_format_as_str(attr_meta->format), prefix, attr_meta->index);
+                pandecode_log_cont("%s %s_%u", mali_format_as_str(attr_meta->format >> 12), prefix, attr_meta->index);
 
                 if (attr_meta->src_offset)
                         pandecode_log_cont("[%u]", attr_meta->src_offset);
 
-                pandecode_swizzle(attr_meta->swizzle, attr_meta->format);
+                pandecode_swizzle(attr_meta->format & ((1 << 12) - 1), attr_meta->format >> 12);
 
                 pandecode_log_cont(";\n");
         }
index 836f4ad3485dbd6c3f5839fa0ff43aa6903fc914..fbc346003906ef0766b726143d8f24261fd24b03 100644 (file)
@@ -203,8 +203,7 @@ panfrost_load_midg(
         struct mali_attr_meta varying_meta = {
                 .index = 0,
                 .unknown1 = 2,
-                .swizzle = (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3),
-                .format = MALI_RGBA32F
+                .format = (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3) | (MALI_RGBA32F << 12)
         };
 
         struct mali_stencil_packed stencil;