Don't process empty shaders
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 8 Jun 2010 01:53:06 +0000 (18:53 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 8 Jun 2010 01:53:06 +0000 (18:53 -0700)
Some valid shaders, such as 'precision highp float;', evaluate to
empty sets of instructions.  This causes some of the optimization
stages to enter infinite loops.  Instead, don't bother processing the
empty ones.

glsl_parser_extras.cpp

index afce9d9..f6b3028 100644 (file)
@@ -737,7 +737,8 @@ main(int argc, char **argv)
         ast->print();
       }
 
-      _mesa_ast_to_hir(&instructions, &state);
+      if (!state.translation_unit.is_empty())
+        _mesa_ast_to_hir(&instructions, &state);
    } else {
       /* FINISHME: We should initialize this to the max GLSL version supported
        * FINISHME: by the driver.  At the moment, we don't know what that is.
@@ -748,7 +749,7 @@ main(int argc, char **argv)
    }
 
    /* Optimization passes */
-   if (!state.error) {
+   if (!state.error && !instructions.is_empty()) {
       bool progress;
       do {
         progress = false;