mesa/st: fix pointsize adding check

* components is already multiplied by 4
* also verify base maxcomponents for gs

fixes #6282

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15821>
This commit is contained in:
Mike Blumenkrantz 2022-04-08 11:00:39 -04:00 committed by Marge Bot
parent 6357ce2b8e
commit a2823747bb

View file

@ -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;
}