OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Plus/include/GLSL/OgreGLSLProgram.h
Go to the documentation of this file.
1 /*
2  -----------------------------------------------------------------------------
3  This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5  For the latest info, see http://www.ogre3d.org/
6 
7  Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9  Permission is hereby granted, free of charge, to any person obtaining a copy
10  of this software and associated documentation files (the "Software"), to deal
11  in the Software without restriction, including without limitation the rights
12  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13  copies of the Software, and to permit persons to whom the Software is
14  furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in
17  all copies or substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25  THE SOFTWARE.
26  -----------------------------------------------------------------------------
27 */
28 #ifndef __GLSLProgram_H__
29 #define __GLSLProgram_H__
30 
32 #include "OgreGpuProgram.h"
38 
39 namespace Ogre {
40 
41  class GLSLShader;
42 
45  {
47  GLint mLocation;
52  };
53 
60  {
62  GLint mBinding;
64  GLint mOffset;
69  };
70 
72  typedef GLUniformReferenceList::iterator GLUniformReferenceIterator;
74  typedef GLAtomicCounterReferenceList::iterator GLAtomicCounterReferenceIterator;
76  typedef GLUniformBufferList::iterator GLUniformBufferIterator;
79  typedef GLCounterBufferList::iterator GLCounterBufferIterator;
80 
84  {
85  public:
87  GLSLProgram(GLSLShader* vertexProgram,
88  GLSLShader* hullProgram,
89  GLSLShader* domainProgram,
90  GLSLShader* geometryProgram,
91  GLSLShader* fragmentProgram,
92  GLSLShader* computeProgram);
93  virtual ~GLSLProgram(void);
94 
97  virtual void activate(void) = 0;
98 
102  virtual void updateUniforms(GpuProgramParametersSharedPtr params, uint16 mask, GpuProgramType fromProgType) = 0;
106  virtual void updateUniformBlocks(GpuProgramParametersSharedPtr params, uint16 mask, GpuProgramType fromProgType) = 0;
110  virtual void updatePassIterationUniforms(GpuProgramParametersSharedPtr params) = 0;
112  virtual void extractLayoutQualifiers(void);
114  GLuint getGLProgramHandle(void) const { return mGLProgramHandle; }
121  void setSkeletalAnimationIncluded(bool included) { mSkeletalAnimation = included; }
122 
129  bool isSkeletalAnimationIncluded(void) const { return mSkeletalAnimation; }
130 
132  virtual GLint getAttributeIndex(VertexElementSemantic semantic, uint index);
134  bool isAttributeValid(VertexElementSemantic semantic, uint index);
135 
136  GLSLShader* getVertexShader() const { return mVertexShader; }
137  GLSLShader* getHullShader() const { return mHullShader; }
138  GLSLShader* getDomainShader() const { return mDomainShader; }
139  GLSLShader* getGeometryShader() const { return mGeometryShader; }
140  GLSLShader* getFragmentShader() const { return mFragmentShader; }
141  GLSLShader* getComputeShader() const { return mComputeShader; }
142  GL3PlusVertexArrayObject* getVertexArrayObject() { return mVertexArrayObject; }
143 
144  protected:
155 
170 
176  GLint mLinked;
181 
183  void buildGLUniformReferences(void);
185 
187  GLint mCustomAttributesIndexes[VES_COUNT][OGRE_MAX_TEXTURE_COORD_SETS];
189 #define NULL_CUSTOM_ATTRIBUTES_INDEX -2
190 #define NOT_FOUND_CUSTOM_ATTRIBUTES_INDEX -1
192 
193  Ogre::String getCombinedName(void);
195  void getMicrocodeFromCache(void);
197  virtual void compileAndLink(void) = 0;
198  // /// Put a program in use
199  // virtual void _useProgram(void) = 0;
200 
203 
204  VertexElementSemantic getAttributeSemanticEnum(String type);
205  const char * getAttributeSemanticString(VertexElementSemantic semantic);
206  };
207 
208 
209 }
210 
211 #endif // __GLSLProgram_H__
GLSLShader * mHullShader
Linked hull (control) shader.
GLSLShader * getComputeShader() const
GLint mOffset
GL offset (only used for atomic counters)
GLSLShader * mDomainShader
Linked domain (evaluation) shader.
const GpuConstantDefinition * mConstantDef
The constant definition it relates to.
const GpuConstantDefinition * mConstantDef
The constant definition it relates to.
GLUniformReferenceList mGLUniformReferences
Container of uniform references that are active in the program object.
GLCounterBufferList mGLCounterBufferReferences
Container of counter buffer references that are active in the program object.
vector< GLAtomicCounterReference >::type GLAtomicCounterReferenceList
GpuProgramType
Enumerates the types of programs which can run on the GPU.
C++ encapsulation of GLSL program object.
void setSkeletalAnimationIncluded(bool included)
Sets whether the linked program includes the required instructions to perform skeletal animation...
GLSLShader * getVertexShader() const
SharedParamsBufferMap mSharedParamsBufferMap
Map of shared parameter blocks to uniform buffer references.
Structure used to keep track of named uniforms in the linked program object.
GLint mLinked
Flag indicating that the program or pipeline object has been successfully linked. ...
VertexElementSemantic
Vertex element semantics, used to identify the meaning of vertex buffer contents. ...
map< String, VertexElementSemantic >::type SemanticToStringMap
GLSLShader * mFragmentShader
Linked fragment shader.
GLSLShader * mVertexShader
Linked vertex shader.
GLUniformBufferList mGLUniformBufferReferences
Container of uniform buffer references that are active in the program object.
GpuProgramType mSourceProgType
Which type of program params will this value come from?
GLint mBinding
GL binding handle (similar to location)
GLAtomicCounterReferenceList::iterator GLAtomicCounterReferenceIterator
GLuint getGLProgramHandle(void) const
Get the GL Handle for the program object.
Specialisation of VertexDeclaration for OpenGL Vertex Array Object usage.
GLuint mGLProgramHandle
GL handle for the program object.
GLAtomicCounterReferenceList mGLAtomicCounterReferences
Container of atomic counter uniform references that are active in the program object.
Structure used to keep track of named atomic counter uniforms in the linked program object...
GLSLShader * getGeometryShader() const
GLSLShader * getDomainShader() const
#define OGRE_MAX_TEXTURE_COORD_SETS
Define number of texture coordinate sets allowed per vertex.
Definition: OgreConfig.h:68
vector< HardwareUniformBufferSharedPtr >::type GLUniformBufferList
GLUniformBufferList::iterator GLUniformBufferIterator
bool mTriedToLinkAndFailed
Flag indicating that the program or pipeline object has tried to link and failed. ...
GLUniformReferenceList::iterator GLUniformReferenceIterator
GLSLShader * mGeometryShader
Linked geometry shader.
GL3PlusVertexArrayObject * mVertexArrayObject
GL handle for the vertex array object.
GL3PlusVertexArrayObject * getVertexArrayObject()
GLSLShader * mComputeShader
Linked compute shader.
bool mSkeletalAnimation
Flag indicating skeletal animation is being performed.
#define _OgreGL3PlusExport
GLSLShader * getFragmentShader() const
vector< GLUniformReference >::type GLUniformReferenceList
vector< HardwareCounterBufferSharedPtr >::type GLCounterBufferList
Information about predefined program constants.
_StringBase String
Definition: OgreCommon.h:53
bool isSkeletalAnimationIncluded(void) const
Returns whether the linked program includes the required instructions to perform skeletal animation...
The number of VertexElementSemantic elements (note - the first value VES_POSITION is 1) ...
unsigned short uint16
Definition: OgrePlatform.h:421
map< GpuSharedParametersPtr, HardwareUniformBufferSharedPtr >::type SharedParamsBufferMap
bool mUniformRefsBuilt
Flag to indicate that uniform references have already been built.
GpuProgramType mSourceProgType
Which type of program params will this value come from?
GLCounterBufferList::iterator GLCounterBufferIterator
Specialisation of HighLevelGpuProgram to encapsulate shader objects obtained from compiled shaders wr...
unsigned int uint