summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ast_function.cpp11
-rw-r--r--ast_to_hir.cpp8
-rw-r--r--glsl_types.cpp7
3 files changed, 15 insertions, 11 deletions
diff --git a/ast_function.cpp b/ast_function.cpp
index d89266b9cc7..279c45eac0e 100644
--- a/ast_function.cpp
+++ b/ast_function.cpp
@@ -170,8 +170,13 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type)
}
break;
case GLSL_TYPE_BOOL: {
- int z = 0;
- ir_constant *const zero = new ir_constant(src->type, &z);
+ ir_constant *zero = NULL;
+
+ switch (b) {
+ case GLSL_TYPE_UINT: zero = new ir_constant(unsigned(0)); break;
+ case GLSL_TYPE_INT: zero = new ir_constant(int(0)); break;
+ case GLSL_TYPE_FLOAT: zero = new ir_constant(0.0f); break;
+ }
result = new ir_expression(ir_binop_nequal, desired_type, src, zero);
}
@@ -211,7 +216,7 @@ dereference_component(ir_rvalue *src, unsigned component)
*/
const int c = component / src->type->column_type()->vector_elements;
const int r = component % src->type->column_type()->vector_elements;
- ir_constant *const col_index = new ir_constant(glsl_type::int_type, &c);
+ ir_constant *const col_index = new ir_constant(c);
ir_dereference *const col = new ir_dereference_array(src, col_index);
col->type = src->type->column_type();
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index 927a9e4779f..1c0b98b10ca 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -1257,22 +1257,22 @@ ast_expression::hir(exec_list *instructions,
case ast_int_constant:
type = glsl_type::int_type;
- result = new ir_constant(type, & this->primary_expression);
+ result = new ir_constant(this->primary_expression.int_constant);
break;
case ast_uint_constant:
type = glsl_type::uint_type;
- result = new ir_constant(type, & this->primary_expression);
+ result = new ir_constant(this->primary_expression.uint_constant);
break;
case ast_float_constant:
type = glsl_type::float_type;
- result = new ir_constant(type, & this->primary_expression);
+ result = new ir_constant(this->primary_expression.float_constant);
break;
case ast_bool_constant:
type = glsl_type::bool_type;
- result = new ir_constant(type, & this->primary_expression);
+ result = new ir_constant(bool(this->primary_expression.bool_constant));
break;
case ast_sequence: {
diff --git a/glsl_types.cpp b/glsl_types.cpp
index 4b6a61a13c2..290756d453c 100644
--- a/glsl_types.cpp
+++ b/glsl_types.cpp
@@ -359,8 +359,7 @@ generate_mat_body_from_scalar(exec_list *instructions,
inst = new ir_assignment(lhs, rhs, NULL);
instructions->push_tail(inst);
- const float z = 0.0f;
- ir_constant *const zero = new ir_constant(glsl_type::float_type, &z);
+ ir_constant *const zero = new ir_constant(0.0f);
for (unsigned i = 1; i < column_type->vector_elements; i++) {
ir_dereference *const lhs_ref = new ir_dereference_variable(column);
@@ -382,7 +381,7 @@ generate_mat_body_from_scalar(exec_list *instructions,
swiz[5 - i], swiz[6 - i],
column_type->vector_elements);
- ir_constant *const idx = new ir_constant(glsl_type::int_type, &i);
+ ir_constant *const idx = new ir_constant(int(i));
ir_dereference *const lhs =
new ir_dereference_array(declarations[16], idx);
@@ -413,7 +412,7 @@ generate_mat_body_from_N_scalars(exec_list *instructions,
*/
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_type::int_type, &i);
+ ir_constant *row_index = new ir_constant(int(i));
ir_dereference *const row_access =
new ir_dereference_array(declarations[16], row_index);