aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r--mesalib/src/glsl/Makefile.am5
-rw-r--r--mesalib/src/glsl/ast_function.cpp4
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp46
-rw-r--r--mesalib/src/glsl/glcpp/Makefile.am2
-rw-r--r--mesalib/src/glsl/glsl_symbol_table.cpp14
-rw-r--r--mesalib/src/glsl/glsl_symbol_table.h1
-rw-r--r--mesalib/src/glsl/ir_clone.cpp4
-rw-r--r--mesalib/src/glsl/link_uniforms.cpp7
-rw-r--r--mesalib/src/glsl/linker.cpp4
9 files changed, 59 insertions, 28 deletions
diff --git a/mesalib/src/glsl/Makefile.am b/mesalib/src/glsl/Makefile.am
index 0f545d548..36af90ef1 100644
--- a/mesalib/src/glsl/Makefile.am
+++ b/mesalib/src/glsl/Makefile.am
@@ -25,9 +25,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/mapi \
-I$(top_srcdir)/src/mesa/ \
- $(LIBRARY_INCLUDES) \
$(DEFINES) \
- $(LIBRARY_DEFINES) \
$(API_DEFINES)
AM_CFLAGS = $(VISIBILITY_CFLAGS)
AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS)
@@ -37,7 +35,8 @@ AM_LFLAGS = --nounistd -o$(LEX_OUTPUT_ROOT).c
include Makefile.sources
noinst_LTLIBRARIES = libglsl.la
-noinst_PROGRAMS = glsl_compiler glsl_test
+check_PROGRAMS = glsl_test
+noinst_PROGRAMS = glsl_compiler
libglsl_la_SOURCES = \
glsl_lexer.ll \
diff --git a/mesalib/src/glsl/ast_function.cpp b/mesalib/src/glsl/ast_function.cpp
index b56a3c723..dc7a58bf2 100644
--- a/mesalib/src/glsl/ast_function.cpp
+++ b/mesalib/src/glsl/ast_function.cpp
@@ -183,7 +183,7 @@ verify_parameter_modes(_mesa_glsl_parse_state *state,
*/
static ir_rvalue *
generate_call(exec_list *instructions, ir_function_signature *sig,
- YYLTYPE *loc, exec_list *actual_parameters,
+ exec_list *actual_parameters,
ir_call **call_ir,
struct _mesa_glsl_parse_state *state)
{
@@ -1501,7 +1501,7 @@ ast_function_expression::hir(exec_list *instructions,
/* an error has already been emitted */
value = ir_rvalue::error_value(ctx);
} else {
- value = generate_call(instructions, sig, &loc, &actual_parameters,
+ value = generate_call(instructions, sig, &actual_parameters,
&call, state);
}
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index f934c8e2d..de3ce902e 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -1933,6 +1933,31 @@ is_varying_var(ir_variable *var, _mesa_glsl_parser_targets target)
}
+/**
+ * Matrix layout qualifiers are only allowed on certain types
+ */
+static void
+validate_matrix_layout_for_type(struct _mesa_glsl_parse_state *state,
+ YYLTYPE *loc,
+ const glsl_type *type)
+{
+ if (!type->is_matrix() && !type->is_record()) {
+ _mesa_glsl_error(loc, state,
+ "uniform block layout qualifiers row_major and "
+ "column_major can only be applied to matrix and "
+ "structure types");
+ } else if (type->is_record()) {
+ /* We allow 'layout(row_major)' on structure types because it's the only
+ * way to get row-major layouts on matrices contained in structures.
+ */
+ _mesa_glsl_warning(loc, state,
+ "uniform block layout qualifiers row_major and "
+ "column_major applied to structure types is not "
+ "strictly conformant and my be rejected by other "
+ "compilers");
+ }
+}
+
static void
apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
ir_variable *var,
@@ -2251,12 +2276,14 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
"members");
}
- if (!ubo_qualifiers_valid &&
- (qual->flags.q.row_major || qual->flags.q.column_major)) {
- _mesa_glsl_error(loc, state,
- "uniform block layout qualifiers row_major and "
- "column_major can only be applied to uniform block "
- "members");
+ if (qual->flags.q.row_major || qual->flags.q.column_major) {
+ if (!ubo_qualifiers_valid) {
+ _mesa_glsl_error(loc, state,
+ "uniform block layout qualifiers row_major and "
+ "column_major can only be applied to uniform block "
+ "members");
+ } else
+ validate_matrix_layout_for_type(state, loc, var->type);
}
}
@@ -4105,6 +4132,12 @@ ast_uniform_block::hir(exec_list *instructions,
struct gl_uniform_block *ubo = get_next_uniform_block(state);
ubo->Name = ralloc_strdup(state->uniform_blocks, this->block_name);
+ if (!state->symbols->add_uniform_block(ubo)) {
+ YYLTYPE loc = this->get_location();
+ _mesa_glsl_error(&loc, state, "Uniform block name `%s' already taken in "
+ "the current scope.\n", ubo->Name);
+ }
+
unsigned int num_variables = 0;
foreach_list_typed(ast_declarator_list, decl_list, link, &declarations) {
foreach_list_const(node, &decl_list->declarations) {
@@ -4133,7 +4166,6 @@ ast_uniform_block::hir(exec_list *instructions,
ubo_var->Name = ralloc_strdup(state->uniform_blocks, var->name);
ubo_var->Type = var->type;
- ubo_var->Buffer = ubo - state->uniform_blocks;
ubo_var->Offset = 0; /* Assigned at link time. */
if (var->type->is_matrix() ||
diff --git a/mesalib/src/glsl/glcpp/Makefile.am b/mesalib/src/glsl/glcpp/Makefile.am
index 1efc9dc1a..d79f8653c 100644
--- a/mesalib/src/glsl/glcpp/Makefile.am
+++ b/mesalib/src/glsl/glcpp/Makefile.am
@@ -29,9 +29,7 @@ AM_CFLAGS = \
-I$(top_srcdir)/src/mapi \
-I$(top_srcdir)/src/mesa/ \
$(VISIBILITY_CFLAGS) \
- $(LIBRARY_INCLUDES) \
$(DEFINES) \
- $(LIBRARY_DEFINES) \
$(API_DEFINES)
AM_YFLAGS = -v -d -p "glcpp_parser_"
diff --git a/mesalib/src/glsl/glsl_symbol_table.cpp b/mesalib/src/glsl/glsl_symbol_table.cpp
index f934ea865..eb275b12e 100644
--- a/mesalib/src/glsl/glsl_symbol_table.cpp
+++ b/mesalib/src/glsl/glsl_symbol_table.cpp
@@ -41,13 +41,15 @@ public:
ralloc_free(entry);
}
- symbol_table_entry(ir_variable *v) : v(v), f(0), t(0) {}
- symbol_table_entry(ir_function *f) : v(0), f(f), t(0) {}
- symbol_table_entry(const glsl_type *t) : v(0), f(0), t(t) {}
+ symbol_table_entry(ir_variable *v) : v(v), f(0), t(0), u(0) {}
+ symbol_table_entry(ir_function *f) : v(0), f(f), t(0), u(0) {}
+ symbol_table_entry(const glsl_type *t) : v(0), f(0), t(t), u(0) {}
+ symbol_table_entry(struct gl_uniform_block *u) : v(0), f(0), t(0), u(u) {}
ir_variable *v;
ir_function *f;
const glsl_type *t;
+ struct gl_uniform_block *u;
};
glsl_symbol_table::glsl_symbol_table()
@@ -132,6 +134,12 @@ bool glsl_symbol_table::add_function(ir_function *f)
return _mesa_symbol_table_add_symbol(table, -1, f->name, entry) == 0;
}
+bool glsl_symbol_table::add_uniform_block(struct gl_uniform_block *u)
+{
+ symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(u);
+ return _mesa_symbol_table_add_symbol(table, -1, u->Name, entry) == 0;
+}
+
void glsl_symbol_table::add_global_function(ir_function *f)
{
symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(f);
diff --git a/mesalib/src/glsl/glsl_symbol_table.h b/mesalib/src/glsl/glsl_symbol_table.h
index 9f5602787..f95fb8a01 100644
--- a/mesalib/src/glsl/glsl_symbol_table.h
+++ b/mesalib/src/glsl/glsl_symbol_table.h
@@ -99,6 +99,7 @@ public:
bool add_variable(ir_variable *v);
bool add_type(const char *name, const glsl_type *t);
bool add_function(ir_function *f);
+ bool add_uniform_block(struct gl_uniform_block *u);
/*@}*/
/**
diff --git a/mesalib/src/glsl/ir_clone.cpp b/mesalib/src/glsl/ir_clone.cpp
index 4314efa76..c62c1fc20 100644
--- a/mesalib/src/glsl/ir_clone.cpp
+++ b/mesalib/src/glsl/ir_clone.cpp
@@ -36,10 +36,6 @@ ir_rvalue::clone(void *mem_ctx, struct hash_table *ht) const
/**
* Duplicate an IR variable
- *
- * \note
- * This will probably be made \c virtual and moved to the base class
- * eventually.
*/
ir_variable *
ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index aa8a8b3fb..07d9c18de 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/src/glsl/link_uniforms.cpp
@@ -452,7 +452,7 @@ link_cross_validate_uniform_block(void *mem_ctx,
* would point at the uniform block list in one of the pre-linked
* shaders).
*/
-static bool
+static void
link_update_uniform_buffer_variables(struct gl_shader *shader)
{
foreach_list(node, shader->ir) {
@@ -478,8 +478,6 @@ link_update_uniform_buffer_variables(struct gl_shader *shader)
}
assert(found);
}
-
- return true;
}
void
@@ -544,8 +542,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
if (prog->_LinkedShaders[i] == NULL)
continue;
- if (!link_update_uniform_buffer_variables(prog->_LinkedShaders[i]))
- return;
+ link_update_uniform_buffer_variables(prog->_LinkedShaders[i]);
}
/* First pass: Count the uniform resources used by the user-defined
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 70f3d5bed..63548e071 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -885,8 +885,8 @@ link_intrastage_shaders(void *mem_ctx,
for (unsigned i = 0; i < num_shaders; i++) {
struct gl_shader *sh = shader_list[i];
- for (unsigned j = 0; j < shader_list[i]->NumUniformBlocks; j++) {
- link_assign_uniform_block_offsets(shader_list[i]);
+ for (unsigned j = 0; j < sh->NumUniformBlocks; j++) {
+ link_assign_uniform_block_offsets(sh);
int index = link_cross_validate_uniform_block(mem_ctx,
&uniform_blocks,