Mesa (glsl2): glsl2: Insert global declarations at the top of the instruction stream.

Eric Anholt anholt at kemper.freedesktop.org
Thu Aug 5 21:42:19 UTC 2010


Module: Mesa
Branch: glsl2
Commit: 8048226b7b1bbe8fd89f9c32fa4fadca4b8760c4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8048226b7b1bbe8fd89f9c32fa4fadca4b8760c4

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Aug  5 14:41:09 2010 -0700

glsl2: Insert global declarations at the top of the instruction stream.

Fixes use-before-decl in glslparsertest shaders.

Fixes:
CorrectFull.frag
CorrectModule.frag

---

 src/glsl/ast_to_hir.cpp |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 292c7be..f14341c 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1951,7 +1951,14 @@ ast_declarator_list::hir(exec_list *instructions,
 			  decl->identifier);
       }
 
-      instructions->push_tail(var);
+      /* Push the variable declaration to the top.  It means that all
+       * the variable declarations will appear in a funny
+       * last-to-first order, but otherwise we run into trouble if a
+       * function is prototyped, a global var is decled, then the
+       * function is defined with usage of the global var.  See
+       * glslparsertest's CorrectModule.frag.
+       */
+      instructions->push_head(var);
       instructions->append_list(&initializer_instructions);
 
       /* Add the variable to the symbol table after processing the initializer.




More information about the mesa-commit mailing list