aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/lower_instructions.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-03-04 08:18:40 +0100
committermarha <marha@users.sourceforge.net>2013-03-04 08:18:40 +0100
commitd4d629b77742e60caac3d120ff40e9f386380af2 (patch)
treeed3eacb0fdcf29da0a24e03c4330ce8e3bb66718 /mesalib/src/glsl/lower_instructions.cpp
parentc74ef795c7282681616decc36a9a81cd1b1b6ec7 (diff)
downloadvcxsrv-d4d629b77742e60caac3d120ff40e9f386380af2.tar.gz
vcxsrv-d4d629b77742e60caac3d120ff40e9f386380af2.tar.bz2
vcxsrv-d4d629b77742e60caac3d120ff40e9f386380af2.zip
fontconfig libX11 mesalib pixman xserver xkeyboard-config git update 4 Mar 2013
xserver commit 8f4640bdb9d3988148e09a08d2c7e3bab1d538d6 xkeyboard-config commit fa2f330df22511c3846cb1cb0760551c6e244a81 libX11 commit c23d61d1b84dca3740bf4786978c7908d0065fb9 pixman commit 5feda20fc39407879993ed4a6d861ef7f78d9432 fontconfig commit 612ee2a5c91b8929b2cc5abce4af84d8d7e66bd0 mesa commit e29124717eae4f8d329bb6a9707b802c0ff4bdd9
Diffstat (limited to 'mesalib/src/glsl/lower_instructions.cpp')
-rw-r--r--mesalib/src/glsl/lower_instructions.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/mesalib/src/glsl/lower_instructions.cpp b/mesalib/src/glsl/lower_instructions.cpp
index a8ef7654e..1ce7b7c9d 100644
--- a/mesalib/src/glsl/lower_instructions.cpp
+++ b/mesalib/src/glsl/lower_instructions.cpp
@@ -37,6 +37,7 @@
* - POW_TO_EXP2
* - LOG_TO_LOG2
* - MOD_TO_FRACT
+ * - LRP_TO_ARITH
*
* SUB_TO_ADD_NEG:
* ---------------
@@ -79,13 +80,20 @@
* Many GPUs don't have a MOD instruction (945 and 965 included), and
* if we have to break it down like this anyway, it gives an
* opportunity to do things like constant fold the (1.0 / op1) easily.
+ *
+ * LRP_TO_ARITH:
+ * -------------
+ * Converts ir_triop_lrp to (op0 * (1.0f - op2)) + (op1 * op2).
*/
#include "main/core.h" /* for M_LOG2E */
#include "glsl_types.h"
#include "ir.h"
+#include "ir_builder.h"
#include "ir_optimization.h"
+using namespace ir_builder;
+
class lower_instructions_visitor : public ir_hierarchical_visitor {
public:
lower_instructions_visitor(unsigned lower)
@@ -105,6 +113,7 @@ private:
void exp_to_exp2(ir_expression *);
void pow_to_exp2(ir_expression *);
void log_to_log2(ir_expression *);
+ void lrp_to_arith(ir_expression *);
};
/**
@@ -268,6 +277,27 @@ lower_instructions_visitor::mod_to_fract(ir_expression *ir)
this->progress = true;
}
+void
+lower_instructions_visitor::lrp_to_arith(ir_expression *ir)
+{
+ /* (lrp x y a) -> x*(1-a) + y*a */
+
+ /* Save op2 */
+ ir_variable *temp = new(ir) ir_variable(ir->operands[2]->type, "lrp_factor",
+ ir_var_temporary);
+ this->base_ir->insert_before(temp);
+ this->base_ir->insert_before(assign(temp, ir->operands[2]));
+
+ ir_constant *one = new(ir) ir_constant(1.0f);
+
+ ir->operation = ir_binop_add;
+ ir->operands[0] = mul(ir->operands[0], sub(one, temp));
+ ir->operands[1] = mul(ir->operands[1], temp);
+ ir->operands[2] = NULL;
+
+ this->progress = true;
+}
+
ir_visitor_status
lower_instructions_visitor::visit_leave(ir_expression *ir)
{
@@ -304,6 +334,11 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
pow_to_exp2(ir);
break;
+ case ir_triop_lrp:
+ if (lowering(LRP_TO_ARITH))
+ lrp_to_arith(ir);
+ break;
+
default:
return visit_continue;
}