[Mesa-dev] [PATCH 2/9] panfrost: Decode rendering block type

Alyssa Rosenzweig alyssa.rosenzweig at collabora.com
Tue Jun 18 14:59:46 UTC 2019


A mode for rendering tiled/uncompressed was noticed, so we reshuffle the
MFBD render target definitions to explicitly include block type.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
---
 .../drivers/panfrost/include/panfrost-job.h   | 14 +++++++++---
 src/gallium/drivers/panfrost/pan_mfbd.c       |  8 ++++---
 .../drivers/panfrost/pandecode/decode.c       | 22 ++++++++++++++++++-
 3 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/panfrost/include/panfrost-job.h b/src/gallium/drivers/panfrost/include/panfrost-job.h
index b982b887a47..35bc4a5a31e 100644
--- a/src/gallium/drivers/panfrost/include/panfrost-job.h
+++ b/src/gallium/drivers/panfrost/include/panfrost-job.h
@@ -1408,8 +1408,14 @@ struct mali_single_framebuffer {
 
 /* Format bits for the render target flags */
 
-#define MALI_MFBD_FORMAT_AFBC 	  (1 << 5)
-#define MALI_MFBD_FORMAT_MSAA 	  (1 << 7)
+#define MALI_MFBD_FORMAT_MSAA 	  (1 << 1)
+
+enum mali_mfbd_block_format {
+        MALI_MFBD_BLOCK_TILED   = 0x0,
+        MALI_MFBD_BLOCK_UNKNOWN = 0x1,
+        MALI_MFBD_BLOCK_LINEAR  = 0x2,
+        MALI_MFBD_BLOCK_AFBC    = 0x3,
+};
 
 struct mali_rt_format {
         unsigned unk1 : 32;
@@ -1417,7 +1423,9 @@ struct mali_rt_format {
 
         unsigned nr_channels : 2; /* MALI_POSITIVE */
 
-        unsigned flags : 11;
+        unsigned unk3 : 5;
+        enum mali_mfbd_block_format block : 2;
+        unsigned flags : 4;
 
         unsigned swizzle : 12;
 
diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c
index 17f59e0aab2..d2cccbe1a66 100644
--- a/src/gallium/drivers/panfrost/pan_mfbd.c
+++ b/src/gallium/drivers/panfrost/pan_mfbd.c
@@ -42,7 +42,8 @@ panfrost_mfbd_format(struct pipe_surface *surf)
                 .unk1 = 0x4000000,
                 .unk2 = 0x1,
                 .nr_channels = MALI_POSITIVE(desc->nr_channels),
-                .flags = 0x444,
+                .unk3 = 0x4,
+                .flags = 0x8,
                 .swizzle = panfrost_translate_swizzle_4(desc->swizzle),
                 .unk4 = 0x8
         };
@@ -52,7 +53,7 @@ panfrost_mfbd_format(struct pipe_surface *surf)
         if (surf->texture->format == PIPE_FORMAT_B5G6R5_UNORM) {
                 fmt.unk1 = 0x14000000;
                 fmt.nr_channels = MALI_POSITIVE(2);
-                fmt.flags |= 0x1;
+                fmt.unk3 |= 0x1;
         }
 
         return fmt;
@@ -100,6 +101,7 @@ panfrost_mfbd_set_cbuf(
         /* Now, we set the layout specific pieces */
 
         if (rsrc->bo->layout == PAN_LINEAR) {
+                rt->format.block = MALI_MFBD_BLOCK_LINEAR;
                 rt->framebuffer = rsrc->bo->gpu + offset;
                 rt->framebuffer_stride = stride / 16;
         } else if (rsrc->bo->layout == PAN_AFBC) {
@@ -108,7 +110,7 @@ panfrost_mfbd_set_cbuf(
                 rt->afbc.stride = 0;
                 rt->afbc.unk = 0x30009;
 
-                rt->format.flags |= MALI_MFBD_FORMAT_AFBC;
+                rt->format.block = MALI_MFBD_BLOCK_AFBC;
 
                 mali_ptr afbc_main = rsrc->bo->afbc_slab.gpu + rsrc->bo->afbc_metadata_size;
                 rt->framebuffer = afbc_main;
diff --git a/src/gallium/drivers/panfrost/pandecode/decode.c b/src/gallium/drivers/panfrost/pandecode/decode.c
index 01c9d45c3fd..85915b8eb86 100644
--- a/src/gallium/drivers/panfrost/pandecode/decode.c
+++ b/src/gallium/drivers/panfrost/pandecode/decode.c
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2017-2019 Alyssa Rosenzweig
  * Copyright (C) 2017-2019 Connor Abbott
+ * Copyright (C) 2019 Collabora
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -206,7 +207,6 @@ static const struct pandecode_flag_info fb_fmt_flag_info[] = {
 
 #define FLAG_INFO(flag) { MALI_MFBD_FORMAT_##flag, "MALI_MFBD_FORMAT_" #flag }
 static const struct pandecode_flag_info mfbd_fmt_flag_info[] = {
-        FLAG_INFO(AFBC),
         FLAG_INFO(MSAA),
         {}
 };
@@ -423,6 +423,22 @@ pandecode_texture_type(enum mali_texture_type type)
 }
 #undef DEFINE_CASE
 
+#define DEFINE_CASE(name) case MALI_MFBD_BLOCK_## name: return "MALI_MFBD_BLOCK_" #name
+static char *
+pandecode_mfbd_block_format(enum mali_mfbd_block_format fmt)
+{
+        switch (fmt) {
+                DEFINE_CASE(TILED);
+                DEFINE_CASE(UNKNOWN);
+                DEFINE_CASE(LINEAR);
+                DEFINE_CASE(AFBC);
+
+        default:
+                unreachable("Invalid case");
+        }
+}
+#undef DEFINE_CASE
+
 static inline char *
 pandecode_decode_fbd_type(enum mali_fbd_type type)
 {
@@ -540,6 +556,10 @@ pandecode_rt_format(struct mali_rt_format format)
 
         pandecode_prop("unk1 = 0x%" PRIx32, format.unk1);
         pandecode_prop("unk2 = 0x%" PRIx32, format.unk2);
+        pandecode_prop("unk3 = 0x%" PRIx32, format.unk3);
+
+        pandecode_prop("block = %s",
+                        pandecode_mfbd_block_format(format.block));
 
         pandecode_prop("nr_channels = MALI_POSITIVE(%d)",
                         MALI_NEGATIVE(format.nr_channels));
-- 
2.20.1



More information about the mesa-dev mailing list