OGRE  1.8
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-2013 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 
168  GpuProgramPtr createGpuProgram(Program* shaderProgram,
169  ProgramWriter* programWriter,
170  const String& language,
171  const String& profiles,
172  const StringVector& profilesList,
173  const String& cachePath);
174 
179  void addProgramProcessor(ProgramProcessor* processor);
180 
185  void removeProgramProcessor(ProgramProcessor* processor);
186 
191  void destroyGpuProgram(GpuProgramPtr& gpuProgram);
192 
196  void flushGpuProgramsCache(GpuProgramsMap& gpuProgramsMap);
197 
199  size_t getVertexShaderCount() const { return mVertexShaderMap.size(); }
200 
202  size_t getFragmentShaderCount() const { return mFragmentShaderMap.size(); }
203 
205  void synchronizePixelnToBeVertexOut(ProgramSet* programSet);
206 
208  void bindUniformParameters(Program* pCpuProgram, const GpuProgramParametersSharedPtr& passParams);
209 
210 
211 protected:
212 
213 
214 protected:
215  // CPU programs list.
217  // Map between target language and shader program writer.
219  // Map between target language and shader program processor.
221  // Holds standard shader writer factories
223  // The generated vertex shaders.
225  // The generated fragment shaders.
227  // The default program processors.
229 
230 private:
231  friend class ProgramSet;
232  friend class TargetRenderState;
233  friend class ShaderGenerator;
234 };
235 
239 }
240 }
241 
242 #endif
243 
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
Specialisation of SharedPtr to allow SharedPtr to be assigned to GpuProgramPtr.
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.