summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2019-06-20 16:21:48 -0700
committerAlyssa Rosenzweig <[email protected]>2019-06-24 12:57:40 -0700
commit4c6d7512746c1980665cd46919e6a015565709f0 (patch)
tree5258d7e1028292232338b4e42e4c1dfa98b45ac7 /src
parent5d60be4e246710fafea52b6d103433ead224a80c (diff)
panfrost: Allow for dynamic UBO count
We already uploaded UBOs, but only a fixed number (1) for uniforms; let's upload as many as we compute we need. Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/panfrost/pan_context.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index c3d9ad1213d..4a84c99a8ef 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1002,13 +1002,14 @@ panfrost_map_constant_buffer_cpu(struct panfrost_constant_buffer *buf, unsigned
}
/* Compute number of UBOs active (more specifically, compute the highest UBO
- * number addressable -- if there are gaps, include them in the count anyway)
- * */
+ * number addressable -- if there are gaps, include them in the count anyway).
+ * We always include UBO #0 in the count, since we *need* uniforms enabled for
+ * sysvals. */
static unsigned
panfrost_ubo_count(struct panfrost_context *ctx, enum pipe_shader_type stage)
{
- unsigned mask = ctx->constant_buffer[stage].enabled_mask;
+ unsigned mask = ctx->constant_buffer[stage].enabled_mask | 1;
return 32 - __builtin_clz(mask);
}
@@ -1277,16 +1278,20 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
unreachable("Invalid shader stage\n");
}
- /* Also attach the same buffer as a UBO for extended access */
+ /* Next up, attach UBOs. UBO #0 is the uniforms we just
+ * uploaded */
- struct mali_uniform_buffer_meta uniform_buffers[] = {
- {
- .size = MALI_POSITIVE((2 + uniform_count)),
- .ptr = transfer.gpu >> 2,
- },
- };
+ unsigned ubo_count = panfrost_ubo_count(ctx, i);
+ assert(ubo_count >= 1);
- mali_ptr ubufs = panfrost_upload_transient(ctx, uniform_buffers, sizeof(uniform_buffers));
+ size_t sz = sizeof(struct mali_uniform_buffer_meta) * ubo_count;
+ struct mali_uniform_buffer_meta *ubos = calloc(sz, 1);
+
+ /* Upload uniforms as a UBO */
+ ubos[0].size = MALI_POSITIVE((2 + uniform_count));
+ ubos[0].ptr = transfer.gpu >> 2;
+
+ mali_ptr ubufs = panfrost_upload_transient(ctx, ubos, sz);
postfix->uniforms = transfer.gpu;
postfix->uniform_buffers = ubufs;