summaryrefslogtreecommitdiffstats
path: root/src/glsl/glcpp
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2014-01-26 18:06:18 -0800
committerMatt Turner <mattst88@gmail.com>2014-01-27 21:15:35 -0800
commitc59a605c70752b584a05bc6f129a1aa894c861ce (patch)
treec45e47947a49927eafea71be8dd98bb77eaf3e8a /src/glsl/glcpp
parent3e0e9e3bf9e597eb74b06381b3418c958be4d452 (diff)
downloadexternal_mesa3d-c59a605c70752b584a05bc6f129a1aa894c861ce.zip
external_mesa3d-c59a605c70752b584a05bc6f129a1aa894c861ce.tar.gz
external_mesa3d-c59a605c70752b584a05bc6f129a1aa894c861ce.tar.bz2
glcpp: Resolve implicit GLSL version to 100 if the API is ES.
Fixes a regression since b2d1c579 where ES shaders without a #version declaration would fail to compile if their precision declaration was wrapped in the standard #ifdef GL_ES check. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74066 Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/glsl/glcpp')
-rw-r--r--src/glsl/glcpp/glcpp-parse.y15
-rw-r--r--src/glsl/glcpp/glcpp.c1
-rw-r--r--src/glsl/glcpp/glcpp.h3
-rw-r--r--src/glsl/glcpp/pp.c2
4 files changed, 16 insertions, 5 deletions
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 2084c44..17bc649 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -30,6 +30,7 @@
#include "glcpp.h"
#include "main/core.h" /* for struct gl_extensions */
+#include "main/mtypes.h" /* for gl_api enum */
static void
yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
@@ -1186,7 +1187,7 @@ static void add_builtin_define(glcpp_parser_t *parser,
}
glcpp_parser_t *
-glcpp_parser_create (const struct gl_extensions *extensions)
+glcpp_parser_create (const struct gl_extensions *extensions, gl_api api)
{
glcpp_parser_t *parser;
@@ -1215,6 +1216,7 @@ glcpp_parser_create (const struct gl_extensions *extensions)
parser->error = 0;
parser->extensions = extensions;
+ parser->api = api;
parser->version_resolved = false;
parser->has_new_line_number = 0;
@@ -2142,12 +2144,19 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio
}
}
-/* GLSL version is no version is explicitly specified. */
+/* GLSL version if no version is explicitly specified. */
#define IMPLICIT_GLSL_VERSION 110
+/* GLSL ES version if no version is explicitly specified. */
+#define IMPLICIT_GLSL_ES_VERSION 100
+
void
glcpp_parser_resolve_implicit_version(glcpp_parser_t *parser)
{
- _glcpp_parser_handle_version_declaration(parser, IMPLICIT_GLSL_VERSION,
+ int language_version = parser->api == API_OPENGLES2 ?
+ IMPLICIT_GLSL_ES_VERSION :
+ IMPLICIT_GLSL_VERSION;
+
+ _glcpp_parser_handle_version_declaration(parser, language_version,
NULL, false);
}
diff --git a/src/glsl/glcpp/glcpp.c b/src/glsl/glcpp/glcpp.c
index c9c2ff2..6994d7b 100644
--- a/src/glsl/glcpp/glcpp.c
+++ b/src/glsl/glcpp/glcpp.c
@@ -101,6 +101,7 @@ load_text_file(void *ctx, const char *filename)
static void
init_fake_gl_context (struct gl_context *gl_ctx)
{
+ gl_ctx->API = API_OPENGL_COMPAT;
gl_ctx->Const.DisableGLSLLineContinuations = false;
}
diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h
index 9d85c16..79ccb23 100644
--- a/src/glsl/glcpp/glcpp.h
+++ b/src/glsl/glcpp/glcpp.h
@@ -183,6 +183,7 @@ struct glcpp_parser {
size_t info_log_length;
int error;
const struct gl_extensions *extensions;
+ gl_api api;
bool version_resolved;
bool has_new_line_number;
int new_line_number;
@@ -194,7 +195,7 @@ struct glcpp_parser {
struct gl_extensions;
glcpp_parser_t *
-glcpp_parser_create (const struct gl_extensions *extensions);
+glcpp_parser_create (const struct gl_extensions *extensions, gl_api api);
int
glcpp_parser_parse (glcpp_parser_t *parser);
diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c
index fc645f7..4a623f8 100644
--- a/src/glsl/glcpp/pp.c
+++ b/src/glsl/glcpp/pp.c
@@ -139,7 +139,7 @@ glcpp_preprocess(void *ralloc_ctx, const char **shader, char **info_log,
const struct gl_extensions *extensions, struct gl_context *gl_ctx)
{
int errors;
- glcpp_parser_t *parser = glcpp_parser_create (extensions);
+ glcpp_parser_t *parser = glcpp_parser_create (extensions, gl_ctx->API);
if (! gl_ctx->Const.DisableGLSLLineContinuations)
*shader = remove_line_continuations(parser, *shader);