nir/builder: only read meaningful channels in nir_swizzle()
authorConnor Abbott <connor.w.abbott@intel.com>
Mon, 3 Aug 2015 22:04:13 +0000 (15:04 -0700)
committerIago Toral Quiroga <itoral@igalia.com>
Mon, 23 Nov 2015 07:36:12 +0000 (08:36 +0100)
This way the caller doesn't have to initialize all 4 channels when they
aren't using them.

v2: Fix signed/unsigned comparison warning (Iago)

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/nir/nir_builder.h

index d09f929405b0f09d1211fc246c1cf844afdee25b..b909f483579cc737ce7e5b9e65adf24dfd30dd68 100644 (file)
@@ -242,7 +242,7 @@ nir_swizzle(nir_builder *build, nir_ssa_def *src, unsigned swiz[4],
 {
    nir_alu_src alu_src = { NIR_SRC_INIT };
    alu_src.src = nir_src_for_ssa(src);
-   for (int i = 0; i < 4; i++)
+   for (unsigned i = 0; i < num_components; i++)
       alu_src.swizzle[i] = swiz[i];
 
    return use_fmov ? nir_fmov_alu(build, alu_src, num_components) :