[Mesa-dev] [PATCH] nir: Fix output swizzle in get_mul_for_src
Samuel Iglesias Gonsalvez
siglesias at igalia.com
Thu Jun 11 06:20:26 PDT 2015
When we compute output swizzle, avoid reusing it as the source of the
computation because, otherwise, it could calculate it wrongly.
Signed-off-by: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
---
src/glsl/nir/nir_opt_peephole_ffma.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/glsl/nir/nir_opt_peephole_ffma.c b/src/glsl/nir/nir_opt_peephole_ffma.c
index 798506b..c559017 100644
--- a/src/glsl/nir/nir_opt_peephole_ffma.c
+++ b/src/glsl/nir/nir_opt_peephole_ffma.c
@@ -76,6 +76,8 @@ static nir_alu_instr *
get_mul_for_src(nir_alu_src *src, int num_components,
uint8_t swizzle[4], bool *negate, bool *abs)
{
+ uint8_t swizzle_tmp[4];
+
assert(src->src.is_ssa && !src->abs && !src->negate);
nir_instr *instr = src->src.ssa->parent_instr;
@@ -116,8 +118,9 @@ get_mul_for_src(nir_alu_src *src, int num_components,
if (!alu)
return NULL;
+ memcpy(swizzle_tmp, swizzle, 4*sizeof(uint8_t));
for (unsigned i = 0; i < num_components; i++)
- swizzle[i] = swizzle[src->swizzle[i]];
+ swizzle[i] = swizzle_tmp[src->swizzle[i]];
return alu;
}
--
2.1.0
More information about the mesa-dev
mailing list