panfrost: XMLify job_type
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 5 Aug 2020 22:40:44 +0000 (18:40 -0400)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Thu, 13 Aug 2020 06:55:15 +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_cmdstream.c
src/gallium/drivers/panfrost/pan_compute.c
src/gallium/drivers/panfrost/pan_fragment.c
src/panfrost/bifrost/test/bi_submit.c
src/panfrost/include/panfrost-job.h
src/panfrost/lib/decode.c
src/panfrost/lib/midgard.xml
src/panfrost/lib/pan_blit.c
src/panfrost/lib/pan_scoreboard.c

index 756520c5ffec302d1490c46ca2bee389f556f653..3af812f3e859f62d723baad6ee231840e2602b4a 100644 (file)
@@ -2207,9 +2207,9 @@ panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch,
         if (wallpapering) {
                 /* Inject in reverse order, with "predicted" job indices.
                  * THIS IS A HACK XXX */
-                panfrost_new_job(&batch->pool, &batch->scoreboard, JOB_TYPE_TILER, false,
+                panfrost_new_job(&batch->pool, &batch->scoreboard, MALI_JOB_TYPE_TILER, false,
                                  batch->scoreboard.job_index + 2, tp, tp_size, true);
-                panfrost_new_job(&batch->pool, &batch->scoreboard, JOB_TYPE_VERTEX, false, 0,
+                panfrost_new_job(&batch->pool, &batch->scoreboard, MALI_JOB_TYPE_VERTEX, false, 0,
                                  vp, vp_size, true);
                 return;
         }
@@ -2219,13 +2219,13 @@ panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch,
         bool rasterizer_discard = ctx->rasterizer &&
                                   ctx->rasterizer->base.rasterizer_discard;
 
-        unsigned vertex = panfrost_new_job(&batch->pool, &batch->scoreboard, JOB_TYPE_VERTEX, false, 0,
+        unsigned vertex = panfrost_new_job(&batch->pool, &batch->scoreboard, MALI_JOB_TYPE_VERTEX, false, 0,
                                            vp, vp_size, false);
 
         if (rasterizer_discard)
                 return;
 
-        panfrost_new_job(&batch->pool, &batch->scoreboard, JOB_TYPE_TILER, false, vertex, tp, tp_size,
+        panfrost_new_job(&batch->pool, &batch->scoreboard, MALI_JOB_TYPE_TILER, false, vertex, tp, tp_size,
                          false);
 }
 
index 4abb414091ae8300126a9c9c620dc937c53386da..64d868448448d41461881361dbb850413956ad90 100644 (file)
@@ -133,7 +133,7 @@ panfrost_launch_grid(struct pipe_context *pipe,
                                           false);
 
         panfrost_new_job(&batch->pool, &batch->scoreboard,
-                        JOB_TYPE_COMPUTE, true, 0, &payload,
+                        MALI_JOB_TYPE_COMPUTE, true, 0, &payload,
                          sizeof(payload), false);
         panfrost_flush_all_batches(ctx, 0);
 }
index 0b37fec07c089e2ca6061d25fe575f81d28ec17f..6e4875ba1711c4e6c44b07c3b6f07c5e0a7def6d 100644 (file)
@@ -69,7 +69,7 @@ panfrost_fragment_job(struct panfrost_batch *batch, bool has_draws)
                 panfrost_initialize_surface(batch, fb->zsbuf);
 
         struct mali_job_descriptor_header header = {
-                .job_type = JOB_TYPE_FRAGMENT,
+                .job_type = MALI_JOB_TYPE_FRAGMENT,
                 .job_index = 1,
                 .job_descriptor_size = 1
         };
index f11fea3bd2c7de58fcd1c64b840fda6f57f6025b..a131adda55a7d118cbd26b8bd216fd90424abb3d 100644 (file)
@@ -117,7 +117,7 @@ bit_sanity_check(struct panfrost_device *dev)
         };
 
         struct panfrost_bo *bos[] = { scratch };
-        bool success = bit_submit(dev, JOB_TYPE_WRITE_VALUE,
+        bool success = bit_submit(dev, MALI_JOB_TYPE_WRITE_VALUE,
                         &payload, sizeof(payload), bos, 1, false);
 
         return success && (((uint8_t *) scratch->cpu)[0] == 0x0);
@@ -224,7 +224,7 @@ bit_vertex(struct panfrost_device *dev, panfrost_program prog,
                 scratchpad, shmem, shader, shader_desc, ubo, var, attr
         };
 
-        bool succ = bit_submit(dev, JOB_TYPE_VERTEX, &payload,
+        bool succ = bit_submit(dev, MALI_JOB_TYPE_VERTEX, &payload,
                         sizeof(payload), bos, ARRAY_SIZE(bos), debug);
 
         /* Check the output varyings */
index a282c6e32e17753779a9d856bbc6d6ac310fd90d..5c7664ead782d28460d0a309dee696e49b470fdd 100644 (file)
@@ -38,19 +38,6 @@ typedef uint32_t u32;
 typedef uint64_t u64;
 typedef uint64_t mali_ptr;
 
-enum mali_job_type {
-        JOB_NOT_STARTED        = 0,
-        JOB_TYPE_NULL = 1,
-        JOB_TYPE_WRITE_VALUE = 2,
-        JOB_TYPE_CACHE_FLUSH = 3,
-        JOB_TYPE_COMPUTE = 4,
-        JOB_TYPE_VERTEX = 5,
-        JOB_TYPE_GEOMETRY = 6,
-        JOB_TYPE_TILER = 7,
-        JOB_TYPE_FUSED = 8,
-        JOB_TYPE_FRAGMENT = 9,
-};
-
 enum mali_draw_mode {
         MALI_DRAW_NONE      = 0x0,
         MALI_POINTS         = 0x1,
index 059a74d24aa9372337e837a6570b874da53c5ce1..79201030a12d50e35ffe2357df52cbf036405268 100644 (file)
@@ -464,32 +464,6 @@ static char *pandecode_format(enum mali_format format)
 
 #undef DEFINE_CASE
 
-static char *
-pandecode_job_type(enum mali_job_type type)
-{
-#define DEFINE_CASE(name) case JOB_TYPE_ ## name: return "JOB_TYPE_" #name
-
-        switch (type) {
-                DEFINE_CASE(NULL);
-                DEFINE_CASE(WRITE_VALUE);
-                DEFINE_CASE(CACHE_FLUSH);
-                DEFINE_CASE(COMPUTE);
-                DEFINE_CASE(VERTEX);
-                DEFINE_CASE(TILER);
-                DEFINE_CASE(FUSED);
-                DEFINE_CASE(FRAGMENT);
-
-        case JOB_NOT_STARTED:
-                return "NOT_STARTED";
-
-        default:
-                pandecode_log("Warning! Unknown job type %x\n", type);
-                return "!?!?!?";
-        }
-
-#undef DEFINE_CASE
-}
-
 static char *
 pandecode_draw_mode(enum mali_draw_mode mode)
 {
@@ -2115,9 +2089,9 @@ static const char *
 shader_type_for_job(unsigned type)
 {
         switch (type) {
-        case JOB_TYPE_VERTEX:  return "VERTEX";
-        case JOB_TYPE_TILER:   return "FRAGMENT";
-        case JOB_TYPE_COMPUTE: return "COMPUTE";
+        case MALI_JOB_TYPE_VERTEX:  return "VERTEX";
+        case MALI_JOB_TYPE_TILER:   return "FRAGMENT";
+        case MALI_JOB_TYPE_COMPUTE: return "COMPUTE";
         default:
                                return "UNKNOWN";
         }
@@ -2161,14 +2135,14 @@ pandecode_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type,
         } else {
                 stats = disassemble_midgard(pandecode_dump_stream,
                                 code, sz, gpu_id,
-                                type == JOB_TYPE_TILER ?
+                                type == MALI_JOB_TYPE_TILER ?
                                 MESA_SHADER_FRAGMENT : MESA_SHADER_VERTEX);
         }
 
         /* Print shader-db stats. Skip COMPUTE jobs since they are used for
          * driver-internal purposes with the blob and interfere */
 
-        bool should_shaderdb = type != JOB_TYPE_COMPUTE;
+        bool should_shaderdb = type != MALI_JOB_TYPE_COMPUTE;
 
         if (should_shaderdb) {
                 unsigned nr_threads =
@@ -2693,8 +2667,8 @@ pandecode_vertex_tiler_postfix_pre(
                 pandecode_log_cont("\t/* %X %/\n", p->shared_memory & 1);
                 pandecode_compute_fbd(p->shared_memory & ~1, job_no);
         } else if (p->shared_memory & MALI_MFBD)
-                fbd_info = pandecode_mfbd_bfr((u64) ((uintptr_t) p->shared_memory) & FBD_MASK, job_no, false, job_type == JOB_TYPE_COMPUTE, false);
-        else if (job_type == JOB_TYPE_COMPUTE)
+                fbd_info = pandecode_mfbd_bfr((u64) ((uintptr_t) p->shared_memory) & FBD_MASK, job_no, false, job_type == MALI_JOB_TYPE_COMPUTE, false);
+        else if (job_type == MALI_JOB_TYPE_COMPUTE)
                 pandecode_compute_fbd((u64) (uintptr_t) p->shared_memory, job_no);
         else
                 fbd_info = pandecode_sfbd((u64) (uintptr_t) p->shared_memory, job_no, false, gpu_id);
@@ -2865,7 +2839,7 @@ pandecode_vertex_tiler_postfix_pre(
                 /* MRT blend fields are used whenever MFBD is used, with
                  * per-RT descriptors */
 
-                if (job_type == JOB_TYPE_TILER && (is_bifrost || p->shared_memory & MALI_MFBD)) {
+                if (job_type == MALI_JOB_TYPE_TILER && (is_bifrost || p->shared_memory & MALI_MFBD)) {
                         void* blend_base = (void *) (s + 1);
 
                         for (unsigned i = 0; i < fbd_info.rt_count; i++) {
@@ -2982,7 +2956,7 @@ pandecode_vertex_tiler_postfix(const struct mali_vertex_tiler_postfix *p, int jo
         pandecode_log(".postfix = {\n");
         pandecode_indent++;
 
-        pandecode_gl_enables(p->gl_enables, JOB_TYPE_TILER);
+        pandecode_gl_enables(p->gl_enables, MALI_JOB_TYPE_TILER);
         pandecode_prop("instance_shift = 0x%x", p->instance_shift);
         pandecode_prop("instance_odd = 0x%x", p->instance_odd);
 
@@ -3197,7 +3171,7 @@ pandecode_vertex_or_tiler_job_mdg(const struct mali_job_descriptor_header *h,
                 mali_ptr payload, int job_no, unsigned gpu_id)
 {
         struct midgard_payload_vertex_tiler *PANDECODE_PTR_VAR(v, mem, payload);
-        bool is_graphics = (h->job_type == JOB_TYPE_VERTEX) || (h->job_type == JOB_TYPE_TILER);
+        bool is_graphics = (h->job_type == MALI_JOB_TYPE_VERTEX) || (h->job_type == MALI_JOB_TYPE_TILER);
 
         pandecode_vertex_tiler_postfix_pre(&v->postfix, job_no, h->job_type, "", false, gpu_id);
 
@@ -3335,7 +3309,7 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal)
                  * something else.
                  */
                 int offset = h->job_descriptor_size == MALI_JOB_32 &&
-                             h->job_type != JOB_TYPE_FRAGMENT ? 4 : 0;
+                             h->job_type != MALI_JOB_TYPE_FRAGMENT ? 4 : 0;
                 mali_ptr payload_ptr = jc_gpu_va + sizeof(*h) - offset;
 
                 payload = pandecode_fetch_gpu_mem(mem, payload_ptr, 256);
@@ -3349,7 +3323,7 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal)
                 pandecode_log("struct mali_job_descriptor_header job_%"PRIx64"_%d = {\n", jc_gpu_va, job_no);
                 pandecode_indent++;
 
-                pandecode_prop("job_type = %s", pandecode_job_type(h->job_type));
+                pandecode_prop("job_type = %s", mali_job_type_as_str(h->job_type));
 
                 if (h->job_descriptor_size)
                         pandecode_prop("job_descriptor_size = %d", h->job_descriptor_size);
@@ -3385,7 +3359,7 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal)
                 pandecode_log("};\n");
 
                 switch (h->job_type) {
-                case JOB_TYPE_WRITE_VALUE: {
+                case MALI_JOB_TYPE_WRITE_VALUE: {
                         struct mali_payload_write_value *s = payload;
                         pandecode_log("struct mali_payload_write_value payload_%"PRIx64"_%d = {\n", payload_ptr, job_no);
                         pandecode_indent++;
@@ -3408,11 +3382,11 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal)
                         break;
                 }
 
-                case JOB_TYPE_TILER:
-                case JOB_TYPE_VERTEX:
-                case JOB_TYPE_COMPUTE:
+                case MALI_JOB_TYPE_TILER:
+                case MALI_JOB_TYPE_VERTEX:
+                case MALI_JOB_TYPE_COMPUTE:
                         if (bifrost) {
-                                if (h->job_type == JOB_TYPE_TILER)
+                                if (h->job_type == MALI_JOB_TYPE_TILER)
                                         pandecode_tiler_job_bfr(h, mem, payload_ptr, job_no, gpu_id);
                                 else
                                         pandecode_vertex_job_bfr(h, mem, payload_ptr, job_no, gpu_id);
@@ -3421,7 +3395,7 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal)
 
                         break;
 
-                case JOB_TYPE_FRAGMENT:
+                case MALI_JOB_TYPE_FRAGMENT:
                         pandecode_fragment_job(mem, payload_ptr, job_no, bifrost, gpu_id);
                         break;
 
index 569cc137ca5ee837ed0de91222f871b6c7b4be6e..82eabf78e07ccf0053242e3363c961bc92aa5c46 100644 (file)
@@ -1,3 +1,16 @@
 <panxml>
 
+  <enum name="Job Type">
+    <value name="Not started" value="0"/>
+    <value name="Null" value="1"/>
+    <value name="Write value" value="2"/>
+    <value name="Cache flush" value="3"/>
+    <value name="Compute" value="4"/>
+    <value name="Vertex" value="5"/>
+    <value name="Geometry" value="6"/>
+    <value name="Tiler" value="7"/>
+    <value name="Fused" value="8"/>
+    <value name="Fragment" value="9"/>
+  </enum>
+
 </panxml>
index e1cfb1e5b17ba56e168cb7da4de9b68d70481a79..a7e1928a39cbe216b6add5963af84c433ee99c48 100644 (file)
@@ -366,5 +366,5 @@ panfrost_load_midg(
         panfrost_pack_work_groups_compute(&payload.prefix, 1, vertex_count, 1, 1, 1, 1, true);
         payload.prefix.workgroups_x_shift_3 = 6;
 
-        panfrost_new_job(pool, scoreboard, JOB_TYPE_TILER, false, 0, &payload, sizeof(payload), true);
+        panfrost_new_job(pool, scoreboard, MALI_JOB_TYPE_TILER, false, 0, &payload, sizeof(payload), true);
 }
index c72c9a37c3a56c4fa0751661425f8155c33dad87..85ae14df266ec5e87da2277c4144d356d7228a3b 100644 (file)
@@ -117,7 +117,7 @@ panfrost_new_job(
 {
         unsigned global_dep = 0;
 
-        if (type == JOB_TYPE_TILER) {
+        if (type == MALI_JOB_TYPE_TILER) {
                 /* Tiler jobs must be chained, and on Midgard, the first tiler
                  * job must depend on the write value job, whose index we
                  * reserve now */
@@ -155,7 +155,7 @@ panfrost_new_job(
         }
 
         /* Form a chain */
-        if (type == JOB_TYPE_TILER)
+        if (type == MALI_JOB_TYPE_TILER)
                 scoreboard->tiler_dep = index;
 
         if (scoreboard->prev_job)
@@ -183,7 +183,7 @@ panfrost_scoreboard_initialize_tiler(struct pan_pool *pool,
          * regardless of size. */
 
         struct mali_job_descriptor_header job = {
-                .job_type = JOB_TYPE_WRITE_VALUE,
+                .job_type = MALI_JOB_TYPE_WRITE_VALUE,
                 .job_index = scoreboard->write_value_index,
                 .job_descriptor_size = 1,
                 .next_job = scoreboard->first_job