Move storage for uniform blocks to the program binary.

With dynamic shaders we may have multiple shader executables per
program binary. We must store the uniforms outside the executable,
in the program binary, to be consistent between variations.

Change-Id: I1b29a5d78c72dede8562d4878569b609536ba074
Reviewed-on: https://chromium-review.googlesource.com/183586
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libGLESv2/ProgramBinary.h b/src/libGLESv2/ProgramBinary.h
index 579fb22..a374e09 100644
--- a/src/libGLESv2/ProgramBinary.h
+++ b/src/libGLESv2/ProgramBinary.h
@@ -31,6 +31,7 @@
 class ShaderExecutable;
 class Renderer;
 struct TranslatedAttribute;
+class UniformStorage;
 }
 
 namespace gl
@@ -62,9 +63,9 @@
     explicit ProgramBinary(rx::Renderer *renderer);
     ~ProgramBinary();
 
-    rx::ShaderExecutable *getPixelExecutable();
-    rx::ShaderExecutable *getVertexExecutable();
-    rx::ShaderExecutable *getGeometryExecutable();
+    rx::ShaderExecutable *getPixelExecutable() const;
+    rx::ShaderExecutable *getVertexExecutable() const;
+    rx::ShaderExecutable *getGeometryExecutable() const;
 
     GLuint getAttributeLocation(const char *name);
     int getSemanticIndex(int attributeIndex);
@@ -145,6 +146,10 @@
 
     static std::string decorateAttribute(const std::string &name);    // Prepend an underscore
 
+    const UniformArray &getUniforms() const { return mUniforms; }
+    const rx::UniformStorage &getVertexUniformStorage() const { return *mVertexUniformStorage; }
+    const rx::UniformStorage &getFragmentUniformStorage() const { return *mFragmentUniformStorage; }
+
   private:
     DISALLOW_COPY_AND_ASSIGN(ProgramBinary);
 
@@ -173,6 +178,7 @@
     bool defineUniformBlock(InfoLog &infoLog, GLenum shader, const sh::InterfaceBlock &interfaceBlock);
     bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex);
     void defineOutputVariables(FragmentShader *fragmentShader);
+    void initializeUniformStorage();
 
     std::string generateGeometryShaderHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
     std::string generatePointSpriteHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
@@ -220,6 +226,8 @@
     UniformIndex mUniformIndex;
     typedef std::map<int, VariableLocation> ShaderVariableIndex;
     ShaderVariableIndex mOutputVariables;
+    rx::UniformStorage *mVertexUniformStorage;
+    rx::UniformStorage *mFragmentUniformStorage;
 
     bool mValidated;