panfrost: Feed compute shaders into the compiler
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 31 Jul 2019 22:31:23 +0000 (15:31 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 1 Aug 2019 23:23:03 +0000 (16:23 -0700)
The path for compute shader compiles resembles the graphic shader
compile path, although it is substantially simpler as we don't need any
shader keying.

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

index 9da25874b5e33c84f047c03c6411de439cb90799..71065e28ba7b8fc9f430bd0a616586f83499c41b 100644 (file)
 #include "pan_context.h"
 #include "util/u_memory.h"
 
+/* Compute CSOs are tracked like graphics shader CSOs, but are
+ * considerably simpler. We do not implement multiple
+ * variants/keying. So the CSO create function just goes ahead and
+ * compiles the thing. */
+
 static void *
 panfrost_create_compute_state(
         struct pipe_context *pctx,
         const struct pipe_compute_state *cso)
 {
+        struct panfrost_context *ctx = pan_context(pctx);
+
         struct panfrost_shader_variants *so = CALLOC_STRUCT(panfrost_shader_variants);
         so->cbase = *cso;
         so->is_compute = true;
 
+        struct panfrost_shader_state *v = &so->variants[0];
+
+        so->variant_count = 1;
+        so->active_variant = 0;
+
+        v->tripipe = malloc(sizeof(struct mali_shader_meta));
+
+        panfrost_shader_compile(ctx, v->tripipe,
+                        cso->ir_type, cso->prog, NULL,
+                        JOB_TYPE_COMPUTE, v);
+
+
+
         return so;
 }
 
 static void
 panfrost_bind_compute_state(struct pipe_context *pipe, void *cso)
 {
-        struct pipe_compute_state *state = (struct pipe_compute_state *) cso;
+        struct panfrost_context *ctx = pan_context(pipe);
+
+        struct panfrost_shader_variants *variants =
+                (struct panfrost_shader_variants *) cso;
 
-        printf("Binding compute %p\n", state);
-        /* Stub */
+        ctx->shader[PIPE_SHADER_COMPUTE] = variants;
 }
 
 static void