Bug 883478 - Update ANGLE to pull from 13-08-02. r=upstream,bjacob,bas
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 06 Sep 2013 17:24:36 -0700
changeset 146042 356866ae2f6885933451a92aae838af00d659679
parent 146041 2be3551a5d8040c76b92302eb14cdb0852da393d
child 146043 55e14139d90916b996071cc99e34ac5a50385a12
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersupstream, bjacob, bas
bugs883478
milestone26.0a1
Bug 883478 - Update ANGLE to pull from 13-08-02. r=upstream,bjacob,bas
gfx/angle/AUTHORS
gfx/angle/CONTRIBUTORS
gfx/angle/Makefile.in
gfx/angle/README.chromium
gfx/angle/README.mozilla
gfx/angle/angle-build-case-sensitive.patch
gfx/angle/angle-build-d3dcompiler-list.patch
gfx/angle/angle-build-dedupe-debug-cpp-h.patch
gfx/angle/angle-build-dedupe-uniform-cpp-h.patch
gfx/angle/angle-build-ttype.patch
gfx/angle/angle-cross-compilation.patch
gfx/angle/angle-default-clamp-strat.patch
gfx/angle/angle-line-loop-overflow.patch
gfx/angle/angle-long-ident-hash.patch
gfx/angle/angle-long-ident-spooky-hash.patch
gfx/angle/angle-tex-pool-default.patch
gfx/angle/build/common.gypi
gfx/angle/codereview.settings
gfx/angle/extensions/EGL_ANGLE_direct3d_display.txt
gfx/angle/include/EGL/eglext.h
gfx/angle/include/GLES2/gl2ext.h
gfx/angle/include/GLSLANG/ShaderLang.h
gfx/angle/moz.build
gfx/angle/src/ANGLE.sln
gfx/angle/src/build_angle.gypi
gfx/angle/src/common/RefCountObject.cpp
gfx/angle/src/common/angleutils.h
gfx/angle/src/common/debug.cpp
gfx/angle/src/common/debug.h
gfx/angle/src/common/system.h
gfx/angle/src/common/version.h
gfx/angle/src/compiler/64bit-lexer-safety.patch
gfx/angle/src/compiler/BaseTypes.h
gfx/angle/src/compiler/CodeGenHLSL.cpp
gfx/angle/src/compiler/Common.h
gfx/angle/src/compiler/Compiler.cpp
gfx/angle/src/compiler/CompilerUniform.cpp
gfx/angle/src/compiler/CompilerUniform.h
gfx/angle/src/compiler/ConstantUnion.h
gfx/angle/src/compiler/DetectCallDepth.cpp
gfx/angle/src/compiler/DetectCallDepth.h
gfx/angle/src/compiler/DetectRecursion.cpp
gfx/angle/src/compiler/DetectRecursion.h
gfx/angle/src/compiler/Diagnostics.cpp
gfx/angle/src/compiler/InfoSink.cpp
gfx/angle/src/compiler/InfoSink.h
gfx/angle/src/compiler/Initialize.cpp
gfx/angle/src/compiler/Initialize.h
gfx/angle/src/compiler/InitializeDll.cpp
gfx/angle/src/compiler/InitializeDll.h
gfx/angle/src/compiler/InitializeGlobals.h
gfx/angle/src/compiler/InitializeParseContext.cpp
gfx/angle/src/compiler/InitializeParseContext.h
gfx/angle/src/compiler/Intermediate.cpp
gfx/angle/src/compiler/MapLongVariableNames.cpp
gfx/angle/src/compiler/OutputGLSL.cpp
gfx/angle/src/compiler/OutputGLSL.h
gfx/angle/src/compiler/OutputGLSLBase.cpp
gfx/angle/src/compiler/OutputGLSLBase.h
gfx/angle/src/compiler/OutputHLSL.cpp
gfx/angle/src/compiler/OutputHLSL.h
gfx/angle/src/compiler/ParseHelper.cpp
gfx/angle/src/compiler/ParseHelper.h
gfx/angle/src/compiler/PoolAlloc.cpp
gfx/angle/src/compiler/PoolAlloc.h
gfx/angle/src/compiler/ShHandle.h
gfx/angle/src/compiler/ShaderLang.cpp
gfx/angle/src/compiler/SymbolTable.cpp
gfx/angle/src/compiler/SymbolTable.h
gfx/angle/src/compiler/TranslatorHLSL.cpp
gfx/angle/src/compiler/TranslatorHLSL.h
gfx/angle/src/compiler/Types.h
gfx/angle/src/compiler/ValidateLimitations.cpp
gfx/angle/src/compiler/VariableInfo.cpp
gfx/angle/src/compiler/generate_parser.sh
gfx/angle/src/compiler/glslang.l
gfx/angle/src/compiler/glslang.y
gfx/angle/src/compiler/glslang_lex.cpp
gfx/angle/src/compiler/glslang_tab.cpp
gfx/angle/src/compiler/glslang_tab.h
gfx/angle/src/compiler/intermOut.cpp
gfx/angle/src/compiler/intermediate.h
gfx/angle/src/compiler/localintermediate.h
gfx/angle/src/compiler/parseConst.cpp
gfx/angle/src/compiler/preprocessor/64bit-tokenizer-safety.patch
gfx/angle/src/compiler/preprocessor/ExpressionParser.cpp
gfx/angle/src/compiler/preprocessor/Tokenizer.cpp
gfx/angle/src/compiler/preprocessor/Tokenizer.l
gfx/angle/src/compiler/preprocessor/generate_parser.sh
gfx/angle/src/compiler/preprocessor/preprocessor.vcxproj
gfx/angle/src/compiler/preprocessor/preprocessor.vcxproj.filters
gfx/angle/src/compiler/spooky.cpp
gfx/angle/src/compiler/spooky.h
gfx/angle/src/compiler/timing/RestrictVertexShaderTiming.cpp
gfx/angle/src/compiler/translator_common.vcxproj
gfx/angle/src/compiler/translator_common.vcxproj.filters
gfx/angle/src/compiler/translator_hlsl.vcxproj
gfx/angle/src/compiler/translator_hlsl.vcxproj.filters
gfx/angle/src/libEGL/Config.cpp
gfx/angle/src/libEGL/Config.h
gfx/angle/src/libEGL/Display.cpp
gfx/angle/src/libEGL/Display.h
gfx/angle/src/libEGL/Makefile.in
gfx/angle/src/libEGL/ShaderCache.h
gfx/angle/src/libEGL/Surface.cpp
gfx/angle/src/libEGL/Surface.h
gfx/angle/src/libEGL/libEGL.cpp
gfx/angle/src/libEGL/libEGL.vcxproj
gfx/angle/src/libEGL/libEGL.vcxproj.filters
gfx/angle/src/libEGL/main.cpp
gfx/angle/src/libEGL/main.h
gfx/angle/src/libEGL/moz.build
gfx/angle/src/libGLESv2/BinaryStream.h
gfx/angle/src/libGLESv2/Blit.cpp
gfx/angle/src/libGLESv2/Blit.h
gfx/angle/src/libGLESv2/Buffer.cpp
gfx/angle/src/libGLESv2/Buffer.h
gfx/angle/src/libGLESv2/Context.cpp
gfx/angle/src/libGLESv2/Context.h
gfx/angle/src/libGLESv2/D3DConstantTable.cpp
gfx/angle/src/libGLESv2/D3DConstantTable.h
gfx/angle/src/libGLESv2/Fence.cpp
gfx/angle/src/libGLESv2/Fence.h
gfx/angle/src/libGLESv2/Float16ToFloat32.cpp
gfx/angle/src/libGLESv2/Framebuffer.cpp
gfx/angle/src/libGLESv2/Framebuffer.h
gfx/angle/src/libGLESv2/HandleAllocator.cpp
gfx/angle/src/libGLESv2/IndexDataManager.cpp
gfx/angle/src/libGLESv2/IndexDataManager.h
gfx/angle/src/libGLESv2/Makefile.in
gfx/angle/src/libGLESv2/Program.cpp
gfx/angle/src/libGLESv2/Program.h
gfx/angle/src/libGLESv2/ProgramBinary.cpp
gfx/angle/src/libGLESv2/ProgramBinary.h
gfx/angle/src/libGLESv2/Query.cpp
gfx/angle/src/libGLESv2/Query.h
gfx/angle/src/libGLESv2/Renderbuffer.cpp
gfx/angle/src/libGLESv2/Renderbuffer.h
gfx/angle/src/libGLESv2/ResourceManager.cpp
gfx/angle/src/libGLESv2/ResourceManager.h
gfx/angle/src/libGLESv2/Shader.cpp
gfx/angle/src/libGLESv2/Shader.h
gfx/angle/src/libGLESv2/Texture.cpp
gfx/angle/src/libGLESv2/Texture.h
gfx/angle/src/libGLESv2/TextureSSE2.cpp
gfx/angle/src/libGLESv2/Uniform.cpp
gfx/angle/src/libGLESv2/Uniform.h
gfx/angle/src/libGLESv2/VertexDataManager.cpp
gfx/angle/src/libGLESv2/VertexDataManager.h
gfx/angle/src/libGLESv2/angletypes.h
gfx/angle/src/libGLESv2/constants.h
gfx/angle/src/libGLESv2/libGLESv2.cpp
gfx/angle/src/libGLESv2/libGLESv2.def
gfx/angle/src/libGLESv2/libGLESv2.vcxproj
gfx/angle/src/libGLESv2/libGLESv2.vcxproj.filters
gfx/angle/src/libGLESv2/main.cpp
gfx/angle/src/libGLESv2/main.h
gfx/angle/src/libGLESv2/mathutil.h
gfx/angle/src/libGLESv2/moz.build
gfx/angle/src/libGLESv2/precompiled.cpp
gfx/angle/src/libGLESv2/precompiled.h
gfx/angle/src/libGLESv2/renderer/Blit.cpp
gfx/angle/src/libGLESv2/renderer/Blit.h
gfx/angle/src/libGLESv2/renderer/BufferStorage.cpp
gfx/angle/src/libGLESv2/renderer/BufferStorage.h
gfx/angle/src/libGLESv2/renderer/BufferStorage11.cpp
gfx/angle/src/libGLESv2/renderer/BufferStorage11.h
gfx/angle/src/libGLESv2/renderer/BufferStorage9.cpp
gfx/angle/src/libGLESv2/renderer/BufferStorage9.h
gfx/angle/src/libGLESv2/renderer/Fence11.cpp
gfx/angle/src/libGLESv2/renderer/Fence11.h
gfx/angle/src/libGLESv2/renderer/Fence9.cpp
gfx/angle/src/libGLESv2/renderer/Fence9.h
gfx/angle/src/libGLESv2/renderer/FenceImpl.h
gfx/angle/src/libGLESv2/renderer/Image.cpp
gfx/angle/src/libGLESv2/renderer/Image.h
gfx/angle/src/libGLESv2/renderer/Image11.cpp
gfx/angle/src/libGLESv2/renderer/Image11.h
gfx/angle/src/libGLESv2/renderer/Image9.cpp
gfx/angle/src/libGLESv2/renderer/Image9.h
gfx/angle/src/libGLESv2/renderer/ImageSSE2.cpp
gfx/angle/src/libGLESv2/renderer/IndexBuffer.cpp
gfx/angle/src/libGLESv2/renderer/IndexBuffer.h
gfx/angle/src/libGLESv2/renderer/IndexBuffer11.cpp
gfx/angle/src/libGLESv2/renderer/IndexBuffer11.h
gfx/angle/src/libGLESv2/renderer/IndexBuffer9.cpp
gfx/angle/src/libGLESv2/renderer/IndexBuffer9.h
gfx/angle/src/libGLESv2/renderer/IndexDataManager.cpp
gfx/angle/src/libGLESv2/renderer/IndexDataManager.h
gfx/angle/src/libGLESv2/renderer/IndexRangeCache.cpp
gfx/angle/src/libGLESv2/renderer/IndexRangeCache.h
gfx/angle/src/libGLESv2/renderer/InputLayoutCache.cpp
gfx/angle/src/libGLESv2/renderer/InputLayoutCache.h
gfx/angle/src/libGLESv2/renderer/Query11.cpp
gfx/angle/src/libGLESv2/renderer/Query11.h
gfx/angle/src/libGLESv2/renderer/Query9.cpp
gfx/angle/src/libGLESv2/renderer/Query9.h
gfx/angle/src/libGLESv2/renderer/QueryImpl.h
gfx/angle/src/libGLESv2/renderer/RenderStateCache.cpp
gfx/angle/src/libGLESv2/renderer/RenderStateCache.h
gfx/angle/src/libGLESv2/renderer/RenderTarget.h
gfx/angle/src/libGLESv2/renderer/RenderTarget11.cpp
gfx/angle/src/libGLESv2/renderer/RenderTarget11.h
gfx/angle/src/libGLESv2/renderer/RenderTarget9.cpp
gfx/angle/src/libGLESv2/renderer/RenderTarget9.h
gfx/angle/src/libGLESv2/renderer/Renderer.cpp
gfx/angle/src/libGLESv2/renderer/Renderer.h
gfx/angle/src/libGLESv2/renderer/Renderer11.cpp
gfx/angle/src/libGLESv2/renderer/Renderer11.h
gfx/angle/src/libGLESv2/renderer/Renderer9.cpp
gfx/angle/src/libGLESv2/renderer/Renderer9.h
gfx/angle/src/libGLESv2/renderer/ShaderCache.h
gfx/angle/src/libGLESv2/renderer/ShaderExecutable.h
gfx/angle/src/libGLESv2/renderer/ShaderExecutable11.cpp
gfx/angle/src/libGLESv2/renderer/ShaderExecutable11.h
gfx/angle/src/libGLESv2/renderer/ShaderExecutable9.cpp
gfx/angle/src/libGLESv2/renderer/ShaderExecutable9.h
gfx/angle/src/libGLESv2/renderer/SwapChain.h
gfx/angle/src/libGLESv2/renderer/SwapChain11.cpp
gfx/angle/src/libGLESv2/renderer/SwapChain11.h
gfx/angle/src/libGLESv2/renderer/SwapChain9.cpp
gfx/angle/src/libGLESv2/renderer/SwapChain9.h
gfx/angle/src/libGLESv2/renderer/TextureStorage.cpp
gfx/angle/src/libGLESv2/renderer/TextureStorage.h
gfx/angle/src/libGLESv2/renderer/TextureStorage11.cpp
gfx/angle/src/libGLESv2/renderer/TextureStorage11.h
gfx/angle/src/libGLESv2/renderer/TextureStorage9.cpp
gfx/angle/src/libGLESv2/renderer/TextureStorage9.h
gfx/angle/src/libGLESv2/renderer/VertexBuffer.cpp
gfx/angle/src/libGLESv2/renderer/VertexBuffer.h
gfx/angle/src/libGLESv2/renderer/VertexBuffer11.cpp
gfx/angle/src/libGLESv2/renderer/VertexBuffer11.h
gfx/angle/src/libGLESv2/renderer/VertexBuffer9.cpp
gfx/angle/src/libGLESv2/renderer/VertexBuffer9.h
gfx/angle/src/libGLESv2/renderer/VertexDataManager.cpp
gfx/angle/src/libGLESv2/renderer/VertexDataManager.h
gfx/angle/src/libGLESv2/renderer/VertexDeclarationCache.cpp
gfx/angle/src/libGLESv2/renderer/VertexDeclarationCache.h
gfx/angle/src/libGLESv2/renderer/generatemip.h
gfx/angle/src/libGLESv2/renderer/renderer11_utils.cpp
gfx/angle/src/libGLESv2/renderer/renderer11_utils.h
gfx/angle/src/libGLESv2/renderer/renderer9_utils.cpp
gfx/angle/src/libGLESv2/renderer/renderer9_utils.h
gfx/angle/src/libGLESv2/renderer/shaders/Blit.ps
gfx/angle/src/libGLESv2/renderer/shaders/Blit.vs
gfx/angle/src/libGLESv2/renderer/shaders/Clear11.hlsl
gfx/angle/src/libGLESv2/renderer/shaders/Passthrough11.hlsl
gfx/angle/src/libGLESv2/renderer/shaders/compiled/clear11vs.h
gfx/angle/src/libGLESv2/renderer/shaders/compiled/clearmultiple11ps.h
gfx/angle/src/libGLESv2/renderer/shaders/compiled/clearsingle11ps.h
gfx/angle/src/libGLESv2/renderer/shaders/compiled/componentmaskps.h
gfx/angle/src/libGLESv2/renderer/shaders/compiled/flipyvs.h
gfx/angle/src/libGLESv2/renderer/shaders/compiled/luminanceps.h
gfx/angle/src/libGLESv2/renderer/shaders/compiled/passthrough11vs.h
gfx/angle/src/libGLESv2/renderer/shaders/compiled/passthroughlum11ps.h
gfx/angle/src/libGLESv2/renderer/shaders/compiled/passthroughlumalpha11ps.h
gfx/angle/src/libGLESv2/renderer/shaders/compiled/passthroughps.h
gfx/angle/src/libGLESv2/renderer/shaders/compiled/passthroughrgb11ps.h
gfx/angle/src/libGLESv2/renderer/shaders/compiled/passthroughrgba11ps.h
gfx/angle/src/libGLESv2/renderer/shaders/compiled/standardvs.h
gfx/angle/src/libGLESv2/renderer/shaders/generate_shaders.bat
gfx/angle/src/libGLESv2/renderer/vertexconversion.h
gfx/angle/src/libGLESv2/shaders/Blit.ps
gfx/angle/src/libGLESv2/shaders/Blit.vs
gfx/angle/src/libGLESv2/shaders/componentmaskps.h
gfx/angle/src/libGLESv2/shaders/flipyvs.h
gfx/angle/src/libGLESv2/shaders/generate_shaders.bat
gfx/angle/src/libGLESv2/shaders/luminanceps.h
gfx/angle/src/libGLESv2/shaders/passthroughps.h
gfx/angle/src/libGLESv2/shaders/standardvs.h
gfx/angle/src/libGLESv2/utilities.cpp
gfx/angle/src/libGLESv2/utilities.h
gfx/angle/src/libGLESv2/vertexconversion.h
gfx/angle/src/third_party/murmurhash/LICENSE
gfx/angle/src/third_party/murmurhash/MurmurHash3.cpp
gfx/angle/src/third_party/murmurhash/MurmurHash3.h
--- a/gfx/angle/AUTHORS
+++ b/gfx/angle/AUTHORS
@@ -25,9 +25,8 @@ Ginn Chen
 James Hauxwell
 Sam Hocevar
 Pierre Leveille
 Jonathan Liu
 Boying Lu
 Aitor Moreno
 Yuri O'Donnell
 Josh Soref
-Evan Wallace
--- a/gfx/angle/CONTRIBUTORS
+++ b/gfx/angle/CONTRIBUTORS
@@ -1,74 +1,76 @@
-# This is the official list of people who can contribute
-# (and who have contributed) code to the ANGLE project
-# repository.
-# The AUTHORS file lists the copyright holders; this file
-# lists people.  For example, Google employees are listed here
-# but not in AUTHORS, because Google holds the copyright.
-#
-
-TransGaming Inc.
- Nicolas Capens
- Daniel Koch
- Andrew Lewycky
- Gavriel State
- Shannon Woods
-
-Google Inc.
- Brent Austin
- Michael Bai
- John Bauman
- Peter Beverloo
- Steve Block
- Rachel Blum
- Eric Boren
- Henry Bridge
- Nat Duca
- Peter Kasting
- Vangelis Kokkevis
- Zhenyao Mo
- Daniel Nicoara
- Alastair Patrick
- Alok Priyadarshi
- Kenneth Russell
- Brian Salomon
- Gregg Tavares
- Jeff Timanus
- Ben Vanik
- Adrienne Walker
- thestig@chromium.org
- Justin Schuh
-
-Adobe Systems Inc.
- Alexandru Chiculita
- Steve Minns
- Max Vujovic
-
-Autodesk, Inc.
- Ranger Harke
-
-Cloud Party, Inc.
- Conor Dickinson
-
-Intel Corporation
- Jin Yang
- Andy Chen
- Josh Triplett
-
-Klarälvdalens Datakonsult AB
- Milian Wolff
-
-Mozilla Corp.
- Ehsan Akhgari
- Jeff Gilbert
- Mike Hommey
- Benoit Jacob
- Makoto Kato
- Vladimir Vukicevic
-
-Turbulenz
- Michael Braithwaite
-
-Ulrik Persson (ddefrostt)
-Mark Banner (standard8mbp)
-David Kilzer
-
+# This is the official list of people who can contribute
+# (and who have contributed) code to the ANGLE project
+# repository.
+# The AUTHORS file lists the copyright holders; this file
+# lists people.  For example, Google employees are listed here
+# but not in AUTHORS, because Google holds the copyright.
+#
+
+TransGaming Inc.
+ Nicolas Capens
+ Daniel Koch
+ Geoff Lang
+ Andrew Lewycky
+ Jamie Madill
+ Gavriel State
+ Shannon Woods
+
+Google Inc.
+ Brent Austin
+ Michael Bai
+ John Bauman
+ Peter Beverloo
+ Steve Block
+ Rachel Blum
+ Eric Boren
+ Henry Bridge
+ Nat Duca
+ Peter Kasting
+ Vangelis Kokkevis
+ Zhenyao Mo
+ Daniel Nicoara
+ Alastair Patrick
+ Alok Priyadarshi
+ Kenneth Russell
+ Brian Salomon
+ Gregg Tavares
+ Jeff Timanus
+ Ben Vanik
+ Adrienne Walker
+ thestig@chromium.org
+ Justin Schuh
+
+Adobe Systems Inc.
+ Alexandru Chiculita
+ Steve Minns
+ Max Vujovic
+
+Autodesk, Inc.
+ Ranger Harke
+
+Cloud Party, Inc.
+ Conor Dickinson
+
+Intel Corporation
+ Jin Yang
+ Andy Chen
+ Josh Triplett
+
+Klarälvdalens Datakonsult AB
+ Milian Wolff
+
+Mozilla Corp.
+ Ehsan Akhgari
+ Jeff Gilbert
+ Mike Hommey
+ Benoit Jacob
+ Makoto Kato
+ Vladimir Vukicevic
+
+Turbulenz
+ Michael Braithwaite
+
+Ulrik Persson (ddefrostt)
+Mark Banner (standard8mbp)
+David Kilzer
+
--- a/gfx/angle/Makefile.in
+++ b/gfx/angle/Makefile.in
@@ -22,16 +22,17 @@ LOCAL_INCLUDES += \
   -I$(srcdir)/src
 
 DEFINES += -DCOMPILER_IMPLEMENTATION
 
 VPATH += $(srcdir)/src/compiler
 VPATH += $(srcdir)/src/compiler/depgraph
 VPATH += $(srcdir)/src/compiler/timing
 VPATH += $(srcdir)/src/third_party/compiler
+VPATH += $(srcdir)/src/third_party/murmurhash
 
 # Target: 'translator_glsl'
 #   Requires: 'translator_common'
 # src/compiler:
 ifdef MOZ_ANGLE_RENDERER
 
 libs::
 ifdef MOZ_D3DCOMPILER_CAB
new file mode 100644
--- /dev/null
+++ b/gfx/angle/README.chromium
@@ -0,0 +1,10 @@
+Name: ANGLE
+URL: https://code.google.com/p/angleproject/
+Version: 2422
+License: BSD
+License File: LICENSE
+
+Description:
+ANGLE is a conformant implementation of the OpenGL ES 2.0
+specification that is hardware‐accelerated via Direct3D.
+
--- a/gfx/angle/README.mozilla
+++ b/gfx/angle/README.mozilla
@@ -1,69 +1,82 @@
 This is the ANGLE project, from http://code.google.com/p/angleproject/
 
-Current revision: r2042
-
+Current revision: f3fc6571dca9832876e09c63b0958d413737757b
+Date of revision: 2013-08-02
 
 == Applied local patches ==
 In this order:
   angle-build-stdcall-alias.patch:
     Fix an issue GCC has with linking to undecorated stdcalls.
-    
+
   angle-build-dedupe-debug-cpp-h.patch:
     Rename: "src/compiler/debug.{cpp,h}"
     To:     "src/compiler/compiler_debug.{cpp,h}"
     Repair includes accordingly.
-    
+
   angle-build-d3dcompiler-list.patch:
     Move `ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES` define from make files to
-    Display.cpp, where it's used.
-    
+    Renderer.cpp, where it's used.
+
   angle-build-khrplatform-h-path.patch:
     Fix include path for khrplatform.h.
-  
-  angle-long-ident-spooky-hash.patch:
-    Use Spooky Hash for long identifier hashing. See bug 676071.
-  
+
+  angle-build-case-sensitive.patch
+    Fixes cross compilation on case sensitive OSes.
+
+  angle-build-dedupe-uniform-cpp-h.patch:
+    Rename: "src/compiler/Uniform.{cpp,h}"
+    To:     "src/compiler/CompilerUniform.{cpp,h}"
+    Repair includes accordingly.
+
+  angle-build-ttype.patch:
+    Remove bit-field markings for TType, since GCC4.7 emits a default
+    copy constructor which fails to compile.
+
+  angle-long-ident-hash.patch:
+    Use MurmurHash3 for long identifier hashing. See bug 676071, where we used
+    Spooky Hash, before ANGLE came with MurmurHash3.
+
   angle-faceforward-emu.patch:
     Adds emulation for faceforward(float,float,float), which is needed to
     prevent crashing on Mac+Intel. See bug 771406.
-  
+
   angle-default-clamp-strat.patch:
     Fixes TCompiler::Init to treat `resources.ArrayIndexClampingStrategy`
     as a request for the default strategy.
 
-  angle-cross-compilation.patch
-    Fixes cross compilation on case sensitive OSes.
+  angle-tex-pool-default.patch:
+    Don't use D3DPOOL_MANAGED on D3D9. Just use D3DPOOL_DEFAULT.
 
-  angle-line-loop-overflow.patch
-    Fixes a forgotten overflow check on drawing line loop
-    ANGLE bug : http://code.google.com/p/angleproject/issues/detail?id=444
-    ANGLE revision : 07dda9519cf4
-
-In addition to these patches, the Makefile.in files are ours, they're not present in
-upsteam ANGLE. Therefore, changes made to the Makefile.in files should not be stored
-in the local .patch files.
+In addition to these patches, the Makefile.in and moz.build build files are ours,
+they're not present in upsteam ANGLE. Therefore, changes made to the build files
+should not be stored in the local .patch files.
 
 
 == How to do a clean-slate upgrade ==
 1.  Backup our moz-specific files:
       README.mozilla
       Makefile.in
+      moz.build
       *.patch
       src/libEGL/Makefile.in
+      src/libEGL/moz.build
       src/libGLESv2/Makefile.in
+      src/libGLESv2/moz.build
 
 2.  $ rm -rf gfx/angle
 
 3.  Copy the folder containing the angle rev you want onto gfx/angle.
-    $ svn export -r <rev> <src> <moz-central>/gfx/angle 
+    $ svn export -r <rev> <src> <moz-central>/gfx/angle
+    Or:
+    $ git checkout-index --prefix <moz-central>/gfx/angle/ -a
 
 4.  Fold our moz-specific files into this new angle folder. (Makefiles, README)
-4a. Remove the unused directories. (test/, samples/, etc)
+4a. Remove the unused files. (test/, samples/, msvc files)
 
 5.  Clear out the "Applied Local Patches" section above, since we're going to
     repopulate it.
 
 6.  Re-apply the angle-build-*.patch files and record them above.
 
 7.  Update the Makefile.in files with the current deps from the .gyp(i) files.
 
new file mode 100644
--- /dev/null
+++ b/gfx/angle/angle-build-case-sensitive.patch
@@ -0,0 +1,22 @@
+From: Jeff Gilbert <jgilbert@mozilla.com>
+* * *
+Bug 840577 - Fix ANGLE cross compilation on case sensitive OSes, relanded
+
+diff --git a/gfx/angle/src/libGLESv2/precompiled.h b/gfx/angle/src/libGLESv2/precompiled.h
+--- a/gfx/angle/src/libGLESv2/precompiled.h
++++ b/gfx/angle/src/libGLESv2/precompiled.h
+@@ -30,13 +30,13 @@
+ #include <sstream>
+ #include <string>
+ #include <unordered_map>
+ #include <vector>
+ 
+ #include <d3d9.h>
+ #include <D3D11.h>
+ #include <dxgi.h>
+-#include <D3Dcompiler.h>
++#include <d3dcompiler.h>
+ 
+ #ifdef _MSC_VER
+ #include <hash_map>
+ #endif
--- a/gfx/angle/angle-build-d3dcompiler-list.patch
+++ b/gfx/angle/angle-build-d3dcompiler-list.patch
@@ -1,28 +1,41 @@
 From: Jeff Gilbert <jgilbert@mozilla.com>
 
-diff --git a/gfx/angle/src/libEGL/Display.cpp b/gfx/angle/src/libEGL/Display.cpp
---- a/gfx/angle/src/libEGL/Display.cpp
-+++ b/gfx/angle/src/libEGL/Display.cpp
-@@ -26,16 +26,22 @@
- // The "Debug This Pixel..." feature in PIX often fails when using the
- // D3D9Ex interfaces.  In order to get debug pixel to work on a Vista/Win 7
- // machine, define "ANGLE_ENABLE_D3D9EX=0" in your project file.
- #if !defined(ANGLE_ENABLE_D3D9EX)
- // Enables use of the IDirect3D9Ex interface, when available
- #define ANGLE_ENABLE_D3D9EX 1
- #endif // !defined(ANGLE_ENABLE_D3D9EX)
+diff --git a/gfx/angle/src/libGLESv2/renderer/Renderer.cpp b/gfx/angle/src/libGLESv2/renderer/Renderer.cpp
+--- a/gfx/angle/src/libGLESv2/renderer/Renderer.cpp
++++ b/gfx/angle/src/libGLESv2/renderer/Renderer.cpp
+@@ -15,16 +15,23 @@
+ #include "libGLESv2/renderer/Renderer11.h"
+ #include "libGLESv2/utilities.h"
+ 
+ #if !defined(ANGLE_ENABLE_D3D11)
+ // Enables use of the Direct3D 11 API for a default display, when available
+ #define ANGLE_ENABLE_D3D11 0
+ #endif
  
 +#define ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES \
 +    {                                            \
 +        TEXT("d3dcompiler_46.dll"),              \
 +        TEXT("d3dcompiler_43.dll")               \
 +    }
 +
- namespace egl
++
+ namespace rx
+ {
+ 
+ Renderer::Renderer(egl::Display *display) : mDisplay(display)
  {
- namespace
- {
-     typedef std::map<EGLNativeDisplayType, Display*> DisplayMap; 
-     DisplayMap displays;
+     mD3dCompilerModule = NULL;
+     mD3DCompileFunc = NULL;
+ }
+@@ -212,9 +219,9 @@ rx::Renderer *glCreateRenderer(egl::Disp
+     return NULL;
  }
  
+ void glDestroyRenderer(rx::Renderer *renderer)
+ {
+     delete renderer;
+ }
+ 
+-}
+\ No newline at end of file
++}
--- a/gfx/angle/angle-build-dedupe-debug-cpp-h.patch
+++ b/gfx/angle/angle-build-dedupe-debug-cpp-h.patch
@@ -64,17 +64,17 @@ diff --git a/gfx/angle/src/compiler/Outp
  {
  TString arrayBrackets(const TType& type)
  {
      ASSERT(type.isArray());
 diff --git a/gfx/angle/src/compiler/OutputHLSL.cpp b/gfx/angle/src/compiler/OutputHLSL.cpp
 --- a/gfx/angle/src/compiler/OutputHLSL.cpp
 +++ b/gfx/angle/src/compiler/OutputHLSL.cpp
 @@ -2,17 +2,17 @@
- // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
+ // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
  // Use of this source code is governed by a BSD-style license that can be
  // found in the LICENSE file.
  //
  
  #include "compiler/OutputHLSL.h"
  
  #include "common/angleutils.h"
 -#include "compiler/debug.h"
@@ -85,35 +85,35 @@ diff --git a/gfx/angle/src/compiler/Outp
  #include "compiler/UnfoldShortCircuit.h"
  
  #include <algorithm>
  #include <cfloat>
  #include <stdio.h>
 diff --git a/gfx/angle/src/compiler/Types.h b/gfx/angle/src/compiler/Types.h
 --- a/gfx/angle/src/compiler/Types.h
 +++ b/gfx/angle/src/compiler/Types.h
-@@ -4,17 +4,17 @@
- // found in the LICENSE file.
- //
+@@ -6,17 +6,17 @@
  
  #ifndef _TYPES_INCLUDED
  #define _TYPES_INCLUDED
  
+ #include "common/angleutils.h"
+ 
  #include "compiler/BaseTypes.h"
  #include "compiler/Common.h"
 -#include "compiler/debug.h"
 +#include "compiler/compiler_debug.h"
  
+ struct TPublicType;
  class TType;
- struct TPublicType;
  
- //
- // Need to have association of line numbers to types in a list for building structs.
- //
- struct TTypeLine {
+ class TField
+ {
+ public:
+     POOL_ALLOCATOR_NEW_DELETE();
 diff --git a/gfx/angle/src/compiler/debug.cpp b/gfx/angle/src/compiler/compiler_debug.cpp
 rename from gfx/angle/src/compiler/debug.cpp
 rename to gfx/angle/src/compiler/compiler_debug.cpp
 --- a/gfx/angle/src/compiler/debug.cpp
 +++ b/gfx/angle/src/compiler/compiler_debug.cpp
 @@ -1,17 +1,17 @@
  //
  // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
new file mode 100644
--- /dev/null
+++ b/gfx/angle/angle-build-dedupe-uniform-cpp-h.patch
@@ -0,0 +1,93 @@
+From: Jeff Gilbert <jgilbert@mozilla.com>
+
+diff --git a/gfx/angle/src/compiler/Uniform.cpp b/gfx/angle/src/compiler/CompilerUniform.cpp
+rename from gfx/angle/src/compiler/Uniform.cpp
+rename to gfx/angle/src/compiler/CompilerUniform.cpp
+--- a/gfx/angle/src/compiler/Uniform.cpp
++++ b/gfx/angle/src/compiler/CompilerUniform.cpp
+@@ -1,15 +1,15 @@
+ //
+ // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+ //
+ 
+-#include "compiler/Uniform.h"
++#include "CompilerUniform.h"
+ 
+ namespace sh
+ {
+ 
+ Uniform::Uniform(GLenum type, GLenum precision, const char *name, int arraySize, int registerIndex)
+ {
+     this->type = type;
+     this->precision = precision;
+diff --git a/gfx/angle/src/compiler/Uniform.h b/gfx/angle/src/compiler/CompilerUniform.h
+rename from gfx/angle/src/compiler/Uniform.h
+rename to gfx/angle/src/compiler/CompilerUniform.h
+diff --git a/gfx/angle/src/compiler/OutputHLSL.h b/gfx/angle/src/compiler/OutputHLSL.h
+--- a/gfx/angle/src/compiler/OutputHLSL.h
++++ b/gfx/angle/src/compiler/OutputHLSL.h
+@@ -11,17 +11,17 @@
+ #include <set>
+ #include <map>
+ 
+ #define GL_APICALL
+ #include <GLES2/gl2.h>
+ 
+ #include "compiler/intermediate.h"
+ #include "compiler/ParseHelper.h"
+-#include "compiler/Uniform.h"
++#include "compiler/CompilerUniform.h"
+ 
+ namespace sh
+ {
+ class UnfoldShortCircuit;
+ 
+ class OutputHLSL : public TIntermTraverser
+ {
+   public:
+diff --git a/gfx/angle/src/compiler/TranslatorHLSL.h b/gfx/angle/src/compiler/TranslatorHLSL.h
+--- a/gfx/angle/src/compiler/TranslatorHLSL.h
++++ b/gfx/angle/src/compiler/TranslatorHLSL.h
+@@ -3,17 +3,17 @@
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+ //
+ 
+ #ifndef COMPILER_TRANSLATORHLSL_H_
+ #define COMPILER_TRANSLATORHLSL_H_
+ 
+ #include "compiler/ShHandle.h"
+-#include "compiler/Uniform.h"
++#include "compiler/CompilerUniform.h"
+ 
+ class TranslatorHLSL : public TCompiler {
+ public:
+     TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output);
+ 
+     virtual TranslatorHLSL *getAsTranslatorHLSL() { return this; }
+     const sh::ActiveUniforms &getUniforms() { return mActiveUniforms; }
+ 
+diff --git a/gfx/angle/src/libGLESv2/Shader.h b/gfx/angle/src/libGLESv2/Shader.h
+--- a/gfx/angle/src/libGLESv2/Shader.h
++++ b/gfx/angle/src/libGLESv2/Shader.h
+@@ -13,17 +13,17 @@
+ #define LIBGLESV2_SHADER_H_
+ 
+ #define GL_APICALL
+ #include <GLES2/gl2.h>
+ #include <string>
+ #include <list>
+ #include <vector>
+ 
+-#include "compiler/Uniform.h"
++#include "compiler/CompilerUniform.h"
+ #include "common/angleutils.h"
+ 
+ namespace rx
+ {
+ class Renderer;
+ }
+ 
+ namespace gl
new file mode 100644
--- /dev/null
+++ b/gfx/angle/angle-build-ttype.patch
@@ -0,0 +1,52 @@
+From: Jeff Gilbert <jgilbert@mozilla.com>
+
+diff --git a/gfx/angle/src/compiler/Types.h b/gfx/angle/src/compiler/Types.h
+--- a/gfx/angle/src/compiler/Types.h
++++ b/gfx/angle/src/compiler/Types.h
+@@ -90,17 +90,17 @@ private:
+ //
+ // Base class for things that have a type.
+ //
+ class TType
+ {
+ public:
+     POOL_ALLOCATOR_NEW_DELETE();
+     TType() {}
+-    TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :
++    TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, char s = 1, bool m = false, bool a = false) :
+             type(t), precision(p), qualifier(q), size(s), matrix(m), array(a), arraySize(0), structure(0)
+     {
+     }
+     explicit TType(const TPublicType &p);
+     TType(TStructure* userDef, TPrecision p = EbpUndefined) :
+             type(EbtStruct), precision(p), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0), structure(userDef)
+     {
+     }
+@@ -229,22 +229,22 @@ public:
+ 
+     bool isStructureContainingArrays() const {
+         return structure ? structure->containsArrays() : false;
+     }
+ 
+ private:
+     TString buildMangledName() const;
+ 
+-    TBasicType type      : 6;
++    TBasicType type;
+     TPrecision precision;
+-    TQualifier qualifier : 7;
+-    int size             : 8; // size of vector or matrix, not size of array
+-    unsigned int matrix  : 1;
+-    unsigned int array   : 1;
++    TQualifier qualifier;
++    char size; // size of vector or matrix, not size of array
++    bool matrix;
++    bool array;
+     int arraySize;
+ 
+     TStructure* structure;      // 0 unless this is a struct
+ 
+     mutable TString mangled;
+ };
+ 
+ //
deleted file mode 100644
--- a/gfx/angle/angle-cross-compilation.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-From: Jacek Caban <jacek@codeweavers.com>
-Bug 840577 - Fix ANGLE cross compilation on case sensitive OSes, relanded
-
-
-diff --git a/gfx/angle/src/common/system.h b/gfx/angle/src/common/system.h
-index f071a05..74f659b 100644
---- a/gfx/angle/src/common/system.h
-+++ b/gfx/angle/src/common/system.h
-@@ -10,17 +10,17 @@
- #define COMMON_SYSTEM_H
- 
- #if !defined(WIN32_LEAN_AND_MEAN)
- #define WIN32_LEAN_AND_MEAN
- #endif
- 
- #include <windows.h>
- #include <d3d9.h>
--#include <D3Dcompiler.h>
-+#include <d3dcompiler.h>
- #include <d3d9types.h>
- #include <mmsystem.h>
- 
- #if defined(min)
- #undef min
- #endif
- 
- #if defined(max)
-diff --git a/gfx/angle/src/libEGL/Display.h b/gfx/angle/src/libEGL/Display.h
-index 5859cf2..a1a7870 100644
---- a/gfx/angle/src/libEGL/Display.h
-+++ b/gfx/angle/src/libEGL/Display.h
-@@ -8,17 +8,17 @@
- // display on which graphics are drawn. Implements EGLDisplay.
- // [EGL 1.4] section 2.1.2 page 3.
- 
- #ifndef LIBEGL_DISPLAY_H_
- #define LIBEGL_DISPLAY_H_
- 
- #include "common/system.h"
- #include <d3d9.h>
--#include <D3Dcompiler.h>
-+#include <d3dcompiler.h>
- 
- #include <set>
- #include <vector>
- 
- #include "libGLESv2/Context.h"
- 
- #include "libEGL/Config.h"
- #include "libEGL/ShaderCache.h"
--- a/gfx/angle/angle-default-clamp-strat.patch
+++ b/gfx/angle/angle-default-clamp-strat.patch
@@ -1,14 +1,14 @@
 From: Jeff Gilbert <jgilbert@mozilla.com>
 
 diff --git a/gfx/angle/src/compiler/Compiler.cpp b/gfx/angle/src/compiler/Compiler.cpp
 --- a/gfx/angle/src/compiler/Compiler.cpp
 +++ b/gfx/angle/src/compiler/Compiler.cpp
-@@ -124,18 +124,21 @@ bool TCompiler::Init(const ShBuiltInReso
+@@ -130,18 +130,21 @@ bool TCompiler::Init(const ShBuiltInReso
      TScopedPoolAllocator scopedAlloc(&allocator, false);
  
      // Generate built-in symbol table.
      if (!InitBuiltInSymbolTable(resources))
          return false;
      InitExtensionBehavior(resources, extensionBehavior);
      fragmentPrecisionHigh = resources.FragmentPrecisionHigh == 1;
  
deleted file mode 100644
--- a/gfx/angle/angle-line-loop-overflow.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-# HG changeset patch
-# Parent 308e3cf5ba75fdf8ed3bdd3dc766410b708b98ef
-
-diff --git a/gfx/angle/src/libGLESv2/IndexDataManager.cpp b/gfx/angle/src/libGLESv2/IndexDataManager.cpp
---- a/gfx/angle/src/libGLESv2/IndexDataManager.cpp
-+++ b/gfx/angle/src/libGLESv2/IndexDataManager.cpp
-@@ -375,17 +375,18 @@ void StreamingIndexBuffer::reserveSpace(
-     
-         if (FAILED(result))
-         {
-             ERR("Out of memory allocating a vertex buffer of size %lu.", mBufferSize);
-         }
- 
-         mWritePosition = 0;
-     }
--    else if (mWritePosition + requiredSpace > mBufferSize)   // Recycle
-+    else if (mWritePosition + requiredSpace > mBufferSize ||
-+             mWritePosition + requiredSpace < mWritePosition)   // Recycle
-     {
-         void *dummy;
-         mIndexBuffer->Lock(0, 1, &dummy, D3DLOCK_DISCARD);
-         mIndexBuffer->Unlock();
- 
-         mWritePosition = 0;
-     }
- }
new file mode 100644
--- /dev/null
+++ b/gfx/angle/angle-long-ident-hash.patch
@@ -0,0 +1,137 @@
+From: Jeff Gilbert <jgilbert@mozilla.com>
+
+diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
+--- a/gfx/angle/Makefile.in
++++ b/gfx/angle/Makefile.in
+@@ -32,16 +32,17 @@ LOCAL_INCLUDES += \
+   -I$(srcdir)/src
+ 
+ DEFINES += -DCOMPILER_IMPLEMENTATION
+ 
+ VPATH += $(srcdir)/src/compiler
+ VPATH += $(srcdir)/src/compiler/depgraph
+ VPATH += $(srcdir)/src/compiler/timing
+ VPATH += $(srcdir)/src/third_party/compiler
++VPATH += $(srcdir)/src/third_party/murmurhash
+ 
+ # Target: 'translator_glsl'
+ #   Requires: 'translator_common'
+ # src/compiler:
+ ifdef MOZ_ANGLE_RENDERER
+ 
+ libs::
+ ifdef MOZ_D3DCOMPILER_CAB
+diff --git a/gfx/angle/moz.build b/gfx/angle/moz.build
+--- a/gfx/angle/moz.build
++++ b/gfx/angle/moz.build
+@@ -83,16 +83,21 @@ CPP_SOURCES += [
+     'RestrictVertexShaderTiming.cpp',
+ ]
+ 
+ # src/third_party/compiler:
+ CPP_SOURCES += [
+     'ArrayBoundsClamper.cpp',
+ ]
+ 
++# src/third_party/murmurhash:
++CPP_SOURCES += [
++    'MurmurHash3.cpp',
++]
++
+ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
+     CPP_SOURCES += [
+         'ossource_win.cpp',
+     ]
+ else:
+     CPP_SOURCES += [
+         'ossource_posix.cpp',
+     ]
+diff --git a/gfx/angle/src/compiler/MapLongVariableNames.cpp b/gfx/angle/src/compiler/MapLongVariableNames.cpp
+--- a/gfx/angle/src/compiler/MapLongVariableNames.cpp
++++ b/gfx/angle/src/compiler/MapLongVariableNames.cpp
+@@ -1,29 +1,39 @@
+ //
+ // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+ //
+ 
+ #include "compiler/MapLongVariableNames.h"
+ 
++#include "third_party/murmurhash/MurmurHash3.h"
++
+ namespace {
+ 
+ TString mapLongName(size_t id, const TString& name, bool isGlobal)
+ {
+     ASSERT(name.size() > MAX_SHORTENED_IDENTIFIER_SIZE);
+     TStringStream stream;
+-    stream << "webgl_";
+-    if (isGlobal)
+-        stream << "g";
+-    stream << id;
+-    if (name[0] != '_')
+-        stream << "_";
+-    stream << name.substr(0, MAX_SHORTENED_IDENTIFIER_SIZE - stream.str().size());
++
++    uint64_t hash[2] = {0, 0};
++    MurmurHash3_x64_128(name.data(), name.length(), 0, hash);
++
++    // We want to avoid producing a string with a double underscore,
++    // which would be an illegal GLSL identifier. We can assume that the
++    // original identifier doesn't have a double underscore, otherwise
++    // it's illegal anyway.
++    stream << (name[0] == '_' ? "webgl" : "webgl_")
++           << name.substr(0, 9)
++           << (name[8] == '_' ? "" : "_")
++           << std::hex
++           << hash[0];
++    ASSERT(stream.str().length() <= MAX_SHORTENED_IDENTIFIER_SIZE);
++    ASSERT(stream.str().length() >= MAX_SHORTENED_IDENTIFIER_SIZE - 2);
+     return stream.str();
+ }
+ 
+ LongNameMap* gLongNameMapInstance = NULL;
+ 
+ }  // anonymous namespace
+ 
+ LongNameMap::LongNameMap()
+diff --git a/gfx/angle/src/libGLESv2/moz.build b/gfx/angle/src/libGLESv2/moz.build
+--- a/gfx/angle/src/libGLESv2/moz.build
++++ b/gfx/angle/src/libGLESv2/moz.build
+@@ -71,16 +71,21 @@ CPP_SOURCES += [
+     'RestrictVertexShaderTiming.cpp',
+ ]
+ 
+ # src/third_party/compiler:
+ CPP_SOURCES += [
+     'ArrayBoundsClamper.cpp',
+ ]
+ 
++# src/third_party/murmurhash:
++CPP_SOURCES += [
++    'MurmurHash3.cpp',
++]
++
+ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
+     CPP_SOURCES += [
+         'ossource_win.cpp',
+     ]
+ else:
+     CPP_SOURCES += [
+         'ossource_posix.cpp',
+     ]
+@@ -165,13 +170,8 @@ CPP_SOURCES += [
+     'TextureStorage11.cpp',
+     'TextureStorage9.cpp',
+     'VertexBuffer.cpp',
+     'VertexBuffer9.cpp',
+     'VertexBuffer11.cpp',
+     'VertexDataManager.cpp',
+     'VertexDeclarationCache.cpp',
+ ]
+-
+-# src/third_party/murmurhash:
+-CPP_SOURCES += [
+-    'MurmurHash3.cpp',
+-]
deleted file mode 100644
--- a/gfx/angle/angle-long-ident-spooky-hash.patch
+++ /dev/null
@@ -1,743 +0,0 @@
-# HG changeset patch
-# Parent 262218204644915abb2add8aa52195c24035c293
-
-diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
---- a/gfx/angle/Makefile.in
-+++ b/gfx/angle/Makefile.in
-@@ -84,16 +84,17 @@ CPPSRCS += \
-   intermOut.cpp \
-   IntermTraverse.cpp \
-   MapLongVariableNames.cpp \
-   parseConst.cpp \
-   ParseHelper.cpp \
-   PoolAlloc.cpp \
-   QualifierAlive.cpp \
-   RemoveTree.cpp \
-+  spooky.cpp \
-   SymbolTable.cpp \
-   util.cpp \
-   ValidateLimitations.cpp \
-   VariableInfo.cpp \
-   VariablePacker.cpp \
-   $(NULL)
- 
- VPATH += $(srcdir)/src/compiler/depgraph
-diff --git a/gfx/angle/src/compiler/MapLongVariableNames.cpp b/gfx/angle/src/compiler/MapLongVariableNames.cpp
---- a/gfx/angle/src/compiler/MapLongVariableNames.cpp
-+++ b/gfx/angle/src/compiler/MapLongVariableNames.cpp
-@@ -1,29 +1,36 @@
- //
- // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
- //
- 
- #include "compiler/MapLongVariableNames.h"
-+#include "spooky.h"
- 
- namespace {
- 
- TString mapLongName(size_t id, const TString& name, bool isGlobal)
- {
-     ASSERT(name.size() > MAX_SHORTENED_IDENTIFIER_SIZE);
-     TStringStream stream;
--    stream << "webgl_";
--    if (isGlobal)
--        stream << "g";
--    stream << id;
--    if (name[0] != '_')
--        stream << "_";
--    stream << name.substr(0, MAX_SHORTENED_IDENTIFIER_SIZE - stream.str().size());
-+    uint64 hash = SpookyHash::Hash64(name.data(), name.length(), 0);
-+
-+    // We want to avoid producing a string with a double underscore,
-+    // which would be an illegal GLSL identifier. We can assume that the
-+    // original identifier doesn't have a double underscore, otherwise
-+    // it's illegal anyway.
-+    stream << (name[0] == '_' ? "webgl" : "webgl_")
-+           << name.substr(0, 9)
-+           << (name[8] == '_' ? "" : "_")
-+           << std::hex
-+           << hash;
-+    ASSERT(stream.str().length() <= MAX_SHORTENED_IDENTIFIER_SIZE);
-+    ASSERT(stream.str().length() >= MAX_SHORTENED_IDENTIFIER_SIZE - 2);
-     return stream.str();
- }
- 
- LongNameMap* gLongNameMapInstance = NULL;
- 
- }  // anonymous namespace
- 
- LongNameMap::LongNameMap()
-diff --git a/gfx/angle/src/compiler/spooky.cpp b/gfx/angle/src/compiler/spooky.cpp
-new file mode 100644
---- /dev/null
-+++ b/gfx/angle/src/compiler/spooky.cpp
-@@ -0,0 +1,348 @@
-+// Spooky Hash
-+// A 128-bit noncryptographic hash, for checksums and table lookup
-+// By Bob Jenkins.  Public domain.
-+//   Oct 31 2010: published framework, disclaimer ShortHash isn't right
-+//   Nov 7 2010: disabled ShortHash
-+//   Oct 31 2011: replace End, ShortMix, ShortEnd, enable ShortHash again
-+
-+#include <memory.h>
-+#include <string.h>
-+#include "spooky.h"
-+
-+#define ALLOW_UNALIGNED_READS 1
-+
-+//
-+// short hash ... it could be used on any message, 
-+// but it's used by Spooky just for short messages.
-+//
-+void SpookyHash::Short(
-+    const void *message,
-+    size_t length,
-+    uint64 *hash1,
-+    uint64 *hash2)
-+{
-+    uint64 buf[sc_numVars];
-+    union 
-+    { 
-+        const uint8 *p8; 
-+        uint32 *p32;
-+        uint64 *p64; 
-+        size_t i; 
-+    } u;
-+
-+    u.p8 = (const uint8 *)message;
-+    
-+    if (!ALLOW_UNALIGNED_READS && (u.i & 0x7))
-+    {
-+        memcpy(buf, message, length);
-+        u.p64 = buf;
-+    }
-+
-+    size_t remainder = length%32;
-+    uint64 a=*hash1;
-+    uint64 b=*hash2;
-+    uint64 c=sc_const;
-+    uint64 d=sc_const;
-+
-+    if (length > 15)
-+    {
-+        const uint64 *end = u.p64 + (length/32)*4;
-+        
-+        // handle all complete sets of 32 bytes
-+        for (; u.p64 < end; u.p64 += 4)
-+        {
-+            c += u.p64[0];
-+            d += u.p64[1];
-+            ShortMix(a,b,c,d);
-+            a += u.p64[2];
-+            b += u.p64[3];
-+        }
-+        
-+        //Handle the case of 16+ remaining bytes.
-+        if (remainder >= 16)
-+        {
-+            c += u.p64[0];
-+            d += u.p64[1];
-+            ShortMix(a,b,c,d);
-+            u.p64 += 2;
-+            remainder -= 16;
-+        }
-+    }
-+    
-+    // Handle the last 0..15 bytes, and its length
-+    d = ((uint64)length) << 56;
-+    switch (remainder)
-+    {
-+    case 15:
-+    d += ((uint64)u.p8[14]) << 48;
-+    case 14:
-+        d += ((uint64)u.p8[13]) << 40;
-+    case 13:
-+        d += ((uint64)u.p8[12]) << 32;
-+    case 12:
-+        d += u.p32[2];
-+        c += u.p64[0];
-+        break;
-+    case 11:
-+        d += ((uint64)u.p8[10]) << 16;
-+    case 10:
-+        d += ((uint64)u.p8[9]) << 8;
-+    case 9:
-+        d += (uint64)u.p8[8];
-+    case 8:
-+        c += u.p64[0];
-+        break;
-+    case 7:
-+        c += ((uint64)u.p8[6]) << 48;
-+    case 6:
-+        c += ((uint64)u.p8[5]) << 40;
-+    case 5:
-+        c += ((uint64)u.p8[4]) << 32;
-+    case 4:
-+        c += u.p32[0];
-+        break;
-+    case 3:
-+        c += ((uint64)u.p8[2]) << 16;
-+    case 2:
-+        c += ((uint64)u.p8[1]) << 8;
-+    case 1:
-+        c += (uint64)u.p8[0];
-+        break;
-+    case 0:
-+        c += sc_const;
-+        d += sc_const;
-+    }
-+    ShortEnd(a,b,c,d);
-+    *hash1 = a;
-+    *hash2 = b;
-+}
-+
-+
-+
-+
-+// do the whole hash in one call
-+void SpookyHash::Hash128(
-+    const void *message, 
-+    size_t length, 
-+    uint64 *hash1, 
-+    uint64 *hash2)
-+{
-+    if (length < sc_bufSize)
-+    {
-+        Short(message, length, hash1, hash2);
-+        return;
-+    }
-+
-+    uint64 h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11;
-+    uint64 buf[sc_numVars];
-+    uint64 *end;
-+    union 
-+    { 
-+        const uint8 *p8; 
-+        uint64 *p64; 
-+        size_t i; 
-+    } u;
-+    size_t remainder;
-+    
-+    h0=h3=h6=h9  = *hash1;
-+    h1=h4=h7=h10 = *hash2;
-+    h2=h5=h8=h11 = sc_const;
-+    
-+    u.p8 = (const uint8 *)message;
-+    end = u.p64 + (length/sc_blockSize)*sc_numVars;
-+
-+    // handle all whole sc_blockSize blocks of bytes
-+    if (ALLOW_UNALIGNED_READS || ((u.i & 0x7) == 0))
-+    {
-+        while (u.p64 < end)
-+        { 
-+            Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+	    u.p64 += sc_numVars;
-+        }
-+    }
-+    else
-+    {
-+        while (u.p64 < end)
-+        {
-+            memcpy(buf, u.p64, sc_blockSize);
-+            Mix(buf, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+	    u.p64 += sc_numVars;
-+        }
-+    }
-+
-+    // handle the last partial block of sc_blockSize bytes
-+    remainder = (length - ((const uint8 *)end-(const uint8 *)message));
-+    memcpy(buf, end, remainder);
-+    memset(((uint8 *)buf)+remainder, 0, sc_blockSize-remainder);
-+    ((uint8 *)buf)[sc_blockSize-1] = remainder;
-+    Mix(buf, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+    
-+    // do some final mixing 
-+    End(h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+    *hash1 = h0;
-+    *hash2 = h1;
-+}
-+
-+
-+
-+// init spooky state
-+void SpookyHash::Init(uint64 seed1, uint64 seed2)
-+{
-+    m_length = 0;
-+    m_remainder = 0;
-+    m_state[0] = seed1;
-+    m_state[1] = seed2;
-+}
-+
-+
-+// add a message fragment to the state
-+void SpookyHash::Update(const void *message, size_t length)
-+{
-+    uint64 h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11;
-+    size_t newLength = length + m_remainder;
-+    uint8  remainder;
-+    union 
-+    { 
-+        const uint8 *p8; 
-+        uint64 *p64; 
-+        size_t i; 
-+    } u;
-+    const uint64 *end;
-+    
-+    // Is this message fragment too short?  If it is, stuff it away.
-+    if (newLength < sc_bufSize)
-+    {
-+        memcpy(&((uint8 *)m_data)[m_remainder], message, length);
-+        m_length = length + m_length;
-+        m_remainder = (uint8)newLength;
-+        return;
-+    }
-+    
-+    // init the variables
-+    if (m_length < sc_bufSize)
-+    {
-+        h0=h3=h6=h9  = m_state[0];
-+        h1=h4=h7=h10 = m_state[1];
-+        h2=h5=h8=h11 = sc_const;
-+    }
-+    else
-+    {
-+        h0 = m_state[0];
-+        h1 = m_state[1];
-+        h2 = m_state[2];
-+        h3 = m_state[3];
-+        h4 = m_state[4];
-+        h5 = m_state[5];
-+        h6 = m_state[6];
-+        h7 = m_state[7];
-+        h8 = m_state[8];
-+        h9 = m_state[9];
-+        h10 = m_state[10];
-+        h11 = m_state[11];
-+    }
-+    m_length = length + m_length;
-+    
-+    // if we've got anything stuffed away, use it now
-+    if (m_remainder)
-+    {
-+        uint8 prefix = sc_bufSize-m_remainder;
-+        memcpy(&(((uint8 *)m_data)[m_remainder]), message, prefix);
-+        u.p64 = m_data;
-+        Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+        Mix(&u.p64[sc_numVars], h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+        u.p8 = ((const uint8 *)message) + prefix;
-+        length -= prefix;
-+    }
-+    else
-+    {
-+        u.p8 = (const uint8 *)message;
-+    }
-+    
-+    // handle all whole blocks of sc_blockSize bytes
-+    end = u.p64 + (length/sc_blockSize)*sc_numVars;
-+    remainder = (uint8)(length-((const uint8 *)end-u.p8));
-+    if (ALLOW_UNALIGNED_READS || (u.i & 0x7) == 0)
-+    {
-+        while (u.p64 < end)
-+        { 
-+            Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+	    u.p64 += sc_numVars;
-+        }
-+    }
-+    else
-+    {
-+        while (u.p64 < end)
-+        { 
-+            memcpy(m_data, u.p8, sc_blockSize);
-+            Mix(m_data, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+	    u.p64 += sc_numVars;
-+        }
-+    }
-+
-+    // stuff away the last few bytes
-+    m_remainder = remainder;
-+    memcpy(m_data, end, remainder);
-+    
-+    // stuff away the variables
-+    m_state[0] = h0;
-+    m_state[1] = h1;
-+    m_state[2] = h2;
-+    m_state[3] = h3;
-+    m_state[4] = h4;
-+    m_state[5] = h5;
-+    m_state[6] = h6;
-+    m_state[7] = h7;
-+    m_state[8] = h8;
-+    m_state[9] = h9;
-+    m_state[10] = h10;
-+    m_state[11] = h11;
-+}
-+
-+
-+// report the hash for the concatenation of all message fragments so far
-+void SpookyHash::Final(uint64 *hash1, uint64 *hash2)
-+{
-+    // init the variables
-+    if (m_length < sc_bufSize)
-+    {
-+        Short( m_data, m_length, hash1, hash2);
-+        return;
-+    }
-+    
-+    const uint64 *data = (const uint64 *)m_data;
-+    uint8 remainder = m_remainder;
-+    
-+    uint64 h0 = m_state[0];
-+    uint64 h1 = m_state[1];
-+    uint64 h2 = m_state[2];
-+    uint64 h3 = m_state[3];
-+    uint64 h4 = m_state[4];
-+    uint64 h5 = m_state[5];
-+    uint64 h6 = m_state[6];
-+    uint64 h7 = m_state[7];
-+    uint64 h8 = m_state[8];
-+    uint64 h9 = m_state[9];
-+    uint64 h10 = m_state[10];
-+    uint64 h11 = m_state[11];
-+
-+    if (remainder >= sc_blockSize)
-+    {
-+        // m_data can contain two blocks; handle any whole first block
-+        Mix(data, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+	data += sc_numVars;
-+	remainder -= sc_blockSize;
-+    }
-+
-+    // mix in the last partial block, and the length mod sc_blockSize
-+    memset(&((uint8 *)data)[remainder], 0, (sc_blockSize-remainder));
-+
-+    ((uint8 *)data)[sc_blockSize-1] = remainder;
-+    Mix(data, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+    
-+    // do some final mixing
-+    End(h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+
-+    *hash1 = h0;
-+    *hash2 = h1;
-+}
-+
-diff --git a/gfx/angle/src/compiler/spooky.h b/gfx/angle/src/compiler/spooky.h
-new file mode 100644
---- /dev/null
-+++ b/gfx/angle/src/compiler/spooky.h
-@@ -0,0 +1,293 @@
-+//
-+// SpookyHash: a 128-bit noncryptographic hash function
-+// By Bob Jenkins, public domain
-+//   Oct 31 2010: alpha, framework + SpookyHash::Mix appears right
-+//   Oct 31 2011: alpha again, Mix only good to 2^^69 but rest appears right
-+//   Dec 31 2011: beta, improved Mix, tested it for 2-bit deltas
-+//   Feb  2 2012: production, same bits as beta
-+//   Feb  5 2012: adjusted definitions of uint* to be more portable
-+// 
-+// Up to 4 bytes/cycle for long messages.  Reasonably fast for short messages.
-+// All 1 or 2 bit deltas achieve avalanche within 1% bias per output bit.
-+//
-+// This was developed for and tested on 64-bit x86-compatible processors.
-+// It assumes the processor is little-endian.  There is a macro
-+// controlling whether unaligned reads are allowed (by default they are).
-+// This should be an equally good hash on big-endian machines, but it will
-+// compute different results on them than on little-endian machines.
-+//
-+// Google's CityHash has similar specs to SpookyHash, and CityHash is faster
-+// on some platforms.  MD4 and MD5 also have similar specs, but they are orders
-+// of magnitude slower.  CRCs are two or more times slower, but unlike 
-+// SpookyHash, they have nice math for combining the CRCs of pieces to form 
-+// the CRCs of wholes.  There are also cryptographic hashes, but those are even 
-+// slower than MD5.
-+//
-+
-+#include <stddef.h>
-+
-+#ifdef _MSC_VER
-+# define INLINE __forceinline
-+  typedef  unsigned __int64 uint64;
-+  typedef  unsigned __int32 uint32;
-+  typedef  unsigned __int16 uint16;
-+  typedef  unsigned __int8  uint8;
-+#else
-+# include <stdint.h>
-+# define INLINE inline
-+  typedef  uint64_t  uint64;
-+  typedef  uint32_t  uint32;
-+  typedef  uint16_t  uint16;
-+  typedef  uint8_t   uint8;
-+#endif
-+
-+
-+class SpookyHash
-+{
-+public:
-+    //
-+    // SpookyHash: hash a single message in one call, produce 128-bit output
-+    //
-+    static void Hash128(
-+        const void *message,  // message to hash
-+        size_t length,        // length of message in bytes
-+        uint64 *hash1,        // in/out: in seed 1, out hash value 1
-+        uint64 *hash2);       // in/out: in seed 2, out hash value 2
-+
-+    //
-+    // Hash64: hash a single message in one call, return 64-bit output
-+    //
-+    static uint64 Hash64(
-+        const void *message,  // message to hash
-+        size_t length,        // length of message in bytes
-+        uint64 seed)          // seed
-+    {
-+        uint64 hash1 = seed;
-+        Hash128(message, length, &hash1, &seed);
-+        return hash1;
-+    }
-+
-+    //
-+    // Hash32: hash a single message in one call, produce 32-bit output
-+    //
-+    static uint32 Hash32(
-+        const void *message,  // message to hash
-+        size_t length,        // length of message in bytes
-+        uint32 seed)          // seed
-+    {
-+        uint64 hash1 = seed, hash2 = seed;
-+        Hash128(message, length, &hash1, &hash2);
-+        return (uint32)hash1;
-+    }
-+
-+    //
-+    // Init: initialize the context of a SpookyHash
-+    //
-+    void Init(
-+        uint64 seed1,       // any 64-bit value will do, including 0
-+        uint64 seed2);      // different seeds produce independent hashes
-+    
-+    //
-+    // Update: add a piece of a message to a SpookyHash state
-+    //
-+    void Update(
-+        const void *message,  // message fragment
-+        size_t length);       // length of message fragment in bytes
-+
-+
-+    //
-+    // Final: compute the hash for the current SpookyHash state
-+    //
-+    // This does not modify the state; you can keep updating it afterward
-+    //
-+    // The result is the same as if SpookyHash() had been called with
-+    // all the pieces concatenated into one message.
-+    //
-+    void Final(
-+        uint64 *hash1,    // out only: first 64 bits of hash value.
-+        uint64 *hash2);   // out only: second 64 bits of hash value.
-+
-+    //
-+    // left rotate a 64-bit value by k bytes
-+    //
-+    static INLINE uint64 Rot64(uint64 x, int k)
-+    {
-+        return (x << k) | (x >> (64 - k));
-+    }
-+
-+    //
-+    // This is used if the input is 96 bytes long or longer.
-+    //
-+    // The internal state is fully overwritten every 96 bytes.
-+    // Every input bit appears to cause at least 128 bits of entropy
-+    // before 96 other bytes are combined, when run forward or backward
-+    //   For every input bit,
-+    //   Two inputs differing in just that input bit
-+    //   Where "differ" means xor or subtraction
-+    //   And the base value is random
-+    //   When run forward or backwards one Mix
-+    // I tried 3 pairs of each; they all differed by at least 212 bits.
-+    //
-+    static INLINE void Mix(
-+        const uint64 *data, 
-+        uint64 &s0, uint64 &s1, uint64 &s2, uint64 &s3,
-+        uint64 &s4, uint64 &s5, uint64 &s6, uint64 &s7,
-+        uint64 &s8, uint64 &s9, uint64 &s10,uint64 &s11)
-+    {
-+      s0 += data[0];    s2 ^= s10;    s11 ^= s0;    s0 = Rot64(s0,11);    s11 += s1;
-+      s1 += data[1];    s3 ^= s11;    s0 ^= s1;    s1 = Rot64(s1,32);    s0 += s2;
-+      s2 += data[2];    s4 ^= s0;    s1 ^= s2;    s2 = Rot64(s2,43);    s1 += s3;
-+      s3 += data[3];    s5 ^= s1;    s2 ^= s3;    s3 = Rot64(s3,31);    s2 += s4;
-+      s4 += data[4];    s6 ^= s2;    s3 ^= s4;    s4 = Rot64(s4,17);    s3 += s5;
-+      s5 += data[5];    s7 ^= s3;    s4 ^= s5;    s5 = Rot64(s5,28);    s4 += s6;
-+      s6 += data[6];    s8 ^= s4;    s5 ^= s6;    s6 = Rot64(s6,39);    s5 += s7;
-+      s7 += data[7];    s9 ^= s5;    s6 ^= s7;    s7 = Rot64(s7,57);    s6 += s8;
-+      s8 += data[8];    s10 ^= s6;    s7 ^= s8;    s8 = Rot64(s8,55);    s7 += s9;
-+      s9 += data[9];    s11 ^= s7;    s8 ^= s9;    s9 = Rot64(s9,54);    s8 += s10;
-+      s10 += data[10];    s0 ^= s8;    s9 ^= s10;    s10 = Rot64(s10,22);    s9 += s11;
-+      s11 += data[11];    s1 ^= s9;    s10 ^= s11;    s11 = Rot64(s11,46);    s10 += s0;
-+    }
-+
-+    //
-+    // Mix all 12 inputs together so that h0, h1 are a hash of them all.
-+    //
-+    // For two inputs differing in just the input bits
-+    // Where "differ" means xor or subtraction
-+    // And the base value is random, or a counting value starting at that bit
-+    // The final result will have each bit of h0, h1 flip
-+    // For every input bit,
-+    // with probability 50 +- .3%
-+    // For every pair of input bits,
-+    // with probability 50 +- 3%
-+    //
-+    // This does not rely on the last Mix() call having already mixed some.
-+    // Two iterations was almost good enough for a 64-bit result, but a
-+    // 128-bit result is reported, so End() does three iterations.
-+    //
-+    static INLINE void EndPartial(
-+        uint64 &h0, uint64 &h1, uint64 &h2, uint64 &h3,
-+        uint64 &h4, uint64 &h5, uint64 &h6, uint64 &h7, 
-+        uint64 &h8, uint64 &h9, uint64 &h10,uint64 &h11)
-+    {
-+        h11+= h1;    h2 ^= h11;   h1 = Rot64(h1,44);
-+	h0 += h2;    h3 ^= h0;    h2 = Rot64(h2,15);
-+	h1 += h3;    h4 ^= h1;    h3 = Rot64(h3,34);
-+	h2 += h4;    h5 ^= h2;    h4 = Rot64(h4,21);
-+	h3 += h5;    h6 ^= h3;    h5 = Rot64(h5,38);
-+	h4 += h6;    h7 ^= h4;    h6 = Rot64(h6,33);
-+	h5 += h7;    h8 ^= h5;    h7 = Rot64(h7,10);
-+	h6 += h8;    h9 ^= h6;    h8 = Rot64(h8,13);
-+	h7 += h9;    h10^= h7;    h9 = Rot64(h9,38);
-+	h8 += h10;   h11^= h8;    h10= Rot64(h10,53);
-+	h9 += h11;   h0 ^= h9;    h11= Rot64(h11,42);
-+	h10+= h0;    h1 ^= h10;   h0 = Rot64(h0,54);
-+    }
-+
-+    static INLINE void End(
-+        uint64 &h0, uint64 &h1, uint64 &h2, uint64 &h3,
-+        uint64 &h4, uint64 &h5, uint64 &h6, uint64 &h7, 
-+        uint64 &h8, uint64 &h9, uint64 &h10,uint64 &h11)
-+    {
-+        EndPartial(h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+        EndPartial(h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+        EndPartial(h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
-+    }
-+
-+    //
-+    // The goal is for each bit of the input to expand into 128 bits of 
-+    //   apparent entropy before it is fully overwritten.
-+    // n trials both set and cleared at least m bits of h0 h1 h2 h3
-+    //   n: 2   m: 29
-+    //   n: 3   m: 46
-+    //   n: 4   m: 57
-+    //   n: 5   m: 107
-+    //   n: 6   m: 146
-+    //   n: 7   m: 152
-+    // when run forwards or backwards
-+    // for all 1-bit and 2-bit diffs
-+    // with diffs defined by either xor or subtraction
-+    // with a base of all zeros plus a counter, or plus another bit, or random
-+    //
-+    static INLINE void ShortMix(uint64 &h0, uint64 &h1, uint64 &h2, uint64 &h3)
-+    {
-+        h2 = Rot64(h2,50);  h2 += h3;  h0 ^= h2;
-+        h3 = Rot64(h3,52);  h3 += h0;  h1 ^= h3;
-+        h0 = Rot64(h0,30);  h0 += h1;  h2 ^= h0;
-+        h1 = Rot64(h1,41);  h1 += h2;  h3 ^= h1;
-+        h2 = Rot64(h2,54);  h2 += h3;  h0 ^= h2;
-+        h3 = Rot64(h3,48);  h3 += h0;  h1 ^= h3;
-+        h0 = Rot64(h0,38);  h0 += h1;  h2 ^= h0;
-+        h1 = Rot64(h1,37);  h1 += h2;  h3 ^= h1;
-+        h2 = Rot64(h2,62);  h2 += h3;  h0 ^= h2;
-+        h3 = Rot64(h3,34);  h3 += h0;  h1 ^= h3;
-+        h0 = Rot64(h0,5);   h0 += h1;  h2 ^= h0;
-+        h1 = Rot64(h1,36);  h1 += h2;  h3 ^= h1;
-+    }
-+
-+    //
-+    // Mix all 4 inputs together so that h0, h1 are a hash of them all.
-+    //
-+    // For two inputs differing in just the input bits
-+    // Where "differ" means xor or subtraction
-+    // And the base value is random, or a counting value starting at that bit
-+    // The final result will have each bit of h0, h1 flip
-+    // For every input bit,
-+    // with probability 50 +- .3% (it is probably better than that)
-+    // For every pair of input bits,
-+    // with probability 50 +- .75% (the worst case is approximately that)
-+    //
-+    static INLINE void ShortEnd(uint64 &h0, uint64 &h1, uint64 &h2, uint64 &h3)
-+    {
-+        h3 ^= h2;  h2 = Rot64(h2,15);  h3 += h2;
-+        h0 ^= h3;  h3 = Rot64(h3,52);  h0 += h3;
-+        h1 ^= h0;  h0 = Rot64(h0,26);  h1 += h0;
-+        h2 ^= h1;  h1 = Rot64(h1,51);  h2 += h1;
-+        h3 ^= h2;  h2 = Rot64(h2,28);  h3 += h2;
-+        h0 ^= h3;  h3 = Rot64(h3,9);   h0 += h3;
-+        h1 ^= h0;  h0 = Rot64(h0,47);  h1 += h0;
-+        h2 ^= h1;  h1 = Rot64(h1,54);  h2 += h1;
-+        h3 ^= h2;  h2 = Rot64(h2,32);  h3 += h2;
-+        h0 ^= h3;  h3 = Rot64(h3,25);  h0 += h3;
-+        h1 ^= h0;  h0 = Rot64(h0,63);  h1 += h0;
-+    }
-+    
-+private:
-+
-+    //
-+    // Short is used for messages under 192 bytes in length
-+    // Short has a low startup cost, the normal mode is good for long
-+    // keys, the cost crossover is at about 192 bytes.  The two modes were
-+    // held to the same quality bar.
-+    // 
-+    static void Short(
-+        const void *message,
-+        size_t length,
-+        uint64 *hash1,
-+        uint64 *hash2);
-+
-+    // number of uint64's in internal state
-+    static const size_t sc_numVars = 12;
-+
-+    // size of the internal state
-+    static const size_t sc_blockSize = sc_numVars*8;
-+
-+    // size of buffer of unhashed data, in bytes
-+    static const size_t sc_bufSize = 2*sc_blockSize;
-+
-+    //
-+    // sc_const: a constant which:
-+    //  * is not zero
-+    //  * is odd
-+    //  * is a not-very-regular mix of 1's and 0's
-+    //  * does not need any other special mathematical properties
-+    //
-+    static const uint64 sc_const = 0xdeadbeefdeadbeefLL;
-+
-+    uint64 m_data[2*sc_numVars];   // unhashed data, for partial messages
-+    uint64 m_state[sc_numVars];  // internal state of the hash
-+    size_t m_length;             // total length of the input so far
-+    uint8  m_remainder;          // length of unhashed data stashed in m_data
-+};
-+
-+
-+
-diff --git a/gfx/angle/src/libGLESv2/Makefile.in b/gfx/angle/src/libGLESv2/Makefile.in
---- a/gfx/angle/src/libGLESv2/Makefile.in
-+++ b/gfx/angle/src/libGLESv2/Makefile.in
-@@ -91,16 +91,17 @@ CPPSRCS += \
-   intermOut.cpp \
-   IntermTraverse.cpp \
-   MapLongVariableNames.cpp \
-   parseConst.cpp \
-   ParseHelper.cpp \
-   PoolAlloc.cpp \
-   QualifierAlive.cpp \
-   RemoveTree.cpp \
-+  spooky.cpp \
-   SymbolTable.cpp \
-   util.cpp \
-   ValidateLimitations.cpp \
-   VariableInfo.cpp \
-   VariablePacker.cpp \
-   $(NULL)
- 
- VPATH += $(srcdir)/../compiler/depgraph
new file mode 100644
--- /dev/null
+++ b/gfx/angle/angle-tex-pool-default.patch
@@ -0,0 +1,24 @@
+From: Jeff Gilbert <jgilbert@mozilla.com>
+
+diff --git a/gfx/angle/src/libGLESv2/renderer/Renderer9.cpp b/gfx/angle/src/libGLESv2/renderer/Renderer9.cpp
+--- a/gfx/angle/src/libGLESv2/renderer/Renderer9.cpp
++++ b/gfx/angle/src/libGLESv2/renderer/Renderer9.cpp
+@@ -3128,17 +3128,17 @@ D3DPOOL Renderer9::getTexturePool(DWORD 
+     if (mD3d9Ex != NULL)
+     {
+         return D3DPOOL_DEFAULT;
+     }
+     else
+     {
+         if (!(usage & (D3DUSAGE_DEPTHSTENCIL | D3DUSAGE_RENDERTARGET)))
+         {
+-            return D3DPOOL_MANAGED;
++            return D3DPOOL_DEFAULT;
+         }
+     }
+ 
+     return D3DPOOL_DEFAULT;
+ }
+ 
+ bool Renderer9::copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged)
+ {
--- a/gfx/angle/build/common.gypi
+++ b/gfx/angle/build/common.gypi
@@ -105,16 +105,20 @@
             'PreprocessorDefinitions': ['_DEBUG'],
             'BasicRuntimeChecks': '3',
             'RuntimeLibrary': '1',  # /MTd (debug static)
           },
           'VCLinkerTool': {
             'LinkIncremental': '2',
           },
         },
+        'xcode_settings': {
+          'COPY_PHASE_STRIP': 'NO',
+          'GCC_OPTIMIZATION_LEVEL': '0',
+        },
       },  # Debug
       'Release': {
         'inherit_from': ['Common'],
         'msvs_settings': {
           'VCCLCompilerTool': {
             'Optimization': '2',  # /Os
             'PreprocessorDefinitions': ['NDEBUG'],
             'RuntimeLibrary': '0',  # /MT (static)
deleted file mode 100644
--- a/gfx/angle/codereview.settings
+++ /dev/null
@@ -1,4 +0,0 @@
-# This file is used by gcl to get repository specific information.
-CODE_REVIEW_SERVER: codereview.appspot.com
-CC_LIST: angleproject-review@googlegroups.com
-VIEW_VC: http://code.google.com/p/angleproject/source/detail?r=
new file mode 100644
--- /dev/null
+++ b/gfx/angle/extensions/EGL_ANGLE_direct3d_display.txt
@@ -0,0 +1,68 @@
+Name
+
+    ANGLE_direct3d_display
+
+Name Strings
+
+    EGL_ANGLE_direct3d_display
+
+Contributors
+
+    Nicolas Capens
+    Shannon Woods
+
+Contacts
+
+    Shannon Woods, Google Inc. (shannonwoods 'at' chromium.org)
+
+Status
+
+    In progress
+
+Version
+
+    Version 1, May 15, 2013
+
+Number
+
+    EGL Extension #??
+
+Dependencies
+
+    This extension is written against the wording of the EGL 1.4
+    Specification. 
+
+Overview
+
+    This extension allows for specifying the behavior of the renderer backing the display.
+
+New Types
+
+    None
+
+New Procedures and Functions
+
+    None
+
+New Tokens
+
+    EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE         (EGLNativeDisplayType)-2
+    EGL_D3D11_ONLY_DISPLAY_ANGLE              (EGLNativeDisplayType)-3
+
+Additions to Chapter 3 of the EGL 1.4 Specification (EGL Functions and Errors)
+
+    Add before the last sentence of the first paragraph of section 3.2,
+    "Initialization":
+
+    "If <display_id> is EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE, the display returned
+    will be backed by a Direct3D 11 renderer if one is available, or by a
+    Direct3D 9 renderer otherwise. If <display_id> is EGL_D3D11_ONLY_DISPLAY_ANGLE,
+    the display returned will be backed by a Direct3D 11 renderer if one is
+    available, or will return NULL otherwise."
+
+Issues
+
+Revision History
+
+    Version 1, 2013/05/15 - First draft.
+
--- a/gfx/angle/include/EGL/eglext.h
+++ b/gfx/angle/include/EGL/eglext.h
@@ -301,16 +301,22 @@ EGLAPI EGLBoolean eglQuerySurfacePointer
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
 #endif
 
 #ifndef EGL_ANGLE_software_display
 #define EGL_ANGLE_software_display 1
 #define EGL_SOFTWARE_DISPLAY_ANGLE ((EGLNativeDisplayType)-1)
 #endif
 
+#ifndef EGL_ANGLE_direct3d_display
+#define EGL_ANGLE_direct3d_display 1
+#define EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ((EGLNativeDisplayType)-2)
+#define EGL_D3D11_ONLY_DISPLAY_ANGLE ((EGLNativeDisplayType)-3)
+#endif
+
 #ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle
 #define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
 #define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE	0x3200
 #endif
 
 #ifndef EGL_NV_coverage_sample_resolve
 #define EGL_NV_coverage_sample_resolve 1
 #define EGL_COVERAGE_SAMPLE_RESOLVE_NV		0x3131
--- a/gfx/angle/include/GLES2/gl2ext.h
+++ b/gfx/angle/include/GLES2/gl2ext.h
@@ -551,16 +551,54 @@ typedef void* GLeglImageOES;
 #define GL_COLOR_ATTACHMENT10_NV                                0x8CEA
 #define GL_COLOR_ATTACHMENT11_NV                                0x8CEB
 #define GL_COLOR_ATTACHMENT12_NV                                0x8CEC
 #define GL_COLOR_ATTACHMENT13_NV                                0x8CED
 #define GL_COLOR_ATTACHMENT14_NV                                0x8CEE
 #define GL_COLOR_ATTACHMENT15_NV                                0x8CEF
 #endif
 
+/* GL_EXT_draw_buffers */
+#ifndef GL_EXT_draw_buffers
+#define GL_MAX_DRAW_BUFFERS_EXT                                  0x8824
+#define GL_DRAW_BUFFER0_EXT                                      0x8825
+#define GL_DRAW_BUFFER1_EXT                                      0x8826
+#define GL_DRAW_BUFFER2_EXT                                      0x8827
+#define GL_DRAW_BUFFER3_EXT                                      0x8828
+#define GL_DRAW_BUFFER4_EXT                                      0x8829
+#define GL_DRAW_BUFFER5_EXT                                      0x882A
+#define GL_DRAW_BUFFER6_EXT                                      0x882B
+#define GL_DRAW_BUFFER7_EXT                                      0x882C
+#define GL_DRAW_BUFFER8_EXT                                      0x882D
+#define GL_DRAW_BUFFER9_EXT                                      0x882E
+#define GL_DRAW_BUFFER10_EXT                                     0x882F
+#define GL_DRAW_BUFFER11_EXT                                     0x8830
+#define GL_DRAW_BUFFER12_EXT                                     0x8831
+#define GL_DRAW_BUFFER13_EXT                                     0x8832
+#define GL_DRAW_BUFFER14_EXT                                     0x8833
+#define GL_DRAW_BUFFER15_EXT                                     0x8834
+#define GL_COLOR_ATTACHMENT0_EXT                                 0x8CE0
+#define GL_COLOR_ATTACHMENT1_EXT                                 0x8CE1
+#define GL_COLOR_ATTACHMENT2_EXT                                 0x8CE2
+#define GL_COLOR_ATTACHMENT3_EXT                                 0x8CE3
+#define GL_COLOR_ATTACHMENT4_EXT                                 0x8CE4
+#define GL_COLOR_ATTACHMENT5_EXT                                 0x8CE5
+#define GL_COLOR_ATTACHMENT6_EXT                                 0x8CE6
+#define GL_COLOR_ATTACHMENT7_EXT                                 0x8CE7
+#define GL_COLOR_ATTACHMENT8_EXT                                 0x8CE8
+#define GL_COLOR_ATTACHMENT9_EXT                                 0x8CE9
+#define GL_COLOR_ATTACHMENT10_EXT                                0x8CEA
+#define GL_COLOR_ATTACHMENT11_EXT                                0x8CEB
+#define GL_COLOR_ATTACHMENT12_EXT                                0x8CEC
+#define GL_COLOR_ATTACHMENT13_EXT                                0x8CED
+#define GL_COLOR_ATTACHMENT14_EXT                                0x8CEE
+#define GL_COLOR_ATTACHMENT15_EXT                                0x8CEF
+#define GL_MAX_COLOR_ATTACHMENTS_EXT                             0x8CDF
+#endif
+
 /* GL_NV_fbo_color_attachments */
 #ifndef GL_NV_fbo_color_attachments
 #define GL_MAX_COLOR_ATTACHMENTS_NV                             0x8CDF
 /* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */
 #endif
 
 /* GL_NV_fence */
 #ifndef GL_NV_fence
@@ -1326,16 +1364,24 @@ typedef void (GL_APIENTRYP PFNGLCOVERAGE
 #ifndef GL_NV_draw_buffers
 #define GL_NV_draw_buffers 1
 #ifdef GL_GLEXT_PROTOTYPES
 GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs);
 #endif
 typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);
 #endif
 
+#ifndef GL_EXT_draw_buffers
+#define GL_EXT_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs);
+#endif
+typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs);
+#endif
+
 /* GL_NV_fbo_color_attachments */
 #ifndef GL_NV_fbo_color_attachments
 #define GL_NV_fbo_color_attachments 1
 #endif
 
 /* GL_NV_fence */
 #ifndef GL_NV_fence
 #define GL_NV_fence 1
--- a/gfx/angle/include/GLSLANG/ShaderLang.h
+++ b/gfx/angle/include/GLSLANG/ShaderLang.h
@@ -1,10 +1,10 @@
 //
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 #ifndef _COMPILER_INTERFACE_INCLUDED_
 #define _COMPILER_INTERFACE_INCLUDED_
 
 #if defined(COMPONENT_BUILD)
 #if defined(_WIN32) || defined(_WIN64)
@@ -73,19 +73,21 @@ typedef enum {
   // It may also perform additional operations like varying assignment, texture
   // access, and gl_FragColor assignment in order to implement the CSS Shaders
   // blend modes.
   //
   SH_CSS_SHADERS_SPEC = 0x8B42
 } ShShaderSpec;
 
 typedef enum {
-  SH_ESSL_OUTPUT = 0x8B45,
-  SH_GLSL_OUTPUT = 0x8B46,
-  SH_HLSL_OUTPUT = 0x8B47
+  SH_ESSL_OUTPUT   = 0x8B45,
+  SH_GLSL_OUTPUT   = 0x8B46,
+  SH_HLSL_OUTPUT   = 0x8B47,
+  SH_HLSL9_OUTPUT  = 0x8B47,
+  SH_HLSL11_OUTPUT = 0x8B48
 } ShShaderOutput;
 
 typedef enum {
   SH_NONE           = 0,
   SH_INT            = 0x1404,
   SH_FLOAT          = 0x1406,
   SH_FLOAT_VEC2     = 0x8B50,
   SH_FLOAT_VEC3     = 0x8B51,
@@ -111,17 +113,18 @@ typedef enum {
   SH_OBJECT_CODE_LENGTH          =  0x8B88,  // GL_SHADER_SOURCE_LENGTH
   SH_ACTIVE_UNIFORMS             =  0x8B86,
   SH_ACTIVE_UNIFORM_MAX_LENGTH   =  0x8B87,
   SH_ACTIVE_ATTRIBUTES           =  0x8B89,
   SH_ACTIVE_ATTRIBUTE_MAX_LENGTH =  0x8B8A,
   SH_MAPPED_NAME_MAX_LENGTH      =  0x6000,
   SH_NAME_MAX_LENGTH             =  0x6001,
   SH_HASHED_NAME_MAX_LENGTH      =  0x6002,
-  SH_HASHED_NAMES_COUNT          =  0x6003
+  SH_HASHED_NAMES_COUNT          =  0x6003,
+  SH_ACTIVE_UNIFORMS_ARRAY       =  0x6004
 } ShShaderInfo;
 
 // Compile options.
 typedef enum {
   SH_VALIDATE                = 0,
   SH_VALIDATE_LOOP_INDEXING  = 0x0001,
   SH_INTERMEDIATE_TREE       = 0x0002,
   SH_OBJECT_CODE             = 0x0004,
@@ -154,17 +157,23 @@ typedef enum {
   SH_ENFORCE_PACKING_RESTRICTIONS = 0x0800,
 
   // This flag ensures all indirect (expression-based) array indexing
   // is clamped to the bounds of the array. This ensures, for example,
   // that you cannot read off the end of a uniform, whether an array
   // vec234, or mat234 type. The ShArrayIndexClampingStrategy enum,
   // specified in the ShBuiltInResources when constructing the
   // compiler, selects the strategy for the clamping implementation.
-  SH_CLAMP_INDIRECT_ARRAY_BOUNDS = 0x1000
+  SH_CLAMP_INDIRECT_ARRAY_BOUNDS = 0x1000,
+
+  // This flag limits the complexity of an expression.
+  SH_LIMIT_EXPRESSION_COMPLEXITY = 0x2000,
+
+  // This flag limits the depth of the call stack.
+  SH_LIMIT_CALL_STACK_DEPTH = 0x4000,
 } ShCompileOptions;
 
 // Defines alternate strategies for implementing array index clamping.
 typedef enum {
   // Use the clamp intrinsic for array index clamping.
   SH_CLAMP_WITH_CLAMP_INTRINSIC = 1,
 
   // Use a user-defined function for array index clamping.
@@ -204,29 +213,36 @@ typedef struct
     int MaxDrawBuffers;
 
     // Extensions.
     // Set to 1 to enable the extension, else 0.
     int OES_standard_derivatives;
     int OES_EGL_image_external;
     int ARB_texture_rectangle;
     int EXT_draw_buffers;
+    int EXT_frag_depth;
 
     // Set to 1 if highp precision is supported in the fragment language.
     // Default is 0.
     int FragmentPrecisionHigh;
 
     // Name Hashing.
     // Set a 64 bit hash function to enable user-defined name hashing.
     // Default is NULL.
     ShHashFunction64 HashFunction;
 
     // Selects a strategy to use when implementing array index clamping.
     // Default is SH_CLAMP_WITH_CLAMP_INTRINSIC.
     ShArrayIndexClampingStrategy ArrayIndexClampingStrategy;
+
+    // The maximum complexity an expression can be.
+    int MaxExpressionComplexity;
+
+    // The maximum depth a call stack can be.
+    int MaxCallStackDepth;
 } ShBuiltInResources;
 
 //
 // Initialize built-in resources with minimum expected values.
 //
 COMPILER_EXPORT void ShInitBuiltInResources(ShBuiltInResources* resources);
 
 //
@@ -243,17 +259,17 @@ typedef void* ShHandle;
 //
 // Returns the handle of constructed compiler, null if the requested compiler is
 // not supported.
 // Parameters:
 // type: Specifies the type of shader - SH_FRAGMENT_SHADER or SH_VERTEX_SHADER.
 // spec: Specifies the language spec the compiler must conform to -
 //       SH_GLES2_SPEC or SH_WEBGL_SPEC.
 // output: Specifies the output code type - SH_ESSL_OUTPUT, SH_GLSL_OUTPUT,
-//         or SH_HLSL_OUTPUT.
+//         SH_HLSL9_OUTPUT or SH_HLSL11_OUTPUT.
 // resources: Specifies the built-in resources.
 COMPILER_EXPORT ShHandle ShConstructCompiler(
     ShShaderType type,
     ShShaderSpec spec,
     ShShaderOutput output,
     const ShBuiltInResources* resources);
 COMPILER_EXPORT void ShDestruct(ShHandle handle);
 
@@ -406,13 +422,25 @@ COMPILER_EXPORT void ShGetActiveUniform(
 //             memory to accomodate the name. The size of the buffer required
 //             to store the name can be obtained by calling ShGetInfo with
 //             SH_HASHED_NAME_MAX_LENGTH.
 COMPILER_EXPORT void ShGetNameHashingEntry(const ShHandle handle,
                                            int index,
                                            char* name,
                                            char* hashedName);
 
+// Returns a parameter from a compiled shader.
+// Parameters:
+// handle: Specifies the compiler
+// pname: Specifies the parameter to query.
+// The following parameters are defined:
+// SH_ACTIVE_UNIFORMS_ARRAY: an STL vector of active uniforms. Valid only for
+//                           HLSL output.
+// params: Requested parameter
+COMPILER_EXPORT void ShGetInfoPointer(const ShHandle handle,
+                                      ShShaderInfo pname,
+                                      void** params);
+
 #ifdef __cplusplus
 }
 #endif
 
 #endif // _COMPILER_INTERFACE_INCLUDED_
--- a/gfx/angle/moz.build
+++ b/gfx/angle/moz.build
@@ -29,22 +29,25 @@ CPP_SOURCES += [
     'Lexer.cpp',
     'Macro.cpp',
     'MacroExpander.cpp',
     'Preprocessor.cpp',
     'Token.cpp',
     'Tokenizer.cpp',
 ]
 
+
+# Target: 'translator_common'
+#   Requires: 'preprocessor'
 # src/compiler:
 CPP_SOURCES += [
     'BuiltInFunctionEmulator.cpp',
     'Compiler.cpp',
     'compiler_debug.cpp',
-    'DetectRecursion.cpp',
+    'DetectCallDepth.cpp',
     'Diagnostics.cpp',
     'DirectiveHandler.cpp',
     'ForLoopUnroll.cpp',
     'glslang_lex.cpp',
     'glslang_tab.cpp',
     'InfoSink.cpp',
     'Initialize.cpp',
     'InitializeDll.cpp',
@@ -53,18 +56,18 @@ CPP_SOURCES += [
     'intermOut.cpp',
     'IntermTraverse.cpp',
     'MapLongVariableNames.cpp',
     'parseConst.cpp',
     'ParseHelper.cpp',
     'PoolAlloc.cpp',
     'QualifierAlive.cpp',
     'RemoveTree.cpp',
-    'spooky.cpp',
     'SymbolTable.cpp',
+    'CompilerUniform.cpp',
     'util.cpp',
     'ValidateLimitations.cpp',
     'VariableInfo.cpp',
     'VariablePacker.cpp',
 ]
 
 # src/compiler/depgraph:
 CPP_SOURCES += [
@@ -80,37 +83,40 @@ CPP_SOURCES += [
     'RestrictVertexShaderTiming.cpp',
 ]
 
 # src/third_party/compiler:
 CPP_SOURCES += [
     'ArrayBoundsClamper.cpp',
 ]
 
+# src/third_party/murmurhash:
+CPP_SOURCES += [
+    'MurmurHash3.cpp',
+]
+
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     CPP_SOURCES += [
         'ossource_win.cpp',
     ]
 else:
     CPP_SOURCES += [
         'ossource_posix.cpp',
     ]
 
+
 # Target: 'translator_glsl'
 #   Requires: 'translator_common'
 # src/compiler:
 CPP_SOURCES += [
     'CodeGenGLSL.cpp',
     'OutputESSL.cpp',
     'OutputGLSLBase.cpp',
     'OutputGLSL.cpp',
     'ShaderLang.cpp',
     'TranslatorESSL.cpp',
     'TranslatorGLSL.cpp',
     'VersionGLSL.cpp',
 ]
 
 LIBRARY_NAME = 'angle'
-
 LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
-
deleted file mode 100644
--- a/gfx/angle/src/ANGLE.sln
+++ /dev/null
@@ -1,66 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual C++ Express 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libEGL", "libEGL\libEGL.vcxproj", "{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLESv2", "libGLESv2\libGLESv2.vcxproj", "{B5871A7A-968C-42E3-A33B-981E6F448E78}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_hlsl", "compiler\translator_hlsl.vcxproj", "{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_common", "compiler\translator_common.vcxproj", "{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "preprocessor", "compiler\preprocessor\preprocessor.vcxproj", "{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Debug|x64 = Debug|x64
-		Release|Win32 = Release|Win32
-		Release|x64 = Release|x64
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|Win32.ActiveCfg = Debug|Win32
-		{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|Win32.Build.0 = Debug|Win32
-		{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|x64.ActiveCfg = Debug|x64
-		{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|x64.Build.0 = Debug|x64
-		{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|Win32.ActiveCfg = Release|Win32
-		{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|Win32.Build.0 = Release|Win32
-		{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|x64.ActiveCfg = Release|x64
-		{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|x64.Build.0 = Release|x64
-		{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.ActiveCfg = Debug|Win32
-		{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.Build.0 = Debug|Win32
-		{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|x64.ActiveCfg = Debug|x64
-		{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|x64.Build.0 = Debug|x64
-		{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.ActiveCfg = Release|Win32
-		{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.Build.0 = Release|Win32
-		{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|x64.ActiveCfg = Release|x64
-		{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|x64.Build.0 = Release|x64
-		{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.ActiveCfg = Debug|Win32
-		{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.Build.0 = Debug|Win32
-		{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|x64.ActiveCfg = Debug|x64
-		{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|x64.Build.0 = Debug|x64
-		{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.ActiveCfg = Release|Win32
-		{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.Build.0 = Release|Win32
-		{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|x64.ActiveCfg = Release|x64
-		{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|x64.Build.0 = Release|x64
-		{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.ActiveCfg = Debug|Win32
-		{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.Build.0 = Debug|Win32
-		{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|x64.ActiveCfg = Debug|x64
-		{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|x64.Build.0 = Debug|x64
-		{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|Win32.ActiveCfg = Release|Win32
-		{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|Win32.Build.0 = Release|Win32
-		{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|x64.ActiveCfg = Release|x64
-		{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|x64.Build.0 = Release|x64
-		{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Debug|Win32.ActiveCfg = Debug|Win32
-		{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Debug|Win32.Build.0 = Debug|Win32
-		{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Debug|x64.ActiveCfg = Debug|x64
-		{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Debug|x64.Build.0 = Debug|x64
-		{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Release|Win32.ActiveCfg = Release|Win32
-		{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Release|Win32.Build.0 = Release|Win32
-		{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Release|x64.ActiveCfg = Release|x64
-		{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Release|x64.Build.0 = Release|x64
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
--- a/gfx/angle/src/build_angle.gypi
+++ b/gfx/angle/src/build_angle.gypi
@@ -67,18 +67,18 @@
         'compiler/BaseTypes.h',
         'compiler/BuiltInFunctionEmulator.cpp',
         'compiler/BuiltInFunctionEmulator.h',
         'compiler/Common.h',
         'compiler/Compiler.cpp',
         'compiler/ConstantUnion.h',
         'compiler/debug.cpp',
         'compiler/debug.h',
-        'compiler/DetectRecursion.cpp',
-        'compiler/DetectRecursion.h',
+        'compiler/DetectCallDepth.cpp',
+        'compiler/DetectCallDepth.h',
         'compiler/Diagnostics.h',
         'compiler/Diagnostics.cpp',
         'compiler/DirectiveHandler.h',
         'compiler/DirectiveHandler.cpp',
         'compiler/ExtensionBehavior.h',
         'compiler/ForLoopUnroll.cpp',
         'compiler/ForLoopUnroll.h',
         'compiler/glslang.h',
@@ -113,16 +113,18 @@
         'compiler/QualifierAlive.h',
         'compiler/RemoveTree.cpp',
         'compiler/RemoveTree.h',
         'compiler/RenameFunction.h',
         'compiler/ShHandle.h',
         'compiler/SymbolTable.cpp',
         'compiler/SymbolTable.h',
         'compiler/Types.h',
+        'compiler/Uniform.cpp',
+        'compiler/Uniform.h',
         'compiler/util.cpp',
         'compiler/util.h',
         'compiler/ValidateLimitations.cpp',
         'compiler/ValidateLimitations.h',
         'compiler/VariableInfo.cpp',
         'compiler/VariableInfo.h',
         'compiler/VariablePacker.cpp',
         'compiler/VariablePacker.h',
@@ -216,38 +218,36 @@
         },
         {
           'target_name': 'libGLESv2',
           'type': 'shared_library',
           'dependencies': ['translator_hlsl'],
           'include_dirs': [
             '.',
             '../include',
+            'libGLESv2',
           ],
           'sources': [
+            'third_party/murmurhash/MurmurHash3.h',
+            'third_party/murmurhash/MurmurHash3.cpp',
             'common/angleutils.h',
             'common/debug.cpp',
             'common/debug.h',
             'common/RefCountObject.cpp',
             'common/RefCountObject.h',
             'common/version.h',
-            'libGLESv2/IndexDataManager.cpp',
-            'libGLESv2/IndexDataManager.h',
-            'libGLESv2/vertexconversion.h',
-            'libGLESv2/VertexDataManager.cpp',
-            'libGLESv2/VertexDataManager.h',
+            'libGLESv2/precompiled.h',
+            'libGLESv2/precompiled.cpp',
             'libGLESv2/BinaryStream.h',
-            'libGLESv2/Blit.cpp',
-            'libGLESv2/Blit.h',
             'libGLESv2/Buffer.cpp',
             'libGLESv2/Buffer.h',
+            'libGLESv2/constants.h',
             'libGLESv2/Context.cpp',
             'libGLESv2/Context.h',
-            'libGLESv2/D3DConstantTable.cpp',
-            'libGLESv2/D3DConstantTable.h',
+            'libGLESv2/angletypes.h',
             'libGLESv2/Fence.cpp',
             'libGLESv2/Fence.h',
             'libGLESv2/Float16ToFloat32.cpp',
             'libGLESv2/Framebuffer.cpp',
             'libGLESv2/Framebuffer.h',
             'libGLESv2/HandleAllocator.cpp',
             'libGLESv2/HandleAllocator.h',
             'libGLESv2/libGLESv2.cpp',
@@ -259,43 +259,129 @@
             'libGLESv2/Program.cpp',
             'libGLESv2/Program.h',
             'libGLESv2/ProgramBinary.cpp',
             'libGLESv2/ProgramBinary.h',
             'libGLESv2/Query.h',
             'libGLESv2/Query.cpp',
             'libGLESv2/Renderbuffer.cpp',
             'libGLESv2/Renderbuffer.h',
+            'libGLESv2/renderer/Blit.cpp',
+            'libGLESv2/renderer/Blit.h',
+            'libGLESv2/renderer/BufferStorage.h',
+            'libGLESv2/renderer/BufferStorage.cpp',
+            'libGLESv2/renderer/BufferStorage9.cpp',
+            'libGLESv2/renderer/BufferStorage9.h',
+            'libGLESv2/renderer/BufferStorage11.cpp',
+            'libGLESv2/renderer/BufferStorage11.h',
+            'libGLESv2/renderer/FenceImpl.h',
+            'libGLESv2/renderer/Fence9.cpp',
+            'libGLESv2/renderer/Fence9.h',
+            'libGLESv2/renderer/Fence11.cpp',
+            'libGLESv2/renderer/Fence11.h',
+            'libGLESv2/renderer/generatemip.h',
+            'libGLESv2/renderer/Image.cpp',
+            'libGLESv2/renderer/Image.h',
+            'libGLESv2/renderer/Image11.cpp',
+            'libGLESv2/renderer/Image11.h',
+            'libGLESv2/renderer/Image9.cpp',
+            'libGLESv2/renderer/Image9.h',
+            'libGLESv2/renderer/ImageSSE2.cpp',
+            'libGLESv2/renderer/IndexBuffer.cpp',
+            'libGLESv2/renderer/IndexBuffer.h',
+            'libGLESv2/renderer/IndexBuffer9.cpp',
+            'libGLESv2/renderer/IndexBuffer9.h',
+            'libGLESv2/renderer/IndexBuffer11.cpp',
+            'libGLESv2/renderer/IndexBuffer11.h',
+            'libGLESv2/renderer/IndexDataManager.cpp',
+            'libGLESv2/renderer/IndexDataManager.h',
+            'libGLESv2/renderer/IndexRangeCache.cpp',
+            'libGLESv2/renderer/IndexRangeCache.h',
+            'libGLESv2/renderer/InputLayoutCache.cpp',
+            'libGLESv2/renderer/InputLayoutCache.h',
+            'libGLESv2/renderer/QueryImpl.h',
+            'libGLESv2/renderer/Query9.cpp',
+            'libGLESv2/renderer/Query9.h',
+            'libGLESv2/renderer/Query11.cpp',
+            'libGLESv2/renderer/Query11.h',
+            'libGLESv2/renderer/Renderer.cpp',
+            'libGLESv2/renderer/Renderer.h',
+            'libGLESv2/renderer/Renderer11.cpp',
+            'libGLESv2/renderer/Renderer11.h',
+            'libGLESv2/renderer/renderer11_utils.cpp',
+            'libGLESv2/renderer/renderer11_utils.h',
+            'libGLESv2/renderer/Renderer9.cpp',
+            'libGLESv2/renderer/Renderer9.h',
+            'libGLESv2/renderer/renderer9_utils.cpp',
+            'libGLESv2/renderer/renderer9_utils.h',
+            'libGLESv2/renderer/RenderStateCache.cpp',
+            'libGLESv2/renderer/RenderStateCache.h',
+            'libGLESv2/renderer/RenderTarget.h',
+            'libGLESv2/renderer/RenderTarget11.h',
+            'libGLESv2/renderer/RenderTarget11.cpp',
+            'libGLESv2/renderer/RenderTarget9.h',
+            'libGLESv2/renderer/RenderTarget9.cpp',
+            'libGLESv2/renderer/ShaderCache.h',
+            'libGLESv2/renderer/ShaderExecutable.h',
+            'libGLESv2/renderer/ShaderExecutable9.cpp',
+            'libGLESv2/renderer/ShaderExecutable9.h',
+            'libGLESv2/renderer/ShaderExecutable11.cpp',
+            'libGLESv2/renderer/ShaderExecutable11.h',
+            'libGLESv2/renderer/SwapChain.h',
+            'libGLESv2/renderer/SwapChain9.cpp',
+            'libGLESv2/renderer/SwapChain9.h',
+            'libGLESv2/renderer/SwapChain11.cpp',
+            'libGLESv2/renderer/SwapChain11.h',
+            'libGLESv2/renderer/TextureStorage.cpp',
+            'libGLESv2/renderer/TextureStorage.h',
+            'libGLESv2/renderer/TextureStorage11.cpp',
+            'libGLESv2/renderer/TextureStorage11.h',
+            'libGLESv2/renderer/TextureStorage9.cpp',
+            'libGLESv2/renderer/TextureStorage9.h',
+            'libGLESv2/renderer/VertexBuffer.cpp',
+            'libGLESv2/renderer/VertexBuffer.h',
+            'libGLESv2/renderer/VertexBuffer9.cpp',
+            'libGLESv2/renderer/VertexBuffer9.h',
+            'libGLESv2/renderer/VertexBuffer11.cpp',
+            'libGLESv2/renderer/VertexBuffer11.h',
+            'libGLESv2/renderer/vertexconversion.h',
+            'libGLESv2/renderer/VertexDataManager.cpp',
+            'libGLESv2/renderer/VertexDataManager.h',
+            'libGLESv2/renderer/VertexDeclarationCache.cpp',
+            'libGLESv2/renderer/VertexDeclarationCache.h',
             'libGLESv2/ResourceManager.cpp',
             'libGLESv2/ResourceManager.h',
             'libGLESv2/Shader.cpp',
             'libGLESv2/Shader.h',
             'libGLESv2/Texture.cpp',
-            'libGLESv2/TextureSSE2.cpp',
             'libGLESv2/Texture.h',
+            'libGLESv2/Uniform.cpp',
+            'libGLESv2/Uniform.h',
             'libGLESv2/utilities.cpp',
             'libGLESv2/utilities.h',
           ],
           # TODO(jschuh): http://crbug.com/167187 size_t -> int
           'msvs_disabled_warnings': [ 4267 ],
           'msvs_settings': {
             'VCLinkerTool': {
               'AdditionalDependencies': [
                 'd3d9.lib',
+                'dxguid.lib',
               ],
             }
           },
         },
         {
           'target_name': 'libEGL',
           'type': 'shared_library',
           'dependencies': ['libGLESv2'],
           'include_dirs': [
             '.',
             '../include',
+            'libGLESv2',
           ],
           'sources': [
             'common/angleutils.h',
             'common/debug.cpp',
             'common/debug.h',
             'common/RefCountObject.cpp',
             'common/RefCountObject.h',
             'common/version.h',
@@ -312,17 +398,16 @@
             'libEGL/Surface.h',
           ],
           # TODO(jschuh): http://crbug.com/167187 size_t -> int
           'msvs_disabled_warnings': [ 4267 ],
           'msvs_settings': {
             'VCLinkerTool': {
               'AdditionalDependencies': [
                 'd3d9.lib',
-                'dxguid.lib',
               ],
             }
           },
         },
       ],
     }],
   ],
 }
--- a/gfx/angle/src/common/RefCountObject.cpp
+++ b/gfx/angle/src/common/RefCountObject.cpp
@@ -1,8 +1,9 @@
+#include "precompiled.h"
 //
 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
 // RefCountObject.cpp: Defines the gl::RefCountObject base class that provides
 // lifecycle support for GL objects using the traditional BindObject scheme, but
--- a/gfx/angle/src/common/angleutils.h
+++ b/gfx/angle/src/common/angleutils.h
@@ -4,23 +4,53 @@
 // found in the LICENSE file.
 //
 
 // angleutils.h: Common ANGLE utilities.
 
 #ifndef COMMON_ANGLEUTILS_H_
 #define COMMON_ANGLEUTILS_H_
 
+#include <stddef.h>
+
 // A macro to disallow the copy constructor and operator= functions
 // This must be used in the private: declarations for a class
 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
   TypeName(const TypeName&);               \
   void operator=(const TypeName&)
 
+template <typename T, unsigned int N>
+inline unsigned int ArraySize(T(&)[N])
+{
+    return N;
+}
+
+template <typename T, unsigned int N>
+void SafeRelease(T (&resourceBlock)[N])
+{
+    for (unsigned int i = 0; i < N; i++)
+    {
+        SafeRelease(resourceBlock[i]);
+    }
+}
+
+template <typename T>
+void SafeRelease(T& resource)
+{
+    if (resource)
+    {
+        resource->Release();
+        resource = NULL;
+    }
+}
+
 #if defined(_MSC_VER)
 #define snprintf _snprintf
 #endif
 
 #define VENDOR_ID_AMD 0x1002
 #define VENDOR_ID_INTEL 0x8086
 #define VENDOR_ID_NVIDIA 0x10DE
 
+#define GL_BGRA4_ANGLEX 0x6ABC
+#define GL_BGR5_A1_ANGLEX 0x6ABD
+
 #endif // COMMON_ANGLEUTILS_H_
--- a/gfx/angle/src/common/debug.cpp
+++ b/gfx/angle/src/common/debug.cpp
@@ -2,20 +2,16 @@
 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
 // debug.cpp: Debugging utilities.
 
 #include "common/debug.h"
-
-#include <stdio.h>
-#include <stdarg.h>
-
 #include "common/system.h"
 #include <d3d9.h>
 
 namespace gl
 {
 
 typedef void (WINAPI *PerfOutputFunction)(D3DCOLOR, LPCWSTR);
 
--- a/gfx/angle/src/common/debug.h
+++ b/gfx/angle/src/common/debug.h
@@ -94,12 +94,19 @@ namespace gl
 #define UNREACHABLE() do { \
     ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \
     assert(false); \
     } while(0)
 #else
     #define UNREACHABLE() ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__)
 #endif
 
+// A macro that determines whether an object has a given runtime type.
+#if !defined(NDEBUG) && (!defined(_MSC_VER) || defined(_CPPRTTI))
+#define HAS_DYNAMIC_TYPE(type, obj) (dynamic_cast<type >(obj) != NULL)
+#else
+#define HAS_DYNAMIC_TYPE(type, obj) true
+#endif
+
 // A macro functioning as a compile-time assert to validate constant conditions
 #define META_ASSERT(condition) typedef int COMPILE_TIME_ASSERT_##__LINE__[static_cast<bool>(condition)?1:-1]
 
 #endif   // COMMON_DEBUG_H_
--- a/gfx/angle/src/common/system.h
+++ b/gfx/angle/src/common/system.h
@@ -9,20 +9,16 @@
 #ifndef COMMON_SYSTEM_H
 #define COMMON_SYSTEM_H
 
 #if !defined(WIN32_LEAN_AND_MEAN)
 #define WIN32_LEAN_AND_MEAN
 #endif
 
 #include <windows.h>
-#include <d3d9.h>
-#include <d3dcompiler.h>
-#include <d3d9types.h>
-#include <mmsystem.h>
 
 #if defined(min)
 #undef min
 #endif
 
 #if defined(max)
 #undef max
 #endif
--- a/gfx/angle/src/common/version.h
+++ b/gfx/angle/src/common/version.h
@@ -1,12 +1,12 @@
 #define MAJOR_VERSION 1
-#define MINOR_VERSION 0
+#define MINOR_VERSION 2
 #define BUILD_VERSION 0
-#define BUILD_REVISION 2040
+#define BUILD_REVISION 2431
 
 #define STRINGIFY(x) #x
 #define MACRO_STRINGIFY(x) STRINGIFY(x)
 
 #define REVISION_STRING MACRO_STRINGIFY(BUILD_REVISION)
 #define VERSION_STRING MACRO_STRINGIFY(MAJOR_VERSION) "." MACRO_STRINGIFY(MINOR_VERSION) "." MACRO_STRINGIFY(BUILD_VERSION) "." MACRO_STRINGIFY(BUILD_REVISION)
 
 #define VERSION_DWORD ((MAJOR_VERSION << 24) | (MINOR_VERSION << 16) | BUILD_REVISION)
new file mode 100644
--- /dev/null
+++ b/gfx/angle/src/compiler/64bit-lexer-safety.patch
@@ -0,0 +1,177 @@
+--- a/src/compiler/glslang_lex.cpp
++++ b/src/compiler/glslang_lex.cpp
+@@ -68,6 +68,7 @@ typedef int16_t flex_int16_t;
+ typedef uint16_t flex_uint16_t;
+ typedef int32_t flex_int32_t;
+ typedef uint32_t flex_uint32_t;
++typedef uint64_t flex_uint64_t;
+ #else
+ typedef signed char flex_int8_t;
+ typedef short int flex_int16_t;
+@@ -191,6 +192,11 @@ typedef void* yyscan_t;
+ typedef struct yy_buffer_state *YY_BUFFER_STATE;
+ #endif
+ 
++#ifndef YY_TYPEDEF_YY_SIZE_T
++#define YY_TYPEDEF_YY_SIZE_T
++typedef size_t yy_size_t;
++#endif
++
+ #define EOB_ACT_CONTINUE_SCAN 0
+ #define EOB_ACT_END_OF_FILE 1
+ #define EOB_ACT_LAST_MATCH 2
+@@ -204,7 +210,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
+      */
+     #define  YY_LESS_LINENO(n) \
+             do { \
+-                int yyl;\
++                yy_size_t yyl;\
+                 for ( yyl = n; yyl < yyleng; ++yyl )\
+                     if ( yytext[yyl] == '\n' )\
+                         --yylineno;\
+@@ -226,11 +232,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
+ 
+ #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
+ 
+-#ifndef YY_TYPEDEF_YY_SIZE_T
+-#define YY_TYPEDEF_YY_SIZE_T
+-typedef size_t yy_size_t;
+-#endif
+-
+ #ifndef YY_STRUCT_YY_BUFFER_STATE
+ #define YY_STRUCT_YY_BUFFER_STATE
+ struct yy_buffer_state
+@@ -248,7 +249,7 @@ struct yy_buffer_state
+ 	/* Number of characters read into yy_ch_buf, not including EOB
+ 	 * characters.
+ 	 */
+-	int yy_n_chars;
++	yy_size_t yy_n_chars;
+ 
+ 	/* Whether we "own" the buffer - i.e., we know we created it,
+ 	 * and can realloc() it to grow it, and should free() it to
+@@ -327,7 +328,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
+ 
+ YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
+ YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
+-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
++YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
+ 
+ void *yyalloc (yy_size_t ,yyscan_t yyscanner );
+ void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
+@@ -378,7 +379,7 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
+  */
+ #define YY_DO_BEFORE_ACTION \
+ 	yyg->yytext_ptr = yy_bp; \
+-	yyleng = (size_t) (yy_cp - yy_bp); \
++	yyleng = (yy_size_t) (yy_cp - yy_bp); \
+ 	yyg->yy_hold_char = *yy_cp; \
+ 	*yy_cp = '\0'; \
+ 	yyg->yy_c_buf_p = yy_cp;
+@@ -1035,8 +1036,8 @@ struct yyguts_t
+     size_t yy_buffer_stack_max; /**< capacity of stack. */
+     YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
+     char yy_hold_char;
+-    int yy_n_chars;
+-    int yyleng_r;
++    yy_size_t yy_n_chars;
++    yy_size_t yyleng_r;
+     char *yy_c_buf_p;
+     int yy_init;
+     int yy_start;
+@@ -1089,7 +1090,7 @@ FILE *yyget_out (yyscan_t yyscanner );
+ 
+ void yyset_out  (FILE * out_str ,yyscan_t yyscanner );
+ 
+-int yyget_leng (yyscan_t yyscanner );
++yy_size_t yyget_leng (yyscan_t yyscanner );
+ 
+ char *yyget_text (yyscan_t yyscanner );
+ 
+@@ -1158,7 +1159,7 @@ static int input (yyscan_t yyscanner );
+ 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ 		{ \
+ 		int c = '*'; \
+-		int n; \
++		yy_size_t n; \
+ 		for ( n = 0; n < max_size && \
+ 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+ 			buf[n] = (char) c; \
+@@ -1317,7 +1318,7 @@ yy_find_action:
+ 
+ 		if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
+ 			{
+-			int yyl;
++			yy_size_t yyl;
+ 			for ( yyl = 0; yyl < yyleng; ++yyl )
+ 				if ( yytext[yyl] == '\n' )
+ 					   
+@@ -2203,7 +2204,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
+ 
+ 	else
+ 		{
+-			int num_to_read =
++			yy_size_t num_to_read =
+ 			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+ 
+ 		while ( num_to_read <= 0 )
+@@ -2217,7 +2218,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
+ 
+ 			if ( b->yy_is_our_buffer )
+ 				{
+-				int new_size = b->yy_buf_size * 2;
++				yy_size_t new_size = b->yy_buf_size * 2;
+ 
+ 				if ( new_size <= 0 )
+ 					b->yy_buf_size += b->yy_buf_size / 8;
+@@ -2248,7 +2249,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
+ 
+ 		/* Read in more data. */
+ 		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+-			yyg->yy_n_chars, (size_t) num_to_read );
++			yyg->yy_n_chars, num_to_read );
+ 
+ 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+ 		}
+@@ -2373,7 +2374,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
+ 
+ 		else
+ 			{ /* need more input */
+-			int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
++			yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+ 			++yyg->yy_c_buf_p;
+ 
+ 			switch ( yy_get_next_buffer( yyscanner ) )
+@@ -2660,7 +2661,7 @@ void yypop_buffer_state (yyscan_t yyscanner)
+  */
+ static void yyensure_buffer_stack (yyscan_t yyscanner)
+ {
+-	int num_to_alloc;
++	yy_size_t num_to_alloc;
+     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ 
+ 	if (!yyg->yy_buffer_stack) {
+@@ -2758,12 +2759,11 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
+  * @param yyscanner The scanner object.
+  * @return the newly allocated buffer state object.
+  */
+-YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
++YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len , yyscan_t yyscanner)
+ {
+ 	YY_BUFFER_STATE b;
+ 	char *buf;
+-	yy_size_t n;
+-	int i;
++	yy_size_t n, i;
+     
+ 	/* Get memory for full buffer, including space for trailing EOB's. */
+ 	n = _yybytes_len + 2;
+@@ -2913,7 +2913,7 @@ FILE *yyget_out  (yyscan_t yyscanner)
+ /** Get the length of the current token.
+  * @param yyscanner The scanner object.
+  */
+-int yyget_leng  (yyscan_t yyscanner)
++yy_size_t yyget_leng  (yyscan_t yyscanner)
+ {
+     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+     return yyleng;
--- a/gfx/angle/src/compiler/BaseTypes.h
+++ b/gfx/angle/src/compiler/BaseTypes.h
@@ -85,20 +85,16 @@ enum TQualifier
     EvqConst,         // User defined constants and non-output parameters in functions
     EvqAttribute,     // Readonly
     EvqVaryingIn,     // readonly, fragment shaders only
     EvqVaryingOut,    // vertex shaders only  read/write
     EvqInvariantVaryingIn,     // readonly, fragment shaders only
     EvqInvariantVaryingOut,    // vertex shaders only  read/write
     EvqUniform,       // Readonly, vertex and fragment
 
-    // pack/unpack input and output
-    EvqInput,
-    EvqOutput,
-
     // parameters
     EvqIn,
     EvqOut,
     EvqInOut,
     EvqConstReadOnly,
 
     // built-ins written by vertex shader
     EvqPosition,
@@ -107,16 +103,17 @@ enum TQualifier
     // built-ins read by fragment shader
     EvqFragCoord,
     EvqFrontFacing,
     EvqPointCoord,
 
     // built-ins written by fragment shader
     EvqFragColor,
     EvqFragData,
+    EvqFragDepth,
 
     // end of list
     EvqLast
 };
 
 //
 // This is just for debug print out, carried along with the definitions above.
 //
@@ -132,21 +129,20 @@ inline const char* getQualifierString(TQ
     case EvqVaryingIn:      return "varying";        break;
     case EvqVaryingOut:     return "varying";        break;
     case EvqInvariantVaryingIn: return "invariant varying";	break;
     case EvqInvariantVaryingOut:return "invariant varying";	break;
     case EvqUniform:        return "uniform";        break;
     case EvqIn:             return "in";             break;
     case EvqOut:            return "out";            break;
     case EvqInOut:          return "inout";          break;
-    case EvqInput:          return "input";          break;
-    case EvqOutput:         return "output";         break;
     case EvqPosition:       return "Position";       break;
     case EvqPointSize:      return "PointSize";      break;
     case EvqFragCoord:      return "FragCoord";      break;
     case EvqFrontFacing:    return "FrontFacing";    break;
     case EvqFragColor:      return "FragColor";      break;
     case EvqFragData:       return "FragData";      break;
+    case EvqFragDepth:      return "FragDepth";     break;
     default:                return "unknown qualifier";
     }
 }
 
 #endif // _BASICTYPES_INCLUDED_
--- a/gfx/angle/src/compiler/CodeGenHLSL.cpp
+++ b/gfx/angle/src/compiler/CodeGenHLSL.cpp
@@ -1,27 +1,29 @@
 //
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
 #include "compiler/TranslatorHLSL.h"
 
 //
 // This function must be provided to create the actual
 // compile object used by higher level code.  It returns
 // a subclass of TCompiler.
 //
 TCompiler* ConstructCompiler(
     ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
 {
-  switch (output) {
-    case SH_HLSL_OUTPUT:
-      return new TranslatorHLSL(type, spec);
+  switch (output)
+  {
+    case SH_HLSL9_OUTPUT:
+    case SH_HLSL11_OUTPUT:
+      return new TranslatorHLSL(type, spec, output);
     default:
       return NULL;
   }
 }
 
 //
 // Delete the compiler made by ConstructCompiler
 //
--- a/gfx/angle/src/compiler/Common.h
+++ b/gfx/angle/src/compiler/Common.h
@@ -9,57 +9,45 @@
 
 #include <map>
 #include <sstream>
 #include <string>
 #include <vector>
 
 #include "compiler/PoolAlloc.h"
 
-// We need two pieces of information to report errors/warnings - string and
-// line number. We encode these into a single int so that it can be easily
-// incremented/decremented by lexer. The right SOURCE_LOC_LINE_SIZE bits store
-// line number while the rest store the string number. Since the shaders are
-// usually small, we should not run out of memory. SOURCE_LOC_LINE_SIZE
-// can be increased to alleviate this issue.
-typedef int TSourceLoc;
-const unsigned int SOURCE_LOC_LINE_SIZE = 16;  // in bits.
-const unsigned int SOURCE_LOC_LINE_MASK = (1 << SOURCE_LOC_LINE_SIZE) - 1;
-
-inline TSourceLoc EncodeSourceLoc(int string, int line) {
-    return (string << SOURCE_LOC_LINE_SIZE) | (line & SOURCE_LOC_LINE_MASK);
-}
-
-inline void DecodeSourceLoc(TSourceLoc loc, int* string, int* line) {
-    if (string) *string = loc >> SOURCE_LOC_LINE_SIZE;
-    if (line) *line = loc & SOURCE_LOC_LINE_MASK;
-}
+struct TSourceLoc {
+    int first_file;
+    int first_line;
+    int last_file;
+    int last_line;
+};
 
 //
 // Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme.
 //
-#define POOL_ALLOCATOR_NEW_DELETE(A)                                  \
-    void* operator new(size_t s) { return (A).allocate(s); }          \
-    void* operator new(size_t, void *_Where) { return (_Where);	}     \
-    void operator delete(void*) { }                                   \
-    void operator delete(void *, void *) { }                          \
-    void* operator new[](size_t s) { return (A).allocate(s); }        \
-    void* operator new[](size_t, void *_Where) { return (_Where);	} \
-    void operator delete[](void*) { }                                 \
+#define POOL_ALLOCATOR_NEW_DELETE()                                                  \
+    void* operator new(size_t s) { return GetGlobalPoolAllocator()->allocate(s); }   \
+    void* operator new(size_t, void *_Where) { return (_Where); }                    \
+    void operator delete(void*) { }                                                  \
+    void operator delete(void *, void *) { }                                         \
+    void* operator new[](size_t s) { return GetGlobalPoolAllocator()->allocate(s); } \
+    void* operator new[](size_t, void *_Where) { return (_Where); }                  \
+    void operator delete[](void*) { }                                                \
     void operator delete[](void *, void *) { }
 
 //
 // Pool version of string.
 //
 typedef pool_allocator<char> TStringAllocator;
 typedef std::basic_string <char, std::char_traits<char>, TStringAllocator> TString;
 typedef std::basic_ostringstream<char, std::char_traits<char>, TStringAllocator> TStringStream;
 inline TString* NewPoolTString(const char* s)
 {
-	void* memory = GlobalPoolAllocator.allocate(sizeof(TString));
+	void* memory = GetGlobalPoolAllocator()->allocate(sizeof(TString));
 	return new(memory) TString(s);
 }
 
 //
 // Persistent string memory.  Should only be used for strings that survive
 // across compiles.
 //
 #define TPersistString std::string
--- a/gfx/angle/src/compiler/Compiler.cpp
+++ b/gfx/angle/src/compiler/Compiler.cpp
@@ -1,16 +1,16 @@
 //
-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
 #include "compiler/BuiltInFunctionEmulator.h"
-#include "compiler/DetectRecursion.h"
+#include "compiler/DetectCallDepth.h"
 #include "compiler/ForLoopUnroll.h"
 #include "compiler/Initialize.h"
 #include "compiler/InitializeParseContext.h"
 #include "compiler/MapLongVariableNames.h"
 #include "compiler/ParseHelper.h"
 #include "compiler/RenameFunction.h"
 #include "compiler/ShHandle.h"
 #include "compiler/ValidateLimitations.h"
@@ -22,61 +22,16 @@
 #include "third_party/compiler/ArrayBoundsClamper.h"
 
 bool isWebGLBasedSpec(ShShaderSpec spec)
 {
      return spec == SH_WEBGL_SPEC || spec == SH_CSS_SHADERS_SPEC;
 }
 
 namespace {
-bool InitializeSymbolTable(
-    const TBuiltInStrings& builtInStrings,
-    ShShaderType type, ShShaderSpec spec, const ShBuiltInResources& resources,
-    TInfoSink& infoSink, TSymbolTable& symbolTable)
-{
-    TIntermediate intermediate(infoSink);
-    TExtensionBehavior extBehavior;
-    InitExtensionBehavior(resources, extBehavior);
-    // The builtins deliberately don't specify precisions for the function
-    // arguments and return types. For that reason we don't try to check them.
-    TParseContext parseContext(symbolTable, extBehavior, intermediate, type, spec, 0, false, NULL, infoSink);
-    parseContext.fragmentPrecisionHigh = resources.FragmentPrecisionHigh == 1;
-
-    GlobalParseContext = &parseContext;
-
-    assert(symbolTable.isEmpty());       
-    //
-    // Parse the built-ins.  This should only happen once per
-    // language symbol table.
-    //
-    // Push the symbol table to give it an initial scope.  This
-    // push should not have a corresponding pop, so that built-ins
-    // are preserved, and the test for an empty table fails.
-    //
-    symbolTable.push();
-
-    for (TBuiltInStrings::const_iterator i = builtInStrings.begin(); i != builtInStrings.end(); ++i)
-    {
-        const char* builtInShaders = i->c_str();
-        int builtInLengths = static_cast<int>(i->size());
-        if (builtInLengths <= 0)
-          continue;
-
-        if (PaParseStrings(1, &builtInShaders, &builtInLengths, &parseContext) != 0)
-        {
-            infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
-            return false;
-        }
-    }
-
-    IdentifyBuiltIns(type, spec, resources, symbolTable);
-
-    return true;
-}
-
 class TScopedPoolAllocator {
 public:
     TScopedPoolAllocator(TPoolAllocator* allocator, bool pushPop)
         : mAllocator(allocator), mPushPopAllocator(pushPop) {
         if (mPushPopAllocator) mAllocator->push();
         SetGlobalPoolAllocator(mAllocator);
     }
     ~TScopedPoolAllocator() {
@@ -98,16 +53,19 @@ TShHandleBase::TShHandleBase() {
 TShHandleBase::~TShHandleBase() {
     SetGlobalPoolAllocator(NULL);
     allocator.popAll();
 }
 
 TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec)
     : shaderType(type),
       shaderSpec(spec),
+      maxUniformVectors(0),
+      maxExpressionComplexity(0),
+      maxCallStackDepth(0),
       fragmentPrecisionHigh(false),
       clampingStrategy(SH_CLAMP_WITH_CLAMP_INTRINSIC),
       builtInFunctionEmulator(type)
 {
     longNameMap = LongNameMap::GetInstance();
 }
 
 TCompiler::~TCompiler()
@@ -116,16 +74,18 @@ TCompiler::~TCompiler()
     longNameMap->Release();
 }
 
 bool TCompiler::Init(const ShBuiltInResources& resources)
 {
     maxUniformVectors = (shaderType == SH_VERTEX_SHADER) ?
         resources.MaxVertexUniformVectors :
         resources.MaxFragmentUniformVectors;
+    maxExpressionComplexity = resources.MaxExpressionComplexity;
+    maxCallStackDepth = resources.MaxCallStackDepth;
     TScopedPoolAllocator scopedAlloc(&allocator, false);
 
     // Generate built-in symbol table.
     if (!InitBuiltInSymbolTable(resources))
         return false;
     InitExtensionBehavior(resources, extensionBehavior);
     fragmentPrecisionHigh = resources.FragmentPrecisionHigh == 1;
 
@@ -163,34 +123,36 @@ bool TCompiler::compile(const char* cons
         ++firstSource;
     }
 
     TIntermediate intermediate(infoSink);
     TParseContext parseContext(symbolTable, extensionBehavior, intermediate,
                                shaderType, shaderSpec, compileOptions, true,
                                sourcePath, infoSink);
     parseContext.fragmentPrecisionHigh = fragmentPrecisionHigh;
-    GlobalParseContext = &parseContext;
+    SetGlobalParseContext(&parseContext);
 
     // We preserve symbols at the built-in level from compile-to-compile.
     // Start pushing the user-defined symbols at global level.
     symbolTable.push();
-    if (!symbolTable.atGlobalLevel())
-        infoSink.info.message(EPrefixInternalError, "Wrong symbol table level");
+    if (!symbolTable.atGlobalLevel()) {
+        infoSink.info.prefix(EPrefixInternalError);
+        infoSink.info << "Wrong symbol table level";
+    }
 
     // Parse shader.
     bool success =
         (PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], NULL, &parseContext) == 0) &&
         (parseContext.treeRoot != NULL);
     if (success) {
         TIntermNode* root = parseContext.treeRoot;
         success = intermediate.postProcess(root);
 
         if (success)
-            success = detectRecursion(root);
+            success = detectCallDepth(root, infoSink, (compileOptions & SH_LIMIT_CALL_STACK_DEPTH) != 0);
 
         if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING))
             success = validateLimitations(root);
 
         if (success && (compileOptions & SH_TIMING_RESTRICTIONS))
             success = enforceTimingRestrictions(root, (compileOptions & SH_DEPENDENCY_GRAPH) != 0);
 
         if (success && shaderSpec == SH_CSS_SHADERS_SPEC)
@@ -203,29 +165,34 @@ bool TCompiler::compile(const char* cons
         // Built-in function emulation needs to happen after validateLimitations pass.
         if (success && (compileOptions & SH_EMULATE_BUILT_IN_FUNCTIONS))
             builtInFunctionEmulator.MarkBuiltInFunctionsForEmulation(root);
 
         // Clamping uniform array bounds needs to happen after validateLimitations pass.
         if (success && (compileOptions & SH_CLAMP_INDIRECT_ARRAY_BOUNDS))
             arrayBoundsClamper.MarkIndirectArrayBoundsForClamping(root);
 
+        // Disallow expressions deemed too complex.
+        if (success && (compileOptions & SH_LIMIT_EXPRESSION_COMPLEXITY))
+            success = limitExpressionComplexity(root);
+
         // Call mapLongVariableNames() before collectAttribsUniforms() so in
         // collectAttribsUniforms() we already have the mapped symbol names and
         // we could composite mapped and original variable names.
         // Also, if we hash all the names, then no need to do this for long names.
         if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) && hashFunction == NULL)
             mapLongVariableNames(root);
 
         if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) {
             collectAttribsUniforms(root);
             if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS) {
                 success = enforcePackingRestrictions();
                 if (!success) {
-                    infoSink.info.message(EPrefixError, "too many uniforms");
+                    infoSink.info.prefix(EPrefixError);
+                    infoSink.info << "too many uniforms";
                 }
             }
         }
 
         if (success && (compileOptions & SH_INTERMEDIATE_TREE))
             intermediate.outputTree(root);
 
         if (success && (compileOptions & SH_OBJECT_CODE))
@@ -237,23 +204,52 @@ bool TCompiler::compile(const char* cons
     // Ensure symbol table is returned to the built-in level,
     // throwing away all but the built-ins.
     while (!symbolTable.atBuiltInLevel())
         symbolTable.pop();
 
     return success;
 }
 
-bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources& resources)
+bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
 {
-    TBuiltIns builtIns;
+    compileResources = resources;
+
+    assert(symbolTable.isEmpty());
+    symbolTable.push();
+
+    TPublicType integer;
+    integer.type = EbtInt;
+    integer.size = 1;
+    integer.matrix = false;
+    integer.array = false;
 
-    builtIns.initialize(shaderType, shaderSpec, resources);
-    return InitializeSymbolTable(builtIns.getBuiltInStrings(),
-        shaderType, shaderSpec, resources, infoSink, symbolTable);
+    TPublicType floatingPoint;
+    floatingPoint.type = EbtFloat;
+    floatingPoint.size = 1;
+    floatingPoint.matrix = false;
+    floatingPoint.array = false;
+
+    switch(shaderType)
+    {
+      case SH_FRAGMENT_SHADER:
+        symbolTable.setDefaultPrecision(integer, EbpMedium);
+        break;
+      case SH_VERTEX_SHADER:
+        symbolTable.setDefaultPrecision(integer, EbpHigh);
+        symbolTable.setDefaultPrecision(floatingPoint, EbpHigh);
+        break;
+      default: assert(false && "Language not supported");
+    }
+
+    InsertBuiltInFunctions(shaderType, shaderSpec, resources, symbolTable);
+
+    IdentifyBuiltIns(shaderType, shaderSpec, resources, symbolTable);
+
+    return true;
 }
 
 void TCompiler::clearResults()
 {
     arrayBoundsClamper.Cleanup();
     infoSink.info.erase();
     infoSink.obj.erase();
     infoSink.debug.erase();
@@ -261,28 +257,34 @@ void TCompiler::clearResults()
     attribs.clear();
     uniforms.clear();
 
     builtInFunctionEmulator.Cleanup();
 
     nameMap.clear();
 }
 
-bool TCompiler::detectRecursion(TIntermNode* root)
+bool TCompiler::detectCallDepth(TIntermNode* root, TInfoSink& infoSink, bool limitCallStackDepth)
 {
-    DetectRecursion detect;
+    DetectCallDepth detect(infoSink, limitCallStackDepth, maxCallStackDepth);
     root->traverse(&detect);
-    switch (detect.detectRecursion()) {
-        case DetectRecursion::kErrorNone:
+    switch (detect.detectCallDepth()) {
+        case DetectCallDepth::kErrorNone:
             return true;
-        case DetectRecursion::kErrorMissingMain:
-            infoSink.info.message(EPrefixError, "Missing main()");
+        case DetectCallDepth::kErrorMissingMain:
+            infoSink.info.prefix(EPrefixError);
+            infoSink.info << "Missing main()";
             return false;
-        case DetectRecursion::kErrorRecursion:
-            infoSink.info.message(EPrefixError, "Function recursion detected");
+        case DetectCallDepth::kErrorRecursion:
+            infoSink.info.prefix(EPrefixError);
+            infoSink.info << "Function recursion detected";
+            return false;
+        case DetectCallDepth::kErrorMaxDepthExceeded:
+            infoSink.info.prefix(EPrefixError);
+            infoSink.info << "Function call stack too deep";
             return false;
         default:
             UNREACHABLE();
             return false;
     }
 }
 
 void TCompiler::rewriteCSSShader(TIntermNode* root)
@@ -318,16 +320,38 @@ bool TCompiler::enforceTimingRestriction
         
         return success;
     }
     else {
         return enforceVertexShaderTimingRestrictions(root);
     }
 }
 
+bool TCompiler::limitExpressionComplexity(TIntermNode* root)
+{
+    TIntermTraverser traverser;
+    root->traverse(&traverser);
+    TDependencyGraph graph(root);
+
+    for (TFunctionCallVector::const_iterator iter = graph.beginUserDefinedFunctionCalls();
+         iter != graph.endUserDefinedFunctionCalls();
+         ++iter)
+    {
+        TGraphFunctionCall* samplerSymbol = *iter;
+        TDependencyGraphTraverser graphTraverser;
+        samplerSymbol->traverse(&graphTraverser);
+    }
+
+    if (traverser.getMaxDepth() > maxExpressionComplexity) {
+        infoSink.info << "Expression too complex.";
+        return false;
+    }
+    return true;
+}
+
 bool TCompiler::enforceFragmentShaderTimingRestrictions(const TDependencyGraph& graph)
 {
     RestrictFragmentShaderTiming restrictor(infoSink.info);
     restrictor.enforceRestrictions(graph);
     return restrictor.numErrors() == 0;
 }
 
 bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root)
@@ -361,16 +385,21 @@ int TCompiler::getMappedNameMaxLength() 
     return MAX_SHORTENED_IDENTIFIER_SIZE + 1;
 }
 
 const TExtensionBehavior& TCompiler::getExtensionBehavior() const
 {
     return extensionBehavior;
 }
 
+const ShBuiltInResources& TCompiler::getResources() const
+{
+    return compileResources;
+}
+
 const ArrayBoundsClamper& TCompiler::getArrayBoundsClamper() const
 {
     return arrayBoundsClamper;
 }
 
 ShArrayIndexClampingStrategy TCompiler::getArrayIndexClampingStrategy() const
 {
     return clampingStrategy;
new file mode 100644
--- /dev/null
+++ b/gfx/angle/src/compiler/CompilerUniform.cpp
@@ -0,0 +1,21 @@
+//
+// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "CompilerUniform.h"
+
+namespace sh
+{
+
+Uniform::Uniform(GLenum type, GLenum precision, const char *name, int arraySize, int registerIndex)
+{
+    this->type = type;
+    this->precision = precision;
+    this->name = name;
+    this->arraySize = arraySize;
+    this->registerIndex = registerIndex;
+}
+
+}
new file mode 100644
--- /dev/null
+++ b/gfx/angle/src/compiler/CompilerUniform.h
@@ -0,0 +1,35 @@
+//
+// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#ifndef COMPILER_UNIFORM_H_
+#define COMPILER_UNIFORM_H_
+
+#include <string>
+#include <vector>
+
+#define GL_APICALL
+#include <GLES2/gl2.h>
+
+namespace sh
+{
+
+struct Uniform
+{
+    Uniform(GLenum type, GLenum precision, const char *name, int arraySize, int registerIndex);
+
+    GLenum type;
+    GLenum precision;
+    std::string name;
+    unsigned int arraySize;
+    
+    int registerIndex;
+};
+
+typedef std::vector<Uniform> ActiveUniforms;
+
+}
+
+#endif   // COMPILER_UNIFORM_H_
--- a/gfx/angle/src/compiler/ConstantUnion.h
+++ b/gfx/angle/src/compiler/ConstantUnion.h
@@ -6,23 +6,23 @@
 
 #ifndef _CONSTANT_UNION_INCLUDED_
 #define _CONSTANT_UNION_INCLUDED_
 
 #include <assert.h>
 
 class ConstantUnion {
 public:
+    POOL_ALLOCATOR_NEW_DELETE();
     ConstantUnion()
     {
         iConst = 0;
         type = EbtVoid;
     }
 
-    POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)        
     void setIConst(int i) {iConst = i; type = EbtInt; }
     void setFConst(float f) {fConst = f; type = EbtFloat; }
     void setBConst(bool b) {bConst = b; type = EbtBool; }
 
     int getIConst() { return iConst; }
     float getFConst() { return fConst; }
     bool getBConst() { return bConst; }
     int getIConst() const { return iConst; }
new file mode 100644
--- /dev/null
+++ b/gfx/angle/src/compiler/DetectCallDepth.cpp
@@ -0,0 +1,185 @@
+//
+// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "compiler/DetectCallDepth.h"
+#include "compiler/InfoSink.h"
+
+DetectCallDepth::FunctionNode::FunctionNode(const TString& fname)
+    : name(fname),
+      visit(PreVisit)
+{
+}
+
+const TString& DetectCallDepth::FunctionNode::getName() const
+{
+    return name;
+}
+
+void DetectCallDepth::FunctionNode::addCallee(
+    DetectCallDepth::FunctionNode* callee)
+{
+    for (size_t i = 0; i < callees.size(); ++i) {
+        if (callees[i] == callee)
+            return;
+    }
+    callees.push_back(callee);
+}
+
+int DetectCallDepth::FunctionNode::detectCallDepth(DetectCallDepth* detectCallDepth, int depth)
+{
+    ASSERT(visit == PreVisit);
+    ASSERT(detectCallDepth);
+
+    int maxDepth = depth;
+    visit = InVisit;
+    for (size_t i = 0; i < callees.size(); ++i) {
+        switch (callees[i]->visit) {
+            case InVisit:
+                // cycle detected, i.e., recursion detected.
+                return kInfiniteCallDepth;
+            case PostVisit:
+                break;
+            case PreVisit: {
+                // Check before we recurse so we don't go too depth
+                if (detectCallDepth->checkExceedsMaxDepth(depth))
+                    return depth;
+                int callDepth = callees[i]->detectCallDepth(detectCallDepth, depth + 1);
+                // Check after we recurse so we can exit immediately and provide info.
+                if (detectCallDepth->checkExceedsMaxDepth(callDepth)) {
+                    detectCallDepth->getInfoSink().info << "<-" << callees[i]->getName();
+                    return callDepth;
+                }
+                maxDepth = std::max(callDepth, maxDepth);
+                break;
+            }
+            default:
+                UNREACHABLE();
+                break;
+        }
+    }
+    visit = PostVisit;
+    return maxDepth;
+}
+
+void DetectCallDepth::FunctionNode::reset()
+{
+    visit = PreVisit;
+}
+
+DetectCallDepth::DetectCallDepth(TInfoSink& infoSink, bool limitCallStackDepth, int maxCallStackDepth)
+    : TIntermTraverser(true, false, true, false),
+      currentFunction(NULL),
+      infoSink(infoSink),
+      maxDepth(limitCallStackDepth ? maxCallStackDepth : FunctionNode::kInfiniteCallDepth)
+{
+}
+
+DetectCallDepth::~DetectCallDepth()
+{
+    for (size_t i = 0; i < functions.size(); ++i)
+        delete functions[i];
+}
+
+bool DetectCallDepth::visitAggregate(Visit visit, TIntermAggregate* node)
+{
+    switch (node->getOp())
+    {
+        case EOpPrototype:
+            // Function declaration.
+            // Don't add FunctionNode here because node->getName() is the
+            // unmangled function name.
+            break;
+        case EOpFunction: {
+            // Function definition.
+            if (visit == PreVisit) {
+                currentFunction = findFunctionByName(node->getName());
+                if (currentFunction == NULL) {
+                    currentFunction = new FunctionNode(node->getName());
+                    functions.push_back(currentFunction);
+                }
+            } else if (visit == PostVisit) {
+                currentFunction = NULL;
+            }
+            break;
+        }
+        case EOpFunctionCall: {
+            // Function call.
+            if (visit == PreVisit) {
+                FunctionNode* func = findFunctionByName(node->getName());
+                if (func == NULL) {
+                    func = new FunctionNode(node->getName());
+                    functions.push_back(func);
+                }
+                if (currentFunction)
+                    currentFunction->addCallee(func);
+            }
+            break;
+        }
+        default:
+            break;
+    }
+    return true;
+}
+
+bool DetectCallDepth::checkExceedsMaxDepth(int depth)
+{
+    return depth >= maxDepth;
+}
+
+void DetectCallDepth::resetFunctionNodes()
+{
+    for (size_t i = 0; i < functions.size(); ++i) {
+        functions[i]->reset();
+    }
+}
+
+DetectCallDepth::ErrorCode DetectCallDepth::detectCallDepthForFunction(FunctionNode* func)
+{
+    currentFunction = NULL;
+    resetFunctionNodes();
+
+    int maxCallDepth = func->detectCallDepth(this, 1);
+
+    if (maxCallDepth == FunctionNode::kInfiniteCallDepth)
+        return kErrorRecursion;
+
+    if (maxCallDepth >= maxDepth)
+        return kErrorMaxDepthExceeded;
+
+    return kErrorNone;
+}
+
+DetectCallDepth::ErrorCode DetectCallDepth::detectCallDepth()
+{
+    if (maxDepth != FunctionNode::kInfiniteCallDepth) {
+        // Check all functions because the driver may fail on them
+        // TODO: Before detectingRecursion, strip unused functions.
+        for (size_t i = 0; i < functions.size(); ++i) {
+            ErrorCode error = detectCallDepthForFunction(functions[i]);
+            if (error != kErrorNone)
+                return error;
+        }
+    } else {
+        FunctionNode* main = findFunctionByName("main(");
+        if (main == NULL)
+            return kErrorMissingMain;
+
+        return detectCallDepthForFunction(main);
+    }
+
+    return kErrorNone;
+}
+
+DetectCallDepth::FunctionNode* DetectCallDepth::findFunctionByName(
+    const TString& name)
+{
+    for (size_t i = 0; i < functions.size(); ++i) {
+        if (functions[i]->getName() == name)
+            return functions[i];
+    }
+    return NULL;
+}
+
new file mode 100644
--- /dev/null
+++ b/gfx/angle/src/compiler/DetectCallDepth.h
@@ -0,0 +1,80 @@
+//
+// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#ifndef COMPILER_DETECT_RECURSION_H_
+#define COMPILER_DETECT_RECURSION_H_
+
+#include "GLSLANG/ShaderLang.h"
+
+#include <limits.h>
+#include "compiler/intermediate.h"
+#include "compiler/VariableInfo.h"
+
+class TInfoSink;
+
+// Traverses intermediate tree to detect function recursion.
+class DetectCallDepth : public TIntermTraverser {
+public:
+    enum ErrorCode {
+        kErrorMissingMain,
+        kErrorRecursion,
+        kErrorMaxDepthExceeded,
+        kErrorNone
+    };
+
+    DetectCallDepth(TInfoSink& infoSync, bool limitCallStackDepth, int maxCallStackDepth);
+    ~DetectCallDepth();
+
+    virtual bool visitAggregate(Visit, TIntermAggregate*);
+
+    bool checkExceedsMaxDepth(int depth);
+
+    ErrorCode detectCallDepth();
+
+private:
+    class FunctionNode {
+    public:
+        static const int kInfiniteCallDepth = INT_MAX;
+
+        FunctionNode(const TString& fname);
+
+        const TString& getName() const;
+
+        // If a function is already in the callee list, this becomes a no-op.
+        void addCallee(FunctionNode* callee);
+
+        // Returns kInifinityCallDepth if recursive function calls are detected.
+        int detectCallDepth(DetectCallDepth* detectCallDepth, int depth);
+
+        // Reset state.
+        void reset();
+
+    private:
+        // mangled function name is unique.
+        TString name;
+
+        // functions that are directly called by this function.
+        TVector<FunctionNode*> callees;
+
+        Visit visit;
+    };
+
+    ErrorCode detectCallDepthForFunction(FunctionNode* func);
+    FunctionNode* findFunctionByName(const TString& name);
+    void resetFunctionNodes();
+
+    TInfoSink& getInfoSink() { return infoSink; }
+
+    TVector<FunctionNode*> functions;
+    FunctionNode* currentFunction;
+    TInfoSink& infoSink;
+    int maxDepth;
+
+    DetectCallDepth(const DetectCallDepth&);
+    void operator=(const DetectCallDepth&);
+};
+
+#endif  // COMPILER_DETECT_RECURSION_H_
deleted file mode 100644
--- a/gfx/angle/src/compiler/DetectRecursion.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-//
-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/DetectRecursion.h"
-
-DetectRecursion::FunctionNode::FunctionNode(const TString& fname)
-    : name(fname),
-      visit(PreVisit)
-{
-}
-
-const TString& DetectRecursion::FunctionNode::getName() const
-{
-    return name;
-}
-
-void DetectRecursion::FunctionNode::addCallee(
-    DetectRecursion::FunctionNode* callee)
-{
-    for (size_t i = 0; i < callees.size(); ++i) {
-        if (callees[i] == callee)
-            return;
-    }
-    callees.push_back(callee);
-}
-
-bool DetectRecursion::FunctionNode::detectRecursion()
-{
-    ASSERT(visit == PreVisit);
-    visit = InVisit;
-    for (size_t i = 0; i < callees.size(); ++i) {
-        switch (callees[i]->visit) {
-            case InVisit:
-                // cycle detected, i.e., recursion detected.
-                return true;
-            case PostVisit:
-                break;
-            case PreVisit: {
-                bool recursion = callees[i]->detectRecursion();
-                if (recursion)
-                    return true;
-                break;
-            }
-            default:
-                UNREACHABLE();
-                break;
-        }
-    }
-    visit = PostVisit;
-    return false;
-}
-
-DetectRecursion::DetectRecursion()
-    : currentFunction(NULL)
-{
-}
-
-DetectRecursion::~DetectRecursion()
-{
-    for (size_t i = 0; i < functions.size(); ++i)
-        delete functions[i];
-}
-
-bool DetectRecursion::visitAggregate(Visit visit, TIntermAggregate* node)
-{
-    switch (node->getOp())
-    {
-        case EOpPrototype:
-            // Function declaration.
-            // Don't add FunctionNode here because node->getName() is the
-            // unmangled function name.
-            break;
-        case EOpFunction: {
-            // Function definition.
-            if (visit == PreVisit) {
-                currentFunction = findFunctionByName(node->getName());
-                if (currentFunction == NULL) {
-                    currentFunction = new FunctionNode(node->getName());
-                    functions.push_back(currentFunction);
-                }
-            }
-            break;
-        }
-        case EOpFunctionCall: {
-            // Function call.
-            if (visit == PreVisit) {
-                ASSERT(currentFunction != NULL);
-                FunctionNode* func = findFunctionByName(node->getName());
-                if (func == NULL) {
-                    func = new FunctionNode(node->getName());
-                    functions.push_back(func);
-                }
-                currentFunction->addCallee(func);
-            }
-            break;
-        }
-        default:
-            break;
-    }
-    return true;
-}
-
-DetectRecursion::ErrorCode DetectRecursion::detectRecursion()
-{
-    FunctionNode* main = findFunctionByName("main(");
-    if (main == NULL)
-        return kErrorMissingMain;
-    if (main->detectRecursion())
-        return kErrorRecursion;
-    return kErrorNone;
-}
-
-DetectRecursion::FunctionNode* DetectRecursion::findFunctionByName(
-    const TString& name)
-{
-    for (size_t i = 0; i < functions.size(); ++i) {
-        if (functions[i]->getName() == name)
-            return functions[i];
-    }
-    return NULL;
-}
-
deleted file mode 100644
--- a/gfx/angle/src/compiler/DetectRecursion.h
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_DETECT_RECURSION_H_
-#define COMPILER_DETECT_RECURSION_H_
-
-#include "GLSLANG/ShaderLang.h"
-
-#include "compiler/intermediate.h"
-#include "compiler/VariableInfo.h"
-
-// Traverses intermediate tree to detect function recursion.
-class DetectRecursion : public TIntermTraverser {
-public:
-    enum ErrorCode {
-        kErrorMissingMain,
-        kErrorRecursion,
-        kErrorNone
-    };
-
-    DetectRecursion();
-    ~DetectRecursion();
-
-    virtual bool visitAggregate(Visit, TIntermAggregate*);
-
-    ErrorCode detectRecursion();
-
-private:
-    class FunctionNode {
-    public:
-        FunctionNode(const TString& fname);
-
-        const TString& getName() const;
-
-        // If a function is already in the callee list, this becomes a no-op.
-        void addCallee(FunctionNode* callee);
-
-        // Return true if recursive function calls are detected.
-        bool detectRecursion();
-
-    private:
-        // mangled function name is unique.
-        TString name;
-
-        // functions that are directly called by this function.
-        TVector<FunctionNode*> callees;
-
-        Visit visit;
-    };
-
-    FunctionNode* findFunctionByName(const TString& name);
-
-    TVector<FunctionNode*> functions;
-    FunctionNode* currentFunction;
-};
-
-#endif  // COMPILER_DETECT_RECURSION_H_
--- a/gfx/angle/src/compiler/Diagnostics.cpp
+++ b/gfx/angle/src/compiler/Diagnostics.cpp
@@ -41,17 +41,17 @@ void TDiagnostics::writeInfo(Severity se
       default:
         UNREACHABLE();
         break;
     }
 
     TInfoSinkBase& sink = mInfoSink.info;
     /* VC++ format: file(linenum) : error #: 'token' : extrainfo */
     sink.prefix(prefix);
-    sink.location(EncodeSourceLoc(loc.file, loc.line));
+    sink.location(loc.file, loc.line);
     sink << "'" << token <<  "' : " << reason << " " << extra << "\n";
 }
 
 void TDiagnostics::writeDebug(const std::string& str)
 {
     mInfoSink.debug << str;
 }
 
--- a/gfx/angle/src/compiler/InfoSink.cpp
+++ b/gfx/angle/src/compiler/InfoSink.cpp
@@ -1,18 +1,18 @@
 //
 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
 #include "compiler/InfoSink.h"
 
-void TInfoSinkBase::prefix(TPrefixType message) {
-    switch(message) {
+void TInfoSinkBase::prefix(TPrefixType p) {
+    switch(p) {
         case EPrefixNone:
             break;
         case EPrefixWarning:
             sink.append("WARNING: ");
             break;
         case EPrefixError:
             sink.append("ERROR: ");
             break;
@@ -26,34 +26,29 @@ void TInfoSinkBase::prefix(TPrefixType m
             sink.append("NOTE: ");
             break;
         default:
             sink.append("UNKOWN ERROR: ");
             break;
     }
 }
 
-void TInfoSinkBase::location(TSourceLoc loc) {
-    int string = 0, line = 0;
-    DecodeSourceLoc(loc, &string, &line);
-
+void TInfoSinkBase::location(int file, int line) {
     TPersistStringStream stream;
     if (line)
-        stream << string << ":" << line;
+        stream << file << ":" << line;
     else
-        stream << string << ":? ";
+        stream << file << ":? ";
     stream << ": ";
 
     sink.append(stream.str());
 }
 
-void TInfoSinkBase::message(TPrefixType message, const char* s) {
-    prefix(message);
-    sink.append(s);
-    sink.append("\n");
+void TInfoSinkBase::location(const TSourceLoc& loc) {
+    location(loc.first_file, loc.first_line);
 }
 
-void TInfoSinkBase::message(TPrefixType message, const char* s, TSourceLoc loc) {
-    prefix(message);
+void TInfoSinkBase::message(TPrefixType p, const TSourceLoc& loc, const char* m) {
+    prefix(p);
     location(loc);
-    sink.append(s);
+    sink.append(m);
     sink.append("\n");
 }
--- a/gfx/angle/src/compiler/InfoSink.h
+++ b/gfx/angle/src/compiler/InfoSink.h
@@ -91,20 +91,20 @@ public:
     }
 
     void erase() { sink.clear(); }
     int size() { return static_cast<int>(sink.size()); }
 
     const TPersistString& str() const { return sink; }
     const char* c_str() const { return sink.c_str(); }
 
-    void prefix(TPrefixType message);
-    void location(TSourceLoc loc);
-    void message(TPrefixType message, const char* s);
-    void message(TPrefixType message, const char* s, TSourceLoc loc);
+    void prefix(TPrefixType p);
+    void location(int file, int line);
+    void location(const TSourceLoc& loc);
+    void message(TPrefixType p, const TSourceLoc& loc, const char* m);
 
 private:
     TPersistString sink;
 };
 
 class TInfoSink {
 public:
     TInfoSinkBase info;
--- a/gfx/angle/src/compiler/Initialize.cpp
+++ b/gfx/angle/src/compiler/Initialize.cpp
@@ -1,531 +1,431 @@
 //
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
 //
 // Create strings that declare built-in definitions, add built-ins that
 // cannot be expressed in the files, and establish mappings between 
 // built-in functions and operators.
 //
 
 #include "compiler/Initialize.h"
 
 #include "compiler/intermediate.h"
 
-//============================================================================
-//
-// Prototypes for built-in functions seen by both vertex and fragment shaders.
-//
-//============================================================================
-static TString BuiltInFunctionsCommon(const ShBuiltInResources& resources)
+void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable)
 {
-    TString s;
+    TType *float1 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 1);
+    TType *float2 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 2);
+    TType *float3 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 3);
+    TType *float4 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 4);
+
+    TType *int2 = new TType(EbtInt, EbpUndefined, EvqGlobal, 2);
+    TType *int3 = new TType(EbtInt, EbpUndefined, EvqGlobal, 3);
+    TType *int4 = new TType(EbtInt, EbpUndefined, EvqGlobal, 4);
 
     //
     // Angle and Trigonometric Functions.
     //
-    s.append(TString("float radians(float degrees);"));
-    s.append(TString("vec2  radians(vec2  degrees);"));
-    s.append(TString("vec3  radians(vec3  degrees);"));
-    s.append(TString("vec4  radians(vec4  degrees);"));
+    symbolTable.insertBuiltIn(float1, "radians", float1);
+    symbolTable.insertBuiltIn(float2, "radians", float2);
+    symbolTable.insertBuiltIn(float3, "radians", float3);
+    symbolTable.insertBuiltIn(float4, "radians", float4);
 
-    s.append(TString("float degrees(float radians);"));
-    s.append(TString("vec2  degrees(vec2  radians);"));
-    s.append(TString("vec3  degrees(vec3  radians);"));
-    s.append(TString("vec4  degrees(vec4  radians);"));
+    symbolTable.insertBuiltIn(float1, "degrees", float1);
+    symbolTable.insertBuiltIn(float2, "degrees", float2);
+    symbolTable.insertBuiltIn(float3, "degrees", float3);
+    symbolTable.insertBuiltIn(float4, "degrees", float4);
 
-    s.append(TString("float sin(float angle);"));
-    s.append(TString("vec2  sin(vec2  angle);"));
-    s.append(TString("vec3  sin(vec3  angle);"));
-    s.append(TString("vec4  sin(vec4  angle);"));
+    symbolTable.insertBuiltIn(float1, "sin", float1);
+    symbolTable.insertBuiltIn(float2, "sin", float2);
+    symbolTable.insertBuiltIn(float3, "sin", float3);
+    symbolTable.insertBuiltIn(float4, "sin", float4);
 
-    s.append(TString("float cos(float angle);"));
-    s.append(TString("vec2  cos(vec2  angle);"));
-    s.append(TString("vec3  cos(vec3  angle);"));
-    s.append(TString("vec4  cos(vec4  angle);"));
+    symbolTable.insertBuiltIn(float1, "cos", float1);
+    symbolTable.insertBuiltIn(float2, "cos", float2);
+    symbolTable.insertBuiltIn(float3, "cos", float3);
+    symbolTable.insertBuiltIn(float4, "cos", float4);
 
-    s.append(TString("float tan(float angle);"));
-    s.append(TString("vec2  tan(vec2  angle);"));
-    s.append(TString("vec3  tan(vec3  angle);"));
-    s.append(TString("vec4  tan(vec4  angle);"));
+    symbolTable.insertBuiltIn(float1, "tan", float1);
+    symbolTable.insertBuiltIn(float2, "tan", float2);
+    symbolTable.insertBuiltIn(float3, "tan", float3);
+    symbolTable.insertBuiltIn(float4, "tan", float4);
 
-    s.append(TString("float asin(float x);"));
-    s.append(TString("vec2  asin(vec2  x);"));
-    s.append(TString("vec3  asin(vec3  x);"));
-    s.append(TString("vec4  asin(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "asin", float1);
+    symbolTable.insertBuiltIn(float2, "asin", float2);
+    symbolTable.insertBuiltIn(float3, "asin", float3);
+    symbolTable.insertBuiltIn(float4, "asin", float4);
 
-    s.append(TString("float acos(float x);"));
-    s.append(TString("vec2  acos(vec2  x);"));
-    s.append(TString("vec3  acos(vec3  x);"));
-    s.append(TString("vec4  acos(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "acos", float1);
+    symbolTable.insertBuiltIn(float2, "acos", float2);
+    symbolTable.insertBuiltIn(float3, "acos", float3);
+    symbolTable.insertBuiltIn(float4, "acos", float4);
 
-    s.append(TString("float atan(float y, float x);"));
-    s.append(TString("vec2  atan(vec2  y, vec2  x);"));
-    s.append(TString("vec3  atan(vec3  y, vec3  x);"));
-    s.append(TString("vec4  atan(vec4  y, vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "atan", float1, float1);
+    symbolTable.insertBuiltIn(float2, "atan", float2, float2);
+    symbolTable.insertBuiltIn(float3, "atan", float3, float3);
+    symbolTable.insertBuiltIn(float4, "atan", float4, float4);
 
-    s.append(TString("float atan(float y_over_x);"));
-    s.append(TString("vec2  atan(vec2  y_over_x);"));
-    s.append(TString("vec3  atan(vec3  y_over_x);"));
-    s.append(TString("vec4  atan(vec4  y_over_x);"));
+    symbolTable.insertBuiltIn(float1, "atan", float1);
+    symbolTable.insertBuiltIn(float2, "atan", float2);
+    symbolTable.insertBuiltIn(float3, "atan", float3);
+    symbolTable.insertBuiltIn(float4, "atan", float4);
 
     //
     // Exponential Functions.
     //
-    s.append(TString("float pow(float x, float y);"));
-    s.append(TString("vec2  pow(vec2  x, vec2  y);"));
-    s.append(TString("vec3  pow(vec3  x, vec3  y);"));
-    s.append(TString("vec4  pow(vec4  x, vec4  y);"));
+    symbolTable.insertBuiltIn(float1, "pow", float1, float1);
+    symbolTable.insertBuiltIn(float2, "pow", float2, float2);
+    symbolTable.insertBuiltIn(float3, "pow", float3, float3);
+    symbolTable.insertBuiltIn(float4, "pow", float4, float4);
 
-    s.append(TString("float exp(float x);"));
-    s.append(TString("vec2  exp(vec2  x);"));
-    s.append(TString("vec3  exp(vec3  x);"));
-    s.append(TString("vec4  exp(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "exp", float1);
+    symbolTable.insertBuiltIn(float2, "exp", float2);
+    symbolTable.insertBuiltIn(float3, "exp", float3);
+    symbolTable.insertBuiltIn(float4, "exp", float4);
 
-    s.append(TString("float log(float x);"));
-    s.append(TString("vec2  log(vec2  x);"));
-    s.append(TString("vec3  log(vec3  x);"));
-    s.append(TString("vec4  log(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "log", float1);
+    symbolTable.insertBuiltIn(float2, "log", float2);
+    symbolTable.insertBuiltIn(float3, "log", float3);
+    symbolTable.insertBuiltIn(float4, "log", float4);
 
-    s.append(TString("float exp2(float x);"));
-    s.append(TString("vec2  exp2(vec2  x);"));
-    s.append(TString("vec3  exp2(vec3  x);"));
-    s.append(TString("vec4  exp2(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "exp2", float1);
+    symbolTable.insertBuiltIn(float2, "exp2", float2);
+    symbolTable.insertBuiltIn(float3, "exp2", float3);
+    symbolTable.insertBuiltIn(float4, "exp2", float4);
 
-    s.append(TString("float log2(float x);"));
-    s.append(TString("vec2  log2(vec2  x);"));
-    s.append(TString("vec3  log2(vec3  x);"));
-    s.append(TString("vec4  log2(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "log2", float1);
+    symbolTable.insertBuiltIn(float2, "log2", float2);
+    symbolTable.insertBuiltIn(float3, "log2", float3);
+    symbolTable.insertBuiltIn(float4, "log2", float4);
 
-    s.append(TString("float sqrt(float x);"));
-    s.append(TString("vec2  sqrt(vec2  x);"));
-    s.append(TString("vec3  sqrt(vec3  x);"));
-    s.append(TString("vec4  sqrt(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "sqrt", float1);
+    symbolTable.insertBuiltIn(float2, "sqrt", float2);
+    symbolTable.insertBuiltIn(float3, "sqrt", float3);
+    symbolTable.insertBuiltIn(float4, "sqrt", float4);
 
-    s.append(TString("float inversesqrt(float x);"));
-    s.append(TString("vec2  inversesqrt(vec2  x);"));
-    s.append(TString("vec3  inversesqrt(vec3  x);"));
-    s.append(TString("vec4  inversesqrt(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "inversesqrt", float1);
+    symbolTable.insertBuiltIn(float2, "inversesqrt", float2);
+    symbolTable.insertBuiltIn(float3, "inversesqrt", float3);
+    symbolTable.insertBuiltIn(float4, "inversesqrt", float4);
 
     //
     // Common Functions.
     //
-    s.append(TString("float abs(float x);"));
-    s.append(TString("vec2  abs(vec2  x);"));
-    s.append(TString("vec3  abs(vec3  x);"));
-    s.append(TString("vec4  abs(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "abs", float1);
+    symbolTable.insertBuiltIn(float2, "abs", float2);
+    symbolTable.insertBuiltIn(float3, "abs", float3);
+    symbolTable.insertBuiltIn(float4, "abs", float4);
 
-    s.append(TString("float sign(float x);"));
-    s.append(TString("vec2  sign(vec2  x);"));
-    s.append(TString("vec3  sign(vec3  x);"));
-    s.append(TString("vec4  sign(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "sign", float1);
+    symbolTable.insertBuiltIn(float2, "sign", float2);
+    symbolTable.insertBuiltIn(float3, "sign", float3);
+    symbolTable.insertBuiltIn(float4, "sign", float4);
 
-    s.append(TString("float floor(float x);"));
-    s.append(TString("vec2  floor(vec2  x);"));
-    s.append(TString("vec3  floor(vec3  x);"));
-    s.append(TString("vec4  floor(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "floor", float1);
+    symbolTable.insertBuiltIn(float2, "floor", float2);
+    symbolTable.insertBuiltIn(float3, "floor", float3);
+    symbolTable.insertBuiltIn(float4, "floor", float4);
 
-    s.append(TString("float ceil(float x);"));
-    s.append(TString("vec2  ceil(vec2  x);"));
-    s.append(TString("vec3  ceil(vec3  x);"));
-    s.append(TString("vec4  ceil(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "ceil", float1);
+    symbolTable.insertBuiltIn(float2, "ceil", float2);
+    symbolTable.insertBuiltIn(float3, "ceil", float3);
+    symbolTable.insertBuiltIn(float4, "ceil", float4);
 
-    s.append(TString("float fract(float x);"));
-    s.append(TString("vec2  fract(vec2  x);"));
-    s.append(TString("vec3  fract(vec3  x);"));
-    s.append(TString("vec4  fract(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "fract", float1);
+    symbolTable.insertBuiltIn(float2, "fract", float2);
+    symbolTable.insertBuiltIn(float3, "fract", float3);
+    symbolTable.insertBuiltIn(float4, "fract", float4);
 
-    s.append(TString("float mod(float x, float y);"));
-    s.append(TString("vec2  mod(vec2  x, float y);"));
-    s.append(TString("vec3  mod(vec3  x, float y);"));
-    s.append(TString("vec4  mod(vec4  x, float y);"));
-    s.append(TString("vec2  mod(vec2  x, vec2  y);"));
-    s.append(TString("vec3  mod(vec3  x, vec3  y);"));
-    s.append(TString("vec4  mod(vec4  x, vec4  y);"));
+    symbolTable.insertBuiltIn(float1, "mod", float1, float1);
+    symbolTable.insertBuiltIn(float2, "mod", float2, float1);
+    symbolTable.insertBuiltIn(float3, "mod", float3, float1);
+    symbolTable.insertBuiltIn(float4, "mod", float4, float1);
+    symbolTable.insertBuiltIn(float2, "mod", float2, float2);
+    symbolTable.insertBuiltIn(float3, "mod", float3, float3);
+    symbolTable.insertBuiltIn(float4, "mod", float4, float4);
 
-    s.append(TString("float min(float x, float y);"));
-    s.append(TString("vec2  min(vec2  x, float y);"));
-    s.append(TString("vec3  min(vec3  x, float y);"));
-    s.append(TString("vec4  min(vec4  x, float y);"));
-    s.append(TString("vec2  min(vec2  x, vec2  y);"));
-    s.append(TString("vec3  min(vec3  x, vec3  y);"));
-    s.append(TString("vec4  min(vec4  x, vec4  y);"));
+    symbolTable.insertBuiltIn(float1, "min", float1, float1);
+    symbolTable.insertBuiltIn(float2, "min", float2, float1);
+    symbolTable.insertBuiltIn(float3, "min", float3, float1);
+    symbolTable.insertBuiltIn(float4, "min", float4, float1);
+    symbolTable.insertBuiltIn(float2, "min", float2, float2);
+    symbolTable.insertBuiltIn(float3, "min", float3, float3);
+    symbolTable.insertBuiltIn(float4, "min", float4, float4);
 
-    s.append(TString("float max(float x, float y);"));
-    s.append(TString("vec2  max(vec2  x, float y);"));
-    s.append(TString("vec3  max(vec3  x, float y);"));
-    s.append(TString("vec4  max(vec4  x, float y);"));
-    s.append(TString("vec2  max(vec2  x, vec2  y);"));
-    s.append(TString("vec3  max(vec3  x, vec3  y);"));
-    s.append(TString("vec4  max(vec4  x, vec4  y);"));
+    symbolTable.insertBuiltIn(float1, "max", float1, float1);
+    symbolTable.insertBuiltIn(float2, "max", float2, float1);
+    symbolTable.insertBuiltIn(float3, "max", float3, float1);
+    symbolTable.insertBuiltIn(float4, "max", float4, float1);
+    symbolTable.insertBuiltIn(float2, "max", float2, float2);
+    symbolTable.insertBuiltIn(float3, "max", float3, float3);
+    symbolTable.insertBuiltIn(float4, "max", float4, float4);
 
-    s.append(TString("float clamp(float x, float minVal, float maxVal);"));
-    s.append(TString("vec2  clamp(vec2  x, float minVal, float maxVal);"));
-    s.append(TString("vec3  clamp(vec3  x, float minVal, float maxVal);"));
-    s.append(TString("vec4  clamp(vec4  x, float minVal, float maxVal);"));
-    s.append(TString("vec2  clamp(vec2  x, vec2  minVal, vec2  maxVal);"));
-    s.append(TString("vec3  clamp(vec3  x, vec3  minVal, vec3  maxVal);"));
-    s.append(TString("vec4  clamp(vec4  x, vec4  minVal, vec4  maxVal);"));
+    symbolTable.insertBuiltIn(float1, "clamp", float1, float1, float1);
+    symbolTable.insertBuiltIn(float2, "clamp", float2, float1, float1);
+    symbolTable.insertBuiltIn(float3, "clamp", float3, float1, float1);
+    symbolTable.insertBuiltIn(float4, "clamp", float4, float1, float1);
+    symbolTable.insertBuiltIn(float2, "clamp", float2, float2, float2);
+    symbolTable.insertBuiltIn(float3, "clamp", float3, float3, float3);
+    symbolTable.insertBuiltIn(float4, "clamp", float4, float4, float4);
 
-    s.append(TString("float mix(float x, float y, float a);"));
-    s.append(TString("vec2  mix(vec2  x, vec2  y, float a);"));
-    s.append(TString("vec3  mix(vec3  x, vec3  y, float a);"));
-    s.append(TString("vec4  mix(vec4  x, vec4  y, float a);"));
-    s.append(TString("vec2  mix(vec2  x, vec2  y, vec2  a);"));
-    s.append(TString("vec3  mix(vec3  x, vec3  y, vec3  a);"));
-    s.append(TString("vec4  mix(vec4  x, vec4  y, vec4  a);"));
+    symbolTable.insertBuiltIn(float1, "mix", float1, float1, float1);
+    symbolTable.insertBuiltIn(float2, "mix", float2, float2, float1);
+    symbolTable.insertBuiltIn(float3, "mix", float3, float3, float1);
+    symbolTable.insertBuiltIn(float4, "mix", float4, float4, float1);
+    symbolTable.insertBuiltIn(float2, "mix", float2, float2, float2);
+    symbolTable.insertBuiltIn(float3, "mix", float3, float3, float3);
+    symbolTable.insertBuiltIn(float4, "mix", float4, float4, float4);
 
-    s.append(TString("float step(float edge, float x);"));
-    s.append(TString("vec2  step(vec2  edge, vec2  x);"));
-    s.append(TString("vec3  step(vec3  edge, vec3  x);"));
-    s.append(TString("vec4  step(vec4  edge, vec4  x);"));
-    s.append(TString("vec2  step(float edge, vec2  x);"));
-    s.append(TString("vec3  step(float edge, vec3  x);"));
-    s.append(TString("vec4  step(float edge, vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "step", float1, float1);
+    symbolTable.insertBuiltIn(float2, "step", float2, float2);
+    symbolTable.insertBuiltIn(float3, "step", float3, float3);
+    symbolTable.insertBuiltIn(float4, "step", float4, float4);
+    symbolTable.insertBuiltIn(float2, "step", float1, float2);
+    symbolTable.insertBuiltIn(float3, "step", float1, float3);
+    symbolTable.insertBuiltIn(float4, "step", float1, float4);
 
-    s.append(TString("float smoothstep(float edge0, float edge1, float x);"));
-    s.append(TString("vec2  smoothstep(vec2  edge0, vec2  edge1, vec2  x);"));
-    s.append(TString("vec3  smoothstep(vec3  edge0, vec3  edge1, vec3  x);"));
-    s.append(TString("vec4  smoothstep(vec4  edge0, vec4  edge1, vec4  x);"));
-    s.append(TString("vec2  smoothstep(float edge0, float edge1, vec2  x);"));
-    s.append(TString("vec3  smoothstep(float edge0, float edge1, vec3  x);"));
-    s.append(TString("vec4  smoothstep(float edge0, float edge1, vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "smoothstep", float1, float1, float1);
+    symbolTable.insertBuiltIn(float2, "smoothstep", float2, float2, float2);
+    symbolTable.insertBuiltIn(float3, "smoothstep", float3, float3, float3);
+    symbolTable.insertBuiltIn(float4, "smoothstep", float4, float4, float4);
+    symbolTable.insertBuiltIn(float2, "smoothstep", float1, float1, float2);
+    symbolTable.insertBuiltIn(float3, "smoothstep", float1, float1, float3);
+    symbolTable.insertBuiltIn(float4, "smoothstep", float1, float1, float4);
 
     //
     // Geometric Functions.
     //
-    s.append(TString("float length(float x);"));
-    s.append(TString("float length(vec2  x);"));
-    s.append(TString("float length(vec3  x);"));
-    s.append(TString("float length(vec4  x);"));
+    symbolTable.insertBuiltIn(float1, "length", float1);
+    symbolTable.insertBuiltIn(float1, "length", float2);
+    symbolTable.insertBuiltIn(float1, "length", float3);
+    symbolTable.insertBuiltIn(float1, "length", float4);
 
-    s.append(TString("float distance(float p0, float p1);"));
-    s.append(TString("float distance(vec2  p0, vec2  p1);"));
-    s.append(TString("float distance(vec3  p0, vec3  p1);"));
-    s.append(TString("float distance(vec4  p0, vec4  p1);"));
+    symbolTable.insertBuiltIn(float1, "distance", float1, float1);
+    symbolTable.insertBuiltIn(float1, "distance", float2, float2);
+    symbolTable.insertBuiltIn(float1, "distance", float3, float3);
+    symbolTable.insertBuiltIn(float1, "distance", float4, float4);
 
-    s.append(TString("float dot(float x, float y);"));
-    s.append(TString("float dot(vec2  x, vec2  y);"));
-    s.append(TString("float dot(vec3  x, vec3  y);"));
-    s.append(TString("float dot(vec4  x, vec4  y);"));
+    symbolTable.insertBuiltIn(float1, "dot", float1, float1);
+    symbolTable.insertBuiltIn(float1, "dot", float2, float2);
+    symbolTable.insertBuiltIn(float1, "dot", float3, float3);
+    symbolTable.insertBuiltIn(float1, "dot", float4, float4);
 
-    s.append(TString("vec3 cross(vec3 x, vec3 y);"));
-    s.append(TString("float normalize(float x);"));
-    s.append(TString("vec2  normalize(vec2  x);"));
-    s.append(TString("vec3  normalize(vec3  x);"));
-    s.append(TString("vec4  normalize(vec4  x);"));
+    symbolTable.insertBuiltIn(float3, "cross", float3, float3);
+    symbolTable.insertBuiltIn(float1, "normalize", float1);
+    symbolTable.insertBuiltIn(float2, "normalize", float2);
+    symbolTable.insertBuiltIn(float3, "normalize", float3);
+    symbolTable.insertBuiltIn(float4, "normalize", float4);
+
+    symbolTable.insertBuiltIn(float1, "faceforward", float1, float1, float1);
+    symbolTable.insertBuiltIn(float2, "faceforward", float2, float2, float2);
+    symbolTable.insertBuiltIn(float3, "faceforward", float3, float3, float3);
+    symbolTable.insertBuiltIn(float4, "faceforward", float4, float4, float4);
 
-    s.append(TString("float faceforward(float N, float I, float Nref);"));
-    s.append(TString("vec2  faceforward(vec2  N, vec2  I, vec2  Nref);"));
-    s.append(TString("vec3  faceforward(vec3  N, vec3  I, vec3  Nref);"));
-    s.append(TString("vec4  faceforward(vec4  N, vec4  I, vec4  Nref);"));
+    symbolTable.insertBuiltIn(float1, "reflect", float1, float1);
+    symbolTable.insertBuiltIn(float2, "reflect", float2, float2);
+    symbolTable.insertBuiltIn(float3, "reflect", float3, float3);
+    symbolTable.insertBuiltIn(float4, "reflect", float4, float4);
 
-    s.append(TString("float reflect(float I, float N);"));
-    s.append(TString("vec2  reflect(vec2  I, vec2  N);"));
-    s.append(TString("vec3  reflect(vec3  I, vec3  N);"));
-    s.append(TString("vec4  reflect(vec4  I, vec4  N);"));
+    symbolTable.insertBuiltIn(float1, "refract", float1, float1, float1);
+    symbolTable.insertBuiltIn(float2, "refract", float2, float2, float1);
+    symbolTable.insertBuiltIn(float3, "refract", float3, float3, float1);
+    symbolTable.insertBuiltIn(float4, "refract", float4, float4, float1);
 
-    s.append(TString("float refract(float I, float N, float eta);"));
-    s.append(TString("vec2  refract(vec2  I, vec2  N, float eta);"));
-    s.append(TString("vec3  refract(vec3  I, vec3  N, float eta);"));
-    s.append(TString("vec4  refract(vec4  I, vec4  N, float eta);"));
+    TType *mat2 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 2, true);
+    TType *mat3 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 3, true);
+    TType *mat4 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 4, true);
 
     //
     // Matrix Functions.
     //
-    s.append(TString("mat2 matrixCompMult(mat2 x, mat2 y);"));
-    s.append(TString("mat3 matrixCompMult(mat3 x, mat3 y);"));
-    s.append(TString("mat4 matrixCompMult(mat4 x, mat4 y);"));
+    symbolTable.insertBuiltIn(mat2, "matrixCompMult", mat2, mat2);
+    symbolTable.insertBuiltIn(mat3, "matrixCompMult", mat3, mat3);
+    symbolTable.insertBuiltIn(mat4, "matrixCompMult", mat4, mat4);
+
+    TType *bool1 = new TType(EbtBool, EbpUndefined, EvqGlobal, 1);
+    TType *bool2 = new TType(EbtBool, EbpUndefined, EvqGlobal, 2);
+    TType *bool3 = new TType(EbtBool, EbpUndefined, EvqGlobal, 3);
+    TType *bool4 = new TType(EbtBool, EbpUndefined, EvqGlobal, 4);
 
     //
     // Vector relational functions.
     //
-    s.append(TString("bvec2 lessThan(vec2 x, vec2 y);"));
-    s.append(TString("bvec3 lessThan(vec3 x, vec3 y);"));
-    s.append(TString("bvec4 lessThan(vec4 x, vec4 y);"));
+    symbolTable.insertBuiltIn(bool2, "lessThan", float2, float2);
+    symbolTable.insertBuiltIn(bool3, "lessThan", float3, float3);
+    symbolTable.insertBuiltIn(bool4, "lessThan", float4, float4);
 
-    s.append(TString("bvec2 lessThan(ivec2 x, ivec2 y);"));
-    s.append(TString("bvec3 lessThan(ivec3 x, ivec3 y);"));
-    s.append(TString("bvec4 lessThan(ivec4 x, ivec4 y);"));
+    symbolTable.insertBuiltIn(bool2, "lessThan", int2, int2);
+    symbolTable.insertBuiltIn(bool3, "lessThan", int3, int3);
+    symbolTable.insertBuiltIn(bool4, "lessThan", int4, int4);
 
-    s.append(TString("bvec2 lessThanEqual(vec2 x, vec2 y);"));
-    s.append(TString("bvec3 lessThanEqual(vec3 x, vec3 y);"));
-    s.append(TString("bvec4 lessThanEqual(vec4 x, vec4 y);"));
+    symbolTable.insertBuiltIn(bool2, "lessThanEqual", float2, float2);
+    symbolTable.insertBuiltIn(bool3, "lessThanEqual", float3, float3);
+    symbolTable.insertBuiltIn(bool4, "lessThanEqual", float4, float4);
 
-    s.append(TString("bvec2 lessThanEqual(ivec2 x, ivec2 y);"));
-    s.append(TString("bvec3 lessThanEqual(ivec3 x, ivec3 y);"));
-    s.append(TString("bvec4 lessThanEqual(ivec4 x, ivec4 y);"));
-
-    s.append(TString("bvec2 greaterThan(vec2 x, vec2 y);"));
-    s.append(TString("bvec3 greaterThan(vec3 x, vec3 y);"));
-    s.append(TString("bvec4 greaterThan(vec4 x, vec4 y);"));
+    symbolTable.insertBuiltIn(bool2, "lessThanEqual", int2, int2);
+    symbolTable.insertBuiltIn(bool3, "lessThanEqual", int3, int3);
+    symbolTable.insertBuiltIn(bool4, "lessThanEqual", int4, int4);
 
-    s.append(TString("bvec2 greaterThan(ivec2 x, ivec2 y);"));
-    s.append(TString("bvec3 greaterThan(ivec3 x, ivec3 y);"));
-    s.append(TString("bvec4 greaterThan(ivec4 x, ivec4 y);"));
+    symbolTable.insertBuiltIn(bool2, "greaterThan", float2, float2);
+    symbolTable.insertBuiltIn(bool3, "greaterThan", float3, float3);
+    symbolTable.insertBuiltIn(bool4, "greaterThan", float4, float4);
 
-    s.append(TString("bvec2 greaterThanEqual(vec2 x, vec2 y);"));
-    s.append(TString("bvec3 greaterThanEqual(vec3 x, vec3 y);"));
-    s.append(TString("bvec4 greaterThanEqual(vec4 x, vec4 y);"));
-
-    s.append(TString("bvec2 greaterThanEqual(ivec2 x, ivec2 y);"));
-    s.append(TString("bvec3 greaterThanEqual(ivec3 x, ivec3 y);"));
-    s.append(TString("bvec4 greaterThanEqual(ivec4 x, ivec4 y);"));
+    symbolTable.insertBuiltIn(bool2, "greaterThan", int2, int2);
+    symbolTable.insertBuiltIn(bool3, "greaterThan", int3, int3);
+    symbolTable.insertBuiltIn(bool4, "greaterThan", int4, int4);
 
-    s.append(TString("bvec2 equal(vec2 x, vec2 y);"));
-    s.append(TString("bvec3 equal(vec3 x, vec3 y);"));
-    s.append(TString("bvec4 equal(vec4 x, vec4 y);"));
+    symbolTable.insertBuiltIn(bool2, "greaterThanEqual", float2, float2);
+    symbolTable.insertBuiltIn(bool3, "greaterThanEqual", float3, float3);
+    symbolTable.insertBuiltIn(bool4, "greaterThanEqual", float4, float4);
 
-    s.append(TString("bvec2 equal(ivec2 x, ivec2 y);"));
-    s.append(TString("bvec3 equal(ivec3 x, ivec3 y);"));
-    s.append(TString("bvec4 equal(ivec4 x, ivec4 y);"));
-
-    s.append(TString("bvec2 equal(bvec2 x, bvec2 y);"));
-    s.append(TString("bvec3 equal(bvec3 x, bvec3 y);"));
-    s.append(TString("bvec4 equal(bvec4 x, bvec4 y);"));
+    symbolTable.insertBuiltIn(bool2, "greaterThanEqual", int2, int2);
+    symbolTable.insertBuiltIn(bool3, "greaterThanEqual", int3, int3);
+    symbolTable.insertBuiltIn(bool4, "greaterThanEqual", int4, int4);
 
-    s.append(TString("bvec2 notEqual(vec2 x, vec2 y);"));
-    s.append(TString("bvec3 notEqual(vec3 x, vec3 y);"));
-    s.append(TString("bvec4 notEqual(vec4 x, vec4 y);"));
+    symbolTable.insertBuiltIn(bool2, "equal", float2, float2);
+    symbolTable.insertBuiltIn(bool3, "equal", float3, float3);
+    symbolTable.insertBuiltIn(bool4, "equal", float4, float4);
 
-    s.append(TString("bvec2 notEqual(ivec2 x, ivec2 y);"));
-    s.append(TString("bvec3 notEqual(ivec3 x, ivec3 y);"));
-    s.append(TString("bvec4 notEqual(ivec4 x, ivec4 y);"));
+    symbolTable.insertBuiltIn(bool2, "equal", int2, int2);
+    symbolTable.insertBuiltIn(bool3, "equal", int3, int3);
+    symbolTable.insertBuiltIn(bool4, "equal", int4, int4);
 
-    s.append(TString("bvec2 notEqual(bvec2 x, bvec2 y);"));
-    s.append(TString("bvec3 notEqual(bvec3 x, bvec3 y);"));
-    s.append(TString("bvec4 notEqual(bvec4 x, bvec4 y);"));
+    symbolTable.insertBuiltIn(bool2, "equal", bool2, bool2);
+    symbolTable.insertBuiltIn(bool3, "equal", bool3, bool3);
+    symbolTable.insertBuiltIn(bool4, "equal", bool4, bool4);
 
-    s.append(TString("bool any(bvec2 x);"));
-    s.append(TString("bool any(bvec3 x);"));
-    s.append(TString("bool any(bvec4 x);"));
-
-    s.append(TString("bool all(bvec2 x);"));
-    s.append(TString("bool all(bvec3 x);"));
-    s.append(TString("bool all(bvec4 x);"));
+    symbolTable.insertBuiltIn(bool2, "notEqual", float2, float2);
+    symbolTable.insertBuiltIn(bool3, "notEqual", float3, float3);
+    symbolTable.insertBuiltIn(bool4, "notEqual", float4, float4);
 
-    s.append(TString("bvec2 not(bvec2 x);"));
-    s.append(TString("bvec3 not(bvec3 x);"));
-    s.append(TString("bvec4 not(bvec4 x);"));
+    symbolTable.insertBuiltIn(bool2, "notEqual", int2, int2);
+    symbolTable.insertBuiltIn(bool3, "notEqual", int3, int3);
+    symbolTable.insertBuiltIn(bool4, "notEqual", int4, int4);
 
-    //
-    // Texture Functions.
-    //
-    s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));
-    s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));
-    s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));
-    s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));
+    symbolTable.insertBuiltIn(bool2, "notEqual", bool2, bool2);
+    symbolTable.insertBuiltIn(bool3, "notEqual", bool3, bool3);
+    symbolTable.insertBuiltIn(bool4, "notEqual", bool4, bool4);
 
-    if (resources.OES_EGL_image_external) {
-        s.append(TString("vec4 texture2D(samplerExternalOES sampler, vec2 coord);"));
-        s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec3 coord);"));
-        s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec4 coord);"));
-    }
+    symbolTable.insertBuiltIn(bool1, "any", bool2);
+    symbolTable.insertBuiltIn(bool1, "any", bool3);
+    symbolTable.insertBuiltIn(bool1, "any", bool4);
 
-    if (resources.ARB_texture_rectangle) {
-        s.append(TString("vec4 texture2DRect(sampler2DRect sampler, vec2 coord);"));
-        s.append(TString("vec4 texture2DRectProj(sampler2DRect sampler, vec3 coord);"));
-        s.append(TString("vec4 texture2DRectProj(sampler2DRect sampler, vec4 coord);"));
-    }
+    symbolTable.insertBuiltIn(bool1, "all", bool2);
+    symbolTable.insertBuiltIn(bool1, "all", bool3);
+    symbolTable.insertBuiltIn(bool1, "all", bool4);
+
+    symbolTable.insertBuiltIn(bool2, "not", bool2);
+    symbolTable.insertBuiltIn(bool3, "not", bool3);
+    symbolTable.insertBuiltIn(bool4, "not", bool4);
+
+    TType *sampler2D = new TType(EbtSampler2D, EbpUndefined, EvqGlobal, 1);
+    TType *samplerCube = new TType(EbtSamplerCube, EbpUndefined, EvqGlobal, 1);
 
     //
-    // Noise functions.
-    //
-    //s.append(TString("float noise1(float x);"));
-    //s.append(TString("float noise1(vec2  x);"));
-    //s.append(TString("float noise1(vec3  x);"));
-    //s.append(TString("float noise1(vec4  x);"));
-
-    //s.append(TString("vec2 noise2(float x);"));
-    //s.append(TString("vec2 noise2(vec2  x);"));
-    //s.append(TString("vec2 noise2(vec3  x);"));
-    //s.append(TString("vec2 noise2(vec4  x);"));
-
-    //s.append(TString("vec3 noise3(float x);"));
-    //s.append(TString("vec3 noise3(vec2  x);"));
-    //s.append(TString("vec3 noise3(vec3  x);"));
-    //s.append(TString("vec3 noise3(vec4  x);"));
-
-    //s.append(TString("vec4 noise4(float x);"));
-    //s.append(TString("vec4 noise4(vec2  x);"));
-    //s.append(TString("vec4 noise4(vec3  x);"));
-    //s.append(TString("vec4 noise4(vec4  x);"));
-
-    return s;
-}
-
-//============================================================================
-//
-// Prototypes for built-in functions seen by vertex shaders only.
-//
-//============================================================================
-static TString BuiltInFunctionsVertex(const ShBuiltInResources& resources)
-{
-    TString s;
-
-    //
-    // Geometric Functions.
-    //
-    //s.append(TString("vec4 ftransform();"));
-
+    // Texture Functions for GLSL ES 1.0
     //
-    // Texture Functions.
-    //
-    s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);"));
-    s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);"));
-    s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);"));
-    s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);"));
+    symbolTable.insertBuiltIn(float4, "texture2D", sampler2D, float2);
+    symbolTable.insertBuiltIn(float4, "texture2DProj", sampler2D, float3);
+    symbolTable.insertBuiltIn(float4, "texture2DProj", sampler2D, float4);
+    symbolTable.insertBuiltIn(float4, "textureCube", samplerCube, float3);
 
-    return s;
-}
-
-//============================================================================
-//
-// Prototypes for built-in functions seen by fragment shaders only.
-//
-//============================================================================
-static TString BuiltInFunctionsFragment(const ShBuiltInResources& resources)
-{
-    TString s;
+    if (resources.OES_EGL_image_external)
+    {
+        TType *samplerExternalOES = new TType(EbtSamplerExternalOES, EbpUndefined, EvqGlobal, 1);
 
-    //
-    // Texture Functions.
-    //
-    s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord, float bias);"));
-    s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);"));
-    s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);"));
-    s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);"));
+        symbolTable.insertBuiltIn(float4, "texture2D", samplerExternalOES, float2);
+        symbolTable.insertBuiltIn(float4, "texture2DProj", samplerExternalOES, float3);
+        symbolTable.insertBuiltIn(float4, "texture2DProj", samplerExternalOES, float4);
+    }
 
-    if (resources.OES_standard_derivatives) {
-        s.append(TString("float dFdx(float p);"));
-        s.append(TString("vec2  dFdx(vec2  p);"));
-        s.append(TString("vec3  dFdx(vec3  p);"));
-        s.append(TString("vec4  dFdx(vec4  p);"));
+    if (resources.ARB_texture_rectangle)
+    {
+        TType *sampler2DRect = new TType(EbtSampler2DRect, EbpUndefined, EvqGlobal, 1);
 
-        s.append(TString("float dFdy(float p);"));
-        s.append(TString("vec2  dFdy(vec2  p);"));
-        s.append(TString("vec3  dFdy(vec3  p);"));
-        s.append(TString("vec4  dFdy(vec4  p);"));
-
-        s.append(TString("float fwidth(float p);"));
-        s.append(TString("vec2  fwidth(vec2  p);"));
-        s.append(TString("vec3  fwidth(vec3  p);"));
-        s.append(TString("vec4  fwidth(vec4  p);"));
+        symbolTable.insertBuiltIn(float4, "texture2DRect", sampler2DRect, float2);
+        symbolTable.insertBuiltIn(float4, "texture2DRectProj", sampler2DRect, float3);
+        symbolTable.insertBuiltIn(float4, "texture2DRectProj", sampler2DRect, float4);
     }
 
-    return s;
-}
+    if (type == SH_FRAGMENT_SHADER)
+    {
+        symbolTable.insertBuiltIn(float4, "texture2D", sampler2D, float2, float1);
+        symbolTable.insertBuiltIn(float4, "texture2DProj", sampler2D, float3, float1);
+        symbolTable.insertBuiltIn(float4, "texture2DProj", sampler2D, float4, float1);
+        symbolTable.insertBuiltIn(float4, "textureCube", samplerCube, float3, float1);
 
-//============================================================================
-//
-// Standard uniforms.
-//
-//============================================================================
-static TString StandardUniforms()
-{
-    TString s;
+        if (resources.OES_standard_derivatives)
+        {
+            symbolTable.insertBuiltIn(float1, "dFdx", float1);
+            symbolTable.insertBuiltIn(float2, "dFdx", float2);
+            symbolTable.insertBuiltIn(float3, "dFdx", float3);
+            symbolTable.insertBuiltIn(float4, "dFdx", float4);
+            
+            symbolTable.insertBuiltIn(float1, "dFdy", float1);
+            symbolTable.insertBuiltIn(float2, "dFdy", float2);
+            symbolTable.insertBuiltIn(float3, "dFdy", float3);
+            symbolTable.insertBuiltIn(float4, "dFdy", float4);
+
+            symbolTable.insertBuiltIn(float1, "fwidth", float1);
+            symbolTable.insertBuiltIn(float2, "fwidth", float2);
+            symbolTable.insertBuiltIn(float3, "fwidth", float3);
+            symbolTable.insertBuiltIn(float4, "fwidth", float4);
+        }
+    }
+
+    if(type == SH_VERTEX_SHADER)
+    {
+        symbolTable.insertBuiltIn(float4, "texture2DLod", sampler2D, float2, float1);
+        symbolTable.insertBuiltIn(float4, "texture2DProjLod", sampler2D, float3, float1);
+        symbolTable.insertBuiltIn(float4, "texture2DProjLod", sampler2D, float4, float1);
+        symbolTable.insertBuiltIn(float4, "textureCubeLod", samplerCube, float3, float1);
+    }
 
     //
     // Depth range in window coordinates
     //
-    s.append(TString("struct gl_DepthRangeParameters {"));
-    s.append(TString("    highp float near;"));        // n
-    s.append(TString("    highp float far;"));         // f
-    s.append(TString("    highp float diff;"));        // f - n
-    s.append(TString("};"));
-    s.append(TString("uniform gl_DepthRangeParameters gl_DepthRange;"));
-
-    return s;
-}
-
-//============================================================================
-//
-// Default precision for vertex shaders.
-//
-//============================================================================
-static TString DefaultPrecisionVertex()
-{
-    TString s;
-
-    s.append(TString("precision highp int;"));
-    s.append(TString("precision highp float;"));
-
-    return s;
-}
+    TFieldList *fields = NewPoolTFieldList();
+    TField *near = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("near"));
+    TField *far = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("far"));
+    TField *diff = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("diff"));
+    fields->push_back(near);
+    fields->push_back(far);
+    fields->push_back(diff);
+    TStructure *depthRangeStruct = new TStructure(NewPoolTString("gl_DepthRangeParameters"), fields);
+    TVariable *depthRangeParameters = new TVariable(&depthRangeStruct->name(), depthRangeStruct, true);
+    symbolTable.insert(*depthRangeParameters);
+    TVariable *depthRange = new TVariable(NewPoolTString("gl_DepthRange"), TType(depthRangeStruct));
+    depthRange->setQualifier(EvqUniform);
+    symbolTable.insert(*depthRange);
 
-//============================================================================
-//
-// Default precision for fragment shaders.
-//
-//============================================================================
-static TString DefaultPrecisionFragment()
-{
-    TString s;
-
-    s.append(TString("precision mediump int;"));
-    // No default precision for float in fragment shaders
-
-    return s;
-}
-
-//============================================================================
-//
-// Implementation dependent built-in constants.
-//
-//============================================================================
-static TString BuiltInConstants(ShShaderSpec spec, const ShBuiltInResources &resources)
-{
-    TStringStream s;
-
-    s << "const int gl_MaxVertexAttribs = " << resources.MaxVertexAttribs << ";";
-    s << "const int gl_MaxVertexUniformVectors = " << resources.MaxVertexUniformVectors << ";";
-
-    s << "const int gl_MaxVaryingVectors = " << resources.MaxVaryingVectors << ";";
-    s << "const int gl_MaxVertexTextureImageUnits = " << resources.MaxVertexTextureImageUnits << ";";
-    s << "const int gl_MaxCombinedTextureImageUnits = " << resources.MaxCombinedTextureImageUnits << ";";
-    s << "const int gl_MaxTextureImageUnits = " << resources.MaxTextureImageUnits << ";";
-    s << "const int gl_MaxFragmentUniformVectors = " << resources.MaxFragmentUniformVectors << ";";
+    //
+    // Implementation dependent built-in constants.
+    //
+    symbolTable.insertConstInt("gl_MaxVertexAttribs", resources.MaxVertexAttribs);
+    symbolTable.insertConstInt("gl_MaxVertexUniformVectors", resources.MaxVertexUniformVectors);
+    symbolTable.insertConstInt("gl_MaxVaryingVectors", resources.MaxVaryingVectors);
+    symbolTable.insertConstInt("gl_MaxVertexTextureImageUnits", resources.MaxVertexTextureImageUnits);
+    symbolTable.insertConstInt("gl_MaxCombinedTextureImageUnits", resources.MaxCombinedTextureImageUnits);
+    symbolTable.insertConstInt("gl_MaxTextureImageUnits", resources.MaxTextureImageUnits);
+    symbolTable.insertConstInt("gl_MaxFragmentUniformVectors", resources.MaxFragmentUniformVectors);
 
     if (spec != SH_CSS_SHADERS_SPEC)
-        s << "const int gl_MaxDrawBuffers = " << resources.MaxDrawBuffers << ";";
-
-    return s.str();
-}
-
-void TBuiltIns::initialize(ShShaderType type, ShShaderSpec spec,
-                           const ShBuiltInResources& resources)
-{
-    switch (type) {
-    case SH_FRAGMENT_SHADER:
-        builtInStrings.push_back(DefaultPrecisionFragment());
-        builtInStrings.push_back(BuiltInFunctionsCommon(resources));
-        builtInStrings.push_back(BuiltInFunctionsFragment(resources));
-        builtInStrings.push_back(StandardUniforms());
-        break;
-
-    case SH_VERTEX_SHADER:
-        builtInStrings.push_back(DefaultPrecisionVertex());
-        builtInStrings.push_back(BuiltInFunctionsCommon(resources));
-        builtInStrings.push_back(BuiltInFunctionsVertex(resources));
-        builtInStrings.push_back(StandardUniforms());
-        break;
-
-    default: assert(false && "Language not supported");
+    {
+        symbolTable.insertConstInt("gl_MaxDrawBuffers", resources.MaxDrawBuffers);
     }
-
-    builtInStrings.push_back(BuiltInConstants(spec, resources));
 }
 
 void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
-                      const ShBuiltInResources& resources,
-                      TSymbolTable& symbolTable)
+                      const ShBuiltInResources &resources,
+                      TSymbolTable &symbolTable)
 {
     //
     // First, insert some special built-in variables that are not in 
     // the built-in header files.
     //
     switch(type) {
     case SH_FRAGMENT_SHADER:
         symbolTable.insert(*new TVariable(NewPoolTString("gl_FragCoord"),                       TType(EbtFloat, EbpMedium, EvqFragCoord,   4)));
@@ -534,16 +434,20 @@ void IdentifyBuiltIns(ShShaderType type,
 
         //
         // In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available.
         // Instead, css_MixColor and css_ColorMatrix are available.
         //
         if (spec != SH_CSS_SHADERS_SPEC) {
             symbolTable.insert(*new TVariable(NewPoolTString("gl_FragColor"),                   TType(EbtFloat, EbpMedium, EvqFragColor,   4)));
             symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData,    4)));
+            if (resources.EXT_frag_depth) {
+                symbolTable.insert(*new TVariable(NewPoolTString("gl_FragDepthEXT"),            TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1)));
+                symbolTable.relateToExtension("gl_FragDepthEXT", "GL_EXT_frag_depth");
+            }
         } else {
             symbolTable.insert(*new TVariable(NewPoolTString("css_MixColor"),                   TType(EbtFloat, EbpMedium, EvqGlobal,      4)));
             symbolTable.insert(*new TVariable(NewPoolTString("css_ColorMatrix"),                TType(EbtFloat, EbpMedium, EvqGlobal,      4, true)));
         }
 
         break;
 
     case SH_VERTEX_SHADER:
@@ -555,18 +459,16 @@ void IdentifyBuiltIns(ShShaderType type,
     }
 
     //
     // Next, identify which built-ins from the already loaded headers have
     // a mapping to an operator.  Those that are not identified as such are
     // expected to be resolved through a library of functions, versus as
     // operations.
     //
-    symbolTable.relateToOperator("not",              EOpVectorLogicalNot);
-
     symbolTable.relateToOperator("matrixCompMult",   EOpMul);
 
     symbolTable.relateToOperator("equal",            EOpVectorEqual);
     symbolTable.relateToOperator("notEqual",         EOpVectorNotEqual);
     symbolTable.relateToOperator("lessThan",         EOpLessThan);
     symbolTable.relateToOperator("greaterThan",      EOpGreaterThan);
     symbolTable.relateToOperator("lessThanEqual",    EOpLessThanEqual);
     symbolTable.relateToOperator("greaterThanEqual", EOpGreaterThanEqual);
@@ -607,16 +509,17 @@ void IdentifyBuiltIns(ShShaderType type,
     symbolTable.relateToOperator("cross",        EOpCross);
     symbolTable.relateToOperator("normalize",    EOpNormalize);
     symbolTable.relateToOperator("faceforward",  EOpFaceForward);
     symbolTable.relateToOperator("reflect",      EOpReflect);
     symbolTable.relateToOperator("refract",      EOpRefract);
     
     symbolTable.relateToOperator("any",          EOpAny);
     symbolTable.relateToOperator("all",          EOpAll);
+    symbolTable.relateToOperator("not",          EOpVectorLogicalNot);
 
     // Map language-specific operators.
     switch(type) {
     case SH_VERTEX_SHADER:
         break;
     case SH_FRAGMENT_SHADER:
         if (resources.OES_standard_derivatives) {
             symbolTable.relateToOperator("dFdx",   EOpDFdx);
@@ -651,9 +554,11 @@ void InitExtensionBehavior(const ShBuilt
     if (resources.OES_standard_derivatives)
         extBehavior["GL_OES_standard_derivatives"] = EBhUndefined;
     if (resources.OES_EGL_image_external)
         extBehavior["GL_OES_EGL_image_external"] = EBhUndefined;
     if (resources.ARB_texture_rectangle)
         extBehavior["GL_ARB_texture_rectangle"] = EBhUndefined;
     if (resources.EXT_draw_buffers)
         extBehavior["GL_EXT_draw_buffers"] = EBhUndefined;
+    if (resources.EXT_frag_depth)
+        extBehavior["GL_EXT_frag_depth"] = EBhUndefined;
 }
--- a/gfx/angle/src/compiler/Initialize.h
+++ b/gfx/angle/src/compiler/Initialize.h
@@ -1,34 +1,22 @@
 //
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
 #ifndef _INITIALIZE_INCLUDED_
 #define _INITIALIZE_INCLUDED_
 
 #include "compiler/Common.h"
 #include "compiler/ShHandle.h"
 #include "compiler/SymbolTable.h"
 
-typedef TVector<TString> TBuiltInStrings;
-
-class TBuiltIns {
-public:
-    POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
-
-    void initialize(ShShaderType type, ShShaderSpec spec,
-                    const ShBuiltInResources& resources);
-    const TBuiltInStrings& getBuiltInStrings() { return builtInStrings; }
-
-protected:
-    TBuiltInStrings builtInStrings;
-};
+void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &table);
 
 void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
                       const ShBuiltInResources& resources,
                       TSymbolTable& symbolTable);
 
 void InitExtensionBehavior(const ShBuiltInResources& resources,
                            TExtensionBehavior& extensionBehavior);
 
--- a/gfx/angle/src/compiler/InitializeDll.cpp
+++ b/gfx/angle/src/compiler/InitializeDll.cpp
@@ -5,111 +5,28 @@
 //
 
 #include "compiler/InitializeDll.h"
 
 #include "compiler/InitializeGlobals.h"
 #include "compiler/InitializeParseContext.h"
 #include "compiler/osinclude.h"
 
-OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
-
 bool InitProcess()
 {
-    if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX) {
-        //
-        // Function is re-entrant.
-        //
-        return true;
-    }
-
-    ThreadInitializeIndex = OS_AllocTLSIndex();
-
-    if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
-        assert(0 && "InitProcess(): Failed to allocate TLS area for init flag");
-        return false;
-    }
-
-
     if (!InitializePoolIndex()) {
         assert(0 && "InitProcess(): Failed to initalize global pool");
         return false;
     }
 
     if (!InitializeParseContextIndex()) {
         assert(0 && "InitProcess(): Failed to initalize parse context");
         return false;
     }
 
-    return InitThread();
-}
-
-bool DetachProcess()
-{
-    bool success = true;
-
-    if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
-        return true;
-
-    success = DetachThread();
-
-    if (!FreeParseContextIndex())
-        success = false;
-
-    FreePoolIndex();
-
-    OS_FreeTLSIndex(ThreadInitializeIndex);
-    ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
-
-    return success;
-}
-
-bool InitThread()
-{
-    //
-    // This function is re-entrant
-    //
-    if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
-        assert(0 && "InitThread(): Process hasn't been initalised.");
-        return false;
-    }
-
-    if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
-        return true;
-
-    InitializeGlobalPools();
-
-    if (!InitializeGlobalParseContext())
-        return false;
-
-    if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)1)) {
-        assert(0 && "InitThread(): Unable to set init flag.");
-        return false;
-    }
-
     return true;
 }
 
-bool DetachThread()
+void DetachProcess()
 {
-    bool success = true;
-
-    if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
-        return true;
-
-    //
-    // Function is re-entrant and this thread may not have been initalised.
-    //
-    if (OS_GetTLSValue(ThreadInitializeIndex) != 0) {
-        if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)0)) {
-            assert(0 && "DetachThread(): Unable to clear init flag.");
-            success = false;
-        }
-
-        if (!FreeParseContext())
-            success = false;
-
-        FreeGlobalPools();
-    }
-
-    return success;
+    FreeParseContextIndex();
+    FreePoolIndex();
 }
-
--- a/gfx/angle/src/compiler/InitializeDll.h
+++ b/gfx/angle/src/compiler/InitializeDll.h
@@ -2,15 +2,12 @@
 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 #ifndef __INITIALIZEDLL_H
 #define __INITIALIZEDLL_H
 
 bool InitProcess();
-bool DetachProcess();
-
-bool InitThread();
-bool DetachThread();
+void DetachProcess();
 
 #endif // __INITIALIZEDLL_H
 
--- a/gfx/angle/src/compiler/InitializeGlobals.h
+++ b/gfx/angle/src/compiler/InitializeGlobals.h
@@ -2,14 +2,12 @@
 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
 #ifndef __INITIALIZE_GLOBALS_INCLUDED_
 #define __INITIALIZE_GLOBALS_INCLUDED_
 
-void InitializeGlobalPools();
-void FreeGlobalPools();
 bool InitializePoolIndex();
 void FreePoolIndex();
 
 #endif // __INITIALIZE_GLOBALS_INCLUDED_
--- a/gfx/angle/src/compiler/InitializeParseContext.cpp
+++ b/gfx/angle/src/compiler/InitializeParseContext.cpp
@@ -7,90 +7,34 @@
 #include "compiler/InitializeParseContext.h"
 
 #include "compiler/osinclude.h"
 
 OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
 
 bool InitializeParseContextIndex()
 {
-    if (GlobalParseContextIndex != OS_INVALID_TLS_INDEX) {
-        assert(0 && "InitializeParseContextIndex(): Parse Context already initalized");
-        return false;
-    }
-
-    //
-    // Allocate a TLS index.
-    //
-    GlobalParseContextIndex = OS_AllocTLSIndex();
-    
-    if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
-        assert(0 && "InitializeParseContextIndex(): Parse Context already initalized");
-        return false;
-    }
+    assert(GlobalParseContextIndex == OS_INVALID_TLS_INDEX);
 
-    return true;
-}
-
-bool FreeParseContextIndex()
-{
-    OS_TLSIndex tlsiIndex = GlobalParseContextIndex;
-
-    if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
-        assert(0 && "FreeParseContextIndex(): Parse Context index not initalized");
-        return false;
-    }
-
-    GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
-
-    return OS_FreeTLSIndex(tlsiIndex);
+    GlobalParseContextIndex = OS_AllocTLSIndex();
+    return GlobalParseContextIndex != OS_INVALID_TLS_INDEX;
 }
 
-bool InitializeGlobalParseContext()
+void FreeParseContextIndex()
 {
-    if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
-        assert(0 && "InitializeGlobalParseContext(): Parse Context index not initalized");
-        return false;
-    }
+    assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX);
 
-    TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex));
-    if (lpParseContext != 0) {
-        assert(0 && "InitializeParseContextIndex(): Parse Context already initalized");
-        return false;
-    }
-
-    TThreadParseContext *lpThreadData = new TThreadParseContext();
-    if (lpThreadData == 0) {
-        assert(0 && "InitializeGlobalParseContext(): Unable to create thread parse context");
-        return false;
-    }
-
-    lpThreadData->lpGlobalParseContext = 0;
-    OS_SetTLSValue(GlobalParseContextIndex, lpThreadData);
-
-    return true;
+    OS_FreeTLSIndex(GlobalParseContextIndex);
+    GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
 }
 
-bool FreeParseContext()
+void SetGlobalParseContext(TParseContext* context)
 {
-    if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
-        assert(0 && "FreeParseContext(): Parse Context index not initalized");
-        return false;
-    }
-
-    TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex));
-    if (lpParseContext)
-        delete lpParseContext;
-
-    return true;
+    assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX);
+    OS_SetTLSValue(GlobalParseContextIndex, context);
 }
 
-TParseContextPointer& GetGlobalParseContext()
+TParseContext* GetGlobalParseContext()
 {
-    //
-    // Minimal error checking for speed
-    //
-
-    TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex));
-
-    return lpParseContext->lpGlobalParseContext;
+    assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX);
+    return static_cast<TParseContext*>(OS_GetTLSValue(GlobalParseContextIndex));
 }
 
--- a/gfx/angle/src/compiler/InitializeParseContext.h
+++ b/gfx/angle/src/compiler/InitializeParseContext.h
@@ -3,24 +3,15 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
 #ifndef __INITIALIZE_PARSE_CONTEXT_INCLUDED_
 #define __INITIALIZE_PARSE_CONTEXT_INCLUDED_
 
 bool InitializeParseContextIndex();
-bool FreeParseContextIndex();
-
-bool InitializeGlobalParseContext();
-bool FreeParseContext();
+void FreeParseContextIndex();
 
 struct TParseContext;
-typedef TParseContext* TParseContextPointer;
-extern TParseContextPointer& GetGlobalParseContext();
-#define GlobalParseContext GetGlobalParseContext()
-
-typedef struct TThreadParseContextRec
-{
-    TParseContext *lpGlobalParseContext;
-} TThreadParseContext;
+extern void SetGlobalParseContext(TParseContext* context);
+extern TParseContext* GetGlobalParseContext();
 
 #endif // __INITIALIZE_PARSE_CONTEXT_INCLUDED_
--- a/gfx/angle/src/compiler/Intermediate.cpp
+++ b/gfx/angle/src/compiler/Intermediate.cpp
@@ -126,30 +126,30 @@ const char* getOperatorString(TOperator 
 //
 /////////////////////////////////////////////////////////////////////////////
 
 //
 // Add a terminal node for an identifier in an expression.
 //
 // Returns the added node.
 //
-TIntermSymbol* TIntermediate::addSymbol(int id, const TString& name, const TType& type, TSourceLoc line)
+TIntermSymbol* TIntermediate::addSymbol(int id, const TString& name, const TType& type, const TSourceLoc& line)
 {
     TIntermSymbol* node = new TIntermSymbol(id, name, type);
     node->setLine(line);
 
     return node;
 }
 
 //
 // Connect two nodes with a new parent that does a binary operation on the nodes.
 //
 // Returns the added node.
 //
-TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc line, TSymbolTable& symbolTable)
+TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc& line, TSymbolTable& symbolTable)
 {
     switch (op) {
         case EOpEqual:
         case EOpNotEqual:
             if (left->isArray())
                 return 0;
             break;
         case EOpLessThan:
@@ -195,18 +195,16 @@ TIntermTyped* TIntermediate::addBinaryMa
         }
     }
 
     //
     // Need a new node holding things together then.  Make
     // one and promote it to the right type.
     //
     TIntermBinary* node = new TIntermBinary(op);
-    if (line == 0)
-        line = right->getLine();
     node->setLine(line);
 
     node->setLeft(left);
     node->setRight(right);
     if (!node->promote(infoSink))
         return 0;
 
     //
@@ -225,25 +223,23 @@ TIntermTyped* TIntermediate::addBinaryMa
     return node;
 }
 
 //
 // Connect two nodes through an assignment.
 //
 // Returns the added node.
 //
-TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc line)
+TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc& line)
 {
     //
     // Like adding binary math, except the conversion can only go
     // from right to left.
     //
     TIntermBinary* node = new TIntermBinary(op);
-    if (line == 0)
-        line = left->getLine();
     node->setLine(line);
 
     TIntermTyped* child = addConversion(op, left->getType(), right);
     if (child == 0)
         return 0;
 
     node->setLeft(left);
     node->setRight(child);
@@ -255,42 +251,40 @@ TIntermTyped* TIntermediate::addAssign(T
 
 //
 // Connect two nodes through an index operator, where the left node is the base
 // of an array or struct, and the right node is a direct or indirect offset.
 //
 // Returns the added node.
 // The caller should set the type of the returned node.
 //
-TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc line)
+TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, const TSourceLoc& line)
 {
     TIntermBinary* node = new TIntermBinary(op);
-    if (line == 0)
-        line = index->getLine();
     node->setLine(line);
     node->setLeft(base);
     node->setRight(index);
 
     // caller should set the type
 
     return node;
 }
 
 //
 // Add one node as the parent of another that it operates on.
 //
 // Returns the added node.
 //
-TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode, TSourceLoc line, TSymbolTable& symbolTable)
+TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode, const TSourceLoc& line, TSymbolTable& symbolTable)
 {
     TIntermUnary* node;
     TIntermTyped* child = childNode->getAsTyped();
 
     if (child == 0) {
-        infoSink.info.message(EPrefixInternalError, "Bad type in AddUnaryMath", line);
+        infoSink.info.message(EPrefixInternalError, line, "Bad type in AddUnaryMath");
         return 0;
     }
 
     switch (op) {
         case EOpLogicalNot:
             if (child->getType().getBasicType() != EbtBool || child->getType().isMatrix() || child->getType().isArray() || child->getType().isVector()) {
                 return 0;
             }
@@ -343,18 +337,16 @@ TIntermTyped* TIntermediate::addUnaryMat
     TIntermConstantUnion *childTempConstant = 0;
     if (child->getAsConstantUnion())
         childTempConstant = child->getAsConstantUnion();
 
     //
     // Make a new node for the operator.
     //
     node = new TIntermUnary(op);
-    if (line == 0)
-        line = child->getLine();
     node->setLine(line);
     node->setOperand(child);
 
     if (! node->promote(infoSink))
         return 0;
 
     if (childTempConstant)  {
         TIntermTyped* newChild = childTempConstant->fold(op, 0, infoSink);
@@ -371,43 +363,40 @@ TIntermTyped* TIntermediate::addUnaryMat
 // does lots of error checking and fixing.  Especially for establishing
 // a function call's operation on it's set of parameters.  Sequences
 // of instructions are also aggregates, but they just direnctly set
 // their operator to EOpSequence.
 //
 // Returns an aggregate node, which could be the one passed in if
 // it was already an aggregate but no operator was set.
 //
-TIntermAggregate* TIntermediate::setAggregateOperator(TIntermNode* node, TOperator op, TSourceLoc line)
+TIntermAggregate* TIntermediate::setAggregateOperator(TIntermNode* node, TOperator op, const TSourceLoc& line)
 {
     TIntermAggregate* aggNode;
 
     //
     // Make sure we have an aggregate.  If not turn it into one.
     //
     if (node) {
         aggNode = node->getAsAggregate();
         if (aggNode == 0 || aggNode->getOp() != EOpNull) {
             //
             // Make an aggregate containing this node.
             //
             aggNode = new TIntermAggregate();
             aggNode->getSequence().push_back(node);
-            if (line == 0)
-                line = node->getLine();
         }
     } else
         aggNode = new TIntermAggregate();
 
     //
     // Set the operator.
     //
     aggNode->setOp(op);
-    if (line != 0)
-        aggNode->setLine(line);
+    aggNode->setLine(line);
 
     return aggNode;
 }
 
 //
 // Convert one type to another.
 //
 // Returns the node representing the conversion, which could be the same
@@ -486,40 +475,40 @@ TIntermTyped* TIntermediate::addConversi
 
         TOperator newOp = EOpNull;
         switch (promoteTo) {
             case EbtFloat:
                 switch (node->getBasicType()) {
                     case EbtInt:   newOp = EOpConvIntToFloat;  break;
                     case EbtBool:  newOp = EOpConvBoolToFloat; break;
                     default:
-                        infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
+                        infoSink.info.message(EPrefixInternalError, node->getLine(), "Bad promotion node");
                         return 0;
                 }
                 break;
             case EbtBool:
                 switch (node->getBasicType()) {
                     case EbtInt:   newOp = EOpConvIntToBool;   break;
                     case EbtFloat: newOp = EOpConvFloatToBool; break;
                     default:
-                        infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
+                        infoSink.info.message(EPrefixInternalError, node->getLine(), "Bad promotion node");
                         return 0;
                 }
                 break;
             case EbtInt:
                 switch (node->getBasicType()) {
                     case EbtBool:   newOp = EOpConvBoolToInt;  break;
                     case EbtFloat:  newOp = EOpConvFloatToInt; break;
                     default:
-                        infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
+                        infoSink.info.message(EPrefixInternalError, node->getLine(), "Bad promotion node");
                         return 0;
                 }
                 break;
             default:
-                infoSink.info.message(EPrefixInternalError, "Bad promotion type", node->getLine());
+                infoSink.info.message(EPrefixInternalError, node->getLine(), "Bad promotion type");
                 return 0;
         }
 
         TType type(promoteTo, node->getPrecision(), EvqTemporary, node->getNominalSize(), node->isMatrix(), node->isArray());
         newNode = new TIntermUnary(newOp, type);
         newNode->setLine(node->getLine());
         newNode->setOperand(node);
 
@@ -529,68 +518,63 @@ TIntermTyped* TIntermediate::addConversi
 
 //
 // Safe way to combine two nodes into an aggregate.  Works with null pointers,
 // a node that's not a aggregate yet, etc.
 //
 // Returns the resulting aggregate, unless 0 was passed in for
 // both existing nodes.
 //
-TIntermAggregate* TIntermediate::growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc line)
+TIntermAggregate* TIntermediate::growAggregate(TIntermNode* left, TIntermNode* right, const TSourceLoc& line)
 {
     if (left == 0 && right == 0)
         return 0;
 
     TIntermAggregate* aggNode = 0;
     if (left)
         aggNode = left->getAsAggregate();
     if (!aggNode || aggNode->getOp() != EOpNull) {
         aggNode = new TIntermAggregate;
         if (left)
             aggNode->getSequence().push_back(left);
     }
 
     if (right)
         aggNode->getSequence().push_back(right);
 
-    if (line != 0)
-        aggNode->setLine(line);
+    aggNode->setLine(line);
 
     return aggNode;
 }
 
 //
 // Turn an existing node into an aggregate.
 //
 // Returns an aggregate, unless 0 was passed in for the existing node.
 //
-TIntermAggregate* TIntermediate::makeAggregate(TIntermNode* node, TSourceLoc line)
+TIntermAggregate* TIntermediate::makeAggregate(TIntermNode* node, const TSourceLoc& line)
 {
     if (node == 0)
         return 0;
 
     TIntermAggregate* aggNode = new TIntermAggregate;
     aggNode->getSequence().push_back(node);
-
-    if (line != 0)
-        aggNode->setLine(line);
-    else
-        aggNode->setLine(node->getLine());
+    aggNode->setLine(line);
 
     return aggNode;
 }
 
 //
 // For "if" test nodes.  There are three children; a condition,
 // a true path, and a false path.  The two paths are in the
 // nodePair.
 //
 // Returns the selection node created.
 //
-TIntermNode* TIntermediate::addSelection(TIntermTyped* cond, TIntermNodePair nodePair, TSourceLoc line)
+TIntermNode* TIntermediate::addSelection(TIntermTyped* cond, TIntermNodePair nodePair, const TSourceLoc& line)
 {
     //
     // For compile time constant selections, prune the code and
     // test now.
     //
 
     if (cond->getAsTyped() && cond->getAsTyped()->getAsConstantUnion()) {
         if (cond->getAsConstantUnion()->getBConst(0) == true)
@@ -601,17 +585,17 @@ TIntermNode* TIntermediate::addSelection
 
     TIntermSelection* node = new TIntermSelection(cond, nodePair.node1, nodePair.node2);
     node->setLine(line);
 
     return node;
 }
 
 
-TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc line)
+TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc& line)
 {
     if (left->getType().getQualifier() == EvqConst && right->getType().getQualifier() == EvqConst) {
         return right;
     } else {
         TIntermTyped *commaAggregate = growAggregate(left, right, line);
         commaAggregate->getAsAggregate()->setOp(EOpComma);
         commaAggregate->setType(right->getType());
         commaAggregate->getTypePointer()->setQualifier(EvqTemporary);
@@ -621,17 +605,17 @@ TIntermTyped* TIntermediate::addComma(TI
 
 //
 // For "?:" test nodes.  There are three children; a condition,
 // a true path, and a false path.  The two paths are specified
 // as separate parameters.
 //
 // Returns the selection node created, or 0 if one could not be.
 //
-TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc line)
+TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc& line)
 {
     //
     // Get compatible types.
     //
     TIntermTyped* child = addConversion(EOpSequence, trueBlock->getType(), falseBlock);
     if (child)
         falseBlock = child;
     else {
@@ -664,25 +648,25 @@ TIntermTyped* TIntermediate::addSelectio
 }
 
 //
 // Constant terminal nodes.  Has a union that contains bool, float or int constants
 //
 // Returns the constant union node created.
 //
 
-TIntermConstantUnion* TIntermediate::addConstantUnion(ConstantUnion* unionArrayPointer, const TType& t, TSourceLoc line)
+TIntermConstantUnion* TIntermediate::addConstantUnion(ConstantUnion* unionArrayPointer, const TType& t, const TSourceLoc& line)
 {
     TIntermConstantUnion* node = new TIntermConstantUnion(unionArrayPointer, t);
     node->setLine(line);
 
     return node;
 }
 
-TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, TSourceLoc line)
+TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, const TSourceLoc& line)
 {
 
     TIntermAggregate* node = new TIntermAggregate(EOpSequence);
 
     node->setLine(line);
     TIntermConstantUnion* constIntNode;
     TIntermSequence &sequenceVector = node->getSequence();
     ConstantUnion* unionArray;
@@ -695,33 +679,33 @@ TIntermTyped* TIntermediate::addSwizzle(
     }
 
     return node;
 }
 
 //
 // Create loop nodes.
 //
-TIntermNode* TIntermediate::addLoop(TLoopType type, TIntermNode* init, TIntermTyped* cond, TIntermTyped* expr, TIntermNode* body, TSourceLoc line)
+TIntermNode* TIntermediate::addLoop(TLoopType type, TIntermNode* init, TIntermTyped* cond, TIntermTyped* expr, TIntermNode* body, const TSourceLoc& line)
 {
     TIntermNode* node = new TIntermLoop(type, init, cond, expr, body);
     node->setLine(line);
 
     return node;
 }
 
 //
 // Add branches.
 //
-TIntermBranch* TIntermediate::addBranch(TOperator branchOp, TSourceLoc line)
+TIntermBranch* TIntermediate::addBranch(TOperator branchOp, const TSourceLoc& line)
 {
     return addBranch(branchOp, 0, line);
 }
 
-TIntermBranch* TIntermediate::addBranch(TOperator branchOp, TIntermTyped* expression, TSourceLoc line)
+TIntermBranch* TIntermediate::addBranch(TOperator branchOp, TIntermTyped* expression, const TSourceLoc& line)
 {
     TIntermBranch* node = new TIntermBranch(branchOp, expression);
     node->setLine(line);
 
     return node;
 }
 
 //
@@ -856,17 +840,17 @@ bool TIntermUnary::promote(TInfoSink&)
 // makes the operator the correct one for the operands.
 //
 // Returns false if operator can't work on operands.
 //
 bool TIntermBinary::promote(TInfoSink& infoSink)
 {
     // This function only handles scalars, vectors, and matrices.
     if (left->isArray() || right->isArray()) {
-        infoSink.info.message(EPrefixInternalError, "Invalid operation for arrays", getLine());
+        infoSink.info.message(EPrefixInternalError, getLine(), "Invalid operation for arrays");
         return false;
     }
 
     // GLSL ES 2.0 does not support implicit type casting.
     // So the basic type should always match.
     if (left->getBasicType() != right->getBasicType())
         return false;
 
@@ -961,17 +945,17 @@ bool TIntermBinary::promote(TInfoSink& i
             } else if (!left->isMatrix() && !right->isMatrix()) {
                 if (left->isVector() && right->isVector()) {
                     // leave as component product
                 } else if (left->isVector() || right->isVector()) {
                     op = EOpVectorTimesScalar;
                     setType(TType(basicType, higherPrecision, EvqTemporary, size, false));
                 }
             } else {
-                infoSink.info.message(EPrefixInternalError, "Missing elses", getLine());
+                infoSink.info.message(EPrefixInternalError, getLine(), "Missing elses");
                 return false;
             }
             break;
         case EOpMulAssign:
             if (!left->isMatrix() && right->isMatrix()) {
                 if (left->isVector())
                     op = EOpVectorTimesMatrixAssign;
                 else {
@@ -990,17 +974,17 @@ bool TIntermBinary::promote(TInfoSink& i
                     // leave as component product
                 } else if (left->isVector() || right->isVector()) {
                     if (! left->isVector())
                         return false;
                     op = EOpVectorTimesScalarAssign;
                     setType(TType(basicType, higherPrecision, EvqTemporary, size, false));
                 }
             } else {
-                infoSink.info.message(EPrefixInternalError, "Missing elses", getLine());
+                infoSink.info.message(EPrefixInternalError, getLine(), "Missing elses");
                 return false;
             }
             break;
 
         case EOpAssign:
         case EOpInitialize:
         case EOpAdd:
         case EOpSub:
@@ -1030,48 +1014,47 @@ bool TIntermBinary::promote(TInfoSink& i
             return false;
     }
     
     return true;
 }
 
 bool CompareStruct(const TType& leftNodeType, ConstantUnion* rightUnionArray, ConstantUnion* leftUnionArray)
 {
-    const TTypeList* fields = leftNodeType.getStruct();
+    const TFieldList& fields = leftNodeType.getStruct()->fields();
 
-    size_t structSize = fields->size();
-    int index = 0;
+    size_t structSize = fields.size();
+    size_t index = 0;
 
     for (size_t j = 0; j < structSize; j++) {
-        int size = (*fields)[j].type->getObjectSize();
-        for (int i = 0; i < size; i++) {
-            if ((*fields)[j].type->getBasicType() == EbtStruct) {
-                if (!CompareStructure(*(*fields)[j].type, &rightUnionArray[index], &leftUnionArray[index]))
+        size_t size = fields[j]->type()->getObjectSize();
+        for (size_t i = 0; i < size; i++) {
+            if (fields[j]->type()->getBasicType() == EbtStruct) {
+                if (!CompareStructure(*(fields[j]->type()), &rightUnionArray[index], &leftUnionArray[index]))
                     return false;
             } else {
                 if (leftUnionArray[index] != rightUnionArray[index])
                     return false;
                 index++;
             }
-
         }
     }
     return true;
 }
 
 bool CompareStructure(const TType& leftNodeType, ConstantUnion* rightUnionArray, ConstantUnion* leftUnionArray)
 {
     if (leftNodeType.isArray()) {
         TType typeWithoutArrayness = leftNodeType;
         typeWithoutArrayness.clearArrayness();
 
-        int arraySize = leftNodeType.getArraySize();
+        size_t arraySize = leftNodeType.getArraySize();
 
-        for (int i = 0; i < arraySize; ++i) {
-            int offset = typeWithoutArrayness.getObjectSize() * i;
+        for (size_t i = 0; i < arraySize; ++i) {
+            size_t offset = typeWithoutArrayness.getObjectSize() * i;
             if (!CompareStruct(typeWithoutArrayness, &rightUnionArray[offset], &leftUnionArray[offset]))
                 return false;
         }
     } else
         return CompareStruct(leftNodeType, rightUnionArray, leftUnionArray);
 
     return true;
 }
@@ -1081,70 +1064,70 @@ bool CompareStructure(const TType& leftN
 // without generating run-time code.
 //
 // Returns the node to keep using, which may or may not be the node passed in.
 //
 
 TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNode, TInfoSink& infoSink)
 {
     ConstantUnion *unionArray = getUnionArrayPointer();
-    int objectSize = getType().getObjectSize();
+    size_t objectSize = getType().getObjectSize();
 
     if (constantNode) {  // binary operations
         TIntermConstantUnion *node = constantNode->getAsConstantUnion();
         ConstantUnion *rightUnionArray = node->getUnionArrayPointer();
         TType returnType = getType();
 
         // for a case like float f = 1.2 + vec4(2,3,4,5);
         if (constantNode->getType().getObjectSize() == 1 && objectSize > 1) {
             rightUnionArray = new ConstantUnion[objectSize];
-            for (int i = 0; i < objectSize; ++i)
+            for (size_t i = 0; i < objectSize; ++i)
                 rightUnionArray[i] = *node->getUnionArrayPointer();
             returnType = getType();
         } else if (constantNode->getType().getObjectSize() > 1 && objectSize == 1) {
             // for a case like float f = vec4(2,3,4,5) + 1.2;
             unionArray = new ConstantUnion[constantNode->getType().getObjectSize()];
-            for (int i = 0; i < constantNode->getType().getObjectSize(); ++i)
+            for (size_t i = 0; i < constantNode->getType().getObjectSize(); ++i)
                 unionArray[i] = *getUnionArrayPointer();
             returnType = node->getType();
             objectSize = constantNode->getType().getObjectSize();
         }
 
         ConstantUnion* tempConstArray = 0;
         TIntermConstantUnion *tempNode;
 
         bool boolNodeFlag = false;
         switch(op) {
             case EOpAdd:
                 tempConstArray = new ConstantUnion[objectSize];
                 {// support MSVC++6.0
-                    for (int i = 0; i < objectSize; i++)
+                    for (size_t i = 0; i < objectSize; i++)
                         tempConstArray[i] = unionArray[i] + rightUnionArray[i];
                 }
                 break;
             case EOpSub:
                 tempConstArray = new ConstantUnion[objectSize];
                 {// support MSVC++6.0
-                    for (int i = 0; i < objectSize; i++)
+                    for (size_t i = 0; i < objectSize; i++)
                         tempConstArray[i] = unionArray[i] - rightUnionArray[i];
                 }
                 break;
 
             case EOpMul:
             case EOpVectorTimesScalar:
             case EOpMatrixTimesScalar:
                 tempConstArray = new ConstantUnion[objectSize];
                 {// support MSVC++6.0
-                    for (int i = 0; i < objectSize; i++)
+                    for (size_t i = 0; i < objectSize; i++)
                         tempConstArray[i] = unionArray[i] * rightUnionArray[i];
                 }
                 break;
             case EOpMatrixTimesMatrix:
                 if (getType().getBasicType() != EbtFloat || node->getBasicType() != EbtFloat) {
-                    infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix multiply", getLine());
+                    infoSink.info.message(EPrefixInternalError, getLine(), "Constant Folding cannot be done for matrix multiply");
                     return 0;
                 }
                 {// support MSVC++6.0
                     int size = getNominalSize();
                     tempConstArray = new ConstantUnion[size*size];
                     for (int row = 0; row < size; row++) {
                         for (int column = 0; column < size; column++) {
                             tempConstArray[size * column + row].setFConst(0.0f);
@@ -1153,44 +1136,44 @@ TIntermTyped* TIntermConstantUnion::fold
                             }
                         }
                     }
                 }
                 break;
             case EOpDiv:
                 tempConstArray = new ConstantUnion[objectSize];
                 {// support MSVC++6.0
-                    for (int i = 0; i < objectSize; i++) {
+                    for (size_t i = 0; i < objectSize; i++) {
                         switch (getType().getBasicType()) {
             case EbtFloat:
                 if (rightUnionArray[i] == 0.0f) {
-                    infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", getLine());
+                    infoSink.info.message(EPrefixWarning, getLine(), "Divide by zero error during constant folding");
                     tempConstArray[i].setFConst(unionArray[i].getFConst() < 0 ? -FLT_MAX : FLT_MAX);
                 } else
                     tempConstArray[i].setFConst(unionArray[i].getFConst() / rightUnionArray[i].getFConst());
                 break;
 
             case EbtInt:
                 if (rightUnionArray[i] == 0) {
-                    infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", getLine());
+                    infoSink.info.message(EPrefixWarning, getLine(), "Divide by zero error during constant folding");
                     tempConstArray[i].setIConst(INT_MAX);
                 } else
                     tempConstArray[i].setIConst(unionArray[i].getIConst() / rightUnionArray[i].getIConst());
                 break;
             default:
-                infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", getLine());
+                infoSink.info.message(EPrefixInternalError, getLine(), "Constant folding cannot be done for \"/\"");
                 return 0;
                         }
                     }
                 }
                 break;
 
             case EOpMatrixTimesVector:
                 if (node->getBasicType() != EbtFloat) {
-                    infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix times vector", getLine());
+                    infoSink.info.message(EPrefixInternalError, getLine(), "Constant Folding cannot be done for matrix times vector");
                     return 0;
                 }
                 tempConstArray = new ConstantUnion[getNominalSize()];
 
                 {// support MSVC++6.0
                     for (int size = getNominalSize(), i = 0; i < size; i++) {
                         tempConstArray[i].setFConst(0.0f);
                         for (int j = 0; j < size; j++) {
@@ -1201,17 +1184,17 @@ TIntermTyped* TIntermConstantUnion::fold
 
                 tempNode = new TIntermConstantUnion(tempConstArray, node->getType());
                 tempNode->setLine(getLine());
 
                 return tempNode;
 
             case EOpVectorTimesMatrix:
                 if (getType().getBasicType() != EbtFloat) {
-                    infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for vector times matrix", getLine());
+                    infoSink.info.message(EPrefixInternalError, getLine(), "Constant Folding cannot be done for vector times matrix");
                     return 0;
                 }
 
                 tempConstArray = new ConstantUnion[getNominalSize()];
                 {// support MSVC++6.0
                     for (int size = getNominalSize(), i = 0; i < size; i++) {
                         tempConstArray[i].setFConst(0.0f);
                         for (int j = 0; j < size; j++) {
@@ -1219,33 +1202,33 @@ TIntermTyped* TIntermConstantUnion::fold
                         }
                     }
                 }
                 break;
 
             case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
                 tempConstArray = new ConstantUnion[objectSize];
                 {// support MSVC++6.0
-                    for (int i = 0; i < objectSize; i++)
+                    for (size_t i = 0; i < objectSize; i++)
                         tempConstArray[i] = unionArray[i] && rightUnionArray[i];
                 }
                 break;
 
             case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
                 tempConstArray = new ConstantUnion[objectSize];
                 {// support MSVC++6.0
-                    for (int i = 0; i < objectSize; i++)
+                    for (size_t i = 0; i < objectSize; i++)
                         tempConstArray[i] = unionArray[i] || rightUnionArray[i];
                 }
                 break;
 
             case EOpLogicalXor:
                 tempConstArray = new ConstantUnion[objectSize];
                 {// support MSVC++6.0
-                    for (int i = 0; i < objectSize; i++)
+                    for (size_t i = 0; i < objectSize; i++)
                         switch (getType().getBasicType()) {
             case EbtBool: tempConstArray[i].setBConst((unionArray[i] == rightUnionArray[i]) ? false : true); break;
             default: assert(false && "Default missing");
                     }
                 }
                 break;
 
             case EOpLessThan:
@@ -1281,17 +1264,17 @@ TIntermTyped* TIntermConstantUnion::fold
                     break;
                 }
 
             case EOpEqual:
                 if (getType().getBasicType() == EbtStruct) {
                     if (!CompareStructure(node->getType(), node->getUnionArrayPointer(), unionArray))
                         boolNodeFlag = true;
                 } else {
-                    for (int i = 0; i < objectSize; i++) {
+                    for (size_t i = 0; i < objectSize; i++) {
                         if (unionArray[i] != rightUnionArray[i]) {
                             boolNodeFlag = true;
                             break;  // break out of for loop
                         }
                     }
                 }
 
                 tempConstArray = new ConstantUnion[1];
@@ -1307,17 +1290,17 @@ TIntermTyped* TIntermConstantUnion::fold
 
                 return tempNode;
 
             case EOpNotEqual:
                 if (getType().getBasicType() == EbtStruct) {
                     if (CompareStructure(node->getType(), node->getUnionArrayPointer(), unionArray))
                         boolNodeFlag = true;
                 } else {
-                    for (int i = 0; i < objectSize; i++) {
+                    for (size_t i = 0; i < objectSize; i++) {
                         if (unionArray[i] == rightUnionArray[i]) {
                             boolNodeFlag = true;
                             break;  // break out of for loop
                         }
                     }
                 }
 
                 tempConstArray = new ConstantUnion[1];
@@ -1329,118 +1312,118 @@ TIntermTyped* TIntermConstantUnion::fold
                 }
 
                 tempNode = new TIntermConstantUnion(tempConstArray, TType(EbtBool, EbpUndefined, EvqConst));
                 tempNode->setLine(getLine());
 
                 return tempNode;
 
             default:
-                infoSink.info.message(EPrefixInternalError, "Invalid operator for constant folding", getLine());
+                infoSink.info.message(EPrefixInternalError, getLine(), "Invalid operator for constant folding");
                 return 0;
         }
         tempNode = new TIntermConstantUnion(tempConstArray, returnType);
         tempNode->setLine(getLine());
 
         return tempNode;
     } else {
         //
         // Do unary operations
         //
         TIntermConstantUnion *newNode = 0;
         ConstantUnion* tempConstArray = new ConstantUnion[objectSize];
-        for (int i = 0; i < objectSize; i++) {
+        for (size_t i = 0; i < objectSize; i++) {
             switch(op) {
                 case EOpNegative:
                     switch (getType().getBasicType()) {
                         case EbtFloat: tempConstArray[i].setFConst(-unionArray[i].getFConst()); break;
                         case EbtInt:   tempConstArray[i].setIConst(-unionArray[i].getIConst()); break;
                         default:
-                            infoSink.info.message(EPrefixInternalError, "Unary operation not folded into constant", getLine());
+                            infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant");
                             return 0;
                     }
                     break;
                 case EOpLogicalNot: // this code is written for possible future use, will not get executed currently
                     switch (getType().getBasicType()) {
                         case EbtBool:  tempConstArray[i].setBConst(!unionArray[i].getBConst()); break;
                         default:
-                            infoSink.info.message(EPrefixInternalError, "Unary operation not folded into constant", getLine());
+                            infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant");
                             return 0;
                     }
                     break;
                 default:
                     return 0;
             }
         }
         newNode = new TIntermConstantUnion(tempConstArray, getType());
         newNode->setLine(getLine());
         return newNode;
     }
 }
 
 TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermConstantUnion* node)
 {
-    int size = node->getType().getObjectSize();
+    size_t size = node->getType().getObjectSize();
 
     ConstantUnion *leftUnionArray = new ConstantUnion[size];
 
-    for (int i=0; i < size; i++) {
+    for (size_t i = 0; i < size; i++) {
 
         switch (promoteTo) {
             case EbtFloat:
                 switch (node->getType().getBasicType()) {
                     case EbtInt:
                         leftUnionArray[i].setFConst(static_cast<float>(node->getIConst(i)));
                         break;
                     case EbtBool:
                         leftUnionArray[i].setFConst(static_cast<float>(node->getBConst(i)));
                         break;
                     case EbtFloat:
                         leftUnionArray[i].setFConst(static_cast<float>(node->getFConst(i)));
                         break;
                     default:
-                        infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());
+                        infoSink.info.message(EPrefixInternalError, node->getLine(), "Cannot promote");
                         return 0;
                 }
                 break;
             case EbtInt:
                 switch (node->getType().getBasicType()) {
                     case EbtInt:
                         leftUnionArray[i].setIConst(static_cast<int>(node->getIConst(i)));
                         break;
                     case EbtBool:
                         leftUnionArray[i].setIConst(static_cast<int>(node->getBConst(i)));
                         break;
                     case EbtFloat:
                         leftUnionArray[i].setIConst(static_cast<int>(node->getFConst(i)));
                         break;
                     default:
-                        infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());
+                        infoSink.info.message(EPrefixInternalError, node->getLine(), "Cannot promote");
                         return 0;
                 }
                 break;
             case EbtBool:
                 switch (node->getType().getBasicType()) {
                     case EbtInt:
                         leftUnionArray[i].setBConst(node->getIConst(i) != 0);
                         break;
                     case EbtBool:
                         leftUnionArray[i].setBConst(node->getBConst(i));
                         break;
                     case EbtFloat:
                         leftUnionArray[i].setBConst(node->getFConst(i) != 0.0f);
                         break;
                     default:
-                        infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());
+                        infoSink.info.message(EPrefixInternalError, node->getLine(), "Cannot promote");
                         return 0;
                 }
 
                 break;
             default:
-                infoSink.info.message(EPrefixInternalError, "Incorrect data type found", node->getLine());
+                infoSink.info.message(EPrefixInternalError, node->getLine(), "Incorrect data type found");
                 return 0;
         }
 
     }
 
     const TType& t = node->getType();
 
     return addConstantUnion(leftUnionArray, TType(promoteTo, t.getPrecision(), t.getQualifier(), t.getNominalSize(), t.isMatrix(), t.isArray()), node->getLine());
--- a/gfx/angle/src/compiler/MapLongVariableNames.cpp
+++ b/gfx/angle/src/compiler/MapLongVariableNames.cpp
@@ -1,34 +1,37 @@
 //
 // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
 #include "compiler/MapLongVariableNames.h"
-#include "spooky.h"
+
+#include "third_party/murmurhash/MurmurHash3.h"
 
 namespace {
 
 TString mapLongName(size_t id, const TString& name, bool isGlobal)
 {
     ASSERT(name.size() > MAX_SHORTENED_IDENTIFIER_SIZE);
     TStringStream stream;
-    uint64 hash = SpookyHash::Hash64(name.data(), name.length(), 0);
+
+    uint64_t hash[2] = {0, 0};
+    MurmurHash3_x64_128(name.data(), name.length(), 0, hash);
 
     // We want to avoid producing a string with a double underscore,
     // which would be an illegal GLSL identifier. We can assume that the
     // original identifier doesn't have a double underscore, otherwise
     // it's illegal anyway.
     stream << (name[0] == '_' ? "webgl" : "webgl_")
            << name.substr(0, 9)
            << (name[8] == '_' ? "" : "_")
            << std::hex
-           << hash;
+           << hash[0];
     ASSERT(stream.str().length() <= MAX_SHORTENED_IDENTIFIER_SIZE);
     ASSERT(stream.str().length() >= MAX_SHORTENED_IDENTIFIER_SIZE - 2);
     return stream.str();
 }
 
 LongNameMap* gLongNameMapInstance = NULL;
 
 }  // anonymous namespace
--- a/gfx/angle/src/compiler/OutputGLSL.cpp
+++ b/gfx/angle/src/compiler/OutputGLSL.cpp
@@ -14,8 +14,22 @@ TOutputGLSL::TOutputGLSL(TInfoSinkBase& 
     : TOutputGLSLBase(objSink, clampingStrategy, hashFunction, nameMap, symbolTable)
 {
 }
 
 bool TOutputGLSL::writeVariablePrecision(TPrecision)
 {
     return false;
 }
+
+void TOutputGLSL::visitSymbol(TIntermSymbol* node)
+{
+    TInfoSinkBase& out = objSink();
+
+    if (node->getSymbol() == "gl_FragDepthEXT")
+    {
+        out << "gl_FragDepth";
+    }
+    else
+    {
+        TOutputGLSLBase::visitSymbol(node);
+    }
+}
--- a/gfx/angle/src/compiler/OutputGLSL.h
+++ b/gfx/angle/src/compiler/OutputGLSL.h
@@ -15,11 +15,12 @@ public:
     TOutputGLSL(TInfoSinkBase& objSink,
                 ShArrayIndexClampingStrategy clampingStrategy,
                 ShHashFunction64 hashFunction,
                 NameMap& nameMap,
                 TSymbolTable& symbolTable);
 
 protected:
     virtual bool writeVariablePrecision(TPrecision);
+    virtual void visitSymbol(TIntermSymbol* node);
 };
 
 #endif  // CROSSCOMPILERGLSL_OUTPUTGLSL_H_
--- a/gfx/angle/src/compiler/OutputGLSLBase.cpp
+++ b/gfx/angle/src/compiler/OutputGLSLBase.cpp
@@ -74,35 +74,19 @@ void TOutputGLSLBase::writeTriplet(Visit
 void TOutputGLSLBase::writeVariableType(const TType& type)
 {
     TInfoSinkBase& out = objSink();
     TQualifier qualifier = type.getQualifier();
     // TODO(alokp): Validate qualifier for variable declarations.
     if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal))
         out << type.getQualifierString() << " ";
     // Declare the struct if we have not done so already.
-    if ((type.getBasicType() == EbtStruct) &&
-        (mDeclaredStructs.find(type.getTypeName()) == mDeclaredStructs.end()))
+    if ((type.getBasicType() == EbtStruct) && !structDeclared(type.getStruct()))
     {
-        out << "struct " << hashName(type.getTypeName()) << "{\n";
-        const TTypeList* structure = type.getStruct();
-        ASSERT(structure != NULL);
-        for (size_t i = 0; i < structure->size(); ++i)
-        {
-            const TType* fieldType = (*structure)[i].type;
-            ASSERT(fieldType != NULL);
-            if (writeVariablePrecision(fieldType->getPrecision()))
-                out << " ";
-            out << getTypeName(*fieldType) << " " << hashName(fieldType->getFieldName());
-            if (fieldType->isArray())
-                out << arrayBrackets(*fieldType);
-            out << ";\n";
-        }
-        out << "}";
-        mDeclaredStructs.insert(type.getTypeName());
+        declareStruct(type.getStruct());
     }
     else
     {
         if (writeVariablePrecision(type.getPrecision()))
             out << " ";
         out << getTypeName(type);
     }
 }
@@ -133,34 +117,35 @@ void TOutputGLSLBase::writeFunctionParam
 
 const ConstantUnion* TOutputGLSLBase::writeConstantUnion(const TType& type,
                                                          const ConstantUnion* pConstUnion)
 {
     TInfoSinkBase& out = objSink();
 
     if (type.getBasicType() == EbtStruct)
     {
-        out << hashName(type.getTypeName()) << "(";
-        const TTypeList* structure = type.getStruct();
-        ASSERT(structure != NULL);
-        for (size_t i = 0; i < structure->size(); ++i)
+        const TStructure* structure = type.getStruct();
+        out << hashName(structure->name()) << "(";
+
+        const TFieldList& fields = structure->fields();
+        for (size_t i = 0; i < fields.size(); ++i)
         {
-            const TType* fieldType = (*structure)[i].type;
+            const TType* fieldType = fields[i]->type();
             ASSERT(fieldType != NULL);
             pConstUnion = writeConstantUnion(*fieldType, pConstUnion);
-            if (i != structure->size() - 1) out << ", ";
+            if (i != fields.size() - 1) out << ", ";
         }
         out << ")";
     }
     else
     {
-        int size = type.getObjectSize();
+        size_t size = type.getObjectSize();
         bool writeType = size > 1;
         if (writeType) out << getTypeName(type) << "(";
-        for (int i = 0; i < size; ++i, ++pConstUnion)
+        for (size_t i = 0; i < size; ++i, ++pConstUnion)
         {
             switch (pConstUnion->getType())
             {
                 case EbtFloat: out << std::min(FLT_MAX, std::max(-FLT_MAX, pConstUnion->getFConst())); break;
                 case EbtInt: out << pConstUnion->getIConst(); break;
                 case EbtBool: out << pConstUnion->getBConst(); break;
                 default: UNREACHABLE();
             }
@@ -255,22 +240,28 @@ bool TOutputGLSLBase::visitBinary(Visit 
             else
             {
                 writeTriplet(visit, NULL, "[", "]");
             }
             break;
         case EOpIndexDirectStruct:
             if (visit == InVisit)
             {
+                // Here we are writing out "foo.bar", where "foo" is struct
+                // and "bar" is field. In AST, it is represented as a binary
+                // node, where left child represents "foo" and right child "bar".
+                // The node itself represents ".". The struct field "bar" is
+                // actually stored as an index into TStructure::fields.
                 out << ".";
-                // TODO(alokp): ASSERT
-                TString fieldName = node->getType().getFieldName();
+                const TStructure* structure = node->getLeft()->getType().getStruct();
+                const TIntermConstantUnion* index = node->getRight()->getAsConstantUnion();
+                const TField* field = structure->fields()[index->getIConst(0)];
 
-                const TType& structType = node->getLeft()->getType();
-                if (!mSymbolTable.findBuiltIn(structType.getTypeName()))
+                TString fieldName = field->name();
+                if (!mSymbolTable.findBuiltIn(structure->name()))
                     fieldName = hashName(fieldName);
 
                 out << fieldName;
                 visitChildren = false;
             }
             break;
         case EOpVectorSwizzle:
             if (visit == InVisit)
@@ -591,17 +582,17 @@ bool TOutputGLSLBase::visitAggregate(Vis
         case EOpConstructMat2: writeTriplet(visit, "mat2(", ", ", ")"); break;
         case EOpConstructMat3: writeTriplet(visit, "mat3(", ", ", ")"); break;
         case EOpConstructMat4: writeTriplet(visit, "mat4(", ", ", ")"); break;
         case EOpConstructStruct:
             if (visit == PreVisit)
             {
                 const TType& type = node->getType();
                 ASSERT(type.getBasicType() == EbtStruct);
-                out << hashName(type.getTypeName()) << "(";
+                out << hashName(type.getStruct()->name()) << "(";
             }
             else if (visit == InVisit)
             {
                 out << ", ";
             }
             else
             {
                 out << ")";
@@ -760,17 +751,17 @@ TString TOutputGLSLBase::getTypeName(con
             case EbtBool: out << "bvec"; break;
             default: UNREACHABLE(); break;
         }
         out << type.getNominalSize();
     }
     else
     {
         if (type.getBasicType() == EbtStruct)
-            out << hashName(type.getTypeName());
+            out << hashName(type.getStruct()->name());
         else
             out << type.getBasicString();
     }
     return TString(out.c_str());
 }
 
 TString TOutputGLSLBase::hashName(const TString& name)
 {
@@ -793,8 +784,34 @@ TString TOutputGLSLBase::hashVariableNam
 
 TString TOutputGLSLBase::hashFunctionName(const TString& mangled_name)
 {
     TString name = TFunction::unmangleName(mangled_name);
     if (mSymbolTable.findBuiltIn(mangled_name) != NULL || name == "main")
         return name;
     return hashName(name);
 }
+
+bool TOutputGLSLBase::structDeclared(const TStructure* structure) const
+{
+    return mDeclaredStructs.find(structure->name()) != mDeclaredStructs.end();
+}
+
+void TOutputGLSLBase::declareStruct(const TStructure* structure)
+{
+    TInfoSinkBase& out = objSink();
+
+    out << "struct " << hashName(structure->name()) << "{\n";
+    const TFieldList& fields = structure->fields();
+    for (size_t i = 0; i < fields.size(); ++i)
+    {
+        const TField* field = fields[i];
+        if (writeVariablePrecision(field->type()->getPrecision()))
+            out << " ";
+        out << getTypeName(*field->type()) << " " << hashName(field->name());
+        if (field->type()->isArray())
+            out << arrayBrackets(*field->type());
+        out << ";\n";
+    }
+    out << "}";
+
+    mDeclaredStructs.insert(structure->name());
+}
--- a/gfx/angle/src/compiler/OutputGLSLBase.h
+++ b/gfx/angle/src/compiler/OutputGLSLBase.h
@@ -47,16 +47,19 @@ protected:
     // otherwise return the hashed name.
     TString hashName(const TString& name);
     // Same as hashName(), but without hashing built-in variables.
     TString hashVariableName(const TString& name);
     // Same as hashName(), but without hashing built-in functions.
     TString hashFunctionName(const TString& mangled_name);
 
 private:
+    bool structDeclared(const TStructure* structure) const;
+    void declareStruct(const TStructure* structure);
+
     TInfoSinkBase& mObjSink;
     bool mDeclaringVariables;
 
     // Structs are declared as the tree is traversed. This set contains all
     // the structs already declared. It is maintained so that a struct is
     // declared only once.
     typedef std::set<TString> DeclaredStructs;
     DeclaredStructs mDeclaredStructs;
--- a/gfx/angle/src/compiler/OutputHLSL.cpp
+++ b/gfx/angle/src/compiler/OutputHLSL.cpp
@@ -1,10 +1,10 @@
 //
-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
 #include "compiler/OutputHLSL.h"
 
 #include "common/angleutils.h"
 #include "compiler/compiler_debug.h"
@@ -22,17 +22,18 @@ namespace sh
 // Integer to TString conversion
 TString str(int i)
 {
     char buffer[20];
     snprintf(buffer, sizeof(buffer), "%d", i);
     return buffer;
 }
 
-OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, true), mContext(context)
+OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resources, ShShaderOutput outputType)
+    : TIntermTraverser(true, true, true), mContext(context), mOutputType(outputType)
 {
     mUnfoldShortCircuit = new UnfoldShortCircuit(context, this);
     mInsideFunction = false;
 
     mUsesTexture2D = false;
     mUsesTexture2D_bias = false;
     mUsesTexture2DProj = false;
     mUsesTexture2DProj_bias = false;
@@ -42,59 +43,70 @@ OutputHLSL::OutputHLSL(TParseContext &co
     mUsesTextureCube_bias = false;
     mUsesTextureCubeLod = false;
     mUsesTexture2DLod0 = false;
     mUsesTexture2DLod0_bias = false;
     mUsesTexture2DProjLod0 = false;
     mUsesTexture2DProjLod0_bias = false;
     mUsesTextureCubeLod0 = false;
     mUsesTextureCubeLod0_bias = false;
+    mUsesFragColor = false;
+    mUsesFragData = false;
     mUsesDepthRange = false;
     mUsesFragCoord = false;
     mUsesPointCoord = false;
     mUsesFrontFacing = false;
     mUsesPointSize = false;
+    mUsesFragDepth = false;
     mUsesXor = false;
     mUsesMod1 = false;
     mUsesMod2v = false;
     mUsesMod2f = false;
     mUsesMod3v = false;
     mUsesMod3f = false;
     mUsesMod4v = false;
     mUsesMod4f = false;
     mUsesFaceforward1 = false;
     mUsesFaceforward2 = false;
     mUsesFaceforward3 = false;
     mUsesFaceforward4 = false;
-    mUsesEqualMat2 = false;
-    mUsesEqualMat3 = false;
-    mUsesEqualMat4 = false;
-    mUsesEqualVec2 = false;
-    mUsesEqualVec3 = false;
-    mUsesEqualVec4 = false;
-    mUsesEqualIVec2 = false;
-    mUsesEqualIVec3 = false;
-    mUsesEqualIVec4 = false;
-    mUsesEqualBVec2 = false;
-    mUsesEqualBVec3 = false;
-    mUsesEqualBVec4 = false;
     mUsesAtan2_1 = false;
     mUsesAtan2_2 = false;
     mUsesAtan2_3 = false;
     mUsesAtan2_4 = false;
 
+    mNumRenderTargets = resources.EXT_draw_buffers ? resources.MaxDrawBuffers : 1;
+
     mScopeDepth = 0;
 
     mUniqueIndex = 0;
 
     mContainsLoopDiscontinuity = false;
     mOutputLod0Function = false;
     mInsideDiscontinuousLoop = false;
 
     mExcessiveLoopIndex = NULL;
+
+    if (mOutputType == SH_HLSL9_OUTPUT)
+    {
+        if (mContext.shaderType == SH_FRAGMENT_SHADER)
+        {
+            mUniformRegister = 3;   // Reserve registers for dx_DepthRange, dx_ViewCoords and dx_DepthFront
+        }
+        else
+        {
+            mUniformRegister = 2;   // Reserve registers for dx_DepthRange and dx_ViewAdjust
+        }
+    }
+    else
+    {
+        mUniformRegister = 0;
+    }
+
+    mSamplerRegister = 0;
 }
 
 OutputHLSL::~OutputHLSL()
 {
     delete mUnfoldShortCircuit;
 }
 
 void OutputHLSL::output()
@@ -108,16 +120,21 @@ void OutputHLSL::output()
     mContext.infoSink().obj << mBody.c_str();
 }
 
 TInfoSinkBase &OutputHLSL::getBodyStream()
 {
     return mBody;
 }
 
+const ActiveUniforms &OutputHLSL::getUniforms()
+{
+    return mActiveUniforms;
+}
+
 int OutputHLSL::vectorSize(const TType &type) const
 {
     int elementSize = type.isMatrix() ? type.getNominalSize() : 1;
     int arraySize = type.isArray() ? type.getArraySize() : 1;
 
     return elementSize * arraySize;
 }
 
@@ -131,68 +148,86 @@ void OutputHLSL::header()
         out << *structDeclaration;
     }
 
     for (Constructors::iterator constructor = mConstructors.begin(); constructor != mConstructors.end(); constructor++)
     {
         out << *constructor;
     }
 
+    TString uniforms;
+    TString varyings;
+    TString attributes;
+
+    for (ReferencedSymbols::const_iterator uniform = mReferencedUniforms.begin(); uniform != mReferencedUniforms.end(); uniform++)
+    {
+        const TType &type = uniform->second->getType();
+        const TString &name = uniform->second->getSymbol();
+
+        if (mOutputType == SH_HLSL11_OUTPUT && IsSampler(type.getBasicType()))   // Also declare the texture
+        {
+            int index = samplerRegister(mReferencedUniforms[name]);
+
+            uniforms += "uniform SamplerState sampler_" + decorateUniform(name, type) + arrayString(type) + 
+                        " : register(s" + str(index) + ");\n";
+
+            uniforms += "uniform " + textureString(type) + " texture_" + decorateUniform(name, type) + arrayString(type) + 
+                        " : register(t" + str(index) + ");\n";
+        }
+        else
+        {
+            uniforms += "uniform " + typeString(type) + " " + decorateUniform(name, type) + arrayString(type) + 
+                        " : register(" + registerString(mReferencedUniforms[name]) + ");\n";
+        }
+    }
+
+    for (ReferencedSymbols::const_iterator varying = mReferencedVaryings.begin(); varying != mReferencedVaryings.end(); varying++)
+    {
+        const TType &type = varying->second->getType();
+        const TString &name = varying->second->getSymbol();
+
+        // Program linking depends on this exact format
+        varyings += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n";
+    }
+
+    for (ReferencedSymbols::const_iterator attribute = mReferencedAttributes.begin(); attribute != mReferencedAttributes.end(); attribute++)
+    {
+        const TType &type = attribute->second->getType();
+        const TString &name = attribute->second->getSymbol();
+
+        attributes += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n";
+    }
+
     if (shaderType == SH_FRAGMENT_SHADER)
     {
-        TString uniforms;
-        TString varyings;
-
-        TSymbolTableLevel *symbols = mContext.symbolTable.getGlobalLevel();
-        int semanticIndex = 0;
-
-        for (TSymbolTableLevel::const_iterator namedSymbol = symbols->begin(); namedSymbol != symbols->end(); namedSymbol++)
-        {
-            const TSymbol *symbol = (*namedSymbol).second;
-            const TString &name = symbol->getName();
-
-            if (symbol->isVariable())
-            {
-                const TVariable *variable = static_cast<const TVariable*>(symbol);
-                const TType &type = variable->getType();
-                TQualifier qualifier = type.getQualifier();
-
-                if (qualifier == EvqUniform)
-                {
-                    if (mReferencedUniforms.find(name.c_str()) != mReferencedUniforms.end())
-                    {
-                        uniforms += "uniform " + typeString(type) + " " + decorateUniform(name, type) + arrayString(type) + ";\n";
-                    }
-                }
-                else if (qualifier == EvqVaryingIn || qualifier == EvqInvariantVaryingIn)
-                {
-                    if (mReferencedVaryings.find(name.c_str()) != mReferencedVaryings.end())
-                    {
-                        // Program linking depends on this exact format
-                        varyings += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n";
-
-                        semanticIndex += type.isArray() ? type.getArraySize() : 1;
-                    }
-                }
-                else if (qualifier == EvqGlobal || qualifier == EvqTemporary)
-                {
-                    // Globals are declared and intialized as an aggregate node
-                }
-                else if (qualifier == EvqConst)
-                {
-                    // Constants are repeated as literals where used
-                }
-                else UNREACHABLE();
-            }
-        }
+        TExtensionBehavior::const_iterator iter = mContext.extensionBehavior().find("GL_EXT_draw_buffers");
+        const bool usingMRTExtension = (iter != mContext.extensionBehavior().end() && (iter->second == EBhEnable || iter->second == EBhRequire));
+
+        const unsigned int numColorValues = usingMRTExtension ? mNumRenderTargets : 1;
 
         out << "// Varyings\n";
         out <<  varyings;
         out << "\n"
-               "static float4 gl_Color[1] = {float4(0, 0, 0, 0)};\n";
+               "static float4 gl_Color[" << numColorValues << "] =\n"
+               "{\n";
+        for (unsigned int i = 0; i < numColorValues; i++)
+        {
+            out << "    float4(0, 0, 0, 0)";
+            if (i + 1 != numColorValues)
+            {
+                out << ",";
+            }
+            out << "\n";
+        }
+        out << "};\n";
+
+        if (mUsesFragDepth)
+        {
+            out << "static float gl_Depth = 0.0;\n";
+        }
 
         if (mUsesFragCoord)
         {
             out << "static float4 gl_FragCoord = float4(0, 0, 0, 0);\n";
         }
 
         if (mUsesPointCoord)
         {
@@ -201,296 +236,590 @@ void OutputHLSL::header()
 
         if (mUsesFrontFacing)
         {
             out << "static bool gl_FrontFacing = false;\n";
         }
 
         out << "\n";
 
-        if (mUsesFragCoord)
+        if (mUsesDepthRange)
         {
-            out << "uniform float4 dx_Coord;\n"
-                   "uniform float2 dx_Depth;\n";
+            out << "struct gl_DepthRangeParameters\n"
+                   "{\n"
+                   "    float near;\n"
+                   "    float far;\n"
+                   "    float diff;\n"
+                   "};\n"
+                   "\n";
         }
 
-        if (mUsesFrontFacing)
+        if (mOutputType == SH_HLSL11_OUTPUT)
         {
-            out << "uniform bool dx_PointsOrLines;\n"
-                   "uniform bool dx_FrontCCW;\n";
+            out << "cbuffer DriverConstants : register(b1)\n"
+                   "{\n";
+
+            if (mUsesDepthRange)
+            {
+                out << "    float3 dx_DepthRange : packoffset(c0);\n";
+            }
+
+            if (mUsesFragCoord)
+            {
+                out << "    float4 dx_ViewCoords : packoffset(c1);\n";
+            }
+
+            if (mUsesFragCoord || mUsesFrontFacing)
+            {
+                out << "    float3 dx_DepthFront : packoffset(c2);\n";
+            }
+
+            out << "};\n";
+        }
+        else
+        {
+            if (mUsesDepthRange)
+            {
+                out << "uniform float3 dx_DepthRange : register(c0);";
+            }
+
+            if (mUsesFragCoord)
+            {
+                out << "uniform float4 dx_ViewCoords : register(c1);\n";
+            }
+
+            if (mUsesFragCoord || mUsesFrontFacing)
+            {
+                out << "uniform float3 dx_DepthFront : register(c2);\n";
+            }
+        }
+
+        out << "\n";
+
+        if (mUsesDepthRange)
+        {
+            out << "static gl_DepthRangeParameters gl_DepthRange = {dx_DepthRange.x, dx_DepthRange.y, dx_DepthRange.z};\n"
+                   "\n";
         }
         
-        out << "\n";
         out <<  uniforms;
         out << "\n";
 
         if (mUsesTexture2D)
         {
-            out << "float4 gl_texture2D(sampler2D s, float2 t)\n"
-                   "{\n"
-                   "    return tex2D(s, t);\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_texture2D(sampler2D s, float2 t)\n"
+                       "{\n"
+                       "    return tex2D(s, t);\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_texture2D(Texture2D t, SamplerState s, float2 uv)\n"
+                       "{\n"
+                       "    return t.Sample(s, uv);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTexture2D_bias)
         {
-            out << "float4 gl_texture2D(sampler2D s, float2 t, float bias)\n"
-                   "{\n"
-                   "    return tex2Dbias(s, float4(t.x, t.y, 0, bias));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_texture2D(sampler2D s, float2 t, float bias)\n"
+                       "{\n"
+                       "    return tex2Dbias(s, float4(t.x, t.y, 0, bias));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_texture2D(Texture2D t, SamplerState s, float2 uv, float bias)\n"
+                       "{\n"
+                       "    return t.SampleBias(s, uv, bias);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTexture2DProj)
         {
-            out << "float4 gl_texture2DProj(sampler2D s, float3 t)\n"
-                   "{\n"
-                   "    return tex2Dproj(s, float4(t.x, t.y, 0, t.z));\n"
-                   "}\n"
-                   "\n"
-                   "float4 gl_texture2DProj(sampler2D s, float4 t)\n"
-                   "{\n"
-                   "    return tex2Dproj(s, t);\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_texture2DProj(sampler2D s, float3 t)\n"
+                       "{\n"
+                       "    return tex2Dproj(s, float4(t.x, t.y, 0, t.z));\n"
+                       "}\n"
+                       "\n"
+                       "float4 gl_texture2DProj(sampler2D s, float4 t)\n"
+                       "{\n"
+                       "    return tex2Dproj(s, t);\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_texture2DProj(Texture2D t, SamplerState s, float3 uvw)\n"
+                       "{\n"
+                       "    return t.Sample(s, float2(uvw.x / uvw.z, uvw.y / uvw.z));\n"
+                       "}\n"
+                       "\n"
+                       "float4 gl_texture2DProj(Texture2D t, SamplerState s, float4 uvw)\n"
+                       "{\n"
+                       "    return t.Sample(s, float2(uvw.x / uvw.w, uvw.y / uvw.w));\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTexture2DProj_bias)
         {
-            out << "float4 gl_texture2DProj(sampler2D s, float3 t, float bias)\n"
-                   "{\n"
-                   "    return tex2Dbias(s, float4(t.x / t.z, t.y / t.z, 0, bias));\n"
-                   "}\n"
-                   "\n"
-                   "float4 gl_texture2DProj(sampler2D s, float4 t, float bias)\n"
-                   "{\n"
-                   "    return tex2Dbias(s, float4(t.x / t.w, t.y / t.w, 0, bias));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_texture2DProj(sampler2D s, float3 t, float bias)\n"
+                       "{\n"
+                       "    return tex2Dbias(s, float4(t.x / t.z, t.y / t.z, 0, bias));\n"
+                       "}\n"
+                       "\n"
+                       "float4 gl_texture2DProj(sampler2D s, float4 t, float bias)\n"
+                       "{\n"
+                       "    return tex2Dbias(s, float4(t.x / t.w, t.y / t.w, 0, bias));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_texture2DProj(Texture2D t, SamplerState s, float3 uvw, float bias)\n"
+                       "{\n"
+                       "    return t.SampleBias(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), bias);\n"
+                       "}\n"
+                       "\n"
+                       "float4 gl_texture2DProj(Texture2D t, SamplerState s, float4 uvw, float bias)\n"
+                       "{\n"
+                       "    return t.SampleBias(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), bias);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTextureCube)
         {
-            out << "float4 gl_textureCube(samplerCUBE s, float3 t)\n"
-                   "{\n"
-                   "    return texCUBE(s, t);\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_textureCube(samplerCUBE s, float3 t)\n"
+                       "{\n"
+                       "    return texCUBE(s, t);\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_textureCube(TextureCube t, SamplerState s, float3 uvw)\n"
+                       "{\n"
+                       "    return t.Sample(s, uvw);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTextureCube_bias)
         {
-            out << "float4 gl_textureCube(samplerCUBE s, float3 t, float bias)\n"
-                   "{\n"
-                   "    return texCUBEbias(s, float4(t.x, t.y, t.z, bias));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_textureCube(samplerCUBE s, float3 t, float bias)\n"
+                       "{\n"
+                       "    return texCUBEbias(s, float4(t.x, t.y, t.z, bias));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_textureCube(TextureCube t, SamplerState s, float3 uvw, float bias)\n"
+                       "{\n"
+                       "    return t.SampleBias(s, uvw, bias);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         // These *Lod0 intrinsics are not available in GL fragment shaders.
         // They are used to sample using discontinuous texture coordinates.
         if (mUsesTexture2DLod0)
         {
-            out << "float4 gl_texture2DLod0(sampler2D s, float2 t)\n"
-                   "{\n"
-                   "    return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_texture2DLod0(sampler2D s, float2 t)\n"
+                       "{\n"
+                       "    return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_texture2DLod0(Texture2D t, SamplerState s, float2 uv)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, uv, 0);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTexture2DLod0_bias)
         {
-            out << "float4 gl_texture2DLod0(sampler2D s, float2 t, float bias)\n"
-                   "{\n"
-                   "    return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_texture2DLod0(sampler2D s, float2 t, float bias)\n"
+                       "{\n"
+                       "    return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_texture2DLod0(Texture2D t, SamplerState s, float2 uv, float bias)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, uv, 0);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTexture2DProjLod0)
         {
-            out << "float4 gl_texture2DProjLod0(sampler2D s, float3 t)\n"
-                   "{\n"
-                   "    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n"
-                   "}\n"
-                   "\n"
-                   "float4 gl_texture2DProjLod(sampler2D s, float4 t)\n"
-                   "{\n"
-                   "    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_texture2DProjLod0(sampler2D s, float3 t)\n"
+                       "{\n"
+                       "    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n"
+                       "}\n"
+                       "\n"
+                       "float4 gl_texture2DProjLod(sampler2D s, float4 t)\n"
+                       "{\n"
+                       "    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_texture2DProjLod0(Texture2D t, SamplerState s, float3 uvw)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), 0);\n"
+                       "}\n"
+                       "\n"
+                       "float4 gl_texture2DProjLod0(Texture2D t, SamplerState s, float4 uvw)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTexture2DProjLod0_bias)
         {
-            out << "float4 gl_texture2DProjLod0_bias(sampler2D s, float3 t, float bias)\n"
-                   "{\n"
-                   "    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n"
-                   "}\n"
-                   "\n"
-                   "float4 gl_texture2DProjLod_bias(sampler2D s, float4 t, float bias)\n"
-                   "{\n"
-                   "    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_texture2DProjLod0_bias(sampler2D s, float3 t, float bias)\n"
+                       "{\n"
+                       "    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n"
+                       "}\n"
+                       "\n"
+                       "float4 gl_texture2DProjLod_bias(sampler2D s, float4 t, float bias)\n"
+                       "{\n"
+                       "    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_texture2DProjLod_bias(Texture2D t, SamplerState s, float3 uvw, float bias)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), 0);\n"
+                       "}\n"
+                       "\n"
+                       "float4 gl_texture2DProjLod_bias(Texture2D t, SamplerState s, float4 uvw, float bias)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTextureCubeLod0)
         {
-            out << "float4 gl_textureCubeLod0(samplerCUBE s, float3 t)\n"
-                   "{\n"
-                   "    return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_textureCubeLod0(samplerCUBE s, float3 t)\n"
+                       "{\n"
+                       "    return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_textureCubeLod0(TextureCube t, SamplerState s, float3 uvw)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, uvw, 0);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTextureCubeLod0_bias)
         {
-            out << "float4 gl_textureCubeLod0(samplerCUBE s, float3 t, float bias)\n"
-                   "{\n"
-                   "    return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_textureCubeLod0(samplerCUBE s, float3 t, float bias)\n"
+                       "{\n"
+                       "    return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_textureCubeLod0(TextureCube t, SamplerState s, float3 uvw, float bias)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, uvw, 0);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
+        }
+
+        if (usingMRTExtension && mNumRenderTargets > 1)
+        {
+            out << "#define GL_USES_MRT\n";
+        }
+
+        if (mUsesFragColor)
+        {
+            out << "#define GL_USES_FRAG_COLOR\n";
+        }
+
+        if (mUsesFragData)
+        {
+            out << "#define GL_USES_FRAG_DATA\n";
         }
     }
     else   // Vertex shader
     {
-        TString uniforms;
-        TString attributes;
-        TString varyings;
-
-        TSymbolTableLevel *symbols = mContext.symbolTable.getGlobalLevel();
-
-        for (TSymbolTableLevel::const_iterator namedSymbol = symbols->begin(); namedSymbol != symbols->end(); namedSymbol++)
-        {
-            const TSymbol *symbol = (*namedSymbol).second;
-            const TString &name = symbol->getName();
-
-            if (symbol->isVariable())
-            {
-                const TVariable *variable = static_cast<const TVariable*>(symbol);
-                const TType &type = variable->getType();
-                TQualifier qualifier = type.getQualifier();
-
-                if (qualifier == EvqUniform)
-                {
-                    if (mReferencedUniforms.find(name.c_str()) != mReferencedUniforms.end())
-                    {
-                        uniforms += "uniform " + typeString(type) + " " + decorateUniform(name, type) + arrayString(type) + ";\n";
-                    }
-                }
-                else if (qualifier == EvqAttribute)
-                {
-                    if (mReferencedAttributes.find(name.c_str()) != mReferencedAttributes.end())
-                    {
-                        attributes += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n";
-                    }
-                }
-                else if (qualifier == EvqVaryingOut || qualifier == EvqInvariantVaryingOut)
-                {
-                    if (mReferencedVaryings.find(name.c_str()) != mReferencedVaryings.end())
-                    {
-                        // Program linking depends on this exact format
-                        varyings += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n";
-                    }
-                }
-                else if (qualifier == EvqGlobal || qualifier == EvqTemporary)
-                {
-                    // Globals are declared and intialized as an aggregate node
-                }
-                else if (qualifier == EvqConst)
-                {
-                    // Constants are repeated as literals where used
-                }
-                else UNREACHABLE();
-            }
-        }
-
         out << "// Attributes\n";
         out <<  attributes;
         out << "\n"
                "static float4 gl_Position = float4(0, 0, 0, 0);\n";
         
         if (mUsesPointSize)
         {
             out << "static float gl_PointSize = float(1);\n";
         }
 
         out << "\n"
                "// Varyings\n";
         out <<  varyings;
-        out << "\n"
-               "uniform float2 dx_HalfPixelSize;\n"
-               "\n";
-        out <<  uniforms;
+        out << "\n";
+
+        if (mUsesDepthRange)
+        {
+            out << "struct gl_DepthRangeParameters\n"
+                   "{\n"
+                   "    float near;\n"
+                   "    float far;\n"
+                   "    float diff;\n"
+                   "};\n"
+                   "\n";
+        }
+
+        if (mOutputType == SH_HLSL11_OUTPUT)
+        {
+            if (mUsesDepthRange)
+            {
+                out << "cbuffer DriverConstants : register(b1)\n"
+                       "{\n"
+                       "    float3 dx_DepthRange : packoffset(c0);\n"
+                       "};\n"
+                       "\n";
+            }
+        }
+        else
+        {
+            if (mUsesDepthRange)
+            {
+                out << "uniform float3 dx_DepthRange : register(c0);\n";
+            }
+
+            out << "uniform float4 dx_ViewAdjust : register(c1);\n"
+                   "\n";
+        }
+
+        if (mUsesDepthRange)
+        {
+            out << "static gl_DepthRangeParameters gl_DepthRange = {dx_DepthRange.x, dx_DepthRange.y, dx_DepthRange.z};\n"
+                   "\n";
+        }
+
+        out << uniforms;
         out << "\n";
         
         if (mUsesTexture2D)
         {
-            out << "float4 gl_texture2D(sampler2D s, float2 t)\n"
-                   "{\n"
-                   "    return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_texture2D(sampler2D s, float2 t)\n"
+                       "{\n"
+                       "    return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_texture2D(Texture2D t, SamplerState s, float2 uv)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, uv, 0);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTexture2DLod)
         {
-            out << "float4 gl_texture2DLod(sampler2D s, float2 t, float lod)\n"
-                   "{\n"
-                   "    return tex2Dlod(s, float4(t.x, t.y, 0, lod));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_texture2DLod(sampler2D s, float2 t, float lod)\n"
+                       "{\n"
+                       "    return tex2Dlod(s, float4(t.x, t.y, 0, lod));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_texture2DLod(Texture2D t, SamplerState s, float2 uv, float lod)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, uv, lod);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTexture2DProj)
         {
-            out << "float4 gl_texture2DProj(sampler2D s, float3 t)\n"
-                   "{\n"
-                   "    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n"
-                   "}\n"
-                   "\n"
-                   "float4 gl_texture2DProj(sampler2D s, float4 t)\n"
-                   "{\n"
-                   "    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_texture2DProj(sampler2D s, float3 t)\n"
+                       "{\n"
+                       "    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n"
+                       "}\n"
+                       "\n"
+                       "float4 gl_texture2DProj(sampler2D s, float4 t)\n"
+                       "{\n"
+                       "    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_texture2DProj(Texture2D t, SamplerState s, float3 uvw)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), 0);\n"
+                       "}\n"
+                       "\n"
+                       "float4 gl_texture2DProj(Texture2D t, SamplerState s, float4 uvw)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTexture2DProjLod)
         {
-            out << "float4 gl_texture2DProjLod(sampler2D s, float3 t, float lod)\n"
-                   "{\n"
-                   "    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, lod));\n"
-                   "}\n"
-                   "\n"
-                   "float4 gl_texture2DProjLod(sampler2D s, float4 t, float lod)\n"
-                   "{\n"
-                   "    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, lod));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_texture2DProjLod(sampler2D s, float3 t, float lod)\n"
+                       "{\n"
+                       "    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, lod));\n"
+                       "}\n"
+                       "\n"
+                       "float4 gl_texture2DProjLod(sampler2D s, float4 t, float lod)\n"
+                       "{\n"
+                       "    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, lod));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_texture2DProj(Texture2D t, SamplerState s, float3 uvw, float lod)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), lod);\n"
+                       "}\n"
+                       "\n"
+                       "float4 gl_texture2DProj(Texture2D t, SamplerState s, float4 uvw)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), lod);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTextureCube)
         {
-            out << "float4 gl_textureCube(samplerCUBE s, float3 t)\n"
-                   "{\n"
-                   "    return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_textureCube(samplerCUBE s, float3 t)\n"
+                       "{\n"
+                       "    return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_textureCube(TextureCube t, SamplerState s, float3 uvw)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, uvw, 0);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
 
         if (mUsesTextureCubeLod)
         {
-            out << "float4 gl_textureCubeLod(samplerCUBE s, float3 t, float lod)\n"
-                   "{\n"
-                   "    return texCUBElod(s, float4(t.x, t.y, t.z, lod));\n"
-                   "}\n"
-                   "\n";
+            if (mOutputType == SH_HLSL9_OUTPUT)
+            {
+                out << "float4 gl_textureCubeLod(samplerCUBE s, float3 t, float lod)\n"
+                       "{\n"
+                       "    return texCUBElod(s, float4(t.x, t.y, t.z, lod));\n"
+                       "}\n"
+                       "\n";
+            }
+            else if (mOutputType == SH_HLSL11_OUTPUT)
+            {
+                out << "float4 gl_textureCubeLod(TextureCube t, SamplerState s, float3 uvw, float lod)\n"
+                       "{\n"
+                       "    return t.SampleLevel(s, uvw, lod);\n"
+                       "}\n"
+                       "\n";
+            }
+            else UNREACHABLE();
         }
     }
 
     if (mUsesFragCoord)
     {
         out << "#define GL_USES_FRAG_COORD\n";
     }
 
@@ -504,28 +833,24 @@ void OutputHLSL::header()
         out << "#define GL_USES_FRONT_FACING\n";
     }
 
     if (mUsesPointSize)
     {
         out << "#define GL_USES_POINT_SIZE\n";
     }
 
+    if (mUsesFragDepth)
+    {
+        out << "#define GL_USES_FRAG_DEPTH\n";
+    }
+
     if (mUsesDepthRange)
     {
-        out << "struct gl_DepthRangeParameters\n"
-               "{\n"
-               "    float near;\n"
-               "    float far;\n"
-               "    float diff;\n"
-               "};\n"
-               "\n"
-               "uniform float3 dx_DepthRange;"
-               "static gl_DepthRangeParameters gl_DepthRange = {dx_DepthRange.x, dx_DepthRange.y, dx_DepthRange.z};\n"
-               "\n";
+        out << "#define GL_USES_DEPTH_RANGE\n";
     }
 
     if (mUsesXor)
     {
         out << "bool xor(bool p, bool q)\n"
                "{\n"
                "    return (p || q) && !(p && q);\n"
                "}\n"
@@ -654,118 +979,16 @@ void OutputHLSL::header()
                "    else\n"
                "    {\n"
                "        return N;\n"
                "    }\n"
                "}\n"
                "\n";
     }
 
-    if (mUsesEqualMat2)
-    {
-        out << "bool equal(float2x2 m, float2x2 n)\n"
-               "{\n"
-               "    return m[0][0] == n[0][0] && m[0][1] == n[0][1] &&\n"
-               "           m[1][0] == n[1][0] && m[1][1] == n[1][1];\n"
-               "}\n";
-    }
-
-    if (mUsesEqualMat3)
-    {
-        out << "bool equal(float3x3 m, float3x3 n)\n"
-               "{\n"
-               "    return m[0][0] == n[0][0] && m[0][1] == n[0][1] && m[0][2] == n[0][2] &&\n"
-               "           m[1][0] == n[1][0] && m[1][1] == n[1][1] && m[1][2] == n[1][2] &&\n"
-               "           m[2][0] == n[2][0] && m[2][1] == n[2][1] && m[2][2] == n[2][2];\n"
-               "}\n";
-    }
-
-    if (mUsesEqualMat4)
-    {
-        out << "bool equal(float4x4 m, float4x4 n)\n"
-               "{\n"
-               "    return m[0][0] == n[0][0] && m[0][1] == n[0][1] && m[0][2] == n[0][2] && m[0][3] == n[0][3] &&\n"
-               "           m[1][0] == n[1][0] && m[1][1] == n[1][1] && m[1][2] == n[1][2] && m[1][3] == n[1][3] &&\n"
-               "           m[2][0] == n[2][0] && m[2][1] == n[2][1] && m[2][2] == n[2][2] && m[2][3] == n[2][3] &&\n"
-               "           m[3][0] == n[3][0] && m[3][1] == n[3][1] && m[3][2] == n[3][2] && m[3][3] == n[3][3];\n"
-               "}\n";
-    }
-
-    if (mUsesEqualVec2)
-    {
-        out << "bool equal(float2 v, float2 u)\n"
-               "{\n"
-               "    return v.x == u.x && v.y == u.y;\n"
-               "}\n";
-    }
-
-    if (mUsesEqualVec3)
-    {
-        out << "bool equal(float3 v, float3 u)\n"
-               "{\n"
-               "    return v.x == u.x && v.y == u.y && v.z == u.z;\n"
-               "}\n";
-    }
-
-    if (mUsesEqualVec4)
-    {
-        out << "bool equal(float4 v, float4 u)\n"
-               "{\n"
-               "    return v.x == u.x && v.y == u.y && v.z == u.z && v.w == u.w;\n"
-               "}\n";
-    }
-
-    if (mUsesEqualIVec2)
-    {
-        out << "bool equal(int2 v, int2 u)\n"
-               "{\n"
-               "    return v.x == u.x && v.y == u.y;\n"
-               "}\n";
-    }
-
-    if (mUsesEqualIVec3)
-    {
-        out << "bool equal(int3 v, int3 u)\n"
-               "{\n"
-               "    return v.x == u.x && v.y == u.y && v.z == u.z;\n"
-               "}\n";
-    }
-
-    if (mUsesEqualIVec4)
-    {
-        out << "bool equal(int4 v, int4 u)\n"
-               "{\n"
-               "    return v.x == u.x && v.y == u.y && v.z == u.z && v.w == u.w;\n"
-               "}\n";
-    }
-
-    if (mUsesEqualBVec2)
-    {
-        out << "bool equal(bool2 v, bool2 u)\n"
-               "{\n"
-               "    return v.x == u.x && v.y == u.y;\n"
-               "}\n";
-    }
-
-    if (mUsesEqualBVec3)
-    {
-        out << "bool equal(bool3 v, bool3 u)\n"
-               "{\n"
-               "    return v.x == u.x && v.y == u.y && v.z == u.z;\n"
-               "}\n";
-    }
-
-    if (mUsesEqualBVec4)
-    {
-        out << "bool equal(bool4 v, bool4 u)\n"
-               "{\n"
-               "    return v.x == u.x && v.y == u.y && v.z == u.z && v.w == u.w;\n"
-               "}\n";
-    }
-
     if (mUsesAtan2_1)
     {
         out << "float atanyx(float y, float x)\n"
                "{\n"
                "    if(x == 0 && y == 0) x = 1;\n"   // Avoid producing a NaN
                "    return atan2(y, x);\n"
                "}\n";
     }
@@ -808,20 +1031,22 @@ void OutputHLSL::visitSymbol(TIntermSymb
 {
     TInfoSinkBase &out = mBody;
 
     TString name = node->getSymbol();
 
     if (name == "gl_FragColor")
     {
         out << "gl_Color[0]";
+        mUsesFragColor = true;
     }
     else if (name == "gl_FragData")
     {
         out << "gl_Color";
+        mUsesFragData = true;
     }
     else if (name == "gl_DepthRange")
     {
         mUsesDepthRange = true;
         out << name;
     }
     else if (name == "gl_FragCoord")
     {
@@ -838,33 +1063,38 @@ void OutputHLSL::visitSymbol(TIntermSymb
         mUsesFrontFacing = true;
         out << name;
     }
     else if (name == "gl_PointSize")
     {
         mUsesPointSize = true;
         out << name;
     }
+    else if (name == "gl_FragDepthEXT")
+    {
+        mUsesFragDepth = true;
+        out << "gl_Depth";
+    }
     else
     {
         TQualifier qualifier = node->getQualifier();
 
         if (qualifier == EvqUniform)
         {
-            mReferencedUniforms.insert(name.c_str());
+            mReferencedUniforms[name] = node;
             out << decorateUniform(name, node->getType());
         }
         else if (qualifier == EvqAttribute)
         {
-            mReferencedAttributes.insert(name.c_str());
+            mReferencedAttributes[name] = node;
             out << decorate(name);
         }
         else if (qualifier == EvqVaryingOut || qualifier == EvqInvariantVaryingOut || qualifier == EvqVaryingIn || qualifier == EvqInvariantVaryingIn)
         {
-            mReferencedVaryings.insert(name.c_str());
+            mReferencedVaryings[name] = node;
             out << decorate(name);
         }
         else
         {
             out << decorate(name);
         }
     }
 }
@@ -947,17 +1177,20 @@ bool OutputHLSL::visitBinary(Visit visit
         }
         break;
       case EOpDivAssign:               outputTriplet(visit, "(", " /= ", ")");          break;
       case EOpIndexDirect:             outputTriplet(visit, "", "[", "]");              break;
       case EOpIndexIndirect:           outputTriplet(visit, "", "[", "]");              break;
       case EOpIndexDirectStruct:
         if (visit == InVisit)
         {
-            out << "." + decorateField(node->getType().getFieldName(), node->getLeft()->getType());
+            const TStructure* structure = node->getLeft()->getType().getStruct();
+            const TIntermConstantUnion* index = node->getRight()->getAsConstantUnion();
+            const TField* field = structure->fields()[index->getIConst(0)];
+            out << "." + decorateField(field->name(), node->getLeft()->getType());
 
             return false;
         }
         break;
       case EOpVectorSwizzle:
         if (visit == InVisit)
         {
             out << ".";
@@ -1016,92 +1249,48 @@ bool OutputHLSL::visitBinary(Visit visit
             {
                 out << "(";
             }
             else
             {
                 out << "!(";
             }
 
-            const TTypeList *fields = node->getLeft()->getType().getStruct();
-
-            for (size_t i = 0; i < fields->size(); i++)
+            const TFieldList &fields = node->getLeft()->getType().getStruct()->fields();
+
+            for (size_t i = 0; i < fields.size(); i++)
             {
-                const TType *fieldType = (*fields)[i].type;
+                const TField *field = fields[i];
 
                 node->getLeft()->traverse(this);
-                out << "." + decorateField(fieldType->getFieldName(), node->getLeft()->getType()) + " == ";
+                out << "." + decorateField(field->name(), node->getLeft()->getType()) + " == ";
                 node->getRight()->traverse(this);
-                out << "." + decorateField(fieldType->getFieldName(), node->getLeft()->getType());
-
-                if (i < fields->size() - 1)
+                out << "." + decorateField(field->name(), node->getLeft()->getType());
+
+                if (i < fields.size() - 1)
                 {
                     out << " && ";
                 }
             }
 
             out << ")";
 
             return false;
         }
         else
         {
-            if (node->getLeft()->isMatrix())
-            {
-                switch (node->getLeft()->getNominalSize())
-                {
-                  case 2: mUsesEqualMat2 = true; break;
-                  case 3: mUsesEqualMat3 = true; break;
-                  case 4: mUsesEqualMat4 = true; break;
-                  default: UNREACHABLE();
-                }
-            }
-            else if (node->getLeft()->isVector())
-            {
-                switch (node->getLeft()->getBasicType())
-                {
-                  case EbtFloat:
-                    switch (node->getLeft()->getNominalSize())
-                    {
-                      case 2: mUsesEqualVec2 = true; break;
-                      case 3: mUsesEqualVec3 = true; break;
-                      case 4: mUsesEqualVec4 = true; break;
-                      default: UNREACHABLE();
-                    }
-                    break;
-                  case EbtInt:
-                    switch (node->getLeft()->getNominalSize())
-                    {
-                      case 2: mUsesEqualIVec2 = true; break;
-                      case 3: mUsesEqualIVec3 = true; break;
-                      case 4: mUsesEqualIVec4 = true; break;
-                      default: UNREACHABLE();
-                    }
-                    break;
-                  case EbtBool:
-                    switch (node->getLeft()->getNominalSize())
-                    {
-                      case 2: mUsesEqualBVec2 = true; break;
-                      case 3: mUsesEqualBVec3 = true; break;
-                      case 4: mUsesEqualBVec4 = true; break;
-                      default: UNREACHABLE();
-                    }
-                    break;
-                  default: UNREACHABLE();
-                }
-            }
-            else UNREACHABLE();
+            ASSERT(node->getLeft()->isMatrix() || node->getLeft()->isVector());
 
             if (node->getOp() == EOpEqual)
             {
-                outputTriplet(visit, "equal(", ", ", ")");
+                outputTriplet(visit, "all(", " == ", ")");
             }
             else
             {
-                outputTriplet(visit, "!equal(", ", ", ")");
+                outputTriplet(visit, "!all(", " == ", ")");
             }
         }
         break;
       case EOpLessThan:          outputTriplet(visit, "(", " < ", ")");   break;
       case EOpGreaterThan:       outputTriplet(visit, "(", " > ", ")");   break;
       case EOpLessThanEqual:     outputTriplet(visit, "(", " <= ", ")");  break;
       case EOpGreaterThanEqual:  outputTriplet(visit, "(", " >= ", ")");  break;
       case EOpVectorTimesScalar: outputTriplet(visit, "(", " * ", ")");   break;
@@ -1233,62 +1422,61 @@ bool OutputHLSL::visitAggregate(Visit vi
     TInfoSinkBase &out = mBody;
 
     switch (node->getOp())
     {
       case EOpSequence:
         {
             if (mInsideFunction)
             {
-                outputLineDirective(node->getLine());
+                outputLineDirective(node->getLine().first_line);
                 out << "{\n";
 
                 mScopeDepth++;
 
                 if (mScopeBracket.size() < mScopeDepth)
                 {
                     mScopeBracket.push_back(0);   // New scope level
                 }
                 else
                 {
                     mScopeBracket[mScopeDepth - 1]++;   // New scope at existing level
                 }
             }
 
             for (TIntermSequence::iterator sit = node->getSequence().begin(); sit != node->getSequence().end(); sit++)
             {
-                outputLineDirective((*sit)->getLine());
+                outputLineDirective((*sit)->getLine().first_line);
 
                 traverseStatements(*sit);
 
                 out << ";\n";
             }
 
             if (mInsideFunction)
             {
-                outputLineDirective(node->getEndLine());
+                outputLineDirective(node->getLine().last_line);
                 out << "}\n";
 
                 mScopeDepth--;
             }
 
             return false;
         }
       case EOpDeclaration:
         if (visit == PreVisit)
         {
             TIntermSequence &sequence = node->getSequence();
             TIntermTyped *variable = sequence[0]->getAsTyped();
-            bool visit = true;
 
             if (variable && (variable->getQualifier() == EvqTemporary || variable->getQualifier() == EvqGlobal))
             {
                 if (variable->getType().getStruct())
                 {
-                    addConstructor(variable->getType(), scopedStruct(variable->getType().getTypeName()), NULL);
+                    addConstructor(variable->getType(), scopedStruct(variable->getType().getStruct()->name()), NULL);
                 }
 
                 if (!variable->getAsSymbolNode() || variable->getAsSymbolNode()->getSymbol() != "")   // Variable declaration
                 {
                     if (!mInsideFunction)
                     {
                         out << "static ";
                     }
@@ -1305,37 +1493,46 @@ bool OutputHLSL::visitAggregate(Visit vi
                             out << arrayString(symbol->getType());
                             out << " = " + initializer(variable->getType());
                         }
                         else
                         {
                             (*sit)->traverse(this);
                         }
 
-                        if (visit && this->inVisit)
+                        if (*sit != sequence.back())
                         {
-                            if (*sit != sequence.back())
-                            {
-                                visit = this->visitAggregate(InVisit, node);
-                            }
+                            out << ", ";
                         }
                     }
-
-                    if (visit && this->postVisit)
-                    {
-                        this->visitAggregate(PostVisit, node);
-                    }
                 }
                 else if (variable->getAsSymbolNode() && variable->getAsSymbolNode()->getSymbol() == "")   // Type (struct) declaration
                 {
                     // Already added to constructor map
                 }
                 else UNREACHABLE();
             }
-            
+            else if (variable && (variable->getQualifier() == EvqVaryingOut || variable->getQualifier() == EvqInvariantVaryingOut))
+            {
+                for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); sit++)
+                {
+                    TIntermSymbol *symbol = (*sit)->getAsSymbolNode();
+
+                    if (symbol)
+                    {
+                        // Vertex (output) varyings which are declared but not written to should still be declared to allow successful linking
+                        mReferencedVaryings[symbol->getSymbol()] = symbol;
+                    }
+                    else
+                    {
+                        (*sit)->traverse(this);
+                    }
+                }
+            }
+
             return false;
         }
         else if (visit == InVisit)
         {
             out << ", ";
         }
         break;
       case EOpPrototype:
@@ -1396,17 +1593,17 @@ bool OutputHLSL::visitAggregate(Visit vi
             for (unsigned int i = 0; i < arguments.size(); i++)
             {
                 TIntermSymbol *symbol = arguments[i]->getAsSymbolNode();
 
                 if (symbol)
                 {
                     if (symbol->getType().getStruct())
                     {
-                        addConstructor(symbol->getType(), scopedStruct(symbol->getType().getTypeName()), NULL);
+                        addConstructor(symbol->getType(), scopedStruct(symbol->getType().getStruct()->name()), NULL);
                     }
 
                     out << argumentString(symbol);
 
                     if (i < arguments.size() - 1)