[Mesa-dev] [PATCH 23/25] glsl: Allow arrays of arrays in GLSL ES 3.10 and GLSL 4.30
Timothy Arceri
t_arceri at yahoo.com.au
Wed Aug 19 21:37:31 PDT 2015
V2: add missing 's' to the extension name in error messages
and add decimal place in version string
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
src/glsl/ast_to_hir.cpp | 13 ++++++++-----
src/glsl/glsl_parser.yy | 22 ++++++++++++++--------
src/glsl/glsl_parser_extras.h | 5 +++++
3 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index c8e695a..78e22cc 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1996,12 +1996,15 @@ process_array_type(YYLTYPE *loc, const glsl_type *base,
*
* "Only one-dimensional arrays may be declared."
*/
- if (!state->ARB_arrays_of_arrays_enable) {
+ if (!state->has_arrays_of_arrays()) {
+ const char *const requirement = state->es_shader
+ ? "GLSL ES 3.10"
+ : "GL_ARB_arrays_of_arrays or GLSL 4.30";
_mesa_glsl_error(loc, state,
- "invalid array of `%s'"
- "GL_ARB_arrays_of_arrays "
- "required for defining arrays of arrays",
- base->name);
+ "invalid array of `%s' "
+ "%s required for defining arrays of arrays",
+ base->name, requirement);
+
return glsl_type::error_type;
}
}
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 72606d2..396088f 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1965,10 +1965,13 @@ array_specifier:
void *ctx = state;
$$ = $1;
- if (!state->ARB_arrays_of_arrays_enable) {
- _mesa_glsl_error(& @1, state,
- "GL_ARB_arrays_of_arrays "
- "required for defining arrays of arrays");
+ if (!state->has_arrays_of_arrays()) {
+ const char *const requirement = state->es_shader
+ ? "GLSL ES 3.10"
+ : "GL_ARB_arrays_of_arrays or GLSL 4.30";
+ _mesa_glsl_error(& @1, state,
+ "%s required for defining arrays of arrays.",
+ requirement);
}
$$->add_dimension(new(ctx) ast_expression(ast_unsized_array_dim, NULL,
NULL, NULL));
@@ -1977,10 +1980,13 @@ array_specifier:
{
$$ = $1;
- if (!state->ARB_arrays_of_arrays_enable) {
- _mesa_glsl_error(& @1, state,
- "GL_ARB_arrays_of_arrays "
- "required for defining arrays of arrays");
+ if (!state->has_arrays_of_arrays()) {
+ const char *const requirement = state->es_shader
+ ? "GLSL ES 3.10"
+ : "GL_ARB_arrays_of_arrays or GLSL 4.30";
+ _mesa_glsl_error(& @1, state,
+ "%s required for defining arrays of arrays.",
+ requirement);
}
$$->add_dimension($3);
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 57a7555..91f8c95 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -190,6 +190,11 @@ struct _mesa_glsl_parse_state {
return true;
}
+ bool has_arrays_of_arrays() const
+ {
+ return ARB_arrays_of_arrays_enable || is_version(430, 310);
+ }
+
bool has_atomic_counters() const
{
return ARB_shader_atomic_counters_enable || is_version(420, 310);
--
2.4.3
More information about the mesa-dev
mailing list