panfrost: Remove CSO dependency from shader_compile
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 31 Jul 2019 22:19:09 +0000 (15:19 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 1 Aug 2019 23:23:03 +0000 (16:23 -0700)
We want this routine to be generic across graphics and compute, so let
the caller deal with the typing.

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

index 4d69cd136bd5bea5ee04529c841b69b87887d6be..3f3e866f54a28d5a0cc999b29d18a43671eb5d2a 100644 (file)
 #include "tgsi/tgsi_dump.h"
 
 void
-panfrost_shader_compile(struct panfrost_context *ctx, struct mali_shader_meta *meta, const char *src, int type, struct panfrost_shader_state *state)
+panfrost_shader_compile(
+                struct panfrost_context *ctx,
+                struct mali_shader_meta *meta,
+                enum pipe_shader_ir ir_type,
+                const void *ir,
+                const char *src,
+                int type,
+                struct panfrost_shader_state *state)
 {
         uint8_t *dst;
 
         nir_shader *s;
 
-        struct pipe_shader_state *cso = state->base;
-
-        if (cso->type == PIPE_SHADER_IR_NIR) {
-                s = nir_shader_clone(NULL, cso->ir.nir);
+        if (ir_type == PIPE_SHADER_IR_NIR) {
+                s = nir_shader_clone(NULL, ir);
         } else {
-                assert (cso->type == PIPE_SHADER_IR_TGSI);
-                //tgsi_dump(cso->tokens, 0);
-                s = tgsi_to_nir(cso->tokens, ctx->base.screen);
+                assert (ir_type == PIPE_SHADER_IR_TGSI);
+                s = tgsi_to_nir(ir, ctx->base.screen);
         }
 
         s->info.stage = type == JOB_TYPE_VERTEX ? MESA_SHADER_VERTEX : MESA_SHADER_FRAGMENT;
index fbf2e07f9855bb29f31c4dace7a468fb32f42fe1..e1de285ae8c11a0c9383e129d9ac82b5f685719c 100644 (file)
@@ -2120,7 +2120,12 @@ panfrost_bind_shader_state(
         /* We finally have a variant, so compile it */
 
         if (!shader_state->compiled) {
-                panfrost_shader_compile(ctx, shader_state->tripipe, NULL,
+                panfrost_shader_compile(ctx, shader_state->tripipe,
+                              variants->base.type,
+                              variants->base.type == PIPE_SHADER_IR_NIR ?
+                                      variants->base.ir.nir :
+                                      variants->base.tokens,
+                              NULL,
                                         panfrost_job_type_for_pipe(type), shader_state);
 
                 shader_state->compiled = true;
index eefd9eff43f55c707c60e8a6ea264e0c8e320707..1b607fa53a0314557b01aa341dc588a36d2c3d04 100644 (file)
@@ -302,7 +302,14 @@ mali_ptr
 panfrost_fragment_job(struct panfrost_context *ctx, bool has_draws);
 
 void
-panfrost_shader_compile(struct panfrost_context *ctx, struct mali_shader_meta *meta, const char *src, int type, struct panfrost_shader_state *state);
+panfrost_shader_compile(
+                struct panfrost_context *ctx,
+                struct mali_shader_meta *meta,
+                enum pipe_shader_ir ir_type,
+                const void *ir,
+                const char *src,
+                int type,
+                struct panfrost_shader_state *state);
 
 void
 panfrost_pack_work_groups_compute(