25 #include "GLObjectWrapper.h" 26 #include "HashUtils.h" 27 #include "ShaderBase.h" 28 #include "SamplerGLImpl.h" 31 # define VERIFY_RESOURCE_BINDINGS 36 class GLProgramResources
40 GLProgramResources( GLProgramResources&& Program );
42 void LoadUniforms(
class RenderDeviceGLImpl *pDeviceGLImpl,
45 const ShaderVariableDesc *VariableDesc,
47 const StaticSamplerDesc *StaticSamplers,
48 Uint32 NumStaticSamplers);
50 void Clone(
const GLProgramResources& SrcLayout,
55 struct GLProgramVariableBase
60 pResources(_ArraySize)
62 VERIFY_EXPR(_ArraySize >= 1);
66 std::vector< RefCntAutoPtr<IDeviceObject> > pResources;
70 struct UniformBufferInfo : GLProgramVariableBase
72 UniformBufferInfo(
const Char* _Name,
size_t _ArraySize,
SHADER_VARIABLE_TYPE _VarType, GLint _Index) :
73 GLProgramVariableBase(_Name, _ArraySize, _VarType),
79 std::vector<UniformBufferInfo>& GetUniformBlocks(){
return m_UniformBlocks; }
81 struct SamplerInfo : GLProgramVariableBase
83 SamplerInfo(
const Char* _Name,
size_t _ArraySize,
SHADER_VARIABLE_TYPE _VarType, GLint _Location, GLenum _Type,
class SamplerGLImpl *_pStaticSampler) :
84 GLProgramVariableBase(_Name, _ArraySize, _VarType),
87 pStaticSampler(_pStaticSampler)
91 RefCntAutoPtr<class SamplerGLImpl> pStaticSampler;
93 std::vector<SamplerInfo>& GetSamplers(){
return m_Samplers; }
95 struct ImageInfo : GLProgramVariableBase
97 ImageInfo(
const Char* _Name,
size_t _ArraySize,
SHADER_VARIABLE_TYPE _VarType, GLint _BindingPoint, GLenum _Type) :
98 GLProgramVariableBase(_Name, _ArraySize, _VarType),
99 BindingPoint(_BindingPoint),
106 std::vector<ImageInfo>& GetImages(){
return m_Images; }
108 struct StorageBlockInfo : GLProgramVariableBase
110 StorageBlockInfo(
const Char* _Name,
size_t _ArraySize,
SHADER_VARIABLE_TYPE _VarType, GLint _Binding) :
111 GLProgramVariableBase(_Name, _ArraySize, _VarType),
117 std::vector<StorageBlockInfo>& GetStorageBlocks(){
return m_StorageBlocks; }
120 struct CGLShaderVariable : ShaderVariableBase
122 CGLShaderVariable( IObject &Owner, GLProgramResources::GLProgramVariableBase &ProgVar ) :
123 ShaderVariableBase( Owner ),
127 virtual void Set( IDeviceObject *pObject )
override final 129 ProgramVar.pResources[0] = pObject;
132 virtual void SetArray(IDeviceObject*
const* ppObjects, Uint32 FirstElement, Uint32 NumElements)
override final 134 for(Uint32 i=0; i < NumElements; ++i)
135 ProgramVar.pResources[FirstElement + i] = ppObjects[i];
139 GLProgramVariableBase &ProgramVar;
142 void BindResources(IResourceMapping *pResourceMapping, Uint32 Flags);
144 #ifdef VERIFY_RESOURCE_BINDINGS 145 void dbgVerifyResourceBindings();
148 IShaderVariable* GetShaderVariable(
const Char* Name );
150 const std::unordered_map<HashMapStringKey, CGLShaderVariable>& GetVariables(){
return m_VariableHash;}
153 const GLProgramResources& operator = (
const GLProgramResources& Program);
155 void InitVariables(IObject &Owner);
157 std::vector<UniformBufferInfo> m_UniformBlocks;
158 std::vector< SamplerInfo > m_Samplers;
159 std::vector< ImageInfo > m_Images;
160 std::vector< StorageBlockInfo > m_StorageBlocks;
163 std::unordered_map<HashMapStringKey, CGLShaderVariable> m_VariableHash;
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
SHADER_VARIABLE_TYPE
Describes shader variable type that is used by ShaderVariableDesc.
Definition: Shader.h:100