OgreShaderFunction.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 _ShaderProgramFunction_
#define _ShaderProgramFunction_
#include "OgreShaderPrerequisites.h"
#include "OgreShaderParameter.h"
#include "OgreShaderFunctionAtom.h"
namespace Ogre {
namespace RTShader {
class _OgreRTSSExport Function : public RTShaderSystemAlloc
{
// Interface.
public:
enum FunctionType
{
// internal function (default)
FFT_INTERNAL,
// Vertex program main
FFT_VS_MAIN,
// Pixel shader main
FFT_PS_MAIN
};
const String& getName() const { return mName; }
const String& getDescription() const { return mDescription; }
ParameterPtr resolveInputParameter(Parameter::Semantic semantic, int index, const Parameter::Content content, GpuConstantType type);
ParameterPtr resolveOutputParameter(Parameter::Semantic semantic, int index, const Parameter::Content content, GpuConstantType type);
ParameterPtr resolveLocalParameter(Parameter::Semantic semantic, int index, const String& name, GpuConstantType type);
ParameterPtr resolveLocalParameter(Parameter::Semantic semantic, int index, const Parameter::Content content, GpuConstantType type);
static ParameterPtr getParameterByName(const ShaderParameterList& parameterList, const String& name);
static ParameterPtr getParameterBySemantic(const ShaderParameterList& parameterList, const Parameter::Semantic semantic, int index);
ParameterPtr getParameterByContent(const ShaderParameterList& parameterList, const Parameter::Content content, GpuConstantType type);
const ShaderParameterList& getInputParameters() const { return mInputParameters; }
const ShaderParameterList& getOutputParameters() const { return mOutputParameters; }
const ShaderParameterList& getLocalParameters() const { return mLocalParameters; }
void addAtomInstance(FunctionAtom* atomInstance);
bool deleteAtomInstance(FunctionAtom* atomInstance);
void sortAtomInstances();
FunctionAtomInstanceList& getAtomInstances() { return mAtomInstances; }
const FunctionAtomInstanceList& getAtomInstances() const { return mAtomInstances; }
void addInputParameter(ParameterPtr parameter);
void addOutputParameter(ParameterPtr parameter);
void deleteInputParameter(ParameterPtr parameter);
void deleteOutputParameter(ParameterPtr parameter);
void deleteAllInputParameters();
void deleteAllOutputParameters();
FunctionType getFunctionType() const;
protected:
Function(const String& name, const String& desc, const FunctionType functionType);
~Function();
void addParameter(ShaderParameterList& parameterList, ParameterPtr parameter);
void deleteParameter(ShaderParameterList& parameterList, ParameterPtr parameter);
protected:
// Function name.
String mName;
// Function description.
String mDescription;
// Input parameters.
ShaderParameterList mInputParameters;
// Output parameters.
ShaderParameterList mOutputParameters;
// Local parameters.
ShaderParameterList mLocalParameters;
// Atom instances composing this function.
FunctionAtomInstanceList mAtomInstances;
// Function type
FunctionType mFunctionType;
private:
friend class Program;
};
typedef vector<Function*>::type ShaderFunctionList;
typedef ShaderFunctionList::iterator ShaderFunctionIterator;
typedef ShaderFunctionList::const_iterator ShaderFunctionConstIterator;
}
}
#endif
Ogre::RTShader::Function::getLocalParameters
const ShaderParameterList & getLocalParameters() const
Return a list of local parameters.
Definition: OgreShaderFunction.h:140
Ogre::RTShader::FunctionAtom
A class that represents an atomic code section of shader based program function.
Definition: OgreShaderFunctionAtom.h:48
Ogre::RTShader::Parameter::Semantic
Semantic
Definition: OgreShaderParameter.h:53
Ogre::RTShader::Function::getInputParameters
const ShaderParameterList & getInputParameters() const
Return a list of input parameters.
Definition: OgreShaderFunction.h:134
Ogre::RTShader::Function::mInputParameters
ShaderParameterList mInputParameters
Definition: OgreShaderFunction.h:207
Ogre::RTShader::Function::mLocalParameters
ShaderParameterList mLocalParameters
Definition: OgreShaderFunction.h:211
OgreShaderParameter.h
Ogre::RTShader::ShaderFunctionIterator
ShaderFunctionList::iterator ShaderFunctionIterator
Definition: OgreShaderFunction.h:222
OgreShaderPrerequisites.h
Ogre::RTShader::Function::FunctionType
FunctionType
Definition: OgreShaderFunction.h:50
Ogre::RTShader::ShaderParameterList
vector< ParameterPtr >::type ShaderParameterList
Definition: OgreShaderParameter.h:370
Ogre::RTShader::Function::getDescription
const String & getDescription() const
Get the description of this function.
Definition: OgreShaderFunction.h:64
Ogre::RTShader::Parameter::Content
Content
Definition: OgreShaderParameter.h:76
Ogre::RTShader::ShaderFunctionList
vector< Function * >::type ShaderFunctionList
Definition: OgreShaderFunction.h:221
Ogre::RTShader::Program
A class that represents a shader based program.
Definition: OgreShaderProgram.h:50
Ogre::RTShader::Function::getAtomInstances
FunctionAtomInstanceList & getAtomInstances()
Return list of atom instances composing this function.
Definition: OgreShaderFunction.h:156
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::RTShader::Function::FFT_INTERNAL
Definition: OgreShaderFunction.h:53
Ogre::RTShader::Function::getName
const String & getName() const
Get the name of this function.
Definition: OgreShaderFunction.h:61
Ogre::RTShader::Function::mName
String mName
Definition: OgreShaderFunction.h:203
_OgreRTSSExport
#define _OgreRTSSExport
Definition: OgreShaderPrerequisites.h:108
Ogre::RTShader::Function::mAtomInstances
FunctionAtomInstanceList mAtomInstances
Definition: OgreShaderFunction.h:213
Ogre::RTShader::Function::mFunctionType
FunctionType mFunctionType
Definition: OgreShaderFunction.h:215
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::RTShader::Function
A class that represents a shader based program function.
Definition: OgreShaderFunction.h:46
Ogre::SharedPtr< Parameter >
Ogre::GpuConstantType
GpuConstantType
Enumeration of the types of constant we may encounter in programs.
Definition: OgreGpuProgramParams.h:54
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::RTShader::Function::getOutputParameters
const ShaderParameterList & getOutputParameters() const
Return a list of output parameters.
Definition: OgreShaderFunction.h:137
Ogre::RTShader::Function::FFT_VS_MAIN
Definition: OgreShaderFunction.h:55
Ogre::RTShader::Function::getAtomInstances
const FunctionAtomInstanceList & getAtomInstances() const
Return list of atom instances composing this function.
Definition: OgreShaderFunction.h:159
Ogre::RTShader::ShaderFunctionConstIterator
ShaderFunctionList::const_iterator ShaderFunctionConstIterator
Definition: OgreShaderFunction.h:223
Ogre::RTShader::Function::mDescription
String mDescription
Definition: OgreShaderFunction.h:205
Ogre::RTShader::FunctionAtomInstanceList
vector< FunctionAtom * >::type FunctionAtomInstanceList
Definition: OgreShaderFunctionAtom.h:257
OgreShaderFunctionAtom.h
Ogre::RTShader::Function::mOutputParameters
ShaderParameterList mOutputParameters
Definition: OgreShaderFunction.h:209
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58

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