OGRE  1.9.0
OgreGpuProgramManager.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE 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
39namespace 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
68 const String& group, bool isManual, ManualResourceLoader* loader,
70 public:
73
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
121
136 virtual GpuProgramPtr createProgram(const String& name,
137 const String& groupName, const String& filename,
139
155 const String& groupName, const String& code,
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
171
172
179
184
188
194 void setSaveMicrocodesToCache( const bool val );
195
198 bool isCacheDirty(void) const;
199
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
268
269
270
271 };
272
275}
276
277#include "OgreHeaderSuffix.h"
278
279#endif
#define _OgreExport
static GpuProgramManager * getSingletonPtr(void)
Override standard Singleton retrieval.
map< String, Microcode >::type MicrocodeMap
virtual GpuProgramPtr createProgramFromString(const String &name, const String &groupName, const String &code, GpuProgramType gptype, const String &syntaxCode)
Create a GPU program from a string of assembly code.
virtual Microcode createMicrocode(const uint32 size) const
Creates a microcode to be later added to the cache.
virtual GpuSharedParametersPtr getSharedParameters(const String &name) const
Retrieve a set of shared parameters, which can be used across many GpuProgramParameters objects of di...
set< String >::type SyntaxCodes
bool isCacheDirty(void) const
Returns true if the microcodecache changed during the run.
virtual GpuProgramPtr createProgram(const String &name, const String &groupName, const String &filename, GpuProgramType gptype, const String &syntaxCode)
Create a new, unloaded GpuProgram from a file of assembly.
virtual void removeMicrocodeFromCache(const String &name)
Removes a microcode for a program from the microcode cache.
virtual void addMicrocodeToCache(const String &name, const Microcode &microcode)
Adds a microcode for a program to the microcode cache.
virtual GpuSharedParametersPtr createSharedParameters(const String &name)
Create a new set of shared parameters, which can be used across many GpuProgramParameters objects of ...
virtual bool isSyntaxSupported(const String &syntaxCode) const
Returns whether a given syntax code (e.g.
virtual bool isMicrocodeAvailableInCache(const String &name) const
Check if a microcode is available for a program in the microcode cache.
bool getSaveMicrocodesToCache()
Get if the microcode of a shader should be saved to a cache.
virtual const SharedParametersMap & getAvailableSharedParameters() const
Get (const) access to the available shared parameter sets.
virtual GpuProgramParametersSharedPtr createParameters(void)
Creates a new GpuProgramParameters instance which can be used to bind parameters to your programs.
SharedParametersMap mSharedParametersMap
virtual const Microcode & getMicrocodeFromCache(const String &name) const
Returns a microcode for a program from the microcode cache.
ResourcePtr getResourceByName(const String &name, bool preferHighLevelPrograms=true)
Overrides the standard ResourceManager getResourceByName method.
virtual ResourcePtr create(const String &name, const String &group, GpuProgramType gptype, const String &syntaxCode, bool isManual=false, ManualResourceLoader *loader=0)
General create method, using specific create parameters instead of name / value pairs.
virtual void saveMicrocodeCache(DataStreamPtr stream) const
Saves the microcode cache to disk.
virtual Resource * createImpl(const String &name, ResourceHandle handle, const String &group, bool isManual, ManualResourceLoader *loader, GpuProgramType gptype, const String &syntaxCode)=0
Specialised create method with specific parameters.
static GpuProgramManager & getSingleton(void)
Override standard Singleton retrieval.
void setSaveMicrocodesToCache(const bool val)
Set if the microcode of a shader should be saved to a cache.
virtual GpuProgramPtr loadFromString(const String &name, const String &groupName, const String &code, GpuProgramType gptype, const String &syntaxCode)
Loads a GPU program from a string of assembly code.
static String addRenderSystemToName(const String &name)
virtual const SyntaxCodes & getSupportedSyntax(void) const
Returns the syntaxes that this manager supports.
virtual GpuProgramPtr load(const String &name, const String &groupName, const String &filename, GpuProgramType gptype, const String &syntaxCode)
Loads a GPU program from a file of assembly.
map< String, GpuSharedParametersPtr >::type SharedParametersMap
MemoryDataStreamPtr Microcode
virtual void loadMicrocodeCache(DataStreamPtr stream)
Loads the microcode cache from disk.
GpuProgramPtr getByName(const String &name, bool preferHighLevelPrograms=true)
Get a resource by name.
Interface describing a manual resource loader.
Defines a generic resource handler.
Abstract class representing a loadable resource (e.g.
Reference-counted shared pointer, used for objects where implicit destruction is required.
Template class for creating single-instance global classes.
GpuProgramType
Enumerates the types of programs which can run on the GPU.
_StringBase String
std::map< K, V, P, A > type
std::set< T, P, A > type