[Mesa-dev] [PATCH 2/2] nir: fix a bug with constant folding non-per-component instructions

Connor Abbott cwabbott0 at gmail.com
Sun Jan 25 08:56:41 PST 2015


Before, we were only copying the first N channels, where N is the size
of the SSA destination, which is fine for per-component instructions,
but non-per-component instructions like fdot3 can have more source
components than destination components. Fix this using the helper
function introduced in the last patch.

Signed-off-by: Connor Abbott <cwabbott0 at gmail.com>
---
Whoops, sorry I missed this during review...

 src/glsl/nir/nir_opt_constant_folding.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/glsl/nir/nir_opt_constant_folding.c b/src/glsl/nir/nir_opt_constant_folding.c
index f727453..e79e287 100644
--- a/src/glsl/nir/nir_opt_constant_folding.c
+++ b/src/glsl/nir/nir_opt_constant_folding.c
@@ -56,7 +56,8 @@ constant_fold_alu_instr(nir_alu_instr *instr, void *mem_ctx)
          return false;
       nir_load_const_instr* load_const = nir_instr_as_load_const(src_instr);
 
-      for (unsigned j = 0; j < instr->dest.dest.ssa.num_components; j++) {
+      for (unsigned j = 0; j < nir_alu_instr_ssa_src_components(instr, i);
+           j++) {
          src[i].u[j] = load_const->value.u[instr->src[i].swizzle[j]];
       }
 
-- 
2.1.0



More information about the mesa-dev mailing list