From 5bfbcf7265dfc72d85f6adbf3b243355b16334d9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 29 Jul 2008 17:12:19 -0600 Subject: mesa: implement grammar/parsing for precision/invariant syntax Plus, fix some issues with pre-defined preprocessor symbols and version checking. --- src/mesa/shader/slang/slang_preprocess.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/mesa/shader/slang/slang_preprocess.c') diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c index 1645afcc18..d3f412c211 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) { -- cgit v1.2.3