panfrost: Decode AFBC flag bits
authorIcecream95 <ixn@keemail.me>
Tue, 2 Jun 2020 02:13:03 +0000 (14:13 +1200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 3 Jun 2020 15:19:43 +0000 (15:19 +0000)
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5293>

src/gallium/drivers/panfrost/pan_mfbd.c
src/panfrost/include/panfrost-job.h
src/panfrost/pandecode/decode.c

index 552da168690898758559b0cccb24598bb68c006d..4b762d1b6466ea42953cb223cd9ccaa3d3a86803 100644 (file)
@@ -241,7 +241,7 @@ panfrost_mfbd_set_cbuf(
                 rt->framebuffer = base + header_size;
                 rt->afbc.metadata = base;
                 rt->afbc.stride = 0;
-                rt->afbc.unk = 0x30009;
+                rt->afbc.flags = MALI_AFBC_FLAGS | MALI_AFBC_YTR;
 
                 /* TODO: The blob sets this to something nonzero, but it's not
                  * clear what/how to calculate/if it matters */
@@ -285,7 +285,7 @@ panfrost_mfbd_set_zsbuf(
                 fbx->ds_afbc.depth_stencil_afbc_metadata = base;
                 fbx->ds_afbc.depth_stencil_afbc_stride = 0;
 
-                fbx->ds_afbc.zero1 = 0x10009;
+                fbx->ds_afbc.flags = MALI_AFBC_FLAGS;
                 fbx->ds_afbc.padding = 0x1000;
         } else if (rsrc->layout == MALI_TEXTURE_LINEAR || rsrc->layout == MALI_TEXTURE_TILED) {
                 /* TODO: Z32F(S8) support, which is always linear */
index 1edef5d2fe8ccd2835e0d702c609a2a6c83ecd0e..0008bb18015518e1af991cb549a3c684ceea96a7 100644 (file)
@@ -1690,6 +1690,13 @@ struct mali_rt_format {
         unsigned no_preload : 1;
 } __attribute__((packed));
 
+/* Flags for afbc.flags and ds_afbc.flags */
+
+#define MALI_AFBC_FLAGS 0x10009
+
+/* Lossless RGB and RGBA colorspace transform */
+#define MALI_AFBC_YTR (1 << 17)
+
 struct mali_render_target {
         struct mali_rt_format format;
 
@@ -1708,7 +1715,7 @@ struct mali_render_target {
 
                 mali_ptr metadata;
                 u32 stride; // stride in units of tiles
-                u32 unk; // = 0x20000
+                u32 flags; // = 0x20000
         } afbc;
 
         mali_ptr framebuffer;
@@ -1752,7 +1759,7 @@ struct mali_framebuffer_extra  {
                 struct {
                         mali_ptr depth_stencil_afbc_metadata;
                         u32 depth_stencil_afbc_stride; // in units of tiles
-                        u32 zero1;
+                        u32 flags;
 
                         mali_ptr depth_stencil;
 
index 8c42a575ba57643948dcaa26a2e4449c79f66682..f9bfa190fbf11fe81c84c5d0b5b91a9e58ed54c0 100644 (file)
@@ -248,6 +248,13 @@ static const struct pandecode_flag_info mfbd_fmt_flag_info[] = {
 };
 #undef FLAG_INFO
 
+#define FLAG_INFO(flag) { MALI_AFBC_##flag, "MALI_AFBC_" #flag }
+static const struct pandecode_flag_info afbc_fmt_flag_info[] = {
+        FLAG_INFO(YTR),
+        {}
+};
+#undef FLAG_INFO
+
 #define FLAG_INFO(flag) { MALI_EXTRA_##flag, "MALI_EXTRA_" #flag }
 static const struct pandecode_flag_info mfbd_extra_flag_hi_info[] = {
         FLAG_INFO(PRESENT),
@@ -1056,15 +1063,18 @@ pandecode_render_target(uint64_t gpu_va, unsigned job_no, const struct mali_fram
                         free(a);
 
                         pandecode_prop("stride = %d", rt->afbc.stride);
-                        pandecode_prop("unk = 0x%" PRIx32, rt->afbc.unk);
+
+                        pandecode_log(".flags = ");
+                        pandecode_log_decoded_flags(afbc_fmt_flag_info, rt->afbc.flags);
+                        pandecode_log_cont(",\n");
 
                         pandecode_indent--;
                         pandecode_log("},\n");
-                } else if (rt->afbc.metadata || rt->afbc.stride || rt->afbc.unk) {
+                } else if (rt->afbc.metadata || rt->afbc.stride || rt->afbc.flags) {
                         pandecode_msg("XXX: AFBC disabled but AFBC field set (0x%lX, 0x%x, 0x%x)\n",
                                         rt->afbc.metadata,
                                         rt->afbc.stride,
-                                        rt->afbc.unk);
+                                        rt->afbc.flags);
                 }
 
                 MEMORY_PROP(rt, framebuffer);
@@ -1234,12 +1244,13 @@ pandecode_mfbd_bfr(uint64_t gpu_va, int job_no, bool is_fragment, bool is_comput
                                        fbx->ds_afbc.depth_stencil_afbc_stride);
                         MEMORY_PROP_DIR(fbx->ds_afbc, depth_stencil);
 
-                        if (fbx->ds_afbc.zero1 || fbx->ds_afbc.padding) {
+                        pandecode_log(".flags = ");
+                        pandecode_log_decoded_flags(afbc_fmt_flag_info, fbx->ds_afbc.flags);
+                        pandecode_log_cont(",\n");
+
+                        if (fbx->ds_afbc.padding) {
                                 pandecode_msg("XXX: Depth/stencil AFBC zeros tripped\n");
-                                pandecode_prop("zero1 = 0x%" PRIx32,
-                                               fbx->ds_afbc.zero1);
-                                pandecode_prop("padding = 0x%" PRIx64,
-                                               fbx->ds_afbc.padding);
+                                pandecode_prop("padding = 0x%" PRIx64, fbx->ds_afbc.padding);
                         }
 
                         pandecode_indent--;