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-2013 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 "OgreException.h"
35 #include "OgreGpuProgram.h"
36 #include "OgreSingleton.h"
37 #include "OgreHeaderPrefix.h"
38 
39 namespace Ogre {
40 
47  class _OgreExport GpuProgramManager : public ResourceManager, public Singleton<GpuProgramManager>
48  {
49  public:
50 
53 
56 
57  protected:
58 
62  bool mCacheDirty; // When this is true the cache is 'dirty' and should be resaved to disk.
63 
64  static String addRenderSystemToName( const String & name );
65 
67  virtual Resource* createImpl(const String& name, ResourceHandle handle,
68  const String& group, bool isManual, ManualResourceLoader* loader,
69  GpuProgramType gptype, const String& syntaxCode) = 0;
70  public:
72  virtual ~GpuProgramManager();
73 
76  GpuProgramPtr getByName(const String& name, bool preferHighLevelPrograms = true);
77 
89  virtual GpuProgramPtr load(const String& name, const String& groupName,
90  const String& filename, GpuProgramType gptype,
91  const String& syntaxCode);
92 
104  virtual GpuProgramPtr loadFromString(const String& name, const String& groupName,
105  const String& code, GpuProgramType gptype,
106  const String& syntaxCode);
107 
109  virtual const SyntaxCodes& getSupportedSyntax(void) const;
110 
111 
113  virtual bool isSyntaxSupported(const String& syntaxCode) const;
114 
120  virtual GpuProgramParametersSharedPtr createParameters(void);
121 
136  virtual GpuProgramPtr createProgram(const String& name,
137  const String& groupName, const String& filename,
138  GpuProgramType gptype, const String& syntaxCode);
139 
154  virtual GpuProgramPtr createProgramFromString(const String& name,
155  const String& groupName, const String& code,
156  GpuProgramType gptype, const String& syntaxCode);
157 
161  virtual ResourcePtr create(const String& name, const String& group,
162  GpuProgramType gptype, const String& syntaxCode, bool isManual = false,
163  ManualResourceLoader* loader = 0);
164 
170  ResourcePtr getResourceByName(const String& name, bool preferHighLevelPrograms = true);
171 
172 
178  virtual GpuSharedParametersPtr createSharedParameters(const String& name);
179 
183  virtual GpuSharedParametersPtr getSharedParameters(const String& name) const;
184 
187  virtual const SharedParametersMap& getAvailableSharedParameters() const;
188 
191  bool getSaveMicrocodesToCache();
194  void setSaveMicrocodesToCache( const bool val );
195 
198  bool isCacheDirty(void) const;
199 
200  bool canGetCompiledShaderBuffer();
204  virtual bool isMicrocodeAvailableInCache( const String & name ) const;
208  virtual const Microcode & getMicrocodeFromCache( const String & name ) const;
209 
213  virtual Microcode createMicrocode( const uint32 size ) const;
214 
218  virtual void addMicrocodeToCache( const String & name, const Microcode & microcode );
219 
223  virtual void removeMicrocodeFromCache( const String & name );
224 
228  virtual void saveMicrocodeCache( DataStreamPtr stream ) const;
232  virtual void loadMicrocodeCache( DataStreamPtr stream );
233 
234 
235 
251  static GpuProgramManager& getSingleton(void);
267  static GpuProgramManager* getSingletonPtr(void);
268 
269 
270 
271  };
272 
275 }
276 
277 #include "OgreHeaderSuffix.h"
278 
279 #endif
OgreHeaderSuffix.h
Ogre::ResourceHandle
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
Ogre::GpuProgramManager::mCacheDirty
bool mCacheDirty
Definition: OgreGpuProgramManager.h:62
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::GpuProgramManager::Microcode
MemoryDataStreamPtr Microcode
Definition: OgreGpuProgramManager.h:54
Ogre::map
Definition: OgrePrerequisites.h:533
OgreSingleton.h
Ogre::set
Definition: OgrePrerequisites.h:519
Ogre::GpuProgramManager::SyntaxCodes
set< String >::type SyntaxCodes
Definition: OgreGpuProgramManager.h:51
OgreException.h
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::GpuProgramManager
Definition: OgreGpuProgramManager.h:47
Ogre::GpuProgramType
GpuProgramType
Enumerates the types of programs which can run on the GPU.
Definition: OgreGpuProgram.h:50
OgreHeaderPrefix.h
OgrePrerequisites.h
Ogre::Singleton
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
Ogre::ResourceManager
Defines a generic resource handler.
Definition: OgreResourceManager.h:122
Ogre::SharedPtr
Reference-counted shared pointer, used for objects where implicit destruction is required.
Definition: OgrePrerequisites.h:310
Ogre::Resource
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:79
Ogre::GpuProgramManager::SharedParametersMap
map< String, GpuSharedParametersPtr >::type SharedParametersMap
Definition: OgreGpuProgramManager.h:52
Ogre::GpuProgramManager::mSharedParametersMap
SharedParametersMap mSharedParametersMap
Definition: OgreGpuProgramManager.h:59
Ogre::GpuProgramManager::mSaveMicrocodesToCache
bool mSaveMicrocodesToCache
Definition: OgreGpuProgramManager.h:61
Ogre::GpuProgramManager::mMicrocodeCache
MicrocodeMap mMicrocodeCache
Definition: OgreGpuProgramManager.h:60
OgreGpuProgram.h
Ogre::GpuProgramManager::MicrocodeMap
map< String, Microcode >::type MicrocodeMap
Definition: OgreGpuProgramManager.h:55
Ogre::ManualResourceLoader
Interface describing a manual resource loader.
Definition: OgreResource.h:514
OgreResourceManager.h

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Tue Apr 13 2021 08:53:15