OGRE  1.9.0
OgreShaderProgramManager.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24THE SOFTWARE.
25-----------------------------------------------------------------------------
26*/
27#ifndef _ShaderProgramManager_
28#define _ShaderProgramManager_
29
31#include "OgreShaderProgram.h"
33
34namespace Ogre {
35namespace RTShader {
36
46class _OgreRTSSExport ProgramManager : public Singleton<ProgramManager>, public RTShaderSystemAlloc
47{
48// Interface.
49public:
50
53
56
57
74
91
96 void acquirePrograms(Pass* pass, TargetRenderState* renderState);
97
102 void releasePrograms(Pass* pass, TargetRenderState* renderState);
103
107
108protected:
109
110 //-----------------------------------------------------------------------------
112 typedef GpuProgramsMap::iterator GpuProgramsMapIterator;
113 typedef GpuProgramsMap::const_iterator GpuProgramsMapConstIterator;
114
115 //-----------------------------------------------------------------------------
117 typedef ProgramList::iterator ProgramListIterator;
119 typedef ProgramWriterMap::iterator ProgramWriterIterator;
121
122 //-----------------------------------------------------------------------------
124 typedef ProgramProcessorMap::iterator ProgramProcessorIterator;
125 typedef ProgramProcessorMap::const_iterator ProgramProcessorConstIterator;
127
128
129protected:
132
135
138
141
144
149
153 void destroyCpuProgram(Program* shaderProgram);
154
158 bool createGpuPrograms(ProgramSet* programSet);
159
165 String generateGUID(const String& programString);
166
176 ProgramWriter* programWriter,
177 const String& language,
178 const String& profiles,
179 const StringVector& profilesList,
180 const String& cachePath);
181
187
193
198
203
205 size_t getVertexShaderCount() const { return mVertexShaderMap.size(); }
206
208 size_t getFragmentShaderCount() const { return mFragmentShaderMap.size(); }
209
212
214 void bindUniformParameters(Program* pCpuProgram, const GpuProgramParametersSharedPtr& passParams);
215
216
217protected:
218
219
220protected:
221 // CPU programs list.
223 // Map between target language and shader program writer.
225 // Map between target language and shader program processor.
227 // Holds standard shader writer factories
229 // The generated vertex shaders.
231 // The generated fragment shaders.
233 // The default program processors.
235
236private:
237 friend class ProgramSet;
238 friend class TargetRenderState;
239 friend class ShaderGenerator;
240};
241
245}
246}
247
248#endif
249
#define _OgreRTSSExport
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Class defining a single pass of a Technique (of a Material), i.e.
Definition OgrePass.h:81
A singleton manager class that manages shader based programs.
void acquirePrograms(Pass *pass, TargetRenderState *renderState)
Acquire CPU/GPU programs set associated with the given render state and bind them to the pass.
map< String, ProgramWriter * >::type ProgramWriterMap
map< String, ProgramProcessor * >::type ProgramProcessorMap
void addProgramProcessor(ProgramProcessor *processor)
Add program processor instance to this manager.
String generateGUID(const String &programString)
Generates a unique guid value from a string.
void removeProgramProcessor(ProgramProcessor *processor)
Remove program processor instance from this manager.
ProgramProcessorMap::const_iterator ProgramProcessorConstIterator
ProgramWriterFactoryList mProgramWriterFactories
Program * createCpuProgram(GpuProgramType type)
Create CPU program .
vector< ProgramWriterFactory * >::type ProgramWriterFactoryList
void bindUniformParameters(Program *pCpuProgram, const GpuProgramParametersSharedPtr &passParams)
Bind the uniform parameters of a given CPU and GPU program set.
ProgramProcessorMap::iterator ProgramProcessorIterator
~ProgramManager()
Class destructor.
void synchronizePixelnToBeVertexOut(ProgramSet *programSet)
Fix the input of the pixel shader to be the same as the output of the vertex shader.
void flushGpuProgramsCache()
Flush the local GPU programs cache.
void destroyDefaultProgramWriterFactories()
Destroy default program processors.
void destroyDefaultProgramProcessors()
Destroy default program processors.
void createDefaultProgramProcessors()
Create default program processors.
ProgramManager()
Class default constructor.
ProgramWriterMap::iterator ProgramWriterIterator
size_t getFragmentShaderCount() const
Return the number of created fragment shaders.
GpuProgramPtr createGpuProgram(Program *shaderProgram, ProgramWriter *programWriter, const String &language, const String &profiles, const StringVector &profilesList, const String &cachePath)
Create GPU program based on the give CPU program.
void releasePrograms(Pass *pass, TargetRenderState *renderState)
Release CPU/GPU programs set associated with the given render state and pass.
vector< ProgramProcessor * >::type ProgramProcessorList
void createDefaultProgramWriterFactories()
Create default program processors.
void destroyProgramWriters()
Destroy all program writers.
static ProgramManager & getSingleton()
Override standard Singleton retrieval.
bool createGpuPrograms(ProgramSet *programSet)
Create GPU programs for the given program set based on the CPU programs it contains.
static ProgramManager * getSingletonPtr()
Override standard Singleton retrieval.
size_t getVertexShaderCount() const
Return the number of created vertex shaders.
void flushGpuProgramsCache(GpuProgramsMap &gpuProgramsMap)
Flush the local GPU programs cache.
void destroyGpuProgram(GpuProgramPtr &gpuProgram)
Destroy a GPU program by name.
GpuProgramsMap::const_iterator GpuProgramsMapConstIterator
void destroyCpuProgram(Program *shaderProgram)
Destroy a CPU program by name.
GpuProgramsMap::iterator GpuProgramsMapIterator
map< String, GpuProgramPtr >::type GpuProgramsMap
A class that provides extra processing services on CPU based programs.
Container class for shader based programs.
Base class interface for shader program writers.
A class that represents a shader based program.
Shader generator system main interface.
This is the target render state.
Template class for creating single-instance global classes.
vector< String >::type StringVector
GpuProgramType
Enumerates the types of programs which can run on the GPU.
_StringBase String
std::map< K, V, P, A > type
std::set< T, P, A > type
std::vector< T, A > type