From: Connor Abbott Date: Mon, 3 Aug 2015 22:04:13 +0000 (-0700) Subject: nir/builder: only read meaningful channels in nir_swizzle() X-Git-Tag: upstream/17.1.0~14297 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb93dd7aa8f2cac520bbbd3fc2af807bd2573480;p=platform%2Fupstream%2Fmesa.git nir/builder: only read meaningful channels in nir_swizzle() 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 Reviewed-by: Matt Turner --- diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h index d09f929..b909f483 100644 --- a/src/glsl/nir/nir_builder.h +++ b/src/glsl/nir/nir_builder.h @@ -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) :