From 14ccd5d945e488464ce7f52b5d61ab52f7201b2c Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Fri, 10 Jan 2025 22:26:37 +0100 Subject: [PATCH] etnaviv: allow more constants in unified uniform mode In unified uniform mode the constant memory is dynmically partitioned between VS and FS, which allows to use far more FS constants than currently supported with the fixed split when VS constant usage is low. Limit computation taken from the Vivante kernel driver. Fixes dEQP-GLES2.functional.uniform_api.random.79 on GPUs with unified uniform support. Signed-off-by: Lucas Stach Reviewed-by: Christian Gmeiner Part-of: --- src/gallium/drivers/etnaviv/etnaviv_screen.c | 9 +++++++-- src/gallium/drivers/etnaviv/etnaviv_shader.c | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c index 3cebd36bc02..46a4851e38e 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c @@ -761,8 +761,13 @@ etna_determine_uniform_limits(struct etna_screen *screen) * gcmCONFIGUREUNIFORMS in the Vivante kernel driver file * drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_base.h. */ - if (screen->info->model == chipModel_GC2000 && - (screen->info->revision == 0x5118 || screen->info->revision == 0x5140)) { + if (screen->info->halti >= 1) { + /* with halti1 we use unified constant mode */ + screen->specs.max_vs_uniforms = screen->specs.max_ps_uniforms = + MIN2(512, screen->info->gpu.num_constants - 64); + } else if (screen->info->model == chipModel_GC2000 && + (screen->info->revision == 0x5118 || + screen->info->revision == 0x5140)) { screen->specs.max_vs_uniforms = 256; screen->specs.max_ps_uniforms = 64; } else if (screen->info->gpu.num_constants == 320) { diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.c b/src/gallium/drivers/etnaviv/etnaviv_shader.c index f4bc0491d79..712ebc6ae83 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_shader.c +++ b/src/gallium/drivers/etnaviv/etnaviv_shader.c @@ -140,6 +140,17 @@ etna_link_shaders(struct etna_context *ctx, struct compiled_shader_state *cs, link.varyings[idx].pa_attributes); } + if (ctx->screen->specs.has_unified_uniforms) { + /* check if combined shader constants fit into unified const memory */ + if ((vs->uniforms.count + fs->uniforms.count) / 4 > + ctx->screen->info->gpu.num_constants) { + DBG("Number of combined uniforms (%d) exceeds maximum %d", + (vs->uniforms.count + fs->uniforms.count) / 4, + ctx->screen->info->gpu.num_constants); + return false; + } + } + /* set last_varying_2x flag if the last varying has 1 or 2 components */ bool last_varying_2x = false; if (link.num_varyings > 0 && link.varyings[link.num_varyings - 1].num_components <= 2)