glsl2: Invoke preprocessor before calling the compiler proper
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 29 Jun 2010 17:02:36 +0000 (10:02 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 29 Jun 2010 18:00:58 +0000 (11:00 -0700)
src/mesa/shader/ir_to_mesa.cpp

index 24b03e1be11c6a2bc7ebfbb09b74a94eca134714..1232bada27addf626e0c525f5121acb804c2a510 100644 (file)
@@ -1526,9 +1526,17 @@ _mesa_get_glsl_shader(GLcontext *ctx, void *mem_ctx, struct gl_shader *sh)
    state->loop_or_switch_nesting = NULL;
    state->ARB_texture_rectangle_enable = true;
 
-   _mesa_glsl_lexer_ctor(state, shader->Source);
-   _mesa_glsl_parse(state);
-   _mesa_glsl_lexer_dtor(state);
+   /* Create a new context for the preprocessor output.  Ultimately, this
+    * should probably be the parser context, but there isn't one yet.
+    */
+   const char *source = shader->Source;
+   state->error = preprocess(shader, &source, &state->info_log);
+
+   if (!state->error) {
+     _mesa_glsl_lexer_ctor(state, source);
+     _mesa_glsl_parse(state);
+     _mesa_glsl_lexer_dtor(state);
+   }
 
    shader->ir.make_empty();
    if (!state->error && !state->translation_unit.is_empty())