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-2005 The OGRE Team 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 */ 00025 #ifndef __D3D9GpuProgram_H_ 00026 #define __D3D9GpuProgram_H_ 00027 00028 // Precompiler options 00029 #include "OgreD3D9Prerequisites.h" 00030 #include "OgreGpuProgram.h" 00031 00032 namespace Ogre { 00033 00035 class D3D9GpuProgram : public GpuProgram 00036 { 00037 protected: 00038 LPDIRECT3DDEVICE9 mpDevice; 00039 LPD3DXBUFFER mpExternalMicrocode; // microcode from elsewhere, we do NOT delete this ourselves 00040 public: 00041 D3D9GpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle, 00042 const String& group, bool isManual, ManualResourceLoader* loader, LPDIRECT3DDEVICE9 pDev); 00043 00044 00049 void setExternalMicrocode(LPD3DXBUFFER pMicrocode) { mpExternalMicrocode = pMicrocode; } 00051 LPD3DXBUFFER getExternalMicrocode(void) { return mpExternalMicrocode; } 00052 protected: 00054 void loadImpl(void); 00056 void loadFromSource(void); 00058 virtual void loadFromMicrocode(LPD3DXBUFFER microcode) = 0; 00059 00060 00061 }; 00062 00064 class D3D9GpuVertexProgram : public D3D9GpuProgram 00065 { 00066 protected: 00067 LPDIRECT3DVERTEXSHADER9 mpVertexShader; 00068 public: 00069 D3D9GpuVertexProgram(ResourceManager* creator, const String& name, ResourceHandle handle, 00070 const String& group, bool isManual, ManualResourceLoader* loader, LPDIRECT3DDEVICE9 pDev); 00071 ~D3D9GpuVertexProgram(); 00073 LPDIRECT3DVERTEXSHADER9 getVertexShader(void) const { return mpVertexShader; } 00074 protected: 00076 void unloadImpl(void); 00077 void loadFromMicrocode(LPD3DXBUFFER microcode); 00078 }; 00079 00081 class D3D9GpuFragmentProgram : public D3D9GpuProgram 00082 { 00083 protected: 00084 LPDIRECT3DPIXELSHADER9 mpPixelShader; 00085 public: 00086 D3D9GpuFragmentProgram(ResourceManager* creator, const String& name, ResourceHandle handle, 00087 const String& group, bool isManual, ManualResourceLoader* loader, LPDIRECT3DDEVICE9 pDev); 00088 ~D3D9GpuFragmentProgram(); 00090 LPDIRECT3DPIXELSHADER9 getPixelShader(void) const { return mpPixelShader; } 00091 protected: 00093 void unloadImpl(void); 00094 void loadFromMicrocode(LPD3DXBUFFER microcode); 00095 }; 00102 class _OgreExport D3D9GpuProgramPtr : public SharedPtr<D3D9GpuProgram> 00103 { 00104 public: 00105 D3D9GpuProgramPtr() : SharedPtr<D3D9GpuProgram>() {} 00106 explicit D3D9GpuProgramPtr(D3D9GpuProgram* rep) : SharedPtr<D3D9GpuProgram>(rep) {} 00107 D3D9GpuProgramPtr(const D3D9GpuProgramPtr& r) : SharedPtr<D3D9GpuProgram>(r) {} 00108 D3D9GpuProgramPtr(const ResourcePtr& r) : SharedPtr<D3D9GpuProgram>() 00109 { 00110 // lock & copy other mutex pointer 00111 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) 00112 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) 00113 pRep = static_cast<D3D9GpuProgram*>(r.getPointer()); 00114 pUseCount = r.useCountPointer(); 00115 if (pUseCount) 00116 { 00117 ++(*pUseCount); 00118 } 00119 } 00120 00122 D3D9GpuProgramPtr& operator=(const ResourcePtr& r) 00123 { 00124 if (pRep == static_cast<D3D9GpuProgram*>(r.getPointer())) 00125 return *this; 00126 release(); 00127 // lock & copy other mutex pointer 00128 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) 00129 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) 00130 pRep = static_cast<D3D9GpuProgram*>(r.getPointer()); 00131 pUseCount = r.useCountPointer(); 00132 if (pUseCount) 00133 { 00134 ++(*pUseCount); 00135 } 00136 return *this; 00137 } 00138 }; 00139 00140 } 00141 00142 00143 #endif
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:39 2006