Mesa (main): mesa/st: fix pointsize adding check

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Apr 10 17:24:10 UTC 2022


Module: Mesa
Branch: main
Commit: a2823747bbd28e71323efc0b3a26ac3ad84f48ac
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a2823747bbd28e71323efc0b3a26ac3ad84f48ac

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Fri Apr  8 11:00:39 2022 -0400

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 at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15821>

---

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



More information about the mesa-commit mailing list