etnaviv: only emit used PA_SHADER_ATTRIBUTES states
It's quite wasteful on the command stream space to always emit all of the PA_SHADER_ATTRIBUTES states, as many shaders use far less varyings than the absolute max number. Limit the emission to actually used attributes. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32991>
This commit is contained in:
@@ -204,7 +204,7 @@ emit_pre_halti5_state(struct etna_context *ctx)
|
||||
/*00838*/ EMIT_STATE(VS_START_PC, ctx->shader_state.VS_START_PC);
|
||||
}
|
||||
if (unlikely(dirty & (ETNA_DIRTY_SHADER))) {
|
||||
for (int x = 0; x < VIVS_PA_SHADER_ATTRIBUTES__LEN; ++x) {
|
||||
for (int x = 0; x < ctx->shader_state.pa_shader_attributes_states; ++x) {
|
||||
/*00A40*/ EMIT_STATE(PA_SHADER_ATTRIBUTES(x), ctx->shader_state.PA_SHADER_ATTRIBUTES[x]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,6 +234,7 @@ struct compiled_shader_state {
|
||||
uint32_t PA_ATTRIBUTE_ELEMENT_COUNT;
|
||||
uint32_t PA_CONFIG;
|
||||
uint32_t PA_SHADER_ATTRIBUTES[VIVS_PA_SHADER_ATTRIBUTES__LEN];
|
||||
int pa_shader_attributes_states;
|
||||
uint32_t VS_END_PC;
|
||||
uint32_t VS_OUTPUT_COUNT; /* number of outputs if point size per vertex disabled */
|
||||
uint32_t VS_OUTPUT_COUNT_PSIZE; /* number of outputs of point size per vertex enabled */
|
||||
|
||||
@@ -152,6 +152,7 @@ etna_link_shaders(struct etna_context *ctx, struct compiled_shader_state *cs,
|
||||
STATIC_ASSERT(VIVS_PA_SHADER_ATTRIBUTES__LEN >= ETNA_NUM_VARYINGS);
|
||||
for (int idx = 0; idx < link.num_varyings; ++idx)
|
||||
cs->PA_SHADER_ATTRIBUTES[idx] = link.varyings[idx].pa_attributes;
|
||||
cs->pa_shader_attributes_states = link.num_varyings;
|
||||
|
||||
cs->VS_END_PC = vs->code_size / 4;
|
||||
cs->VS_OUTPUT_COUNT = 1 + link.num_varyings; /* position + varyings */
|
||||
|
||||
Reference in New Issue
Block a user