OgreShaderFunctionAtom.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 _ShaderFunctionAtom_
#define _ShaderFunctionAtom_
#include "OgreShaderPrerequisites.h"
#include "OgreGpuProgram.h"
#include "OgreSingleton.h"
#include "OgreShaderParameter.h"
#include "OgreStringVector.h"
namespace Ogre {
namespace RTShader {
class _OgreRTSSExport FunctionAtom : public RTShaderSystemAlloc
{
// Interface.
public:
FunctionAtom();
virtual ~FunctionAtom() {}
int getGroupExecutionOrder() const;
int getInternalExecutionOrder() const;
virtual void writeSourceCode(std::ostream& os, const String& targetLanguage) const = 0;
virtual const String& getFunctionAtomType() = 0;
// Attributes.
protected:
// The owner group execution order.
int mGroupExecutionOrder;
// The execution order within the group.
int mInternalExecutionOrder;
};
class _OgreRTSSExport Operand : public RTShaderSystemAlloc
{
public:
// InOut semantic
enum OpSemantic
{
OPS_IN,
OPS_OUT,
OPS_INOUT
};
// Used field mask
enum OpMask
{
OPM_ALL = 0x0001,
OPM_X = 0x0002,
OPM_Y = 0x0004,
OPM_Z = 0x0008,
OPM_W = 0x0010,
OPM_XY = OPM_X | OPM_Y,
OPM_XZ = OPM_X | OPM_Z,
OPM_XW = OPM_X | OPM_W,
OPM_YZ = OPM_Y | OPM_Z,
OPM_YW = OPM_Y | OPM_W,
OPM_ZW = OPM_Z | OPM_W,
OPM_XYZ = OPM_X | OPM_Y | OPM_Z,
OPM_XYW = OPM_X | OPM_Y | OPM_W,
OPM_XZW = OPM_X | OPM_Z | OPM_W,
OPM_YZW = OPM_Y | OPM_Z | OPM_W,
OPM_XYZW = OPM_X | OPM_Y | OPM_Z | OPM_W
};
Operand(ParameterPtr parameter, Operand::OpSemantic opSemantic, int opMask = Operand::OPM_ALL, ushort indirectionLevel = 0);
Operand(const Operand& rhs);
Operand& operator= (const Operand & rhs);
~Operand();
const ParameterPtr& getParameter() const { return mParameter; }
bool hasFreeFields() const { return ((mMask & ~OPM_ALL) && ((mMask & ~OPM_X) || (mMask & ~OPM_Y) || (mMask & ~OPM_Z) || (mMask & ~OPM_W))); }
int getMask() const { return mMask; }
OpSemantic getSemantic() const { return mSemantic; }
ushort getIndirectionLevel() const { return mIndirectionLevel; }
String toString() const;
static String getMaskAsString(int mask);
static int getFloatCount(int mask);
static GpuConstantType getGpuConstantType(int mask);
protected:
ParameterPtr mParameter;
OpSemantic mSemantic;
int mMask;
ushort mIndirectionLevel;
};
class _OgreRTSSExport FunctionInvocation : public FunctionAtom
{
// Interface.
public:
typedef vector<Operand>::type OperandVector;
FunctionInvocation(const String& functionName, int groupOrder, int internalOrder, String returnType = "void");
FunctionInvocation(const FunctionInvocation& rhs);
virtual void writeSourceCode(std::ostream& os, const String& targetLanguage) const;
virtual const String& getFunctionAtomType() { return Type; }
OperandVector& getOperandList() { return mOperands; }
void pushOperand(ParameterPtr parameter, Operand::OpSemantic opSemantic, int opMask = Operand::OPM_ALL, int indirectionLevel = 0);
const String& getFunctionName() const { return mFunctionName; }
const String& getReturnType() const { return mReturnType; }
bool operator == ( const FunctionInvocation& rhs ) const;
bool operator != ( const FunctionInvocation& rhs ) const;
bool operator < ( const FunctionInvocation& rhs ) const;
struct FunctionInvocationLessThan
{
bool operator()(FunctionInvocation const& lhs, FunctionInvocation const& rhs) const;
};
struct FunctionInvocationCompare
{
bool operator()(FunctionInvocation const& lhs, FunctionInvocation const& rhs) const;
};
static String Type;
// Attributes.
protected:
String mFunctionName;
String mReturnType;
OperandVector mOperands;
};
typedef vector<FunctionAtom*>::type FunctionAtomInstanceList;
typedef FunctionAtomInstanceList::iterator FunctionAtomInstanceIterator;
typedef FunctionAtomInstanceList::const_iterator FunctionAtomInstanceConstIterator;
}
}
#endif
Ogre::RTShader::FunctionAtom
A class that represents an atomic code section of shader based program function.
Definition: OgreShaderFunctionAtom.h:48
Ogre::RTShader::FunctionInvocation::Type
static String Type
The type of this class.
Definition: OgreShaderFunctionAtom.h:248
Ogre::RTShader::FunctionInvocation::getReturnType
const String & getReturnType() const
Return the return type.
Definition: OgreShaderFunctionAtom.h:220
Ogre::RTShader::Operand::mParameter
ParameterPtr mParameter
The parameter being carried by the operand.
Definition: OgreShaderFunctionAtom.h:167
Ogre::RTShader::Operand::mIndirectionLevel
ushort mIndirectionLevel
The level of indirection.
Definition: OgreShaderFunctionAtom.h:173
Ogre::RTShader::FunctionInvocation::OperandVector
vector< Operand >::type OperandVector
Definition: OgreShaderFunctionAtom.h:182
Ogre::RTShader::FunctionAtom::~FunctionAtom
virtual ~FunctionAtom()
Class default destructor.
Definition: OgreShaderFunctionAtom.h:56
Ogre::RTShader::FunctionInvocation::FunctionInvocationLessThan
Comparator function to be used for sorting.
Definition: OgreShaderFunctionAtom.h:234
Ogre::RTShader::Operand::OpMask
OpMask
Definition: OgreShaderFunctionAtom.h:96
Ogre::RTShader::FunctionInvocation::mOperands
OperandVector mOperands
Definition: OgreShaderFunctionAtom.h:254
Ogre::RTShader::FunctionInvocation::getFunctionName
const String & getFunctionName() const
Return the function name.
Definition: OgreShaderFunctionAtom.h:217
Ogre::RTShader::Operand::OPS_IN
The parameter is a input parameter.
Definition: OgreShaderFunctionAtom.h:88
OgreShaderParameter.h
OgreShaderPrerequisites.h
Ogre::RTShader::Operand::getSemantic
OpSemantic getSemantic() const
Returns the operand semantic (do we read/write or both with the parameter).
Definition: OgreShaderFunctionAtom.h:144
Ogre::RTShader::FunctionInvocation
A class that represents function invocation code from shader based program function.
Definition: OgreShaderFunctionAtom.h:178
Ogre::RTShader::FunctionAtomInstanceConstIterator
FunctionAtomInstanceList::const_iterator FunctionAtomInstanceConstIterator
Definition: OgreShaderFunctionAtom.h:259
Ogre::RTShader::FunctionAtom::mGroupExecutionOrder
int mGroupExecutionOrder
Definition: OgreShaderFunctionAtom.h:73
Ogre::RTShader::FunctionInvocation::FunctionInvocationCompare
Comparator function to be used for comparisons.
Definition: OgreShaderFunctionAtom.h:242
OgreSingleton.h
Ogre::RTShader::FunctionInvocation::mFunctionName
String mFunctionName
Definition: OgreShaderFunctionAtom.h:252
Ogre::operator!=
bool operator!=(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
Definition: OgreMemorySTLAllocator.h:202
Ogre::RTShader::Operand::hasFreeFields
bool hasFreeFields() const
Returns true if not all fields used.
Definition: OgreShaderFunctionAtom.h:138
OgreStringVector.h
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::RTShader::Operand::OPM_ALL
Definition: OgreShaderFunctionAtom.h:98
Ogre::RTShader::Operand
A class that represents a function operand (its the combination of a parameter the in/out semantic an...
Definition: OgreShaderFunctionAtom.h:80
_OgreRTSSExport
#define _OgreRTSSExport
Definition: OgreShaderPrerequisites.h:108
Ogre::RTShader::FunctionAtom::mInternalExecutionOrder
int mInternalExecutionOrder
Definition: OgreShaderFunctionAtom.h:75
Ogre::RTShader::Operand::getParameter
const ParameterPtr & getParameter() const
Returns the parameter object as weak reference.
Definition: OgreShaderFunctionAtom.h:135
Ogre::RTShader::Operand::getMask
int getMask() const
Returns the mask bitfield.
Definition: OgreShaderFunctionAtom.h:141
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::RTShader::Operand::OPS_OUT
The parameter is a output parameter.
Definition: OgreShaderFunctionAtom.h:90
Ogre::SharedPtr< Parameter >
Ogre::RTShader::Operand::mMask
int mMask
Which part of the parameter should be passed (x,y,z,w)
Definition: OgreShaderFunctionAtom.h:171
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::operator==
bool operator==(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
Definition: OgreMemorySTLAllocator.h:184
Ogre::RTShader::FunctionInvocation::mReturnType
String mReturnType
Definition: OgreShaderFunctionAtom.h:253
Ogre::RTShader::FunctionInvocation::getFunctionAtomType
virtual const String & getFunctionAtomType()
Definition: OgreShaderFunctionAtom.h:203
Ogre::RTShader::Operand::mSemantic
OpSemantic mSemantic
Tells if the parameter is of type input,output or both.
Definition: OgreShaderFunctionAtom.h:169
Ogre::RTShader::Operand::getIndirectionLevel
ushort getIndirectionLevel() const
Returns the level of indirection.
Definition: OgreShaderFunctionAtom.h:151
Ogre::RTShader::FunctionAtomInstanceList
vector< FunctionAtom * >::type FunctionAtomInstanceList
Definition: OgreShaderFunctionAtom.h:257
Ogre::RTShader::Operand::OpSemantic
OpSemantic
Definition: OgreShaderFunctionAtom.h:85
Ogre::ushort
unsigned short ushort
Definition: OgrePrerequisites.h:113
Ogre::RTShader::FunctionInvocation::getOperandList
OperandVector & getOperandList()
Get a list of parameters this function invocation will use in the function call as arguments...
Definition: OgreShaderFunctionAtom.h:206
Ogre::RTShader::FunctionAtomInstanceIterator
FunctionAtomInstanceList::iterator FunctionAtomInstanceIterator
Definition: OgreShaderFunctionAtom.h:258
OgreGpuProgram.h
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::operator<
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)
Definition: OgreSharedPtr.h:326

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