[Mesa-dev] [PATCH 1/8] glsl: parse #version XXX compatibility
Marek Olšák
maraeo at gmail.com
Wed May 23 20:58:52 UTC 2018
From: Marek Olšák <marek.olsak at amd.com>
---
src/compiler/glsl/glcpp/glcpp-parse.y | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y b/src/compiler/glsl/glcpp/glcpp-parse.y
index d83f99f1c7e..4be5cfa3d54 100644
--- a/src/compiler/glsl/glcpp/glcpp-parse.y
+++ b/src/compiler/glsl/glcpp/glcpp-parse.y
@@ -2310,37 +2310,41 @@ _glcpp_parser_skip_stack_pop(glcpp_parser_t *parser, YYLTYPE *loc)
glcpp_error (loc, parser, "#endif without #if\n");
return;
}
node = parser->skip_stack;
parser->skip_stack = node->next;
}
static void
_glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t version,
- const char *es_identifier,
+ const char *identifier,
bool explicitly_set)
{
if (parser->version_set)
return;
parser->version = version;
parser->version_set = true;
add_builtin_define (parser, "__VERSION__", version);
parser->is_gles = (version == 100) ||
- (es_identifier && (strcmp(es_identifier, "es") == 0));
+ (identifier && (strcmp(identifier, "es") == 0));
+ bool is_compat = version >= 150 && identifier &&
+ strcmp(identifier, "compatibility") == 0;
/* Add pre-defined macros. */
if (parser->is_gles)
add_builtin_define(parser, "GL_ES", 1);
+ else if (is_compat)
+ add_builtin_define(parser, "GL_compatibility_profile", 1);
else if (version >= 150)
add_builtin_define(parser, "GL_core_profile", 1);
/* Currently, all ES2/ES3 implementations support highp in the
* fragment shader, so we always define this macro in ES2/ES3.
* If we ever get a driver that doesn't support highp, we'll
* need to add a flag to the gl_context and check that here.
*/
if (version >= 130 || parser->is_gles)
add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1);
@@ -2361,22 +2365,22 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio
add_builtin_define(parser, "__have_builtin_builtin_udiv64", 1);
add_builtin_define(parser, "__have_builtin_builtin_umod64", 1);
add_builtin_define(parser, "__have_builtin_builtin_idiv64", 1);
add_builtin_define(parser, "__have_builtin_builtin_imod64", 1);
}
}
if (explicitly_set) {
_mesa_string_buffer_printf(parser->output,
"#version %" PRIiMAX "%s%s", version,
- es_identifier ? " " : "",
- es_identifier ? es_identifier : "");
+ identifier ? " " : "",
+ identifier ? identifier : "");
}
}
/* 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
--
2.17.0
More information about the mesa-dev
mailing list