diff options
author | Brian Paul <[email protected]> | 2008-07-29 17:12:19 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-07-29 17:12:19 -0600 |
commit | 5bfbcf7265dfc72d85f6adbf3b243355b16334d9 (patch) | |
tree | cd1d54d6a7c7c5ec60ca47f95c43b4efa2c073b5 /src/mesa/shader/slang/slang_preprocess.c | |
parent | c3ad1761586c640ba7d4060c4a6917ce61078cf9 (diff) |
mesa: implement grammar/parsing for precision/invariant syntax
Plus, fix some issues with pre-defined preprocessor symbols and version checking.
Diffstat (limited to 'src/mesa/shader/slang/slang_preprocess.c')
-rw-r--r-- | src/mesa/shader/slang/slang_preprocess.c | 27 |
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) { |