diff options
author | Karol Herbst <[email protected]> | 2018-07-13 03:33:22 +0200 |
---|---|---|
committer | Karol Herbst <[email protected]> | 2018-07-13 15:46:57 +0200 |
commit | cb65246ed2ac826285b6d6cc6e1994ff1299e531 (patch) | |
tree | 41b6f0180b5f5f41f7c96aed00e05f8917a3bdc3 /src/compiler/nir/nir_builder.h | |
parent | 0288fe8d0417730bdd5b3477130dd1dc32bdbcd3 (diff) |
nir: cleanup oversized arrays in nir_swizzle calls
There are no fixed sized array arguments in C, those are simply pointers
to unsized arrays and as the size is passed in anyway, just rely on that.
where possible calls are replaced by nir_channel and nir_channels.
Reviewed-by: Jason Ekstrand <[email protected]>
Signed-off-by: Karol Herbst <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_builder.h')
-rw-r--r-- | src/compiler/nir/nir_builder.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index ae64e72663c..ed61771150a 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -430,12 +430,13 @@ nir_imov_alu(nir_builder *build, nir_alu_src src, unsigned num_components) * Construct an fmov or imov that reswizzles the source's components. */ static inline nir_ssa_def * -nir_swizzle(nir_builder *build, nir_ssa_def *src, const unsigned swiz[4], +nir_swizzle(nir_builder *build, nir_ssa_def *src, const unsigned *swiz, unsigned num_components, bool use_fmov) { + assert(num_components <= 4); nir_alu_src alu_src = { NIR_SRC_INIT }; alu_src.src = nir_src_for_ssa(src); - for (unsigned i = 0; i < num_components; i++) + for (unsigned i = 0; i < num_components && i < 4; i++) alu_src.swizzle[i] = swiz[i]; return use_fmov ? nir_fmov_alu(build, alu_src, num_components) : @@ -481,8 +482,7 @@ nir_bany(nir_builder *b, nir_ssa_def *src) static inline nir_ssa_def * nir_channel(nir_builder *b, nir_ssa_def *def, unsigned c) { - unsigned swizzle[4] = {c, c, c, c}; - return nir_swizzle(b, def, swizzle, 1, false); + return nir_swizzle(b, def, &c, 1, false); } static inline nir_ssa_def * |