panfrost: Remove postfix parameter from UBO upload
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 25 Aug 2020 16:03:17 +0000 (12:03 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 28 Aug 2020 14:53:53 +0000 (14:53 +0000)
Need to signal push constants via a side channel. I tried to disentangle
this code, but there are a number of stacked issues here:

* We need to upload sysvals. Currently we prefix UBO #0 with sysvals,
  but this requires a memcpy() of the entire contents of UBO #0. We
  could create a synthetic UBO instead with sysvals at the end.

* We want to push uniforms/sysvals. Currently we push UBO #0 as much as
  we can, which pushes sysvals automatically by point 1.

* We want to optimize out f2f16(uniform). We don't currently handle
  this.

* We want to optimize out uniform-on-uniform/constant operations. Mesa
  doesn't currently have good support for this.

The real solution will look something like:

* Create a separate UBO for sysvals.

* Let the compiler allocate push constant space as it sees fit ("copy
  word 12:15 of UBO 1 to word 2:3 of push constant space, as fp16").

* Somehow handle uniform folding when NIR gains support.

For now, let's not block the depostfixening.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6476>

src/gallium/drivers/panfrost/pan_cmdstream.c
src/gallium/drivers/panfrost/pan_cmdstream.h
src/gallium/drivers/panfrost/pan_compute.c
src/gallium/drivers/panfrost/pan_context.c

index 617efa46b7531ccdc0acd11e3b40fea75a146dc9..20639cdee5aab25508b3d976888513c80777a7c2 100644 (file)
@@ -975,16 +975,16 @@ panfrost_map_constant_buffer_cpu(struct panfrost_constant_buffer *buf,
                 unreachable("No constant buffer");
 }
 
-void
+mali_ptr
 panfrost_emit_const_buf(struct panfrost_batch *batch,
                         enum pipe_shader_type stage,
-                        struct mali_vertex_tiler_postfix *postfix)
+                        mali_ptr *push_constants)
 {
         struct panfrost_context *ctx = batch->ctx;
         struct panfrost_shader_variants *all = ctx->shader[stage];
 
         if (!all)
-                return;
+                return 0;
 
         struct panfrost_constant_buffer *buf = &ctx->constant_buffer[stage];
 
@@ -1052,10 +1052,10 @@ panfrost_emit_const_buf(struct panfrost_batch *batch,
                 }
         }
 
-        postfix->uniforms = transfer.gpu;
-        postfix->uniform_buffers = ubos.gpu;
+        *push_constants = transfer.gpu;
 
         buf->dirty_mask = 0;
+        return ubos.gpu;
 }
 
 mali_ptr
index 5eb5e64c43a9693b3bc9ec37894898025bad137a..430d47243b1ff9cf5c7a7edce6079b3e4b846e49 100644 (file)
@@ -60,10 +60,10 @@ panfrost_emit_frag_shader_meta(struct panfrost_batch *batch);
 mali_ptr
 panfrost_emit_viewport(struct panfrost_batch *batch);
 
-void
+mali_ptr
 panfrost_emit_const_buf(struct panfrost_batch *batch,
                         enum pipe_shader_type stage,
-                        struct mali_vertex_tiler_postfix *postfix);
+                        mali_ptr *push_constants);
 
 mali_ptr
 panfrost_emit_shared_memory(struct panfrost_batch *batch,
index 4996afd11d0b56b4224aa8ebd18b374011a1694a..14ec88e70f38df828367e8b4e45def9ce5acd795 100644 (file)
@@ -119,8 +119,10 @@ panfrost_launch_grid(struct pipe_context *pipe,
 
         panfrost_vt_init(ctx, PIPE_SHADER_COMPUTE, &payload.prefix, &payload.postfix);
 
+        mali_ptr push = 0;
         payload.postfix.shader = panfrost_emit_compute_shader_meta(batch, PIPE_SHADER_COMPUTE);
-        panfrost_emit_const_buf(batch, PIPE_SHADER_COMPUTE, &payload.postfix);
+        payload.postfix.uniform_buffers = panfrost_emit_const_buf(batch, PIPE_SHADER_COMPUTE, &push);
+        payload.postfix.uniforms = push;
         payload.postfix.shared_memory = panfrost_emit_shared_memory(batch, info);
 
         /* Invoke according to the grid info */
index 5f39613114a6052808bc024724dbee6365f02785..215fe594406d4bba409c5b035090d87a4a28a2eb 100644 (file)
@@ -319,6 +319,8 @@ panfrost_draw_vbo(
                                         1, 1, 1);
 
         /* Emit all sort of descriptors. */
+        mali_ptr push_vert = 0, push_frag = 0;
+
         panfrost_emit_vertex_data(batch, &vertex_postfix);
         panfrost_emit_varying_descriptor(batch,
                                          ctx->padded_count *
@@ -329,8 +331,10 @@ panfrost_draw_vbo(
         tiler_postfix.sampler_descriptor = panfrost_emit_sampler_descriptors(batch, PIPE_SHADER_FRAGMENT);
         vertex_postfix.textures = panfrost_emit_texture_descriptors(batch, PIPE_SHADER_VERTEX);
         tiler_postfix.textures = panfrost_emit_texture_descriptors(batch, PIPE_SHADER_FRAGMENT);
-        panfrost_emit_const_buf(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
-        panfrost_emit_const_buf(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
+        vertex_postfix.uniform_buffers = panfrost_emit_const_buf(batch, PIPE_SHADER_VERTEX, &push_vert);
+        tiler_postfix.uniform_buffers = panfrost_emit_const_buf(batch, PIPE_SHADER_FRAGMENT, &push_frag);
+        vertex_postfix.uniforms = push_vert;
+        tiler_postfix.uniforms = push_frag;
         tiler_postfix.viewport = panfrost_emit_viewport(batch);
 
         vertex_postfix.shader = panfrost_emit_compute_shader_meta(batch, PIPE_SHADER_VERTEX);