summaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_parser_extras.h
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2013-09-25 14:36:27 -0700
committerIan Romanick <ian.d.romanick@intel.com>2013-10-30 13:49:30 -0700
commit5cb80f03142ddcc949f4d208594004cc2bcc4140 (patch)
tree9a1c46daf1808acf5a4140a1445ba568b93e8bad /src/glsl/glsl_parser_extras.h
parent9d6294f5a2337c5aa975c8ac65f775467b51043d (diff)
downloadexternal_mesa3d-5cb80f03142ddcc949f4d208594004cc2bcc4140.zip
external_mesa3d-5cb80f03142ddcc949f4d208594004cc2bcc4140.tar.gz
external_mesa3d-5cb80f03142ddcc949f4d208594004cc2bcc4140.tar.bz2
glsl: Move layout(location) checks to AST-to-HIR conversion
This will simplify the addition of layout(location) qualifiers for separate shader objects. This was validated with new piglit tests arb_explicit_attrib_location/1.30/compiler/not-enabled-01.vert and arb_explicit_attrib_location/1.30/compiler/not-enabled-02.vert. v2: Refactor error checking to check_explicit_attrib_location_allowed and eliminate the gotos. Suggested by Paul. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Paul Berry <stereotype441@gmail.com>
Diffstat (limited to 'src/glsl/glsl_parser_extras.h')
-rw-r--r--src/glsl/glsl_parser_extras.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index f3560c3..f22dac3 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -69,6 +69,10 @@ typedef struct YYLTYPE {
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
+extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
+ const char *fmt, ...);
+
+
struct _mesa_glsl_parse_state {
_mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target,
void *mem_ctx);
@@ -121,6 +125,22 @@ struct _mesa_glsl_parse_state {
return check_version(130, 300, locp, "bit-wise operations are forbidden");
}
+ bool check_explicit_attrib_location_allowed(YYLTYPE *locp,
+ const ir_variable *var)
+ {
+ if (!this->has_explicit_attrib_location()) {
+ const char *const requirement = this->es_shader
+ ? "GLSL ES 300"
+ : "GL_ARB_explicit_attrib_location extension or GLSL 330";
+
+ _mesa_glsl_error(locp, this, "%s explicit location requires %s",
+ mode_string(var), requirement);
+ return false;
+ }
+
+ return true;
+ }
+
bool has_explicit_attrib_location() const
{
return ARB_explicit_attrib_location_enable || is_version(330, 300);
@@ -372,9 +392,6 @@ do { \
(Current).source = 0; \
} while (0)
-extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
- const char *fmt, ...);
-
/**
* Emit a warning to the shader log
*