From: Ian Romanick Date: Mon, 29 Mar 2010 22:11:05 +0000 (-0700) Subject: Implement HIR conversion for ast_nequal and ast_equal X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6e659caaa946339a2de3890a8bed091ccb65102a;p=mesa.git Implement HIR conversion for ast_nequal and ast_equal The following tests now pass: shaders/glsl-unused-varying.frag shaders/glsl-fs-sqrt-branch.frag --- diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 8d34adf8ef4..4674cfcdd52 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -582,7 +582,30 @@ ast_expression::hir(exec_list *instructions, case ast_nequal: case ast_equal: - /* FINISHME: Implement equality operators. */ + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + /* From page 58 (page 64 of the PDF) of the GLSL 1.50 spec: + * + * "The equality operators equal (==), and not equal (!=) + * operate on all types. They result in a scalar Boolean. If + * the operand types do not match, then there must be a + * conversion from Section 4.1.10 "Implicit Conversions" + * applied to one operand that can make them match, in which + * case this conversion is done." + */ + /* FINISHME: Apply implicit conversions */ + if (op[0]->type != op[1]->type) { + _mesa_glsl_error(& loc, state, "operands of `%s' must have the same " + "type", (this->oper == ast_equal) ? "==" : "!="); + error_emitted = true; + } + + result = new ir_expression(operations[this->oper], glsl_type::bool_type, + op[0], op[1]); + type = glsl_type::bool_type; + + assert(result->type == glsl_type::bool_type); break; case ast_bit_and: