Public
Authored by Icecream95

Midgard texture format test

This is a simple SDL2 application for testing the Midgard texture formats.

Use n and p to cycle through the formats, w to hold the display for two seconds and e to hold the display for 10 seconds.

For it to you work you'll need to compile Mesa with this patch:

diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 4c5308c8238..6e72736ee71 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -2152,6 +2152,12 @@ panfrost_create_sampler_view(
                 array_size /= 6;
         }
 
+        {
+           const char* fmt = getenv("PAN_FMT");
+           if (fmt)
+              format = strtol(fmt, NULL, 0);
+        }
+
         struct mali_texture_descriptor texture_descriptor = {
                 .width = MALI_POSITIVE(u_minify(texture->width0, first_level)),
                 .height = MALI_POSITIVE(u_minify(texture->height0, first_level)),
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index df0fc9e5cac..dc62af75422 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -400,6 +400,14 @@ panfrost_resource_create_bo(struct panfrost_screen *screen, struct panfrost_reso
         /* Depth/stencil can't be tiled, only linear or AFBC */
         should_tile &= !(res->bind & PIPE_BIND_DEPTH_STENCIL);

+        {
+           static char* flag = 1;
+           if (flag == 1)
+              flag = getenv("PAN_TILE");
+           if (flag)
+              should_tile = false;
+        }
+
         /* FBOs we would like to checksum, if at all possible */
         bool can_checksum = !(res->bind & (PIPE_BIND_SCANOUT | PIPE_BIND_SHARED));
         bool should_checksum = res->bind & PIPE_BIND_RENDER_TARGET;

You can get a list of all the Midgard formats in Mesa with:

sed -n '/per-pixel formats/,/Alpha coverage/p' src/panfrost/include/panfrost-job.h | cpp 2>/dev/null - | sed -n '/{/,/}/p' | tail -n+2 | head -n-1 | tr -d ' ' | grep -v '^$' | tr = ' ' | rev | cut -c2- | rev >/tmp/texfmt.tmp
cat /tmp/texfmt.tmp | cut -d" " -f2 | xargs -I{} bash -c 'echo $(( {} ))' | xargs printf "0x%x\n"  | paste - /tmp/texfmt.tmp
Edited
main.c 3.03 KB
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment