panfrost: XMLify Block Format
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 12 Aug 2020 01:00:47 +0000 (21:00 -0400)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Thu, 13 Aug 2020 06:55:17 +0000 (08:55 +0200)
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/6195>

src/gallium/drivers/panfrost/pan_mfbd.c
src/gallium/drivers/panfrost/pan_sfbd.c
src/panfrost/include/panfrost-job.h
src/panfrost/lib/decode.c
src/panfrost/lib/midgard.xml

index 3dc3a3dd25ac496a650e3042e44d8e80dccef812..6cbf2f219fe9484145230b7f4cc1aac34d47b2f3 100644 (file)
@@ -233,7 +233,7 @@ panfrost_mfbd_set_cbuf(
                 if (is_bifrost) {
                         rt->format.unk4 = 0x1;
                 } else {
-                        rt->format.block = MALI_BLOCK_LINEAR;
+                        rt->format.block = MALI_BLOCK_FORMAT_LINEAR;
                 }
 
                 rt->framebuffer = base;
@@ -243,14 +243,14 @@ panfrost_mfbd_set_cbuf(
                 if (is_bifrost) {
                         rt->format.unk3 |= 0x8;
                 } else {
-                        rt->format.block = MALI_BLOCK_TILED;
+                        rt->format.block = MALI_BLOCK_FORMAT_TILED;
                 }
 
                 rt->framebuffer = base;
                 rt->framebuffer_stride = stride;
                 rt->layer_stride = layer_stride;
         } else if (drm_is_afbc(rsrc->modifier)) {
-                rt->format.block = MALI_BLOCK_AFBC;
+                rt->format.block = MALI_BLOCK_FORMAT_AFBC;
 
                 unsigned header_size = rsrc->slices[level].header_size;
 
@@ -303,7 +303,7 @@ panfrost_mfbd_set_zsbuf(
 
                 fbx->flags_hi |= MALI_EXTRA_PRESENT;
                 fbx->flags_lo |= MALI_EXTRA_ZS | 0x1; /* unknown */
-                fbx->zs_block = MALI_BLOCK_AFBC;
+                fbx->zs_block = MALI_BLOCK_FORMAT_AFBC;
 
                 fbx->ds_afbc.depth_stencil = base + header_size;
                 fbx->ds_afbc.depth_stencil_afbc_metadata = base;
@@ -326,16 +326,17 @@ panfrost_mfbd_set_zsbuf(
                 fbx->ds_linear.depth = base;
 
                 if (rsrc->modifier == DRM_FORMAT_MOD_LINEAR) {
-                        fbx->zs_block = MALI_BLOCK_LINEAR;
+                        fbx->zs_block = MALI_BLOCK_FORMAT_LINEAR;
                         fbx->ds_linear.depth_stride = stride / 16;
                         fbx->ds_linear.depth_layer_stride = layer_stride;
                 } else {
                         if (is_bifrost) {
-                                fbx->zs_block = MALI_BLOCK_UNKNOWN;
+                                /* XXX: Bifrost fields are different here */
+                                fbx->zs_block = 1;
                                 fbx->flags_hi |= 0x440;
                                 fbx->flags_lo |= 0x1;
                         } else {
-                                fbx->zs_block = MALI_BLOCK_TILED;
+                                fbx->zs_block = MALI_BLOCK_FORMAT_TILED;
                         }
 
                         fbx->ds_linear.depth_stride = stride;
index 4f830991531accdaba28d55431940a27f7b6ba33..58d33dcddde32b488fb8360a621618e81f7f312c 100644 (file)
@@ -142,9 +142,9 @@ panfrost_sfbd_set_cbuf(
         fb->stride = stride;
 
         if (rsrc->modifier == DRM_FORMAT_MOD_LINEAR)
-                fb->format.block = MALI_BLOCK_LINEAR;
+                fb->format.block = MALI_BLOCK_FORMAT_LINEAR;
         else if (rsrc->modifier == DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED) {
-                fb->format.block = MALI_BLOCK_TILED;
+                fb->format.block = MALI_BLOCK_FORMAT_TILED;
                 fb->stride *= 16;
         } else {
                 fprintf(stderr, "Invalid render modifier\n");
index 1adfbb2c0dc96ec3b16ac759968d2a9b84e9c308..48379cce9056e1cb34083ddbb75c43888325c966 100644 (file)
@@ -1267,13 +1267,6 @@ struct midgard_tiler_descriptor {
         u32 weights[8];
 };
 
-enum mali_block_format {
-        MALI_BLOCK_TILED   = 0x0,
-        MALI_BLOCK_UNKNOWN = 0x1,
-        MALI_BLOCK_LINEAR  = 0x2,
-        MALI_BLOCK_AFBC    = 0x3,
-};
-
 struct mali_sfbd_format {
         /* 0x1 */
         unsigned unk1 : 6;
index b218595560b9743bfdb9bbc139d15ace70b9b515..c47b8f52b6cc5899f5e299ef9107f4f331cea1a2 100644 (file)
@@ -510,22 +510,6 @@ pandecode_special_record(uint64_t v, bool* attribute)
         }
 }
 
-#define DEFINE_CASE(name) case MALI_BLOCK_## name: return "MALI_BLOCK_" #name
-static char *
-pandecode_block_format(enum mali_block_format fmt)
-{
-        switch (fmt) {
-                DEFINE_CASE(TILED);
-                DEFINE_CASE(UNKNOWN);
-                DEFINE_CASE(LINEAR);
-                DEFINE_CASE(AFBC);
-
-        default:
-                unreachable("Invalid case");
-        }
-}
-#undef DEFINE_CASE
-
 #define DEFINE_CASE(name) case MALI_EXCEPTION_ACCESS_## name: return ""#name
 static char *
 pandecode_exception_access(unsigned access)
@@ -718,7 +702,7 @@ pandecode_sfbd_format(struct mali_sfbd_format format)
         pandecode_log_decoded_flags(sfbd_unk2_info, format.unk2);
         pandecode_log_cont(",\n");
 
-        pandecode_prop("block = %s", pandecode_block_format(format.block));
+        pandecode_prop("block = %s", mali_block_format_as_str(format.block));
 
         pandecode_prop("unk3 = 0x%" PRIx32, format.unk3);
 
@@ -1029,7 +1013,7 @@ pandecode_rt_format(struct mali_rt_format format)
         pandecode_prop("unk3 = 0x%" PRIx32, format.unk3);
         pandecode_prop("unk4 = 0x%" PRIx32, format.unk4);
 
-        pandecode_prop("block = %s", pandecode_block_format(format.block));
+        pandecode_prop("block = %s", mali_block_format_as_str(format.block));
 
         /* TODO: Map formats so we can check swizzles and print nicely */
         pandecode_log("swizzle");
@@ -1080,7 +1064,7 @@ pandecode_render_target(uint64_t gpu_va, unsigned job_no, const struct mali_fram
 
                 pandecode_rt_format(rt->format);
 
-                if (rt->format.block == MALI_BLOCK_AFBC) {
+                if (rt->format.block == MALI_BLOCK_FORMAT_AFBC) {
                         pandecode_log(".afbc = {\n");
                         pandecode_indent++;
 
@@ -1261,10 +1245,10 @@ pandecode_mfbd_bfr(uint64_t gpu_va, int job_no, bool is_fragment, bool is_comput
                 pandecode_log_decoded_flags(mfbd_extra_flag_lo_info, fbx->flags_lo);
                 pandecode_log_cont(",\n");
 
-                pandecode_prop("zs_block = %s", pandecode_block_format(fbx->zs_block));
+                pandecode_prop("zs_block = %s", mali_block_format_as_str(fbx->zs_block));
                 pandecode_prop("zs_samples = MALI_POSITIVE(%u)", fbx->zs_samples + 1);
 
-                if (fbx->zs_block == MALI_BLOCK_AFBC) {
+                if (fbx->zs_block == MALI_BLOCK_FORMAT_AFBC) {
                         pandecode_log(".ds_afbc = {\n");
                         pandecode_indent++;
 
index 5a9acba2c4c90d55068972f25498fec58fe9d122..57de518972a67eb2607eb4551b2b5833836c72af 100644 (file)
     <value name="Always" value="7"/>
   </enum>
 
+  <enum name="Block Format">
+    <!--- 16x16 block u-interleaved -->
+    <value name="Tiled" value="0"/>
+    <value name="Linear" value="2"/>
+    <value name="AFBC" value="3"/>
+  </enum>
+
   <enum name="Mipmap Mode">
     <value name="Nearest" value="0"/>
     <value name="None" value="1"/>