OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreShaderProgramManager.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 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 -----------------------------------------------------------------------------
26 */
27 #ifndef _ShaderProgramManager_
28 #define _ShaderProgramManager_
29 
31 #include "OgreShaderProgram.h"
33 
34 namespace Ogre {
35 namespace RTShader {
36 
46 class _OgreRTSSExport ProgramManager : public Singleton<ProgramManager>, public RTShaderSystemAlloc
47 {
48 // Interface.
49 public:
50 
53 
55  ~ProgramManager();
56 
57 
73  static ProgramManager& getSingleton();
74 
90  static ProgramManager* getSingletonPtr();
91 
96  void acquirePrograms(Pass* pass, TargetRenderState* renderState);
97 
102  void releasePrograms(Pass* pass, TargetRenderState* renderState);
103 
106  void flushGpuProgramsCache();
107 
108 protected:
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 
129 protected:
131  void createDefaultProgramProcessors();
132 
134  void destroyDefaultProgramProcessors();
135 
137  void createDefaultProgramWriterFactories();
138 
140  void destroyDefaultProgramWriterFactories();
141 
143  void destroyProgramWriters();
144 
148  Program* createCpuProgram(GpuProgramType type);
149 
153  void destroyCpuProgram(Program* shaderProgram);
154 
158  bool createGpuPrograms(ProgramSet* programSet);
159 
165  String generateGUID(const String& programString);
166 
175  GpuProgramPtr createGpuProgram(Program* shaderProgram,
176  ProgramWriter* programWriter,
177  const String& language,
178  const String& profiles,
179  const StringVector& profilesList,
180  const String& cachePath);
181 
186  void addProgramProcessor(ProgramProcessor* processor);
187 
192  void removeProgramProcessor(ProgramProcessor* processor);
193 
197  void destroyGpuProgram(GpuProgramPtr& gpuProgram);
198 
202  void flushGpuProgramsCache(GpuProgramsMap& gpuProgramsMap);
203 
205  size_t getVertexShaderCount() const { return mVertexShaderMap.size(); }
206 
208  size_t getFragmentShaderCount() const { return mFragmentShaderMap.size(); }
209 
211  void synchronizePixelnToBeVertexOut(ProgramSet* programSet);
212 
214  void bindUniformParameters(Program* pCpuProgram, const GpuProgramParametersSharedPtr& passParams);
215 
216 
217 protected:
218 
219 
220 protected:
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 
236 private:
237  friend class ProgramSet;
238  friend class TargetRenderState;
239  friend class ShaderGenerator;
240 };
241 
245 }
246 }
247 
248 #endif
249 
GpuProgramsMap::const_iterator GpuProgramsMapConstIterator
ProgramWriterMap::iterator ProgramWriterIterator
map< String, ProgramProcessor * >::type ProgramProcessorMap
vector< ProgramWriterFactory * >::type ProgramWriterFactoryList
map< String, ProgramWriter * >::type ProgramWriterMap
GpuProgramsMap::iterator GpuProgramsMapIterator
ProgramProcessorMap::iterator ProgramProcessorIterator
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
GpuProgramType
Enumerates the types of programs which can run on the GPU.
A class that provides extra processing services on CPU based programs.
#define _OgreRTSSExport
ProgramProcessorList mDefaultProgramProcessors
vector< ProgramProcessor * >::type ProgramProcessorList
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:80
This is the target render state.
Shader generator system main interface.
Base class interface for shader program writers.
map< String, GpuProgramPtr >::type GpuProgramsMap
ProgramProcessorMap::const_iterator ProgramProcessorConstIterator
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
vector< String >::type StringVector
size_t getVertexShaderCount() const
Return the number of created vertex shaders.
A class that represents a shader based program.
ProgramWriterFactoryList mProgramWriterFactories
_StringBase String
Container class for shader based programs.
size_t getFragmentShaderCount() const
Return the number of created fragment shaders.
A singleton manager class that manages shader based programs.