Bug 1405600 - Initialize uniform blocks before detaching shaders; draft
authorDaosheng Mu <daoshengmu@gmail.com>
Mon, 30 Oct 2017 17:34:37 +0800
changeset 688591 a1b2625978aa83a8d279ba0f38f182b3eb694846
parent 688337 d3910b7628b8066d3f30d58b17b5824b05768854
child 738112 61d9dcf86b57d88e0ccf6828a0100026240c3666
push id86796
push userbmo:dmu@mozilla.com
push dateMon, 30 Oct 2017 09:52:11 +0000
bugs1405600
milestone58.0a1
Bug 1405600 - Initialize uniform blocks before detaching shaders; MozReview-Commit-ID: 4fQ1XuGxWLn
gfx/angle/src/libANGLE/Program.cpp
gfx/angle/src/libANGLE/renderer/ProgramImpl.h
gfx/angle/src/libANGLE/renderer/d3d/ProgramD3D.h
--- a/gfx/angle/src/libANGLE/Program.cpp
+++ b/gfx/angle/src/libANGLE/Program.cpp
@@ -511,16 +511,18 @@ void Program::attachShader(Shader *shade
         }
         default:
             UNREACHABLE();
     }
 }
 
 void Program::detachShader(const Context *context, Shader *shader)
 {
+	mProgram->ensureUniformBlocksInitialized();
+
     switch (shader->getType())
     {
         case GL_VERTEX_SHADER:
         {
             ASSERT(mState.mAttachedVertexShader == shader);
             shader->release(context);
             mState.mAttachedVertexShader = nullptr;
             break;
--- a/gfx/angle/src/libANGLE/renderer/ProgramImpl.h
+++ b/gfx/angle/src/libANGLE/renderer/ProgramImpl.h
@@ -105,15 +105,19 @@ class ProgramImpl : angle::NonCopyable
     // Implementation-specific method for ignoring unreferenced uniforms. Some implementations may
     // perform more extensive analysis and ignore some locations that ANGLE doesn't detect as
     // unreferenced. This method is not required to be overriden by a back-end.
     virtual void markUnusedUniformLocations(std::vector<gl::VariableLocation> *uniformLocations,
                                             std::vector<gl::SamplerBinding> *samplerBindings)
     {
     }
 
+    virtual void ensureUniformBlocksInitialized()
+    {
+    }
+
   protected:
     const gl::ProgramState &mState;
 };
 
 }  // namespace rx
 
 #endif // LIBANGLE_RENDERER_PROGRAMIMPL_H_
--- a/gfx/angle/src/libANGLE/renderer/d3d/ProgramD3D.h
+++ b/gfx/angle/src/libANGLE/renderer/d3d/ProgramD3D.h
@@ -265,16 +265,17 @@ class ProgramD3D : public ProgramImpl
                                GLboolean transpose,
                                const GLfloat *value);
 
     void getUniformfv(const gl::Context *context, GLint location, GLfloat *params) const override;
     void getUniformiv(const gl::Context *context, GLint location, GLint *params) const override;
     void getUniformuiv(const gl::Context *context, GLint location, GLuint *params) const override;
 
     void setUniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding) override;
+    void ensureUniformBlocksInitialized();
 
     UniformStorageD3D &getVertexUniformStorage() const { return *mVertexUniformStorage.get(); }
     UniformStorageD3D &getFragmentUniformStorage() const { return *mFragmentUniformStorage.get(); }
     UniformStorageD3D &getComputeUniformStorage() const { return *mComputeUniformStorage.get(); }
 
     unsigned int getSerial() const;
 
     const AttribIndexArray &getAttribLocationToD3DSemantics() const
@@ -423,17 +424,16 @@ class ProgramD3D : public ProgramImpl
                                          const BuiltinInfo &builtins);
     D3DUniform *getD3DUniformByName(const std::string &name);
     D3DUniform *getD3DUniformFromLocation(GLint location);
     const D3DUniform *getD3DUniformFromLocation(GLint location) const;
 
     void initAttribLocationsToD3DSemantic(const gl::Context *context);
 
     void reset();
-    void ensureUniformBlocksInitialized();
 
     void initUniformBlockInfo(const gl::Context *context, gl::Shader *shader);
     size_t getUniformBlockInfo(const sh::InterfaceBlock &interfaceBlock);
 
     void updateCachedInputLayoutFromShader(const gl::Context *context);
     void updateCachedOutputLayoutFromShader();
     void updateCachedVertexExecutableIndex();
     void updateCachedPixelExecutableIndex();