OgreGpuProgram.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __GpuProgram_H_
#define __GpuProgram_H_
// Precompiler options
#include "OgrePrerequisites.h"
#include "OgreResource.h"
#include "OgreSharedPtr.h"
#include "OgreIteratorWrappers.h"
#include "OgreSerializer.h"
#include "OgreRenderOperation.h"
#include "OgreGpuProgramParams.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
enum GpuProgramType
{
GPT_VERTEX_PROGRAM,
GPT_FRAGMENT_PROGRAM,
GPT_GEOMETRY_PROGRAM,
GPT_DOMAIN_PROGRAM,
GPT_HULL_PROGRAM,
GPT_COMPUTE_PROGRAM
};
class _OgreExport GpuProgram : public Resource
{
protected:
class _OgreExport CmdType : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
class _OgreExport CmdSyntax : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
class _OgreExport CmdSkeletal : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
class _OgreExport CmdMorph : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
class _OgreExport CmdPose : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
class _OgreExport CmdVTF : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
class _OgreExport CmdManualNamedConstsFile : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
class _OgreExport CmdAdjacency : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
// Command object for setting / getting parameters
static CmdType msTypeCmd;
static CmdSyntax msSyntaxCmd;
static CmdSkeletal msSkeletalCmd;
static CmdMorph msMorphCmd;
static CmdPose msPoseCmd;
static CmdVTF msVTFCmd;
static CmdManualNamedConstsFile msManNamedConstsFileCmd;
static CmdAdjacency msAdjacencyCmd;
GpuProgramType mType;
String mFilename;
String mSource;
bool mLoadFromFile;
String mSyntaxCode;
bool mSkeletalAnimation;
bool mMorphAnimation;
ushort mPoseAnimation;
bool mVertexTextureFetch;
bool mNeedsAdjacencyInfo;
GpuProgramParametersSharedPtr mDefaultParams;
bool mCompileError;
mutable GpuLogicalBufferStructPtr mFloatLogicalToPhysical;
mutable GpuLogicalBufferStructPtr mDoubleLogicalToPhysical;
mutable GpuLogicalBufferStructPtr mIntLogicalToPhysical;
mutable GpuNamedConstantsPtr mConstantDefs;
String mManualNamedConstantsFile;
bool mLoadedManualNamedConstants;
void setupBaseParamDictionary(void);
bool isRequiredCapabilitiesSupported(void) const;
void loadImpl(void);
void createParameterMappingStructures(bool recreateIfExists = true) const;
void createLogicalParameterMappingStructures(bool recreateIfExists = true) const;
void createNamedParameterMappingStructures(bool recreateIfExists = true) const;
public:
GpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
virtual ~GpuProgram() {}
virtual void setSourceFile(const String& filename);
virtual void setSource(const String& source);
virtual const String& getSyntaxCode(void) const { return mSyntaxCode; }
virtual void setSyntaxCode(const String& syntax);
virtual const String& getSourceFile(void) const { return mFilename; }
virtual const String& getSource(void) const { return mSource; }
virtual void setType(GpuProgramType t);
virtual GpuProgramType getType(void) const { return mType; }
virtual GpuProgram* _getBindingDelegate(void) { return this; }
virtual bool isSupported(void) const;
virtual GpuProgramParametersSharedPtr createParameters(void);
virtual void setSkeletalAnimationIncluded(bool included)
{ mSkeletalAnimation = included; }
virtual bool isSkeletalAnimationIncluded(void) const { return mSkeletalAnimation; }
virtual void setMorphAnimationIncluded(bool included)
{ mMorphAnimation = included; }
virtual void setPoseAnimationIncluded(ushort poseCount)
{ mPoseAnimation = poseCount; }
virtual bool isMorphAnimationIncluded(void) const { return mMorphAnimation; }
virtual bool isPoseAnimationIncluded(void) const { return mPoseAnimation > 0; }
virtual ushort getNumberOfPosesIncluded(void) const { return mPoseAnimation; }
virtual void setVertexTextureFetchRequired(bool r) { mVertexTextureFetch = r; }
virtual bool isVertexTextureFetchRequired(void) const { return mVertexTextureFetch; }
virtual void setAdjacencyInfoRequired(bool r) { mNeedsAdjacencyInfo = r; }
virtual bool isAdjacencyInfoRequired(void) const { return mNeedsAdjacencyInfo; }
virtual GpuProgramParametersSharedPtr getDefaultParameters(void);
virtual bool hasDefaultParameters(void) const { return !mDefaultParams.isNull(); }
virtual bool getPassSurfaceAndLightStates(void) const { return false; }
virtual bool getPassFogStates(void) const { return true; }
virtual bool getPassTransformStates(void) const { return false; }
virtual const String& getLanguage(void) const;
virtual bool hasCompileError(void) const { return mCompileError; }
virtual void resetCompileError(void) { mCompileError = false; }
virtual void setManualNamedConstants(const GpuNamedConstants& namedConstants);
virtual const GpuNamedConstants& getNamedConstants() const { return *mConstantDefs.get(); }
virtual void setManualNamedConstantsFile(const String& paramDefFile);
virtual const String& getManualNamedConstantsFile() const { return mManualNamedConstantsFile; }
virtual const GpuNamedConstants& getConstantDefinitions() const { return *mConstantDefs.get(); }
virtual size_t calculateSize(void) const;
protected:
virtual void loadFromSource(void) = 0;
};
}
#include "OgreHeaderSuffix.h"
#endif
Ogre::GpuProgram::setMorphAnimationIncluded
virtual void setMorphAnimationIncluded(bool included)
Sets whether a vertex program includes the required instructions to perform morph animation...
Definition: OgreGpuProgram.h:278
Ogre::GpuProgram::mSyntaxCode
String mSyntaxCode
Syntax code e.g. arbvp1, vs_2_0 etc.
Definition: OgreGpuProgram.h:139
Ogre::GpuProgram::getNamedConstants
virtual const GpuNamedConstants & getNamedConstants() const
Get a read-only reference to the named constants registered for this program (manually or automatical...
Definition: OgreGpuProgram.h:394
Ogre::GpuProgram::msManNamedConstsFileCmd
static CmdManualNamedConstsFile msManNamedConstsFileCmd
Definition: OgreGpuProgram.h:128
Ogre::GpuProgram::CmdMorph
Definition: OgreGpuProgram.h:91
Ogre::GpuProgram::msSyntaxCmd
static CmdSyntax msSyntaxCmd
Definition: OgreGpuProgram.h:123
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::GpuProgram::getType
virtual GpuProgramType getType(void) const
Get the program type.
Definition: OgreGpuProgram.h:235
Ogre::GpuProgram::resetCompileError
virtual void resetCompileError(void)
Reset a compile error if it occurred, allowing the load to be retried.
Definition: OgreGpuProgram.h:381
Ogre::GpuProgram::msTypeCmd
static CmdType msTypeCmd
Definition: OgreGpuProgram.h:122
Ogre::GpuProgram::mType
GpuProgramType mType
The type of the program.
Definition: OgreGpuProgram.h:131
Ogre::GpuProgram::mMorphAnimation
bool mMorphAnimation
Does this (vertex) program include morph animation?
Definition: OgreGpuProgram.h:143
OgreResource.h
OgreSharedPtr.h
Ogre::GpuNamedConstants
Struct collecting together the information for named constants.
Definition: OgreGpuProgramParams.h:355
Ogre::GpuProgram::getSyntaxCode
virtual const String & getSyntaxCode(void) const
Gets the syntax code for this program e.g.
Definition: OgreGpuProgram.h:223
Ogre::GpuProgram::hasDefaultParameters
virtual bool hasDefaultParameters(void) const
Returns true if default parameters have been set up.
Definition: OgreGpuProgram.h:342
Ogre::GpuProgram::CmdType
Command object - see ParamCommand.
Definition: OgreGpuProgram.h:73
Ogre::GpuProgram::mFloatLogicalToPhysical
GpuLogicalBufferStructPtr mFloatLogicalToPhysical
Record of logical to physical buffer maps.
Definition: OgreGpuProgram.h:158
Ogre::GpuProgram::msVTFCmd
static CmdVTF msVTFCmd
Definition: OgreGpuProgram.h:127
Ogre::GpuProgram::setAdjacencyInfoRequired
virtual void setAdjacencyInfoRequired(bool r)
Sets whether this geometry program requires adjacency information from the input primitives.
Definition: OgreGpuProgram.h:322
Ogre::Resource
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:79
Ogre::GpuProgram::mSource
String mSource
The assembler source of the program (may be blank until file loaded)
Definition: OgreGpuProgram.h:135
Ogre::GpuProgram::mDefaultParams
GpuProgramParametersSharedPtr mDefaultParams
The default parameters for use with this object.
Definition: OgreGpuProgram.h:151
Ogre::ManualResourceLoader
Interface describing a manual resource loader.
Definition: OgreResource.h:514
Ogre::SharedPtr::isNull
bool isNull(void) const
Definition: OgreSharedPtr.h:275
Ogre::GpuProgram::mManualNamedConstantsFile
String mManualNamedConstantsFile
File from which to load named constants manually.
Definition: OgreGpuProgram.h:175
Ogre::ResourceHandle
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
Ogre::GpuProgram::msAdjacencyCmd
static CmdAdjacency msAdjacencyCmd
Definition: OgreGpuProgram.h:129
Ogre::GPT_GEOMETRY_PROGRAM
Definition: OgreGpuProgram.h:54
Ogre::GpuProgram::setSkeletalAnimationIncluded
virtual void setSkeletalAnimationIncluded(bool included)
Sets whether a vertex program includes the required instructions to perform skeletal animation...
Definition: OgreGpuProgram.h:261
Ogre::GpuProgram::mConstantDefs
GpuNamedConstantsPtr mConstantDefs
Parameter name -> ConstantDefinition map, shared instance used by all parameter objects.
Definition: OgreGpuProgram.h:173
Ogre::GpuProgram::isVertexTextureFetchRequired
virtual bool isVertexTextureFetchRequired(void) const
Returns whether this vertex program requires support for vertex texture fetch from the hardware...
Definition: OgreGpuProgram.h:317
Ogre::GpuProgram::getPassTransformStates
virtual bool getPassTransformStates(void) const
Returns whether a vertex program wants transform state to be passed through fixed pipeline low level ...
Definition: OgreGpuProgram.h:368
Ogre::GPT_COMPUTE_PROGRAM
Definition: OgreGpuProgram.h:57
Ogre::GPT_VERTEX_PROGRAM
Definition: OgreGpuProgram.h:52
Ogre::GpuProgram::isAdjacencyInfoRequired
virtual bool isAdjacencyInfoRequired(void) const
Returns whether this geometry program requires adjacency information from the input primitives...
Definition: OgreGpuProgram.h:326
Ogre::GpuProgram::msPoseCmd
static CmdPose msPoseCmd
Definition: OgreGpuProgram.h:126
Ogre::GpuProgram::mPoseAnimation
ushort mPoseAnimation
Does this (vertex) program include pose animation (count of number of poses supported) ...
Definition: OgreGpuProgram.h:145
OgrePrerequisites.h
OgreGpuProgramParams.h
Ogre::GpuProgram::getConstantDefinitions
virtual const GpuNamedConstants & getConstantDefinitions() const
Get the full list of named constants.
Definition: OgreGpuProgram.h:418
Ogre::GpuProgram::CmdPose
Definition: OgreGpuProgram.h:97
Ogre::GpuProgram::CmdVTF
Definition: OgreGpuProgram.h:103
Ogre::GpuProgram::getPassFogStates
virtual bool getPassFogStates(void) const
Returns whether a fragment program wants fog state to be passed through fixed pipeline low level API ...
Definition: OgreGpuProgram.h:360
Ogre::GpuProgram::mFilename
String mFilename
The name of the file to load source from (may be blank)
Definition: OgreGpuProgram.h:133
Ogre::GPT_FRAGMENT_PROGRAM
Definition: OgreGpuProgram.h:53
Ogre::GpuProgram::getManualNamedConstantsFile
virtual const String & getManualNamedConstantsFile() const
Gets the name of a file from which to load named parameters mapping for a program which would not be ...
Definition: OgreGpuProgram.h:411
OgreRenderOperation.h
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::GpuProgramType
GpuProgramType
Enumerates the types of programs which can run on the GPU.
Definition: OgreGpuProgram.h:50
OgreHeaderSuffix.h
Ogre::GpuProgram::CmdManualNamedConstsFile
Definition: OgreGpuProgram.h:109
Ogre::ResourceManager
Defines a generic resource handler.
Definition: OgreResourceManager.h:122
OgreIteratorWrappers.h
Ogre::GpuProgram
Defines a program which runs on the GPU such as a vertex or fragment program.
Definition: OgreGpuProgram.h:69
Ogre::GpuProgram::isMorphAnimationIncluded
virtual bool isMorphAnimationIncluded(void) const
Returns whether a vertex program includes the required instructions to perform morph animation...
Definition: OgreGpuProgram.h:297
Ogre::GpuProgram::mCompileError
bool mCompileError
Did we encounter a compilation error?
Definition: OgreGpuProgram.h:153
Ogre::GpuProgram::getPassSurfaceAndLightStates
virtual bool getPassSurfaceAndLightStates(void) const
Returns whether a vertex program wants light and material states to be passed through fixed pipeline ...
Definition: OgreGpuProgram.h:350
Ogre::GpuProgram::getSourceFile
virtual const String & getSourceFile(void) const
Gets the name of the file used as source for this program.
Definition: OgreGpuProgram.h:229
Ogre::GPT_DOMAIN_PROGRAM
Definition: OgreGpuProgram.h:55
Ogre::SharedPtr::get
T * get() const
Definition: OgreSharedPtr.h:254
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::GpuProgram::setVertexTextureFetchRequired
virtual void setVertexTextureFetchRequired(bool r)
Sets whether this vertex program requires support for vertex texture fetch from the hardware...
Definition: OgreGpuProgram.h:313
Ogre::GpuProgram::CmdSkeletal
Definition: OgreGpuProgram.h:85
Ogre::GpuProgram::msMorphCmd
static CmdMorph msMorphCmd
Definition: OgreGpuProgram.h:125
Ogre::GpuProgram::msSkeletalCmd
static CmdSkeletal msSkeletalCmd
Definition: OgreGpuProgram.h:124
OgreSerializer.h
Ogre::GpuProgram::mSkeletalAnimation
bool mSkeletalAnimation
Does this (vertex) program include skeletal animation?
Definition: OgreGpuProgram.h:141
Ogre::SharedPtr< GpuProgramParameters >
Ogre::GpuProgram::mVertexTextureFetch
bool mVertexTextureFetch
Does this (vertex) program require support for vertex texture fetch?
Definition: OgreGpuProgram.h:147
Ogre::GpuProgram::getNumberOfPosesIncluded
virtual ushort getNumberOfPosesIncluded(void) const
Returns the number of simultaneous poses the vertex program can blend, for use in pose animation...
Definition: OgreGpuProgram.h:309
OgreHeaderPrefix.h
Ogre::GpuProgram::mNeedsAdjacencyInfo
bool mNeedsAdjacencyInfo
Does this (geometry) program require adjacency information?
Definition: OgreGpuProgram.h:149
Ogre::GpuProgram::mIntLogicalToPhysical
GpuLogicalBufferStructPtr mIntLogicalToPhysical
Record of logical to physical buffer maps.
Definition: OgreGpuProgram.h:168
Ogre::GpuProgram::CmdSyntax
Definition: OgreGpuProgram.h:79
Ogre::GpuProgram::mDoubleLogicalToPhysical
GpuLogicalBufferStructPtr mDoubleLogicalToPhysical
Record of logical to physical buffer maps.
Definition: OgreGpuProgram.h:163
Ogre::GPT_HULL_PROGRAM
Definition: OgreGpuProgram.h:56
Ogre::GpuProgram::isSkeletalAnimationIncluded
virtual bool isSkeletalAnimationIncluded(void) const
Returns whether a vertex program includes the required instructions to perform skeletal animation...
Definition: OgreGpuProgram.h:270
Ogre::GpuProgram::hasCompileError
virtual bool hasCompileError(void) const
Did this program encounter a compile error when loading?
Definition: OgreGpuProgram.h:377
Ogre::ushort
unsigned short ushort
Definition: OgrePrerequisites.h:113
Ogre::ParamCommand
Abstract class which is command object which gets/sets parameters.
Definition: OgreStringInterface.h:79
Ogre::GpuProgram::CmdAdjacency
Definition: OgreGpuProgram.h:115
Ogre::GpuProgram::~GpuProgram
virtual ~GpuProgram()
Definition: OgreGpuProgram.h:208
Ogre::GpuProgram::setPoseAnimationIncluded
virtual void setPoseAnimationIncluded(ushort poseCount)
Sets whether a vertex program includes the required instructions to perform pose animation.
Definition: OgreGpuProgram.h:288
Ogre::GpuProgram::_getBindingDelegate
virtual GpuProgram * _getBindingDelegate(void)
Returns the GpuProgram which should be bound to the pipeline.
Definition: OgreGpuProgram.h:241
Ogre::GpuProgram::mLoadedManualNamedConstants
bool mLoadedManualNamedConstants
Definition: OgreGpuProgram.h:176
Ogre::GpuProgram::getSource
virtual const String & getSource(void) const
Gets the assembler source for this program.
Definition: OgreGpuProgram.h:231
Ogre::GpuProgram::mLoadFromFile
bool mLoadFromFile
Whether we need to load source from file or not.
Definition: OgreGpuProgram.h:137
Ogre::GpuProgram::isPoseAnimationIncluded
virtual bool isPoseAnimationIncluded(void) const
Returns whether a vertex program includes the required instructions to perform pose animation...
Definition: OgreGpuProgram.h:305

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.