Browse Source

More DX11 work, and refactor on Hardware buffers

Marko Pintera 13 years ago
parent
commit
1c73bb445a
49 changed files with 849 additions and 736 deletions
  1. 12 0
      CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj
  2. 36 0
      CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj.filters
  3. 1 1
      CamelotD3D11RenderSystem/Include/CmD3D11Device.h
  4. 36 0
      CamelotD3D11RenderSystem/Include/CmD3D11Driver.h
  5. 23 0
      CamelotD3D11RenderSystem/Include/CmD3D11DriverList.h
  6. 3 18
      CamelotD3D11RenderSystem/Include/CmD3D11GpuProgram.h
  7. 19 0
      CamelotD3D11RenderSystem/Include/CmD3D11GpuProgramManager.h
  8. 46 0
      CamelotD3D11RenderSystem/Include/CmD3D11HLSLProgram.h
  9. 68 68
      CamelotD3D11RenderSystem/Include/CmD3D11Mappings.h
  10. 29 0
      CamelotD3D11RenderSystem/Include/CmD3D11VideoMode.h
  11. 24 0
      CamelotD3D11RenderSystem/Include/CmD3D11VideoModeList.h
  12. 110 0
      CamelotD3D11RenderSystem/Source/CmD3D11Driver.cpp
  13. 63 0
      CamelotD3D11RenderSystem/Source/CmD3D11DriverList.cpp
  14. 32 0
      CamelotD3D11RenderSystem/Source/CmD3D11GpuProgramManager.cpp
  15. 80 0
      CamelotD3D11RenderSystem/Source/CmD3D11HLSLProgram.cpp
  16. 43 0
      CamelotD3D11RenderSystem/Source/CmD3D11VideoMode.cpp
  17. 109 0
      CamelotD3D11RenderSystem/Source/CmD3D11VideoModeList.cpp
  18. 0 11
      CamelotD3D9Renderer/Include/CmD3D9HLSLProgram.h
  19. 2 2
      CamelotD3D9Renderer/Include/CmD3D9HardwareBufferManager.h
  20. 1 1
      CamelotD3D9Renderer/Include/CmD3D9HardwareIndexBuffer.h
  21. 1 1
      CamelotD3D9Renderer/Include/CmD3D9HardwareVertexBuffer.h
  22. 0 11
      CamelotD3D9Renderer/Source/CmD3D9HLSLProgram.cpp
  23. 6 43
      CamelotD3D9Renderer/Source/CmD3D9HardwareBufferManager.cpp
  24. 2 2
      CamelotD3D9Renderer/Source/CmD3D9HardwareIndexBuffer.cpp
  25. 1 1
      CamelotD3D9Renderer/Source/CmD3D9HardwarePixelBuffer.cpp
  26. 2 2
      CamelotD3D9Renderer/Source/CmD3D9HardwareVertexBuffer.cpp
  27. 2 2
      CamelotGLRenderer/Include/CmGLDefaultHardwareBufferManager.h
  28. 2 2
      CamelotGLRenderer/Include/CmGLHardwareBufferManager.h
  29. 1 3
      CamelotGLRenderer/Include/CmGLHardwareIndexBuffer.h
  30. 1 3
      CamelotGLRenderer/Include/CmGLHardwareVertexBuffer.h
  31. 5 5
      CamelotGLRenderer/Source/CmGLDefaultHardwareBufferManager.cpp
  32. 4 4
      CamelotGLRenderer/Source/CmGLHardwareBufferManager.cpp
  33. 4 48
      CamelotGLRenderer/Source/CmGLHardwareIndexBuffer.cpp
  34. 1 1
      CamelotGLRenderer/Source/CmGLHardwarePixelBuffer.cpp
  35. 5 49
      CamelotGLRenderer/Source/CmGLHardwareVertexBuffer.cpp
  36. 2 2
      CamelotRenderer/Include/CmDefaultHardwareBufferManager.h
  37. 9 90
      CamelotRenderer/Include/CmHardwareBuffer.h
  38. 6 46
      CamelotRenderer/Include/CmHardwareBufferManager.h
  39. 1 1
      CamelotRenderer/Include/CmHardwareIndexBuffer.h
  40. 1 1
      CamelotRenderer/Include/CmHardwarePixelBuffer.h
  41. 1 7
      CamelotRenderer/Include/CmHardwareVertexBuffer.h
  42. 0 21
      CamelotRenderer/Include/CmVertexIndexData.h
  43. 5 5
      CamelotRenderer/Source/CmDefaultHardwareBufferManager.cpp
  44. 0 42
      CamelotRenderer/Source/CmHardwareBufferManager.cpp
  45. 2 16
      CamelotRenderer/Source/CmHardwareIndexBuffer.cpp
  46. 5 19
      CamelotRenderer/Source/CmHardwarePixelBuffer.cpp
  47. 2 13
      CamelotRenderer/Source/CmHardwareVertexBuffer.cpp
  48. 2 193
      CamelotRenderer/Source/CmVertexIndexData.cpp
  49. 39 2
      CamelotRenderer/TODO.txt

+ 12 - 0
CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj

@@ -147,14 +147,26 @@
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\CmD3D11Device.h" />
     <ClInclude Include="Include\CmD3D11Device.h" />
+    <ClInclude Include="Include\CmD3D11Driver.h" />
+    <ClInclude Include="Include\CmD3D11DriverList.h" />
     <ClInclude Include="Include\CmD3D11GpuProgram.h" />
     <ClInclude Include="Include\CmD3D11GpuProgram.h" />
+    <ClInclude Include="Include\CmD3D11GpuProgramManager.h" />
+    <ClInclude Include="Include\CmD3D11HLSLProgram.h" />
     <ClInclude Include="Include\CmD3D11Mappings.h" />
     <ClInclude Include="Include\CmD3D11Mappings.h" />
     <ClInclude Include="Include\CmD3D11Prerequisites.h" />
     <ClInclude Include="Include\CmD3D11Prerequisites.h" />
+    <ClInclude Include="Include\CmD3D11VideoMode.h" />
+    <ClInclude Include="Include\CmD3D11VideoModeList.h" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CmD3D11Device.cpp" />
     <ClCompile Include="Source\CmD3D11Device.cpp" />
+    <ClCompile Include="Source\CmD3D11Driver.cpp" />
+    <ClCompile Include="Source\CmD3D11DriverList.cpp" />
     <ClCompile Include="Source\CmD3D11GpuProgram.cpp" />
     <ClCompile Include="Source\CmD3D11GpuProgram.cpp" />
+    <ClCompile Include="Source\CmD3D11GpuProgramManager.cpp" />
+    <ClCompile Include="Source\CmD3D11HLSLProgram.cpp" />
     <ClCompile Include="Source\CmD3D11Mappings.cpp" />
     <ClCompile Include="Source\CmD3D11Mappings.cpp" />
+    <ClCompile Include="Source\CmD3D11VideoMode.cpp" />
+    <ClCompile Include="Source\CmD3D11VideoModeList.cpp" />
   </ItemGroup>
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   <ImportGroup Label="ExtensionTargets">

+ 36 - 0
CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj.filters

@@ -27,6 +27,24 @@
     <ClInclude Include="Include\CmD3D11Device.h">
     <ClInclude Include="Include\CmD3D11Device.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\CmD3D11VideoMode.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmD3D11VideoModeList.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmD3D11Driver.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmD3D11DriverList.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmD3D11GpuProgramManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmD3D11HLSLProgram.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CmD3D11GpuProgram.cpp">
     <ClCompile Include="Source\CmD3D11GpuProgram.cpp">
@@ -38,5 +56,23 @@
     <ClCompile Include="Source\CmD3D11Device.cpp">
     <ClCompile Include="Source\CmD3D11Device.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\CmD3D11VideoMode.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmD3D11VideoModeList.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmD3D11Driver.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmD3D11DriverList.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmD3D11GpuProgramManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmD3D11HLSLProgram.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 1 - 1
CamelotD3D11RenderSystem/Include/CmD3D11Device.h

@@ -4,7 +4,7 @@
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
-	class D3D11Device
+	class CM_D3D11_EXPORT D3D11Device
 	{
 	{
 	public:
 	public:
 		D3D11Device(ID3D11Device* device);
 		D3D11Device(ID3D11Device* device);

+ 36 - 0
CamelotD3D11RenderSystem/Include/CmD3D11Driver.h

@@ -0,0 +1,36 @@
+#pragma once
+
+#include "CmD3D11Prerequisites.h"
+
+namespace CamelotEngine
+{
+	class D3D11Driver
+	{
+	public:
+		D3D11Driver(const D3D11Driver &ob);
+		D3D11Driver(UINT32 adapterNumber, IDXGIAdapter* dxgiAdapter);
+		~D3D11Driver();
+
+		D3D11Driver& operator=(const D3D11Driver& r);
+
+		String getDriverName() const;
+		String getDriverDescription() const;
+		UINT32 getAdapterNumber() const { return mAdapterNumber; }
+		UINT32 getNumAdapterOutputs() const;
+		const DXGI_ADAPTER_DESC& getAdapterIdentifier() const { return mAdapterIdentifier; }
+		const DXGI_MODE_DESC& getDesktopMode() const { return mDesktopDisplayMode; }
+		IDXGIAdapter* getDeviceAdapter() { return mDXGIAdapter; }
+		const D3D11VideoModeList* getVideoModeList(UINT32 adapterOutputIdx) const;
+
+	private:
+		// D3D only allows one device per adapter, so it can safely be stored here as well.
+		UINT32					mAdapterNumber;
+		UINT32					mNumOutputs;
+		DXGI_ADAPTER_DESC		mAdapterIdentifier;
+		DXGI_MODE_DESC			mDesktopDisplayMode;
+		D3D11VideoModeList**	mVideoModeList;
+		IDXGIAdapter*			mDXGIAdapter;
+
+		void init()
+	};
+}

+ 23 - 0
CamelotD3D11RenderSystem/Include/CmD3D11DriverList.h

@@ -0,0 +1,23 @@
+#pragma once
+
+#include "CmD3D11Prerequisites.h"
+
+namespace CamelotEngine
+{
+	class CM_D3D11_EXPORT D3D11DriverList
+	{
+	public:
+		D3D11DriverList(IDXGIFactory* dxgiFactory);
+		~D3D11DriverList();
+
+		UINT32 count() const;
+
+		const D3D11Driver& item(UINT32 idx) const;
+		const D3D11Driver& item(const String &name) const;
+
+	private:
+		vector<D3D11Driver*>::type mDriverList;
+
+		void enumerate(IDXGIFactory* dxgiFactory);
+	};
+}

+ 3 - 18
CamelotD3D11RenderSystem/Include/CmD3D11GpuProgram.h

@@ -5,8 +5,7 @@
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
-	/** Direct3D implementation of a few things common to low-level vertex & fragment programs. */
-	class D3D11GpuProgram : public GpuProgram
+	class CM_D3D11_EXPORT D3D11GpuProgram : public GpuProgram
 	{
 	{
 	public:
 	public:
 		D3D11GpuProgram(GpuProgramType type, GpuProgramProfile profile);
 		D3D11GpuProgram(GpuProgramType type, GpuProgramProfile profile);
@@ -26,8 +25,7 @@ namespace CamelotEngine
 		virtual void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode) = 0;
 		virtual void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode) = 0;
 	};
 	};
 
 
-	/** Direct3D implementation of low-level vertex programs. */
-	class D3D11GpuVertexProgram : public D3D11GpuProgram
+	class CM_D3D11_EXPORT D3D11GpuVertexProgram : public D3D11GpuProgram
 	{
 	{
 	protected:
 	protected:
 		ID3D11VertexShader* mVertexShader;
 		ID3D11VertexShader* mVertexShader;
@@ -35,15 +33,13 @@ namespace CamelotEngine
 		D3D11GpuVertexProgram(GpuProgramProfile profile);
 		D3D11GpuVertexProgram(GpuProgramProfile profile);
 		~D3D11GpuVertexProgram();
 		~D3D11GpuVertexProgram();
 
 
-		/// Gets the vertex shader
 		ID3D11VertexShader* getVertexShader(void) const;
 		ID3D11VertexShader* getVertexShader(void) const;
 	protected:
 	protected:
 		void unloadImpl(void);
 		void unloadImpl(void);
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 	};
 	};
 
 
-	/** Direct3D implementation of low-level fragment programs. */
-	class D3D11GpuFragmentProgram : public D3D11GpuProgram
+	class CM_D3D11_EXPORT D3D11GpuFragmentProgram : public D3D11GpuProgram
 	{
 	{
 	protected:
 	protected:
 		ID3D11PixelShader* mPixelShader;
 		ID3D11PixelShader* mPixelShader;
@@ -51,15 +47,12 @@ namespace CamelotEngine
 		D3D11GpuFragmentProgram(GpuProgramProfile profile);
 		D3D11GpuFragmentProgram(GpuProgramProfile profile);
 		~D3D11GpuFragmentProgram();
 		~D3D11GpuFragmentProgram();
 
 
-		/// Gets the pixel shader
 		ID3D11PixelShader* getPixelShader(void) const;
 		ID3D11PixelShader* getPixelShader(void) const;
 	protected:
 	protected:
-		/** @copydoc Resource::unloadImpl */
 		void unloadImpl(void);
 		void unloadImpl(void);
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 	};
 	};
 
 
-	/** Direct3D implementation of low-level vertex programs. */
 	class D3D11GpuDomainProgram : public D3D11GpuProgram
 	class D3D11GpuDomainProgram : public D3D11GpuProgram
 	{
 	{
 	protected:
 	protected:
@@ -68,14 +61,12 @@ namespace CamelotEngine
 		D3D11GpuDomainProgram(GpuProgramProfile profile);
 		D3D11GpuDomainProgram(GpuProgramProfile profile);
 		~D3D11GpuDomainProgram();
 		~D3D11GpuDomainProgram();
 
 
-		/// Gets the vertex shader
 		ID3D11DomainShader* getDomainShader(void) const;
 		ID3D11DomainShader* getDomainShader(void) const;
 	protected:
 	protected:
 		void unloadImpl(void);
 		void unloadImpl(void);
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 	};
 	};
 
 
-	/** Direct3D implementation of low-level vertex programs. */
 	class D3D11GpuHullProgram : public D3D11GpuProgram
 	class D3D11GpuHullProgram : public D3D11GpuProgram
 	{
 	{
 	protected:
 	protected:
@@ -84,17 +75,12 @@ namespace CamelotEngine
 		D3D11GpuHullProgram(GpuProgramProfile profile);
 		D3D11GpuHullProgram(GpuProgramProfile profile);
 		~D3D11GpuHullProgram();
 		~D3D11GpuHullProgram();
 
 
-		/// Gets the vertex shader
 		ID3D11HullShader* getHullShader() const;
 		ID3D11HullShader* getHullShader() const;
 	protected:
 	protected:
 		void unloadImpl(void);
 		void unloadImpl(void);
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 	};
 	};
 
 
-	/** 
-		Direct3D implementation of low-level geometry programs. 
-		Added due to need to accept geometry programs came from other profiles (nvgp4, for example)
-	*/
 	class D3D11GpuGeometryProgram : public D3D11GpuProgram
 	class D3D11GpuGeometryProgram : public D3D11GpuProgram
 	{
 	{
 	protected:
 	protected:
@@ -103,7 +89,6 @@ namespace CamelotEngine
 		D3D11GpuGeometryProgram(GpuProgramProfile profile);
 		D3D11GpuGeometryProgram(GpuProgramProfile profile);
 		~D3D11GpuGeometryProgram();
 		~D3D11GpuGeometryProgram();
 
 
-		/// Gets the geometry shader
 		ID3D11GeometryShader* getGeometryShader(void) const;
 		ID3D11GeometryShader* getGeometryShader(void) const;
 	protected:
 	protected:
 		void unloadImpl(void);
 		void unloadImpl(void);

+ 19 - 0
CamelotD3D11RenderSystem/Include/CmD3D11GpuProgramManager.h

@@ -0,0 +1,19 @@
+#pragma once
+
+#include "CmD3D11Prerequisites.h"
+#include "CmGpuProgramManager.h"
+
+namespace CamelotEngine
+{
+	class D3D11GpuProgramManager : public GpuProgramManager
+	{
+	public:
+		D3D11GpuProgramManager(D3D11Device& device);
+		~D3D11GpuProgramManager();
+
+	protected:
+		D3D11Device& mDevice;
+		
+		GpuProgram* create(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype, GpuProgramProfile profile);
+	};
+}

+ 46 - 0
CamelotD3D11RenderSystem/Include/CmD3D11HLSLProgram.h

@@ -0,0 +1,46 @@
+#pragma once
+
+#include "CmD3D11Prerequisites.h"
+#include "CmHighLevelGpuProgram.h"
+
+namespace CamelotEngine
+{
+	class D3D11HLSLProgram : public HighLevelGpuProgram
+	{
+	public:
+		~D3D11HLSLProgram();
+
+		const String& getLanguage() const;
+		bool isSupported() const;
+
+		/** Sets whether matrix packing in column-major order. */ 
+		void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
+		/** Gets whether matrix packed in column-major order. */
+		bool getColumnMajorMatrices(void) const { return mColumnMajorMatrices; }
+		/** Sets whether backwards compatibility is enabled. */ 
+		void setEnableBackwardsCompatibility(bool enableBackwardsCompatibility) { mEnableBackwardsCompatibility = enableBackwardsCompatibility; }
+		/** Gets whether backwards compatibility is enabled. */
+		bool getEnableBackwardsCompatibility(void) const { return mEnableBackwardsCompatibility; }
+
+	protected:
+		friend class D3D11HLSLProgramFactory;
+
+		D3D11HLSLProgram(const String& source, const String& entryPoint, const String& language, 
+			GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired = false);
+
+        /** Internal load implementation, must be implemented by subclasses.
+        */
+        void loadFromSource(void);
+        /** Internal method for creating an appropriate low-level program from this
+        high-level program, must be implemented by subclasses. */
+        void createLowLevelImpl(void);
+        /// Internal unload implementation, must be implemented by subclasses
+        void unloadHighLevelImpl(void);
+
+		ID3DBlob* compileMicrocode();
+
+	private:
+		bool mColumnMajorMatrices;
+		bool mEnableBackwardsCompatibility;
+	};
+}

+ 68 - 68
CamelotD3D11RenderSystem/Include/CmD3D11Mappings.h

@@ -10,73 +10,73 @@
 
 
 namespace CamelotEngine
 namespace CamelotEngine
 {
 {
-	class D3D11Mappings
-	{
-	public:
-
-		/// enum identifying D3D11 filter usage type
-		enum eD3DFilterUsage
-		{
-			/// min filter
-			D3D_FUSAGE_MIN,
-			/// mag filter
-			D3D_FUSAGE_MAG,
-			/// mip filter
-			D3D_FUSAGE_MIP
-		};
-
-		/// return a D3D11 equivalent for a Ogre TextureAddressingMode value
-		static D3D11_TEXTURE_ADDRESS_MODE get(SamplerState::TextureAddressingMode tam);
-		/// return a D3D11 equivalent for a Ogre SceneBlendFactor value
-		static D3D11_BLEND get(SceneBlendFactor sbf);
-		/// return a D3D11 equivalent for a Ogre SceneBlendOperation value
-		static D3D11_BLEND_OP get(SceneBlendOperation sbo);
-		/// return a D3D11 equivalent for a Ogre CompareFunction value
-		static D3D11_COMPARISON_FUNC get(CompareFunction cf);
-		/// return a D3D11 equivalent for a Ogre CillingMode value
-		static D3D11_CULL_MODE get(CullingMode cm, bool flip = false);
-		/// return a D3D11 equivalent for a Ogre PolygonMode value
-		static D3D11_FILL_MODE get(PolygonMode level);
-		/// return a D3D11 equivalent for a Ogre StencilOperation value
-		static D3D11_STENCIL_OP get(StencilOperation op, bool invert = false);
-		/// return a D3D11 state type for Ogre FilterType value
-		static DWORD get(FilterType ft);
-		static D3D11_FILTER get(const FilterOptions minification, const FilterOptions magnification, const FilterOptions mips, const bool comparison = false);
-		/// return the combination of D3DUSAGE values for Ogre buffer usage
-		static DWORD get(HardwareBuffer::Usage usage);
-		/// Get lock options
-		static D3D11_MAP get(HardwareBuffer::LockOptions options, HardwareBuffer::Usage usage);
-		static UINT getByteWidth(HardwareIndexBuffer::IndexType itype);
-		/// Get vertex data type
-		static DXGI_FORMAT get(VertexElementType vType);
-		/// Get vertex semantic
-		static LPCSTR get(VertexElementSemantic sem);
-		static VertexElementSemantic get(LPCSTR sem);
-		/// Get dx11 color
-		static void get(const Color& inColour, float * outColour );
-
-
-		/// utility method, convert D3D11 pixel format to Ogre pixel format
-		static PixelFormat _getPF(DXGI_FORMAT d3dPF);
-		/// utility method, convert Ogre pixel format to D3D11 pixel format
-		static DXGI_FORMAT _getPF(PixelFormat ogrePF);
-		//
-		static D3D11_USAGE _getUsage(HardwareBuffer::Usage mUsage);
-		static D3D11_USAGE _getUsage(int mUsage);
-		static UINT _getAccessFlags(HardwareBuffer::Usage mUsage);
-		static UINT _getAccessFlags(int mUsage);
-		static bool _isDynamic(HardwareBuffer::Usage mUsage);
-
-		static bool _isDynamic(int mUsage);
-
-		/// utility method, find closest Ogre pixel format that D3D11 can support
-		static PixelFormat _getClosestSupportedPF(PixelFormat ogrePF);
-
-		static TextureType _getTexType(D3D11_SRV_DIMENSION type);
-
-		static size_t _getSizeInBytes(PixelFormat pf, size_t xcount = 1, size_t ycount = 1);
-
-		static UINT _getTextureBindFlags(DXGI_FORMAT format, bool isdynamic);
-		static UINT _getTextureMiscFlags(UINT bindflags, TextureType textype, bool isdynamic);
+	class CM_D3D11_EXPORT D3D11Mappings
+	{
+	public:
+
+		/// enum identifying D3D11 filter usage type
+		enum eD3DFilterUsage
+		{
+			/// min filter
+			D3D_FUSAGE_MIN,
+			/// mag filter
+			D3D_FUSAGE_MAG,
+			/// mip filter
+			D3D_FUSAGE_MIP
+		};
+
+		/// return a D3D11 equivalent for a Ogre TextureAddressingMode value
+		static D3D11_TEXTURE_ADDRESS_MODE get(SamplerState::TextureAddressingMode tam);
+		/// return a D3D11 equivalent for a Ogre SceneBlendFactor value
+		static D3D11_BLEND get(SceneBlendFactor sbf);
+		/// return a D3D11 equivalent for a Ogre SceneBlendOperation value
+		static D3D11_BLEND_OP get(SceneBlendOperation sbo);
+		/// return a D3D11 equivalent for a Ogre CompareFunction value
+		static D3D11_COMPARISON_FUNC get(CompareFunction cf);
+		/// return a D3D11 equivalent for a Ogre CillingMode value
+		static D3D11_CULL_MODE get(CullingMode cm, bool flip = false);
+		/// return a D3D11 equivalent for a Ogre PolygonMode value
+		static D3D11_FILL_MODE get(PolygonMode level);
+		/// return a D3D11 equivalent for a Ogre StencilOperation value
+		static D3D11_STENCIL_OP get(StencilOperation op, bool invert = false);
+		/// return a D3D11 state type for Ogre FilterType value
+		static DWORD get(FilterType ft);
+		static D3D11_FILTER get(const FilterOptions minification, const FilterOptions magnification, const FilterOptions mips, const bool comparison = false);
+		/// return the combination of D3DUSAGE values for Ogre buffer usage
+		static DWORD get(HardwareBuffer::Usage usage);
+		/// Get lock options
+		static D3D11_MAP get(HardwareBuffer::LockOptions options, HardwareBuffer::Usage usage);
+		static UINT getByteWidth(HardwareIndexBuffer::IndexType itype);
+		/// Get vertex data type
+		static DXGI_FORMAT get(VertexElementType vType);
+		/// Get vertex semantic
+		static LPCSTR get(VertexElementSemantic sem);
+		static VertexElementSemantic get(LPCSTR sem);
+		/// Get dx11 color
+		static void get(const Color& inColour, float * outColour );
+
+
+		/// utility method, convert D3D11 pixel format to Ogre pixel format
+		static PixelFormat _getPF(DXGI_FORMAT d3dPF);
+		/// utility method, convert Ogre pixel format to D3D11 pixel format
+		static DXGI_FORMAT _getPF(PixelFormat ogrePF);
+		//
+		static D3D11_USAGE _getUsage(HardwareBuffer::Usage mUsage);
+		static D3D11_USAGE _getUsage(int mUsage);
+		static UINT _getAccessFlags(HardwareBuffer::Usage mUsage);
+		static UINT _getAccessFlags(int mUsage);
+		static bool _isDynamic(HardwareBuffer::Usage mUsage);
+
+		static bool _isDynamic(int mUsage);
+
+		/// utility method, find closest Ogre pixel format that D3D11 can support
+		static PixelFormat _getClosestSupportedPF(PixelFormat ogrePF);
+
+		static TextureType _getTexType(D3D11_SRV_DIMENSION type);
+
+		static size_t _getSizeInBytes(PixelFormat pf, size_t xcount = 1, size_t ycount = 1);
+
+		static UINT _getTextureBindFlags(DXGI_FORMAT format, bool isdynamic);
+		static UINT _getTextureMiscFlags(UINT bindflags, TextureType textype, bool isdynamic);
 	};
 	};
 }
 }

+ 29 - 0
CamelotD3D11RenderSystem/Include/CmD3D11VideoMode.h

@@ -0,0 +1,29 @@
+#pragma once
+
+#include "CmD3D11Prerequisites.h"
+
+namespace CamelotEngine
+{
+	class CM_D3D11_EXPORT D3D11VideoMode
+	{
+	public:
+		D3D11VideoMode();
+		D3D11VideoMode(const D3D11VideoMode& ob);
+		D3D11VideoMode(DXGI_OUTPUT_DESC d3ddm, DXGI_MODE_DESC modeDesc);
+		~D3D11VideoMode();
+
+		UINT32 getWidth() const { return mModeDesc.Width; }
+		UINT32 getHeight() const { return mModeDesc.Height; }
+		DXGI_FORMAT getFormat() const { return mModeDesc.Format; }
+		DXGI_RATIONAL getRefreshRate() const { return mModeDesc.RefreshRate; }
+		UINT32 getColorDepth() const;
+		DXGI_OUTPUT_DESC getDisplayMode() const { return mDisplayMode; }
+		DXGI_MODE_DESC getModeDesc() const { return mModeDesc; }
+		String getDescription() const;
+
+	private:
+		DXGI_OUTPUT_DESC	mDisplayMode;
+		DXGI_MODE_DESC		mModeDesc;
+		UINT32				modeNumber;
+	};
+}

+ 24 - 0
CamelotD3D11RenderSystem/Include/CmD3D11VideoModeList.h

@@ -0,0 +1,24 @@
+#pragma once
+
+#include "CmD3D11Prerequisites.h"
+
+namespace CamelotEngine
+{
+	class CM_D3D11_EXPORT D3D11VideoModeList
+	{
+	public:
+		D3D11VideoModeList(D3D11Driver* driver, UINT32 adapterOutput = 0);
+		~D3D11VideoModeList();
+
+		UINT32 count() const;
+
+		const D3D11VideoMode& item(UINT32 idx) const;
+		const D3D11VideoMode& item(const String &name) const;
+
+	private:
+		D3D11Driver* mDriver;
+		vector<D3D11VideoMode>::type mModeList;
+
+		void enumerate(UINT32 adapterOutput);
+	};
+}

+ 110 - 0
CamelotD3D11RenderSystem/Source/CmD3D11Driver.cpp

@@ -0,0 +1,110 @@
+#include "CmD3D11Driver.h"
+#include "CmD3D11VideoModeList.h"
+
+namespace CamelotEngine
+{
+	D3D11Driver::D3D11Driver( const D3D11Driver &ob ) 
+	{
+		mAdapterNumber = ob.mAdapterNumber;
+		mAdapterIdentifier = ob.mAdapterIdentifier;
+		mDesktopDisplayMode = ob.mDesktopDisplayMode;
+		mVideoModeList = nullptr;
+		mDXGIAdapter = ob.mDXGIAdapter;
+
+		if(mDXGIAdapter)
+			mDXGIAdapter->AddRef();
+
+		init();
+	}
+
+	D3D11Driver::D3D11Driver(unsigned int adapterNumber, IDXGIAdapter* pDXGIAdapter)
+	{
+		mAdapterNumber = adapterNumber;
+		mVideoModeList = nullptr;
+		mDXGIAdapter = pDXGIAdapter;
+
+		if(mDXGIAdapter)
+			mDXGIAdapter->AddRef();
+
+		// get the description of the adapter
+		pDXGIAdapter->GetDesc(&mAdapterIdentifier);
+
+		init();
+	}
+
+	D3D11Driver::~D3D11Driver()
+	{
+		for(UINT32 i = 0; i < mNumOutputs; i++)
+			SAFE_DELETE(mVideoModeList[i]);
+
+		SAFE_DELETE(mVideoModeList);
+		SAFE_RELEASE(mDXGIAdapter);
+	}
+
+	void D3D11Driver::init()
+	{
+		assert(mDXGIAdapter != nullptr);
+
+		UINT32 outputIdx = 0;
+		IDXGIOutput* output;
+		while(mDXGIAdapter->EnumOutputs(outputIdx, &output) != DXGI_ERROR_NOT_FOUND)
+		{
+			outputIdx++;
+		}
+
+		mNumOutputs = outputIdx + 1;
+
+		mVideoModeList = new D3D11VideoModeList*[mNumOutputs];
+		for(UINT32 i = 0; i < mNumOutputs; i++)
+			mVideoModeList[i] = new D3D11VideoModeList(this, i);
+	}
+
+	D3D11Driver& D3D11Driver::operator=(const D3D11Driver& ob)
+	{
+		mAdapterNumber = ob.mAdapterNumber;
+		mAdapterIdentifier = ob.mAdapterIdentifier;
+		mDesktopDisplayMode = ob.mDesktopDisplayMode;
+		mVideoModeList = nullptr;
+
+		if(ob.mDXGIAdapter)
+			ob.mDXGIAdapter->AddRef();
+
+		SAFE_RELEASE(mDXGIAdapter);
+		mDXGIAdapter=ob.mDXGIAdapter;
+
+		return *this;
+	}
+	
+	String D3D11Driver::getDriverName() const
+	{
+		size_t size = wcslen(mAdapterIdentifier.Description);
+		char* str = new char[size + 1];
+
+		wcstombs(str, mAdapterIdentifier.Description, size);
+		str[size] = '\0';
+		String Description = str;
+		delete str;
+		return String(Description );
+	}
+
+	String D3D11Driver::getDriverDescription() const
+	{
+		size_t size = wcslen(mAdapterIdentifier.Description);
+		char* str = new char[size + 1];
+
+		wcstombs(str, mAdapterIdentifier.Description, size);
+		str[size] = '\0';
+		String driverDescription = str;
+		delete [] str;
+		StringUtil::trim(driverDescription);
+
+		return driverDescription;
+	}
+
+	const D3D11VideoModeList* D3D11Driver::getVideoModeList(UINT32 adapterOutputIdx) const
+	{
+		assert(adapterOutputIdx >= 0 && adapterOutputIdx < mNumOutputs);
+
+		return mVideoModeList[adapterOutputIdx];
+	}
+}

+ 63 - 0
CamelotD3D11RenderSystem/Source/CmD3D11DriverList.cpp

@@ -0,0 +1,63 @@
+#include "CmD3D11DriverList.h"
+#include "CmD3D11Driver.h"
+#include "CmException.h"
+
+namespace CamelotEngine
+{
+	D3D11DriverList::D3D11DriverList(IDXGIFactory* dxgiFactory) 
+	{
+		enumerate(dxgiFactory);
+	}
+
+	D3D11DriverList::~D3D11DriverList(void)
+	{
+		for(size_t i = 0; i < mDriverList.size(); i++)
+		{
+			delete (mDriverList[i]);
+		}
+
+		mDriverList.clear();
+	}
+
+	void D3D11DriverList::enumerate(IDXGIFactory* dxgiFactory)
+	{
+		UINT32 adapterIdx = 0;
+		IDXGIAdapter* dxgiAdapter = nullptr;
+		HRESULT hr;
+
+		while((hr = dxgiFactory->EnumAdapters(adapterIdx, &dxgiAdapter)) != DXGI_ERROR_NOT_FOUND)
+		{
+			if( FAILED(hr) )
+			{
+				SAFE_RELEASE(dxgiAdapter);
+				CM_EXCEPT(InternalErrorException, "Enumerating adapters failed.");
+			}
+
+			mDriverList.push_back(new D3D11Driver(adapterIdx, dxgiAdapter));
+
+			SAFE_RELEASE(dxgiAdapter);
+			adapterIdx++;
+		}
+	}
+
+	UINT32 D3D11DriverList::count() const 
+	{
+		return (UINT32)mDriverList.size();
+	}
+
+	const D3D11Driver& D3D11DriverList::item(UINT32 idx) const
+	{
+		return *mDriverList.at(idx);
+	}
+
+	const D3D11Driver& D3D11DriverList::item(const String &name) const
+	{
+		for (auto it = mDriverList.begin(); it != mDriverList.end(); ++it)
+		{
+			if ((*it)->getDriverDescription() == name)
+				return *(*it);
+		}
+
+		CM_EXCEPT(InvalidParametersException, "Cannot find video mode with the specified name.");
+	}
+}

+ 32 - 0
CamelotD3D11RenderSystem/Source/CmD3D11GpuProgramManager.cpp

@@ -0,0 +1,32 @@
+#include "CmD3D11GpuProgramManager.h"
+#include "CmD3D11GpuProgram.h"
+
+namespace CamelotEngine
+{
+	D3D11GpuProgramManager::D3D11GpuProgramManager(D3D11Device& device)
+		:mDevice(device)
+	{ }
+
+	D3D11GpuProgramManager::~D3D11GpuProgramManager()
+	{ }
+
+	GpuProgram* D3D11GpuProgramManager::create(const String& source, const String& entryPoint, 
+		const String& language, GpuProgramType gptype, GpuProgramProfile profile)
+	{
+		switch(gptype)
+		{
+		case GPT_VERTEX_PROGRAM:
+			return new D3D11GpuVertexProgram(profile);
+		case GPT_FRAGMENT_PROGRAM:
+			return new D3D11GpuFragmentProgram(profile);
+		case GPT_HULL_PROGRAM:
+			return new D3D11GpuHullProgram(profile);
+		case GPT_DOMAIN_PROGRAM:
+			return new D3D11GpuDomainProgram(profile);
+		case GPT_GEOMETRY_PROGRAM:
+			return new D3D11GpuGeometryProgram(profile);
+		}
+		
+		return nullptr;
+	}
+}

+ 80 - 0
CamelotD3D11RenderSystem/Source/CmD3D11HLSLProgram.cpp

@@ -0,0 +1,80 @@
+#include "CmD3D11HLSLProgram.h"
+#include "CmRenderSystemManager.h"
+#include "CmRenderSystem.h"
+#include "CmException.h"
+
+namespace CamelotEngine
+{
+	D3D11HLSLProgram::D3D11HLSLProgram(const String& source, const String& entryPoint, const String& language, 
+		GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired)
+		: HighLevelGpuProgram(source, entryPoint, language, gptype, profile, isAdjacencyInfoRequired),
+		mColumnMajorMatrices(true), mEnableBackwardsCompatibility(false)
+	{
+	}
+
+	D3D11HLSLProgram::~D3D11HLSLProgram()
+	{
+		unloadHighLevel();
+	}
+
+	const String& D3D11HLSLProgram::getLanguage() const
+	{
+		static String name = "hlsl";
+
+		return name;
+	}
+
+	bool D3D11HLSLProgram::isSupported() const
+	{
+		RenderSystem* rs = RenderSystemManager::getActive();
+
+		return rs->getCapabilities_internal()->isShaderProfileSupported(getSyntaxCode()) && HighLevelGpuProgram::isSupported();
+	}
+
+	ID3DBlob* D3D11HLSLProgram::compileMicrocode()
+	{
+		// TODO - Preprocessor defines aren't supported
+
+		UINT compileFlags = 0;
+#if defined(CM_DEBUG_MODE)
+		compileFlags |= D3DCOMPILE_DEBUG;
+		compileFlags |= D3DCOMPILE_SKIP_OPTIMIZATION;
+#endif
+
+		if (mColumnMajorMatrices)
+			compileFlags |= D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR;
+		else
+			compileFlags |= D3DCOMPILE_PACK_MATRIX_ROW_MAJOR;
+
+		if (mEnableBackwardsCompatibility)
+			compileFlags |= D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY;
+
+		ID3DBlob* microCode = nullptr;
+		ID3DBlob* errors = nullptr;
+
+		HRESULT hr = D3DCompile(
+			mSource.c_str(),	// [in] Pointer to the shader in memory. 
+			mSource.size(),		// [in] Size of the shader in memory.  
+			nullptr,			// [in] The name of the file that contains the shader code. 
+			nullptr,			// [in] Optional. Pointer to a NULL-terminated array of macro definitions. See D3D_SHADER_MACRO. If not used, set this to NULL. 
+			nullptr,			// [in] Optional. Pointer to an ID3DInclude Interface interface for handling include files. Setting this to NULL will cause a compile error if a shader contains a #include. 
+			mEntryPoint.c_str(),// [in] Name of the shader-entrypoint function where shader execution begins. 
+			mSyntaxCode.c_str(),// [in] A string that specifies the shader model; can be any profile in shader model 4 or higher. 
+			compileFlags,		// [in] Effect compile flags - no D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY at the first try...
+			0,					// [in] Effect compile flags
+			&microCode,			// [out] A pointer to an ID3DBlob Interface which contains the compiled shader, as well as any embedded debug and symbol-table information. 
+			&errors				// [out] A pointer to an ID3DBlob Interface which contains a listing of errors and warnings that occurred during compilation. These errors and warnings are identical to the the debug output from a debugger.
+			);
+
+		if (FAILED(hr))
+		{
+			String message = "Cannot assemble D3D11 high-level shader. Errors:\n" +
+				String(static_cast<const char*>(errors->GetBufferPointer()));
+
+			SAFE_RELEASE(errors);
+			CM_EXCEPT(RenderingAPIException, message);
+		}
+
+		SAFE_RELEASE(errors);
+	}
+}

+ 43 - 0
CamelotD3D11RenderSystem/Source/CmD3D11VideoMode.cpp

@@ -0,0 +1,43 @@
+#include "CmD3D11VideoMode.h"
+
+namespace CamelotEngine
+{
+	D3D11VideoMode::D3D11VideoMode(DXGI_OUTPUT_DESC d3ddm, DXGI_MODE_DESC modeDesc)
+		:mDisplayMode(d3ddm), mModeDesc(modeDesc)
+	{ }
+
+	D3D11VideoMode::D3D11VideoMode(const D3D11VideoMode &ob)
+		:mDisplayMode(ob.mDisplayMode), mModeDesc(ob.mModeDesc)
+	{ }
+
+	D3D11VideoMode::D3D11VideoMode()
+	{
+		ZeroMemory(&mDisplayMode, sizeof(DXGI_OUTPUT_DESC));
+		ZeroMemory(&mModeDesc, sizeof(DXGI_MODE_DESC));
+	}
+
+	D3D11VideoMode::~D3D11VideoMode()
+	{ }
+
+	String D3D11VideoMode::getDescription() const
+	{
+		return toString(mModeDesc.Width) + " x " + toString(mModeDesc.Height) + " @ " + toString(getColorDepth()) + "-bit color";
+	}
+
+	UINT32 D3D11VideoMode::getColorDepth() const
+	{
+		UINT32 colourDepth = 16;
+		if( mModeDesc.Format == DXGI_FORMAT_R32G32B32A32_TYPELESS ||
+			mModeDesc.Format == DXGI_FORMAT_R32G32B32A32_FLOAT ||
+			mModeDesc.Format == DXGI_FORMAT_R32G32B32A32_UINT ||
+			mModeDesc.Format == DXGI_FORMAT_R32G32B32A32_SINT ||
+			mModeDesc.Format == DXGI_FORMAT_R32G32B32_TYPELESS ||
+			mModeDesc.Format == DXGI_FORMAT_R32G32B32_FLOAT ||
+			mModeDesc.Format == DXGI_FORMAT_R32G32B32_UINT ||
+			mModeDesc.Format == DXGI_FORMAT_R32G32B32_SINT 
+			)
+			colourDepth = 32;
+
+		return colourDepth;
+	}
+}

+ 109 - 0
CamelotD3D11RenderSystem/Source/CmD3D11VideoModeList.cpp

@@ -0,0 +1,109 @@
+#include "CmD3D11VideoModeList.h"
+#include "CmException.h"
+#include "CmD3D11VideoMode.h"
+#include "CmD3D11Driver.h"
+
+namespace CamelotEngine
+{
+	D3D11VideoModeList::D3D11VideoModeList(D3D11Driver* driver, UINT32 adapterOutput = 0)
+	{
+		if(driver == nullptr)
+			CM_EXCEPT(InvalidParametersException, "driver parameter is NULL");
+
+		mDriver = driver;
+		enumerate(adapterOutput);
+	}
+
+	D3D11VideoModeList::~D3D11VideoModeList()
+	{
+		mDriver = NULL;
+		mModeList.clear();
+	}
+
+	void D3D11VideoModeList::enumerate(UINT32 adapterOutput)
+	{
+		UINT adapter = mDriver->getAdapterNumber();
+		HRESULT hr;
+
+		IDXGIOutput* output;
+		hr = mDriver->getDeviceAdapter()->EnumOutputs(adapterOutput, &output);
+		if(hr == DXGI_ERROR_NOT_FOUND)
+			CM_EXCEPT(InvalidParametersException, "Adapter output " + toString(adapterOutput) + " not found!");
+
+		if(FAILED(hr))
+			CM_EXCEPT(InternalErrorException, "Error while enumerating adapter output video modes. Output index: " + toString(adapterOutput));
+
+		DXGI_OUTPUT_DESC outputDesc;
+		output->GetDesc(&outputDesc);
+
+		UINT32 numModes = 0;
+
+		hr = output->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, 0, &numModes, 0);
+		if(FAILED(hr))
+		{
+			SAFE_RELEASE(output);
+			CM_EXCEPT(InternalErrorException, "Error while enumerating adapter output video modes. Output index: " + toString(adapterOutput));
+		}
+
+		DXGI_MODE_DESC* modeDesc = new DXGI_MODE_DESC[numModes];
+
+		hr = output->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, 0, &numModes, modeDesc);
+		if(FAILED(hr))
+		{
+			SAFE_RELEASE(output);
+			CM_EXCEPT(InternalErrorException, "Error while enumerating adapter output video modes. Output index: " + toString(adapterOutput));
+		}
+
+		SAFE_RELEASE(output);
+
+		for(UINT32 i = 0; i < numModes; i++)
+		{
+			DXGI_MODE_DESC displayMode = modeDesc[i];
+
+			// Filter out low-resolutions
+			if(displayMode.Width < 640 || displayMode.Height < 400)
+				continue;
+
+			// Check to see if it is already in the list (to filter out refresh rates)
+			bool found = false;
+			for(auto it = mModeList.begin(); it != mModeList.end(); it++)
+			{
+				DXGI_MODE_DESC existingMode = it->getModeDesc();
+				if(	existingMode.Width == displayMode.Width && 
+					existingMode.Height == displayMode.Height &&
+					existingMode.Format == displayMode.Format &&
+					existingMode.RefreshRate.Numerator == displayMode.RefreshRate.Numerator &&
+					existingMode.RefreshRate.Denominator == displayMode.RefreshRate.Denominator
+					)
+				{
+					found = true;
+					break;
+				}
+			}
+
+			if(!found)
+				mModeList.push_back(D3D11VideoMode(outputDesc, displayMode));
+		}
+	}
+
+	UINT32 D3D11VideoModeList::count() const
+	{
+		return (UINT32)mModeList.size();
+	}
+
+	const D3D11VideoMode& D3D11VideoModeList::item(UINT32 idx) const
+	{
+		return mModeList.at(idx);
+	}
+
+	const D3D11VideoMode& D3D11VideoModeList::item(const String &name) const
+	{
+		for (auto iter = mModeList.begin(); iter != mModeList.end(); ++iter)
+		{
+			if (iter->getDescription() == name)
+				return (*iter);
+		}
+
+		CM_EXCEPT(InvalidParametersException, "Cannot find video mode with the specified name.");
+	}
+}

+ 0 - 11
CamelotD3D9Renderer/Include/CmD3D9HLSLProgram.h

@@ -34,11 +34,6 @@ THE SOFTWARE.
 namespace CamelotEngine {
 namespace CamelotEngine {
     /** Specialisation of HighLevelGpuProgram to provide support for D3D9 
     /** Specialisation of HighLevelGpuProgram to provide support for D3D9 
         High-Level Shader Language (HLSL).
         High-Level Shader Language (HLSL).
-    @remarks
-        Note that the syntax of D3D9 HLSL is identical to nVidia's Cg language, therefore
-        unless you know you will only ever be deploying on Direct3D, or you have some specific
-        reason for not wanting to use the Cg plugin, I suggest you use Cg instead since that
-        can produce programs for OpenGL too.
     */
     */
     class CM_D3D9_EXPORT D3D9HLSLProgram : public HighLevelGpuProgram
     class CM_D3D9_EXPORT D3D9HLSLProgram : public HighLevelGpuProgram
     {
     {
@@ -67,12 +62,6 @@ namespace CamelotEngine {
     public:
     public:
         ~D3D9HLSLProgram();
         ~D3D9HLSLProgram();
 
 
-        /** Gets the entry point defined for this program. */
-        const String& getEntryPoint(void) const { return mEntryPoint; }
-        /** Sets the shader target to compile down to, e.g. 'vs_1_1'. */
-        void setTarget(const String& target);
-        /** Gets the shader target to compile down to, e.g. 'vs_1_1'. */
-        const String getTarget(void) const;
         /** Sets the preprocessor defines use to compile the program. */
         /** Sets the preprocessor defines use to compile the program. */
         void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
         void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
         /** Sets the preprocessor defines use to compile the program. */
         /** Sets the preprocessor defines use to compile the program. */

+ 2 - 2
CamelotD3D9Renderer/Include/CmD3D9HardwareBufferManager.h

@@ -47,10 +47,10 @@ namespace CamelotEngine {
         ~D3D9HardwareBufferManagerBase();
         ~D3D9HardwareBufferManagerBase();
         /// Creates a vertex buffer
         /// Creates a vertex buffer
 		HardwareVertexBufferPtr 
 		HardwareVertexBufferPtr 
-            createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer = false);
+            createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage);
 		/// Create a hardware vertex buffer
 		/// Create a hardware vertex buffer
 		HardwareIndexBufferPtr 
 		HardwareIndexBufferPtr 
-            createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, HardwareBuffer::Usage usage, bool useShadowBuffer = false);
+            createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, HardwareBuffer::Usage usage);
     };
     };
 
 
 	/// D3D9HardwareBufferManagerBase as a Singleton
 	/// D3D9HardwareBufferManagerBase as a Singleton

+ 1 - 1
CamelotD3D9Renderer/Include/CmD3D9HardwareIndexBuffer.h

@@ -40,7 +40,7 @@ namespace CamelotEngine {
   
   
     public:
     public:
 		D3D9HardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType, UINT32 numIndexes, 
 		D3D9HardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType, UINT32 numIndexes, 
-			HardwareBuffer::Usage usage, bool useSystemMem, bool useShadowBuffer);
+			HardwareBuffer::Usage usage, bool useSystemMem);
         ~D3D9HardwareIndexBuffer();
         ~D3D9HardwareIndexBuffer();
         /** See HardwareBuffer. */
         /** See HardwareBuffer. */
         void readData(UINT32 offset, UINT32 length, void* pDest);
         void readData(UINT32 offset, UINT32 length, void* pDest);

+ 1 - 1
CamelotD3D9Renderer/Include/CmD3D9HardwareVertexBuffer.h

@@ -40,7 +40,7 @@ namespace CamelotEngine {
 
 
     public:
     public:
 		D3D9HardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, 
 		D3D9HardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, 
-			UINT32 numVertices, HardwareBuffer::Usage usage, bool useSystemMem, bool useShadowBuffer);
+			UINT32 numVertices, HardwareBuffer::Usage usage, bool useSystemMem);
         ~D3D9HardwareVertexBuffer();
         ~D3D9HardwareVertexBuffer();
         /** See HardwareBuffer. */
         /** See HardwareBuffer. */
         void readData(UINT32 offset, UINT32 length, void* pDest);
         void readData(UINT32 offset, UINT32 length, void* pDest);

+ 0 - 11
CamelotD3D9Renderer/Source/CmD3D9HLSLProgram.cpp

@@ -518,11 +518,6 @@ namespace CamelotEngine {
 		return mpMicroCode;
 		return mpMicroCode;
 	}
 	}
 
 
-	const String D3D9HLSLProgram::getTarget(void) const
-	{
-		return GpuProgramManager::instance().gpuProgProfileToRSSpecificProfile(mProfile);
-	}
-
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
 	D3D9HLSLProgram::D3D9HLSLProgram(const String& source, const String& entryPoint, const String& language, 
 	D3D9HLSLProgram::D3D9HLSLProgram(const String& source, const String& entryPoint, const String& language, 
 		GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired)
 		GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired)
@@ -560,12 +555,6 @@ namespace CamelotEngine {
         // Need to transpose matrices if compiled with column-major matrices
         // Need to transpose matrices if compiled with column-major matrices
         params->setTransposeMatrices(mColumnMajorMatrices);
         params->setTransposeMatrices(mColumnMajorMatrices);
     }
     }
-    //-----------------------------------------------------------------------
-    void D3D9HLSLProgram::setTarget(const String& target)
-    {
-        //mTarget = target;
-    }
-
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     const String& D3D9HLSLProgram::getLanguage(void) const
     const String& D3D9HLSLProgram::getLanguage(void) const
     {
     {

+ 6 - 43
CamelotD3D9Renderer/Source/CmD3D9HardwareBufferManager.cpp

@@ -44,31 +44,12 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     HardwareVertexBufferPtr 
     HardwareVertexBufferPtr 
     D3D9HardwareBufferManagerBase::
     D3D9HardwareBufferManagerBase::
-    createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage,
-		bool useShadowBuffer)
+    createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage)
     {
     {
 		assert (numVerts > 0);
 		assert (numVerts > 0);
-#if CM_D3D_MANAGE_BUFFERS
-        // Override shadow buffer setting; managed buffers are automatically
-        // backed by system memory
-        // Don't override shadow buffer if discardable, since then we use
-        // unmanaged buffers for speed (avoids write-through overhead)
-        if (useShadowBuffer && !(usage & HardwareBuffer::HBU_DISCARDABLE))
-        {
-            useShadowBuffer = false;
-            // Also drop any WRITE_ONLY so we can read direct
-            if (usage == HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY)
-            {
-                usage = HardwareBuffer::HBU_DYNAMIC;
-            }
-            else if (usage == HardwareBuffer::HBU_STATIC_WRITE_ONLY)
-            {
-                usage = HardwareBuffer::HBU_STATIC;
-            }
-        }
-#endif
+
 		D3D9HardwareVertexBuffer* vbuf = new D3D9HardwareVertexBuffer(
 		D3D9HardwareVertexBuffer* vbuf = new D3D9HardwareVertexBuffer(
-			this, vertexSize, numVerts, usage, false, useShadowBuffer);
+			this, vertexSize, numVerts, usage, false);
 		{
 		{
 			CM_LOCK_MUTEX(mVertexBuffersMutex)
 			CM_LOCK_MUTEX(mVertexBuffersMutex)
 			mVertexBuffers.insert(vbuf);
 			mVertexBuffers.insert(vbuf);
@@ -78,29 +59,11 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
 	HardwareIndexBufferPtr 
 	HardwareIndexBufferPtr 
     D3D9HardwareBufferManagerBase::
     D3D9HardwareBufferManagerBase::
-    createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
-        HardwareBuffer::Usage usage, bool useShadowBuffer)
+    createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, HardwareBuffer::Usage usage)
     {
     {
 		assert (numIndexes > 0);
 		assert (numIndexes > 0);
-#if CM_D3D_MANAGE_BUFFERS
-        // Override shadow buffer setting; managed buffers are automatically
-        // backed by system memory
-        if (useShadowBuffer)
-        {
-            useShadowBuffer = false;
-            // Also drop any WRITE_ONLY so we can read direct
-            if (usage == HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY)
-            {
-                usage = HardwareBuffer::HBU_DYNAMIC;
-            }
-            else if (usage == HardwareBuffer::HBU_STATIC_WRITE_ONLY)
-            {
-                usage = HardwareBuffer::HBU_STATIC;
-            }
-        }
-#endif
-		D3D9HardwareIndexBuffer* idx = new D3D9HardwareIndexBuffer(
-			this, itype, numIndexes, usage, false, useShadowBuffer);
+
+		D3D9HardwareIndexBuffer* idx = new D3D9HardwareIndexBuffer(this, itype, numIndexes, usage, false);
 		{
 		{
 			CM_LOCK_MUTEX(mIndexBuffersMutex)
 			CM_LOCK_MUTEX(mIndexBuffersMutex)
 			mIndexBuffers.insert(idx);
 			mIndexBuffers.insert(idx);

+ 2 - 2
CamelotD3D9Renderer/Source/CmD3D9HardwareIndexBuffer.cpp

@@ -38,8 +38,8 @@ namespace CamelotEngine {
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
     D3D9HardwareIndexBuffer::D3D9HardwareIndexBuffer(HardwareBufferManagerBase* mgr, HardwareIndexBuffer::IndexType idxType, 
     D3D9HardwareIndexBuffer::D3D9HardwareIndexBuffer(HardwareBufferManagerBase* mgr, HardwareIndexBuffer::IndexType idxType, 
         UINT32 numIndexes, HardwareBuffer::Usage usage,
         UINT32 numIndexes, HardwareBuffer::Usage usage,
-        bool useSystemMemory, bool useShadowBuffer)
-        : HardwareIndexBuffer(mgr, idxType, numIndexes, usage, useSystemMemory, useShadowBuffer)
+        bool useSystemMemory)
+        : HardwareIndexBuffer(mgr, idxType, numIndexes, usage, useSystemMemory)
     {
     {
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
 

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9HardwarePixelBuffer.cpp

@@ -40,7 +40,7 @@ CM_STATIC_MUTEX_INSTANCE(D3D9HardwarePixelBuffer::msDeviceAccessMutex)
 
 
 D3D9HardwarePixelBuffer::D3D9HardwarePixelBuffer(HardwareBuffer::Usage usage, 
 D3D9HardwarePixelBuffer::D3D9HardwarePixelBuffer(HardwareBuffer::Usage usage, 
 												 D3D9Texture* ownerTexture):
 												 D3D9Texture* ownerTexture):
-	HardwarePixelBuffer(0, 0, 0, PF_UNKNOWN, usage, false, false),
+	HardwarePixelBuffer(0, 0, 0, PF_UNKNOWN, usage, false),
 	mDoMipmapGen(0), mHWMipmaps(0), mOwnerTexture(ownerTexture), 
 	mDoMipmapGen(0), mHWMipmaps(0), mOwnerTexture(ownerTexture), 
 	mRenderTexture(NULL)
 	mRenderTexture(NULL)
 {	
 {	

+ 2 - 2
CamelotD3D9Renderer/Source/CmD3D9HardwareVertexBuffer.cpp

@@ -38,8 +38,8 @@ namespace CamelotEngine {
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
     D3D9HardwareVertexBuffer::D3D9HardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, 
     D3D9HardwareVertexBuffer::D3D9HardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, 
         UINT32 numVertices, HardwareBuffer::Usage usage, 
         UINT32 numVertices, HardwareBuffer::Usage usage, 
-        bool useSystemMemory, bool useShadowBuffer)
-        : HardwareVertexBuffer(mgr, vertexSize, numVertices, usage, useSystemMemory, useShadowBuffer)
+        bool useSystemMemory)
+		: HardwareVertexBuffer(mgr, vertexSize, numVertices, usage, useSystemMemory)
     {
     {
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
 

+ 2 - 2
CamelotGLRenderer/Include/CmGLDefaultHardwareBufferManager.h

@@ -106,11 +106,11 @@ namespace CamelotEngine {
         /// Creates a vertex buffer
         /// Creates a vertex buffer
 		HardwareVertexBufferPtr 
 		HardwareVertexBufferPtr 
             createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, 
             createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, 
-				HardwareBuffer::Usage usage, bool useShadowBuffer = false);
+				HardwareBuffer::Usage usage);
 		/// Create a hardware vertex buffer
 		/// Create a hardware vertex buffer
 		HardwareIndexBufferPtr 
 		HardwareIndexBufferPtr 
             createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
             createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
-				HardwareBuffer::Usage usage, bool useShadowBuffer = false);
+				HardwareBuffer::Usage usage);
 
 
     };
     };
 
 

+ 2 - 2
CamelotGLRenderer/Include/CmGLHardwareBufferManager.h

@@ -50,11 +50,11 @@ namespace CamelotEngine {
         ~GLHardwareBufferManagerBase();
         ~GLHardwareBufferManagerBase();
         /// Creates a vertex buffer
         /// Creates a vertex buffer
         HardwareVertexBufferPtr createVertexBuffer(UINT32 vertexSize, 
         HardwareVertexBufferPtr createVertexBuffer(UINT32 vertexSize, 
-            UINT32 numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer = false);
+            UINT32 numVerts, HardwareBuffer::Usage usage);
         /// Create a hardware vertex buffer
         /// Create a hardware vertex buffer
         HardwareIndexBufferPtr createIndexBuffer(
         HardwareIndexBufferPtr createIndexBuffer(
             HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
             HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
-            HardwareBuffer::Usage usage, bool useShadowBuffer = false);
+            HardwareBuffer::Usage usage);
         /// Utility function to get the correct GL usage based on HBU's
         /// Utility function to get the correct GL usage based on HBU's
         static GLenum getGLUsage(unsigned int usage);
         static GLenum getGLUsage(unsigned int usage);
 
 

+ 1 - 3
CamelotGLRenderer/Include/CmGLHardwareIndexBuffer.h

@@ -51,15 +51,13 @@ namespace CamelotEngine {
         void unlockImpl(void);
         void unlockImpl(void);
     public:
     public:
         GLHardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType, UINT32 numIndexes, 
         GLHardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType, UINT32 numIndexes, 
-            HardwareBuffer::Usage usage, bool useShadowBuffer); 
+            HardwareBuffer::Usage usage); 
         ~GLHardwareIndexBuffer();
         ~GLHardwareIndexBuffer();
         /** See HardwareBuffer. */
         /** See HardwareBuffer. */
         void readData(UINT32 offset, UINT32 length, void* pDest);
         void readData(UINT32 offset, UINT32 length, void* pDest);
         /** See HardwareBuffer. */
         /** See HardwareBuffer. */
         void writeData(UINT32 offset, UINT32 length, 
         void writeData(UINT32 offset, UINT32 length, 
             const void* pSource, bool discardWholeBuffer = false);
             const void* pSource, bool discardWholeBuffer = false);
-        /** See HardwareBuffer. */
-        void _updateFromShadow(void);
 
 
         GLuint getGLBufferId(void) const { return mBufferId; }
         GLuint getGLBufferId(void) const { return mBufferId; }
     };
     };

+ 1 - 3
CamelotGLRenderer/Include/CmGLHardwareVertexBuffer.h

@@ -52,15 +52,13 @@ namespace CamelotEngine {
         void unlockImpl(void);
         void unlockImpl(void);
     public:
     public:
         GLHardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, UINT32 numVertices, 
         GLHardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, UINT32 numVertices, 
-            HardwareBuffer::Usage usage, bool useShadowBuffer); 
+            HardwareBuffer::Usage usage); 
         ~GLHardwareVertexBuffer();
         ~GLHardwareVertexBuffer();
         /** See HardwareBuffer. */
         /** See HardwareBuffer. */
         void readData(UINT32 offset, UINT32 length, void* pDest);
         void readData(UINT32 offset, UINT32 length, void* pDest);
         /** See HardwareBuffer. */
         /** See HardwareBuffer. */
         void writeData(UINT32 offset, UINT32 length, 
         void writeData(UINT32 offset, UINT32 length, 
             const void* pSource, bool discardWholeBuffer = false);
             const void* pSource, bool discardWholeBuffer = false);
-        /** See HardwareBuffer. */
-        void _updateFromShadow(void);
 
 
         GLuint getGLBufferId(void) const { return mBufferId; }
         GLuint getGLBufferId(void) const { return mBufferId; }
     };
     };

+ 5 - 5
CamelotGLRenderer/Source/CmGLDefaultHardwareBufferManager.cpp

@@ -32,14 +32,14 @@ namespace CamelotEngine {
 
 
 	GLDefaultHardwareVertexBuffer::GLDefaultHardwareVertexBuffer(UINT32 vertexSize, UINT32 numVertices, 
 	GLDefaultHardwareVertexBuffer::GLDefaultHardwareVertexBuffer(UINT32 vertexSize, UINT32 numVertices, 
 																 HardwareBuffer::Usage usage)
 																 HardwareBuffer::Usage usage)
-	: HardwareVertexBuffer(0, vertexSize, numVertices, usage, true, false) // always software, never shadowed
+	: HardwareVertexBuffer(0, vertexSize, numVertices, usage, true)
 	{
 	{
 		mpData = static_cast<unsigned char*>(_aligned_malloc(mSizeInBytes, CM_SIMD_ALIGNMENT));
 		mpData = static_cast<unsigned char*>(_aligned_malloc(mSizeInBytes, CM_SIMD_ALIGNMENT));
 	}
 	}
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	GLDefaultHardwareVertexBuffer::GLDefaultHardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, UINT32 numVertices, 
 	GLDefaultHardwareVertexBuffer::GLDefaultHardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, UINT32 numVertices, 
 		HardwareBuffer::Usage usage)
 		HardwareBuffer::Usage usage)
-        : HardwareVertexBuffer(mgr, vertexSize, numVertices, usage, true, false) // always software, never shadowed
+		: HardwareVertexBuffer(mgr, vertexSize, numVertices, usage, true)
 	{
 	{
         mpData = static_cast<unsigned char*>(_aligned_malloc(mSizeInBytes, CM_SIMD_ALIGNMENT));
         mpData = static_cast<unsigned char*>(_aligned_malloc(mSizeInBytes, CM_SIMD_ALIGNMENT));
 	}
 	}
@@ -90,7 +90,7 @@ namespace CamelotEngine {
 
 
 	GLDefaultHardwareIndexBuffer::GLDefaultHardwareIndexBuffer(IndexType idxType, 
 	GLDefaultHardwareIndexBuffer::GLDefaultHardwareIndexBuffer(IndexType idxType, 
 		UINT32 numIndexes, HardwareBuffer::Usage usage) 
 		UINT32 numIndexes, HardwareBuffer::Usage usage) 
-		: HardwareIndexBuffer(0, idxType, numIndexes, usage, true, false) // always software, never shadowed
+		: HardwareIndexBuffer(0, idxType, numIndexes, usage, true)
 	{
 	{
 		mpData = new unsigned char[mSizeInBytes];
 		mpData = new unsigned char[mSizeInBytes];
 	}
 	}
@@ -152,7 +152,7 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
 	HardwareVertexBufferPtr 
 	HardwareVertexBufferPtr 
         GLDefaultHardwareBufferManagerBase::createVertexBuffer(UINT32 vertexSize, 
         GLDefaultHardwareBufferManagerBase::createVertexBuffer(UINT32 vertexSize, 
-		UINT32 numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer)
+		UINT32 numVerts, HardwareBuffer::Usage usage)
 	{
 	{
 		return HardwareVertexBufferPtr(
 		return HardwareVertexBufferPtr(
 			new GLDefaultHardwareVertexBuffer(this, vertexSize, numVerts, usage));
 			new GLDefaultHardwareVertexBuffer(this, vertexSize, numVerts, usage));
@@ -160,7 +160,7 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
 	HardwareIndexBufferPtr 
 	HardwareIndexBufferPtr 
         GLDefaultHardwareBufferManagerBase::createIndexBuffer(HardwareIndexBuffer::IndexType itype, 
         GLDefaultHardwareBufferManagerBase::createIndexBuffer(HardwareIndexBuffer::IndexType itype, 
-		UINT32 numIndexes, HardwareBuffer::Usage usage, bool useShadowBuffer)
+		UINT32 numIndexes, HardwareBuffer::Usage usage)
 	{
 	{
 		return HardwareIndexBufferPtr(
 		return HardwareIndexBufferPtr(
 			new GLDefaultHardwareIndexBuffer(itype, numIndexes, usage) );
 			new GLDefaultHardwareIndexBuffer(itype, numIndexes, usage) );

+ 4 - 4
CamelotGLRenderer/Source/CmGLHardwareBufferManager.cpp

@@ -82,10 +82,10 @@ namespace CamelotEngine {
     }
     }
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     HardwareVertexBufferPtr GLHardwareBufferManagerBase::createVertexBuffer(
     HardwareVertexBufferPtr GLHardwareBufferManagerBase::createVertexBuffer(
-        UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer)
+        UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage)
     {
     {
 		GLHardwareVertexBuffer* buf = 
 		GLHardwareVertexBuffer* buf = 
-			new GLHardwareVertexBuffer(this, vertexSize, numVerts, usage, useShadowBuffer);
+			new GLHardwareVertexBuffer(this, vertexSize, numVerts, usage);
 		{
 		{
 			CM_LOCK_MUTEX(mVertexBuffersMutex)
 			CM_LOCK_MUTEX(mVertexBuffersMutex)
 			mVertexBuffers.insert(buf);
 			mVertexBuffers.insert(buf);
@@ -96,10 +96,10 @@ namespace CamelotEngine {
     HardwareIndexBufferPtr 
     HardwareIndexBufferPtr 
     GLHardwareBufferManagerBase::createIndexBuffer(
     GLHardwareBufferManagerBase::createIndexBuffer(
         HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
         HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
-        HardwareBuffer::Usage usage, bool useShadowBuffer)
+        HardwareBuffer::Usage usage)
     {
     {
 		GLHardwareIndexBuffer* buf = 
 		GLHardwareIndexBuffer* buf = 
-			new GLHardwareIndexBuffer(this, itype, numIndexes, usage, useShadowBuffer);
+			new GLHardwareIndexBuffer(this, itype, numIndexes, usage);
 		{
 		{
 			CM_LOCK_MUTEX(mIndexBuffersMutex)
 			CM_LOCK_MUTEX(mIndexBuffersMutex)
 			mIndexBuffers.insert(buf);
 			mIndexBuffers.insert(buf);

+ 4 - 48
CamelotGLRenderer/Source/CmGLHardwareIndexBuffer.cpp

@@ -33,8 +33,8 @@ namespace CamelotEngine {
 
 
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
     GLHardwareIndexBuffer::GLHardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType,
     GLHardwareIndexBuffer::GLHardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType,
-        UINT32 numIndexes, HardwareBuffer::Usage usage, bool useShadowBuffer)
-        : HardwareIndexBuffer(mgr, idxType, numIndexes, usage, false, useShadowBuffer)
+        UINT32 numIndexes, HardwareBuffer::Usage usage)
+        : HardwareIndexBuffer(mgr, idxType, numIndexes, usage, false)
     {
     {
         glGenBuffersARB( 1, &mBufferId );
         glGenBuffersARB( 1, &mBufferId );
 
 
@@ -165,18 +165,8 @@ namespace CamelotEngine {
     void GLHardwareIndexBuffer::readData(UINT32 offset, UINT32 length, 
     void GLHardwareIndexBuffer::readData(UINT32 offset, UINT32 length, 
         void* pDest)
         void* pDest)
     {
     {
-        if(mUseShadowBuffer)
-        {
-            // get data from the shadow buffer
-            void* srcData = mpShadowBuffer->lock(offset, length, HBL_READ_ONLY);
-            memcpy(pDest, srcData, length);
-            mpShadowBuffer->unlock();
-        }
-        else
-        {
-            glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId );
-            glGetBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, pDest);
-        }
+		glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId );
+		glGetBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, pDest);
     }
     }
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
     void GLHardwareIndexBuffer::writeData(UINT32 offset, UINT32 length, 
     void GLHardwareIndexBuffer::writeData(UINT32 offset, UINT32 length, 
@@ -184,15 +174,6 @@ namespace CamelotEngine {
     {
     {
         glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId );
         glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId );
 
 
-        // Update the shadow buffer
-        if(mUseShadowBuffer)
-        {
-            void* destData = mpShadowBuffer->lock(offset, length, 
-                discardWholeBuffer ? HBL_DISCARD : HBL_NORMAL);
-            memcpy(destData, pSource, length);
-            mpShadowBuffer->unlock();
-        }
-
         if (offset == 0 && length == mSizeInBytes)
         if (offset == 0 && length == mSizeInBytes)
         {
         {
             glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mSizeInBytes, pSource,
             glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mSizeInBytes, pSource,
@@ -210,29 +191,4 @@ namespace CamelotEngine {
             glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, pSource);
             glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, pSource);
         }
         }
     }
     }
-	//---------------------------------------------------------------------
-    void GLHardwareIndexBuffer::_updateFromShadow(void)
-    {
-        if (mUseShadowBuffer && mShadowUpdated && !mSuppressHardwareUpdate)
-        {
-            const void *srcData = mpShadowBuffer->lock(
-                mLockStart, mLockSize, HBL_READ_ONLY);
-
-            glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId);
-
-            // Update whole buffer if possible, otherwise normal
-            if (mLockStart == 0 && mLockSize == mSizeInBytes)
-            {
-                glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mSizeInBytes, srcData,
-                    GLHardwareBufferManager::getGLUsage(mUsage));
-            }
-            else
-            {
-                glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mLockStart, mLockSize, srcData);
-            }
-
-            mpShadowBuffer->unlock();
-            mShadowUpdated = false;
-        }
-    }
 }
 }

+ 1 - 1
CamelotGLRenderer/Source/CmGLHardwarePixelBuffer.cpp

@@ -39,7 +39,7 @@ namespace CamelotEngine {
 GLHardwarePixelBuffer::GLHardwarePixelBuffer(UINT32 inWidth, UINT32 inHeight, UINT32 inDepth,
 GLHardwarePixelBuffer::GLHardwarePixelBuffer(UINT32 inWidth, UINT32 inHeight, UINT32 inDepth,
                 PixelFormat inFormat,
                 PixelFormat inFormat,
                 HardwareBuffer::Usage usage):
                 HardwareBuffer::Usage usage):
-      HardwarePixelBuffer(inWidth, inHeight, inDepth, inFormat, usage, false, false),
+      HardwarePixelBuffer(inWidth, inHeight, inDepth, inFormat, usage, false),
       mBuffer(inWidth, inHeight, inDepth, inFormat),
       mBuffer(inWidth, inHeight, inDepth, inFormat),
       mGLInternalFormat(GL_NONE)
       mGLInternalFormat(GL_NONE)
 {
 {

+ 5 - 49
CamelotGLRenderer/Source/CmGLHardwareVertexBuffer.cpp

@@ -33,8 +33,8 @@ namespace CamelotEngine {
 
 
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
     GLHardwareVertexBuffer::GLHardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, 
     GLHardwareVertexBuffer::GLHardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, 
-        UINT32 numVertices, HardwareBuffer::Usage usage, bool useShadowBuffer)
-        : HardwareVertexBuffer(mgr, vertexSize, numVertices, usage, false, useShadowBuffer)
+        UINT32 numVertices, HardwareBuffer::Usage usage)
+        : HardwareVertexBuffer(mgr, vertexSize, numVertices, usage, false)
     {
     {
         glGenBuffersARB( 1, &mBufferId );
         glGenBuffersARB( 1, &mBufferId );
 
 
@@ -166,20 +166,10 @@ namespace CamelotEngine {
     void GLHardwareVertexBuffer::readData(UINT32 offset, UINT32 length, 
     void GLHardwareVertexBuffer::readData(UINT32 offset, UINT32 length, 
         void* pDest)
         void* pDest)
     {
     {
-        if(mUseShadowBuffer)
-        {
-            // get data from the shadow buffer
-            void* srcData = mpShadowBuffer->lock(offset, length, HBL_READ_ONLY);
-            memcpy(pDest, srcData, length);
-            mpShadowBuffer->unlock();
-        }
-        else
-        {
-            // get data from the real buffer
-            glBindBufferARB(GL_ARRAY_BUFFER_ARB, mBufferId);
+        // get data from the real buffer
+        glBindBufferARB(GL_ARRAY_BUFFER_ARB, mBufferId);
         
         
-            glGetBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, length, pDest);
-        }
+        glGetBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, length, pDest);
     }
     }
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
     void GLHardwareVertexBuffer::writeData(UINT32 offset, UINT32 length, 
     void GLHardwareVertexBuffer::writeData(UINT32 offset, UINT32 length, 
@@ -187,15 +177,6 @@ namespace CamelotEngine {
     {
     {
         glBindBufferARB(GL_ARRAY_BUFFER_ARB, mBufferId);
         glBindBufferARB(GL_ARRAY_BUFFER_ARB, mBufferId);
 
 
-        // Update the shadow buffer
-        if(mUseShadowBuffer)
-        {
-            void* destData = mpShadowBuffer->lock(offset, length, 
-                discardWholeBuffer ? HBL_DISCARD : HBL_NORMAL);
-            memcpy(destData, pSource, length);
-            mpShadowBuffer->unlock();
-        }
-
         if (offset == 0 && length == mSizeInBytes)
         if (offset == 0 && length == mSizeInBytes)
         {
         {
             glBufferDataARB(GL_ARRAY_BUFFER_ARB, mSizeInBytes, pSource, 
             glBufferDataARB(GL_ARRAY_BUFFER_ARB, mSizeInBytes, pSource, 
@@ -213,29 +194,4 @@ namespace CamelotEngine {
             glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, length, pSource); 
             glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, length, pSource); 
         }
         }
     }
     }
-	//---------------------------------------------------------------------
-    void GLHardwareVertexBuffer::_updateFromShadow(void)
-    {
-        if (mUseShadowBuffer && mShadowUpdated && !mSuppressHardwareUpdate)
-        {
-            const void *srcData = mpShadowBuffer->lock(
-                mLockStart, mLockSize, HBL_READ_ONLY);
-
-            glBindBufferARB(GL_ARRAY_BUFFER_ARB, mBufferId);
-
-            // Update whole buffer if possible, otherwise normal
-            if (mLockStart == 0 && mLockSize == mSizeInBytes)
-            {
-                glBufferDataARB(GL_ARRAY_BUFFER_ARB, mSizeInBytes, srcData,
-                    GLHardwareBufferManager::getGLUsage(mUsage));
-            }
-            else
-            {
-                glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, mLockStart, mLockSize, srcData);
-            }
-
-            mpShadowBuffer->unlock();
-            mShadowUpdated = false;
-        }
-    }
 }
 }

+ 2 - 2
CamelotRenderer/Include/CmDefaultHardwareBufferManager.h

@@ -108,11 +108,11 @@ namespace CamelotEngine {
         /// Creates a vertex buffer
         /// Creates a vertex buffer
 		HardwareVertexBufferPtr 
 		HardwareVertexBufferPtr 
             createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, 
             createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, 
-				HardwareBuffer::Usage usage, bool useShadowBuffer = false);
+				HardwareBuffer::Usage usage);
 		/// Create a hardware vertex buffer
 		/// Create a hardware vertex buffer
 		HardwareIndexBufferPtr 
 		HardwareIndexBufferPtr 
             createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
             createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
-				HardwareBuffer::Usage usage, bool useShadowBuffer = false);
+				HardwareBuffer::Usage usage);
     };
     };
 
 
 	/// DefaultHardwareBufferManager as a Singleton
 	/// DefaultHardwareBufferManager as a Singleton

+ 9 - 90
CamelotRenderer/Include/CmHardwareBuffer.h

@@ -143,10 +143,6 @@ namespace CamelotEngine {
 			UINT32 mLockStart;
 			UINT32 mLockStart;
 			UINT32 mLockSize;
 			UINT32 mLockSize;
 			bool mSystemMemory;
 			bool mSystemMemory;
-            bool mUseShadowBuffer;
-            HardwareBuffer* mpShadowBuffer;
-            bool mShadowUpdated;
-            bool mSuppressHardwareUpdate;
     		
     		
             /// Internal implementation of lock()
             /// Internal implementation of lock()
 		    virtual void* lockImpl(UINT32 offset, UINT32 length, LockOptions options) = 0;
 		    virtual void* lockImpl(UINT32 offset, UINT32 length, LockOptions options) = 0;
@@ -155,21 +151,9 @@ namespace CamelotEngine {
 
 
     public:
     public:
 		    /// Constructor, to be called by HardwareBufferManager only
 		    /// Constructor, to be called by HardwareBufferManager only
-            HardwareBuffer(Usage usage, bool systemMemory, bool useShadowBuffer) 
-				: mUsage(usage), mIsLocked(false), mSystemMemory(systemMemory), 
-                mUseShadowBuffer(useShadowBuffer), mpShadowBuffer(NULL), mShadowUpdated(false), 
-                mSuppressHardwareUpdate(false) 
-            {
-                // If use shadow buffer, upgrade to WRITE_ONLY on hardware side
-                if (useShadowBuffer && usage == HBU_DYNAMIC)
-                {
-                    mUsage = HBU_DYNAMIC_WRITE_ONLY;
-                }
-                else if (useShadowBuffer && usage == HBU_STATIC)
-                {
-                    mUsage = HBU_STATIC_WRITE_ONLY;
-                }
-            }
+            HardwareBuffer(Usage usage, bool systemMemory) 
+				: mUsage(usage), mIsLocked(false), mSystemMemory(systemMemory)
+            {  }
             virtual ~HardwareBuffer() {}
             virtual ~HardwareBuffer() {}
 		    /** Lock the buffer for (potentially) reading / writing.
 		    /** Lock the buffer for (potentially) reading / writing.
 		    @param offset The byte offset from the start of the buffer to lock
 		    @param offset The byte offset from the start of the buffer to lock
@@ -180,24 +164,9 @@ namespace CamelotEngine {
 		    virtual void* lock(UINT32 offset, UINT32 length, LockOptions options)
 		    virtual void* lock(UINT32 offset, UINT32 length, LockOptions options)
             {
             {
                 assert(!isLocked() && "Cannot lock this buffer, it is already locked!");
                 assert(!isLocked() && "Cannot lock this buffer, it is already locked!");
-                void* ret;
-				if (mUseShadowBuffer)
-                {
-					if (options != HBL_READ_ONLY)
-					{
-						// we have to assume a read / write lock so we use the shadow buffer
-						// and tag for sync on unlock()
-                        mShadowUpdated = true;
-                    }
+                void* ret = lockImpl(offset, length, options);
+                mIsLocked = true;
 
 
-                    ret = mpShadowBuffer->lock(offset, length, options);
-                }
-                else
-                {
-					// Lock the real buffer if there is no shadow buffer 
-                    ret = lockImpl(offset, length, options);
-                    mIsLocked = true;
-                }
 				mLockStart = offset;
 				mLockStart = offset;
 				mLockSize = length;
 				mLockSize = length;
                 return ret;
                 return ret;
@@ -227,20 +196,8 @@ namespace CamelotEngine {
             {
             {
                 assert(isLocked() && "Cannot unlock this buffer, it is not locked!");
                 assert(isLocked() && "Cannot unlock this buffer, it is not locked!");
 
 
-				// If we used the shadow buffer this time...
-                if (mUseShadowBuffer && mpShadowBuffer->isLocked())
-                {
-                    mpShadowBuffer->unlock();
-                    // Potentially update the 'real' buffer from the shadow buffer
-                    _updateFromShadow();
-                }
-                else
-                {
-					// Otherwise, unlock the real one
-                    unlockImpl();
-                    mIsLocked = false;
-                }
-
+                unlockImpl();
+                mIsLocked = false;
             }
             }
 
 
             /** Reads data from the buffer and places it in the memory pointed to by pDest.
             /** Reads data from the buffer and places it in the memory pointed to by pDest.
@@ -291,54 +248,16 @@ namespace CamelotEngine {
 				copyData(srcBuffer, 0, 0, sz, true);
 				copyData(srcBuffer, 0, 0, sz, true);
 			}
 			}
 			
 			
-			/// Updates the real buffer from the shadow buffer, if required
-            virtual void _updateFromShadow(void)
-            {
-                if (mUseShadowBuffer && mShadowUpdated && !mSuppressHardwareUpdate)
-                {
-                    // Do this manually to avoid locking problems
-                    const void *srcData = mpShadowBuffer->lockImpl(
-    					mLockStart, mLockSize, HBL_READ_ONLY);
-					// Lock with discard if the whole buffer was locked, otherwise normal
-					LockOptions lockOpt;
-					if (mLockStart == 0 && mLockSize == mSizeInBytes)
-						lockOpt = HBL_DISCARD;
-					else
-						lockOpt = HBL_NORMAL;
-					
-                    void *destData = this->lockImpl(
-    					mLockStart, mLockSize, lockOpt);
-					// Copy shadow to real
-                    memcpy(destData, srcData, mLockSize);
-                    this->unlockImpl();
-                    mpShadowBuffer->unlockImpl();
-                    mShadowUpdated = false;
-                }
-            }
-
             /// Returns the size of this buffer in bytes
             /// Returns the size of this buffer in bytes
             UINT32 getSizeInBytes(void) const { return mSizeInBytes; }
             UINT32 getSizeInBytes(void) const { return mSizeInBytes; }
             /// Returns the Usage flags with which this buffer was created
             /// Returns the Usage flags with which this buffer was created
             Usage getUsage(void) const { return mUsage; }
             Usage getUsage(void) const { return mUsage; }
 			/// Returns whether this buffer is held in system memory
 			/// Returns whether this buffer is held in system memory
 			bool isSystemMemory(void) const { return mSystemMemory; }
 			bool isSystemMemory(void) const { return mSystemMemory; }
-			/// Returns whether this buffer has a system memory shadow for quicker reading
-			bool hasShadowBuffer(void) const { return mUseShadowBuffer; }
             /// Returns whether or not this buffer is currently locked.
             /// Returns whether or not this buffer is currently locked.
             bool isLocked(void) const { 
             bool isLocked(void) const { 
-                return mIsLocked || (mUseShadowBuffer && mpShadowBuffer->isLocked()); 
-            }
-            /// Pass true to suppress hardware upload of shadow buffer changes
-            void suppressHardwareUpdate(bool suppress) {
-                mSuppressHardwareUpdate = suppress;
-                if (!suppress)
-                    _updateFromShadow();
-            }
-
-
-
-
-    		
+                return mIsLocked; 
+            }	
     };
     };
 	/** @} */
 	/** @} */
 	/** @} */
 	/** @} */

+ 6 - 46
CamelotRenderer/Include/CmHardwareBufferManager.h

@@ -67,7 +67,6 @@ namespace CamelotEngine {
         VertexBufferList mVertexBuffers;
         VertexBufferList mVertexBuffers;
         IndexBufferList mIndexBuffers;
         IndexBufferList mIndexBuffers;
 
 
-
 		typedef set<VertexBufferBinding*>::type VertexBufferBindingList;
 		typedef set<VertexBufferBinding*>::type VertexBufferBindingList;
 		VertexBufferBindingList mVertexBufferBindings;
 		VertexBufferBindingList mVertexBufferBindings;
 
 
@@ -87,13 +86,6 @@ namespace CamelotEngine {
 		/// Internal method for destroys a VertexBufferBinding, may be overridden by certain rendering APIs
 		/// Internal method for destroys a VertexBufferBinding, may be overridden by certain rendering APIs
 		virtual void destroyVertexBufferBindingImpl(VertexBufferBinding* binding);
 		virtual void destroyVertexBufferBindingImpl(VertexBufferBinding* binding);
 
 
-    protected:
-
-        /// Creates  a new buffer as a copy of the source, does not copy data
-        virtual HardwareVertexBufferPtr makeBufferCopy(
-            const HardwareVertexBufferPtr& source, 
-            HardwareBuffer::Usage usage, bool useShadowBuffer);
-
     public:
     public:
         HardwareBufferManagerBase();
         HardwareBufferManagerBase();
         virtual ~HardwareBufferManagerBase();
         virtual ~HardwareBufferManagerBase();
@@ -126,8 +118,7 @@ namespace CamelotEngine {
             be synchronised with the real buffer at an appropriate time.
             be synchronised with the real buffer at an appropriate time.
         */
         */
 		virtual HardwareVertexBufferPtr 
 		virtual HardwareVertexBufferPtr 
-            createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage, 
-			bool useShadowBuffer = false) = 0;
+            createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage) = 0;
 		/** Create a hardware index buffer.
 		/** Create a hardware index buffer.
         @remarks Note that because buffers can be shared, they are reference
         @remarks Note that because buffers can be shared, they are reference
             counted so you do not need to worry about destroying them this will be done
             counted so you do not need to worry about destroying them this will be done
@@ -146,7 +137,7 @@ namespace CamelotEngine {
         */
         */
 		virtual HardwareIndexBufferPtr 
 		virtual HardwareIndexBufferPtr 
             createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
             createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
-			HardwareBuffer::Usage usage, bool useShadowBuffer = false) = 0;
+			HardwareBuffer::Usage usage) = 0;
 
 
         /** Creates a new vertex declaration. */
         /** Creates a new vertex declaration. */
         virtual VertexDeclarationPtr createVertexDeclaration(void);
         virtual VertexDeclarationPtr createVertexDeclaration(void);
@@ -156,26 +147,6 @@ namespace CamelotEngine {
 		/** Destroys a VertexBufferBinding. */
 		/** Destroys a VertexBufferBinding. */
 		virtual void destroyVertexBufferBinding(VertexBufferBinding* binding);
 		virtual void destroyVertexBufferBinding(VertexBufferBinding* binding);
 
 
-        /** Allocates a copy of a given vertex buffer.
-        @remarks
-            This method allocates a temporary copy of an existing vertex buffer.
-            This buffer is subsequently stored and can be made available for 
-            other purposes later without incurring the cost of construction / 
-            destruction.
-        @param sourceBuffer The source buffer to use as a copy
-        @param licenseType The type of license required on this buffer - automatic
-            release causes this class to release licenses every frame so that 
-            they can be reallocated anew.
-        @param licensee Pointer back to the class requesting the copy, which must
-            implement HardwareBufferLicense in order to be notified when the license
-            expires.
-        @param copyData If true, the current data is copied as well as the 
-            structure of the buffer
-        */
-        virtual HardwareVertexBufferPtr allocateVertexBufferCopy(
-            const HardwareVertexBufferPtr& sourceBuffer,
-            bool copyData = false);
-
 		/// Notification that a hardware vertex buffer has been destroyed
 		/// Notification that a hardware vertex buffer has been destroyed
 		void _notifyVertexBufferDestroyed(HardwareVertexBuffer* buf);
 		void _notifyVertexBufferDestroyed(HardwareVertexBuffer* buf);
 		/// Notification that a hardware index buffer has been destroyed
 		/// Notification that a hardware index buffer has been destroyed
@@ -193,18 +164,14 @@ namespace CamelotEngine {
 		~HardwareBufferManager();
 		~HardwareBufferManager();
 
 
 		/** @copydoc HardwareBufferManagerInterface::createVertexBuffer */
 		/** @copydoc HardwareBufferManagerInterface::createVertexBuffer */
-		HardwareVertexBufferPtr 
-            createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage, 
-			bool useShadowBuffer = false)
+		HardwareVertexBufferPtr createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage)
 		{
 		{
-			return mImpl->createVertexBuffer(vertexSize, numVerts, usage, useShadowBuffer);
+			return mImpl->createVertexBuffer(vertexSize, numVerts, usage);
 		}
 		}
 		/** @copydoc HardwareBufferManagerInterface::createIndexBuffer */
 		/** @copydoc HardwareBufferManagerInterface::createIndexBuffer */
-		HardwareIndexBufferPtr 
-            createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
-			HardwareBuffer::Usage usage, bool useShadowBuffer = false)
+		HardwareIndexBufferPtr createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, HardwareBuffer::Usage usage)
 		{
 		{
-			return mImpl->createIndexBuffer(itype, numIndexes, usage, useShadowBuffer);
+			return mImpl->createIndexBuffer(itype, numIndexes, usage);
 		}
 		}
 
 
 		/** @copydoc HardwareBufferManagerInterface::createVertexDeclaration */
 		/** @copydoc HardwareBufferManagerInterface::createVertexDeclaration */
@@ -223,13 +190,6 @@ namespace CamelotEngine {
 		{
 		{
 			mImpl->destroyVertexBufferBinding(binding);
 			mImpl->destroyVertexBufferBinding(binding);
 		}
 		}
-		/** @copydoc HardwareBufferManagerInterface::allocateVertexBufferCopy */
-        virtual HardwareVertexBufferPtr allocateVertexBufferCopy(
-            const HardwareVertexBufferPtr& sourceBuffer,
-            bool copyData = false)
-		{
-			return mImpl->allocateVertexBufferCopy(sourceBuffer, copyData);
-		}
 		/** @copydoc HardwareBufferManagerInterface::_notifyVertexBufferDestroyed */
 		/** @copydoc HardwareBufferManagerInterface::_notifyVertexBufferDestroyed */
 		void _notifyVertexBufferDestroyed(HardwareVertexBuffer* buf)
 		void _notifyVertexBufferDestroyed(HardwareVertexBuffer* buf)
 		{
 		{

+ 1 - 1
CamelotRenderer/Include/CmHardwareIndexBuffer.h

@@ -59,7 +59,7 @@ namespace CamelotEngine {
 	    public:
 	    public:
 		    /// Should be called by HardwareBufferManager
 		    /// Should be called by HardwareBufferManager
 		    HardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType, UINT32 numIndexes, HardwareBuffer::Usage usage,
 		    HardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType, UINT32 numIndexes, HardwareBuffer::Usage usage,
-                bool useSystemMemory, bool useShadowBuffer);
+                bool useSystemMemory);
             ~HardwareIndexBuffer();
             ~HardwareIndexBuffer();
 			/// Return the manager of this buffer, if any
 			/// Return the manager of this buffer, if any
 			HardwareBufferManagerBase* getManager() const { return mMgr; }
 			HardwareBufferManagerBase* getManager() const { return mMgr; }

+ 1 - 1
CamelotRenderer/Include/CmHardwarePixelBuffer.h

@@ -81,7 +81,7 @@ namespace CamelotEngine {
         /// Should be called by HardwareBufferManager
         /// Should be called by HardwareBufferManager
         HardwarePixelBuffer(UINT32 mWidth, UINT32 mHeight, UINT32 mDepth,
         HardwarePixelBuffer(UINT32 mWidth, UINT32 mHeight, UINT32 mDepth,
                 PixelFormat mFormat,
                 PixelFormat mFormat,
-                HardwareBuffer::Usage usage, bool useSystemMemory, bool useShadowBuffer);
+                HardwareBuffer::Usage usage, bool useSystemMemory);
         ~HardwarePixelBuffer();
         ~HardwarePixelBuffer();
 
 
         /** make every lock method from HardwareBuffer available.
         /** make every lock method from HardwareBuffer available.

+ 1 - 7
CamelotRenderer/Include/CmHardwareVertexBuffer.h

@@ -47,7 +47,6 @@ namespace CamelotEngine {
     class CM_EXPORT HardwareVertexBuffer : public HardwareBuffer
     class CM_EXPORT HardwareVertexBuffer : public HardwareBuffer
     {
     {
 	    protected:
 	    protected:
-
 			HardwareBufferManagerBase* mMgr;
 			HardwareBufferManagerBase* mMgr;
 		    UINT32 mNumVertices;
 		    UINT32 mNumVertices;
             UINT32 mVertexSize;
             UINT32 mVertexSize;
@@ -55,7 +54,7 @@ namespace CamelotEngine {
 	    public:
 	    public:
 		    /// Should be called by HardwareBufferManager
 		    /// Should be called by HardwareBufferManager
 		    HardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, UINT32 numVertices,
 		    HardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, UINT32 numVertices,
-                HardwareBuffer::Usage usage, bool useSystemMemory, bool useShadowBuffer);
+                HardwareBuffer::Usage usage, bool useSystemMemory);
             ~HardwareVertexBuffer();
             ~HardwareVertexBuffer();
 			/// Return the manager of this buffer, if any
 			/// Return the manager of this buffer, if any
 			HardwareBufferManagerBase* getManager() const { return mMgr; }
 			HardwareBufferManagerBase* getManager() const { return mMgr; }
@@ -63,11 +62,6 @@ namespace CamelotEngine {
             UINT32 getVertexSize(void) const { return mVertexSize; }
             UINT32 getVertexSize(void) const { return mVertexSize; }
             /// Get the number of vertices in this buffer
             /// Get the number of vertices in this buffer
             UINT32 getNumVertices(void) const { return mNumVertices; }
             UINT32 getNumVertices(void) const { return mNumVertices; }
-
-
-
-		    // NB subclasses should override lock, unlock, readData, writeData
-
     };
     };
 
 
 	typedef std::shared_ptr<HardwareVertexBuffer> HardwareVertexBufferPtr;
 	typedef std::shared_ptr<HardwareVertexBuffer> HardwareVertexBufferPtr;

+ 0 - 21
CamelotRenderer/Include/CmVertexIndexData.h

@@ -95,27 +95,6 @@ namespace CamelotEngine {
 		*/
 		*/
 		VertexData* clone(bool copyData = true, HardwareBufferManagerBase* mgr = 0) const;
 		VertexData* clone(bool copyData = true, HardwareBufferManagerBase* mgr = 0) const;
 
 
-        /** Modifies the vertex data to be suitable for use for rendering shadow geometry.
-        @remarks
-            Preparing vertex data to generate a shadow volume involves firstly ensuring that the 
-            vertex buffer containing the positions is a standalone vertex buffer,
-            with no other components in it. This method will therefore break apart any existing
-            vertex buffers if position is sharing a vertex buffer. 
-            Secondly, it will double the size of this vertex buffer so that there are 2 copies of 
-            the position data for the mesh. The first half is used for the original, and the second 
-            half is used for the 'extruded' version. The vertex count used to render will remain 
-            the same though, so as not to add any overhead to regular rendering of the object.
-            Both copies of the position are required in one buffer because shadow volumes stretch 
-            from the original mesh to the extruded version. 
-        @par
-            It's important to appreciate that this method can fundamentally change the structure of your
-            vertex buffers, although in reality they will be new buffers. As it happens, if other 
-            objects are using the original buffers then they will be unaffected because the reference
-            counting will keep them intact. However, if you have made any assumptions about the 
-            structure of the vertex data in the buffers of this object, you may have to rethink them.
-        */
-        void prepareForShadowVolume(void);
-
         /** Additional shadow volume vertex buffer storage. 
         /** Additional shadow volume vertex buffer storage. 
         @remarks
         @remarks
             This additional buffer is only used where we have prepared this VertexData for
             This additional buffer is only used where we have prepared this VertexData for

+ 5 - 5
CamelotRenderer/Source/CmDefaultHardwareBufferManager.cpp

@@ -32,7 +32,7 @@ namespace CamelotEngine {
 
 
 	DefaultHardwareVertexBuffer::DefaultHardwareVertexBuffer(UINT32 vertexSize, UINT32 numVertices, 
 	DefaultHardwareVertexBuffer::DefaultHardwareVertexBuffer(UINT32 vertexSize, UINT32 numVertices, 
 															 HardwareBuffer::Usage usage)
 															 HardwareBuffer::Usage usage)
-	: HardwareVertexBuffer(0, vertexSize, numVertices, usage, true, false) // always software, never shadowed
+	: HardwareVertexBuffer(0, vertexSize, numVertices, usage, true)
 	{
 	{
         // Allocate aligned memory for better SIMD processing friendly.
         // Allocate aligned memory for better SIMD processing friendly.
         mpData = static_cast<unsigned char*>(_aligned_malloc(mSizeInBytes, CM_SIMD_ALIGNMENT));
         mpData = static_cast<unsigned char*>(_aligned_malloc(mSizeInBytes, CM_SIMD_ALIGNMENT));
@@ -40,7 +40,7 @@ namespace CamelotEngine {
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	DefaultHardwareVertexBuffer::DefaultHardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, UINT32 numVertices, 
 	DefaultHardwareVertexBuffer::DefaultHardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, UINT32 numVertices, 
 		HardwareBuffer::Usage usage)
 		HardwareBuffer::Usage usage)
-        : HardwareVertexBuffer(mgr, vertexSize, numVertices, usage, true, false) // always software, never shadowed
+        : HardwareVertexBuffer(mgr, vertexSize, numVertices, usage, true)
 	{
 	{
         // Allocate aligned memory for better SIMD processing friendly.
         // Allocate aligned memory for better SIMD processing friendly.
         mpData = static_cast<unsigned char*>(_aligned_malloc(mSizeInBytes, CM_SIMD_ALIGNMENT));
         mpData = static_cast<unsigned char*>(_aligned_malloc(mSizeInBytes, CM_SIMD_ALIGNMENT));
@@ -92,7 +92,7 @@ namespace CamelotEngine {
 
 
 	DefaultHardwareIndexBuffer::DefaultHardwareIndexBuffer(IndexType idxType, 
 	DefaultHardwareIndexBuffer::DefaultHardwareIndexBuffer(IndexType idxType, 
 		UINT32 numIndexes, HardwareBuffer::Usage usage) 
 		UINT32 numIndexes, HardwareBuffer::Usage usage) 
-		: HardwareIndexBuffer(0, idxType, numIndexes, usage, true, false) // always software, never shadowed
+		: HardwareIndexBuffer(0, idxType, numIndexes, usage, true)
 	{
 	{
 		mpData = (unsigned char*)malloc(sizeof(unsigned char) * mSizeInBytes);
 		mpData = (unsigned char*)malloc(sizeof(unsigned char) * mSizeInBytes);
 	}
 	}
@@ -152,7 +152,7 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
 	HardwareVertexBufferPtr 
 	HardwareVertexBufferPtr 
         DefaultHardwareBufferManagerBase::createVertexBuffer(UINT32 vertexSize, 
         DefaultHardwareBufferManagerBase::createVertexBuffer(UINT32 vertexSize, 
-		UINT32 numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer)
+		UINT32 numVerts, HardwareBuffer::Usage usage)
 	{
 	{
         DefaultHardwareVertexBuffer* vb = new DefaultHardwareVertexBuffer(this, vertexSize, numVerts, usage);
         DefaultHardwareVertexBuffer* vb = new DefaultHardwareVertexBuffer(this, vertexSize, numVerts, usage);
         return HardwareVertexBufferPtr(vb);
         return HardwareVertexBufferPtr(vb);
@@ -160,7 +160,7 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
 	HardwareIndexBufferPtr 
 	HardwareIndexBufferPtr 
         DefaultHardwareBufferManagerBase::createIndexBuffer(HardwareIndexBuffer::IndexType itype, 
         DefaultHardwareBufferManagerBase::createIndexBuffer(HardwareIndexBuffer::IndexType itype, 
-		UINT32 numIndexes, HardwareBuffer::Usage usage, bool useShadowBuffer)
+		UINT32 numIndexes, HardwareBuffer::Usage usage)
 	{
 	{
         DefaultHardwareIndexBuffer* ib = new DefaultHardwareIndexBuffer(itype, numIndexes, usage);
         DefaultHardwareIndexBuffer* ib = new DefaultHardwareIndexBuffer(itype, numIndexes, usage);
 		return HardwareIndexBufferPtr(ib);
 		return HardwareIndexBufferPtr(ib);

+ 0 - 42
CamelotRenderer/Source/CmHardwareBufferManager.cpp

@@ -106,37 +106,6 @@ namespace CamelotEngine {
             destroyVertexBufferBindingImpl(*bind);
             destroyVertexBufferBindingImpl(*bind);
         }
         }
         mVertexBufferBindings.clear();
         mVertexBufferBindings.clear();
-    }
-	//-----------------------------------------------------------------------
-    HardwareVertexBufferPtr 
-    HardwareBufferManagerBase::allocateVertexBufferCopy(
-        const HardwareVertexBufferPtr& sourceBuffer, 
-        bool copyData)
-    {
-		// pre-lock the mVertexBuffers mutex, which would usually get locked in
-		//  makeBufferCopy / createVertexBuffer
-		// this prevents a deadlock in _notifyVertexBufferDestroyed
-		// which locks the same mutexes (via other methods) but in reverse order
-		CM_LOCK_MUTEX(mVertexBuffersMutex)
-		{
-			HardwareVertexBufferPtr vbuf;
-
-			// Locate existing buffer copy in temporary vertex buffers
-			// copy buffer, use shadow buffer and make dynamic
-			vbuf = makeBufferCopy(
-				sourceBuffer, 
-				HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE, 
-				true);
-
-			// Copy data?
-			if (copyData)
-			{
-				vbuf->copyData(*(sourceBuffer.get()), 0, 0, sourceBuffer->getSizeInBytes(), true);
-			}
-
-			return vbuf;
-		}
-
     }
     }
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	void HardwareBufferManagerBase::_notifyVertexBufferDestroyed(HardwareVertexBuffer* buf)
 	void HardwareBufferManagerBase::_notifyVertexBufferDestroyed(HardwareVertexBuffer* buf)
@@ -161,15 +130,4 @@ namespace CamelotEngine {
 			mIndexBuffers.erase(i);
 			mIndexBuffers.erase(i);
 		}
 		}
 	}
 	}
-    //-----------------------------------------------------------------------
-    HardwareVertexBufferPtr 
-    HardwareBufferManagerBase::makeBufferCopy(
-        const HardwareVertexBufferPtr& source,
-        HardwareBuffer::Usage usage, bool useShadowBuffer)
-    {
-        return this->createVertexBuffer(
-            source->getVertexSize(), 
-            source->getNumVertices(),
-            usage, useShadowBuffer);
-    }
 }
 }

+ 2 - 16
CamelotRenderer/Source/CmHardwareIndexBuffer.cpp

@@ -36,8 +36,8 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------------
     //-----------------------------------------------------------------------------
     HardwareIndexBuffer::HardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType, 
     HardwareIndexBuffer::HardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType, 
         UINT32 numIndexes, HardwareBuffer::Usage usage, 
         UINT32 numIndexes, HardwareBuffer::Usage usage, 
-        bool useSystemMemory, bool useShadowBuffer) 
-        : HardwareBuffer(usage, useSystemMemory, useShadowBuffer)
+        bool useSystemMemory) 
+        : HardwareBuffer(usage, useSystemMemory)
 		, mMgr(mgr)
 		, mMgr(mgr)
 		, mIndexType(idxType)
 		, mIndexType(idxType)
 		, mNumIndexes(numIndexes)
 		, mNumIndexes(numIndexes)
@@ -53,15 +53,6 @@ namespace CamelotEngine {
             break;
             break;
         }
         }
         mSizeInBytes = mIndexSize * mNumIndexes;
         mSizeInBytes = mIndexSize * mNumIndexes;
-
-        // Create a shadow buffer if required
-        if (mUseShadowBuffer)
-        {
-            mpShadowBuffer = new DefaultHardwareIndexBuffer(mIndexType, 
-                mNumIndexes, HardwareBuffer::HBU_DYNAMIC);
-        }
-
-
     }
     }
     //-----------------------------------------------------------------------------
     //-----------------------------------------------------------------------------
     HardwareIndexBuffer::~HardwareIndexBuffer()
     HardwareIndexBuffer::~HardwareIndexBuffer()
@@ -70,11 +61,6 @@ namespace CamelotEngine {
 		{
 		{
 			mMgr->_notifyIndexBufferDestroyed(this);
 			mMgr->_notifyIndexBufferDestroyed(this);
 		}
 		}
-
-        if (mpShadowBuffer)
-        {
-            delete mpShadowBuffer;
-        }
     }
     }
 }
 }
 
 

+ 5 - 19
CamelotRenderer/Source/CmHardwarePixelBuffer.cpp

@@ -34,8 +34,8 @@ namespace CamelotEngine
     //-----------------------------------------------------------------------------    
     //-----------------------------------------------------------------------------    
     HardwarePixelBuffer::HardwarePixelBuffer(UINT32 width, UINT32 height, UINT32 depth,
     HardwarePixelBuffer::HardwarePixelBuffer(UINT32 width, UINT32 height, UINT32 depth,
             PixelFormat format,
             PixelFormat format,
-            HardwareBuffer::Usage usage, bool useSystemMemory, bool useShadowBuffer):
-        HardwareBuffer(usage, useSystemMemory, useShadowBuffer),
+            HardwareBuffer::Usage usage, bool useSystemMemory):
+        HardwareBuffer(usage, useSystemMemory),
         mWidth(width), mHeight(height), mDepth(depth),
         mWidth(width), mHeight(height), mDepth(depth),
         mFormat(format)
         mFormat(format)
     {
     {
@@ -64,23 +64,9 @@ namespace CamelotEngine
     //-----------------------------------------------------------------------------    
     //-----------------------------------------------------------------------------    
     const PixelData& HardwarePixelBuffer::lock(const Box& lockBox, LockOptions options)
     const PixelData& HardwarePixelBuffer::lock(const Box& lockBox, LockOptions options)
     {
     {
-        if (mUseShadowBuffer)
-        {
-            if (options != HBL_READ_ONLY)
-            {
-                // we have to assume a read / write lock so we use the shadow buffer
-                // and tag for sync on unlock()
-                mShadowUpdated = true;
-            }
-
-            mCurrentLock = static_cast<HardwarePixelBuffer*>(mpShadowBuffer)->lock(lockBox, options);
-        }
-        else
-        {
-            // Lock the real buffer if there is no shadow buffer 
-            mCurrentLock = lockImpl(lockBox, options);
-            mIsLocked = true;
-        }
+        // Lock the real buffer if there is no shadow buffer 
+        mCurrentLock = lockImpl(lockBox, options);
+        mIsLocked = true;
 
 
         return mCurrentLock;
         return mCurrentLock;
     }
     }

+ 2 - 13
CamelotRenderer/Source/CmHardwareVertexBuffer.cpp

@@ -40,8 +40,8 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------------
     //-----------------------------------------------------------------------------
     HardwareVertexBuffer::HardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize,  
     HardwareVertexBuffer::HardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize,  
         UINT32 numVertices, HardwareBuffer::Usage usage, 
         UINT32 numVertices, HardwareBuffer::Usage usage, 
-        bool useSystemMemory, bool useShadowBuffer) 
-        : HardwareBuffer(usage, useSystemMemory, useShadowBuffer), 
+        bool useSystemMemory) 
+        : HardwareBuffer(usage, useSystemMemory), 
 		  mMgr(mgr),
 		  mMgr(mgr),
           mNumVertices(numVertices),
           mNumVertices(numVertices),
           mVertexSize(vertexSize)
           mVertexSize(vertexSize)
@@ -49,13 +49,6 @@ namespace CamelotEngine {
         // Calculate the size of the vertices
         // Calculate the size of the vertices
         mSizeInBytes = mVertexSize * numVertices;
         mSizeInBytes = mVertexSize * numVertices;
 
 
-        // Create a shadow buffer if required
-        if (mUseShadowBuffer)
-        {
-            mpShadowBuffer = new DefaultHardwareVertexBuffer(mMgr, mVertexSize, 
-                    mNumVertices, HardwareBuffer::HBU_DYNAMIC);
-        }
-
     }
     }
     //-----------------------------------------------------------------------------
     //-----------------------------------------------------------------------------
     HardwareVertexBuffer::~HardwareVertexBuffer()
     HardwareVertexBuffer::~HardwareVertexBuffer()
@@ -64,10 +57,6 @@ namespace CamelotEngine {
 		{
 		{
 			mMgr->_notifyVertexBufferDestroyed(this);
 			mMgr->_notifyVertexBufferDestroyed(this);
 		}
 		}
-        if (mpShadowBuffer)
-        {
-            delete mpShadowBuffer;
-        }
     }
     }
     //-----------------------------------------------------------------------------
     //-----------------------------------------------------------------------------
     VertexElement::VertexElement(unsigned short source, UINT32 offset, 
     VertexElement::VertexElement(unsigned short source, UINT32 offset, 

+ 2 - 193
CamelotRenderer/Source/CmVertexIndexData.cpp

@@ -88,8 +88,7 @@ namespace CamelotEngine {
             {
             {
 			    // create new buffer with the same settings
 			    // create new buffer with the same settings
 			    dstBuf = pManager->createVertexBuffer(
 			    dstBuf = pManager->createVertexBuffer(
-					    srcbuf->getVertexSize(), srcbuf->getNumVertices(), srcbuf->getUsage(),
-					    srcbuf->hasShadowBuffer());
+					    srcbuf->getVertexSize(), srcbuf->getNumVertices(), srcbuf->getUsage());
 
 
 			    // copy data
 			    // copy data
 			    dstBuf->copyData(*srcbuf, 0, 0, srcbuf->getSizeInBytes(), true);
 			    dstBuf->copyData(*srcbuf, 0, 0, srcbuf->getSizeInBytes(), true);
@@ -127,196 +126,6 @@ namespace CamelotEngine {
         
         
         return dest;
         return dest;
 	}
 	}
-    //-----------------------------------------------------------------------
-    void VertexData::prepareForShadowVolume(void)
-    {
-        /* NOTE
-        I would dearly, dearly love to just use a 4D position buffer in order to 
-        store the extra 'w' value I need to differentiate between extruded and 
-        non-extruded sections of the buffer, so that vertex programs could use that.
-        Hey, it works fine for GL. However, D3D9 in it's infinite stupidity, does not
-        support 4d position vertices in the fixed-function pipeline. If you use them, 
-        you just see nothing. Since we can't know whether the application is going to use
-        fixed function or vertex programs, we have to stick to 3d position vertices and
-        store the 'w' in a separate 1D texture coordinate buffer, which is only used
-        when rendering the shadow.
-        */
-
-        // Upfront, lets check whether we have vertex program capability
-        bool useVertexPrograms = false;
-
-		RenderSystem* rend = CamelotEngine::RenderSystemManager::getActive();
-        if (rend && rend->getCapabilities_internal()->hasCapability(RSC_VERTEX_PROGRAM))
-        {
-            useVertexPrograms = true;
-        }
-
-
-        // Look for a position element
-        const VertexElement* posElem = vertexDeclaration->findElementBySemantic(VES_POSITION);
-        if (posElem)
-        {
-            UINT32 v;
-            unsigned short posOldSource = posElem->getSource();
-
-            HardwareVertexBufferPtr vbuf = vertexBufferBinding->getBuffer(posOldSource);
-            bool wasSharedBuffer = false;
-            // Are there other elements in the buffer except for the position?
-            if (vbuf->getVertexSize() > posElem->getSize())
-            {
-                // We need to create another buffer to contain the remaining elements
-                // Most drivers don't like gaps in the declaration, and in any case it's waste
-                wasSharedBuffer = true;
-            }
-            HardwareVertexBufferPtr newPosBuffer, newRemainderBuffer;
-            if (wasSharedBuffer)
-            {
-                newRemainderBuffer = vbuf->getManager()->createVertexBuffer(
-                    vbuf->getVertexSize() - posElem->getSize(), vbuf->getNumVertices(), vbuf->getUsage(),
-                    vbuf->hasShadowBuffer());
-            }
-            // Allocate new position buffer, will be FLOAT3 and 2x the size
-            UINT32 oldVertexCount = vbuf->getNumVertices();
-            UINT32 newVertexCount = oldVertexCount * 2;
-            newPosBuffer = vbuf->getManager()->createVertexBuffer(
-                VertexElement::getTypeSize(VET_FLOAT3), newVertexCount, vbuf->getUsage(), 
-                vbuf->hasShadowBuffer());
-
-            // Iterate over the old buffer, copying the appropriate elements and initialising the rest
-            float* pSrc;
-            unsigned char *pBaseSrc = static_cast<unsigned char*>(
-                vbuf->lock(HardwareBuffer::HBL_READ_ONLY));
-            // Point first destination pointer at the start of the new position buffer,
-            // the other one half way along
-            float *pDest = static_cast<float*>(newPosBuffer->lock(HardwareBuffer::HBL_DISCARD));
-            float* pDest2 = pDest + oldVertexCount * 3; 
-
-            // Precalculate any dimensions of vertex areas outside the position
-            UINT32 prePosVertexSize = 0, postPosVertexSize, postPosVertexOffset;
-            unsigned char *pBaseDestRem = 0;
-            if (wasSharedBuffer)
-            {
-                pBaseDestRem = static_cast<unsigned char*>(
-                    newRemainderBuffer->lock(HardwareBuffer::HBL_DISCARD));
-                prePosVertexSize = posElem->getOffset();
-                postPosVertexOffset = prePosVertexSize + posElem->getSize();
-                postPosVertexSize = vbuf->getVertexSize() - postPosVertexOffset;
-                // the 2 separate bits together should be the same size as the remainder buffer vertex
-                assert (newRemainderBuffer->getVertexSize() == prePosVertexSize + postPosVertexSize);
-
-                // Iterate over the vertices
-                for (v = 0; v < oldVertexCount; ++v)
-                {
-                    // Copy position, into both buffers
-                    posElem->baseVertexPointerToElement(pBaseSrc, &pSrc);
-                    *pDest++ = *pDest2++ = *pSrc++;
-                    *pDest++ = *pDest2++ = *pSrc++;
-                    *pDest++ = *pDest2++ = *pSrc++;
-
-                    // now deal with any other elements 
-                    // Basically we just memcpy the vertex excluding the position
-                    if (prePosVertexSize > 0)
-                        memcpy(pBaseDestRem, pBaseSrc, prePosVertexSize);
-                    if (postPosVertexSize > 0)
-                        memcpy(pBaseDestRem + prePosVertexSize, 
-                            pBaseSrc + postPosVertexOffset, postPosVertexSize);
-                    pBaseDestRem += newRemainderBuffer->getVertexSize();
-
-                    pBaseSrc += vbuf->getVertexSize();
-
-                } // next vertex
-            }
-            else
-            {
-                // Unshared buffer, can block copy the whole thing
-                memcpy(pDest, pBaseSrc, vbuf->getSizeInBytes());
-                memcpy(pDest2, pBaseSrc, vbuf->getSizeInBytes());
-            }
-
-            vbuf->unlock();
-            newPosBuffer->unlock();
-            if (wasSharedBuffer)
-                newRemainderBuffer->unlock();
-
-            if (useVertexPrograms)
-            {
-                // Now it's time to set up the w buffer
-                hardwareShadowVolWBuffer = vbuf->getManager()->createVertexBuffer(
-                    sizeof(float), newVertexCount, HardwareBuffer::HBU_STATIC_WRITE_ONLY, false);
-                // Fill the first half with 1.0, second half with 0.0
-                pDest = static_cast<float*>(
-                    hardwareShadowVolWBuffer->lock(HardwareBuffer::HBL_DISCARD));
-                for (v = 0; v < oldVertexCount; ++v)
-                {
-                    *pDest++ = 1.0f;
-                }
-                for (v = 0; v < oldVertexCount; ++v)
-                {
-                    *pDest++ = 0.0f;
-                }
-                hardwareShadowVolWBuffer->unlock();
-            }
-
-            unsigned short newPosBufferSource; 
-            if (wasSharedBuffer)
-            {
-                // Get the a new buffer binding index
-                newPosBufferSource= vertexBufferBinding->getNextIndex();
-                // Re-bind the old index to the remainder buffer
-                vertexBufferBinding->setBinding(posOldSource, newRemainderBuffer);
-            }
-            else
-            {
-                // We can just re-use the same source idex for the new position buffer
-                newPosBufferSource = posOldSource;
-            }
-            // Bind the new position buffer
-            vertexBufferBinding->setBinding(newPosBufferSource, newPosBuffer);
-
-            // Now, alter the vertex declaration to change the position source
-            // and the offsets of elements using the same buffer
-            VertexDeclaration::VertexElementList::const_iterator elemi = 
-                vertexDeclaration->getElements().begin();
-            VertexDeclaration::VertexElementList::const_iterator elemiend = 
-                vertexDeclaration->getElements().end();
-            unsigned short idx;
-            for(idx = 0; elemi != elemiend; ++elemi, ++idx) 
-            {
-                if (&(*elemi) == posElem)
-                {
-                    // Modify position to point at new position buffer
-                    vertexDeclaration->modifyElement(
-                        idx, 
-                        newPosBufferSource, // new source buffer
-                        0, // no offset now
-                        VET_FLOAT3, 
-                        VES_POSITION);
-                }
-                else if (wasSharedBuffer &&
-                    elemi->getSource() == posOldSource &&
-                    elemi->getOffset() > prePosVertexSize )
-                {
-                    // This element came after position, remove the position's
-                    // size
-                    vertexDeclaration->modifyElement(
-                        idx, 
-                        posOldSource, // same old source
-                        elemi->getOffset() - posElem->getSize(), // less offset now
-                        elemi->getType(), 
-                        elemi->getSemantic(),
-                        elemi->getIndex());
-
-                }
-
-            }
-
-
-            // Note that we don't change vertexCount, because the other buffer(s) are still the same
-            // size after all
-
-
-        }
-    }
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	void VertexData::reorganiseBuffers(VertexDeclarationPtr newDeclaration, 
 	void VertexData::reorganiseBuffers(VertexDeclarationPtr newDeclaration, 
 		const BufferUsageList& bufferUsages, HardwareBufferManagerBase* mgr)
 		const BufferUsageList& bufferUsages, HardwareBufferManagerBase* mgr)
@@ -674,7 +483,7 @@ namespace CamelotEngine {
             if (copyData)
             if (copyData)
             {
             {
 			    dest->indexBuffer = pManager->createIndexBuffer(indexBuffer->getType(), indexBuffer->getNumIndexes(),
 			    dest->indexBuffer = pManager->createIndexBuffer(indexBuffer->getType(), indexBuffer->getNumIndexes(),
-				    indexBuffer->getUsage(), indexBuffer->hasShadowBuffer());
+				    indexBuffer->getUsage());
 			    dest->indexBuffer->copyData(*indexBuffer, 0, 0, indexBuffer->getSizeInBytes(), true);
 			    dest->indexBuffer->copyData(*indexBuffer, 0, 0, indexBuffer->getSizeInBytes(), true);
             }
             }
             else
             else

+ 39 - 2
CamelotRenderer/TODO.txt

@@ -22,10 +22,45 @@ High-level TODO:
   - Instancing
   - Instancing
   - Dynamic shader linkage
   - Dynamic shader linkage
   - Append/Consume buffer
   - Append/Consume buffer
+  - 1D/2D/Cube texture arrays
   - What's missing:
   - What's missing:
     - No proper support for texture arrays, or multisampled texture resources
     - No proper support for texture arrays, or multisampled texture resources
 	- Staging and immutable buffers. See D3D11Mapping, DWORD D3D11Mappings::get(HardwareBuffer::Usage usage)
 	- Staging and immutable buffers. See D3D11Mapping, DWORD D3D11Mappings::get(HardwareBuffer::Usage usage)
-
+	- Multiple adapters (multi gpu)
+
+--HARDWARE BUFFERS--
+New set of HardwareBuffer usage flags:
+ IMMUTABLE
+  - DX11: IMMUTABLE
+  - DX9/GL: STATIC (D3DUSAGE_WRITEONLY)
+  - ensures and read/write operations fail after initialization
+ DEFAULT,
+   - DX11: DEFAULT
+   - DX9/GL: STATIC (D3DUSAGE_WRITEONLY) & STATIC_DISCARDABLE
+ CPUWRITE
+   - DX11: DYNAMIC
+   - DX9/GL: DYNAMIC (D3DUSAGE_DYNAMIC)
+ CPUREADWRITE
+   - DX11: STAGING
+   - DX9/GL: DYNAMIC (D3DUSAGE_DYNAMIC)
+ DISCARDABLE
+   - Flag used in addition to the others. Ignored with DX11 and OpenGL
+ Revisit hardware buffers (especially system memory & shadow buffers)
+
+DX11 HLSL:
+ - Preprocessor defines & includes
+
+DX11 classes to port (in that order):
+ VideoMode
+Driver
+VideoModeList
+DriverList
+GpuProgramManager
+HardwareBuffer
+HardwareIndexBuffer
+HardwareVertexBuffer
+VertexDeclaration/HLSLProgram
+HLSLProgramFactory
 
 
 Command buffer TODO:
 Command buffer TODO:
  - Redo OpenGL shaders as they seem to be using pretty old methods (glCreateShaderObjectARB seems to be deprectated for example)
  - Redo OpenGL shaders as they seem to be using pretty old methods (glCreateShaderObjectARB seems to be deprectated for example)
@@ -109,7 +144,9 @@ Low priority TODO:
    if pointer is saved/loaded as a plain field. I need to add a check that ensures the type is POD. 
    if pointer is saved/loaded as a plain field. I need to add a check that ensures the type is POD. 
    See: http://www.boost.org/doc/libs/1_51_0/boost/mpi/datatype.hpp for a possible implementation of a compile time check.
    See: http://www.boost.org/doc/libs/1_51_0/boost/mpi/datatype.hpp for a possible implementation of a compile time check.
  - Fix up WorkQueue as it doesn't lock when initializing, to make sure threads are actually started before returning
  - Fix up WorkQueue as it doesn't lock when initializing, to make sure threads are actually started before returning
- 
+ - D3D9HLSLProgram stuff that isn't used (it needs to be initialized before initializing the shader, which currently isn't possible). Maybe adding it to HighLevelGpuProgramFactory?
+     - setPreprocessorDefines, setColumnMajorMatrices, setOptimisationLevel
+
 Optional TODO:
 Optional TODO:
  - Add precompiled headers to all projects
  - Add precompiled headers to all projects
  - If possible, make sure GLSL uses EntryPoint and Profile fields I have added to GpuProgram
  - If possible, make sure GLSL uses EntryPoint and Profile fields I have added to GpuProgram