aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp4
-rw-r--r--mesalib/src/glsl/ir.cpp31
-rw-r--r--mesalib/src/glsl/ir_expression_flattening.cpp5
-rw-r--r--mesalib/src/glsl/linker.cpp8
4 files changed, 27 insertions, 21 deletions
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index 75d7e9d57..ff56e33b7 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -1692,14 +1692,14 @@ ast_expression::hir(exec_list *instructions,
ir_variable *var =
state->symbols->get_variable(this->primary_expression.identifier);
- result = new(ctx) ir_dereference_variable(var);
-
if (var != NULL) {
var->used = true;
+ result = new(ctx) ir_dereference_variable(var);
} else {
_mesa_glsl_error(& loc, state, "`%s' undeclared",
this->primary_expression.identifier);
+ result = ir_call::get_error_instruction(ctx);
error_emitted = true;
}
break;
diff --git a/mesalib/src/glsl/ir.cpp b/mesalib/src/glsl/ir.cpp
index a5eca5a51..3c9d6e174 100644
--- a/mesalib/src/glsl/ir.cpp
+++ b/mesalib/src/glsl/ir.cpp
@@ -1026,9 +1026,11 @@ ir_loop::ir_loop()
ir_dereference_variable::ir_dereference_variable(ir_variable *var)
{
+ assert(var != NULL);
+
this->ir_type = ir_type_dereference_variable;
this->var = var;
- this->type = (var != NULL) ? var->type : glsl_type::error_type;
+ this->type = var->type;
}
@@ -1055,19 +1057,18 @@ ir_dereference_array::ir_dereference_array(ir_variable *var,
void
ir_dereference_array::set_array(ir_rvalue *value)
{
+ assert(value != NULL);
+
this->array = value;
- this->type = glsl_type::error_type;
- if (this->array != NULL) {
- const glsl_type *const vt = this->array->type;
+ const glsl_type *const vt = this->array->type;
- if (vt->is_array()) {
- type = vt->element_type();
- } else if (vt->is_matrix()) {
- type = vt->column_type();
- } else if (vt->is_vector()) {
- type = vt->get_base_type();
- }
+ if (vt->is_array()) {
+ type = vt->element_type();
+ } else if (vt->is_matrix()) {
+ type = vt->column_type();
+ } else if (vt->is_vector()) {
+ type = vt->get_base_type();
}
}
@@ -1075,11 +1076,12 @@ ir_dereference_array::set_array(ir_rvalue *value)
ir_dereference_record::ir_dereference_record(ir_rvalue *value,
const char *field)
{
+ assert(value != NULL);
+
this->ir_type = ir_type_dereference_record;
this->record = value;
this->field = ralloc_strdup(this, field);
- this->type = (this->record != NULL)
- ? this->record->type->field_type(field) : glsl_type::error_type;
+ this->type = this->record->type->field_type(field);
}
@@ -1091,8 +1093,7 @@ ir_dereference_record::ir_dereference_record(ir_variable *var,
this->ir_type = ir_type_dereference_record;
this->record = new(ctx) ir_dereference_variable(var);
this->field = ralloc_strdup(this, field);
- this->type = (this->record != NULL)
- ? this->record->type->field_type(field) : glsl_type::error_type;
+ this->type = this->record->type->field_type(field);
}
bool
diff --git a/mesalib/src/glsl/ir_expression_flattening.cpp b/mesalib/src/glsl/ir_expression_flattening.cpp
index 0b7c537bd..bd4ac67bc 100644
--- a/mesalib/src/glsl/ir_expression_flattening.cpp
+++ b/mesalib/src/glsl/ir_expression_flattening.cpp
@@ -27,7 +27,10 @@
* Takes the leaves of expression trees and makes them dereferences of
* assignments of the leaves to temporaries, according to a predicate.
*
- * This is used for automatic function inlining, where we want to take
+ * This is used for breaking down matrix operations, where it's easier to
+ * create a temporary and work on each of its vector components individually.
+ *
+ * It is also used for automatic function inlining, where we want to take
* an expression containing a call and move the call out to its own
* assignment so that we can inline it at the appropriate place in the
* instruction stream.
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 8278e43ad..09ffdff63 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -1319,9 +1319,11 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
* attribute overlaps any previously allocated bits.
*/
if ((~(use_mask << attr) & used_locations) != used_locations) {
+ const char *const string = (target_index == MESA_SHADER_VERTEX)
+ ? "vertex shader input" : "fragment shader output";
linker_error(prog,
- "insufficient contiguous attribute locations "
- "available for vertex shader input `%s'",
+ "insufficient contiguous locations "
+ "available for %s `%s'", string,
var->name);
return false;
}
@@ -1370,7 +1372,7 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
? "vertex shader input" : "fragment shader output";
linker_error(prog,
- "insufficient contiguous attribute locations "
+ "insufficient contiguous locations "
"available for %s `%s'",
string, to_assign[i].var->name);
return false;