glsl: Remove the ir_binop_cross opcode.

This commit is contained in:
Kenneth Graunke
2010-11-17 13:59:17 -08:00
parent af1cba2260
commit 9935fe705d
7 changed files with 8 additions and 54 deletions

View File

@@ -252,7 +252,6 @@ ir_expression::get_num_operands(ir_expression_operation op)
2, /* ir_binop_logic_or */ 2, /* ir_binop_logic_or */
2, /* ir_binop_dot */ 2, /* ir_binop_dot */
2, /* ir_binop_cross */
2, /* ir_binop_min */ 2, /* ir_binop_min */
2, /* ir_binop_max */ 2, /* ir_binop_max */
@@ -317,7 +316,6 @@ static const char *const operator_strs[] = {
"^^", "^^",
"||", "||",
"dot", "dot",
"cross",
"min", "min",
"max", "max",
"pow", "pow",

View File

@@ -771,7 +771,6 @@ enum ir_expression_operation {
ir_binop_logic_or, ir_binop_logic_or,
ir_binop_dot, ir_binop_dot,
ir_binop_cross,
ir_binop_min, ir_binop_min,
ir_binop_max, ir_binop_max,

View File

@@ -412,17 +412,6 @@ ir_expression::constant_expression_value()
} }
break; break;
case ir_binop_cross:
assert(op[0]->type == glsl_type::vec3_type);
assert(op[1]->type == glsl_type::vec3_type);
data.f[0] = (op[0]->value.f[1] * op[1]->value.f[2] -
op[1]->value.f[1] * op[0]->value.f[2]);
data.f[1] = (op[0]->value.f[2] * op[1]->value.f[0] -
op[1]->value.f[2] * op[0]->value.f[0]);
data.f[2] = (op[0]->value.f[0] * op[1]->value.f[1] -
op[1]->value.f[0] * op[0]->value.f[1]);
break;
case ir_binop_add: case ir_binop_add:
assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
for (unsigned c = 0, c0 = 0, c1 = 0; for (unsigned c = 0, c0 = 0, c1 = 0;
@@ -1064,7 +1053,14 @@ ir_call::constant_expression_value()
for (unsigned c = 0; c < op[0]->type->components(); c++) for (unsigned c = 0; c < op[0]->type->components(); c++)
data.f[c] = coshf(op[0]->value.f[c]); data.f[c] = coshf(op[0]->value.f[c]);
} else if (strcmp(callee, "cross") == 0) { } else if (strcmp(callee, "cross") == 0) {
expr = new(mem_ctx) ir_expression(ir_binop_cross, type, op[0], op[1]); assert(op[0]->type == glsl_type::vec3_type);
assert(op[1]->type == glsl_type::vec3_type);
data.f[0] = (op[0]->value.f[1] * op[1]->value.f[2] -
op[1]->value.f[1] * op[0]->value.f[2]);
data.f[1] = (op[0]->value.f[2] * op[1]->value.f[0] -
op[1]->value.f[2] * op[0]->value.f[0]);
data.f[2] = (op[0]->value.f[0] * op[1]->value.f[1] -
op[1]->value.f[0] * op[0]->value.f[1]);
} else if (strcmp(callee, "degrees") == 0) { } else if (strcmp(callee, "degrees") == 0) {
assert(op[0]->type->is_float()); assert(op[0]->type->is_float());
for (unsigned c = 0; c < op[0]->type->components(); c++) for (unsigned c = 0; c < op[0]->type->components(); c++)

View File

@@ -372,12 +372,6 @@ ir_validate::visit_leave(ir_expression *ir)
assert(ir->operands[0]->type->is_vector()); assert(ir->operands[0]->type->is_vector());
assert(ir->operands[0]->type == ir->operands[1]->type); assert(ir->operands[0]->type == ir->operands[1]->type);
break; break;
case ir_binop_cross:
assert(ir->operands[0]->type == glsl_type::vec3_type);
assert(ir->operands[1]->type == glsl_type::vec3_type);
assert(ir->type == glsl_type::vec3_type);
break;
} }
return visit_continue; return visit_continue;

View File

@@ -850,7 +850,6 @@ fs_visitor::visit(ir_expression *ir)
break; break;
case ir_binop_dot: case ir_binop_dot:
case ir_binop_cross:
case ir_unop_any: case ir_unop_any:
assert(!"not reached: should be handled by brw_fs_channel_expressions"); assert(!"not reached: should be handled by brw_fs_channel_expressions");
break; break;

View File

@@ -288,34 +288,6 @@ ir_channel_expressions_visitor::visit_leave(ir_assignment *ir)
break; break;
} }
case ir_binop_cross: {
for (i = 0; i < vector_elements; i++) {
int swiz0 = (i + 1) % 3;
int swiz1 = (i + 2) % 3;
ir_expression *temp1, *temp2;
temp1 = new(mem_ctx) ir_expression(ir_binop_mul,
element_type,
get_element(op_var[0], swiz0),
get_element(op_var[1], swiz1));
temp2 = new(mem_ctx) ir_expression(ir_binop_mul,
element_type,
get_element(op_var[1], swiz0),
get_element(op_var[0], swiz1));
temp2 = new(mem_ctx) ir_expression(ir_unop_neg,
element_type,
temp2,
NULL);
assign(ir, i, new(mem_ctx) ir_expression(ir_binop_add,
element_type,
temp1, temp2));
}
break;
}
case ir_binop_logic_and: case ir_binop_logic_and:
case ir_binop_logic_xor: case ir_binop_logic_xor:
case ir_binop_logic_or: case ir_binop_logic_or:

View File

@@ -1058,10 +1058,6 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
ir->operands[0]->type->vector_elements); ir->operands[0]->type->vector_elements);
break; break;
case ir_binop_cross:
ir_to_mesa_emit_op2(ir, OPCODE_XPD, result_dst, op[0], op[1]);
break;
case ir_unop_sqrt: case ir_unop_sqrt:
/* sqrt(x) = x * rsq(x). */ /* sqrt(x) = x * rsq(x). */
ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]);