From 3800ecc029db3e665a60ccc5b14f1bb2d0279893 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Sun, 26 Jan 2025 17:06:56 +0100 Subject: [PATCH] etnaviv: allow larger shaders with unified instruction memory When the core supports unified instruction memory, don't clamp individual shader sizes to 256 instructions. Allow shaders to make full use of the state instruction memory, as long as both VS and FS fit into the memory region. Allows to run the shaders from glmark2 terrain from state instruction memory, so we don't need to use icache mode on GC3000 and makes the app work on GC2000, which doesn't have icache but unified instruction memory. Signed-off-by: Lucas Stach Reviewed-by: Christian Gmeiner Part-of: --- src/gallium/drivers/etnaviv/etnaviv_screen.c | 6 +++--- src/gallium/drivers/etnaviv/etnaviv_shader.c | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c index e9d40594b1c..e2b9d928306 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c @@ -878,19 +878,19 @@ etna_get_specs(struct etna_screen *screen) * same. */ screen->specs.ps_offset = 0x8000; - screen->specs.max_instructions = 256; /* maximum number instructions for non-icache use */ + /* maximum number instructions for non-icache use */ + screen->specs.max_instructions = instruction_count; screen->specs.has_icache = true; } else { if (instruction_count > 256) { /* unified instruction states */ screen->specs.vs_offset = 0xC000; screen->specs.ps_offset = 0xC000; - screen->specs.max_instructions = 256; } else { screen->specs.vs_offset = 0x4000; screen->specs.ps_offset = 0x6000; - screen->specs.max_instructions = instruction_count; } + screen->specs.max_instructions = instruction_count; screen->specs.has_icache = false; } diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.c b/src/gallium/drivers/etnaviv/etnaviv_shader.c index 712ebc6ae83..ed7fb5fc5e6 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_shader.c +++ b/src/gallium/drivers/etnaviv/etnaviv_shader.c @@ -284,7 +284,13 @@ etna_link_shaders(struct etna_context *ctx, struct compiled_shader_state *cs, cs->ps_inst_mem_size = fs->code_size; cs->PS_INST_MEM = fs->code; - if (vs->needs_icache || fs->needs_icache) { + if (vs->needs_icache || fs->needs_icache || + (ctx->screen->specs.has_unified_instmem && + ((cs->vs_inst_mem_size + cs->ps_inst_mem_size) / 4 > + ctx->screen->specs.max_instructions))) { + if (!ctx->screen->specs.has_icache) + return false; + /* If either of the shaders needs ICACHE, we use it for both. It is * either switched on or off for the entire shader processor. */