OgreShaderFunction.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 -----------------------------------------------------------------------------
26 */
27 #ifndef _ShaderProgramFunction_
28 #define _ShaderProgramFunction_
29 
31 #include "OgreShaderParameter.h"
32 #include "OgreShaderFunctionAtom.h"
33 
34 namespace Ogre {
35 namespace RTShader {
36 
47 {
48 // Interface.
49 public:
51  {
52  // internal function (default)
54  // Vertex program main
56  // Pixel shader main
57  FFT_PS_MAIN
58  };
59 
61  const String& getName() const { return mName; }
62 
64  const String& getDescription() const { return mDescription; }
65 
75 
76 
86 
95 
104 
105 
112  static ParameterPtr getParameterByName(const ShaderParameterList& parameterList, const String& name);
113 
121  static ParameterPtr getParameterBySemantic(const ShaderParameterList& parameterList, const Parameter::Semantic semantic, int index);
122 
123 
132 
134  const ShaderParameterList& getInputParameters() const { return mInputParameters; }
135 
137  const ShaderParameterList& getOutputParameters() const { return mOutputParameters; }
138 
140  const ShaderParameterList& getLocalParameters() const { return mLocalParameters; }
141 
145  void addAtomInstance(FunctionAtom* atomInstance);
146 
150  bool deleteAtomInstance(FunctionAtom* atomInstance);
151 
154 
156  FunctionAtomInstanceList& getAtomInstances() { return mAtomInstances; }
157 
159  const FunctionAtomInstanceList& getAtomInstances() const { return mAtomInstances; }
160 
163 
166 
169 
172 
175 
178 
181 
182 
183 protected:
184 
190  Function(const String& name, const String& desc, const FunctionType functionType);
191 
194 
196  void addParameter(ShaderParameterList& parameterList, ParameterPtr parameter);
197 
199  void deleteParameter(ShaderParameterList& parameterList, ParameterPtr parameter);
200 
201 protected:
202  // Function name.
204  // Function description.
206  // Input parameters.
208  // Output parameters.
210  // Local parameters.
212  // Atom instances composing this function.
214  // Function type
216 
217 private:
218  friend class Program;
219 };
220 
222 typedef ShaderFunctionList::iterator ShaderFunctionIterator;
223 typedef ShaderFunctionList::const_iterator ShaderFunctionConstIterator;
224 
228 }
229 }
230 
231 #endif
#define _OgreRTSSExport
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
A class that represents an atomic code section of shader based program function.
A class that represents a shader based program function.
void addParameter(ShaderParameterList &parameterList, ParameterPtr parameter)
Add parameter to given list.
void addInputParameter(ParameterPtr parameter)
Add input parameter to this function.
ShaderParameterList mOutputParameters
Function(const String &name, const String &desc, const FunctionType functionType)
Class constructor.
ShaderParameterList mInputParameters
ParameterPtr resolveLocalParameter(Parameter::Semantic semantic, int index, const String &name, GpuConstantType type)
Resolve local parameter of this function
void sortAtomInstances()
Sort all atom instances of this function.
FunctionAtomInstanceList & getAtomInstances()
Return list of atom instances composing this function.
ParameterPtr resolveLocalParameter(Parameter::Semantic semantic, int index, const Parameter::Content content, GpuConstantType type)
Resolve local parameter of this function
static ParameterPtr getParameterBySemantic(const ShaderParameterList &parameterList, const Parameter::Semantic semantic, int index)
Get parameter by a given semantic and index from the given parameter list.
ParameterPtr getParameterByContent(const ShaderParameterList &parameterList, const Parameter::Content content, GpuConstantType type)
Get parameter by a given content and type from the given parameter list.
const ShaderParameterList & getOutputParameters() const
Return a list of output parameters.
const String & getName() const
Get the name of this function.
FunctionType getFunctionType() const
get function type.
const ShaderParameterList & getLocalParameters() const
Return a list of local parameters.
void deleteInputParameter(ParameterPtr parameter)
Delete input parameter from this function.
void deleteAllOutputParameters()
Delete all output parameters from this function.
void deleteAllInputParameters()
Delete all input parameters from this function.
void deleteOutputParameter(ParameterPtr parameter)
Delete output parameter from this function.
ShaderParameterList mLocalParameters
~Function()
Class destructor.
void deleteParameter(ShaderParameterList &parameterList, ParameterPtr parameter)
Delete parameter from a given list.
bool deleteAtomInstance(FunctionAtom *atomInstance)
Delete a function atom instance from this function.
ParameterPtr resolveOutputParameter(Parameter::Semantic semantic, int index, const Parameter::Content content, GpuConstantType type)
Resolve output parameter of this function.
const ShaderParameterList & getInputParameters() const
Return a list of input parameters.
ParameterPtr resolveInputParameter(Parameter::Semantic semantic, int index, const Parameter::Content content, GpuConstantType type)
Resolve input parameter of this function.
FunctionAtomInstanceList mAtomInstances
static ParameterPtr getParameterByName(const ShaderParameterList &parameterList, const String &name)
Get parameter by a given name from the given parameter list.
const String & getDescription() const
Get the description of this function.
void addAtomInstance(FunctionAtom *atomInstance)
Add a function atom instance to this function.
const FunctionAtomInstanceList & getAtomInstances() const
Return list of atom instances composing this function.
void addOutputParameter(ParameterPtr parameter)
Add output parameter to this function.
A class that represents a shader based program.
GpuConstantType
Enumeration of the types of constant we may encounter in programs.
ShaderFunctionList::const_iterator ShaderFunctionConstIterator
vector< FunctionAtom * >::type FunctionAtomInstanceList
vector< ParameterPtr >::type ShaderParameterList
vector< Function * >::type ShaderFunctionList
ShaderFunctionList::iterator ShaderFunctionIterator
_StringBase String

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