Mesa (7.9): ir_to_mesa: Only compare vector_elements present for any_nequal /all_equal
Eric Anholt
anholt at kemper.freedesktop.org
Wed Sep 22 20:43:59 UTC 2010
Module: Mesa
Branch: 7.9
Commit: 5285100502ad991ba5b012f499726c2dd46a8fe4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5285100502ad991ba5b012f499726c2dd46a8fe4
Author: Eric Anholt <eric at anholt.net>
Date: Wed Sep 22 13:07:57 2010 -0700
ir_to_mesa: Only compare vector_elements present for any_nequal/all_equal
Fixes: glsl-mat-from-int-ctor-03
(cherry picked from commit eaa6bf59db68f97fa32c3395eb4aa6e589f34b26)
---
src/mesa/program/ir_to_mesa.cpp | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 2edf01b..18ca100 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1097,6 +1097,12 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
assert(!ir->operands[operand]->type->is_matrix());
}
+ int vector_elements = ir->operands[0]->type->vector_elements;
+ if (ir->operands[1]) {
+ vector_elements = MAX2(vector_elements,
+ ir->operands[1]->type->vector_elements);
+ }
+
this->result.file = PROGRAM_UNDEFINED;
/* Storage for our result. Ideally for an assignment we'd be using
@@ -1205,7 +1211,12 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
ir_to_mesa_src_reg temp = get_temp(glsl_type::vec4_type);
ir_to_mesa_emit_op2(ir, OPCODE_SNE,
ir_to_mesa_dst_reg_from_src(temp), op[0], op[1]);
- ir_to_mesa_emit_op2(ir, OPCODE_DP4, result_dst, temp, temp);
+ if (vector_elements == 4)
+ ir_to_mesa_emit_op2(ir, OPCODE_DP4, result_dst, temp, temp);
+ else if (vector_elements == 3)
+ ir_to_mesa_emit_op2(ir, OPCODE_DP3, result_dst, temp, temp);
+ else
+ ir_to_mesa_emit_op2(ir, OPCODE_DP2, result_dst, temp, temp);
ir_to_mesa_emit_op2(ir, OPCODE_SEQ,
result_dst, result_src, src_reg_for_float(0.0));
} else {
@@ -1219,7 +1230,12 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
ir_to_mesa_src_reg temp = get_temp(glsl_type::vec4_type);
ir_to_mesa_emit_op2(ir, OPCODE_SNE,
ir_to_mesa_dst_reg_from_src(temp), op[0], op[1]);
- ir_to_mesa_emit_op2(ir, OPCODE_DP4, result_dst, temp, temp);
+ if (vector_elements == 4)
+ ir_to_mesa_emit_op2(ir, OPCODE_DP4, result_dst, temp, temp);
+ else if (vector_elements == 3)
+ ir_to_mesa_emit_op2(ir, OPCODE_DP3, result_dst, temp, temp);
+ else
+ ir_to_mesa_emit_op2(ir, OPCODE_DP2, result_dst, temp, temp);
ir_to_mesa_emit_op2(ir, OPCODE_SNE,
result_dst, result_src, src_reg_for_float(0.0));
} else {
More information about the mesa-commit
mailing list