Mesa (main): st/mesa: fix size miss match for some check

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 8 02:37:26 UTC 2021


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

Author: Qiang Yu <yuq825 at gmail.com>
Date:   Wed Jul  7 15:00:50 2021 +0800

st/mesa: fix size miss match for some check

While we shrink some variable from "GLuint" to "ubyte",
need to update the check from "x != ~0U" to "x != 0xff" too.

This fixes the crash for SPECviewperf 13 benchmark medical
case.

Fixes: d947e3e2c8c2 "st/mesa: decrease the size of st_vertex_program"
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Signed-off-by: Qiang Yu <yuq825 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11757>

---

 src/mesa/state_tracker/st_cb_feedback.c    | 6 +++---
 src/mesa/state_tracker/st_cb_rasterpos.c   | 4 ++--
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 8 ++++----
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c
index 11ca9df913a..b9dbed84729 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -87,7 +87,7 @@ feedback_vertex(struct gl_context *ctx, const struct draw_context *draw,
    struct st_vertex_program *stvp = (struct st_vertex_program *)st->vp;
    GLfloat win[4];
    const GLfloat *color, *texcoord;
-   GLuint slot;
+   ubyte slot;
 
    win[0] = v->data[0][0];
    if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP)
@@ -103,13 +103,13 @@ feedback_vertex(struct gl_context *ctx, const struct draw_context *draw,
     */
 
    slot = stvp->result_to_output[VARYING_SLOT_COL0];
-   if (slot != ~0U)
+   if (slot != 0xff)
       color = v->data[slot];
    else
       color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
 
    slot = stvp->result_to_output[VARYING_SLOT_TEX0];
-   if (slot != ~0U)
+   if (slot != 0xff)
       texcoord = v->data[slot];
    else
       texcoord = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c
index b88a95e0e1d..38bbd5a6827 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -121,8 +121,8 @@ update_attrib(struct gl_context *ctx, const ubyte *outputMapping,
               GLuint result, GLuint defaultAttrib)
 {
    const GLfloat *src;
-   const GLuint k = outputMapping[result];
-   if (k != ~0U)
+   const ubyte k = outputMapping[result];
+   if (k != 0xff)
       src = vert->data[k];
    else
       src = ctx->Current.Attrib[defaultAttrib];
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index ad6608f794e..4f62622ed16 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5981,9 +5981,9 @@ dst_register(struct st_translate *t, gl_register_file file, unsigned index,
             find_inout_array(t->output_decls,
                              t->num_output_decls, array_id);
          unsigned mesa_index = decl->mesa_index;
-         int slot = t->outputMapping[mesa_index];
+         ubyte slot = t->outputMapping[mesa_index];
 
-         assert(slot != -1 && t->outputs[slot].File == TGSI_FILE_OUTPUT);
+         assert(slot != 0xff && t->outputs[slot].File == TGSI_FILE_OUTPUT);
 
          struct ureg_dst dst = t->outputs[slot];
          dst.ArrayID = array_id;
@@ -6116,9 +6116,9 @@ translate_src(struct st_translate *t, const st_src_reg *src_reg)
                                                     t->num_input_decls,
                                                     src_reg->array_id);
          unsigned mesa_index = decl->mesa_index;
-         int slot = t->inputMapping[mesa_index];
+         ubyte slot = t->inputMapping[mesa_index];
 
-         assert(slot != -1 && t->inputs[slot].File == TGSI_FILE_INPUT);
+         assert(slot != 0xff && t->inputs[slot].File == TGSI_FILE_INPUT);
 
          src = t->inputs[slot];
          src.ArrayID = src_reg->array_id;



More information about the mesa-commit mailing list