summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/slang/slang_preprocess.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader/slang/slang_preprocess.c')
-rw-r--r--src/mesa/shader/slang/slang_preprocess.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c
index 1645afcc18f..d3f412c211e 100644
--- a/src/mesa/shader/slang/slang_preprocess.c
+++ b/src/mesa/shader/slang/slang_preprocess.c
@@ -729,6 +729,14 @@ expand (expand_state *e, pp_symbols *symbols)
slang_string_pushi (e->output, e->state->version);
slang_string_pushc (e->output, ' ');
}
+#if FEATURE_es2_glsl
+ else if (_mesa_strcmp (id, "GL_ES") == 0 ||
+ _mesa_strcmp (id, "GL_FRAGMENT_PRECISION_HIGH") == 0) {
+ slang_string_pushc (e->output, ' ');
+ slang_string_pushi (e->output, '1');
+ slang_string_pushc (e->output, ' ');
+ }
+#endif
else {
pp_symbol *symbol;
@@ -829,6 +837,16 @@ static GLboolean
preprocess_source (slang_string *output, const char *source, grammar pid, grammar eid,
slang_info_log *elog)
{
+ static const char *predefined[] = {
+ "__FILE__",
+ "__LINE__",
+ "__VERSION__",
+#if FEATURE_es2_glsl
+ "GL_ES",
+ "GL_FRAGMENT_PRECISION_HIGH",
+#endif
+ NULL
+ };
byte *prod;
GLuint size, i;
pp_state state;
@@ -840,6 +858,15 @@ preprocess_source (slang_string *output, const char *source, grammar pid, gramma
pp_state_init (&state, elog);
+ /* add the predefined symbols to the symbol table */
+ for (i = 0; predefined[i]; i++) {
+ pp_symbol *symbol = NULL;
+ symbol = pp_symbols_push(&state.symbols);
+ assert(symbol);
+ slang_string_pushs(&symbol->name,
+ predefined[i], _mesa_strlen(predefined[i]));
+ }
+
i = 0;
while (i < size) {
if (prod[i] != ESCAPE_TOKEN) {