src/compiler: Fix warning C4244 'argument' : conversion from 'type1' to 'type2', possible loss of data

Reviewed-By: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Jesse Natalie <None>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32979>
This commit is contained in:
Sil Vilerino
2025-01-09 08:20:54 -05:00
committed by Marge Bot
parent 4d653c7df9
commit 8ecb7bc2a2
4 changed files with 24 additions and 18 deletions
+14 -8
View File
@@ -535,6 +535,12 @@ glsl_type_is_struct_or_ifc(const glsl_type *t)
return glsl_type_is_struct(t) || glsl_type_is_interface(t);
}
static inline bool
glsl_type_is_packed(const glsl_type *t)
{
return (t->packed != 0);
}
static inline bool
glsl_type_is_16bit(const glsl_type *t)
{
@@ -674,14 +680,14 @@ static inline bool
glsl_matrix_type_is_row_major(const glsl_type *t)
{
assert((glsl_type_is_matrix(t) && t->explicit_stride) || glsl_type_is_interface(t));
return t->interface_row_major;
return (t->interface_row_major != 0);
}
static inline bool
glsl_sampler_type_is_shadow(const glsl_type *t)
{
assert(glsl_type_is_sampler(t));
return t->sampler_shadow;
return (t->sampler_shadow != 0);
}
static inline bool
@@ -690,14 +696,14 @@ glsl_sampler_type_is_array(const glsl_type *t)
assert(glsl_type_is_sampler(t) ||
glsl_type_is_texture(t) ||
glsl_type_is_image(t));
return t->sampler_array;
return (t->sampler_array != 0);
}
static inline bool
glsl_struct_type_is_packed(const glsl_type *t)
{
assert(glsl_type_is_struct(t));
return t->packed;
return (t->packed != 0);
}
/**
@@ -1130,7 +1136,7 @@ glsl_texture_type_to_sampler(const glsl_type *t, bool is_shadow)
{
assert(glsl_type_is_texture(t));
return glsl_sampler_type((enum glsl_sampler_dim)t->sampler_dimensionality,
is_shadow, t->sampler_array,
is_shadow, (t->sampler_array != 0),
(enum glsl_base_type)t->sampled_type);
}
@@ -1139,7 +1145,7 @@ glsl_sampler_type_to_texture(const glsl_type *t)
{
assert(glsl_type_is_sampler(t) && !glsl_type_is_bare_sampler(t));
return glsl_texture_type((enum glsl_sampler_dim)t->sampler_dimensionality,
t->sampler_array,
(t->sampler_array != 0),
(enum glsl_base_type)t->sampled_type);
}
@@ -1318,10 +1324,10 @@ glsl_get_explicit_interface_type(const glsl_type *t, bool supports_std430)
{
enum glsl_interface_packing packing = glsl_get_internal_ifc_packing(t, supports_std430);
if (packing == GLSL_INTERFACE_PACKING_STD140) {
return glsl_get_explicit_std140_type(t, t->interface_row_major);
return glsl_get_explicit_std140_type(t, (t->interface_row_major != 0));
} else {
assert(packing == GLSL_INTERFACE_PACKING_STD430);
return glsl_get_explicit_std430_type(t, t->interface_row_major);
return glsl_get_explicit_std430_type(t, (t->interface_row_major != 0));
}
}
+3 -3
View File
@@ -329,9 +329,9 @@ nir_const_value_for_raw_uint(uint64_t x, unsigned bit_size)
/* clang-format off */
switch (bit_size) {
case 1: v.b = x; break;
case 8: v.u8 = x; break;
case 16: v.u16 = x; break;
case 32: v.u32 = x; break;
case 8: v.u8 = (uint8_t)x; break;
case 16: v.u16 = (uint16_t)x; break;
case 32: v.u32 = (uint32_t)x; break;
case 64: v.u64 = x; break;
default:
unreachable("Invalid bit size");
+6 -6
View File
@@ -667,7 +667,7 @@ nir_swizzle(nir_builder *build, nir_def *src, const unsigned *swiz,
for (unsigned i = 0; i < num_components && i < NIR_MAX_VEC_COMPONENTS; i++) {
if (swiz[i] != i)
is_identity_swizzle = false;
alu_src.swizzle[i] = swiz[i];
alu_src.swizzle[i] = (uint8_t)swiz[i];
}
if (num_components == src->num_components && is_identity_swizzle)
@@ -819,7 +819,7 @@ nir_vector_extract(nir_builder *b, nir_def *vec, nir_def *c)
if (nir_src_is_const(c_src)) {
uint64_t c_const = nir_src_as_uint(c_src);
if (c_const < vec->num_components)
return nir_channel(b, vec, c_const);
return nir_channel(b, vec, (unsigned)c_const);
else
return nir_undef(b, 1, vec->bit_size);
} else {
@@ -847,7 +847,7 @@ nir_vector_insert_imm(nir_builder *b, nir_def *vec,
vec_instr->src[i].swizzle[0] = 0;
} else {
vec_instr->src[i].src = nir_src_for_ssa(vec);
vec_instr->src[i].swizzle[0] = i;
vec_instr->src[i].swizzle[0] = (uint8_t)i;
}
}
@@ -866,7 +866,7 @@ nir_vector_insert(nir_builder *b, nir_def *vec, nir_def *scalar,
if (nir_src_is_const(c_src)) {
uint64_t c_const = nir_src_as_uint(c_src);
if (c_const < vec->num_components)
return nir_vector_insert_imm(b, vec, scalar, c_const);
return nir_vector_insert_imm(b, vec, scalar, (unsigned )c_const);
else
return vec;
} else {
@@ -1908,7 +1908,7 @@ nir_load_global(nir_builder *build, nir_def *addr, unsigned align,
{
nir_intrinsic_instr *load =
nir_intrinsic_instr_create(build->shader, nir_intrinsic_load_global);
load->num_components = num_components;
load->num_components = (uint8_t)num_components;
load->src[0] = nir_src_for_ssa(addr);
nir_intrinsic_set_align(load, align, 0);
nir_def_init(&load->instr, &load->def, num_components, bit_size);
@@ -1939,7 +1939,7 @@ nir_load_global_constant(nir_builder *build, nir_def *addr, unsigned align,
{
nir_intrinsic_instr *load =
nir_intrinsic_instr_create(build->shader, nir_intrinsic_load_global_constant);
load->num_components = num_components;
load->num_components = (uint8_t)num_components;
load->src[0] = nir_src_for_ssa(addr);
nir_intrinsic_set_align(load, align, 0);
nir_def_init(&load->instr, &load->def, num_components, bit_size);
+1 -1
View File
@@ -124,7 +124,7 @@ _nir_build_${name}(nir_builder *build${intrinsic_decl_list(opcode)})
% if 0 in opcode.src_components:
intrin->num_components = src${opcode.src_components.index(0)}->num_components;
% elif opcode.dest_components == 0:
intrin->num_components = num_components;
intrin->num_components = (uint8_t)num_components;
% endif
% if opcode.has_dest:
% if opcode.dest_components == 0: