summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/glsl')
-rw-r--r--src/compiler/glsl/ast_to_hir.cpp103
-rw-r--r--src/compiler/glsl/glsl_parser_extras.cpp2
-rw-r--r--src/compiler/glsl/glsl_parser_extras.h7
-rw-r--r--src/compiler/glsl/program.h5
4 files changed, 42 insertions, 75 deletions
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index a4842400288..9e811661a2e 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -6268,13 +6268,24 @@ ast_process_struct_or_iface_block_members(exec_list *instructions,
decl_list->type->specifier->hir(instructions, state);
- /* Section 10.9 of the GLSL ES 1.00 specification states that
- * embedded structure definitions have been removed from the language.
+ /* Section 4.1.8 (Structures) of the GLSL 1.10 spec says:
+ *
+ * "Anonymous structures are not supported; so embedded structures
+ * must have a declarator. A name given to an embedded struct is
+ * scoped at the same level as the struct it is embedded in."
+ *
+ * The same section of the GLSL 1.20 spec says:
+ *
+ * "Anonymous structures are not supported. Embedded structures are
+ * not supported."
+ *
+ * The GLSL ES 1.00 and 3.00 specs have similar langauge. So, we allow
+ * embedded structures in 1.10 only.
*/
- if (state->es_shader && decl_list->type->specifier->structure != NULL) {
- _mesa_glsl_error(&loc, state, "embedded structure definitions are "
- "not allowed in GLSL ES 1.00");
- }
+ if (state->language_version != 110 &&
+ decl_list->type->specifier->structure != NULL)
+ _mesa_glsl_error(&loc, state,
+ "embedded structure declarations are not allowed");
const glsl_type *decl_type =
decl_list->type->glsl_type(& type_name, state);
@@ -6293,30 +6304,28 @@ ast_process_struct_or_iface_block_members(exec_list *instructions,
*/
assert(decl_type);
- if (is_interface && decl_type->contains_opaque()) {
- _mesa_glsl_error(&loc, state,
- "uniform/buffer in non-default interface block contains "
- "opaque variable");
- }
-
- if (decl_type->contains_atomic()) {
- /* From section 4.1.7.3 of the GLSL 4.40 spec:
- *
- * "Members of structures cannot be declared as atomic counter
- * types."
- */
- _mesa_glsl_error(&loc, state, "atomic counter in structure, "
- "shader storage block or uniform block");
- }
+ if (is_interface) {
+ if (decl_type->contains_opaque()) {
+ _mesa_glsl_error(&loc, state, "uniform/buffer in non-default "
+ "interface block contains opaque variable");
+ }
+ } else {
+ if (decl_type->contains_atomic()) {
+ /* From section 4.1.7.3 of the GLSL 4.40 spec:
+ *
+ * "Members of structures cannot be declared as atomic counter
+ * types."
+ */
+ _mesa_glsl_error(&loc, state, "atomic counter in structure");
+ }
- if (decl_type->contains_image()) {
- /* FINISHME: Same problem as with atomic counters.
- * FINISHME: Request clarification from Khronos and add
- * FINISHME: spec quotation here.
- */
- _mesa_glsl_error(&loc, state,
- "image in structure, shader storage block or "
- "uniform block");
+ if (decl_type->contains_image()) {
+ /* FINISHME: Same problem as with atomic counters.
+ * FINISHME: Request clarification from Khronos and add
+ * FINISHME: spec quotation here.
+ */
+ _mesa_glsl_error(&loc, state, "image in structure");
+ }
}
if (qual->flags.q.explicit_binding) {
@@ -6515,33 +6524,6 @@ ast_struct_specifier::hir(exec_list *instructions,
{
YYLTYPE loc = this->get_location();
- /* Section 4.1.8 (Structures) of the GLSL 1.10 spec says:
- *
- * "Anonymous structures are not supported; so embedded structures must
- * have a declarator. A name given to an embedded struct is scoped at
- * the same level as the struct it is embedded in."
- *
- * The same section of the GLSL 1.20 spec says:
- *
- * "Anonymous structures are not supported. Embedded structures are not
- * supported.
- *
- * struct S { float f; };
- * struct T {
- * S; // Error: anonymous structures disallowed
- * struct { ... }; // Error: embedded structures disallowed
- * S s; // Okay: nested structures with name are allowed
- * };"
- *
- * The GLSL ES 1.00 and 3.00 specs have similar langauge and examples. So,
- * we allow embedded structures in 1.10 only.
- */
- if (state->language_version != 110 && state->struct_specifier_depth != 0)
- _mesa_glsl_error(&loc, state,
- "embedded structure declarations are not allowed");
-
- state->struct_specifier_depth++;
-
unsigned expl_location = 0;
if (layout && layout->flags.q.explicit_location) {
if (!process_qualifier_constant(state, &loc, "location",
@@ -6584,8 +6566,6 @@ ast_struct_specifier::hir(exec_list *instructions,
}
}
- state->struct_specifier_depth--;
-
/* Structure type definitions do not have r-values.
*/
return NULL;
@@ -6705,11 +6685,6 @@ ast_interface_block::hir(exec_list *instructions,
exec_list declared_variables;
glsl_struct_field *fields;
- /* Treat an interface block as one level of nesting, so that embedded struct
- * specifiers will be disallowed.
- */
- state->struct_specifier_depth++;
-
/* For blocks that accept memory qualifiers (i.e. shader storage), verify
* that we don't have incompatible qualifiers
*/
@@ -6752,8 +6727,6 @@ ast_interface_block::hir(exec_list *instructions,
qual_stream,
expl_location);
- state->struct_specifier_depth--;
-
if (!redeclaring_per_vertex) {
validate_identifier(this->block_name, loc, state);
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 73d378c4bc9..86cf091b4fe 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -69,8 +69,6 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->error = false;
this->loop_nesting_ast = NULL;
- this->struct_specifier_depth = 0;
-
this->uses_builtin_functions = false;
/* Set default language version and extensions */
diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h
index a905b564787..4dacc2ac62b 100644
--- a/src/compiler/glsl/glsl_parser_extras.h
+++ b/src/compiler/glsl/glsl_parser_extras.h
@@ -290,13 +290,6 @@ struct _mesa_glsl_parse_state {
gl_shader_stage stage;
/**
- * Number of nested struct_specifier levels
- *
- * Outside a struct_specifier, this is zero.
- */
- unsigned struct_specifier_depth;
-
- /**
* Default uniform layout qualifiers tracked during parsing.
* Currently affects uniform blocks and uniform buffer variables in
* those blocks.
diff --git a/src/compiler/glsl/program.h b/src/compiler/glsl/program.h
index 64f54635f62..31bb9aa2435 100644
--- a/src/compiler/glsl/program.h
+++ b/src/compiler/glsl/program.h
@@ -22,12 +22,15 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "main/core.h"
#ifdef __cplusplus
extern "C" {
#endif
+struct gl_context;
+struct gl_shader;
+struct gl_shader_program;
+
extern void
_mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
bool dump_ast, bool dump_hir);