summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl/ir.h')
-rw-r--r--src/glsl/ir.h87
1 files changed, 83 insertions, 4 deletions
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 80e0f67d6d8..850033b185f 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -33,6 +33,7 @@ extern "C" {
#include <talloc.h>
}
+#include "glsl_types.h"
#include "list.h"
#include "ir_visitor.h"
#include "ir_hierarchical_visitor.h"
@@ -143,6 +144,8 @@ public:
return this;
}
+ ir_rvalue *as_rvalue_to_saturate();
+
virtual bool is_lvalue()
{
return false;
@@ -171,6 +174,42 @@ public:
return NULL;
}
+ /**
+ * Determine if an r-value has the value zero
+ *
+ * The base implementation of this function always returns \c false. The
+ * \c ir_constant class over-rides this function to return \c true \b only
+ * for vector and scalar types that have all elements set to the value
+ * zero (or \c false for booleans).
+ *
+ * \sa ir_constant::has_value, ir_rvalue::is_one, ir_rvalue::is_negative_one
+ */
+ virtual bool is_zero() const;
+
+ /**
+ * Determine if an r-value has the value one
+ *
+ * The base implementation of this function always returns \c false. The
+ * \c ir_constant class over-rides this function to return \c true \b only
+ * for vector and scalar types that have all elements set to the value
+ * one (or \c true for booleans).
+ *
+ * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_negative_one
+ */
+ virtual bool is_one() const;
+
+ /**
+ * Determine if an r-value has the value negative one
+ *
+ * The base implementation of this function always returns \c false. The
+ * \c ir_constant class over-rides this function to return \c true \b only
+ * for vector and scalar types that have all elements set to the value
+ * negative one. For boolean times, the result is always \c false.
+ *
+ * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_one
+ */
+ virtual bool is_negative_one() const;
+
protected:
ir_rvalue();
};
@@ -705,6 +744,8 @@ enum ir_expression_operation {
/*@{*/
ir_unop_sin,
ir_unop_cos,
+ ir_unop_sin_reduced, /**< Reduced range sin. [-pi, pi] */
+ ir_unop_cos_reduced, /**< Reduced range cos. [-pi, pi] */
/*@}*/
/**
@@ -717,6 +758,11 @@ enum ir_expression_operation {
ir_unop_noise,
+ /**
+ * A sentinel marking the last of the unary operations.
+ */
+ ir_last_unop = ir_unop_noise,
+
ir_binop_add,
ir_binop_sub,
ir_binop_mul,
@@ -771,18 +817,43 @@ enum ir_expression_operation {
ir_binop_logic_or,
ir_binop_dot,
- ir_binop_cross,
ir_binop_min,
ir_binop_max,
- ir_binop_pow
+ ir_binop_pow,
+
+ /**
+ * A sentinel marking the last of the binary operations.
+ */
+ ir_last_binop = ir_binop_pow,
+
+ ir_quadop_vector,
+
+ /**
+ * A sentinel marking the last of all operations.
+ */
+ ir_last_opcode = ir_last_binop
};
class ir_expression : public ir_rvalue {
public:
+ /**
+ * Constructor for unary operation expressions
+ */
+ ir_expression(int op, const struct glsl_type *type, ir_rvalue *);
+
+ /**
+ * Constructor for binary operation expressions
+ */
ir_expression(int op, const struct glsl_type *type,
ir_rvalue *, ir_rvalue *);
+ /**
+ * Constructor for quad operator expressions
+ */
+ ir_expression(int op, const struct glsl_type *type,
+ ir_rvalue *, ir_rvalue *, ir_rvalue *, ir_rvalue *);
+
virtual ir_expression *as_expression()
{
return this;
@@ -808,7 +879,8 @@ public:
*/
unsigned int get_num_operands() const
{
- return get_num_operands(operation);
+ return (this->operation == ir_quadop_vector)
+ ? this->type->vector_elements : get_num_operands(operation);
}
/**
@@ -835,7 +907,7 @@ public:
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
ir_expression_operation operation;
- ir_rvalue *operands[2];
+ ir_rvalue *operands[4];
};
@@ -1441,9 +1513,16 @@ public:
/**
* Determine whether a constant has the same value as another constant
+ *
+ * \sa ir_constant::is_zero, ir_constant::is_one,
+ * ir_constant::is_negative_one
*/
bool has_value(const ir_constant *) const;
+ virtual bool is_zero() const;
+ virtual bool is_one() const;
+ virtual bool is_negative_one() const;
+
/**
* Value of the constant.
*