OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGpuProgram.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-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __GpuProgram_H_
29 #define __GpuProgram_H_
30 
31 // Precompiler options
32 #include "OgrePrerequisites.h"
33 #include "OgreResource.h"
34 #include "OgreGpuProgramParams.h"
35 #include "OgreHeaderPrefix.h"
36 #include "OgreVector3.h"
37 
38 namespace Ogre {
39 
48  {
55  };
56 
67  {
68  protected:
71  {
72  public:
73  String doGet(const void* target) const;
74  void doSet(void* target, const String& val);
75  };
77  {
78  public:
79  String doGet(const void* target) const;
80  void doSet(void* target, const String& val);
81  };
83  {
84  public:
85  String doGet(const void* target) const;
86  void doSet(void* target, const String& val);
87  };
89  {
90  public:
91  String doGet(const void* target) const;
92  void doSet(void* target, const String& val);
93  };
95  {
96  public:
97  String doGet(const void* target) const;
98  void doSet(void* target, const String& val);
99  };
101  {
102  public:
103  String doGet(const void* target) const;
104  void doSet(void* target, const String& val);
105  };
107  {
108  public:
109  String doGet(const void* target) const;
110  void doSet(void* target, const String& val);
111  };
113  {
114  public:
115  String doGet(const void* target) const;
116  void doSet(void* target, const String& val);
117  };
119  {
120  public:
121  String doGet(const void* target) const;
122  void doSet(void* target, const String& val);
123  };
124  // Command object for setting / getting parameters
130  static CmdVTF msVTFCmd;
193 
194 
203  void setupBaseParamDictionary(void);
204 
207  bool isRequiredCapabilitiesSupported(void) const;
208 
210  void loadImpl(void);
211 
213  void createParameterMappingStructures(bool recreateIfExists = true) const;
215  void createLogicalParameterMappingStructures(bool recreateIfExists = true) const;
217  void createNamedParameterMappingStructures(bool recreateIfExists = true) const;
218 
219  public:
220 
221  GpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
222  const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
223 
224  virtual ~GpuProgram() {}
225 
230  virtual void setSourceFile(const String& filename);
231 
236  virtual void setSource(const String& source);
237 
239  virtual const String& getSyntaxCode(void) const { return mSyntaxCode; }
240 
242  virtual void setSyntaxCode(const String& syntax);
243 
245  virtual const String& getSourceFile(void) const { return mFilename; }
247  virtual const String& getSource(void) const { return mSource; }
249  virtual void setType(GpuProgramType t);
251  virtual GpuProgramType getType(void) const { return mType; }
252 
257  virtual GpuProgram* _getBindingDelegate(void) { return this; }
258 
260  virtual bool isSupported(void) const;
261 
269  virtual GpuProgramParametersSharedPtr createParameters(void);
270 
277  virtual void setSkeletalAnimationIncluded(bool included)
278  { mSkeletalAnimation = included; }
279 
286  virtual bool isSkeletalAnimationIncluded(void) const { return mSkeletalAnimation; }
287 
294  virtual void setMorphAnimationIncluded(bool included)
295  { mMorphAnimation = included; }
296 
304  virtual void setPoseAnimationIncluded(ushort poseCount)
305  { mPoseAnimation = poseCount; }
306 
313  virtual bool isMorphAnimationIncluded(void) const { return mMorphAnimation; }
314 
321  virtual bool isPoseAnimationIncluded(void) const { return mPoseAnimation > 0; }
325  virtual ushort getNumberOfPosesIncluded(void) const { return mPoseAnimation; }
329  virtual void setVertexTextureFetchRequired(bool r) { mVertexTextureFetch = r; }
333  virtual bool isVertexTextureFetchRequired(void) const { return mVertexTextureFetch; }
334 
338  virtual void setAdjacencyInfoRequired(bool r) { mNeedsAdjacencyInfo = r; }
342  virtual bool isAdjacencyInfoRequired(void) const { return mNeedsAdjacencyInfo; }
346  virtual void setComputeGroupDimensions(Vector3 dimensions) { mComputeGroupDimensions = dimensions; }
350  virtual Vector3 getComputeGroupDimensions(void) const { return mComputeGroupDimensions; }
351 
362  virtual GpuProgramParametersSharedPtr getDefaultParameters(void);
363 
366  virtual bool hasDefaultParameters(void) const { return !mDefaultParams.isNull(); }
367 
374  virtual bool getPassSurfaceAndLightStates(void) const { return false; }
375 
384  virtual bool getPassFogStates(void) const { return true; }
385 
392  virtual bool getPassTransformStates(void) const { return false; }
393 
397  virtual const String& getLanguage(void) const;
398 
401  virtual bool hasCompileError(void) const { return mCompileError; }
402 
405  virtual void resetCompileError(void) { mCompileError = false; }
406 
415  virtual void setManualNamedConstants(const GpuNamedConstants& namedConstants);
416 
427  virtual void setManualNamedConstantsFile(const String& paramDefFile);
428 
432  virtual const String& getManualNamedConstantsFile() const { return mManualNamedConstantsFile; }
439  virtual const GpuNamedConstants& getConstantDefinitions() const { return *mConstantDefs.get(); }
440 
442  virtual size_t calculateSize(void) const;
443 
444  protected:
446  virtual void loadFromSource(void) = 0;
447 
448  };
451 }
452 
453 #include "OgreHeaderSuffix.h"
454 
455 #endif
GpuLogicalBufferStructPtr mDoubleLogicalToPhysical
Record of logical to physical buffer maps.
virtual void setVertexTextureFetchRequired(bool r)
Sets whether this vertex program requires support for vertex texture fetch from the hardware...
virtual GpuProgramType getType(void) const
Get the program type.
virtual bool hasDefaultParameters(void) const
Returns true if default parameters have been set up.
virtual bool isAdjacencyInfoRequired(void) const
Returns whether this geometry program requires adjacency information from the input primitives...
#define _OgreExport
Definition: OgrePlatform.h:255
virtual bool isVertexTextureFetchRequired(void) const
Returns whether this vertex program requires support for vertex texture fetch from the hardware...
virtual bool getPassFogStates(void) const
Returns whether a fragment program wants fog state to be passed through fixed pipeline low level API ...
Command object - see ParamCommand.
virtual void resetCompileError(void)
Reset a compile error if it occurred, allowing the load to be retried.
virtual bool getPassTransformStates(void) const
Returns whether a vertex program wants transform state to be passed through fixed pipeline low level ...
static CmdAdjacency msAdjacencyCmd
static CmdType msTypeCmd
GpuProgramType
Enumerates the types of programs which can run on the GPU.
GpuLogicalBufferStructPtr mBoolLogicalToPhysical
Record of logical to physical buffer maps.
Defines a program which runs on the GPU such as a vertex or fragment program.
virtual const String & getSourceFile(void) const
Gets the name of the file used as source for this program.
bool mCompileError
Did we encounter a compilation error?
bool mLoadFromFile
Whether we need to load source from file or not.
String mSource
The assembler source of the program (may be blank until file loaded)
Interface describing a manual resource loader.
Definition: OgreResource.h:498
static CmdManualNamedConstsFile msManNamedConstsFileCmd
virtual bool isSkeletalAnimationIncluded(void) const
Returns whether a vertex program includes the required instructions to perform skeletal animation...
virtual bool hasCompileError(void) const
Did this program encounter a compile error when loading?
virtual bool getPassSurfaceAndLightStates(void) const
Returns whether a vertex program wants light and material states to be passed through fixed pipeline ...
bool mMorphAnimation
Does this (vertex) program include morph animation?
GpuLogicalBufferStructPtr mIntLogicalToPhysical
Record of logical to physical buffer maps.
bool mSkeletalAnimation
Does this (vertex) program include skeletal animation?
static CmdPose msPoseCmd
virtual bool isPoseAnimationIncluded(void) const
Returns whether a vertex program includes the required instructions to perform pose animation...
virtual const String & getSource(void) const
Gets the assembler source for this program.
GpuProgramParametersSharedPtr mDefaultParams
The default parameters for use with this object.
virtual void setMorphAnimationIncluded(bool included)
Sets whether a vertex program includes the required instructions to perform morph animation...
GpuProgramType mType
The type of the program.
virtual const GpuNamedConstants & getConstantDefinitions() const
Get the full list of named constants.
virtual Vector3 getComputeGroupDimensions(void) const
Returns the number of process groups dispatched by this compute program.
Vector3 mComputeGroupDimensions
The number of process groups dispatched by this (compute) program.
static CmdVTF msVTFCmd
Struct collecting together the information for named constants.
virtual const String & getSyntaxCode(void) const
Gets the syntax code for this program e.g.
virtual ~GpuProgram()
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
bool mLoadedManualNamedConstants
static CmdSkeletal msSkeletalCmd
unsigned short ushort
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:77
virtual void setComputeGroupDimensions(Vector3 dimensions)
Sets the number of process groups dispatched by this compute program.
bool mVertexTextureFetch
Does this (vertex) program require support for vertex texture fetch?
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
virtual void setSkeletalAnimationIncluded(bool included)
Sets whether a vertex program includes the required instructions to perform skeletal animation...
GpuNamedConstantsPtr mConstantDefs
Parameter name -> ConstantDefinition map, shared instance used by all parameter objects.
String mManualNamedConstantsFile
File from which to load named constants manually.
GpuLogicalBufferStructPtr mFloatLogicalToPhysical
Record of logical to physical buffer maps.
String mFilename
The name of the file to load source from (may be blank)
String mSyntaxCode
Syntax code e.g. arbvp1, vs_2_0 etc.
virtual void setAdjacencyInfoRequired(bool r)
Sets whether this geometry program requires adjacency information from the input primitives.
static CmdSyntax msSyntaxCmd
Defines a generic resource handler.
virtual void setPoseAnimationIncluded(ushort poseCount)
Sets whether a vertex program includes the required instructions to perform pose animation.
virtual bool isMorphAnimationIncluded(void) const
Returns whether a vertex program includes the required instructions to perform morph animation...
static CmdMorph msMorphCmd
static CmdComputeGroupDims msComputeGroupDimsCmd
ushort mPoseAnimation
Does this (vertex) program include pose animation (count of number of poses supported) ...
_StringBase String
Definition: OgreCommon.h:53
virtual GpuProgram * _getBindingDelegate(void)
Returns the GpuProgram which should be bound to the pipeline.
virtual const String & getManualNamedConstantsFile() const
Gets the name of a file from which to load named parameters mapping for a program which would not be ...
virtual ushort getNumberOfPosesIncluded(void) const
Returns the number of simultaneous poses the vertex program can blend, for use in pose animation...
GpuLogicalBufferStructPtr mUIntLogicalToPhysical
Record of logical to physical buffer maps.
Abstract class which is command object which gets/sets parameters.
bool mNeedsAdjacencyInfo
Does this (geometry) program require adjacency information?