panfrost: Pass kernel inputs as uniforms
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 5 Nov 2019 16:19:20 +0000 (11:19 -0500)
committerTomeu Vizoso <tomeu.vizoso@collabora.co.uk>
Tue, 19 Nov 2019 06:22:31 +0000 (06:22 +0000)
We can take the OpenCL kernel inputs and interpret them as uniforms by
simply reusing the Gallium callback.

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

index 23e3791d1d54948dc50d567bc0fc491e7efb1871..905e6e234e0f9f69156f7e452e69bc0f498b3723 100644 (file)
@@ -110,6 +110,19 @@ panfrost_launch_grid(struct pipe_context *pipe,
         /* TODO: Stub */
         struct midgard_payload_vertex_tiler *payload = &ctx->payloads[PIPE_SHADER_COMPUTE];
 
+        /* We implement OpenCL inputs as uniforms (or a UBO -- same thing), so
+         * reuse the graphics path for this by lowering to Gallium */
+
+        struct pipe_constant_buffer ubuf = {
+                .buffer = NULL,
+                .buffer_offset = 0,
+                .buffer_size = ctx->shader[PIPE_SHADER_COMPUTE]->cbase.req_input_mem,
+                .user_buffer = info->input
+        };
+
+        if (info->input)
+                pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, &ubuf);
+
         panfrost_emit_for_draw(ctx, false);
 
         /* Compute jobs have a "compute FBD". It's not a real framebuffer