From ea34c7972b4e9b8a76e6b8fcc77f19ffc3337c62 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Wed, 4 Sep 2024 15:24:19 +0200 Subject: [PATCH] etnaviv: support more VS outputs on halti5 GPUs Halti5 GPUs doubled the number of available VS outputs, as documented in rnndb. Double the size of the driver structure and use the size defines generated by rnndb to emit the correct number of VS output states, depending on GPU generation. Signed-off-by: Lucas Stach Reviewed-by: Christian Gmeiner Part-of: --- src/gallium/drivers/etnaviv/etnaviv_emit.c | 4 ++-- src/gallium/drivers/etnaviv/etnaviv_internal.h | 4 +++- src/gallium/drivers/etnaviv/etnaviv_screen.c | 4 +++- src/gallium/drivers/etnaviv/etnaviv_shader.c | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.c b/src/gallium/drivers/etnaviv/etnaviv_emit.c index 72162c3dabe..b02bfaf492f 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_emit.c +++ b/src/gallium/drivers/etnaviv/etnaviv_emit.c @@ -134,7 +134,7 @@ emit_halti5_only_state(struct etna_context *ctx, int vs_output_count) /*007C4*/ EMIT_STATE(FE_HALTI5_ID_CONFIG, ctx->shader_state.FE_HALTI5_ID_CONFIG); /*00870*/ EMIT_STATE(VS_HALTI5_OUTPUT_COUNT, vs_output_count | ((vs_output_count * 0x10) << 8)); /*008A0*/ EMIT_STATE(VS_HALTI5_UNK008A0, 0x0001000e | ((0x110/vs_output_count) << 20)); - for (int x = 0; x < 4; ++x) { + for (int x = 0; x < VIVS_VS_HALTI5_OUTPUT__LEN; ++x) { /*008E0*/ EMIT_STATE(VS_HALTI5_OUTPUT(x), ctx->shader_state.VS_OUTPUT[x]); } } @@ -167,7 +167,7 @@ emit_pre_halti5_state(struct etna_context *ctx) /*00800*/ EMIT_STATE(VS_END_PC, ctx->shader_state.VS_END_PC); } if (unlikely(dirty & (ETNA_DIRTY_SHADER))) { - for (int x = 0; x < 4; ++x) { + for (int x = 0; x < VIVS_VS_OUTPUT__LEN; ++x) { /*00810*/ EMIT_STATE(VS_OUTPUT(x), ctx->shader_state.VS_OUTPUT[x]); } } diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h b/src/gallium/drivers/etnaviv/etnaviv_internal.h index 34b46b1c17c..123612a6f10 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_internal.h +++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h @@ -109,6 +109,8 @@ struct etna_specs { uint32_t ps_uniforms_offset; /* vertex/fragment shader max instructions */ uint32_t max_instructions; + /* maximum number of VS outputs */ + unsigned max_vs_outputs; /* maximum number of varyings */ unsigned max_varyings; /* maximum vertex uniforms */ @@ -218,7 +220,7 @@ struct compiled_shader_state { uint32_t VS_OUTPUT_COUNT_PSIZE; /* number of outputs of point size per vertex enabled */ uint32_t VS_INPUT_COUNT; uint32_t VS_TEMP_REGISTER_CONTROL; - uint32_t VS_OUTPUT[4]; + uint32_t VS_OUTPUT[8]; uint32_t VS_INPUT[4]; uint32_t VS_LOAD_BALANCING; uint32_t VS_START_PC; diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c index 2f419afbf55..bd87520b591 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c @@ -394,7 +394,7 @@ etna_screen_get_shader_param(struct pipe_screen *pscreen, return shader == PIPE_SHADER_FRAGMENT ? screen->specs.max_varyings : screen->specs.vertex_max_elements; case PIPE_SHADER_CAP_MAX_OUTPUTS: - return 16; /* see VIVS_VS_OUTPUT */ + return screen->specs.max_vs_outputs; case PIPE_SHADER_CAP_MAX_TEMPS: return 64; /* Max native temporaries. */ case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: @@ -964,6 +964,8 @@ etna_get_specs(struct etna_screen *screen) screen->specs.ps_uniforms_offset = VIVS_PS_UNIFORMS(0); } + screen->specs.max_vs_outputs = screen->info->halti >= 5 ? 32 : 16; + screen->specs.max_texture_size = VIV_FEATURE(screen, ETNA_FEATURE_TEXTURE_8K) ? 8192 : 2048; screen->specs.max_rendertarget_size = diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.c b/src/gallium/drivers/etnaviv/etnaviv_shader.c index d8bdfb43063..1c3a049962f 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_shader.c +++ b/src/gallium/drivers/etnaviv/etnaviv_shader.c @@ -155,7 +155,7 @@ etna_link_shaders(struct etna_context *ctx, struct compiled_shader_state *cs, cs->VS_OUTPUT_COUNT = 1 + link.num_varyings; /* position + varyings */ /* vs outputs (varyings) */ - DEFINE_ETNA_BITARRAY(vs_output, 16, 8) = {0}; + DEFINE_ETNA_BITARRAY(vs_output, ARRAY_SIZE(cs->VS_OUTPUT) * 4, 8) = {0}; int varid = 0; etna_bitarray_set(vs_output, 8, varid++, vs->vs_pos_out_reg); for (int idx = 0; idx < link.num_varyings; ++idx)