Do explicit cast to suppress clang warnings

Do explicit cast to suppress the below clang warnings,
../src/mesa/main/get.c:86:31: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]
   return ( ((F) * 65536.0f > INT_MAX) ? INT_MAX :

../src/mesa/main/texparam.c:967:27: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]
                ((param > INT_MAX) ? INT_MAX : (GLint) (param + 0.5)) :

../src/mesa/main/texparam.c:2609:65: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]
         *params = LCLAMPF(obj->Sampler.Attrib.MinLod, INT_MIN, INT_MAX);

../src/mesa/main/texparam.c:2624:65: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]
         *params = LCLAMPF(obj->Sampler.Attrib.MaxLod, INT_MIN, INT_MAX);

../src/mesa/main/texparam.c:2648:72: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]
         *params = LCLAMPF(obj->Sampler.Attrib.MaxAnisotropy, INT_MIN, INT_MAX);

../src/mesa/main/texparam.c:2693:66: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]
         *params = LCLAMPF(obj->Sampler.Attrib.LodBias, INT_MIN, INT_MAX);

../src/gallium/drivers/freedreno/a3xx/fd3_emit.c:731:43: error: implicit conversion from 'unsigned int' to 'float' changes value from 4294967295 to 4294967296 [-Werror,-Wimplicit-const-int-float-conversion]
         OUT_RING(ring, (uint32_t)(zmin * 0xffffffff));

../src/gallium/drivers/freedreno/a3xx/fd3_emit.c:732:43: error: implicit conversion from 'unsigned int' to 'float' changes value from 4294967295 to 4294967296 [-Werror,-Wimplicit-const-int-float-conversion]
         OUT_RING(ring, (uint32_t)(zmax * 0xffffffff));

../src/nouveau/codegen/nv50_ir_peephole.cpp:1647:30: error: implicit conversion from 'unsigned int' to 'float' changes value from 4294967295 to 4294967296 [-Werror,-Wimplicit-const-int-float-conversion]
      CASE(TYPE_U32, u32, 0, UINT32_MAX, 0, INT32_MAX, 0, UINT32_MAX);

../src/nouveau/codegen/nv50_ir_peephole.cpp:1648:38: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]
      CASE(TYPE_S32, s32, INT32_MIN, INT32_MAX, INT32_MIN, INT32_MAX, 0, INT32_MAX);

../src/gallium/drivers/radeonsi/si_nir_lower_vs_inputs.c:400:51: error: implicit conversion from 'unsigned long long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Werror,-Wimplicit-const-int-float-conversion]
         loads[chan] = nir_fmul_imm(b, tmp, 1.0 / BITFIELD64_MASK(bits));

../src/gallium/drivers/radeonsi/si_nir_lower_vs_inputs.c:408:43: error: implicit conversion from 'unsigned long long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Werror,-Wimplicit-const-int-float-conversion]
         tmp = nir_fmul_imm(b, tmp, 1.0 / BITFIELD64_MASK(bits - 1));

Signed-off-by: Vignesh Raman <vignesh.raman@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Acked-by: David Heidelberg <david.heidelberg@collabora.com>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24362>
This commit is contained in:
Vignesh Raman 2023-09-04 08:54:04 +05:30 committed by Marge Bot
parent 3a949de28c
commit 81a28fb3e2
5 changed files with 15 additions and 15 deletions

View file

@ -728,8 +728,8 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
OUT_PKT0(ring, REG_A3XX_RB_Z_CLAMP_MIN, 2);
if (depth == 32) {
OUT_RING(ring, (uint32_t)(zmin * 0xffffffff));
OUT_RING(ring, (uint32_t)(zmax * 0xffffffff));
OUT_RING(ring, (uint32_t)(zmin * (float)0xffffffff));
OUT_RING(ring, (uint32_t)(zmax * (float)0xffffffff));
} else if (depth == 16) {
OUT_RING(ring, (uint32_t)(zmin * 0xffff));
OUT_RING(ring, (uint32_t)(zmax * 0xffff));

View file

@ -399,7 +399,7 @@ opencoded_load_format(nir_builder *b, nir_def *rsrc, nir_def *vindex,
/* 2_10_10_10 data formats */
unsigned bits = log_size == 3 ? (chan == 3 ? 2 : 10) : (8 << log_size);
nir_def *tmp = nir_u2f32(b, loads[chan]);
loads[chan] = nir_fmul_imm(b, tmp, 1.0 / BITFIELD64_MASK(bits));
loads[chan] = nir_fmul_imm(b, tmp, 1.0 / (double)BITFIELD64_MASK(bits));
}
break;
case AC_FETCH_FORMAT_SNORM:
@ -407,7 +407,7 @@ opencoded_load_format(nir_builder *b, nir_def *rsrc, nir_def *vindex,
/* 2_10_10_10 data formats */
unsigned bits = log_size == 3 ? (chan == 3 ? 2 : 10) : (8 << log_size);
nir_def *tmp = nir_i2f32(b, loads[chan]);
tmp = nir_fmul_imm(b, tmp, 1.0 / BITFIELD64_MASK(bits - 1));
tmp = nir_fmul_imm(b, tmp, 1.0 / (double)BITFIELD64_MASK(bits - 1));
/* Clamp to [-1, 1] */
tmp = nir_fmax(b, tmp, nir_imm_float(b, -1));
loads[chan] = nir_fmin(b, tmp, nir_imm_float(b, 1));

View file

@ -83,8 +83,8 @@ FLOAT_TO_BOOLEAN(GLfloat X)
static inline GLint
FLOAT_TO_FIXED(GLfloat F)
{
return ( ((F) * 65536.0f > INT_MAX) ? INT_MAX :
((F) * 65536.0f < INT_MIN) ? INT_MIN :
return ( ((F) * 65536.0f > (float)INT32_MAX) ? INT32_MAX :
((F) * 65536.0f < (float)INT32_MIN) ? INT32_MIN :
(GLint) ((F) * 65536.0f) );
}

View file

@ -54,7 +54,7 @@
/**
* Use macro to resolve undefined clamping behaviour when using lroundf
*/
#define LCLAMPF(a, lmin, lmax) ((a) > (lmin) ? ( (a) >= (lmax) ? (lmax) : (lroundf(a)) ) : (lmin))
#define LCLAMPF(a, lmin, lmax) ((a) > (float)(lmin) ? ( (a) >= (float)(lmax) ? (lmax) : (lroundf(a)) ) : (lmin))
/**
* Check if a coordinate wrap mode is supported for the texture target.
@ -965,8 +965,8 @@ _mesa_texture_parameterf(struct gl_context *ctx,
{
GLint p[4];
p[0] = (param > 0) ?
((param > INT_MAX) ? INT_MAX : (GLint) (param + 0.5)) :
((param < INT_MIN) ? INT_MIN : (GLint) (param - 0.5));
((param > (float)INT32_MAX) ? INT32_MAX : (GLint) (param + 0.5)) :
((param < (float)INT32_MIN) ? INT32_MIN : (GLint) (param - 0.5));
p[1] = p[2] = p[3] = 0;
need_update = set_tex_parameteri(ctx, texObj, pname, p, dsa);
@ -2607,7 +2607,7 @@ get_tex_parameteriv(struct gl_context *ctx,
* it cannot be represented by the returned data type, then the
* nearest value representable using that type is returned.
*/
*params = LCLAMPF(obj->Sampler.Attrib.MinLod, INT_MIN, INT_MAX);
*params = LCLAMPF(obj->Sampler.Attrib.MinLod, INT32_MIN, INT32_MAX);
break;
case GL_TEXTURE_MAX_LOD:
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
@ -2622,7 +2622,7 @@ get_tex_parameteriv(struct gl_context *ctx,
* it cannot be represented by the returned data type, then the
* nearest value representable using that type is returned.
*/
*params = LCLAMPF(obj->Sampler.Attrib.MaxLod, INT_MIN, INT_MAX);
*params = LCLAMPF(obj->Sampler.Attrib.MaxLod, INT32_MIN, INT32_MAX);
break;
case GL_TEXTURE_BASE_LEVEL:
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
@ -2646,7 +2646,7 @@ get_tex_parameteriv(struct gl_context *ctx,
* it cannot be represented by the returned data type, then the
* nearest value representable using that type is returned.
*/
*params = LCLAMPF(obj->Sampler.Attrib.MaxAnisotropy, INT_MIN, INT_MAX);
*params = LCLAMPF(obj->Sampler.Attrib.MaxAnisotropy, INT32_MIN, INT32_MAX);
break;
case GL_GENERATE_MIPMAP_SGIS:
if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
@ -2691,7 +2691,7 @@ get_tex_parameteriv(struct gl_context *ctx,
* it cannot be represented by the returned data type, then the
* nearest value representable using that type is returned.
*/
*params = LCLAMPF(obj->Sampler.Attrib.LodBias, INT_MIN, INT_MAX);
*params = LCLAMPF(obj->Sampler.Attrib.LodBias, INT32_MIN, INT32_MAX);
break;
case GL_TEXTURE_CROP_RECT_OES:
if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture)

View file

@ -1636,8 +1636,8 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
switch(i->dType) {
CASE(TYPE_U16, u16, 0, UINT16_MAX, 0, UINT16_MAX, 0, UINT16_MAX);
CASE(TYPE_S16, s16, INT16_MIN, INT16_MAX, INT16_MIN, INT16_MAX, 0, INT16_MAX);
CASE(TYPE_U32, u32, 0, UINT32_MAX, 0, INT32_MAX, 0, UINT32_MAX);
CASE(TYPE_S32, s32, INT32_MIN, INT32_MAX, INT32_MIN, INT32_MAX, 0, INT32_MAX);
CASE(TYPE_U32, u32, 0, (float)UINT32_MAX, 0, INT32_MAX, 0, UINT32_MAX);
CASE(TYPE_S32, s32, (float)INT32_MIN, (float)INT32_MAX, INT32_MIN, INT32_MAX, 0, INT32_MAX);
case TYPE_F32:
switch (i->sType) {
case TYPE_F64: