From a2823747bbd28e71323efc0b3a26ac3ad84f48ac Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 8 Apr 2022 11:00:39 -0400 Subject: [PATCH] mesa/st: fix pointsize adding check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * components is already multiplied by 4 * also verify base maxcomponents for gs fixes #6282 Reviewed-by: Marek Olšák Part-of: --- src/mesa/state_tracker/st_program.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 5a7147809e9..46b44550a86 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1926,15 +1926,18 @@ st_can_add_pointsize_to_program(struct st_context *st, struct gl_program *prog) nir->info.stage == MESA_SHADER_GEOMETRY); unsigned max_components = nir->info.stage == MESA_SHADER_GEOMETRY ? st->ctx->Const.MaxGeometryTotalOutputComponents : - st->ctx->Const.Program[nir->info.stage].MaxOutputComponents * 4; + st->ctx->Const.Program[nir->info.stage].MaxOutputComponents; unsigned num_components = 0; unsigned needed_components = nir->info.stage == MESA_SHADER_GEOMETRY ? nir->info.gs.vertices_out : 1; nir_foreach_shader_out_variable(var, nir) { num_components += glsl_count_dword_slots(var->type, false); } /* Ensure that there is enough attribute space to emit at least one primitive */ - if (nir->info.stage == MESA_SHADER_GEOMETRY) + if (nir->info.stage == MESA_SHADER_GEOMETRY) { + if (num_components + needed_components > st->ctx->Const.Program[nir->info.stage].MaxOutputComponents) + return false; num_components *= nir->info.gs.vertices_out; + } return num_components + needed_components <= max_components; }