From 8b5f9fc08af32ab68dab1d18a51e21ec686107fa Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 25 Aug 2020 12:03:17 -0400 Subject: [PATCH] panfrost: Remove postfix parameter from UBO upload 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 Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 10 +++++----- src/gallium/drivers/panfrost/pan_cmdstream.h | 4 ++-- src/gallium/drivers/panfrost/pan_compute.c | 4 +++- src/gallium/drivers/panfrost/pan_context.c | 8 ++++++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 617efa46b75..20639cdee5a 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -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 diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.h b/src/gallium/drivers/panfrost/pan_cmdstream.h index 5eb5e64c43a..430d47243b1 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.h +++ b/src/gallium/drivers/panfrost/pan_cmdstream.h @@ -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, diff --git a/src/gallium/drivers/panfrost/pan_compute.c b/src/gallium/drivers/panfrost/pan_compute.c index 4996afd11d0..14ec88e70f3 100644 --- a/src/gallium/drivers/panfrost/pan_compute.c +++ b/src/gallium/drivers/panfrost/pan_compute.c @@ -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 */ diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 5f39613114a..215fe594406 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -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); -- 2.30.2