panfrost: XMLify draw_mode

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>
diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index 3af812f..6eedf88 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -101,7 +101,7 @@
         struct panfrost_rasterizer *rasterizer = ctx->rasterizer;
 
         if (!panfrost_writes_point_size(ctx)) {
-                bool points = prefix->draw_mode == MALI_POINTS;
+                bool points = prefix->draw_mode == MALI_DRAW_MODE_POINTS;
                 float val = 0.0f;
 
                 if (rasterizer)
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 78fa962..bb4ba3b 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -265,7 +265,7 @@
         panfrost_flush_all_batches(ctx, 0);
 }
 
-#define DEFINE_CASE(c) case PIPE_PRIM_##c: return MALI_##c;
+#define DEFINE_CASE(c) case PIPE_PRIM_##c: return MALI_DRAW_MODE_##c;
 
 static int
 g2m_draw_mode(enum pipe_prim_type mode)
diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h
index 5c7664e..cdfc6cc 100644
--- a/src/panfrost/include/panfrost-job.h
+++ b/src/panfrost/include/panfrost-job.h
@@ -38,22 +38,6 @@
 typedef uint64_t u64;
 typedef uint64_t mali_ptr;
 
-enum mali_draw_mode {
-        MALI_DRAW_NONE      = 0x0,
-        MALI_POINTS         = 0x1,
-        MALI_LINES          = 0x2,
-        MALI_LINE_STRIP     = 0x4,
-        MALI_LINE_LOOP      = 0x6,
-        MALI_TRIANGLES      = 0x8,
-        MALI_TRIANGLE_STRIP = 0xA,
-        MALI_TRIANGLE_FAN   = 0xC,
-        MALI_POLYGON        = 0xD,
-        MALI_QUADS          = 0xE,
-        MALI_QUAD_STRIP     = 0xF,
-
-        /* All other modes invalid */
-};
-
 /* Applies to tiler_gl_enables */
 
 #define MALI_OCCLUSION_QUERY    (1 << 3)
diff --git a/src/panfrost/lib/decode.c b/src/panfrost/lib/decode.c
index 7920103..6d13333 100644
--- a/src/panfrost/lib/decode.c
+++ b/src/panfrost/lib/decode.c
@@ -464,32 +464,6 @@
 
 #undef DEFINE_CASE
 
-static char *
-pandecode_draw_mode(enum mali_draw_mode mode)
-{
-#define DEFINE_CASE(name) case MALI_ ## name: return "MALI_" #name
-
-        switch (mode) {
-                DEFINE_CASE(DRAW_NONE);
-                DEFINE_CASE(POINTS);
-                DEFINE_CASE(LINES);
-                DEFINE_CASE(TRIANGLES);
-                DEFINE_CASE(TRIANGLE_STRIP);
-                DEFINE_CASE(TRIANGLE_FAN);
-                DEFINE_CASE(LINE_STRIP);
-                DEFINE_CASE(LINE_LOOP);
-                DEFINE_CASE(POLYGON);
-                DEFINE_CASE(QUADS);
-                DEFINE_CASE(QUAD_STRIP);
-
-        default:
-                pandecode_msg("XXX: invalid draw mode %X\n", mode);
-                return "";
-        }
-
-#undef DEFINE_CASE
-}
-
 #define DEFINE_CASE(name) case MALI_FUNC_ ## name: return "MALI_FUNC_" #name
 static char *
 pandecode_func(enum mali_func mode)
@@ -2013,8 +1987,8 @@
 
         pandecode_prop("workgroups_x_shift_3 = 0x%" PRIx32, p->workgroups_x_shift_3);
 
-        if (p->draw_mode != MALI_DRAW_NONE)
-                pandecode_prop("draw_mode = %s", pandecode_draw_mode(p->draw_mode));
+        if (p->draw_mode != MALI_DRAW_MODE_NONE)
+                pandecode_prop("draw_mode = %s", mali_draw_mode_as_str(p->draw_mode));
 
         /* Index count only exists for tiler jobs anyway */
 
diff --git a/src/panfrost/lib/midgard.xml b/src/panfrost/lib/midgard.xml
index 82eabf7..010f879 100644
--- a/src/panfrost/lib/midgard.xml
+++ b/src/panfrost/lib/midgard.xml
@@ -13,4 +13,18 @@
     <value name="Fragment" value="9"/>
   </enum>
 
+  <enum name="Draw Mode">
+    <value name="None" value="0"/>
+    <value name="Points" value="1"/>
+    <value name="Lines" value="2"/>
+    <value name="Line strip" value="4"/>
+    <value name="Line loop" value="6"/>
+    <value name="Triangles" value="8"/>
+    <value name="Triangle strip" value="10"/>
+    <value name="Triangle fan" value="12"/>
+    <value name="Polygon" value="13"/>
+    <value name="Quads" value="14"/>
+    <value name="Quad strip" value="15"/>
+  </enum>
+
 </panxml>
diff --git a/src/panfrost/lib/pan_blit.c b/src/panfrost/lib/pan_blit.c
index a7e1928..a9289de 100644
--- a/src/panfrost/lib/pan_blit.c
+++ b/src/panfrost/lib/pan_blit.c
@@ -346,7 +346,7 @@
 
         struct midgard_payload_vertex_tiler payload = {
                 .prefix = {
-                        .draw_mode = MALI_TRIANGLES,
+                        .draw_mode = MALI_DRAW_MODE_TRIANGLES,
                         .unknown_draw = 0x3000,
                         .index_count = MALI_POSITIVE(vertex_count)
                 },