aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-03-28 17:35:36 +0100
committermarha <marha@users.sourceforge.net>2014-03-28 17:35:36 +0100
commitcbfb19790917d271b8ca6156554b16acc802719f (patch)
tree830af0dc6e08b5d0c7124fec143e90255f3feee3 /mesalib/src/glsl
parentd02e6760412c7a96abbc4d0add5dd8d5e83bbe27 (diff)
downloadvcxsrv-cbfb19790917d271b8ca6156554b16acc802719f.tar.gz
vcxsrv-cbfb19790917d271b8ca6156554b16acc802719f.tar.bz2
vcxsrv-cbfb19790917d271b8ca6156554b16acc802719f.zip
libxtrans fontconfig mesa xserver git update 28 Mar 2014
xserver commit a2880699e8f1f576e1a48ebf25e8982463323f84 libxtrans commit 68f60238c4224f954ff6556ae778c72e420175f0 fontconfig commit fcba9ef01c978323fc71c17e455d3cd6ae35edcc mesa commit 029ccd773d01a5f801c809c499516d7b0c4cc3f8
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r--mesalib/src/glsl/glsl_parser.yy1
-rw-r--r--mesalib/src/glsl/glsl_symbol_table.cpp25
-rw-r--r--mesalib/src/glsl/glsl_symbol_table.h2
-rw-r--r--mesalib/src/glsl/ir.h36
-rw-r--r--mesalib/src/glsl/ir_clone.cpp10
-rw-r--r--mesalib/src/glsl/ir_constant_expression.cpp205
6 files changed, 110 insertions, 169 deletions
diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy
index faaf4388c..2d0e7be54 100644
--- a/mesalib/src/glsl/glsl_parser.yy
+++ b/mesalib/src/glsl/glsl_parser.yy
@@ -1901,7 +1901,6 @@ struct_specifier:
$$ = new(ctx) ast_struct_specifier($2, $4);
$$->set_location_range(@2, @5);
state->symbols->add_type($2, glsl_type::void_type);
- state->symbols->add_type_ast($2, new(ctx) ast_type_specifier($$));
}
| STRUCT '{' struct_declaration_list '}'
{
diff --git a/mesalib/src/glsl/glsl_symbol_table.cpp b/mesalib/src/glsl/glsl_symbol_table.cpp
index 11569f47e..a05236203 100644
--- a/mesalib/src/glsl/glsl_symbol_table.cpp
+++ b/mesalib/src/glsl/glsl_symbol_table.cpp
@@ -162,23 +162,6 @@ bool glsl_symbol_table::add_type(const char *name, const glsl_type *t)
return _mesa_symbol_table_add_symbol(table, -1, name, entry) == 0;
}
-static char *make_ast_name(const char *name)
-{
- char *ast_name = new char[strlen("#ast.") + strlen(name) + 1];
- strcpy(ast_name, "#ast.");
- strcat(ast_name + strlen("#ast."), name);
- return ast_name;
-}
-
-bool glsl_symbol_table::add_type_ast(const char *name, const class ast_type_specifier *a)
-{
- symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(a);
- char *ast_name = make_ast_name(name);
- bool ret = _mesa_symbol_table_add_symbol(table, -1, ast_name, entry) == 0;
- delete [] ast_name;
- return ret;
-}
-
bool glsl_symbol_table::add_interface(const char *name, const glsl_type *i,
enum ir_variable_mode mode)
{
@@ -230,14 +213,6 @@ const glsl_type *glsl_symbol_table::get_type(const char *name)
return entry != NULL ? entry->t : NULL;
}
-const class ast_type_specifier *glsl_symbol_table::get_type_ast(const char *name)
-{
- char *ast_name = make_ast_name(name);
- symbol_table_entry *entry = get_entry(ast_name);
- delete [] ast_name;
- return entry != NULL ? entry->a : NULL;
-}
-
const glsl_type *glsl_symbol_table::get_interface(const char *name,
enum ir_variable_mode mode)
{
diff --git a/mesalib/src/glsl/glsl_symbol_table.h b/mesalib/src/glsl/glsl_symbol_table.h
index 0e62448e2..f323fc305 100644
--- a/mesalib/src/glsl/glsl_symbol_table.h
+++ b/mesalib/src/glsl/glsl_symbol_table.h
@@ -98,7 +98,6 @@ public:
/*@{*/
bool add_variable(ir_variable *v);
bool add_type(const char *name, const glsl_type *t);
- bool add_type_ast(const char *name, const class ast_type_specifier *t);
bool add_function(ir_function *f);
bool add_interface(const char *name, const glsl_type *i,
enum ir_variable_mode mode);
@@ -115,7 +114,6 @@ public:
/*@{*/
ir_variable *get_variable(const char *name);
const glsl_type *get_type(const char *name);
- const class ast_type_specifier *get_type_ast(const char *name);
ir_function *get_function(const char *name);
const glsl_type *get_interface(const char *name,
enum ir_variable_mode mode);
diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h
index ed3f086ce..8fa3b9ef6 100644
--- a/mesalib/src/glsl/ir.h
+++ b/mesalib/src/glsl/ir.h
@@ -1914,15 +1914,6 @@ public:
* Get the variable that is ultimately referenced by an r-value
*/
virtual ir_variable *variable_referenced() const = 0;
-
- /**
- * Get the constant that is ultimately referenced by an r-value,
- * in a constant expression evaluation context.
- *
- * The offset is used when the reference is to a specific column of
- * a matrix.
- */
- virtual void constant_referenced(struct hash_table *variable_context, ir_constant *&store, int &offset) const = 0;
};
@@ -1950,15 +1941,6 @@ public:
return this->var;
}
- /**
- * Get the constant that is ultimately referenced by an r-value,
- * in a constant expression evaluation context.
- *
- * The offset is used when the reference is to a specific column of
- * a matrix.
- */
- virtual void constant_referenced(struct hash_table *variable_context, ir_constant *&store, int &offset) const;
-
virtual ir_variable *whole_variable_referenced()
{
/* ir_dereference_variable objects always dereference the entire
@@ -2010,15 +1992,6 @@ public:
return this->array->variable_referenced();
}
- /**
- * Get the constant that is ultimately referenced by an r-value,
- * in a constant expression evaluation context.
- *
- * The offset is used when the reference is to a specific column of
- * a matrix.
- */
- virtual void constant_referenced(struct hash_table *variable_context, ir_constant *&store, int &offset) const;
-
virtual void accept(ir_visitor *v)
{
v->visit(this);
@@ -2058,15 +2031,6 @@ public:
return this->record->variable_referenced();
}
- /**
- * Get the constant that is ultimately referenced by an r-value,
- * in a constant expression evaluation context.
- *
- * The offset is used when the reference is to a specific column of
- * a matrix.
- */
- virtual void constant_referenced(struct hash_table *variable_context, ir_constant *&store, int &offset) const;
-
virtual void accept(ir_visitor *v)
{
v->visit(this);
diff --git a/mesalib/src/glsl/ir_clone.cpp b/mesalib/src/glsl/ir_clone.cpp
index 311c992be..167b80c9f 100644
--- a/mesalib/src/glsl/ir_clone.cpp
+++ b/mesalib/src/glsl/ir_clone.cpp
@@ -265,10 +265,12 @@ ir_assignment::clone(void *mem_ctx, struct hash_table *ht) const
if (this->condition)
new_condition = this->condition->clone(mem_ctx, ht);
- return new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht),
- this->rhs->clone(mem_ctx, ht),
- new_condition,
- this->write_mask);
+ ir_assignment *cloned =
+ new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht),
+ this->rhs->clone(mem_ctx, ht),
+ new_condition);
+ cloned->write_mask = this->write_mask;
+ return cloned;
}
ir_function *
diff --git a/mesalib/src/glsl/ir_constant_expression.cpp b/mesalib/src/glsl/ir_constant_expression.cpp
index 7fa5a09d4..8afe8f776 100644
--- a/mesalib/src/glsl/ir_constant_expression.cpp
+++ b/mesalib/src/glsl/ir_constant_expression.cpp
@@ -386,8 +386,104 @@ unpack_half_1x16(uint16_t u)
return _mesa_half_to_float(u);
}
+/**
+ * Get the constant that is ultimately referenced by an r-value, in a constant
+ * expression evaluation context.
+ *
+ * The offset is used when the reference is to a specific column of a matrix.
+ */
+static bool
+constant_referenced(const ir_dereference *deref,
+ struct hash_table *variable_context,
+ ir_constant *&store, int &offset)
+{
+ store = NULL;
+ offset = 0;
+
+ if (variable_context == NULL)
+ return false;
+
+ switch (deref->ir_type) {
+ case ir_type_dereference_array: {
+ const ir_dereference_array *const da =
+ (const ir_dereference_array *) deref;
+
+ ir_constant *const index_c =
+ da->array_index->constant_expression_value(variable_context);
+
+ if (!index_c || !index_c->type->is_scalar() || !index_c->type->is_integer())
+ break;
+
+ const int index = index_c->type->base_type == GLSL_TYPE_INT ?
+ index_c->get_int_component(0) :
+ index_c->get_uint_component(0);
+
+ ir_constant *substore;
+ int suboffset;
+
+ const ir_dereference *const deref = da->array->as_dereference();
+ if (!deref)
+ break;
+
+ if (!constant_referenced(deref, variable_context, substore, suboffset))
+ break;
+
+ const glsl_type *const vt = da->array->type;
+ if (vt->is_array()) {
+ store = substore->get_array_element(index);
+ offset = 0;
+ } else if (vt->is_matrix()) {
+ store = substore;
+ offset = index * vt->vector_elements;
+ } else if (vt->is_vector()) {
+ store = substore;
+ offset = suboffset + index;
+ }
+
+ break;
+ }
+
+ case ir_type_dereference_record: {
+ const ir_dereference_record *const dr =
+ (const ir_dereference_record *) deref;
+
+ const ir_dereference *const deref = dr->record->as_dereference();
+ if (!deref)
+ break;
+
+ ir_constant *substore;
+ int suboffset;
+
+ if (!constant_referenced(deref, variable_context, substore, suboffset))
+ break;
+
+ /* Since we're dropping it on the floor...
+ */
+ assert(suboffset == 0);
+
+ store = substore->get_record_field(dr->field);
+ break;
+ }
+
+ case ir_type_dereference_variable: {
+ const ir_dereference_variable *const dv =
+ (const ir_dereference_variable *) deref;
+
+ store = (ir_constant *) hash_table_find(variable_context, dv->var);
+ break;
+ }
+
+ default:
+ assert(!"Should not get here.");
+ break;
+ }
+
+ return store != NULL;
+}
+
+
ir_constant *
-ir_rvalue::constant_expression_value(struct hash_table *variable_context)
+ir_rvalue::constant_expression_value(struct hash_table *)
{
assert(this->type->is_error());
return NULL;
@@ -1534,7 +1630,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
ir_constant *
-ir_texture::constant_expression_value(struct hash_table *variable_context)
+ir_texture::constant_expression_value(struct hash_table *)
{
/* texture lookups aren't constant expressions */
return NULL;
@@ -1570,19 +1666,6 @@ ir_swizzle::constant_expression_value(struct hash_table *variable_context)
}
-void
-ir_dereference_variable::constant_referenced(struct hash_table *variable_context,
- ir_constant *&store, int &offset) const
-{
- if (variable_context) {
- store = (ir_constant *)hash_table_find(variable_context, var);
- offset = 0;
- } else {
- store = NULL;
- offset = 0;
- }
-}
-
ir_constant *
ir_dereference_variable::constant_expression_value(struct hash_table *variable_context)
{
@@ -1610,60 +1693,6 @@ ir_dereference_variable::constant_expression_value(struct hash_table *variable_c
}
-void
-ir_dereference_array::constant_referenced(struct hash_table *variable_context,
- ir_constant *&store, int &offset) const
-{
- ir_constant *index_c = array_index->constant_expression_value(variable_context);
-
- if (!index_c || !index_c->type->is_scalar() || !index_c->type->is_integer()) {
- store = 0;
- offset = 0;
- return;
- }
-
- int index = index_c->type->base_type == GLSL_TYPE_INT ?
- index_c->get_int_component(0) :
- index_c->get_uint_component(0);
-
- ir_constant *substore;
- int suboffset;
- const ir_dereference *deref = array->as_dereference();
- if (!deref) {
- store = 0;
- offset = 0;
- return;
- }
-
- deref->constant_referenced(variable_context, substore, suboffset);
-
- if (!substore) {
- store = 0;
- offset = 0;
- return;
- }
-
- const glsl_type *vt = array->type;
- if (vt->is_array()) {
- store = substore->get_array_element(index);
- offset = 0;
- return;
- }
- if (vt->is_matrix()) {
- store = substore;
- offset = index * vt->vector_elements;
- return;
- }
- if (vt->is_vector()) {
- store = substore;
- offset = suboffset + index;
- return;
- }
-
- store = 0;
- offset = 0;
-}
-
ir_constant *
ir_dereference_array::constant_expression_value(struct hash_table *variable_context)
{
@@ -1719,33 +1748,8 @@ ir_dereference_array::constant_expression_value(struct hash_table *variable_cont
}
-void
-ir_dereference_record::constant_referenced(struct hash_table *variable_context,
- ir_constant *&store, int &offset) const
-{
- ir_constant *substore;
- int suboffset;
- const ir_dereference *deref = record->as_dereference();
- if (!deref) {
- store = 0;
- offset = 0;
- return;
- }
-
- deref->constant_referenced(variable_context, substore, suboffset);
-
- if (!substore) {
- store = 0;
- offset = 0;
- return;
- }
-
- store = substore->get_record_field(field);
- offset = 0;
-}
-
ir_constant *
-ir_dereference_record::constant_expression_value(struct hash_table *variable_context)
+ir_dereference_record::constant_expression_value(struct hash_table *)
{
ir_constant *v = this->record->constant_expression_value();
@@ -1754,7 +1758,7 @@ ir_dereference_record::constant_expression_value(struct hash_table *variable_con
ir_constant *
-ir_assignment::constant_expression_value(struct hash_table *variable_context)
+ir_assignment::constant_expression_value(struct hash_table *)
{
/* FINISHME: Handle CEs involving assignment (return RHS) */
return NULL;
@@ -1762,7 +1766,7 @@ ir_assignment::constant_expression_value(struct hash_table *variable_context)
ir_constant *
-ir_constant::constant_expression_value(struct hash_table *variable_context)
+ir_constant::constant_expression_value(struct hash_table *)
{
return this;
}
@@ -1803,9 +1807,8 @@ bool ir_function_signature::constant_expression_evaluate_expression_list(const s
ir_constant *store = NULL;
int offset = 0;
- asg->lhs->constant_referenced(variable_context, store, offset);
- if (!store)
+ if (!constant_referenced(asg->lhs, variable_context, store, offset))
return false;
ir_constant *value = asg->rhs->constant_expression_value(variable_context);
@@ -1836,9 +1839,9 @@ bool ir_function_signature::constant_expression_evaluate_expression_list(const s
ir_constant *store = NULL;
int offset = 0;
- call->return_deref->constant_referenced(variable_context, store, offset);
- if (!store)
+ if (!constant_referenced(call->return_deref, variable_context,
+ store, offset))
return false;
ir_constant *value = call->constant_expression_value(variable_context);