# OgreShaderFunctionAtom.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004 (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org
    00006
    00007 Copyright (c) 2000-2009 Torus Knot Software Ltd
    00008 Permission is hereby granted, free of charge, to any person obtaining a copy
    00009 of this software and associated documentation files (the "Software"), to deal
    00010 in the Software without restriction, including without limitation the rights
    00011 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00012 copies of the Software, and to permit persons to whom the Software is
    00013 furnished to do so, subject to the following conditions:
    00014
    00015 The above copyright notice and this permission notice shall be included in
    00016 all copies or substantial portions of the Software.
    00017
    00018 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00019 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00020 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00021 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00022 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00023 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00024 THE SOFTWARE.
    00025 -----------------------------------------------------------------------------
    00026 */
    00027 #ifndef _ShaderFunctionAtom_
    00028 #define _ShaderFunctionAtom_
    00029
    00030 #include "OgreShaderPrerequisites.h"
    00031 #include "OgreGpuProgram.h"
    00032 #include "OgreSingleton.h"
    00033 #include "OgreShaderParameter.h"
    00034 #include "OgreStringVector.h"
    00035
    00036 namespace Ogre {
    00037 namespace RTShader {
    00038
    00048 class _OgreRTSSExport FunctionAtom : public RTShaderSystemAlloc
    00049 {
    00050 // Interface.
    00051 public:
    00053     FunctionAtom            ();
    00054
    00056     virtual ~FunctionAtom   () {}
    00057
    00059     int                     getGroupExecutionOrder      () const;
    00060
    00062     int                     getInternalExecutionOrder   () const;
    00063
    00065     virtual void            writeSourceCode             (std::ostream& os, const String& targetLanguage) const = 0;
    00066
    00068     virtual const String&   getFunctionAtomType         () = 0;
    00069
    00070 // Attributes.
    00071 protected:
    00072     int         mGroupExecutionOrder;       // The owner group execution order.
    00073     int         mInteralExecutionOrder;     // The execution order within the group.
    00074 };
    00075
    00078 class _OgreRTSSExport Operand : public RTShaderSystemAlloc
    00079 {
    00080 public:
    00081
    00082     // InOut semantic
    00083     enum OpSemantic
    00084     {
    00086         OPS_IN,
    00088         OPS_OUT,
    00090         OPS_INOUT
    00091     };
    00092
    00093     // Used field mask
    00094     enum OpMask
    00095     {
    00096         OPM_ALL = 1 << 0,
    00097         OPM_X   = 1 << 1,
    00098         OPM_Y   = 1 << 2,
    00099         OPM_Z   = 1 << 3,
    00100         OPM_W   = 1 << 4
    00101     };
    00102
    00108     Operand(ParameterPtr parameter, Operand::OpSemantic opSemantic, int opMask = Operand::OPM_ALL);
    00109
    00111     Operand(const Operand& rhs);
    00112
    00116     Operand& operator= (const Operand & rhs);
    00117
    00119     ~Operand();
    00120
    00122     const ParameterPtr& getParameter    ()  const { return mParameter; }
    00123
    00125     bool                hasFreeFields   ()  const { return ((mMask & ~OPM_ALL) && ((mMask & ~OPM_X) || (mMask & ~OPM_Y) || (mMask & ~OPM_Z) || (mMask & ~OPM_W))); }
    00126
    00128     int                 getMask         ()  const { return mMask; }
    00129
    00131     OpSemantic          getSemantic     ()  const { return mSemantic; }
    00132
    00134     String              toString        ()  const;
    00135
    00137     static String               getMaskAsString     (int mask);
    00138
    00140     static int                  getFloatCount       (int mask);
    00141
    00143     static GpuConstantType      getGpuConstantType  (int mask);
    00144
    00145 protected:
    00146     ParameterPtr    mParameter;
    00147     OpSemantic      mSemantic;
    00148     int             mMask;
    00149 };
    00150
    00153 class _OgreRTSSExport FunctionInvocation : public FunctionAtom
    00154 {
    00155     // Interface.
    00156 public:
    00157     typedef vector<Operand>::type OperandVector;
    00158
    00165     FunctionInvocation(const String& functionName, int groupOrder, int internalOrder, String returnType = "void");
    00166
    00170     virtual void            writeSourceCode (std::ostream& os, const String& targetLanguage) const;
    00171
    00172
    00176     virtual const String&   getFunctionAtomType         () { return Type; }
    00177
    00179     OperandVector&          getOperandList  () { return mOperands; }
    00180
    00186     void                    pushOperand(ParameterPtr parameter, Operand::OpSemantic opSemantic, int opMask = Operand::OPM_ALL);
    00187
    00189     const String&           getFunctionName () const {return mFunctionName; }
    00190
    00192     const String&           getReturnType   () const {return mReturnType; }
    00193
    00195     static String Type;
    00196
    00197     // Attributes.
    00198 protected:
    00199     String              mFunctionName;
    00200     String              mReturnType;
    00201     OperandVector       mOperands;
    00202 };
    00203
    00204 typedef vector<FunctionAtom*>::type                 FunctionAtomInstanceList;
    00205 typedef FunctionAtomInstanceList::iterator          FunctionAtomInstanceIterator;
    00206 typedef FunctionAtomInstanceList::const_iterator    FunctionAtomInstanceConstIterator;
    00207
    00211 }
    00212 }
    00213
    00214 #endif
    00215

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:52