OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGpuProgramManager.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 __GpuProgramManager_H_
29 #define __GpuProgramManager_H_
30 
31 // Precompiler options
32 #include "OgrePrerequisites.h"
33 #include "OgreResourceManager.h"
34 #include "OgreGpuProgram.h"
35 #include "OgreSingleton.h"
36 #include "OgreHeaderPrefix.h"
37 
38 namespace Ogre {
39 
40  //TODO Add documentation and explain rationale of this class.
41 
48  class _OgreExport GpuProgramManager : public ResourceManager, public Singleton<GpuProgramManager>
49  {
50  public:
51 
54 
57 
58  protected:
59 
63  bool mCacheDirty; // When this is true the cache is 'dirty' and should be resaved to disk.
64 
65  static String addRenderSystemToName( const String & name );
66 
68  virtual Resource* createImpl(const String& name, ResourceHandle handle,
69  const String& group, bool isManual, ManualResourceLoader* loader,
70  GpuProgramType gptype, const String& syntaxCode) = 0;
71  public:
73  virtual ~GpuProgramManager();
74 
77  GpuProgramPtr getByName(const String& name, bool preferHighLevelPrograms = true);
78 
90  virtual GpuProgramPtr load(const String& name, const String& groupName,
91  const String& filename, GpuProgramType gptype,
92  const String& syntaxCode);
93 
105  virtual GpuProgramPtr loadFromString(const String& name, const String& groupName,
106  const String& code, GpuProgramType gptype,
107  const String& syntaxCode);
108 
110  virtual const SyntaxCodes& getSupportedSyntax(void) const;
111 
112 
114  virtual bool isSyntaxSupported(const String& syntaxCode) const;
115 
121  virtual GpuProgramParametersSharedPtr createParameters(void);
122 
137  virtual GpuProgramPtr createProgram(const String& name,
138  const String& groupName, const String& filename,
139  GpuProgramType gptype, const String& syntaxCode);
140 
155  virtual GpuProgramPtr createProgramFromString(const String& name,
156  const String& groupName, const String& code,
157  GpuProgramType gptype, const String& syntaxCode);
158 
162  virtual ResourcePtr create(const String& name, const String& group,
163  GpuProgramType gptype, const String& syntaxCode, bool isManual = false,
164  ManualResourceLoader* loader = 0);
165 
171  ResourcePtr getResourceByName(const String& name, bool preferHighLevelPrograms = true);
172 
173 
179  virtual GpuSharedParametersPtr createSharedParameters(const String& name);
180 
184  virtual GpuSharedParametersPtr getSharedParameters(const String& name) const;
185 
188  virtual const SharedParametersMap& getAvailableSharedParameters() const;
189 
192  bool getSaveMicrocodesToCache();
195  void setSaveMicrocodesToCache( const bool val );
196 
199  bool isCacheDirty(void) const;
200 
201  bool canGetCompiledShaderBuffer();
205  virtual bool isMicrocodeAvailableInCache( const String & name ) const;
209  virtual const Microcode & getMicrocodeFromCache( const String & name ) const;
210 
214  virtual Microcode createMicrocode( const uint32 size ) const;
215 
219  virtual void addMicrocodeToCache( const String & name, const Microcode & microcode );
220 
224  virtual void removeMicrocodeFromCache( const String & name );
225 
229  virtual void saveMicrocodeCache( DataStreamPtr stream ) const;
233  virtual void loadMicrocodeCache( DataStreamPtr stream );
234 
235 
236 
252  static GpuProgramManager& getSingleton(void);
268  static GpuProgramManager* getSingletonPtr(void);
269 
270 
271 
272  };
273 
276 }
277 
278 #include "OgreHeaderSuffix.h"
279 
280 #endif
unsigned int uint32
Definition: OgrePlatform.h:420
#define _OgreExport
Definition: OgrePlatform.h:255
MemoryDataStreamPtr Microcode
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
GpuProgramType
Enumerates the types of programs which can run on the GPU.
Interface describing a manual resource loader.
Definition: OgreResource.h:498
map< String, Microcode >::type MicrocodeMap
map< String, GpuSharedParametersPtr >::type SharedParametersMap
SharedParametersMap mSharedParametersMap
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:77
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
set< String >::type SyntaxCodes
Defines a generic resource handler.
_StringBase String
Definition: OgreCommon.h:53