2
0
Эх сурвалжийг харах

Refactored some enums and started work on generic buffers

Marko Pintera 13 жил өмнө
parent
commit
dc14ccc440
69 өөрчлөгдсөн 428 нэмэгдсэн , 388 устгасан
  1. 2 0
      CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj
  2. 6 0
      CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj.filters
  3. 42 0
      CamelotD3D11RenderSystem/Include/CmD3D11GenericBuffer.h
  4. 2 2
      CamelotD3D11RenderSystem/Include/CmD3D11HardwareBuffer.h
  5. 2 2
      CamelotD3D11RenderSystem/Include/CmD3D11HardwareBufferManager.h
  6. 2 2
      CamelotD3D11RenderSystem/Include/CmD3D11HardwareConstantBuffer.h
  7. 2 2
      CamelotD3D11RenderSystem/Include/CmD3D11HardwareIndexBuffer.h
  8. 2 2
      CamelotD3D11RenderSystem/Include/CmD3D11HardwareVertexBuffer.h
  9. 7 7
      CamelotD3D11RenderSystem/Include/CmD3D11Mappings.h
  10. 1 1
      CamelotD3D11RenderSystem/Include/CmD3D11Texture.h
  11. 37 0
      CamelotD3D11RenderSystem/Source/CmD3D11GenericBuffer.cpp
  12. 12 12
      CamelotD3D11RenderSystem/Source/CmD3D11HardwareBuffer.cpp
  13. 2 2
      CamelotD3D11RenderSystem/Source/CmD3D11HardwareBufferManager.cpp
  14. 2 2
      CamelotD3D11RenderSystem/Source/CmD3D11HardwareConstantBuffer.cpp
  15. 2 2
      CamelotD3D11RenderSystem/Source/CmD3D11HardwareIndexBuffer.cpp
  16. 2 2
      CamelotD3D11RenderSystem/Source/CmD3D11HardwareVertexBuffer.cpp
  17. 29 59
      CamelotD3D11RenderSystem/Source/CmD3D11Mappings.cpp
  18. 6 6
      CamelotD3D11RenderSystem/Source/CmD3D11Texture.cpp
  19. 2 2
      CamelotD3D9Renderer/Include/CmD3D9HardwareBufferManager.h
  20. 3 3
      CamelotD3D9Renderer/Include/CmD3D9HardwareIndexBuffer.h
  21. 2 2
      CamelotD3D9Renderer/Include/CmD3D9HardwarePixelBuffer.h
  22. 3 3
      CamelotD3D9Renderer/Include/CmD3D9HardwareVertexBuffer.h
  23. 3 3
      CamelotD3D9Renderer/Include/CmD3D9Mappings.h
  24. 1 1
      CamelotD3D9Renderer/Include/CmD3D9Texture.h
  25. 2 2
      CamelotD3D9Renderer/Source/CmD3D9HardwareBufferManager.cpp
  26. 9 12
      CamelotD3D9Renderer/Source/CmD3D9HardwareIndexBuffer.cpp
  27. 5 5
      CamelotD3D9Renderer/Source/CmD3D9HardwarePixelBuffer.cpp
  28. 9 12
      CamelotD3D9Renderer/Source/CmD3D9HardwareVertexBuffer.cpp
  29. 17 30
      CamelotD3D9Renderer/Source/CmD3D9Mappings.cpp
  30. 4 4
      CamelotD3D9Renderer/Source/CmD3D9Texture.cpp
  31. 2 2
      CamelotGLRenderer/Include/CmGLHardwareBufferManager.h
  32. 2 2
      CamelotGLRenderer/Include/CmGLHardwareIndexBuffer.h
  33. 4 4
      CamelotGLRenderer/Include/CmGLHardwarePixelBuffer.h
  34. 2 3
      CamelotGLRenderer/Include/CmGLHardwareVertexBuffer.h
  35. 1 1
      CamelotGLRenderer/Include/CmGLTexture.h
  36. 4 8
      CamelotGLRenderer/Source/CmGLHardwareBufferManager.cpp
  37. 7 7
      CamelotGLRenderer/Source/CmGLHardwareIndexBuffer.cpp
  38. 9 9
      CamelotGLRenderer/Source/CmGLHardwarePixelBuffer.cpp
  39. 7 7
      CamelotGLRenderer/Source/CmGLHardwareVertexBuffer.cpp
  40. 2 2
      CamelotGLRenderer/Source/CmGLTexture.cpp
  41. 3 1
      CamelotRenderer/CamelotRenderer.vcxproj
  42. 9 3
      CamelotRenderer/CamelotRenderer.vcxproj.filters
  43. 1 1
      CamelotRenderer/Include/CmBlendState.h
  44. 1 1
      CamelotRenderer/Include/CmCamera.h
  45. 1 1
      CamelotRenderer/Include/CmCommandQueue.h
  46. 19 7
      CamelotRenderer/Include/CmCommonEnums.h
  47. 1 1
      CamelotRenderer/Include/CmDeferredRenderContext.h
  48. 1 1
      CamelotRenderer/Include/CmDepthStencilState.h
  49. 38 0
      CamelotRenderer/Include/CmGenericBuffer.h
  50. 10 54
      CamelotRenderer/Include/CmHardwareBuffer.h
  51. 4 4
      CamelotRenderer/Include/CmHardwareBufferManager.h
  52. 1 1
      CamelotRenderer/Include/CmHardwareIndexBuffer.h
  53. 5 6
      CamelotRenderer/Include/CmHardwarePixelBuffer.h
  54. 1 1
      CamelotRenderer/Include/CmHardwareVertexBuffer.h
  55. 1 1
      CamelotRenderer/Include/CmPass.h
  56. 1 1
      CamelotRenderer/Include/CmRasterizerState.h
  57. 1 1
      CamelotRenderer/Include/CmRenderSystem.h
  58. 1 1
      CamelotRenderer/Include/CmSamplerState.h
  59. 4 4
      CamelotRenderer/Include/CmTexture.h
  60. 1 1
      CamelotRenderer/Include/CmVertexIndexData.h
  61. 1 1
      CamelotRenderer/Include/CmViewport.h
  62. 6 0
      CamelotRenderer/Source/CmGenericBuffer.cpp
  63. 1 1
      CamelotRenderer/Source/CmHardwareIndexBuffer.cpp
  64. 7 7
      CamelotRenderer/Source/CmHardwarePixelBuffer.cpp
  65. 1 1
      CamelotRenderer/Source/CmHardwareVertexBuffer.cpp
  66. 6 6
      CamelotRenderer/Source/CmMesh.cpp
  67. 3 3
      CamelotRenderer/Source/CmTexture.cpp
  68. 11 25
      CamelotRenderer/Source/CmVertexIndexData.cpp
  69. 28 26
      CamelotRenderer/TODO.txt

+ 2 - 0
CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj

@@ -149,6 +149,7 @@
     <ClInclude Include="Include\CmD3D11BlendState.h" />
     <ClInclude Include="Include\CmD3D11DepthStencilBuffer.h" />
     <ClInclude Include="Include\CmD3D11DepthStencilState.h" />
+    <ClInclude Include="Include\CmD3D11GenericBuffer.h" />
     <ClInclude Include="Include\CmD3D11HardwareBufferManager.h" />
     <ClInclude Include="Include\CmD3D11HardwareConstantBuffer.h" />
     <ClInclude Include="Include\CmD3D11Device.h" />
@@ -186,6 +187,7 @@
     <ClCompile Include="Source\CmD3D11Device.cpp" />
     <ClCompile Include="Source\CmD3D11Driver.cpp" />
     <ClCompile Include="Source\CmD3D11DriverList.cpp" />
+    <ClCompile Include="Source\CmD3D11GenericBuffer.cpp" />
     <ClCompile Include="Source\CmD3D11GpuProgram.cpp" />
     <ClCompile Include="Source\CmD3D11GpuProgramManager.cpp" />
     <ClCompile Include="Source\CmD3D11HardwareBuffer.cpp" />

+ 6 - 0
CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj.filters

@@ -114,6 +114,9 @@
     <ClInclude Include="Include\CmD3D11RenderWindowManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmD3D11GenericBuffer.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CmD3D11GpuProgram.cpp">
@@ -206,5 +209,8 @@
     <ClCompile Include="Source\CmD3D11RenderWindowManager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Source\CmD3D11GenericBuffer.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 42 - 0
CamelotD3D11RenderSystem/Include/CmD3D11GenericBuffer.h

@@ -0,0 +1,42 @@
+#pragma once
+
+#include "CmD3D11Prerequisites.h"
+#include "CmGenericBuffer.h"
+#include "CmCommonEnums.h"
+
+namespace CamelotEngine 
+{
+	class CM_D3D11_EXPORT D3D11GenericBuffer : public GenericBuffer
+    {
+    public:
+		D3D11GenericBuffer(GenericBufferType type, GpuBufferUsage usage);
+        ~D3D11GenericBuffer();
+
+		/**
+		 * @copydoc GenericBuffer::lockImpl
+		 */
+		virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options);
+
+		/**
+		 * @copydoc GenericBuffer::unlockImpl
+		 */
+		virtual void unlock();
+
+		/**
+		* @copydoc GenericBuffer::readData
+		*/
+        virtual void readData(UINT32 offset, UINT32 length, void* pDest);
+
+		/**
+		* @copydoc GenericBuffer::writeData
+		*/
+        virtual void writeData(UINT32 offset, UINT32 length, const void* pSource,
+				bool discardWholeBuffer = false);
+
+		/**
+		* @copydoc GenericBuffer::copyData
+		*/
+		void copyData(GenericBuffer& srcBuffer, UINT32 srcOffset, 
+			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false);
+    };
+}

+ 2 - 2
CamelotD3D11RenderSystem/Include/CmD3D11HardwareBuffer.h

@@ -25,12 +25,12 @@ namespace CamelotEngine
 		D3D11_BUFFER_DESC mDesc;
 
 		/** See HardwareBuffer. */
-		void* lockImpl(UINT32 offset, UINT32 length, LockOptions options);
+		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
 		/** See HardwareBuffer. */
 		void unlockImpl(void);
 
 	public:
-		D3D11HardwareBuffer(BufferType btype, UINT32 sizeBytes, HardwareBuffer::Usage usage, 
+		D3D11HardwareBuffer(BufferType btype, UINT32 sizeBytes, GpuBufferUsage usage, 
 			D3D11Device& device, bool useSystemMem, bool streamOut);
 		~D3D11HardwareBuffer();
 

+ 2 - 2
CamelotD3D11RenderSystem/Include/CmD3D11HardwareBufferManager.h

@@ -14,12 +14,12 @@ namespace CamelotEngine
 		/**
 		 * @brief	Creates a hardware vertex buffer.
 		 */
-		HardwareVertexBufferPtr createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage, bool streamOut = false);
+		HardwareVertexBufferPtr createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
 		
 		/**
 		 * @brief	Creates a hardware index buffer.
 		 */
-		HardwareIndexBufferPtr createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, HardwareBuffer::Usage usage);
+		HardwareIndexBufferPtr createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
 
 		/** @copydoc HardwareBufferManagerInterface::createGpuParamBlock */
 		GpuParamBlockPtr createGpuParamBlock(const GpuParamBlockDesc& paramDesc);

+ 2 - 2
CamelotD3D11RenderSystem/Include/CmD3D11HardwareConstantBuffer.h

@@ -11,7 +11,7 @@ namespace CamelotEngine
 	{
 	public:
 		D3D11HardwareConstantBuffer(D3D11Device& device, HardwareBufferManagerBase* mgr, UINT32 sizeBytes, 
-			HardwareBuffer::Usage usage, bool useSystemMem);
+			GpuBufferUsage usage, bool useSystemMem);
 		~D3D11HardwareConstantBuffer();
 
 		/**
@@ -39,7 +39,7 @@ namespace CamelotEngine
 		/**
 		* @copydoc HardwareBuffer::lockImpl
 		 */
-		void* lockImpl(UINT32 offset, UINT32 length, LockOptions options);
+		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
 
 		/**
 		 * @copydoc HardwareBuffer::unlockImpl

+ 2 - 2
CamelotD3D11RenderSystem/Include/CmD3D11HardwareIndexBuffer.h

@@ -10,7 +10,7 @@ namespace CamelotEngine
 	{
 	public:
 		D3D11HardwareIndexBuffer(D3D11Device& device, HardwareBufferManagerBase* mgr, IndexType idxType, UINT32 numIndexes, 
-			HardwareBuffer::Usage usage, bool useSystemMem);
+			GpuBufferUsage usage, bool useSystemMem);
 		~D3D11HardwareIndexBuffer();
 
 		/**
@@ -38,7 +38,7 @@ namespace CamelotEngine
 		/**
 		* @copydoc HardwareBuffer::lockImpl
 		 */
-		void* lockImpl(UINT32 offset, UINT32 length, LockOptions options);
+		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
 
 		/**
 		 * @copydoc HardwareBuffer::unlockImpl

+ 2 - 2
CamelotD3D11RenderSystem/Include/CmD3D11HardwareVertexBuffer.h

@@ -10,7 +10,7 @@ namespace CamelotEngine
 	{
 	public:
 		D3D11HardwareVertexBuffer(D3D11Device& device, HardwareBufferManagerBase* mgr, UINT32 vertexSize, UINT32 numVertices, 
-			HardwareBuffer::Usage usage, bool useSystemMem, bool streamOut);
+			GpuBufferUsage usage, bool useSystemMem, bool streamOut);
 		~D3D11HardwareVertexBuffer();
 
 		/**
@@ -38,7 +38,7 @@ namespace CamelotEngine
 		/**
 		* @copydoc HardwareBuffer::lockImpl
 		 */
-		void* lockImpl(UINT32 offset, UINT32 length, LockOptions options);
+		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
 
 		/**
 		 * @copydoc HardwareBuffer::unlockImpl

+ 7 - 7
CamelotD3D11RenderSystem/Include/CmD3D11Mappings.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include "CmD3D11Prerequisites.h"
-#include "CmCommon.h"
+#include "CmCommonEnums.h"
 #include "CmTexture.h"
 #include "CmPixelData.h"
 #include "CmHardwareIndexBuffer.h"
@@ -45,9 +45,9 @@ namespace CamelotEngine
 		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 engine buffer usage
-		static DWORD get(HardwareBuffer::Usage usage);
+		static DWORD get(GpuBufferUsage usage);
 		/// Get lock options
-		static D3D11_MAP get(LockOptions options, HardwareBuffer::Usage usage);
+		static D3D11_MAP get(GpuLockOptions options, GpuBufferUsage usage);
 		static UINT getByteWidth(HardwareIndexBuffer::IndexType itype);
 		/// Get vertex data type
 		static DXGI_FORMAT get(VertexElementType vType);
@@ -65,11 +65,11 @@ namespace CamelotEngine
 		/// utility method, convert engine pixel format to D3D11 pixel format
 		static DXGI_FORMAT _getPF(PixelFormat ogrePF);
 		//
-		static D3D11_USAGE _getUsage(HardwareBuffer::Usage mUsage);
+		static D3D11_USAGE _getUsage(GpuBufferUsage mUsage);
 		static D3D11_USAGE _getUsage(int mUsage);
-		static UINT _getAccessFlags(HardwareBuffer::Usage mUsage);
+		static UINT _getAccessFlags(GpuBufferUsage mUsage);
 		static UINT _getAccessFlags(int mUsage);
-		static bool _isDynamic(HardwareBuffer::Usage mUsage);
+		static bool _isDynamic(GpuBufferUsage mUsage);
 
 		static bool _isDynamic(int mUsage);
 
@@ -83,6 +83,6 @@ namespace CamelotEngine
 		static UINT _getTextureBindFlags(DXGI_FORMAT format, bool isdynamic);
 		static UINT _getTextureMiscFlags(UINT bindflags, TextureType textype, bool isdynamic);
 
-		static D3D11_MAP _getLockOptions(LockOptions lockOptions);
+		static D3D11_MAP _getLockOptions(GpuLockOptions lockOptions);
 	};
 }

+ 1 - 1
CamelotD3D11RenderSystem/Include/CmD3D11Texture.h

@@ -33,7 +33,7 @@ namespace CamelotEngine
 		/**
 		 * @copydoc Texture::lockImpl
 		 */
-		PixelData lockImpl(LockOptions options, UINT32 mipLevel = 0, UINT32 face = 0);
+		PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0);
 
 		/**
 		 * @copydoc Texture::unlockImpl

+ 37 - 0
CamelotD3D11RenderSystem/Source/CmD3D11GenericBuffer.cpp

@@ -0,0 +1,37 @@
+#include "CmD3D11GenericBuffer.h"
+
+namespace CamelotEngine
+{
+	D3D11GenericBuffer::D3D11GenericBuffer(GenericBufferType type, GpuBufferUsage usage) 
+		: GenericBuffer(type, usage)
+	{  }
+
+	D3D11GenericBuffer::~D3D11GenericBuffer() 
+	{ }
+
+	void* D3D11GenericBuffer::lock(UINT32 offset, UINT32 length, GpuLockOptions options)
+	{
+		return nullptr;
+	}
+
+	void D3D11GenericBuffer::unlock()
+	{
+
+	}
+
+	void D3D11GenericBuffer::readData(UINT32 offset, UINT32 length, void* pDest)
+	{
+
+	}
+
+	void D3D11GenericBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, bool discardWholeBuffer)
+	{
+
+	}
+
+	void D3D11GenericBuffer::copyData(GenericBuffer& srcBuffer, UINT32 srcOffset, 
+		UINT32 dstOffset, UINT32 length, bool discardWholeBuffer)
+	{
+
+	}
+}

+ 12 - 12
CamelotD3D11RenderSystem/Source/CmD3D11HardwareBuffer.cpp

@@ -6,7 +6,7 @@
 
 namespace CamelotEngine
 {
-	D3D11HardwareBuffer::D3D11HardwareBuffer(BufferType btype, UINT32 sizeBytes, HardwareBuffer::Usage usage, 
+	D3D11HardwareBuffer::D3D11HardwareBuffer(BufferType btype, UINT32 sizeBytes, GpuBufferUsage usage, 
 		D3D11Device& device, bool useSystemMemory, bool streamOut)
 		: HardwareBuffer(usage, useSystemMemory),
 		mD3DBuffer(0),
@@ -60,20 +60,20 @@ namespace CamelotEngine
 	}
 
 	void* D3D11HardwareBuffer::lockImpl(UINT32 offset, 
-		UINT32 length, LockOptions options)
+		UINT32 length, GpuLockOptions options)
 	{
 		if (length > mSizeInBytes)
 			CM_EXCEPT(RenderingAPIException, "Provided length " + toString(length) + " larger than the buffer " + toString(mSizeInBytes) + ".");		
 
 		// Use direct (and faster) Map/Unmap if dynamic write, or a staging read/write
-		if((mDesc.Usage == D3D11_USAGE_DYNAMIC && options != HBL_READ_ONLY) || mDesc.Usage == D3D11_USAGE_STAGING)
+		if((mDesc.Usage == D3D11_USAGE_DYNAMIC && options != GBL_READ_ONLY) || mDesc.Usage == D3D11_USAGE_STAGING)
 		{
 			D3D11_MAP mapType;
 
 			switch(options)
 			{
-			case HBL_WRITE_ONLY_DISCARD:
-				if (mUsage & HardwareBuffer::HBU_DYNAMIC)
+			case GBL_WRITE_ONLY_DISCARD:
+				if (mUsage & GBU_DYNAMIC)
 				{
 					// Map cannot be called with MAP_WRITE access, 
 					// because the Resource was created as D3D11_USAGE_DYNAMIC. 
@@ -92,7 +92,7 @@ namespace CamelotEngine
 					LOGWRN("DISCARD lock is only available on dynamic buffers. Falling back to normal write.");
 				}
 				break;
-			case HBL_WRITE_ONLY_NO_OVERWRITE:
+			case GBL_WRITE_ONLY_NO_OVERWRITE:
 				if(mBufferType == INDEX_BUFFER || mBufferType == VERTEX_BUFFER)
 					mapType = D3D11_MAP_WRITE_NO_OVERWRITE;
 				else
@@ -102,7 +102,7 @@ namespace CamelotEngine
 					LOGWRN("NO_OVERWRITE lock is not available on this (" + toString(mBufferType) + ") buffer type. Falling back to normal write.");
 				}
 				break;
-			case HBL_READ_WRITE:
+			case GBL_READ_WRITE:
 				if ((mDesc.CPUAccessFlags & D3D11_CPU_ACCESS_READ) != 0 &&
 					(mDesc.CPUAccessFlags & D3D11_CPU_ACCESS_WRITE) != 0)
 				{
@@ -117,7 +117,7 @@ namespace CamelotEngine
 					mapType = D3D11_MAP_READ;
 				}
 				break;
-			case HBL_READ_ONLY:
+			case GBL_READ_ONLY:
 				mapType = D3D11_MAP_READ;
 				break;
 			}
@@ -154,11 +154,11 @@ namespace CamelotEngine
 			}
 
 			// schedule a copy to the staging
-			if (options != HBL_WRITE_ONLY_DISCARD)
+			if (options != GBL_WRITE_ONLY_DISCARD)
 				mpTempStagingBuffer->copyData(*this, 0, 0, mSizeInBytes, true);
 
 			// register whether we'll need to upload on unlock
-			mStagingUploadNeeded = (options != HBL_READ_ONLY);
+			mStagingUploadNeeded = (options != GBL_READ_ONLY);
 
 			return mpTempStagingBuffer->lock(offset, length, options);
 		}
@@ -229,7 +229,7 @@ namespace CamelotEngine
 	{
 		// There is no functional interface in D3D, just do via manual 
 		// lock, copy & unlock
-		void* pSrc = this->lock(offset, length, HBL_READ_ONLY);
+		void* pSrc = this->lock(offset, length, GBL_READ_ONLY);
 		memcpy(pDest, pSrc, length);
 		this->unlock();
 	}
@@ -240,7 +240,7 @@ namespace CamelotEngine
 		if(mDesc.Usage == D3D11_USAGE_DYNAMIC || mDesc.Usage == D3D11_USAGE_STAGING)
 		{
 			void* pDst = this->lock(offset, length, 
-				discardWholeBuffer ? HBL_WRITE_ONLY_DISCARD : HBL_READ_WRITE);
+				discardWholeBuffer ? GBL_WRITE_ONLY_DISCARD : GBL_READ_WRITE);
 			memcpy(pDst, pSource, length);
 			this->unlock();
 		}

+ 2 - 2
CamelotD3D11RenderSystem/Source/CmD3D11HardwareBufferManager.cpp

@@ -17,7 +17,7 @@ namespace CamelotEngine
 	}
 
 	HardwareVertexBufferPtr D3D11HardwareBufferManagerBase::createVertexBuffer(UINT32 vertexSize, 
-		UINT32 numVerts, HardwareBuffer::Usage usage, bool streamOut)
+		UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
 	{
 		assert (numVerts > 0);
 		D3D11HardwareVertexBuffer* vbuf = new D3D11HardwareVertexBuffer(mDevice,
@@ -30,7 +30,7 @@ namespace CamelotEngine
 	}
 
 	HardwareIndexBufferPtr D3D11HardwareBufferManagerBase::createIndexBuffer(HardwareIndexBuffer::IndexType itype, 
-		UINT32 numIndexes, HardwareBuffer::Usage usage)
+		UINT32 numIndexes, GpuBufferUsage usage)
 	{
 		assert (numIndexes > 0);
 

+ 2 - 2
CamelotD3D11RenderSystem/Source/CmD3D11HardwareConstantBuffer.cpp

@@ -3,7 +3,7 @@
 namespace CamelotEngine
 {
 	D3D11HardwareConstantBuffer::D3D11HardwareConstantBuffer(D3D11Device& device, HardwareBufferManagerBase* mgr, UINT32 sizeBytes, 
-		HardwareBuffer::Usage usage, bool useSystemMem)
+		GpuBufferUsage usage, bool useSystemMem)
 		//:HardwareConstantBuffer(mgr, sizeBytes, usage, useSystemMem)
 	{
 		//mBuffer = new D3D11HardwareBuffer(D3D11HardwareBuffer::CONSTANT_BUFFER, mSizeInBytes, usage, device, useSystemMem, false);
@@ -14,7 +14,7 @@ namespace CamelotEngine
 		delete mBuffer;
 	}
 
-	void* D3D11HardwareConstantBuffer::lockImpl(UINT32 offset, UINT32 length, LockOptions options)
+	void* D3D11HardwareConstantBuffer::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
 	{
 		return mBuffer->lock(offset, length, options);
 	}

+ 2 - 2
CamelotD3D11RenderSystem/Source/CmD3D11HardwareIndexBuffer.cpp

@@ -3,7 +3,7 @@
 namespace CamelotEngine
 {
 	D3D11HardwareIndexBuffer::D3D11HardwareIndexBuffer(D3D11Device& device, HardwareBufferManagerBase* mgr, IndexType idxType, UINT32 numIndexes, 
-		HardwareBuffer::Usage usage, bool useSystemMem)
+		GpuBufferUsage usage, bool useSystemMem)
 		:HardwareIndexBuffer(mgr, idxType, numIndexes, usage, useSystemMem)
 	{
 		mBuffer = new D3D11HardwareBuffer(D3D11HardwareBuffer::INDEX_BUFFER, mSizeInBytes, usage, device, useSystemMem, false);
@@ -14,7 +14,7 @@ namespace CamelotEngine
 		delete mBuffer;
 	}
 
-	void* D3D11HardwareIndexBuffer::lockImpl(UINT32 offset, UINT32 length, LockOptions options)
+	void* D3D11HardwareIndexBuffer::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
 	{
 		return mBuffer->lock(offset, length, options);
 	}

+ 2 - 2
CamelotD3D11RenderSystem/Source/CmD3D11HardwareVertexBuffer.cpp

@@ -3,7 +3,7 @@
 namespace CamelotEngine
 {
 	D3D11HardwareVertexBuffer::D3D11HardwareVertexBuffer(D3D11Device& device, HardwareBufferManagerBase* mgr, UINT32 vertexSize, UINT32 numVertices, 
-		HardwareBuffer::Usage usage, bool useSystemMem, bool streamOut)
+		GpuBufferUsage usage, bool useSystemMem, bool streamOut)
 		:HardwareVertexBuffer(mgr, vertexSize, numVertices, usage, useSystemMem)
 	{
 		mBuffer = new D3D11HardwareBuffer(D3D11HardwareBuffer::VERTEX_BUFFER, mSizeInBytes, usage, device, useSystemMem, streamOut);
@@ -14,7 +14,7 @@ namespace CamelotEngine
 		delete mBuffer;
 	}
 
-	void* D3D11HardwareVertexBuffer::lockImpl(UINT32 offset, UINT32 length, LockOptions options)
+	void* D3D11HardwareVertexBuffer::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
 	{
 		return mBuffer->lock(offset, length, options);
 	}

+ 29 - 59
CamelotD3D11RenderSystem/Source/CmD3D11Mappings.cpp

@@ -259,64 +259,36 @@ namespace CamelotEngine
 		return res;
 	}
 
-	DWORD D3D11Mappings::get(HardwareBuffer::Usage usage)
+	DWORD D3D11Mappings::get(GpuBufferUsage usage)
 	{
-		DWORD ret = 0;
-		if (usage & HardwareBuffer::HBU_DYNAMIC)
-		{
-#if CM_D3D_MANAGE_BUFFERS
-			// Only add the dynamic flag for default pool, and
-			// we use default pool when buffer is discardable
-			if (usage & HardwareBuffer::HBU_DISCARDABLE)
-				ret |= D3D11_USAGE_DYNAMIC;
-#else
-			ret |= D3D11_USAGE_DYNAMIC;
-#endif
-		}
-		if (usage & HardwareBuffer::HBU_WRITE_ONLY)
+		DWORD ret = D3D11_USAGE_DEFAULT;
+
+		if (usage & GBU_DYNAMIC)
 		{
-			ret |= D3D11_USAGE_DYNAMIC;
+			ret = D3D11_USAGE_DYNAMIC;
 		}
+
 		return ret;
 	}
 
-	D3D11_MAP D3D11Mappings::get(LockOptions options, HardwareBuffer::Usage usage)
+	D3D11_MAP D3D11Mappings::get(GpuLockOptions options, GpuBufferUsage usage)
 	{
 		D3D11_MAP ret = D3D11_MAP_READ_WRITE;
-		if (options == HBL_WRITE_ONLY_DISCARD)
+		if (options == GBL_WRITE_ONLY_DISCARD)
 		{
-#if CM_D3D_MANAGE_BUFFERS
-			// Only add the discard flag for dynamic usgae and default pool
-			if ((usage & HardwareBuffer::HBU_DYNAMIC) &&
-				(usage & HardwareBuffer::HBU_DISCARDABLE))
+			// D3D doesn't like discard on non-dynamic buffers
+			if (usage & GBU_DYNAMIC)
 				ret = D3D11_MAP_WRITE_DISCARD;
-#else
-			// D3D doesn't like discard or no_overwrite on non-dynamic buffers
-			if (usage & HardwareBuffer::HBU_DYNAMIC)
-				ret = D3D11_MAP_WRITE_DISCARD;
-#endif
+			else
+				ret = D3D11_MAP_WRITE;
 		}
-		if (options == HBL_READ_ONLY)
+		else if (options == GBL_READ_ONLY)
 		{
-			// D3D debug runtime doesn't like you locking managed buffers readonly
-			// when they were created with write-only (even though you CAN read
-			// from the software backed version)
-			if (!(usage & HardwareBuffer::HBU_WRITE_ONLY))
-				ret = D3D11_MAP_READ;
-
+			ret = D3D11_MAP_READ;
 		}
-		if (options == HBL_WRITE_ONLY_NO_OVERWRITE)
+		else if (options == GBL_WRITE_ONLY_NO_OVERWRITE)
 		{
-#if CM_D3D_MANAGE_BUFFERS
-			// Only add the nooverwrite flag for dynamic usgae and default pool
-			if ((usage & HardwareBuffer::HBU_DYNAMIC) &&
-				(usage & HardwareBuffer::HBU_DISCARDABLE))
-				ret = D3D11_MAP_WRITE_NO_OVERWRITE;
-#else
-			// D3D doesn't like discard or no_overwrite on non-dynamic buffers
-			if (usage & HardwareBuffer::HBU_DYNAMIC)
-				ret = D3D11_MAP_WRITE_NO_OVERWRITE;
-#endif 
+			ret = D3D11_MAP_WRITE_NO_OVERWRITE; // Only allowed for vertex/index buffers
 		}
 
 		return ret;
@@ -731,7 +703,7 @@ namespace CamelotEngine
 		}
 	}
 
-	D3D11_USAGE D3D11Mappings::_getUsage(HardwareBuffer::Usage mUsage)
+	D3D11_USAGE D3D11Mappings::_getUsage(GpuBufferUsage mUsage)
 	{
 		if (_isDynamic(mUsage))
 		{
@@ -743,13 +715,11 @@ namespace CamelotEngine
 		}
 	}
 
-	bool D3D11Mappings::_isDynamic(HardwareBuffer::Usage mUsage)
+	bool D3D11Mappings::_isDynamic(GpuBufferUsage mUsage)
 	{
 		switch ( mUsage)
 		{
-		case HardwareBuffer::HBU_DYNAMIC:
-		case HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY:
-		case HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE:
+		case GBU_DYNAMIC:
 			return true;
 		}
 
@@ -758,7 +728,7 @@ namespace CamelotEngine
 
 	bool D3D11Mappings::_isDynamic(int mUsage)
 	{
-		return _isDynamic(static_cast<HardwareBuffer::Usage>(mUsage));
+		return _isDynamic(static_cast<GpuBufferUsage>(mUsage));
 	}
 
 	bool D3D11Mappings::isMappingWrite(D3D11_MAP map)
@@ -780,15 +750,15 @@ namespace CamelotEngine
 
 	D3D11_USAGE D3D11Mappings::_getUsage(int mUsage)
 	{
-		return _getUsage(static_cast<HardwareBuffer::Usage>(mUsage));
+		return _getUsage(static_cast<GpuBufferUsage>(mUsage));
 	}
 
 	UINT D3D11Mappings::_getAccessFlags(int mUsage)
 	{
-		return _getAccessFlags(static_cast<HardwareBuffer::Usage>(mUsage));
+		return _getAccessFlags(static_cast<GpuBufferUsage>(mUsage));
 	}
 
-	UINT D3D11Mappings::_getAccessFlags(HardwareBuffer::Usage mUsage)
+	UINT D3D11Mappings::_getAccessFlags(GpuBufferUsage mUsage)
 	{
 		if(_isDynamic(mUsage))
 			return D3D11_CPU_ACCESS_WRITE;
@@ -923,23 +893,23 @@ namespace CamelotEngine
 		return flags;
 	}
 
-	D3D11_MAP D3D11Mappings::_getLockOptions(LockOptions lockOptions)
+	D3D11_MAP D3D11Mappings::_getLockOptions(GpuLockOptions lockOptions)
 	{
 		switch(lockOptions)
 		{
-		case HBL_WRITE_ONLY_NO_OVERWRITE:
+		case GBL_WRITE_ONLY_NO_OVERWRITE:
 			return D3D11_MAP_WRITE_NO_OVERWRITE;
 			break;
-		case HBL_READ_WRITE:
+		case GBL_READ_WRITE:
 			return D3D11_MAP_READ_WRITE;
 			break;
-		case HBL_WRITE_ONLY_DISCARD:
+		case GBL_WRITE_ONLY_DISCARD:
 			return D3D11_MAP_WRITE_DISCARD;
 			break;
-		case HBL_READ_ONLY:
+		case GBL_READ_ONLY:
 			return D3D11_MAP_READ;
 			break;
-		case HBL_WRITE_ONLY:
+		case GBL_WRITE_ONLY:
 			return D3D11_MAP_WRITE;
 			break;
 		default: 

+ 6 - 6
CamelotD3D11RenderSystem/Source/CmD3D11Texture.cpp

@@ -49,7 +49,7 @@ namespace CamelotEngine
 		}
 	}
 
-	PixelData D3D11Texture::lockImpl(LockOptions options, UINT32 mipLevel, UINT32 face)
+	PixelData D3D11Texture::lockImpl(GpuLockOptions options, UINT32 mipLevel, UINT32 face)
 	{
 		UINT32 mipWidth = mipLevel >> mWidth;
 		UINT32 mipHeight = mipLevel >> mHeight;
@@ -60,19 +60,19 @@ namespace CamelotEngine
 		D3D11_MAP flags = D3D11Mappings::_getLockOptions(options);
 		switch(options)
 		{
-		case HBL_WRITE_ONLY_NO_OVERWRITE:
+		case GBL_WRITE_ONLY_NO_OVERWRITE:
 			flags = D3D11_MAP_WRITE_NO_OVERWRITE;
 			break;
-		case HBL_READ_WRITE:
+		case GBL_READ_WRITE:
 			flags = D3D11_MAP_READ_WRITE;
 			break;
-		case HBL_WRITE_ONLY_DISCARD:
+		case GBL_WRITE_ONLY_DISCARD:
 			flags = D3D11_MAP_WRITE_DISCARD;
 			break;
-		case HBL_READ_ONLY:
+		case GBL_READ_ONLY:
 			flags = D3D11_MAP_READ;
 			break;
-		case HBL_WRITE_ONLY:
+		case GBL_WRITE_ONLY:
 			flags = D3D11_MAP_WRITE;
 			break;
 		default: 

+ 2 - 2
CamelotD3D9Renderer/Include/CmD3D9HardwareBufferManager.h

@@ -50,13 +50,13 @@ namespace CamelotEngine {
 		 * @copydoc HardwareBufferManagerBase::createVertexBuffer
 		 */
 		HardwareVertexBufferPtr 
-            createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage, bool streamOut = false);
+            createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
 
 		/**
 		 * @copydoc HardwareBufferManagerBase::createIndexBuffer
 		 */
 		HardwareIndexBufferPtr 
-            createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, HardwareBuffer::Usage usage);
+            createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
 
 		/** @copydoc HardwareBufferManagerInterface::createGpuParamBlock */
 		GpuParamBlockPtr createGpuParamBlock(const GpuParamBlockDesc& paramDesc);

+ 3 - 3
CamelotD3D9Renderer/Include/CmD3D9HardwareIndexBuffer.h

@@ -40,7 +40,7 @@ namespace CamelotEngine {
   
     public:
 		D3D9HardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType, UINT32 numIndexes, 
-			HardwareBuffer::Usage usage, bool useSystemMem);
+			GpuBufferUsage usage, bool useSystemMem);
         ~D3D9HardwareIndexBuffer();
         /** See HardwareBuffer. */
         void readData(UINT32 offset, UINT32 length, void* pDest);
@@ -73,13 +73,13 @@ namespace CamelotEngine {
 			bool						mOutOfDate;
 			UINT32						mLockOffset;
 			UINT32						mLockLength;
-			LockOptions					mLockOptions;
+			GpuLockOptions					mLockOptions;
 			UINT32						mLastUsedFrame;
 		};
 
 	protected:
 		/** See HardwareBuffer. */
-		void* lockImpl(UINT32 offset, UINT32 length, LockOptions options);
+		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
 		/** See HardwareBuffer. */
 		void unlockImpl(void);
 		// updates buffer resources from system memory buffer.

+ 2 - 2
CamelotD3D9Renderer/Include/CmD3D9HardwarePixelBuffer.h

@@ -39,7 +39,7 @@ namespace CamelotEngine {
 	class CM_D3D9_EXPORT D3D9HardwarePixelBuffer : public HardwarePixelBuffer
 	{
 	public:
-		D3D9HardwarePixelBuffer(HardwareBuffer::Usage usage, 
+		D3D9HardwarePixelBuffer(GpuBufferUsage usage, 
 			D3D9Texture* ownerTexture);
 		~D3D9HardwarePixelBuffer();
 
@@ -114,7 +114,7 @@ namespace CamelotEngine {
 		CM_STATIC_MUTEX(msDeviceAccessMutex)		
 	protected:
 		/// Lock a box
-		PixelData lockImpl(const Box lockBox,  LockOptions options);
+		PixelData lockImpl(const Box lockBox,  GpuLockOptions options);
 		PixelData lockBuffer(BufferResources* bufferResources, const Box &lockBox, DWORD flags);
 
 		/// Unlock a box

+ 3 - 3
CamelotD3D9Renderer/Include/CmD3D9HardwareVertexBuffer.h

@@ -40,7 +40,7 @@ namespace CamelotEngine {
 
     public:
 		D3D9HardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, 
-			UINT32 numVertices, HardwareBuffer::Usage usage, bool useSystemMem);
+			UINT32 numVertices, GpuBufferUsage usage, bool useSystemMem);
         ~D3D9HardwareVertexBuffer();
         /** See HardwareBuffer. */
         void readData(UINT32 offset, UINT32 length, void* pDest);
@@ -73,13 +73,13 @@ namespace CamelotEngine {
 			bool						mOutOfDate;
 			UINT32						mLockOffset;
 			UINT32						mLockLength;
-			LockOptions					mLockOptions;
+			GpuLockOptions					mLockOptions;
 			UINT32						mLastUsedFrame;
 		};
 
 	protected:		
 		/** See HardwareBuffer. */
-		void* lockImpl(UINT32 offset, UINT32 length, LockOptions options);		
+		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);		
 		/** See HardwareBuffer. */
 		void unlockImpl(void);			
 		// updates buffer resources from system memory buffer.

+ 3 - 3
CamelotD3D9Renderer/Include/CmD3D9Mappings.h

@@ -29,7 +29,7 @@ THE SOFTWARE.
 #define __D3D9MAPPINGS_H__
 
 #include "CmD3D9Prerequisites.h"
-#include "CmCommon.h"
+#include "CmCommonEnums.h"
 #include "CmRenderSystem.h"
 #include "CmHardwareBuffer.h"
 #include "CmHardwareIndexBuffer.h"
@@ -84,9 +84,9 @@ namespace CamelotEngine
 		/// return the D3DtexType equivalent of a Ogre tex. type
 		static eD3DTexType get(TextureType ogreTexType);
         /// return the combination of D3DUSAGE values for Ogre buffer usage
-        static DWORD get(HardwareBuffer::Usage usage);
+        static DWORD get(GpuBufferUsage usage);
         /// Get lock options
-        static DWORD get(LockOptions options, HardwareBuffer::Usage usage);
+        static DWORD get(GpuLockOptions options, GpuBufferUsage usage);
         /// Get index type
         static D3DFORMAT get(HardwareIndexBuffer::IndexType itype);
 		/// Get vertex data type

+ 1 - 1
CamelotD3D9Renderer/Include/CmD3D9Texture.h

@@ -138,7 +138,7 @@ namespace CamelotEngine {
 		/// overridden from Texture
 		void copyImpl(TexturePtr& target);
 
-		PixelData lockImpl(LockOptions options, UINT32 mipLevel = 0, UINT32 face = 0);
+		PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0);
 		void unlockImpl();
 
 		/// internal method, create a blank normal 1D/2D texture		

+ 2 - 2
CamelotD3D9Renderer/Source/CmD3D9HardwareBufferManager.cpp

@@ -45,7 +45,7 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------
     HardwareVertexBufferPtr 
     D3D9HardwareBufferManagerBase::
-    createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage, bool streamOut)
+    createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
     {
 		assert (numVerts > 0);
 
@@ -59,7 +59,7 @@ namespace CamelotEngine {
     //-----------------------------------------------------------------------
 	HardwareIndexBufferPtr 
     D3D9HardwareBufferManagerBase::
-    createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, HardwareBuffer::Usage usage)
+    createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage)
     {
 		assert (numIndexes > 0);
 

+ 9 - 12
CamelotD3D9Renderer/Source/CmD3D9HardwareIndexBuffer.cpp

@@ -37,7 +37,7 @@ namespace CamelotEngine {
 
 	//---------------------------------------------------------------------
     D3D9HardwareIndexBuffer::D3D9HardwareIndexBuffer(HardwareBufferManagerBase* mgr, HardwareIndexBuffer::IndexType idxType, 
-        UINT32 numIndexes, HardwareBuffer::Usage usage,
+        UINT32 numIndexes, GpuBufferUsage usage,
         bool useSystemMemory)
         : HardwareIndexBuffer(mgr, idxType, numIndexes, usage, useSystemMemory)
     {
@@ -46,10 +46,7 @@ namespace CamelotEngine {
 		D3DPOOL eResourcePool;
 
 #if CM_D3D_MANAGE_BUFFERS
-		eResourcePool = useSystemMemory? D3DPOOL_SYSTEMMEM : 
-			// If not system mem, use managed pool UNLESS buffer is discardable
-			// if discardable, keeping the software backing is expensive
-			(usage & HardwareBuffer::HBU_DISCARDABLE)? D3DPOOL_DEFAULT : D3DPOOL_MANAGED;
+		eResourcePool = useSystemMemory ? D3DPOOL_SYSTEMMEM : D3DPOOL_MANAGED;
 #else
 		eResourcePool = useSystemMemory? D3DPOOL_SYSTEMMEM : D3DPOOL_DEFAULT;
 #endif
@@ -90,11 +87,11 @@ namespace CamelotEngine {
     }
 	//---------------------------------------------------------------------
     void* D3D9HardwareIndexBuffer::lockImpl(UINT32 offset, 
-        UINT32 length, LockOptions options)
+        UINT32 length, GpuLockOptions options)
     {		
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
-		if (options != HBL_READ_ONLY)
+		if (options != GBL_READ_ONLY)
 		{
 			DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
 
@@ -119,7 +116,7 @@ namespace CamelotEngine {
 						bufferResources->mLockLength = length;
 				}
 			
-				if (bufferResources->mLockOptions != HBL_WRITE_ONLY_DISCARD)
+				if (bufferResources->mLockOptions != GBL_WRITE_ONLY_DISCARD)
 					bufferResources->mLockOptions = options;
 
 				++it;
@@ -156,7 +153,7 @@ namespace CamelotEngine {
     {
        // There is no functional interface in D3D, just do via manual 
         // lock, copy & unlock
-        void* pSrc = this->lock(offset, length, HBL_READ_ONLY);
+        void* pSrc = this->lock(offset, length, GBL_READ_ONLY);
         memcpy(pDest, pSrc, length);
         this->unlock();
 
@@ -169,7 +166,7 @@ namespace CamelotEngine {
         // There is no functional interface in D3D, just do via manual 
         // lock, copy & unlock
         void* pDst = this->lock(offset, length, 
-            discardWholeBuffer ? HBL_WRITE_ONLY_DISCARD : HBL_READ_WRITE);
+            discardWholeBuffer ? GBL_WRITE_ONLY_DISCARD : GBL_READ_WRITE);
         memcpy(pDst, pSource, length);
         this->unlock();    
 	}
@@ -246,7 +243,7 @@ namespace CamelotEngine {
 		bufferResources->mOutOfDate = true;
 		bufferResources->mLockOffset = 0;
 		bufferResources->mLockLength = getSizeInBytes();
-		bufferResources->mLockOptions = HBL_READ_WRITE;
+		bufferResources->mLockOptions = GBL_READ_WRITE;
 		// TODO PORT - I don't know current frame number. Once I add a method for counting frames call it here
 		//bufferResources->mLastUsedFrame = Root::getSingleton().getNextFrameNumber();
 		bufferResources->mLastUsedFrame = 0;
@@ -337,7 +334,7 @@ namespace CamelotEngine {
 		bufferResources->mOutOfDate = false;
 		bufferResources->mLockOffset = mSizeInBytes;
 		bufferResources->mLockLength = 0;
-		bufferResources->mLockOptions = HBL_READ_WRITE;
+		bufferResources->mLockOptions = GBL_READ_WRITE;
 
 		return true;			
 	}

+ 5 - 5
CamelotD3D9Renderer/Source/CmD3D9HardwarePixelBuffer.cpp

@@ -37,7 +37,7 @@ namespace CamelotEngine
 	CM_STATIC_MUTEX_INSTANCE(D3D9HardwarePixelBuffer::msDeviceAccessMutex)
 	//-----------------------------------------------------------------------------  
 
-	D3D9HardwarePixelBuffer::D3D9HardwarePixelBuffer(HardwareBuffer::Usage usage, 
+	D3D9HardwarePixelBuffer::D3D9HardwarePixelBuffer(GpuBufferUsage usage, 
 													 D3D9Texture* ownerTexture):
 		HardwarePixelBuffer(0, 0, 0, PF_UNKNOWN, usage, false),
 		mDoMipmapGen(0), mHWMipmaps(0), mOwnerTexture(ownerTexture)
@@ -317,7 +317,7 @@ namespace CamelotEngine
 		return pbox;
 	}
 	//-----------------------------------------------------------------------------  
-	PixelData D3D9HardwarePixelBuffer::lockImpl(const Box lockBox,  LockOptions options)
+	PixelData D3D9HardwarePixelBuffer::lockImpl(const Box lockBox,  GpuLockOptions options)
 	{	
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
@@ -328,13 +328,13 @@ namespace CamelotEngine
 		DWORD flags = 0;
 		switch(options)
 		{
-		case HBL_WRITE_ONLY_DISCARD:
+		case GBL_WRITE_ONLY_DISCARD:
 			// D3D only likes D3DLOCK_DISCARD if you created the texture with D3DUSAGE_DYNAMIC
 			// debug runtime flags this up, could cause problems on some drivers
-			if (mUsage & HBU_DYNAMIC)
+			if (mUsage & GBU_DYNAMIC)
 				flags |= D3DLOCK_DISCARD;
 			break;
-		case HBL_READ_ONLY:
+		case GBL_READ_ONLY:
 			flags |= D3DLOCK_READONLY;
 			break;
 		default: 

+ 9 - 12
CamelotD3D9Renderer/Source/CmD3D9HardwareVertexBuffer.cpp

@@ -37,7 +37,7 @@ namespace CamelotEngine {
 
 	//---------------------------------------------------------------------
     D3D9HardwareVertexBuffer::D3D9HardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, 
-        UINT32 numVertices, HardwareBuffer::Usage usage, 
+        UINT32 numVertices, GpuBufferUsage usage, 
         bool useSystemMemory)
 		: HardwareVertexBuffer(mgr, vertexSize, numVertices, usage, useSystemMemory)
     {
@@ -46,10 +46,7 @@ namespace CamelotEngine {
 		D3DPOOL eResourcePool;
 		       
 #if CM_D3D_MANAGE_BUFFERS
-		eResourcePool = useSystemMemory? D3DPOOL_SYSTEMMEM : 
-			// If not system mem, use managed pool UNLESS buffer is discardable
-			// if discardable, keeping the software backing is expensive
-			(usage & HardwareBuffer::HBU_DISCARDABLE)? D3DPOOL_DEFAULT : D3DPOOL_MANAGED;
+		eResourcePool = useSystemMemory? D3DPOOL_SYSTEMMEM : D3DPOOL_MANAGED;
 #else
 		eResourcePool = useSystemMemory? D3DPOOL_SYSTEMMEM : D3DPOOL_DEFAULT;
 #endif       		
@@ -90,11 +87,11 @@ namespace CamelotEngine {
     }
 	//---------------------------------------------------------------------
     void* D3D9HardwareVertexBuffer::lockImpl(UINT32 offset, 
-        UINT32 length, LockOptions options)
+        UINT32 length, GpuLockOptions options)
     {		
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
-		if (options != HBL_READ_ONLY)
+		if (options != GBL_READ_ONLY)
 		{
 			DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
 
@@ -119,7 +116,7 @@ namespace CamelotEngine {
 						bufferResources->mLockLength = length;
 				}
 				
-				if (bufferResources->mLockOptions != HBL_WRITE_ONLY_DISCARD)
+				if (bufferResources->mLockOptions != GBL_WRITE_ONLY_DISCARD)
 					bufferResources->mLockOptions = options;					
 
 				++it;
@@ -156,7 +153,7 @@ namespace CamelotEngine {
     {
         // There is no functional interface in D3D, just do via manual 
         // lock, copy & unlock
-        void* pSrc = this->lock(offset, length, HBL_READ_ONLY);
+        void* pSrc = this->lock(offset, length, GBL_READ_ONLY);
         memcpy(pDest, pSrc, length);
         this->unlock();
 
@@ -169,7 +166,7 @@ namespace CamelotEngine {
 		// There is no functional interface in D3D, just do via manual 
 		// lock, copy & unlock
 		void* pDst = this->lock(offset, length, 
-			discardWholeBuffer ? HBL_WRITE_ONLY_DISCARD : HBL_READ_WRITE);
+			discardWholeBuffer ? GBL_WRITE_ONLY_DISCARD : GBL_READ_WRITE);
 		memcpy(pDst, pSource, length);
 		this->unlock();
 	}
@@ -245,7 +242,7 @@ namespace CamelotEngine {
 		bufferResources->mOutOfDate = true;
 		bufferResources->mLockOffset = 0;
 		bufferResources->mLockLength = getSizeInBytes();
-		bufferResources->mLockOptions = HBL_READ_WRITE;
+		bufferResources->mLockOptions = GBL_READ_WRITE;
 
 		// TODO PORT - Don't know what the next frame number is. Add a method for that
 		//bufferResources->mLastUsedFrame = Root::getSingleton().getNextFrameNumber();
@@ -336,7 +333,7 @@ namespace CamelotEngine {
 		bufferResources->mOutOfDate = false;
 		bufferResources->mLockOffset = mSizeInBytes;
 		bufferResources->mLockLength = 0;
-		bufferResources->mLockOptions = HBL_READ_WRITE;
+		bufferResources->mLockOptions = GBL_READ_WRITE;
 
 		return true;		
 	}

+ 17 - 30
CamelotD3D9Renderer/Source/CmD3D9Mappings.cpp

@@ -308,62 +308,49 @@ namespace CamelotEngine
 		return D3D9Mappings::D3D_TEX_TYPE_NONE;
 	}
 	//---------------------------------------------------------------------
-    DWORD D3D9Mappings::get(HardwareBuffer::Usage usage)
+    DWORD D3D9Mappings::get(GpuBufferUsage usage)
     {
         DWORD ret = 0;
-        if (usage & HardwareBuffer::HBU_DYNAMIC)
+        if (usage & GBU_DYNAMIC)
         {
 #if CM_D3D_MANAGE_BUFFERS
-            // Only add the dynamic flag for default pool, and
-            // we use default pool when buffer is discardable
-            if (usage & HardwareBuffer::HBU_DISCARDABLE)
-                ret |= D3DUSAGE_DYNAMIC;
+            // Not allowed to used dynamic on managed pool
 #else
             ret |= D3DUSAGE_DYNAMIC;
 #endif
         }
-        if (usage & HardwareBuffer::HBU_WRITE_ONLY)
-        {
-            ret |= D3DUSAGE_WRITEONLY;
-        }
+
         return ret;
     }
 	//---------------------------------------------------------------------
-    DWORD D3D9Mappings::get(LockOptions options, HardwareBuffer::Usage usage)
+    DWORD D3D9Mappings::get(GpuLockOptions options, GpuBufferUsage usage)
     {
         DWORD ret = 0;
-        if (options == HBL_WRITE_ONLY_DISCARD)
+        if (options == GBL_WRITE_ONLY_DISCARD)
         {
 #if CM_D3D_MANAGE_BUFFERS
-            // Only add the discard flag for dynamic usgae and default pool
-            if ((usage & HardwareBuffer::HBU_DYNAMIC) &&
-                (usage & HardwareBuffer::HBU_DISCARDABLE))
-                ret |= D3DLOCK_DISCARD;
+			// Cannot use discard with a non-dynamic buffer, and we know buffer is not dynamic
+			// since we are using managed buffers (which don't support dynamic buffers)
 #else
             // D3D doesn't like discard or no_overwrite on non-dynamic buffers
-            if (usage & HardwareBuffer::HBU_DYNAMIC)
+            if (usage & GBU_DYNAMIC)
                 ret |= D3DLOCK_DISCARD;
 #endif
         }
-        if (options == HBL_READ_ONLY)
+        
+		if (options == GBL_READ_ONLY)
         {
-			// D3D debug runtime doesn't like you locking managed buffers readonly
-			// when they were created with write-only (even though you CAN read
-			// from the software backed version)
-			if (!(usage & HardwareBuffer::HBU_WRITE_ONLY))
-				ret |= D3DLOCK_READONLY;
-
+			ret |= D3DLOCK_READONLY;
         }
-        if (options == HBL_WRITE_ONLY_NO_OVERWRITE)
+
+        if (options == GBL_WRITE_ONLY_NO_OVERWRITE)
         {
 #if CM_D3D_MANAGE_BUFFERS
-            // Only add the nooverwrite flag for dynamic usgae and default pool
-            if ((usage & HardwareBuffer::HBU_DYNAMIC) &&
-                (usage & HardwareBuffer::HBU_DISCARDABLE))
-                ret |= D3DLOCK_NOOVERWRITE;
+			// Cannot use no overwrite with a non-dynamic buffer, and we know buffer is not dynamic
+			// since we are using managed buffers (which don't support dynamic buffers)
 #else
             // D3D doesn't like discard or no_overwrite on non-dynamic buffers
-            if (usage & HardwareBuffer::HBU_DYNAMIC)
+            if (usage & GBU_DYNAMIC)
                 ret |= D3DLOCK_NOOVERWRITE;
 #endif 
         }

+ 4 - 4
CamelotD3D9Renderer/Source/CmD3D9Texture.cpp

@@ -80,7 +80,7 @@ namespace CamelotEngine
 		mSurfaceList.clear();		
 	}
 	/****************************************************************************************/
-	PixelData D3D9Texture::lockImpl(LockOptions options, UINT32 mipLevel, UINT32 face)
+	PixelData D3D9Texture::lockImpl(GpuLockOptions options, UINT32 mipLevel, UINT32 face)
 	{
 		if(mLockedBuffer != nullptr)
 			CM_EXCEPT(InternalErrorException, "Trying to lock a buffer that's already locked.");
@@ -951,11 +951,11 @@ namespace CamelotEngine
 		unsigned int bufusage;
 		if ((mUsage & TU_DYNAMIC) && mDynamicTextures)
 		{
-			bufusage = HardwareBuffer::HBU_DYNAMIC;
+			bufusage = GBU_DYNAMIC;
 		}
 		else
 		{
-			bufusage = HardwareBuffer::HBU_STATIC;
+			bufusage = GBU_STATIC;
 		}
 		if (mUsage & TU_RENDERTARGET)
 		{
@@ -972,7 +972,7 @@ namespace CamelotEngine
 			{
 				for(UINT32 mip=0; mip<=mNumMipmaps; ++mip)
 				{
-					buffer = new D3D9HardwarePixelBuffer((HardwareBuffer::Usage)bufusage, this);
+					buffer = new D3D9HardwarePixelBuffer((GpuBufferUsage)bufusage, this);
 					mSurfaceList.push_back(HardwarePixelBufferPtr(buffer));
 				}
 			}

+ 2 - 2
CamelotGLRenderer/Include/CmGLHardwareBufferManager.h

@@ -53,14 +53,14 @@ namespace CamelotEngine {
 		 * @copydoc HardwareBufferManagerBase::createVertexBuffer
 		 */
         HardwareVertexBufferPtr createVertexBuffer(UINT32 vertexSize, 
-            UINT32 numVerts, HardwareBuffer::Usage usage, bool streamOut = false);
+            UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
 
 		/**
 		 * @copydoc HardwareBufferManagerBase::createIndexBuffer
 		 */
         HardwareIndexBufferPtr createIndexBuffer(
             HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
-            HardwareBuffer::Usage usage);
+            GpuBufferUsage usage);
 
 		/** @copydoc HardwareBufferManagerInterface::createGpuParamBlock */
 		GpuParamBlockPtr createGpuParamBlock(const GpuParamBlockDesc& paramDesc);

+ 2 - 2
CamelotGLRenderer/Include/CmGLHardwareIndexBuffer.h

@@ -46,12 +46,12 @@ namespace CamelotEngine {
 		bool mScratchUploadOnUnlock;
     protected:
         /** See HardwareBuffer. */
-        void* lockImpl(UINT32 offset, UINT32 length, LockOptions options);
+        void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
         /** See HardwareBuffer. */
         void unlockImpl(void);
     public:
         GLHardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType, UINT32 numIndexes, 
-            HardwareBuffer::Usage usage); 
+            GpuBufferUsage usage); 
         ~GLHardwareIndexBuffer();
         /** See HardwareBuffer. */
         void readData(UINT32 offset, UINT32 length, void* pDest);

+ 4 - 4
CamelotGLRenderer/Include/CmGLHardwarePixelBuffer.h

@@ -36,7 +36,7 @@ namespace CamelotEngine {
 	{
 	protected:  
 		/// Lock a box
-		PixelData lockImpl(const Box lockBox,  LockOptions options);
+		PixelData lockImpl(const Box lockBox,  GpuLockOptions options);
 
 		/// Unlock a box
 		void unlockImpl(void);
@@ -45,7 +45,7 @@ namespace CamelotEngine {
 		// depending on buffer usage
 		PixelData mBuffer;
         GLenum mGLInternalFormat; // GL internal format
-		LockOptions mCurrentLockOptions;
+		GpuLockOptions mCurrentLockOptions;
 		
 		// Buffer allocation/freeage
 		void allocateBuffer();
@@ -58,7 +58,7 @@ namespace CamelotEngine {
         /// Should be called by HardwareBufferManager
         GLHardwarePixelBuffer(UINT32 mWidth, UINT32 mHeight, UINT32 mDepth,
                 PixelFormat mFormat,
-                HardwareBuffer::Usage usage);
+                GpuBufferUsage usage);
 		
 		/// @copydoc HardwarePixelBuffer::blitFromMemory
 		void blitFromMemory(const PixelData &src, const Box &dstBox);
@@ -81,7 +81,7 @@ namespace CamelotEngine {
     public:
         /** Texture constructor */
 		GLTextureBuffer(const String &baseName, GLenum target, GLuint id, GLint face, 
-			GLint level, Usage usage, bool softwareMipmap, bool writeGamma, UINT32 fsaa);
+			GLint level, GpuBufferUsage usage, bool softwareMipmap, bool writeGamma, UINT32 fsaa);
         ~GLTextureBuffer();
         
         /// @copydoc HardwarePixelBuffer::bindToFramebuffer

+ 2 - 3
CamelotGLRenderer/Include/CmGLHardwareVertexBuffer.h

@@ -47,12 +47,11 @@ namespace CamelotEngine {
 
     protected:
         /** See HardwareBuffer. */
-        void* lockImpl(UINT32 offset, UINT32 length, LockOptions options);
+        void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
         /** See HardwareBuffer. */
         void unlockImpl(void);
     public:
-        GLHardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, UINT32 numVertices, 
-            HardwareBuffer::Usage usage); 
+        GLHardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage); 
         ~GLHardwareVertexBuffer();
         /** See HardwareBuffer. */
         void readData(UINT32 offset, UINT32 length, void* pDest);

+ 1 - 1
CamelotGLRenderer/Include/CmGLTexture.h

@@ -71,7 +71,7 @@ namespace CamelotEngine {
 
 		void initialize_internal();
 
-		PixelData lockImpl(LockOptions options, UINT32 mipLevel, UINT32 face);
+		PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel, UINT32 face);
 		void unlockImpl();
 
 		void copyImpl(TexturePtr& target);

+ 4 - 8
CamelotGLRenderer/Source/CmGLHardwareBufferManager.cpp

@@ -82,7 +82,7 @@ namespace CamelotEngine {
     }
     //-----------------------------------------------------------------------
     HardwareVertexBufferPtr GLHardwareBufferManagerBase::createVertexBuffer(
-        UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage, bool streamOut)
+        UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
     {
 		GLHardwareVertexBuffer* buf = 
 			new GLHardwareVertexBuffer(this, vertexSize, numVerts, usage);
@@ -95,7 +95,7 @@ namespace CamelotEngine {
     HardwareIndexBufferPtr 
     GLHardwareBufferManagerBase::createIndexBuffer(
         HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
-        HardwareBuffer::Usage usage)
+        GpuBufferUsage usage)
     {
 		GLHardwareIndexBuffer* buf = 
 			new GLHardwareIndexBuffer(this, itype, numIndexes, usage);
@@ -114,14 +114,10 @@ namespace CamelotEngine {
     {
         switch(usage)
         {
-        case HardwareBuffer::HBU_STATIC:
-        case HardwareBuffer::HBU_STATIC_WRITE_ONLY:
+        case GBU_STATIC:
             return GL_STATIC_DRAW_ARB;
-        case HardwareBuffer::HBU_DYNAMIC:
-        case HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY:
+        case GBU_DYNAMIC:
             return GL_DYNAMIC_DRAW_ARB;
-        case HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE:
-            return GL_STREAM_DRAW_ARB;
         default:
             return GL_DYNAMIC_DRAW_ARB;
         };

+ 7 - 7
CamelotGLRenderer/Source/CmGLHardwareIndexBuffer.cpp

@@ -33,7 +33,7 @@ namespace CamelotEngine {
 
 	//---------------------------------------------------------------------
     GLHardwareIndexBuffer::GLHardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType,
-        UINT32 numIndexes, HardwareBuffer::Usage usage)
+        UINT32 numIndexes, GpuBufferUsage usage)
         : HardwareIndexBuffer(mgr, idxType, numIndexes, usage, false)
     {
         glGenBuffersARB( 1, &mBufferId );
@@ -59,7 +59,7 @@ namespace CamelotEngine {
     }
 	//---------------------------------------------------------------------
     void* GLHardwareIndexBuffer::lockImpl(UINT32 offset, 
-        UINT32 length, LockOptions options)
+        UINT32 length, GpuLockOptions options)
     {
         GLenum access = 0;
 
@@ -84,9 +84,9 @@ namespace CamelotEngine {
 				mScratchOffset = offset;
 				mScratchSize = length;
 				mScratchPtr = retPtr;
-				mScratchUploadOnUnlock = (options != HBL_READ_ONLY);
+				mScratchUploadOnUnlock = (options != GBL_READ_ONLY);
 
-				if (options != HBL_WRITE_ONLY_DISCARD)
+				if (options != GBL_WRITE_ONLY_DISCARD)
 				{
 					// have to read back the data before returning the pointer
 					readData(offset, length, retPtr);
@@ -98,15 +98,15 @@ namespace CamelotEngine {
 		{
 			glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId );
 			// Use glMapBuffer
-			if(options == HBL_WRITE_ONLY_DISCARD)
+			if(options == GBL_WRITE_ONLY_DISCARD)
 			{
 				// Discard the buffer
 				glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mSizeInBytes, NULL, 
 					GLHardwareBufferManager::getGLUsage(mUsage));
 			}
-			if (mUsage & HBU_WRITE_ONLY)
+			if (options == GBL_WRITE_ONLY || options == GBL_WRITE_ONLY_NO_OVERWRITE)
 				access = GL_WRITE_ONLY_ARB;
-			else if (options == HBL_READ_ONLY)
+			else if (options == GBL_READ_ONLY)
 				access = GL_READ_ONLY_ARB;
 			else
 				access = GL_READ_WRITE_ARB;

+ 9 - 9
CamelotGLRenderer/Source/CmGLHardwarePixelBuffer.cpp

@@ -38,12 +38,12 @@ namespace CamelotEngine
 	//----------------------------------------------------------------------------- 
 	GLHardwarePixelBuffer::GLHardwarePixelBuffer(UINT32 inWidth, UINT32 inHeight, UINT32 inDepth,
 					PixelFormat inFormat,
-					HardwareBuffer::Usage usage):
+					GpuBufferUsage usage):
 		  HardwarePixelBuffer(inWidth, inHeight, inDepth, inFormat, usage, false),
 		  mBuffer(inWidth, inHeight, inDepth, inFormat),
 		  mGLInternalFormat(GL_NONE)
 	{
-		mCurrentLockOptions = (LockOptions)0;
+		mCurrentLockOptions = (GpuLockOptions)0;
 	}
 
 	//-----------------------------------------------------------------------------  
@@ -65,17 +65,17 @@ namespace CamelotEngine
 	void GLHardwarePixelBuffer::freeBuffer()
 	{
 		// Free buffer if we're STATIC to save memory
-		if(mUsage & HBU_STATIC)
+		if(mUsage & GBU_STATIC)
 		{
 			delete [] (UINT8*)mBuffer.data;
 			mBuffer.data = 0;
 		}
 	}
 	//-----------------------------------------------------------------------------  
-	PixelData GLHardwarePixelBuffer::lockImpl(const Box lockBox,  LockOptions options)
+	PixelData GLHardwarePixelBuffer::lockImpl(const Box lockBox,  GpuLockOptions options)
 	{
 		allocateBuffer();
-		if(options != HBL_WRITE_ONLY_DISCARD) 
+		if(options != GBL_WRITE_ONLY_DISCARD) 
 		{
 			// Download the old contents of the texture
 			download(mBuffer);
@@ -87,7 +87,7 @@ namespace CamelotEngine
 	//-----------------------------------------------------------------------------  
 	void GLHardwarePixelBuffer::unlockImpl(void)
 	{
-		if (mCurrentLockOptions != HBL_READ_ONLY)
+		if (mCurrentLockOptions != GBL_READ_ONLY)
 		{
 			// From buffer to card, only upload if was locked for writing
 			upload(mCurrentLock, mLockedBox);
@@ -188,7 +188,7 @@ namespace CamelotEngine
 	}
 	//********* GLTextureBuffer
 	GLTextureBuffer::GLTextureBuffer(const String &baseName, GLenum target, GLuint id, 
-									 GLint face, GLint level, Usage usage, bool crappyCard, 
+									 GLint face, GLint level, GpuBufferUsage usage, bool crappyCard, 
 									 bool writeGamma, UINT32 fsaa):
 		GLHardwarePixelBuffer(0, 0, 0, PF_UNKNOWN, usage),
 		mTarget(target), mFaceTarget(0), mTextureID(id), mFace(face), mLevel(level),
@@ -731,7 +731,7 @@ namespace CamelotEngine
 			glTexImage2D(target, 0, format, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
 
 		/// GL texture buffer
-		GLTextureBuffer tex(StringUtil::BLANK, target, id, 0, 0, (Usage)(HBU_STATIC_WRITE_ONLY), false, false, 0);
+		GLTextureBuffer tex(StringUtil::BLANK, target, id, 0, 0, (GpuBufferUsage)(GBU_STATIC), false, false, 0);
     
 		/// Upload data to 0,0,0 in temporary texture
 		Box tempTarget(0, 0, 0, src.getWidth(), src.getHeight(), src.getDepth());
@@ -749,7 +749,7 @@ namespace CamelotEngine
 	//********* GLRenderBuffer
 	//----------------------------------------------------------------------------- 
 	GLRenderBuffer::GLRenderBuffer(GLenum format, UINT32 width, UINT32 height, GLsizei numSamples):
-		GLHardwarePixelBuffer(width, height, 1, GLPixelUtil::getClosestEngineFormat(format),HBU_WRITE_ONLY),
+		GLHardwarePixelBuffer(width, height, 1, GLPixelUtil::getClosestEngineFormat(format), GBU_DYNAMIC),
 		mRenderbufferID(0)
 	{
 		mGLInternalFormat = format;

+ 7 - 7
CamelotGLRenderer/Source/CmGLHardwareVertexBuffer.cpp

@@ -33,7 +33,7 @@ namespace CamelotEngine {
 
 	//---------------------------------------------------------------------
     GLHardwareVertexBuffer::GLHardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, 
-        UINT32 numVertices, HardwareBuffer::Usage usage)
+        UINT32 numVertices, GpuBufferUsage usage)
         : HardwareVertexBuffer(mgr, vertexSize, numVertices, usage, false)
     {
         glGenBuffersARB( 1, &mBufferId );
@@ -59,7 +59,7 @@ namespace CamelotEngine {
     }
 	//---------------------------------------------------------------------
     void* GLHardwareVertexBuffer::lockImpl(UINT32 offset, 
-        UINT32 length, LockOptions options)
+        UINT32 length, GpuLockOptions options)
     {
         GLenum access = 0;
 
@@ -86,9 +86,9 @@ namespace CamelotEngine {
 				mScratchOffset = offset;
 				mScratchSize = length;
 				mScratchPtr = retPtr;
-				mScratchUploadOnUnlock = (options != HBL_READ_ONLY);
+				mScratchUploadOnUnlock = (options != GBL_READ_ONLY);
 
-				if (options != HBL_WRITE_ONLY_DISCARD)
+				if (options != GBL_WRITE_ONLY_DISCARD)
 				{
 					// have to read back the data before returning the pointer
 					readData(offset, length, retPtr);
@@ -101,16 +101,16 @@ namespace CamelotEngine {
 			// Use glMapBuffer
 			glBindBufferARB( GL_ARRAY_BUFFER_ARB, mBufferId );
 			// Use glMapBuffer
-			if(options == HBL_WRITE_ONLY_DISCARD)
+			if(options == GBL_WRITE_ONLY_DISCARD)
 			{
 				// Discard the buffer
 				glBufferDataARB(GL_ARRAY_BUFFER_ARB, mSizeInBytes, NULL, 
 					GLHardwareBufferManager::getGLUsage(mUsage));
 
 			}
-			if (mUsage & HBU_WRITE_ONLY)
+			if ((options == GBL_WRITE_ONLY) || (options == GBL_WRITE_ONLY_NO_OVERWRITE))
 				access = GL_WRITE_ONLY_ARB;
-			else if (options == HBL_READ_ONLY)
+			else if (options == GBL_READ_ONLY)
 				access = GL_READ_ONLY_ARB;
 			else
 				access = GL_READ_WRITE_ARB;

+ 2 - 2
CamelotGLRenderer/Source/CmGLTexture.cpp

@@ -105,7 +105,7 @@ namespace CamelotEngine {
 	}
 
 	//* Creation / loading methods ********************************************
-	PixelData GLTexture::lockImpl(LockOptions options, UINT32 mipLevel, UINT32 face)
+	PixelData GLTexture::lockImpl(GpuLockOptions options, UINT32 mipLevel, UINT32 face)
 	{
 		if(mLockedBuffer != nullptr)
 			CM_EXCEPT(InternalErrorException, "Trying to lock a buffer that's already locked.");
@@ -269,7 +269,7 @@ namespace CamelotEngine {
 			for(UINT32 mip=0; mip<=getNumMipmaps(); mip++)
 			{
                 GLHardwarePixelBuffer *buf = new GLTextureBuffer("", getGLTextureTarget(), mTextureID, face, mip,
-						static_cast<HardwareBuffer::Usage>(mUsage), false, mHwGamma, mFSAA);
+						static_cast<GpuBufferUsage>(mUsage), false, mHwGamma, mFSAA);
 				mSurfaceList.push_back(HardwarePixelBufferPtr(buf));
                 
                 /// Check for error

+ 3 - 1
CamelotRenderer/CamelotRenderer.vcxproj

@@ -184,13 +184,14 @@
     <ClInclude Include="Include\CmCgProgramFactory.h" />
     <ClInclude Include="Include\CmCgProgramRTTI.h" />
     <ClInclude Include="Include\CmCommandQueue.h" />
-    <ClInclude Include="Include\CmCommon.h" />
+    <ClInclude Include="Include\CmCommonEnums.h" />
     <ClInclude Include="Include\CmComponentRTTI.h" />
     <ClInclude Include="Include\CmConfigOptionMap.h" />
     <ClInclude Include="Include\CmDeferredRenderContext.h" />
     <ClInclude Include="Include\CmDepthStencilBuffer.h" />
     <ClInclude Include="Include\CmDepthStencilStateRTTI.h" />
     <ClInclude Include="Include\CmDepthStencilState.h" />
+    <ClInclude Include="Include\CmGenericBuffer.h" />
     <ClInclude Include="Include\CmGpuParamBlock.h" />
     <ClInclude Include="Include\CmGpuParamDesc.h" />
     <ClInclude Include="Include\CmGpuParams.h" />
@@ -277,6 +278,7 @@
     <ClCompile Include="Source\CmDeferredRenderContext.cpp" />
     <ClCompile Include="Source\CmDepthStencilBuffer.cpp" />
     <ClCompile Include="Source\CmDepthStencilState.cpp" />
+    <ClCompile Include="Source\CmGenericBuffer.cpp" />
     <ClCompile Include="Source\CmGpuParamBlock.cpp" />
     <ClCompile Include="Source\CmGpuParams.cpp" />
     <ClCompile Include="Source\CmGpuProgram.cpp" />

+ 9 - 3
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -92,9 +92,6 @@
     <ClInclude Include="Include\CmConfigOptionMap.h">
       <Filter>Header Files\ForRemoval</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmCommon.h">
-      <Filter>Header Files\Utility</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmWindowEventUtilities.h">
       <Filter>Header Files\Utility</Filter>
     </ClInclude>
@@ -356,6 +353,12 @@
     <ClInclude Include="Include\CmVertexDeclaration.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmGenericBuffer.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmCommonEnums.h">
+      <Filter>Header Files\Utility</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CamelotRenderer.cpp">
@@ -535,5 +538,8 @@
     <ClCompile Include="Source\CmVertexDeclaration.cpp">
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
+    <ClCompile Include="Source\CmGenericBuffer.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 1 - 1
CamelotRenderer/Include/CmBlendState.h

@@ -2,7 +2,7 @@
 
 #include "CmPrerequisites.h"
 #include "CmIReflectable.h"
-#include "CmCommon.h"
+#include "CmCommonEnums.h"
 
 namespace CamelotEngine
 {

+ 1 - 1
CamelotRenderer/Include/CmCamera.h

@@ -41,7 +41,7 @@ THE SOFTWARE.
 #include "CmVertexIndexData.h"
 #include "CmPlane.h"
 #include "CmQuaternion.h"
-#include "CmCommon.h"
+#include "CmCommonEnums.h"
 #include "CmRay.h"
 #include "CmComponent.h"
 

+ 1 - 1
CamelotRenderer/Include/CmCommandQueue.h

@@ -2,7 +2,7 @@
 
 #include "CmPrerequisites.h"
 #include "CmAsyncOp.h"
-#include "CmCommon.h"
+#include "CmCommonEnums.h"
 #include "boost/function.hpp"
 
 namespace CamelotEngine

+ 19 - 7
CamelotRenderer/Include/CmCommon.h → CamelotRenderer/Include/CmCommonEnums.h

@@ -204,24 +204,36 @@ namespace CamelotEngine {
 	};
 
 	/// Locking options
-	enum LockOptions
+	enum GpuLockOptions
 	{
         /** Normal mode, ie allows read/write and contents are preserved. */
-        HBL_READ_WRITE,
+        GBL_READ_WRITE,
 		/** Discards the <em>entire</em> buffer while locking; this allows optimisation to be 
 		performed because synchronisation issues are relaxed. 
 		*/
-		HBL_WRITE_ONLY_DISCARD,
+		GBL_WRITE_ONLY_DISCARD,
 		/** Lock the buffer for reading only. Not allowed in buffers which are created with HBU_WRITE_ONLY. 
 		*/ 
-		HBL_READ_ONLY,
+		GBL_READ_ONLY,
         /** As HBL_NORMAL, except the application guarantees not to overwrite any 
         region of the buffer which has already been used in this frame, can allow
         some optimisation on some APIs. */
-        HBL_WRITE_ONLY_NO_OVERWRITE,
+        GBL_WRITE_ONLY_NO_OVERWRITE,
 		/** Lock for writing only */
-		HBL_WRITE_ONLY
-    			
+		GBL_WRITE_ONLY	
+	};
+
+	/// Enums describing buffer usage; not mutually exclusive
+	enum GpuBufferUsage 
+	{
+        /** Static buffer which the application rarely modifies once created. Modifying 
+        the contents of this buffer will involve a performance hit.
+        */
+        GBU_STATIC = 1,
+		/** Indicates the application would like to modify this buffer with the CPU
+		fairly often. 
+		*/
+		GBU_DYNAMIC = 2,
 	};
 
 	/** Texture addressing mode for each texture coordinate. */

+ 1 - 1
CamelotRenderer/Include/CmDeferredRenderContext.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include "CmPrerequisites.h"
-#include "CmCommon.h"
+#include "CmCommonEnums.h"
 #include "CmSamplerState.h"
 #include "CmGpuProgram.h"
 #include "CmColor.h"

+ 1 - 1
CamelotRenderer/Include/CmDepthStencilState.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include "CmPrerequisites.h"
-#include "CmCommon.h"
+#include "CmCommonEnums.h"
 #include "CmIReflectable.h"
 
 namespace CamelotEngine

+ 38 - 0
CamelotRenderer/Include/CmGenericBuffer.h

@@ -0,0 +1,38 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmCommonEnums.h"
+
+namespace CamelotEngine 
+{
+	enum GenericBufferType
+	{
+		GBT_STRUCTURED,
+		GBT_RAW,
+		GBT_INDIRECTARGUMENT,
+		GBT_APPENDCONSUME
+	};
+
+	class CM_EXPORT GenericBuffer
+    {
+    public:
+        GenericBuffer(GenericBufferType type, GpuBufferUsage usage)
+			:mType(type), mUsage(usage)
+        {  }
+        virtual ~GenericBuffer() {}
+
+
+		virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options) = 0;
+		virtual void unlock() = 0;
+
+        virtual void readData(UINT32 offset, UINT32 length, void* pDest) = 0;
+        virtual void writeData(UINT32 offset, UINT32 length, const void* pSource, bool discardWholeBuffer = false) = 0;
+
+		virtual void copyData(GenericBuffer& srcBuffer, UINT32 srcOffset, 
+			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false) = 0;
+
+	private:
+		GenericBufferType mType;
+		GpuBufferUsage mUsage;
+    };
+}

+ 10 - 54
CamelotRenderer/Include/CmHardwareBuffer.h

@@ -30,10 +30,10 @@ THE SOFTWARE.
 
 // Precompiler options
 #include "CmPrerequisites.h"
-#include "CmCommon.h"
-
-namespace CamelotEngine {
+#include "CmCommonEnums.h"
 
+namespace CamelotEngine 
+{
 	/** \addtogroup Core
 	*  @{
 	*/
@@ -73,66 +73,22 @@ namespace CamelotEngine {
     */
 	class CM_EXPORT HardwareBuffer
     {
-
-	    public:
-		    /// Enums describing buffer usage; not mutually exclusive
-		    enum Usage 
-		    {
-                /** Static buffer which the application rarely modifies once created. Modifying 
-                the contents of this buffer will involve a performance hit.
-                */
-                HBU_STATIC = 1,
-			    /** Indicates the application would like to modify this buffer with the CPU
-			    fairly often. 
-			    Buffers created with this flag will typically end up in AGP memory rather 
-			    than video memory.
-			    */
-			    HBU_DYNAMIC = 2,
-			    /** Indicates the application will never read the contents of the buffer back, 
-			    it will only ever write data. Locking a buffer with this flag will ALWAYS 
-			    return a pointer to new, blank memory rather than the memory associated 
-			    with the contents of the buffer; this avoids DMA stalls because you can 
-			    write to a new memory area while the previous one is being used. 
-			    */
-			    HBU_WRITE_ONLY = 4,
-                /** Indicates that the application will be refilling the contents
-                of the buffer regularly (not just updating, but generating the
-                contents from scratch), and therefore does not mind if the contents 
-                of the buffer are lost somehow and need to be recreated. This
-                allows and additional level of optimisation on the buffer.
-                This option only really makes sense when combined with 
-                HBU_DYNAMIC_WRITE_ONLY.
-                */
-                HBU_DISCARDABLE = 8,
-				/// Combination of HBU_STATIC and HBU_WRITE_ONLY
-				HBU_STATIC_WRITE_ONLY = 5, 
-				/** Combination of HBU_DYNAMIC and HBU_WRITE_ONLY. If you use 
-                this, strongly consider using HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE
-                instead if you update the entire contents of the buffer very 
-                regularly. 
-                */
-				HBU_DYNAMIC_WRITE_ONLY = 6,
-                /// Combination of HBU_DYNAMIC, HBU_WRITE_ONLY and HBU_DISCARDABLE
-                HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE = 14
-
-
-		    };
 	    protected:
 		    UINT32 mSizeInBytes;
-		    Usage mUsage;
+		    GpuBufferUsage mUsage;
 		    bool mIsLocked;
 			UINT32 mLockStart;
 			UINT32 mLockSize;
 			bool mSystemMemory;
     		
             /// Internal implementation of lock()
-		    virtual void* lockImpl(UINT32 offset, UINT32 length, LockOptions options) = 0;
+		    virtual void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) = 0;
             /// Internal implementation of unlock()
 		    virtual void unlockImpl(void) = 0;
 
     public:
 		    /// Constructor, to be called by HardwareBufferManager only
-            HardwareBuffer(Usage usage, bool systemMemory) 
+            HardwareBuffer(GpuBufferUsage usage, bool systemMemory) 
 				: mUsage(usage), mIsLocked(false), mSystemMemory(systemMemory)
             {  }
             virtual ~HardwareBuffer() {}
@@ -142,7 +98,7 @@ namespace CamelotEngine {
 		    @param options Locking options
 		    @returns Pointer to the locked memory
 		    */
-		    virtual void* lock(UINT32 offset, UINT32 length, LockOptions options)
+		    virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options)
             {
                 assert(!isLocked() && "Cannot lock this buffer, it is already locked!");
                 void* ret = lockImpl(offset, length, options);
@@ -157,7 +113,7 @@ namespace CamelotEngine {
 		    @param options Locking options
 		    @returns Pointer to the locked memory
             */
-            void* lock(LockOptions options)
+            void* lock(GpuLockOptions options)
             {
                 return this->lock(0, mSizeInBytes, options);
             }
@@ -213,7 +169,7 @@ namespace CamelotEngine {
 				UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false)
 			{
 				const void *srcData = srcBuffer.lock(
-					srcOffset, length, HBL_READ_ONLY);
+					srcOffset, length, GBL_READ_ONLY);
 				this->writeData(dstOffset, length, srcData, discardWholeBuffer);
 				srcBuffer.unlock();
 			}
@@ -232,7 +188,7 @@ namespace CamelotEngine {
             /// Returns the size of this buffer in bytes
             UINT32 getSizeInBytes(void) const { return mSizeInBytes; }
             /// Returns the Usage flags with which this buffer was created
-            Usage getUsage(void) const { return mUsage; }
+            GpuBufferUsage getUsage(void) const { return mUsage; }
 			/// Returns whether this buffer is held in system memory
 			bool isSystemMemory(void) const { return mSystemMemory; }
             /// Returns whether or not this buffer is currently locked.

+ 4 - 4
CamelotRenderer/Include/CmHardwareBufferManager.h

@@ -110,7 +110,7 @@ namespace CamelotEngine {
 			geometry shader.
         */
 		virtual HardwareVertexBufferPtr 
-            createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage, bool streamOut = false) = 0;
+            createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false) = 0;
 		/** Create a hardware index buffer.
         @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
@@ -122,7 +122,7 @@ namespace CamelotEngine {
         */
 		virtual HardwareIndexBufferPtr 
             createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, 
-			HardwareBuffer::Usage usage) = 0;
+			GpuBufferUsage usage) = 0;
 
 		/**
 		 * @brief	Creates an GPU parameter block that you can use for setting parameters
@@ -156,12 +156,12 @@ namespace CamelotEngine {
 		~HardwareBufferManager();
 
 		/** @copydoc HardwareBufferManagerInterface::createVertexBuffer */
-		HardwareVertexBufferPtr createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, HardwareBuffer::Usage usage, bool streamOut = false)
+		HardwareVertexBufferPtr createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false)
 		{
 			return mImpl->createVertexBuffer(vertexSize, numVerts, usage, streamOut);
 		}
 		/** @copydoc HardwareBufferManagerInterface::createIndexBuffer */
-		HardwareIndexBufferPtr createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, HardwareBuffer::Usage usage)
+		HardwareIndexBufferPtr createIndexBuffer(HardwareIndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage)
 		{
 			return mImpl->createIndexBuffer(itype, numIndexes, usage);
 		}

+ 1 - 1
CamelotRenderer/Include/CmHardwareIndexBuffer.h

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

+ 5 - 6
CamelotRenderer/Include/CmHardwarePixelBuffer.h

@@ -62,18 +62,17 @@ namespace CamelotEngine {
 		Box mLockedBox;
         
         /// Internal implementation of lock(), must be overridden in subclasses
-        virtual PixelData lockImpl(const Box lockBox,  LockOptions options) = 0;
+        virtual PixelData lockImpl(const Box lockBox,  GpuLockOptions options) = 0;
 
         /// Internal implementation of lock(), do not OVERRIDE or CALL this
         /// for HardwarePixelBuffer implementations, but override the previous method
-        virtual void* lockImpl(UINT32 offset, UINT32 length, LockOptions options);
+        virtual void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
 
 		friend class RenderTexture;
     public:
         /// Should be called by HardwareBufferManager
         HardwarePixelBuffer(UINT32 mWidth, UINT32 mHeight, UINT32 mDepth,
-                PixelFormat mFormat,
-                HardwareBuffer::Usage usage, bool useSystemMemory);
+                PixelFormat mFormat, GpuBufferUsage usage, bool useSystemMemory);
         ~HardwarePixelBuffer();
 
         /** make every lock method from HardwareBuffer available.
@@ -87,9 +86,9 @@ namespace CamelotEngine {
 		    @returns PixelBox containing the locked region, the pitches and
 		    	the pixel format
 		*/
-		virtual const PixelData& lock(const Box& lockBox, LockOptions options);
+		virtual const PixelData& lock(const Box& lockBox, GpuLockOptions options);
 		/// @copydoc HardwareBuffer::lock
-        virtual void* lock(UINT32 offset, UINT32 length, LockOptions options);
+        virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options);
 
 		/** Get the current locked region. This is the same value as returned
 		    by lock(const Image::Box, LockOptions)

+ 1 - 1
CamelotRenderer/Include/CmHardwareVertexBuffer.h

@@ -54,7 +54,7 @@ namespace CamelotEngine {
 	    public:
 		    /// Should be called by HardwareBufferManager
 		    HardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize, UINT32 numVertices,
-                HardwareBuffer::Usage usage, bool useSystemMemory);
+                GpuBufferUsage usage, bool useSystemMemory);
             ~HardwareVertexBuffer();
 			/// Return the manager of this buffer, if any
 			HardwareBufferManagerBase* getManager() const { return mMgr; }

+ 1 - 1
CamelotRenderer/Include/CmPass.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include "CmPrerequisites.h"
-#include "CmCommon.h"
+#include "CmCommonEnums.h"
 #include "CmColor.h"
 #include "CmIReflectable.h"
 

+ 1 - 1
CamelotRenderer/Include/CmRasterizerState.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include "CmPrerequisites.h"
-#include "CmCommon.h"
+#include "CmCommonEnums.h"
 #include "CmIReflectable.h"
 
 namespace CamelotEngine

+ 1 - 1
CamelotRenderer/Include/CmRenderSystem.h

@@ -36,7 +36,7 @@ THE SOFTWARE.
 #include "CmString.h"
 
 #include "CmSamplerState.h"
-#include "CmCommon.h"
+#include "CmCommonEnums.h"
 
 #include "CmRenderOperation.h"
 #include "CmRenderSystemCapabilities.h"

+ 1 - 1
CamelotRenderer/Include/CmSamplerState.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include "CmPrerequisites.h"
-#include "CmCommon.h"
+#include "CmCommonEnums.h"
 #include "CmMatrix4.h"
 #include "CmString.h"
 #include "CmPixelUtil.h"

+ 4 - 4
CamelotRenderer/Include/CmTexture.h

@@ -46,8 +46,8 @@ namespace CamelotEngine {
     enum TextureUsage
     {
 		/// @copydoc HardwareBuffer::Usage
-		TU_STATIC = HardwareBuffer::HBU_STATIC, // Optimal setting if texture is read by the GPU often, and very rarely written by CPU
-		TU_DYNAMIC = HardwareBuffer::HBU_DYNAMIC, // Optimal if the texture is updated by CPU often (e.g. every frame)
+		TU_STATIC = GBU_STATIC, // Optimal setting if texture is read by the GPU often, and very rarely written by CPU
+		TU_DYNAMIC = GBU_DYNAMIC, // Optimal if the texture is updated by CPU often (e.g. every frame)
 		TU_RENDERTARGET = 0x200, // Used for rendering by the GPU
 		TU_DEFAULT = TU_STATIC
     };
@@ -199,7 +199,7 @@ namespace CamelotEngine {
 		 */
 		virtual void getRawPixels_internal(UINT32 face, UINT32 mip, AsyncOp& op);
 
-		PixelData lock(LockOptions options, UINT32 mipLevel = 0, UINT32 face = 0);
+		PixelData lock(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0);
 		void unlock();
 
 		/** Copies the contents of this texture to
@@ -238,7 +238,7 @@ namespace CamelotEngine {
 		 */
 		virtual void initialize_internal() = 0;
 
-		virtual PixelData lockImpl(LockOptions options, UINT32 mipLevel = 0, UINT32 face = 0) = 0;
+		virtual PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0) = 0;
 		virtual void unlockImpl() = 0;
 
 		virtual void copyImpl(TexturePtr& target) = 0;

+ 1 - 1
CamelotRenderer/Include/CmVertexIndexData.h

@@ -42,7 +42,7 @@ namespace CamelotEngine {
 	*/
 
 	/// Define a list of usage flags
-	typedef vector<HardwareBuffer::Usage>::type BufferUsageList;
+	typedef vector<GpuBufferUsage>::type BufferUsageList;
 
 
 	/** Summary class collecting together vertex source information. */

+ 1 - 1
CamelotRenderer/Include/CmViewport.h

@@ -29,7 +29,7 @@ THE SOFTWARE.
 #define __Viewport_H__
 
 #include "CmPrerequisites.h"
-#include "CmCommon.h"
+#include "CmCommonEnums.h"
 #include "CmColor.h"
 
 namespace CamelotEngine {

+ 6 - 0
CamelotRenderer/Source/CmGenericBuffer.cpp

@@ -0,0 +1,6 @@
+#include "CmGenericBuffer.h"
+
+namespace CamelotEngine
+{
+
+}

+ 1 - 1
CamelotRenderer/Source/CmHardwareIndexBuffer.cpp

@@ -33,7 +33,7 @@ namespace CamelotEngine {
 
     //-----------------------------------------------------------------------------
     HardwareIndexBuffer::HardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType, 
-        UINT32 numIndexes, HardwareBuffer::Usage usage, 
+        UINT32 numIndexes, GpuBufferUsage usage, 
         bool useSystemMemory) 
         : HardwareBuffer(usage, useSystemMemory)
 		, mMgr(mgr)

+ 7 - 7
CamelotRenderer/Source/CmHardwarePixelBuffer.cpp

@@ -34,7 +34,7 @@ namespace CamelotEngine
     //-----------------------------------------------------------------------------    
     HardwarePixelBuffer::HardwarePixelBuffer(UINT32 width, UINT32 height, UINT32 depth,
             PixelFormat format,
-            HardwareBuffer::Usage usage, bool useSystemMemory):
+            GpuBufferUsage usage, bool useSystemMemory):
         HardwareBuffer(usage, useSystemMemory),
         mWidth(width), mHeight(height), mDepth(depth),
         mFormat(format)
@@ -51,7 +51,7 @@ namespace CamelotEngine
     }
     
     //-----------------------------------------------------------------------------    
-    void* HardwarePixelBuffer::lock(UINT32 offset, UINT32 length, LockOptions options)
+    void* HardwarePixelBuffer::lock(UINT32 offset, UINT32 length, GpuLockOptions options)
     {
         assert(!isLocked() && "Cannot lock this buffer, it is already locked!");
         assert(offset == 0 && length == mSizeInBytes && "Cannot lock memory region, most lock box or entire buffer");
@@ -62,7 +62,7 @@ namespace CamelotEngine
     }
     
     //-----------------------------------------------------------------------------    
-    const PixelData& HardwarePixelBuffer::lock(const Box& lockBox, LockOptions options)
+    const PixelData& HardwarePixelBuffer::lock(const Box& lockBox, GpuLockOptions options)
     {
         // Lock the real buffer if there is no shadow buffer 
         mCurrentLock = lockImpl(lockBox, options);
@@ -81,7 +81,7 @@ namespace CamelotEngine
     
     //-----------------------------------------------------------------------------    
     /// Internal implementation of lock()
-    void* HardwarePixelBuffer::lockImpl(UINT32 offset, UINT32 length, LockOptions options)
+    void* HardwarePixelBuffer::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
     {
 		CM_EXCEPT(InternalErrorException, "lockImpl(offset,length) is not valid for PixelBuffers and should never be called");
     }
@@ -100,14 +100,14 @@ namespace CamelotEngine
 			CM_EXCEPT(InternalErrorException,
                 "Source must not be the same object") ;
 		}
-		const PixelData &srclock = src->lock(srcBox, HBL_READ_ONLY);
+		const PixelData &srclock = src->lock(srcBox, GBL_READ_ONLY);
 
-		LockOptions method = HBL_READ_WRITE;
+		GpuLockOptions method = GBL_READ_WRITE;
 		if(dstBox.left == 0 && dstBox.top == 0 && dstBox.front == 0 &&
 		   dstBox.right == mWidth && dstBox.bottom == mHeight &&
 		   dstBox.back == mDepth)
 			// Entire buffer -- we can discard the previous contents
-			method = HBL_WRITE_ONLY_DISCARD;
+			method = GBL_WRITE_ONLY_DISCARD;
 			
 		const PixelData &dstlock = lock(dstBox, method);
 		if(dstlock.getWidth() != srclock.getWidth() ||

+ 1 - 1
CamelotRenderer/Source/CmHardwareVertexBuffer.cpp

@@ -37,7 +37,7 @@ namespace CamelotEngine {
 
     //-----------------------------------------------------------------------------
     HardwareVertexBuffer::HardwareVertexBuffer(HardwareBufferManagerBase* mgr, UINT32 vertexSize,  
-        UINT32 numVertices, HardwareBuffer::Usage usage, 
+        UINT32 numVertices, GpuBufferUsage usage, 
         bool useSystemMemory) 
         : HardwareBuffer(usage, useSystemMemory), 
 		  mMgr(mgr),

+ 6 - 6
CamelotRenderer/Source/CmMesh.cpp

@@ -58,9 +58,9 @@ namespace CamelotEngine
 		mIndexData->indexBuffer = HardwareBufferManager::instance().createIndexBuffer(
 			HardwareIndexBuffer::IT_32BIT,
 			mIndexData->indexCount, 
-			HardwareBuffer::HBU_STATIC_WRITE_ONLY);
+			GBU_STATIC);
 
-		UINT32* idxData = static_cast<UINT32*>(mIndexData->indexBuffer->lock(HBL_READ_WRITE));
+		UINT32* idxData = static_cast<UINT32*>(mIndexData->indexBuffer->lock(GBL_READ_WRITE));
 
 		for(UINT32 i = 0; i < mIndexData->indexCount; i++)
 		{
@@ -84,12 +84,12 @@ namespace CamelotEngine
 			HardwareVertexBufferPtr vertexBuffer = HardwareBufferManager::instance().createVertexBuffer(
 				mVertexData->vertexDeclaration->getVertexSize(streamIdx),
 				mVertexData->vertexCount,
-				HardwareBuffer::HBU_STATIC_WRITE_ONLY);
+				GBU_STATIC);
 
 			mVertexData->vertexBufferBinding->setBinding(streamIdx, vertexBuffer);
 
 			UINT32 vertexSize = vertexBuffer->getVertexSize();
-			UINT8* vertBufferData = static_cast<UINT8*>(vertexBuffer->lock(HBL_READ_WRITE));
+			UINT8* vertBufferData = static_cast<UINT8*>(vertexBuffer->lock(GBL_READ_WRITE));
 
 			UINT32 numElements = mVertexData->vertexDeclaration->getElementCount();
 
@@ -192,7 +192,7 @@ namespace CamelotEngine
 			meshData->indexCount = mIndexData->indexCount - mIndexData->indexStart;
 			meshData->index = new int[meshData->indexCount];
 
-			UINT16* idxData = static_cast<UINT16*>(mIndexData->indexBuffer->lock(HBL_READ_ONLY));
+			UINT16* idxData = static_cast<UINT16*>(mIndexData->indexBuffer->lock(GBL_READ_ONLY));
 
 			for(UINT32 i = 0; i < mIndexData->indexCount; i++)
 				meshData->index[i] = (UINT32)idxData[i];
@@ -212,7 +212,7 @@ namespace CamelotEngine
 
 				HardwareVertexBufferPtr vertexBuffer = mVertexData->vertexBufferBinding->getBuffer(i);
 				UINT32 vertexSize = vertexBuffer->getVertexSize();
-				UINT8* vertDataIter = static_cast<UINT8*>(vertexBuffer->lock(HBL_READ_ONLY));
+				UINT8* vertDataIter = static_cast<UINT8*>(vertexBuffer->lock(GBL_READ_ONLY));
 
 				std::shared_ptr<MeshData::VertexData> vertexData(new MeshData::VertexData(meshData->vertexCount, i));
 				meshData->vertexBuffers[i] = vertexData;

+ 3 - 3
CamelotRenderer/Source/CmTexture.cpp

@@ -118,7 +118,7 @@ namespace CamelotEngine {
 
 	void Texture::setRawPixels_internal(const PixelData& data, UINT32 face, UINT32 mip)
 	{
-		PixelData myData = lock(HBL_WRITE_ONLY_DISCARD, mip, face);
+		PixelData myData = lock(GBL_WRITE_ONLY_DISCARD, mip, face);
 		memcpy(myData.data, data.data, data.getConsecutiveSize());
 		unlock();
 	}
@@ -156,7 +156,7 @@ namespace CamelotEngine {
 		UINT8* buffer = new UINT8[totalSize]; 
 		PixelDataPtr dst(new PixelData(width, height, depth, getFormat(), buffer, true));
 
-		PixelData myData = lock(HBL_READ_ONLY, mip, face);
+		PixelData myData = lock(GBL_READ_ONLY, mip, face);
 
 #if CM_DEBUG_MODE
 		if(dst->getConsecutiveSize() != myData.getConsecutiveSize())
@@ -172,7 +172,7 @@ namespace CamelotEngine {
 		op.completeOperation(dst);
 	}
 	//----------------------------------------------------------------------------
-	PixelData Texture::lock(LockOptions options, UINT32 mipLevel, UINT32 face)
+	PixelData Texture::lock(GpuLockOptions options, UINT32 mipLevel, UINT32 face)
 	{
 		THROW_IF_NOT_RENDER_THREAD;
 

+ 11 - 25
CamelotRenderer/Source/CmVertexIndexData.cpp

@@ -159,7 +159,7 @@ namespace CamelotEngine {
                 itBinding->second->getVertexSize();
             oldBufferLocks[itBinding->first] =
                 itBinding->second->lock(
-                    HBL_READ_ONLY);
+                    GBL_READ_ONLY);
         }
 		
 		// Create new buffers and lock all for writing
@@ -177,7 +177,7 @@ namespace CamelotEngine {
 
             newBufferVertexSizes.push_back(vertexSize);
 			newBufferLocks.push_back(
-				vbuf->lock(HBL_WRITE_ONLY_DISCARD));
+				vbuf->lock(GBL_WRITE_ONLY_DISCARD));
 			buf++;
 		}
 
@@ -263,8 +263,7 @@ namespace CamelotEngine {
             VertexDeclaration::VertexElementList destElems = newDeclaration->findElementsBySource(b);
             // Initialise with most restrictive version 
             // (not really a usable option, but these flags will be removed)
-            HardwareBuffer::Usage final = static_cast<HardwareBuffer::Usage>(
-                HardwareBuffer::HBU_STATIC_WRITE_ONLY | HardwareBuffer::HBU_DISCARDABLE);
+            GpuBufferUsage final = static_cast<GpuBufferUsage>(GBU_STATIC);
             VertexDeclaration::VertexElementList::iterator v;
             for (v = destElems.begin(); v != destElems.end(); ++v)
             {
@@ -277,28 +276,15 @@ namespace CamelotEngine {
                 HardwareVertexBufferPtr srcbuf = 
                     vertexBufferBinding->getBuffer(srcelem->getSource());
                 // improve flexibility only
-                if (srcbuf->getUsage() & HardwareBuffer::HBU_DYNAMIC)
+                if (srcbuf->getUsage() & GBU_DYNAMIC)
                 {
                     // remove static
-                    final = static_cast<HardwareBuffer::Usage>(
-                        final & ~HardwareBuffer::HBU_STATIC);
+                    final = static_cast<GpuBufferUsage>(
+                        final & ~GBU_STATIC);
                     // add dynamic
-                    final = static_cast<HardwareBuffer::Usage>(
-                        final | HardwareBuffer::HBU_DYNAMIC);
+                    final = static_cast<GpuBufferUsage>(
+                        final | GBU_DYNAMIC);
                 }
-                if (!(srcbuf->getUsage() & HardwareBuffer::HBU_WRITE_ONLY))
-                {
-                    // remove write only
-                    final = static_cast<HardwareBuffer::Usage>(
-                        final & ~HardwareBuffer::HBU_WRITE_ONLY);
-                }
-                if (!(srcbuf->getUsage() & HardwareBuffer::HBU_DISCARDABLE))
-                {
-                    // remove discardable
-                    final = static_cast<HardwareBuffer::Usage>(
-                        final & ~HardwareBuffer::HBU_DISCARDABLE);
-                }
-                
             }
             usages.push_back(final);
         }
@@ -413,7 +399,7 @@ namespace CamelotEngine {
 
 			if (conversionNeeded)
 			{
-				void* pBase = bindi->second->lock(HBL_READ_WRITE);
+				void* pBase = bindi->second->lock(GBL_READ_WRITE);
 
 				for (UINT32 v = 0; v < bindi->second->getNumVertices(); ++v)
 				{
@@ -591,7 +577,7 @@ namespace CamelotEngine {
 	{
 		if (indexBuffer->isLocked()) return;
 
-		void *buffer = indexBuffer->lock(HBL_READ_WRITE);
+		void *buffer = indexBuffer->lock(GBL_READ_WRITE);
 
 		Triangle* triangles;
 		UINT32 *dest;
@@ -698,7 +684,7 @@ namespace CamelotEngine {
     {
 		if (indexBuffer->isLocked()) return;
 
-		UINT16 *shortbuffer = (UINT16 *)indexBuffer->lock(HBL_READ_ONLY);
+		UINT16 *shortbuffer = (UINT16 *)indexBuffer->lock(GBL_READ_ONLY);
 
 		if (indexBuffer->getType() == HardwareIndexBuffer::IT_16BIT)
 			for (unsigned int i = 0; i < indexBuffer->getNumIndexes(); ++i)

+ 28 - 26
CamelotRenderer/TODO.txt

@@ -68,37 +68,39 @@ Figure out how to handle accessing texture from a non-render thread?
 
 
 RenderSystem needed modifications
- - Right now HLSL11 CANNOT SPECIFY TEXTURE PARAMETERS! (Pass needs to be extended)
- - Generic buffers (Normal/Structured/Raw/Append/Consume/Indirect)
- - Unordered access view for OM and CS stages (this should probably just be a flag .enableRandomWrite on Texture & Buffer classes)
- - Ability to bind buffers and texture with different type of view (SHADER_RESOURCE & UNORDERED_ACCESS primarily, major others too)
- - Pass needs to be modified
-  - Needs to support bool/double/texture1D/textue3D/textureCUBE/texture arrays/MS textures/all types of buffers/structs
-  - Needs to support (*void) data type for setting structs in constant buffers
- - TextureBuffer support? (Use for bones when skinning for exaple, as constant buffers are too slow)
- - RW buffers?
- - Tesselation (hull/domain) shader
- - Compute pipeline
- - Stream out (write vertex buffers)
- - Instancing (DrawInstanced, also check DrawIndirect)
- - Dynamic shader linkage (Interfaces and similar)
- - Append/Consume buffer
- - 1D/2D/Cube texture arrays
- - Rendertargets that aren't just 2D (Volumetric (3D) render targets in particular)
- - Readable DepthStencil (needs to be assignable to a shader)
- - Multisampled texture resources
- - Multiple adapters (multi gpu)
- - DX11 allows detachable and reusable depthStencil buffers but right now DX9 and OpenGL just ignore them
-   - Also RenderWindow can't have detachable depth stencil buffers for multiple reasons:
-     - Resizing a window requires a resize of the depth/stencil buffer, so what to do if the buffer is external?
-	 - OpenGL doesn't allow access to primary window buffer anyway
-	 - Is there any situation where I actually need to set primary depth buffer?
+ - High priority
+  - Generic buffers (Normal/Structured/Raw/Append/Consume/Indirect)
+  - Unordered access view for OM and CS stages (this should probably just be a flag .enableRandomWrite on Texture & Buffer classes)
+  - Pass needs to be modified
+   - Needs to support bool/double/texture1D/textue3D/textureCUBE/texture arrays/MS textures/all types of buffers/structs
+   - Needs to support (*void) data type for setting structs in constant buffers
+  - Right now HLSL11 CANNOT SPECIFY TEXTURE PARAMETERS! (Pass needs to be extended)
+  - Tesselation (hull/domain) shader
+  - Stream out (write vertex buffers)
+  - Append/Consume buffer
+  - Instancing (DrawInstanced, also check DrawIndirect)
+  - 1D/2D/Cube texture arrays
+  - Rendertargets that aren't just 2D (Volumetric (3D) render targets in particular)
+  - DX11 allows detachable and reusable depthStencil buffers but right now DX9 and OpenGL just ignore them
+	- Also RenderWindow can't have detachable depth stencil buffers for multiple reasons:
+		- Resizing a window requires a resize of the depth/stencil buffer, so what to do if the buffer is external?
+		- OpenGL doesn't allow access to primary window buffer anyway
+		- Is there any situation where I actually need to set primary depth buffer?
  - Process OpenGL and make sure to equivalents of DX11 features
   - Exact features that are missing (not an exhaustive list):
     - Vertex buffer stream out (Transform Feedback)
-	- GL constant buffers
+	- Instancing
 	- HLSL11 shader equivalents (domain/hull/compute shaders), and advanced shader parameters
  - HLSL9/HLSL11/GLSL/Cg shaders need preprocessor defines & includes
+ - Low priority
+  - Compute pipeline
+  - Dynamic shader linkage (Interfaces and similar)
+  - Multisampled texture resources
+  - Multiple adapters (multi gpu)
+  - Texture buffers 
+    - Essentially a glorified 1D texture, but they don't have 1D texture size limitations
+
+
 
 Command buffer TODO:
  - When importing a resource, and registering it with Resources I don't think it properly gets added to the loaded resources array? For some reason shaders get created twice.