aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_format_convert.h
diff options
context:
space:
mode:
authorKarol Herbst <[email protected]>2019-03-27 00:59:03 +0100
committerKarol Herbst <[email protected]>2019-04-14 22:25:56 +0200
commit14531d676b11999123c04fb7569ab80c9f150180 (patch)
treed0f40439b5b92fa362195868300098c063f71ea7 /src/compiler/nir/nir_format_convert.h
parent73d883037d170ab8dcade3e0cfcf9f33c8ed6557 (diff)
nir: make nir_const_value scalar
v2: remove & operator in a couple of memsets add some memsets v3: fixup lima Signed-off-by: Karol Herbst <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> (v2)
Diffstat (limited to 'src/compiler/nir/nir_format_convert.h')
-rw-r--r--src/compiler/nir/nir_format_convert.h23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/compiler/nir/nir_format_convert.h b/src/compiler/nir/nir_format_convert.h
index bf6dc201a18..23f85ada8d8 100644
--- a/src/compiler/nir/nir_format_convert.h
+++ b/src/compiler/nir/nir_format_convert.h
@@ -53,10 +53,11 @@ nir_mask_shift_or(struct nir_builder *b, nir_ssa_def *dst, nir_ssa_def *src,
static inline nir_ssa_def *
nir_format_mask_uvec(nir_builder *b, nir_ssa_def *src, const unsigned *bits)
{
- nir_const_value mask;
+ nir_const_value mask[NIR_MAX_VEC_COMPONENTS];
+ memset(mask, 0, sizeof(mask));
for (unsigned i = 0; i < src->num_components; i++) {
assert(bits[i] < 32);
- mask.u32[i] = (1u << bits[i]) - 1;
+ mask[i].u32 = (1u << bits[i]) - 1;
}
return nir_iand(b, src, nir_build_imm(b, src->num_components, 32, mask));
}
@@ -210,10 +211,11 @@ _nir_format_norm_factor(nir_builder *b, const unsigned *bits,
unsigned num_components,
bool is_signed)
{
- nir_const_value factor;
+ nir_const_value factor[NIR_MAX_VEC_COMPONENTS];
+ memset(factor, 0, sizeof(factor));
for (unsigned i = 0; i < num_components; i++) {
assert(bits[i] < 32);
- factor.f32[i] = (1ul << (bits[i] - is_signed)) - 1;
+ factor[i].f32 = (1ul << (bits[i] - is_signed)) - 1;
}
return nir_build_imm(b, num_components, 32, factor);
}
@@ -309,10 +311,11 @@ nir_format_clamp_uint(nir_builder *b, nir_ssa_def *f, const unsigned *bits)
if (bits[0] == 32)
return f;
- nir_const_value max;
+ nir_const_value max[NIR_MAX_VEC_COMPONENTS];
+ memset(max, 0, sizeof(max));
for (unsigned i = 0; i < f->num_components; i++) {
assert(bits[i] < 32);
- max.u32[i] = (1 << bits[i]) - 1;
+ max[i].u32 = (1 << bits[i]) - 1;
}
return nir_umin(b, f, nir_build_imm(b, f->num_components, 32, max));
}
@@ -326,11 +329,13 @@ nir_format_clamp_sint(nir_builder *b, nir_ssa_def *f, const unsigned *bits)
if (bits[0] == 32)
return f;
- nir_const_value min, max;
+ nir_const_value min[NIR_MAX_VEC_COMPONENTS], max[NIR_MAX_VEC_COMPONENTS];
+ memset(min, 0, sizeof(min));
+ memset(max, 0, sizeof(max));
for (unsigned i = 0; i < f->num_components; i++) {
assert(bits[i] < 32);
- max.i32[i] = (1 << (bits[i] - 1)) - 1;
- min.i32[i] = -(1 << (bits[i] - 1));
+ max[i].i32 = (1 << (bits[i] - 1)) - 1;
+ min[i].i32 = -(1 << (bits[i] - 1));
}
f = nir_imin(b, f, nir_build_imm(b, f->num_components, 32, max));
f = nir_imax(b, f, nir_build_imm(b, f->num_components, 32, min));