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-2006 Torus Knot Software Ltd 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 00024 You may alternatively use this source under the terms of a specific version of 00025 the OGRE Unrestricted License provided you have obtained such a license from 00026 Torus Knot Software Ltd. 00027 ----------------------------------------------------------------------------- 00028 */ 00029 #ifndef __HighLevelGpuProgram_H__ 00030 #define __HighLevelGpuProgram_H__ 00031 00032 #include "OgrePrerequisites.h" 00033 #include "OgreGpuProgram.h" 00034 00035 namespace Ogre { 00036 00058 class _OgreExport HighLevelGpuProgram : public GpuProgram 00059 { 00060 protected: 00062 bool mHighLevelLoaded; 00064 GpuProgramPtr mAssemblerProgram; 00066 mutable bool mConstantDefsBuilt; 00067 00069 virtual void loadHighLevel(void); 00071 virtual void unloadHighLevel(void); 00075 virtual void loadHighLevelImpl(void); 00078 virtual void createLowLevelImpl(void) = 0; 00080 virtual void unloadHighLevelImpl(void) = 0; 00082 virtual void populateParameterNames(GpuProgramParametersSharedPtr params); 00089 virtual void buildConstantDefinitions() const = 0; 00090 00092 void loadImpl(); 00094 void unloadImpl(); 00095 public: 00097 HighLevelGpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle, 00098 const String& group, bool isManual = false, ManualResourceLoader* loader = 0); 00099 ~HighLevelGpuProgram(); 00100 00101 00109 GpuProgramParametersSharedPtr createParameters(void); 00111 GpuProgram* _getBindingDelegate(void) { return mAssemblerProgram.getPointer(); } 00112 00117 const GpuNamedConstants& getConstantDefinitions() const; 00118 00120 const GpuNamedConstants& getNamedConstants() const { return getConstantDefinitions(); } 00121 00122 00123 00124 00125 00126 }; 00127 00134 class _OgreExport HighLevelGpuProgramPtr : public SharedPtr<HighLevelGpuProgram> 00135 { 00136 public: 00137 HighLevelGpuProgramPtr() : SharedPtr<HighLevelGpuProgram>() {} 00138 explicit HighLevelGpuProgramPtr(HighLevelGpuProgram* rep) : SharedPtr<HighLevelGpuProgram>(rep) {} 00139 HighLevelGpuProgramPtr(const HighLevelGpuProgramPtr& r) : SharedPtr<HighLevelGpuProgram>(r) {} 00140 HighLevelGpuProgramPtr(const ResourcePtr& r) : SharedPtr<HighLevelGpuProgram>() 00141 { 00142 // lock & copy other mutex pointer 00143 OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) 00144 { 00145 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) 00146 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) 00147 pRep = static_cast<HighLevelGpuProgram*>(r.getPointer()); 00148 pUseCount = r.useCountPointer(); 00149 if (pUseCount) 00150 { 00151 ++(*pUseCount); 00152 } 00153 } 00154 } 00155 00157 HighLevelGpuProgramPtr& operator=(const ResourcePtr& r) 00158 { 00159 if (pRep == static_cast<HighLevelGpuProgram*>(r.getPointer())) 00160 return *this; 00161 release(); 00162 // lock & copy other mutex pointer 00163 OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) 00164 { 00165 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) 00166 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) 00167 pRep = static_cast<HighLevelGpuProgram*>(r.getPointer()); 00168 pUseCount = r.useCountPointer(); 00169 if (pUseCount) 00170 { 00171 ++(*pUseCount); 00172 } 00173 } 00174 else 00175 { 00176 // RHS must be a null pointer 00177 assert(r.isNull() && "RHS must be null if it has no mutex!"); 00178 setNull(); 00179 } 00180 return *this; 00181 } 00183 HighLevelGpuProgramPtr& operator=(const GpuProgramPtr& r); 00184 }; 00185 00186 } 00187 #endif
Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 27 22:02:23 2009