OGRE  1.8
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-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 
38 namespace Ogre {
39 
46  class _OgreExport GpuProgramManager : public ResourceManager, public Singleton<GpuProgramManager>
47  {
48  public:
49 
52 
55 
56  protected:
57 
61 
62  static String addRenderSystemToName( const String & name );
63 
65  virtual Resource* createImpl(const String& name, ResourceHandle handle,
66  const String& group, bool isManual, ManualResourceLoader* loader,
67  GpuProgramType gptype, const String& syntaxCode) = 0;
68  public:
70  virtual ~GpuProgramManager();
71 
83  virtual GpuProgramPtr load(const String& name, const String& groupName,
84  const String& filename, GpuProgramType gptype,
85  const String& syntaxCode);
86 
98  virtual GpuProgramPtr loadFromString(const String& name, const String& groupName,
99  const String& code, GpuProgramType gptype,
100  const String& syntaxCode);
101 
103  virtual const SyntaxCodes& getSupportedSyntax(void) const;
104 
105 
107  virtual bool isSyntaxSupported(const String& syntaxCode) const;
108 
114  virtual GpuProgramParametersSharedPtr createParameters(void);
115 
130  virtual GpuProgramPtr createProgram(const String& name,
131  const String& groupName, const String& filename,
132  GpuProgramType gptype, const String& syntaxCode);
133 
148  virtual GpuProgramPtr createProgramFromString(const String& name,
149  const String& groupName, const String& code,
150  GpuProgramType gptype, const String& syntaxCode);
151 
155  virtual ResourcePtr create(const String& name, const String& group,
156  GpuProgramType gptype, const String& syntaxCode, bool isManual = false,
157  ManualResourceLoader* loader = 0);
158 
164  ResourcePtr getByName(const String& name, bool preferHighLevelPrograms = true);
165 
166 
172  virtual GpuSharedParametersPtr createSharedParameters(const String& name);
173 
177  virtual GpuSharedParametersPtr getSharedParameters(const String& name) const;
178 
181  virtual const SharedParametersMap& getAvailableSharedParameters() const;
182 
185  bool getSaveMicrocodesToCache();
188  void setSaveMicrocodesToCache( const bool val );
189 
190  bool canGetCompiledShaderBuffer();
194  virtual bool isMicrocodeAvailableInCache( const String & name ) const;
198  virtual const Microcode & getMicrocodeFromCache( const String & name ) const;
199 
203  virtual Microcode createMicrocode( const size_t size ) const;
204 
208  virtual void addMicrocodeToCache( const String & name, const Microcode & microcode );
209 
213  virtual void saveMicrocodeCache( DataStreamPtr stream ) const;
217  virtual void loadMicrocodeCache( DataStreamPtr stream );
218 
219 
220 
236  static GpuProgramManager& getSingleton(void);
252  static GpuProgramManager* getSingletonPtr(void);
253 
254 
255 
256  };
257 
260 }
261 
262 #endif
#define _OgreExport
Definition: OgrePlatform.h:233
MemoryDataStreamPtr Microcode
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.
Interface describing a manual resource loader.
Definition: OgreResource.h:513
map< String, Microcode >::type MicrocodeMap
map< String, GpuSharedParametersPtr >::type SharedParametersMap
SharedParametersMap mSharedParametersMap
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:78
unsigned long long int ResourceHandle
Definition: OgreResource.h:40
set< String >::type SyntaxCodes
Defines a generic resource handler.
_StringBase String