0029337: Visualization, TKOpenGl - visual artifacts on Intel Broadwell GPU
[occt.git] / src / OpenGl / OpenGl_ShaderProgram.hxx
old mode 100644 (file)
new mode 100755 (executable)
index b97ec3a..86a239c
@@ -1,21 +1,17 @@
 // Created on: 2013-09-19
 // Created by: Denis BOGOLEPOV
-// Copyright (c) 2013 OPEN CASCADE SAS
+// Copyright (c) 2013-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #ifndef _OpenGl_ShaderProgram_Header
 #define _OpenGl_ShaderProgram_Header
 #include <Graphic3d_ShaderObject.hxx>
 #include <Graphic3d_ShaderProgram.hxx>
 
-#include <InterfaceGraphic_tgl_all.hxx>
-
 #include <OpenGl_Vec.hxx>
 #include <OpenGl_Matrix.hxx>
+#include <OpenGl_NamedResource.hxx>
 #include <OpenGl_ShaderObject.hxx>
-#include <Handle_OpenGl_ShaderProgram.hxx>
+
+class OpenGl_ShaderProgram;
+DEFINE_STANDARD_HANDLE(OpenGl_ShaderProgram, OpenGl_NamedResource)
 
 //! The enumeration of OCCT-specific OpenGL/GLSL variables.
 enum OpenGl_StateVariable
@@ -52,138 +49,34 @@ enum OpenGl_StateVariable
   OpenGl_OCC_PROJECTION_MATRIX_INVERSE_TRANSPOSE,
 
   // OpenGL clip planes state
-  OpenGl_OCC_CLIP_PLANE_0_EQUATION,
-  OpenGl_OCC_CLIP_PLANE_1_EQUATION,
-  OpenGl_OCC_CLIP_PLANE_2_EQUATION,
-  OpenGl_OCC_CLIP_PLANE_3_EQUATION,
-  OpenGl_OCC_CLIP_PLANE_4_EQUATION,
-  OpenGl_OCC_CLIP_PLANE_5_EQUATION,
-  OpenGl_OCC_CLIP_PLANE_6_EQUATION,
-  OpenGl_OCC_CLIP_PLANE_7_EQUATION,
-  OpenGl_OCC_CLIP_PLANE_0_SPACE,
-  OpenGl_OCC_CLIP_PLANE_1_SPACE,
-  OpenGl_OCC_CLIP_PLANE_2_SPACE,
-  OpenGl_OCC_CLIP_PLANE_3_SPACE,
-  OpenGl_OCC_CLIP_PLANE_4_SPACE,
-  OpenGl_OCC_CLIP_PLANE_5_SPACE,
-  OpenGl_OCC_CLIP_PLANE_6_SPACE,
-  OpenGl_OCC_CLIP_PLANE_7_SPACE,
-
-  OpenGl_OCC_LIGHT_SOURCE_COUNT,
+  OpenGl_OCC_CLIP_PLANE_EQUATIONS,
+  OpenGl_OCC_CLIP_PLANE_COUNT,
 
   // OpenGL light state
-  OpenGl_OCC_LIGHT_SOURCE_0_TYPE,
-  OpenGl_OCC_LIGHT_SOURCE_1_TYPE,
-  OpenGl_OCC_LIGHT_SOURCE_2_TYPE,
-  OpenGl_OCC_LIGHT_SOURCE_3_TYPE,
-  OpenGl_OCC_LIGHT_SOURCE_4_TYPE,
-  OpenGl_OCC_LIGHT_SOURCE_5_TYPE,
-  OpenGl_OCC_LIGHT_SOURCE_6_TYPE,
-  OpenGl_OCC_LIGHT_SOURCE_7_TYPE,
-  OpenGl_OCC_LIGHT_SOURCE_0_HEAD,
-  OpenGl_OCC_LIGHT_SOURCE_1_HEAD,
-  OpenGl_OCC_LIGHT_SOURCE_2_HEAD,
-  OpenGl_OCC_LIGHT_SOURCE_3_HEAD,
-  OpenGl_OCC_LIGHT_SOURCE_4_HEAD,
-  OpenGl_OCC_LIGHT_SOURCE_5_HEAD,
-  OpenGl_OCC_LIGHT_SOURCE_6_HEAD,
-  OpenGl_OCC_LIGHT_SOURCE_7_HEAD,
-  OpenGl_OCC_LIGHT_SOURCE_0_AMBIENT,
-  OpenGl_OCC_LIGHT_SOURCE_1_AMBIENT,
-  OpenGl_OCC_LIGHT_SOURCE_2_AMBIENT,
-  OpenGl_OCC_LIGHT_SOURCE_3_AMBIENT,
-  OpenGl_OCC_LIGHT_SOURCE_4_AMBIENT,
-  OpenGl_OCC_LIGHT_SOURCE_5_AMBIENT,
-  OpenGl_OCC_LIGHT_SOURCE_6_AMBIENT,
-  OpenGl_OCC_LIGHT_SOURCE_7_AMBIENT,
-  OpenGl_OCC_LIGHT_SOURCE_0_DIFFUSE,
-  OpenGl_OCC_LIGHT_SOURCE_1_DIFFUSE,
-  OpenGl_OCC_LIGHT_SOURCE_2_DIFFUSE,
-  OpenGl_OCC_LIGHT_SOURCE_3_DIFFUSE,
-  OpenGl_OCC_LIGHT_SOURCE_4_DIFFUSE,
-  OpenGl_OCC_LIGHT_SOURCE_5_DIFFUSE,
-  OpenGl_OCC_LIGHT_SOURCE_6_DIFFUSE,
-  OpenGl_OCC_LIGHT_SOURCE_7_DIFFUSE,
-  OpenGl_OCC_LIGHT_SOURCE_0_SPECULAR,
-  OpenGl_OCC_LIGHT_SOURCE_1_SPECULAR,
-  OpenGl_OCC_LIGHT_SOURCE_2_SPECULAR,
-  OpenGl_OCC_LIGHT_SOURCE_3_SPECULAR,
-  OpenGl_OCC_LIGHT_SOURCE_4_SPECULAR,
-  OpenGl_OCC_LIGHT_SOURCE_5_SPECULAR,
-  OpenGl_OCC_LIGHT_SOURCE_6_SPECULAR,
-  OpenGl_OCC_LIGHT_SOURCE_7_SPECULAR,
-  OpenGl_OCC_LIGHT_SOURCE_0_POSITION,
-  OpenGl_OCC_LIGHT_SOURCE_1_POSITION,
-  OpenGl_OCC_LIGHT_SOURCE_2_POSITION,
-  OpenGl_OCC_LIGHT_SOURCE_3_POSITION,
-  OpenGl_OCC_LIGHT_SOURCE_4_POSITION,
-  OpenGl_OCC_LIGHT_SOURCE_5_POSITION,
-  OpenGl_OCC_LIGHT_SOURCE_6_POSITION,
-  OpenGl_OCC_LIGHT_SOURCE_7_POSITION,
-  OpenGl_OCC_LIGHT_SOURCE_0_SPOT_CUTOFF,
-  OpenGl_OCC_LIGHT_SOURCE_1_SPOT_CUTOFF,
-  OpenGl_OCC_LIGHT_SOURCE_2_SPOT_CUTOFF,
-  OpenGl_OCC_LIGHT_SOURCE_3_SPOT_CUTOFF,
-  OpenGl_OCC_LIGHT_SOURCE_4_SPOT_CUTOFF,
-  OpenGl_OCC_LIGHT_SOURCE_5_SPOT_CUTOFF,
-  OpenGl_OCC_LIGHT_SOURCE_6_SPOT_CUTOFF,
-  OpenGl_OCC_LIGHT_SOURCE_7_SPOT_CUTOFF,
-  OpenGl_OCC_LIGHT_SOURCE_0_SPOT_EXPONENT,
-  OpenGl_OCC_LIGHT_SOURCE_1_SPOT_EXPONENT,
-  OpenGl_OCC_LIGHT_SOURCE_2_SPOT_EXPONENT,
-  OpenGl_OCC_LIGHT_SOURCE_3_SPOT_EXPONENT,
-  OpenGl_OCC_LIGHT_SOURCE_4_SPOT_EXPONENT,
-  OpenGl_OCC_LIGHT_SOURCE_5_SPOT_EXPONENT,
-  OpenGl_OCC_LIGHT_SOURCE_6_SPOT_EXPONENT,
-  OpenGl_OCC_LIGHT_SOURCE_7_SPOT_EXPONENT,
-  OpenGl_OCC_LIGHT_SOURCE_0_SPOT_DIRECTION,
-  OpenGl_OCC_LIGHT_SOURCE_1_SPOT_DIRECTION,
-  OpenGl_OCC_LIGHT_SOURCE_2_SPOT_DIRECTION,
-  OpenGl_OCC_LIGHT_SOURCE_3_SPOT_DIRECTION,
-  OpenGl_OCC_LIGHT_SOURCE_4_SPOT_DIRECTION,
-  OpenGl_OCC_LIGHT_SOURCE_5_SPOT_DIRECTION,
-  OpenGl_OCC_LIGHT_SOURCE_6_SPOT_DIRECTION,
-  OpenGl_OCC_LIGHT_SOURCE_7_SPOT_DIRECTION,
-  OpenGl_OCC_LIGHT_SOURCE_0_CONST_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_1_CONST_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_2_CONST_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_3_CONST_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_4_CONST_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_5_CONST_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_6_CONST_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_7_CONST_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_0_LINEAR_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_1_LINEAR_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_2_LINEAR_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_3_LINEAR_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_4_LINEAR_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_5_LINEAR_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_6_LINEAR_ATTENUATION,
-  OpenGl_OCC_LIGHT_SOURCE_7_LINEAR_ATTENUATION,
+  OpenGl_OCC_LIGHT_SOURCE_COUNT,
+  OpenGl_OCC_LIGHT_SOURCE_TYPES,
+  OpenGl_OCC_LIGHT_SOURCE_PARAMS,
+  OpenGl_OCC_LIGHT_AMBIENT,
 
   // Material state
-  OpenGl_OCCT_ACTIVE_SAMPLER,
   OpenGl_OCCT_TEXTURE_ENABLE,
   OpenGl_OCCT_DISTINGUISH_MODE,
-  OpenGl_OCCT_FRONT_MATERIAL_AMBIENT,
-  OpenGl_OCCT_BACK_MATERIAL_AMBIENT,
-  OpenGl_OCCT_FRONT_MATERIAL_DIFFUSE,
-  OpenGl_OCCT_BACK_MATERIAL_DIFFUSE,
-  OpenGl_OCCT_FRONT_MATERIAL_SPECULAR,
-  OpenGl_OCCT_BACK_MATERIAL_SPECULAR,
-  OpenGl_OCCT_FRONT_MATERIAL_EMISSION,
-  OpenGl_OCCT_BACK_MATERIAL_EMISSION,
-  OpenGl_OCCT_FRONT_MATERIAL_SHININESS,
-  OpenGl_OCCT_BACK_MATERIAL_SHININESS,
-  OpenGl_OCCT_FRONT_MATERIAL_TRANSPARENCY,
-  OpenGl_OCCT_BACK_MATERIAL_TRANSPARENCY,
+  OpenGl_OCCT_FRONT_MATERIAL,
+  OpenGl_OCCT_BACK_MATERIAL,
+  OpenGl_OCCT_COLOR,
+
+  // Weighted, Blended Order-Independent Transparency rendering state
+  OpenGl_OCCT_OIT_OUTPUT,
+  OpenGl_OCCT_OIT_DEPTH_FACTOR,
+
+  // Context-dependent state
+  OpenGl_OCCT_TEXTURE_TRSF2D,
+  OpenGl_OCCT_POINT_SIZE,
 
   // DON'T MODIFY THIS ITEM (insert new items before it)
   OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES
 };
 
-class OpenGl_ShaderProgram;
-
 //! Interface for generic setter of user-defined uniform variables.
 struct OpenGl_SetterInterface
 {
@@ -232,16 +125,18 @@ enum OpenGl_UniformStateType
   OpenGl_MODEL_WORLD_STATE,
   OpenGl_WORLD_VIEW_STATE,
   OpenGl_PROJECTION_STATE,
-  OpenGl_MATERIALS_STATE
+  OpenGl_MATERIAL_STATE,
+  OpenGl_SURF_DETAIL_STATE,
+  OpenGL_OIT_STATE,
+  OpenGl_UniformStateType_NB
 };
 
-//! Total number of state types.
-const int MaxStateTypes = 6;
-
 //! Wrapper for OpenGL program object.
-class OpenGl_ShaderProgram : public OpenGl_Resource
+class OpenGl_ShaderProgram : public OpenGl_NamedResource
 {
-
+  friend class OpenGl_View;
+  friend class OpenGl_ShaderManager;
+  DEFINE_STANDARD_RTTIEXT(OpenGl_ShaderProgram, OpenGl_NamedResource)
 public:
 
   //! Non-valid shader name.
@@ -253,11 +148,21 @@ public:
   //! List of pre-defined OCCT state uniform variables.
   static Standard_CString PredefinedKeywords[OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES];
 
-protected:
-
   //! Creates uninitialized shader program.
+  //!
+  //! WARNING! This constructor is not intended to be called anywhere but from OpenGl_ShaderManager::Create().
+  //! Manager has been designed to synchronize camera position, lights definition and other aspects of the program implicitly,
+  //! as well as sharing same program across rendering groups.
+  //!
+  //! Program created outside the manager will be left detached from these routines,
+  //! and them should be performed manually by caller.
+  //!
+  //! This constructor has been made public to provide more flexibility to re-use OCCT OpenGL classes without OCCT Viewer itself.
+  //! If this is not the case - create the program using shared OpenGl_ShaderManager instance instead.
   Standard_EXPORT OpenGl_ShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProxy = NULL);
 
+protected:
+
   static OpenGl_VariableSetterSelector mySetterSelector;
 
 public:
@@ -269,7 +174,10 @@ public:
   Standard_EXPORT Standard_Boolean Create (const Handle(OpenGl_Context)& theCtx);
 
   //! Destroys shader program.
-  Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theCtx) Standard_OVERRIDE;
+
+  //! Returns estimated GPU memory usage - cannot be easily estimated.
+  virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; }
 
   //! Attaches shader object to the program object.
   Standard_EXPORT Standard_Boolean AttachShader (const Handle(OpenGl_Context)&      theCtx,
@@ -293,23 +201,57 @@ public:
   //! Fetches uniform variables from proxy shader program.
   Standard_EXPORT Standard_Boolean ApplyVariables (const Handle(OpenGl_Context)& theCtx);
 
-  //! Sets the program object as part of current rendering state.
-  Standard_EXPORT void Bind (const Handle(OpenGl_Context)& theCtx) const;
+  //! @return true if current object was initialized
+  inline bool IsValid() const
+  {
+    return myProgramID != NO_PROGRAM;
+  }
+
+  //! @return program ID
+  inline GLuint ProgramId() const
+  {
+    return myProgramID;
+  }
+
+public:
+
+  //! Return TRUE if program defines tessellation stage.
+  Standard_Boolean HasTessellationStage() const { return myHasTessShader; }
+
+  //! Return the length of array of light sources (THE_MAX_LIGHTS),
+  //! to be used for initialization occLightSources (OpenGl_OCC_LIGHT_SOURCE_PARAMS).
+  Standard_Integer NbLightsMax() const { return myNbLightsMax; }
 
-  //! Binds the program object and applies variables from proxy shader program.
-  Standard_EXPORT Standard_Boolean BindWithVariables (const Handle(OpenGl_Context)& theCtx);
+  //! Return the length of array of clipping planes (THE_MAX_CLIP_PLANES),
+  //! to be used for initialization occClipPlaneEquations (OpenGl_OCC_CLIP_PLANE_EQUATIONS).
+  Standard_Integer NbClipPlanesMax() const { return myNbClipPlanesMax; }
 
-  //! Reverts to fixed-function graphics pipeline (FFP).
-  Standard_EXPORT static void Unbind (const Handle(OpenGl_Context)& theCtx);
+  //! Return the length of array of Fragment Shader outputs (THE_NB_FRAG_OUTPUTS),
+  //! to be used for initialization occFragColorArray/occFragColorN.
+  Standard_Integer NbFragmentOutputs() const { return myNbFragOutputs; }
+
+  //! Return true if Fragment Shader color should output the weighted OIT coverage; FALSE by default.
+  Standard_Boolean HasWeightOitOutput() const { return myHasWeightOitOutput; }
 
 private:
 
   //! Returns index of last modification of variables of specified state type.
-  Standard_EXPORT Standard_Size ActiveState (const OpenGl_UniformStateType theType) const;
+  Standard_Size ActiveState (const OpenGl_UniformStateType theType) const
+  {
+    return theType < OpenGl_UniformStateType_NB
+         ? myCurrentState[theType]
+         : 0;
+  }
 
   //! Updates index of last modification of variables of specified state type.
-  Standard_EXPORT void UpdateState (const OpenGl_UniformStateType theType,
-                                    const Standard_Size           theIndex);
+  void UpdateState (const OpenGl_UniformStateType theType,
+                    const Standard_Size           theIndex)
+  {
+    if (theType < OpenGl_UniformStateType_NB)
+    {
+      myCurrentState[theType] = theIndex;
+    }
+  }
 
 public:
 
@@ -367,6 +309,53 @@ public:
                                                  GLint                         theIndex,
                                                  OpenGl_Vec4&                  theValue) const;
 
+public:
+
+  //! Wrapper for glBindAttribLocation()
+  Standard_EXPORT Standard_Boolean SetAttributeName (const Handle(OpenGl_Context)& theCtx,
+                                                     GLint                         theIndex,
+                                                     const GLchar*                 theName);
+
+  //! Wrapper for glVertexAttrib1f()
+  Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
+                                                 const GLchar*                 theName,
+                                                 GLfloat                       theValue);
+
+  //! Wrapper for glVertexAttrib1f()
+  Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
+                                                 GLint                         theIndex,
+                                                 GLfloat                       theValue);
+
+  //! Wrapper for glVertexAttrib2fv()
+  Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
+                                                 const GLchar*                 theName,
+                                                 const OpenGl_Vec2&            theValue);
+
+  //! Wrapper for glVertexAttrib2fv()
+  Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
+                                                 GLint                         theIndex,
+                                                 const OpenGl_Vec2&            theValue);
+
+  //! Wrapper for glVertexAttrib3fv()
+  Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
+                                                 const GLchar*                 theName,
+                                                 const OpenGl_Vec3&            theValue);
+
+  //! Wrapper for glVertexAttrib3fv()
+  Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
+                                                 GLint                         theIndex,
+                                                 const OpenGl_Vec3&            theValue);
+
+  //! Wrapper for glVertexAttrib4fv()
+  Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
+                                                 const GLchar*                 theName,
+                                                 const OpenGl_Vec4&            theValue);
+
+  //! Wrapper for glVertexAttrib4fv()
+  Standard_EXPORT Standard_Boolean SetAttribute (const Handle(OpenGl_Context)& theCtx,
+                                                 GLint                         theIndex,
+                                                 const OpenGl_Vec4&            theValue);
+
 public:
 
   //! Specifies the value of the integer uniform variable.
@@ -409,6 +398,30 @@ public:
                                                GLint                         theLocation,
                                                const OpenGl_Vec4i&           theValue);
 
+public:
+
+  //! Specifies the value of the unsigned integer uniform 2D vector (uvec2).
+  Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
+                                               const GLchar*                 theName,
+                                               const OpenGl_Vec2u&           theValue);
+
+  //! Specifies the value of the unsigned integer uniform 2D vector (uvec2).
+  Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
+                                               GLint                         theLocation,
+                                               const OpenGl_Vec2u&           theValue);
+
+  //! Specifies the value of the uvec2 uniform array
+  Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
+                                               const GLchar*                 theName,
+                                               const GLsizei                 theCount,
+                                               const OpenGl_Vec2u*           theValue);
+
+  //! Specifies the value of the uvec2 uniform array
+  Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
+                                               GLint                         theLocation,
+                                               const GLsizei                 theCount,
+                                               const OpenGl_Vec2u*           theValue);
+
 public:
 
   //! Specifies the value of the float uniform variable.
@@ -456,38 +469,86 @@ public:
   //! Specifies the value of the float uniform 4x4 matrix.
   Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
                                                const GLchar*                 theName,
-                                               const OpenGl_Matrix&          theValue,
+                                               const OpenGl_Mat4&            theValue,
                                                GLboolean                     theTranspose = GL_FALSE);
 
   //! Specifies the value of the float uniform 4x4 matrix.
   Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
                                                GLint                         theLocation,
-                                               const OpenGl_Matrix&          theValue,
+                                               const OpenGl_Mat4&            theValue,
                                                GLboolean                     theTranspose = GL_FALSE);
 
   //! Specifies the value of the float uniform 4x4 matrix.
   Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
                                                const GLchar*                 theName,
-                                               const Tmatrix3&               theValue,
+                                               const OpenGl_Matrix&          theValue,
                                                GLboolean                     theTranspose = GL_FALSE);
 
   //! Specifies the value of the float uniform 4x4 matrix.
   Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
                                                GLint                         theLocation,
-                                               const Tmatrix3&               theValue,
+                                               const OpenGl_Matrix&          theValue,
                                                GLboolean                     theTranspose = GL_FALSE);
 
+  //! Specifies the value of the float uniform array
+  Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
+                                               GLint                         theLocation,
+                                               GLuint                        theCount,
+                                               const Standard_ShortReal*     theData);
+
+  //! Specifies the value of the float2 uniform array
+  Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
+                                               GLint                         theLocation,
+                                               GLuint                        theCount,
+                                               const OpenGl_Vec2*            theData);
+
+  //! Specifies the value of the float3 uniform array
+  Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
+                                               GLint                         theLocation,
+                                               GLuint                        theCount,
+                                               const OpenGl_Vec3*            theData);
+
+  //! Specifies the value of the float4 uniform array
+  Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
+                                               GLint                         theLocation,
+                                               GLuint                        theCount,
+                                               const OpenGl_Vec4*            theData);
+
+  //! Specifies the value of the integer uniform array
+  Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
+                                               GLint                         theLocation,
+                                               GLuint                        theCount,
+                                               const Standard_Integer*       theData);
+
+  //! Specifies the value of the int2 uniform array
+  Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
+                                               GLint                         theLocation,
+                                               GLuint                        theCount,
+                                               const OpenGl_Vec2i*           theData);
+
+  //! Specifies the value of the int3 uniform array
+  Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
+                                               GLint                         theLocation,
+                                               GLuint                        theCount,
+                                               const OpenGl_Vec3i*           theData);
+
+  //! Specifies the value of the int4 uniform array
+  Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
+                                               GLint                         theLocation,
+                                               GLuint                        theCount,
+                                               const OpenGl_Vec4i*           theData);
+
 public:
 
   //! Specifies the value of the sampler uniform variable.
   Standard_EXPORT Standard_Boolean SetSampler (const Handle(OpenGl_Context)& theCtx,
                                                const GLchar*                 theName,
-                                               const GLenum                  theTextureUnit);
+                                               const Graphic3d_TextureUnit   theTextureUnit);
 
   //! Specifies the value of the sampler uniform variable.
   Standard_EXPORT Standard_Boolean SetSampler (const Handle(OpenGl_Context)& theCtx,
                                                GLint                         theLocation,
-                                               const GLenum                  theTextureUnit);
+                                               const Graphic3d_TextureUnit   theTextureUnit);
 
 protected:
 
@@ -513,20 +574,19 @@ protected:
   OpenGl_ShaderList               myShaderObjects; //!< List of attached shader objects
   Handle(Graphic3d_ShaderProgram) myProxy;         //!< Proxy shader program (from application layer)
   Standard_Integer                myShareCount;    //!< program users count, initialized with 1 (already shared by one user)
+  Standard_Integer                myNbLightsMax;   //!< length of array of light sources (THE_MAX_LIGHTS)
+  Standard_Integer                myNbClipPlanesMax; //!< length of array of clipping planes (THE_MAX_CLIP_PLANES)
+  Standard_Integer                myNbFragOutputs; //!< length of array of Fragment Shader outputs (THE_NB_FRAG_OUTPUTS)
+  Standard_Boolean                myHasWeightOitOutput; //!< flag indicating that Fragment Shader includes weighted OIT coverage
+  Standard_Boolean                myHasTessShader; //!< flag indicating that program defines tessellation stage
 
 protected:
 
-  //! Defines last modification for variables of each state type.
-  Standard_Size myCurrentState[MaxStateTypes];
+  Standard_Size myCurrentState[OpenGl_UniformStateType_NB]; //!< defines last modification for variables of each state type
 
   //! Stores locations of OCCT state uniform variables.
   GLint myStateLocations[OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES];
 
-public:
-
-  DEFINE_STANDARD_RTTI (OpenGl_ShaderProgram)
-  friend class OpenGl_ShaderManager;
-
 };
 
 template<class T>