panfrost: Add panfrost_job_type_for_pipe helper
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 4 Jun 2019 23:47:35 +0000 (23:47 +0000)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 12 Jun 2019 21:27:47 +0000 (14:27 -0700)
This logic is repeated in a bunch of places and will only grow worse as
we support more job types; collect it.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_context.c

index cacad77d162e5144e597319233bb15e58430e823..d9939641cff7aee22af1830dd2eb422ac60ca8f8 100644 (file)
@@ -53,6 +53,31 @@ extern const char *pan_counters_base;
 /* Do not actually send anything to the GPU; merely generate the cmdstream as fast as possible. Disables framebuffer writes */
 //#define DRY_RUN
 
+static enum mali_job_type
+panfrost_job_type_for_pipe(enum pipe_shader_type type)
+{
+        switch (type) {
+                case PIPE_SHADER_VERTEX:
+                        return JOB_TYPE_VERTEX;
+
+                case PIPE_SHADER_FRAGMENT:
+                        /* Note: JOB_TYPE_FRAGMENT is different.
+                         * JOB_TYPE_FRAGMENT actually executes the
+                         * fragment shader, but JOB_TYPE_TILER is how you
+                         * specify it*/
+                        return JOB_TYPE_TILER;
+
+                case PIPE_SHADER_GEOMETRY:
+                        return JOB_TYPE_GEOMETRY;
+
+                case PIPE_SHADER_COMPUTE:
+                        return JOB_TYPE_COMPUTE;
+
+                default:
+                        unreachable("Unsupported shader stage");
+        }
+}
+
 static void
 panfrost_enable_checksum(struct panfrost_context *ctx, struct panfrost_resource *rsrc)
 {
@@ -1808,7 +1833,8 @@ panfrost_bind_fs_state(
                 /* Now we have a variant selected, so compile and go */
 
                 if (!shader_state->compiled) {
-                        panfrost_shader_compile(ctx, shader_state->tripipe, NULL, JOB_TYPE_TILER, shader_state);
+                        panfrost_shader_compile(ctx, shader_state->tripipe, NULL,
+                                        panfrost_job_type_for_pipe(PIPE_SHADER_FRAGMENT), shader_state);
                         shader_state->compiled = true;
                 }
         }
@@ -1834,7 +1860,8 @@ panfrost_bind_vs_state(
                         ctx->vs->variants[0].tripipe = (struct mali_shader_meta *) transfer.cpu;
                         ctx->vs->variants[0].tripipe_gpu = transfer.gpu;
 
-                        panfrost_shader_compile(ctx, ctx->vs->variants[0].tripipe, NULL, JOB_TYPE_VERTEX, &ctx->vs->variants[0]);
+                        panfrost_shader_compile(ctx, ctx->vs->variants[0].tripipe, NULL,
+                                        panfrost_job_type_for_pipe(PIPE_SHADER_VERTEX), &ctx->vs->variants[0]);
                         ctx->vs->variants[0].compiled = true;
                 }
         }