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-2013 Torus Knot Software Ltd 00008 00009 Permission is hereby granted, free of charge, to any person obtaining a copy 00010 of this software and associated documentation files (the "Software"), to deal 00011 in the Software without restriction, including without limitation the rights 00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 copies of the Software, and to permit persons to whom the Software is 00014 furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in 00017 all copies or substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 THE SOFTWARE. 00026 ----------------------------------------------------------------------------- 00027 */ 00028 #ifndef __GpuProgram_H_ 00029 #define __GpuProgram_H_ 00030 00031 // Precompiler options 00032 #include "OgrePrerequisites.h" 00033 #include "OgreResource.h" 00034 #include "OgreSharedPtr.h" 00035 #include "OgreIteratorWrappers.h" 00036 #include "OgreSerializer.h" 00037 #include "OgreRenderOperation.h" 00038 #include "OgreGpuProgramParams.h" 00039 #include "OgreHeaderPrefix.h" 00040 00041 namespace Ogre { 00042 00050 enum GpuProgramType 00051 { 00052 GPT_VERTEX_PROGRAM, 00053 GPT_FRAGMENT_PROGRAM, 00054 GPT_GEOMETRY_PROGRAM, 00055 GPT_DOMAIN_PROGRAM, 00056 GPT_HULL_PROGRAM, 00057 GPT_COMPUTE_PROGRAM 00058 }; 00059 00069 class _OgreExport GpuProgram : public Resource 00070 { 00071 protected: 00073 class _OgreExport CmdType : public ParamCommand 00074 { 00075 public: 00076 String doGet(const void* target) const; 00077 void doSet(void* target, const String& val); 00078 }; 00079 class _OgreExport CmdSyntax : public ParamCommand 00080 { 00081 public: 00082 String doGet(const void* target) const; 00083 void doSet(void* target, const String& val); 00084 }; 00085 class _OgreExport CmdSkeletal : public ParamCommand 00086 { 00087 public: 00088 String doGet(const void* target) const; 00089 void doSet(void* target, const String& val); 00090 }; 00091 class _OgreExport CmdMorph : public ParamCommand 00092 { 00093 public: 00094 String doGet(const void* target) const; 00095 void doSet(void* target, const String& val); 00096 }; 00097 class _OgreExport CmdPose : public ParamCommand 00098 { 00099 public: 00100 String doGet(const void* target) const; 00101 void doSet(void* target, const String& val); 00102 }; 00103 class _OgreExport CmdVTF : public ParamCommand 00104 { 00105 public: 00106 String doGet(const void* target) const; 00107 void doSet(void* target, const String& val); 00108 }; 00109 class _OgreExport CmdManualNamedConstsFile : public ParamCommand 00110 { 00111 public: 00112 String doGet(const void* target) const; 00113 void doSet(void* target, const String& val); 00114 }; 00115 class _OgreExport CmdAdjacency : public ParamCommand 00116 { 00117 public: 00118 String doGet(const void* target) const; 00119 void doSet(void* target, const String& val); 00120 }; 00121 // Command object for setting / getting parameters 00122 static CmdType msTypeCmd; 00123 static CmdSyntax msSyntaxCmd; 00124 static CmdSkeletal msSkeletalCmd; 00125 static CmdMorph msMorphCmd; 00126 static CmdPose msPoseCmd; 00127 static CmdVTF msVTFCmd; 00128 static CmdManualNamedConstsFile msManNamedConstsFileCmd; 00129 static CmdAdjacency msAdjacencyCmd; 00131 GpuProgramType mType; 00133 String mFilename; 00135 String mSource; 00137 bool mLoadFromFile; 00139 String mSyntaxCode; 00141 bool mSkeletalAnimation; 00143 bool mMorphAnimation; 00145 ushort mPoseAnimation; 00147 bool mVertexTextureFetch; 00149 bool mNeedsAdjacencyInfo; 00151 GpuProgramParametersSharedPtr mDefaultParams; 00153 bool mCompileError; 00158 mutable GpuLogicalBufferStructPtr mFloatLogicalToPhysical; 00163 mutable GpuLogicalBufferStructPtr mDoubleLogicalToPhysical; 00168 mutable GpuLogicalBufferStructPtr mIntLogicalToPhysical; 00173 mutable GpuNamedConstantsPtr mConstantDefs; 00175 String mManualNamedConstantsFile; 00176 bool mLoadedManualNamedConstants; 00177 00178 00187 void setupBaseParamDictionary(void); 00188 00191 bool isRequiredCapabilitiesSupported(void) const; 00192 00194 void loadImpl(void); 00195 00197 void createParameterMappingStructures(bool recreateIfExists = true) const; 00199 void createLogicalParameterMappingStructures(bool recreateIfExists = true) const; 00201 void createNamedParameterMappingStructures(bool recreateIfExists = true) const; 00202 00203 public: 00204 00205 GpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle, 00206 const String& group, bool isManual = false, ManualResourceLoader* loader = 0); 00207 00208 virtual ~GpuProgram() {} 00209 00214 virtual void setSourceFile(const String& filename); 00215 00220 virtual void setSource(const String& source); 00221 00223 virtual const String& getSyntaxCode(void) const { return mSyntaxCode; } 00224 00226 virtual void setSyntaxCode(const String& syntax); 00227 00229 virtual const String& getSourceFile(void) const { return mFilename; } 00231 virtual const String& getSource(void) const { return mSource; } 00233 virtual void setType(GpuProgramType t); 00235 virtual GpuProgramType getType(void) const { return mType; } 00236 00241 virtual GpuProgram* _getBindingDelegate(void) { return this; } 00242 00244 virtual bool isSupported(void) const; 00245 00253 virtual GpuProgramParametersSharedPtr createParameters(void); 00254 00261 virtual void setSkeletalAnimationIncluded(bool included) 00262 { mSkeletalAnimation = included; } 00263 00270 virtual bool isSkeletalAnimationIncluded(void) const { return mSkeletalAnimation; } 00271 00278 virtual void setMorphAnimationIncluded(bool included) 00279 { mMorphAnimation = included; } 00280 00288 virtual void setPoseAnimationIncluded(ushort poseCount) 00289 { mPoseAnimation = poseCount; } 00290 00297 virtual bool isMorphAnimationIncluded(void) const { return mMorphAnimation; } 00298 00305 virtual bool isPoseAnimationIncluded(void) const { return mPoseAnimation > 0; } 00309 virtual ushort getNumberOfPosesIncluded(void) const { return mPoseAnimation; } 00313 virtual void setVertexTextureFetchRequired(bool r) { mVertexTextureFetch = r; } 00317 virtual bool isVertexTextureFetchRequired(void) const { return mVertexTextureFetch; } 00318 00322 virtual void setAdjacencyInfoRequired(bool r) { mNeedsAdjacencyInfo = r; } 00326 virtual bool isAdjacencyInfoRequired(void) const { return mNeedsAdjacencyInfo; } 00327 00338 virtual GpuProgramParametersSharedPtr getDefaultParameters(void); 00339 00342 virtual bool hasDefaultParameters(void) const { return !mDefaultParams.isNull(); } 00343 00350 virtual bool getPassSurfaceAndLightStates(void) const { return false; } 00351 00360 virtual bool getPassFogStates(void) const { return true; } 00361 00368 virtual bool getPassTransformStates(void) const { return false; } 00369 00373 virtual const String& getLanguage(void) const; 00374 00377 virtual bool hasCompileError(void) const { return mCompileError; } 00378 00381 virtual void resetCompileError(void) { mCompileError = false; } 00382 00391 virtual void setManualNamedConstants(const GpuNamedConstants& namedConstants); 00392 00394 virtual const GpuNamedConstants& getNamedConstants() const { return *mConstantDefs.get(); } 00395 00406 virtual void setManualNamedConstantsFile(const String& paramDefFile); 00407 00411 virtual const String& getManualNamedConstantsFile() const { return mManualNamedConstantsFile; } 00418 virtual const GpuNamedConstants& getConstantDefinitions() const { return *mConstantDefs.get(); } 00419 00421 virtual size_t calculateSize(void) const; 00422 00423 protected: 00425 virtual void loadFromSource(void) = 0; 00426 00427 }; 00430 } 00431 00432 #include "OgreHeaderSuffix.h" 00433 00434 #endif
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:43