nir/lower_tex: Change coord type to int.
authorVinson Lee <vlee@freedesktop.org>
Mon, 22 Feb 2021 01:31:30 +0000 (17:31 -0800)
committerMarge Bot <eric+marge@anholt.net>
Thu, 25 Feb 2021 04:15:07 +0000 (04:15 +0000)
nir_tex_instr_src_index returns an int.

Fix defect reported by Coverity Scan.

Macro compares unsigned to 0 (NO_EFFECT)
unsigned_compare: This greater-than-or-equal-to-zero comparison of an unsigned value is always true. coord >= 0U.

Fixes: b154a4154b4 ("nir/lower_tex: rewrite tex/txb -> txd/txl before saturating srcs")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9181>

src/compiler/nir/nir_lower_tex.c

index 2447b4b..ccce138 100644 (file)
@@ -705,7 +705,7 @@ lower_tex_to_txd(nir_builder *b, nir_tex_instr *tex)
       nir_src_copy(&txd->src[i].src, &tex->src[i].src, txd);
       txd->src[i].src_type = tex->src[i].src_type;
    }
-   unsigned coord = nir_tex_instr_src_index(tex, nir_tex_src_coord);
+   int coord = nir_tex_instr_src_index(tex, nir_tex_src_coord);
    assert(coord >= 0);
    nir_ssa_def *dfdx = nir_fddx(b, tex->src[coord].src.ssa);
    nir_ssa_def *dfdy = nir_fddy(b, tex->src[coord].src.ssa);