* floating-point scalars, vectors, and matrices."
*/
if (!type_a->is_numeric() || !type_b->is_numeric()) {
- return glsl_error_type;
+ return glsl_type::error_type;
}
* equality.
*/
if (type_a->base_type != type_b->base_type) {
- return glsl_error_type;
+ return glsl_type::error_type;
}
/* "All arithmetic binary operators result in the same fundamental type
* vector."
*/
if (type_a->is_vector() && type_b->is_vector()) {
- return (type_a == type_b) ? type_a : glsl_error_type;
+ return (type_a == type_b) ? type_a : glsl_type::error_type;
}
/* All of the combinations of <scalar, scalar>, <vector, scalar>,
* more detail how vectors and matrices are operated on."
*/
if (! multiply) {
- return (type_a == type_b) ? type_a : glsl_error_type;
+ return (type_a == type_b) ? type_a : glsl_type::error_type;
} else {
if (type_a->is_matrix() && type_b->is_matrix()) {
/* Matrix multiply. The columns of A must match the rows of B. Given
/* "All other cases are illegal."
*/
- return glsl_error_type;
+ return glsl_type::error_type;
}
* they operated on."
*/
if (!is_numeric_base_type(type->base_type))
- return glsl_error_type;
+ return glsl_type::error_type;
return type;
}
if (! is_integer_base_type(type_a->base_type)
|| ! is_integer_base_type(type_b->base_type)
|| (type_a->base_type != type_b->base_type)) {
- return glsl_error_type;
+ return glsl_type::error_type;
}
/* "The operands cannot be vectors of differing size. If one operand is
/* "The operator modulus (%) is not defined for any other data types
* (non-integer types)."
*/
- return glsl_error_type;
+ return glsl_type::error_type;
}
|| ! is_numeric_base_type(type_b->base_type)
|| !type_a->is_scalar()
|| !type_b->is_scalar())
- return glsl_error_type;
+ return glsl_type::error_type;
/* "Either the operands' types must match, or the conversions from
* Section 4.1.10 "Implicit Conversions" will be applied to the integer
}
if (type_a->base_type != type_b->base_type)
- return glsl_error_type;
+ return glsl_type::error_type;
/* "The result is scalar Boolean."
*/
- return glsl_bool_type;
+ return glsl_type::bool_type;
}
ir_rvalue *result = NULL;
ir_rvalue *op[2];
struct simple_node op_list;
- const struct glsl_type *type = glsl_error_type;
+ const struct glsl_type *type = glsl_type::error_type;
bool error_emitted = false;
YYLTYPE loc;
if (!op[0]->is_lvalue()) {
_mesa_glsl_error(& loc, state, "non-lvalue in assignment");
error_emitted = true;
- type = glsl_error_type;
+ type = glsl_type::error_type;
}
}
ir_instruction *rhs = validate_assignment(op[0]->type, op[1]);
if (rhs == NULL) {
- type = glsl_error_type;
+ type = glsl_type::error_type;
rhs = op[1];
}
if (!op[0]->is_lvalue()) {
_mesa_glsl_error(& loc, state, "non-lvalue in assignment");
error_emitted = true;
- type = glsl_error_type;
+ type = glsl_type::error_type;
}
}
ir_rvalue *rhs = validate_assignment(op[0]->type, temp_rhs);
if (rhs == NULL) {
- type = glsl_error_type;
+ type = glsl_type::error_type;
rhs = temp_rhs;
}
}
case ast_int_constant:
- type = glsl_int_type;
+ type = glsl_type::int_type;
result = new ir_constant(type, & this->primary_expression);
break;
case ast_uint_constant:
- type = glsl_uint_type;
+ type = glsl_type::uint_type;
result = new ir_constant(type, & this->primary_expression);
break;
case ast_float_constant:
- type = glsl_float_type;
+ type = glsl_type::float_type;
result = new ir_constant(type, & this->primary_expression);
break;
case ast_bool_constant:
- type = glsl_bool_type;
+ type = glsl_type::bool_type;
result = new ir_constant(type, & this->primary_expression);
break;
this->identifier);
}
- type = glsl_error_type;
+ type = glsl_type::error_type;
}
ir_variable *var = new ir_variable(type, this->identifier);
#define Elements(x) (sizeof(x)/sizeof(*(x)))
#endif
-static const struct glsl_type error_type =
+static const struct glsl_type _error_type =
glsl_type(GLSL_TYPE_ERROR, 0, 0, "");
static const struct glsl_type void_type =
glsl_type(GLSL_TYPE_VOID, 0, 0, "void");
-const struct glsl_type *const glsl_error_type = & error_type;
+const glsl_type *const glsl_type::error_type = & _error_type;
EOF
gen_footer
echo
-echo 'const struct glsl_type *const glsl_bool_type = & builtin_core_types['$bool_index'];'
-echo 'const struct glsl_type *const glsl_int_type = & builtin_core_types['$int_index'];'
-echo 'const struct glsl_type *const glsl_float_type = & builtin_core_types['$float_index'];'
+echo 'const glsl_type *const glsl_type::bool_type = & builtin_core_types['$bool_index'];'
+echo 'const glsl_type *const glsl_type::int_type = & builtin_core_types['$int_index'];'
+echo 'const glsl_type *const glsl_type::float_type = & builtin_core_types['$float_index'];'
echo 'const glsl_type *const glsl_type::mat2_type = & builtin_core_types['$(($matX_index + 0))'];'
echo 'const glsl_type *const glsl_type::mat3_type = & builtin_core_types['$(($matX_index + 1))'];'
echo 'const glsl_type *const glsl_type::mat4_type = & builtin_core_types['$(($matX_index + 2))'];'
gen_footer
echo ''
-echo 'const struct glsl_type *const glsl_uint_type = & builtin_130_types['$uint_index'];'
+echo 'const glsl_type *const glsl_type::uint_type = & builtin_130_types['$uint_index'];'
echo '/*@}*/'
echo
{
switch (base_type) {
case GLSL_TYPE_UINT:
- return glsl_uint_type;
+ return uint_type;
case GLSL_TYPE_INT:
- return glsl_int_type;
+ return int_type;
case GLSL_TYPE_FLOAT:
- return glsl_float_type;
+ return float_type;
case GLSL_TYPE_BOOL:
- return glsl_bool_type;
+ return bool_type;
default:
- return glsl_error_type;
+ return error_type;
}
}
instructions->push_tail(inst);
const float z = 0.0f;
- ir_constant *const zero = new ir_constant(glsl_float_type, &z);
+ ir_constant *const zero = new ir_constant(glsl_type::float_type, &z);
for (unsigned i = 1; i < column_type->vector_elements; i++) {
ir_dereference *const lhs_ref = new ir_dereference(column);
swiz[5 - i], swiz[6 - i],
column_type->vector_elements);
- ir_constant *const idx = new ir_constant(glsl_int_type, &i);
+ ir_constant *const idx = new ir_constant(glsl_type::int_type, &i);
ir_dereference *const lhs = new ir_dereference(declarations[16], idx);
inst = new ir_assignment(lhs, rhs, NULL);
*/
for (unsigned i = 0; i < column_type->vector_elements; i++) {
for (unsigned j = 0; j < row_type->vector_elements; j++) {
- ir_constant *row_index = new ir_constant(glsl_int_type, &i);
+ ir_constant *row_index = new ir_constant(glsl_type::int_type, &i);
ir_dereference *const row_access =
new ir_dereference(declarations[16], row_index);
glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns)
{
if ((rows < 1) || (rows > 4) || (columns < 1) || (columns > 4))
- return glsl_error_type;
+ return error_type;
/* Treat GLSL vectors as Nx1 matrices.
if (columns == 1) {
switch (base_type) {
case GLSL_TYPE_UINT:
- return glsl_uint_type + (rows - 1);
+ return uint_type + (rows - 1);
case GLSL_TYPE_INT:
- return glsl_int_type + (rows - 1);
+ return int_type + (rows - 1);
case GLSL_TYPE_FLOAT:
- return glsl_float_type + (rows - 1);
+ return float_type + (rows - 1);
case GLSL_TYPE_BOOL:
- return glsl_bool_type + (rows - 1);
+ return bool_type + (rows - 1);
default:
- return glsl_error_type;
+ return error_type;
}
} else {
if ((base_type != GLSL_TYPE_FLOAT) || (rows == 1))
- return glsl_error_type;
+ return error_type;
/* GLSL matrix types are named mat{COLUMNS}x{ROWS}. Only the following
* combinations are valid:
case IDX(4,2): return mat4x2_type;
case IDX(4,3): return mat4x3_type;
case IDX(4,4): return mat4_type;
- default: return glsl_error_type;
+ default: return error_type;
}
}
assert(!"Should not get here.");
- return glsl_error_type;
+ return error_type;
}
#define GLSL_TYPE_VOID 8
#define GLSL_TYPE_ERROR 9
-extern const struct glsl_type *const glsl_error_type;
-extern const struct glsl_type *const glsl_int_type;
-extern const struct glsl_type *const glsl_uint_type;
-extern const struct glsl_type *const glsl_float_type;
-extern const struct glsl_type *const glsl_bool_type;
-
#define is_numeric_base_type(b) \
(((b) >= GLSL_TYPE_UINT) && ((b) <= GLSL_TYPE_FLOAT))
} fields;
+ /**
+ * \name Pointers to various public type singletons
+ */
+ /*@{*/
+ static const glsl_type *const error_type;
+ static const glsl_type *const int_type;
+ static const glsl_type *const uint_type;
+ static const glsl_type *const float_type;
+ static const glsl_type *const bool_type;
+ /*@}*/
+
+
glsl_type(unsigned base_type, unsigned vector_elements,
unsigned matrix_columns, const char *name) :
base_type(base_type),
* Query the full type of a matrix row
*
* \return
- * If the type is not a matrix, \c glsl_error_type is returned. Otherwise
- * a type matching the rows of the matrix is returned.
+ * If the type is not a matrix, \c glsl_type::error_type is returned.
+ * Otherwise a type matching the rows of the matrix is returned.
*/
const glsl_type *row_type() const
{
return is_matrix()
? get_instance(base_type, matrix_columns, 1)
- : glsl_error_type;
+ : error_type;
}
/**
* Query the full type of a matrix column
*
* \return
- * If the type is not a matrix, \c glsl_error_type is returned. Otherwise
- * a type matching the columns of the matrix is returned.
+ * If the type is not a matrix, \c glsl_type::error_type is returned.
+ * Otherwise a type matching the columns of the matrix is returned.
*/
const glsl_type *column_type() const
{
return is_matrix()
? get_instance(base_type, vector_elements, 1)
- : glsl_error_type;
+ : error_type;
}
private:
/**
- * \name Pointers to various type singletons
+ * \name Pointers to various private type singletons
*/
/*@{*/
static const glsl_type *const mat2_type;
{
this->mode = ir_reference_variable;
this->var = var;
- this->type = (var != NULL) ? var->type : glsl_error_type;
+ this->type = (var != NULL) ? var->type : glsl_type::error_type;
}
: ir_rvalue(), mode(ir_reference_array),
var(var)
{
- this->type = (var != NULL) ? var->type : glsl_error_type;
+ this->type = (var != NULL) ? var->type : glsl_type::error_type;
this->selector.array_index = array_index;
}
{
ir_call *call = new ir_call;
- call->type = glsl_error_type;
+ call->type = glsl_type::error_type;
return call;
}