/usr/include/OGRE/RTShaderSystem/OgreShaderFunctionAtom.h is in libogre-1.9-dev 1.9.0+dfsg1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | /*
-----------------------------------------------------------------------------
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 {
/** \addtogroup Core
* @{
*/
/** \addtogroup RTShader
* @{
*/
/** A class that represents an atomic code section of shader based program function.
*/
class _OgreRTSSExport FunctionAtom : public RTShaderSystemAlloc
{
// Interface.
public:
/** Class default constructor. */
FunctionAtom();
/** Class default destructor. */
virtual ~FunctionAtom() {}
/** Get the group execution order of this function atom. */
int getGroupExecutionOrder() const;
/** Get an internal execution order within a group of this function atom. */
int getInternalExecutionOrder() const;
/** Abstract method that writes a source code to the given output stream in the target shader language. */
virtual void writeSourceCode(std::ostream& os, const String& targetLanguage) const = 0;
/** Return the type of this atom instance implementation. */
virtual const String& getFunctionAtomType() = 0;
// Attributes.
protected:
// The owner group execution order.
int mGroupExecutionOrder;
// The execution order within the group.
int mInternalExecutionOrder;
};
/** A class that represents a function operand (its the combination of a parameter the in/out semantic and the used fields)
*/
class _OgreRTSSExport Operand : public RTShaderSystemAlloc
{
public:
// InOut semantic
enum OpSemantic
{
/// The parameter is a input parameter
OPS_IN,
/// The parameter is a output parameter
OPS_OUT,
/// The parameter is a input/output parameter
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
};
/** Class constructor
@param parameter A function parameter.
@param opSemantic The in/out semantic of the parameter.
@param opMask The field mask of the parameter.
*/
Operand(ParameterPtr parameter, Operand::OpSemantic opSemantic, int opMask = Operand::OPM_ALL, ushort indirectionLevel = 0);
/** Copy constructor */
Operand(const Operand& rhs);
/** Copy the given Operand to this Operand.
@param rhs The other Operand to copy to this state.
*/
Operand& operator= (const Operand & rhs);
/** Class destructor */
~Operand();
/** Returns the parameter object as weak reference */
const ParameterPtr& getParameter() const { return mParameter; }
/** Returns true if not all fields used. (usage is described through semantic)*/
bool hasFreeFields() const { return ((mMask & ~OPM_ALL) && ((mMask & ~OPM_X) || (mMask & ~OPM_Y) || (mMask & ~OPM_Z) || (mMask & ~OPM_W))); }
/** Returns the mask bitfield. */
int getMask() const { return mMask; }
/** Returns the operand semantic (do we read/write or both with the parameter). */
OpSemantic getSemantic() const { return mSemantic; }
/** Returns the level of indirection.
The greater the indirection level the more the parameter needs to be nested in brackets.
For example given 4 parameters x1...x4 with the indirections levels 0,1,1,2
respectively. The parameters should form the following string: x1[x2][x3[x4]].
*/
ushort getIndirectionLevel() const { return mIndirectionLevel; }
/** Returns the parameter name and the usage mask like this 'color.xyz' */
String toString() const;
/** Returns the given mask as string representation. */
static String getMaskAsString(int mask);
/** Return the float count of the given mask. */
static int getFloatCount(int mask);
/** Return the gpu constant type of the given mask. */
static GpuConstantType getGpuConstantType(int mask);
protected:
/// The parameter being carried by the operand
ParameterPtr mParameter;
/// Tells if the parameter is of type input,output or both
OpSemantic mSemantic;
/// Which part of the parameter should be passed (x,y,z,w)
int mMask;
/// The level of indirection. @see getIndirectionLevel
ushort mIndirectionLevel;
};
/** A class that represents function invocation code from shader based program function.
*/
class _OgreRTSSExport FunctionInvocation : public FunctionAtom
{
// Interface.
public:
typedef vector<Operand>::type OperandVector;
/** Class constructor
@param functionName The name of the function to invoke.
@param groupOrder The group order of this invocation.
@param internalOrder The internal order of this invocation.
@param returnType The return type of the used function.
*/
FunctionInvocation(const String& functionName, int groupOrder, int internalOrder, String returnType = "void");
/** Copy constructor */
FunctionInvocation(const FunctionInvocation& rhs);
/**
@see FunctionAtom::writeSourceCode
*/
virtual void writeSourceCode(std::ostream& os, const String& targetLanguage) const;
/**
@see FunctionAtom::getFunctionAtomType
*/
virtual const String& getFunctionAtomType() { return Type; }
/** Get a list of parameters this function invocation will use in the function call as arguments. */
OperandVector& getOperandList() { return mOperands; }
/** Push a new operand (on the end) to the function.
@param parameter A function parameter.
@param opSemantic The in/out semantic of the parameter.
@param opMask The field mask of the parameter.
@param indirectionLevel The level of nesting inside brackets
*/
void pushOperand(ParameterPtr parameter, Operand::OpSemantic opSemantic, int opMask = Operand::OPM_ALL, int indirectionLevel = 0);
/** Return the function name */
const String& getFunctionName() const { return mFunctionName; }
/** Return the return type */
const String& getReturnType() const { return mReturnType; }
/** Determines if the current object is equal to the compared one. */
bool operator == ( const FunctionInvocation& rhs ) const;
/** Determines if the current object is not equal to the compared one. */
bool operator != ( const FunctionInvocation& rhs ) const;
/** Determines if the current object is less than the compared one. */
bool operator < ( const FunctionInvocation& rhs ) const;
/** Comparator function to be used for sorting.
Implemented as a struct to make it easier for the compiler to inline
*/
struct FunctionInvocationLessThan
{
bool operator()(FunctionInvocation const& lhs, FunctionInvocation const& rhs) const;
};
/** Comparator function to be used for comparisons.
Implemented as a struct to make it easier for the compiler to inline
*/
struct FunctionInvocationCompare
{
bool operator()(FunctionInvocation const& lhs, FunctionInvocation const& rhs) const;
};
/// The type of this class.
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
|