From c80c68cd496cecb2c7a594e23aa074649b9de7b0 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Sun, 22 Nov 2020 18:53:22 +0100 Subject: [PATCH] panfrost: Fix UBO count calculation on Bifrost The Bifrost compiler relies on nir_lower_uniforms_to_ubo() to lower uniforms to UBOs, and s->info.num_ubos is already incremented when a UBO #0 is created. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_assemble.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index 48dcd0fe3d5..8e45025f1ca 100644 --- a/src/gallium/drivers/panfrost/pan_assemble.c +++ b/src/gallium/drivers/panfrost/pan_assemble.c @@ -380,7 +380,17 @@ panfrost_shader_compile(struct panfrost_context *ctx, /* Needed for linkage */ state->attribute_count = attribute_count; state->varying_count = varying_count; - state->ubo_count = s->info.num_ubos + 1; /* off-by-one for uniforms */ + + /* off-by-one for uniforms. Not needed on Bifrost since uniforms + * have been lowered to UBOs using nir_lower_uniforms_to_ubo() which + * already increments s->info.num_ubos. We do have to account for the + * "no uniform, no UBO" case though, otherwise sysval passed through + * uniforms won't work correctly. + */ + if (dev->quirks & IS_BIFROST) + state->ubo_count = MAX2(s->info.num_ubos, 1); + else + state->ubo_count = s->info.num_ubos + 1; /* Prepare the descriptors at compile-time */ state->shader.shader = shader;