Kaynağa Gözat

Added NoOverwrite support for all render system index/buffers

Marko Pintera 12 yıl önce
ebeveyn
işleme
a2ca5247a4
34 değiştirilmiş dosya ile 198 ekleme ve 350 silme
  1. 2 2
      CamelotClient/CamelotClient.cpp
  2. 19 0
      CamelotCore/Include/CmCommonEnums.h
  3. 1 1
      CamelotCore/Include/CmGpuBuffer.h
  4. 6 3
      CamelotCore/Include/CmHardwareBuffer.h
  5. 1 2
      CamelotCore/Include/CmPixelBuffer.h
  6. 3 3
      CamelotCore/Source/CmMesh.cpp
  7. 4 4
      CamelotCore/Source/CmMeshHeap.cpp
  8. 1 2
      CamelotCore/Source/CmPixelBuffer.cpp
  9. 1 1
      CamelotD3D11RenderSystem/Include/CmD3D11GpuBuffer.h
  10. 1 2
      CamelotD3D11RenderSystem/Include/CmD3D11HardwareBuffer.h
  11. 1 2
      CamelotD3D11RenderSystem/Include/CmD3D11IndexBuffer.h
  12. 0 5
      CamelotD3D11RenderSystem/Include/CmD3D11Prerequisites.h
  13. 1 2
      CamelotD3D11RenderSystem/Include/CmD3D11VertexBuffer.h
  14. 2 2
      CamelotD3D11RenderSystem/Source/CmD3D11GpuBuffer.cpp
  15. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11GpuParamBlockBuffer.cpp
  16. 8 4
      CamelotD3D11RenderSystem/Source/CmD3D11HardwareBuffer.cpp
  17. 2 2
      CamelotD3D11RenderSystem/Source/CmD3D11IndexBuffer.cpp
  18. 2 2
      CamelotD3D11RenderSystem/Source/CmD3D11VertexBuffer.cpp
  19. 1 1
      CamelotD3D9Renderer/Include/CmD3D9GpuBuffer.h
  20. 1 2
      CamelotD3D9Renderer/Include/CmD3D9IndexBuffer.h
  21. 0 5
      CamelotD3D9Renderer/Include/CmD3D9Prerequisites.h
  22. 1 2
      CamelotD3D9Renderer/Include/CmD3D9VertexBuffer.h
  23. 1 1
      CamelotD3D9Renderer/Source/CmD3D9GpuBuffer.cpp
  24. 9 11
      CamelotD3D9Renderer/Source/CmD3D9IndexBuffer.cpp
  25. 0 14
      CamelotD3D9Renderer/Source/CmD3D9Mappings.cpp
  26. 9 11
      CamelotD3D9Renderer/Source/CmD3D9VertexBuffer.cpp
  27. 1 1
      CamelotGLRenderer/Include/CmGLGpuBuffer.h
  28. 5 17
      CamelotGLRenderer/Include/CmGLIndexBuffer.h
  29. 3 12
      CamelotGLRenderer/Include/CmGLVertexBuffer.h
  30. 1 1
      CamelotGLRenderer/Source/CmGLGpuBuffer.cpp
  31. 4 4
      CamelotGLRenderer/Source/CmGLHardwareBufferManager.cpp
  32. 50 111
      CamelotGLRenderer/Source/CmGLIndexBuffer.cpp
  33. 52 117
      CamelotGLRenderer/Source/CmGLVertexBuffer.cpp
  34. 4 0
      Notes.txt

+ 2 - 2
CamelotClient/CamelotClient.cpp

@@ -35,8 +35,8 @@
 #include "CmRTTIType.h"
 #include "CmPlatform.h"
 
-#define DX11
-//#define DX9
+//#define DX11
+#define DX9
 //#define GL
 
 using namespace CamelotFramework;

+ 19 - 0
CamelotCore/Include/CmCommonEnums.h

@@ -315,6 +315,25 @@ namespace CamelotFramework {
 		GPOT_UNKNOWN = 0xffff
 	};
 
+	/**
+	 * @brief	These values represent a hint to the driver when writing
+	 * 			to a GPU buffer.
+	 * 			
+	 *			Normal - Default flag with least restrictions. Can cause a CPU-GPU sync point
+	 *			so avoid using it often (i.e. every frame) as that might limit your performance significantly.
+	 *			Discard - Tells the driver to completely discard the contents of the buffer you are writing
+	 *			to. The driver will (most likely) internally allocate another buffer with same specifications (which is fairly fast)
+	 *			and you will avoid CPU-GPU stalls. 
+	 *			NoOverwrite - Guarantees the driver that you will not be updating any part of the buffer that is currently used.
+	 *			This will also avoid CPU-GPU stalls, without requiring you to discard the entire buffer. However it is hard to
+	 *			guarantee when GPU has finished using a buffer.
+	 */
+	enum class BufferWriteType
+	{
+		Normal,
+		Discard,
+		NoOverwrite
+	};
 
 	/** Texture addressing mode for each texture coordinate. */
 	struct UVWAddressingMode

+ 1 - 1
CamelotCore/Include/CmGpuBuffer.h

@@ -16,7 +16,7 @@ namespace CamelotFramework
 		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 writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal) = 0;
 
 		virtual void copyData(GpuBuffer& srcBuffer, UINT32 srcOffset, 
 			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false) = 0;

+ 6 - 3
CamelotCore/Include/CmHardwareBuffer.h

@@ -150,10 +150,13 @@ namespace CamelotFramework
 		    @param length The size of the data to write to, in bytes
             @param pSource The source of the data to be written
 			@param discardWholeBuffer If true, this allows the driver to discard the entire buffer when writing,
-				such that DMA stalls can be avoided; use if you can.
+				such that stalls can be avoided. Always use when you can.
+			@param noOverwrite If true, you are guaranteeing to the driver that you will not write to any area of the
+				buffer the GPU is currently using. This will avoid stalls. Be aware that guaranteeing that
+				something isn't used on the GPU is problematic.
             */
             virtual void writeData(UINT32 offset, UINT32 length, const void* pSource,
-					bool discardWholeBuffer = false) = 0;
+					BufferWriteType writeFlags = BufferWriteType::Normal) = 0;
 
 			/** Copy data from another buffer into this one.
 			@remarks
@@ -170,7 +173,7 @@ namespace CamelotFramework
 			{
 				const void *srcData = srcBuffer.lock(
 					srcOffset, length, GBL_READ_ONLY);
-				this->writeData(dstOffset, length, srcData, discardWholeBuffer);
+				this->writeData(dstOffset, length, srcData, discardWholeBuffer ? BufferWriteType::Discard : BufferWriteType::Normal);
 				srcBuffer.unlock();
 			}
 

+ 1 - 2
CamelotCore/Include/CmPixelBuffer.h

@@ -99,8 +99,7 @@ namespace CamelotFramework {
 		/// @copydoc HardwareBuffer::readData
 		virtual void readData(UINT32 offset, UINT32 length, void* pDest);
 		/// @copydoc HardwareBuffer::writeData
-		virtual void writeData(UINT32 offset, UINT32 length, const void* pSource,
-				bool discardWholeBuffer = false);
+		virtual void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
 
         /// Gets the width of this buffer
         UINT32 getWidth() const { return mWidth; }

+ 3 - 3
CamelotCore/Source/CmMesh.cpp

@@ -85,7 +85,7 @@ namespace CamelotFramework
 		if((indexOffset + indicesSize) > mIndexData->indexBuffer->getSizeInBytes())
 			CM_EXCEPT(InvalidParametersException, "Index buffer values are being written out of valid range.");
 
-		mIndexData->indexBuffer->writeData(indexOffset, indicesSize, srcIdxData, discardEntireBuffer);
+		mIndexData->indexBuffer->writeData(indexOffset, indicesSize, srcIdxData, discardEntireBuffer ? BufferWriteType::Discard : BufferWriteType::Normal);
 
 		// Vertices
 		for(UINT32 i = 0; i <= meshData.getVertexDesc()->getMaxStreamIdx(); i++)
@@ -127,13 +127,13 @@ namespace CamelotFramework
 					}
 				}
 
-				vertexBuffer->writeData(bufferOffset, bufferSize, bufferCopy, discardEntireBuffer);
+				vertexBuffer->writeData(bufferOffset, bufferSize, bufferCopy, discardEntireBuffer ? BufferWriteType::Discard : BufferWriteType::Normal);
 
 				cm_free(bufferCopy);
 			}
 			else
 			{
-				vertexBuffer->writeData(bufferOffset, bufferSize, srcVertBufferData, discardEntireBuffer);
+				vertexBuffer->writeData(bufferOffset, bufferSize, srcVertBufferData, discardEntireBuffer ? BufferWriteType::Discard : BufferWriteType::Normal);
 			}
 		}
 	}

+ 4 - 4
CamelotCore/Source/CmMeshHeap.cpp

@@ -268,7 +268,7 @@ namespace CamelotFramework
 				}
 			}
 
-			vertexBuffer->writeData(vertChunk.start * vertSize, vertChunk.size * vertSize, vertDest, false);
+			vertexBuffer->writeData(vertChunk.start * vertSize, vertChunk.size * vertSize, vertDest, BufferWriteType::NoOverwrite);
 		}
 
 		IndexBufferPtr indexBuffer = mIndexData->indexBuffer;
@@ -276,7 +276,7 @@ namespace CamelotFramework
 
 		UINT8* idxDest = mCPUIndexData + idxChunk.start * idxSize;
 		memcpy(idxDest, meshData->getIndexData(), idxChunk.start * idxSize);
-		indexBuffer->writeData(idxChunk.start * idxSize, idxChunk.size * idxSize, idxDest, false);
+		indexBuffer->writeData(idxChunk.start * idxSize, idxChunk.size * idxSize, idxDest, BufferWriteType::NoOverwrite);
 	}
 
 	void MeshHeap::deallocInternal(UINT32 meshId)
@@ -341,7 +341,7 @@ namespace CamelotFramework
 				cm_free(oldBuffer);
 			}
 
-			vertexBuffer->writeData(0, destOffset * vertSize, buffer, false);
+			vertexBuffer->writeData(0, destOffset * vertSize, buffer, BufferWriteType::NoOverwrite);
 
 			mCPUVertexData[i] = buffer;
 		}
@@ -414,7 +414,7 @@ namespace CamelotFramework
 			cm_free(oldBuffer);
 		}
 
-		mIndexData->indexBuffer->writeData(0, destOffset * idxSize, buffer, false);
+		mIndexData->indexBuffer->writeData(0, destOffset * idxSize, buffer, BufferWriteType::NoOverwrite);
 
 		mCPUIndexData = buffer;
 

+ 1 - 2
CamelotCore/Source/CmPixelBuffer.cpp

@@ -85,8 +85,7 @@ namespace CamelotFramework
 				"Reading a byte range is not implemented. Use blitToMemory.");
 	}
 
-	void PixelBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource,
-			bool discardWholeBuffer)
+	void PixelBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags)
 	{
 		// TODO
 		CM_EXCEPT(NotImplementedException,

+ 1 - 1
CamelotD3D11RenderSystem/Include/CmD3D11GpuBuffer.h

@@ -30,7 +30,7 @@ namespace CamelotFramework
 		* @copydoc GenericBuffer::writeData
 		*/
         virtual void writeData(UINT32 offset, UINT32 length, const void* pSource,
-				bool discardWholeBuffer = false);
+			BufferWriteType writeFlags = BufferWriteType::Normal);
 
 		/**
 		* @copydoc GenericBuffer::copyData

+ 1 - 2
CamelotD3D11RenderSystem/Include/CmD3D11HardwareBuffer.h

@@ -27,8 +27,7 @@ namespace CamelotFramework
 		/** See HardwareBuffer. */
 		void readData(UINT32 offset, UINT32 length, void* pDest);
 		/** See HardwareBuffer. */
-		void writeData(UINT32 offset, UINT32 length, const void* pSource,
-			bool discardWholeBuffer = false);
+		void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
 		/** See HardwareBuffer. We perform a hardware copy here. */
 		void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, 
 			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false);

+ 1 - 2
CamelotD3D11RenderSystem/Include/CmD3D11IndexBuffer.h

@@ -19,8 +19,7 @@ namespace CamelotFramework
 		/**
 		 * @copydoc HardwareBuffer::writeData
 		 */
-		void writeData(UINT32 offset, UINT32 length, const void* pSource,
-			bool discardWholeBuffer = false);
+		void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
 
 		/**
 		 * @copydoc HardwareBuffer::copyData

+ 0 - 5
CamelotD3D11RenderSystem/Include/CmD3D11Prerequisites.h

@@ -73,11 +73,6 @@ namespace CamelotFramework
 	typedef std::shared_ptr<D3D11RenderWindow> D3D11RenderWindowPtr;
 	typedef std::shared_ptr<D3D11HLSLProgram> D3D11HLSLProgramPtr;
 
-// Should we ask D3D to manage vertex/index buffers automatically?
-// Doing so avoids lost devices, but also has a performance impact
-// which is unacceptably bad when using very large buffers
-#define CM_D3D_MANAGE_BUFFERS 1 // TODO - Keep this on or off? I'll probably want to turn it off at some point
-
     //-------------------------------------------
 	// Windows setttings
 	//-------------------------------------------

+ 1 - 2
CamelotD3D11RenderSystem/Include/CmD3D11VertexBuffer.h

@@ -19,8 +19,7 @@ namespace CamelotFramework
 		/**
 		 * @copydoc HardwareBuffer::writeData
 		 */
-		void writeData(UINT32 offset, UINT32 length, const void* pSource,
-			bool discardWholeBuffer = false);
+		void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
 
 		/**
 		 * @copydoc HardwareBuffer::copyData

+ 2 - 2
CamelotD3D11RenderSystem/Source/CmD3D11GpuBuffer.cpp

@@ -67,9 +67,9 @@ namespace CamelotFramework
 		mBuffer->readData(offset, length, pDest);
 	}
 
-	void D3D11GpuBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, bool discardWholeBuffer)
+	void D3D11GpuBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags)
 	{
-		mBuffer->writeData(offset, length, pSource, discardWholeBuffer);
+		mBuffer->writeData(offset, length, pSource, writeFlags);
 	}
 
 	void D3D11GpuBuffer::copyData(GpuBuffer& srcBuffer, UINT32 srcOffset, 

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11GpuParamBlockBuffer.cpp

@@ -41,7 +41,7 @@ namespace CamelotFramework
 
 	void D3D11GpuParamBlockBuffer::writeData(const UINT8* data)
 	{
-		mBuffer->writeData(0, mSize, data, true);
+		mBuffer->writeData(0, mSize, data, BufferWriteType::Discard);
 	}
 
 	void D3D11GpuParamBlockBuffer::readData(UINT8* data) const

+ 8 - 4
CamelotD3D11RenderSystem/Source/CmD3D11HardwareBuffer.cpp

@@ -276,13 +276,17 @@ namespace CamelotFramework
 		this->unlock();
 	}
 
-	void D3D11HardwareBuffer::writeData(UINT32 offset, UINT32 length, 
-		const void* pSource, bool discardWholeBuffer)
+	void D3D11HardwareBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags)
 	{
 		if(mDesc.Usage == D3D11_USAGE_DYNAMIC || mDesc.Usage == D3D11_USAGE_STAGING)
 		{
-			void* pDst = this->lock(offset, length, 
-				discardWholeBuffer ? GBL_WRITE_ONLY_DISCARD : GBL_WRITE_ONLY);
+			GpuLockOptions lockOption = GBL_WRITE_ONLY;
+			if(writeFlags == BufferWriteType::Discard)
+				lockOption = GBL_WRITE_ONLY_DISCARD;
+			else if(writeFlags == BufferWriteType::NoOverwrite)
+				lockOption = GBL_WRITE_ONLY_NO_OVERWRITE;
+
+			void* pDst = this->lock(offset, length, lockOption);
 			memcpy(pDst, pSource, length);
 			this->unlock();
 		}

+ 2 - 2
CamelotD3D11RenderSystem/Source/CmD3D11IndexBuffer.cpp

@@ -45,9 +45,9 @@ namespace CamelotFramework
 		mBuffer->readData(offset, length, pDest);
 	}
 
-	void D3D11IndexBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, bool discardWholeBuffer)
+	void D3D11IndexBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags)
 	{
-		mBuffer->writeData(offset, length, pSource, discardWholeBuffer);
+		mBuffer->writeData(offset, length, pSource, writeFlags);
 	}
 
 	void D3D11IndexBuffer::copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, 

+ 2 - 2
CamelotD3D11RenderSystem/Source/CmD3D11VertexBuffer.cpp

@@ -26,9 +26,9 @@ namespace CamelotFramework
 		mBuffer->readData(offset, length, pDest);
 	}
 
-	void D3D11VertexBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, bool discardWholeBuffer)
+	void D3D11VertexBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags)
 	{
-		mBuffer->writeData(offset, length, pSource, discardWholeBuffer);
+		mBuffer->writeData(offset, length, pSource, writeFlags);
 	}
 
 	void D3D11VertexBuffer::copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, 

+ 1 - 1
CamelotD3D9Renderer/Include/CmD3D9GpuBuffer.h

@@ -29,7 +29,7 @@ namespace CamelotFramework
 		* @copydoc GenericBuffer::writeData
 		*/
         virtual void writeData(UINT32 offset, UINT32 length, const void* pSource,
-				bool discardWholeBuffer = false);
+				BufferWriteType writeFlags = BufferWriteType::Normal);
 
 		/**
 		* @copydoc GenericBuffer::copyData

+ 1 - 2
CamelotD3D9Renderer/Include/CmD3D9IndexBuffer.h

@@ -43,8 +43,7 @@ namespace CamelotFramework {
         /** See HardwareBuffer. */
         void readData(UINT32 offset, UINT32 length, void* pDest);
         /** See HardwareBuffer. */
-        void writeData(UINT32 offset, UINT32 length, const void* pSource,
-				bool discardWholeBuffer = false);
+		void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
 
 		// Called immediately after the Direct3D device has been created.
 		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);

+ 0 - 5
CamelotD3D9Renderer/Include/CmD3D9Prerequisites.h

@@ -88,11 +88,6 @@ namespace CamelotFramework
 		TID_D3D9_HLSLProgram = 10000
 	};
 
-// Should we ask D3D to manage vertex/index buffers automatically?
-// Doing so avoids lost devices, but also has a performance impact
-// which is unacceptably bad when using very large buffers
-#define CM_D3D_MANAGE_BUFFERS 1 // TODO - Keep this on or off? I'll probably want to turn it off at some point
-
     //-------------------------------------------
 	// Windows setttings
 	//-------------------------------------------

+ 1 - 2
CamelotD3D9Renderer/Include/CmD3D9VertexBuffer.h

@@ -43,8 +43,7 @@ namespace CamelotFramework {
         /** See HardwareBuffer. */
         void readData(UINT32 offset, UINT32 length, void* pDest);
         /** See HardwareBuffer. */
-        void writeData(UINT32 offset, UINT32 length, const void* pSource,
-				bool discardWholeBuffer = false);
+        void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
 	
 		// Called immediately after the Direct3D device has been created.
 		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9GpuBuffer.cpp

@@ -31,7 +31,7 @@ namespace CamelotFramework
 	{
 	}
 
-	void D3D9GpuBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, bool discardWholeBuffer)
+	void D3D9GpuBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags)
 	{
 	}
 

+ 9 - 11
CamelotD3D9Renderer/Source/CmD3D9IndexBuffer.cpp

@@ -51,13 +51,7 @@ namespace CamelotFramework {
 	{
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
-		D3DPOOL eResourcePool;
-
-#if CM_D3D_MANAGE_BUFFERS
-		eResourcePool = mSystemMemory ? D3DPOOL_SYSTEMMEM : D3DPOOL_MANAGED;
-#else
-		eResourcePool = mSystemMemory? D3DPOOL_SYSTEMMEM : D3DPOOL_DEFAULT;
-#endif
+		D3DPOOL eResourcePool = mSystemMemory? D3DPOOL_SYSTEMMEM : D3DPOOL_DEFAULT;
 
 		// Set the desired memory pool.
 		mBufferDesc.Pool = eResourcePool;
@@ -177,13 +171,17 @@ namespace CamelotFramework {
     }
 	//---------------------------------------------------------------------
     void D3D9IndexBuffer::writeData(UINT32 offset, UINT32 length, 
-            const void* pSource,
-			bool discardWholeBuffer)
+            const void* pSource, BufferWriteType writeFlags)
     {
+		GpuLockOptions lockOption = GBL_WRITE_ONLY;
+		if(writeFlags == BufferWriteType::Discard)
+			lockOption = GBL_WRITE_ONLY_DISCARD;
+		else if(writeFlags == BufferWriteType::NoOverwrite)
+			lockOption = GBL_WRITE_ONLY_NO_OVERWRITE;
+
         // There is no functional interface in D3D, just do via manual 
         // lock, copy & unlock
-        void* pDst = this->lock(offset, length, 
-            discardWholeBuffer ? GBL_WRITE_ONLY_DISCARD : GBL_READ_WRITE);
+        void* pDst = this->lock(offset, length, lockOption);
         memcpy(pDst, pSource, length);
         this->unlock();    
 	}

+ 0 - 14
CamelotD3D9Renderer/Source/CmD3D9Mappings.cpp

@@ -311,11 +311,7 @@ namespace CamelotFramework
         DWORD ret = 0;
         if (usage & GBU_DYNAMIC)
         {
-#if CM_D3D_MANAGE_BUFFERS
-            // Not allowed to used dynamic on managed pool
-#else
             ret |= D3DUSAGE_DYNAMIC;
-#endif
         }
 
         return ret;
@@ -326,14 +322,9 @@ namespace CamelotFramework
         DWORD ret = 0;
         if (options == GBL_WRITE_ONLY_DISCARD)
         {
-#if CM_D3D_MANAGE_BUFFERS
-			// 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 & GBU_DYNAMIC)
                 ret |= D3DLOCK_DISCARD;
-#endif
         }
         
 		if (options == GBL_READ_ONLY)
@@ -343,14 +334,9 @@ namespace CamelotFramework
 
         if (options == GBL_WRITE_ONLY_NO_OVERWRITE)
         {
-#if CM_D3D_MANAGE_BUFFERS
-			// 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 & GBU_DYNAMIC)
                 ret |= D3DLOCK_NOOVERWRITE;
-#endif 
         }
 
         return ret;

+ 9 - 11
CamelotD3D9Renderer/Source/CmD3D9VertexBuffer.cpp

@@ -119,13 +119,17 @@ namespace CamelotFramework {
     }
 	//---------------------------------------------------------------------
 	void D3D9VertexBuffer::writeData(UINT32 offset, UINT32 length, 
-		const void* pSource,
-		bool discardWholeBuffer)
+		const void* pSource, BufferWriteType writeFlags)
 	{
+		GpuLockOptions lockOption = GBL_WRITE_ONLY;
+		if(writeFlags == BufferWriteType::Discard)
+			lockOption = GBL_WRITE_ONLY_DISCARD;
+		else if(writeFlags == BufferWriteType::NoOverwrite)
+			lockOption = GBL_WRITE_ONLY_NO_OVERWRITE;
+
 		// There is no functional interface in D3D, just do via manual 
 		// lock, copy & unlock
-		void* pDst = this->lock(offset, length, 
-			discardWholeBuffer ? GBL_WRITE_ONLY_DISCARD : GBL_READ_WRITE);
+		void* pDst = this->lock(offset, length, lockOption);
 		memcpy(pDst, pSource, length);
 		this->unlock();
 	}
@@ -304,13 +308,7 @@ namespace CamelotFramework {
 	{
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
-		D3DPOOL eResourcePool;
-
-#if CM_D3D_MANAGE_BUFFERS
-		eResourcePool = mSystemMemory ? D3DPOOL_SYSTEMMEM : D3DPOOL_MANAGED;
-#else
-		eResourcePool = mSystemMemory ? D3DPOOL_SYSTEMMEM : D3DPOOL_DEFAULT;
-#endif       		
+		D3DPOOL eResourcePool = mSystemMemory ? D3DPOOL_SYSTEMMEM : D3DPOOL_DEFAULT;    		
 
 		// Set the desired memory pool.
 		mBufferDesc.Pool = eResourcePool;

+ 1 - 1
CamelotGLRenderer/Include/CmGLGpuBuffer.h

@@ -29,7 +29,7 @@ namespace CamelotFramework
 		* @copydoc GenericBuffer::writeData
 		*/
         virtual void writeData(UINT32 offset, UINT32 length, const void* pSource,
-				bool discardWholeBuffer = false);
+				BufferWriteType writeFlags = BufferWriteType::Normal);
 
 		/**
 		* @copydoc GenericBuffer::copyData

+ 5 - 17
CamelotGLRenderer/Include/CmGLIndexBuffer.h

@@ -25,15 +25,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 -----------------------------------------------------------------------------
 */
-#ifndef __GLHARDWAREINDEXBUFFER_H__
-#define __GLHARDWAREINDEXBUFFER_H__
+#pragma once
 
 #include "CmGLPrerequisites.h"
 #include "CmIndexBuffer.h"
 
-namespace CamelotFramework { 
-
-
+namespace CamelotFramework 
+{ 
     class CM_RSGL_EXPORT GLIndexBuffer : public IndexBuffer
     {
     public:
@@ -42,7 +40,7 @@ namespace CamelotFramework {
         void readData(UINT32 offset, UINT32 length, void* pDest);
         /** See HardwareBuffer. */
         void writeData(UINT32 offset, UINT32 length, 
-            const void* pSource, bool discardWholeBuffer = false);
+			const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
 
         GLuint getGLBufferId(void) const { return mBufferId; }
 
@@ -69,15 +67,5 @@ namespace CamelotFramework {
 
 	private:
 		GLuint mBufferId;
-		// Scratch buffer handling
-		bool mLockedToScratch;
-		UINT32 mScratchOffset;
-		UINT32 mScratchSize;
-		void* mScratchPtr;
-		bool mScratchUploadOnUnlock;
     };
-
-}
-
-#endif // __GLHARDWAREINDEXBUFFER_H__
-
+}

+ 3 - 12
CamelotGLRenderer/Include/CmGLVertexBuffer.h

@@ -25,8 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 -----------------------------------------------------------------------------
 */
-#ifndef __GLHARDWAREVERTEXBUFFER_H__
-#define __GLHARDWAREVERTEXBUFFER_H__
+#pragma once
 
 #include "CmGLPrerequisites.h"
 #include "CmVertexBuffer.h"
@@ -42,7 +41,7 @@ namespace CamelotFramework {
         void readData(UINT32 offset, UINT32 length, void* pDest);
         /** See HardwareBuffer. */
         void writeData(UINT32 offset, UINT32 length, 
-            const void* pSource, bool discardWholeBuffer = false);
+            const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
 
         GLuint getGLBufferId(void) const { return mBufferId; }
 
@@ -68,13 +67,5 @@ namespace CamelotFramework {
 
 	private:
 		GLuint mBufferId;
-		// Scratch buffer handling
-		bool mLockedToScratch;
-		UINT32 mScratchOffset;
-		UINT32 mScratchSize;
-		void* mScratchPtr;
-		bool mScratchUploadOnUnlock;
     };
-
-}
-#endif // __GLHARDWAREVERTEXBUFFER_H__
+}

+ 1 - 1
CamelotGLRenderer/Source/CmGLGpuBuffer.cpp

@@ -32,7 +32,7 @@ namespace CamelotFramework
 	{
 	}
 
-	void GLGpuBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, bool discardWholeBuffer)
+	void GLGpuBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags)
 	{
 	}
 

+ 4 - 4
CamelotGLRenderer/Source/CmGLHardwareBufferManager.cpp

@@ -110,11 +110,11 @@ namespace CamelotFramework {
         switch(usage)
         {
         case GBU_STATIC:
-            return GL_STATIC_DRAW_ARB;
+            return GL_STATIC_DRAW;
         case GBU_DYNAMIC:
-            return GL_DYNAMIC_DRAW_ARB;
+            return GL_DYNAMIC_DRAW;
         default:
-            return GL_DYNAMIC_DRAW_ARB;
+            return GL_DYNAMIC_DRAW;
         };
     }
     //---------------------------------------------------------------------
@@ -255,7 +255,7 @@ namespace CamelotFramework {
 		return mMapBufferThreshold;
 	}
 	//---------------------------------------------------------------------
-	void GLHardwareBufferManager::setGLMapBufferThreshold( const UINT32 value )
+	void GLHardwareBufferManager::setGLMapBufferThreshold(const UINT32 value)
 	{
 		mMapBufferThreshold = value;
 	}

+ 50 - 111
CamelotGLRenderer/Source/CmGLIndexBuffer.cpp

@@ -29,20 +29,19 @@ THE SOFTWARE.
 #include "CmGLHardwareBufferManager.h"
 #include "CmException.h"
 
-namespace CamelotFramework {
-
-	//---------------------------------------------------------------------
+namespace CamelotFramework 
+{
     GLIndexBuffer::GLIndexBuffer(HardwareBufferManager* mgr, IndexType idxType,
         UINT32 numIndexes, GpuBufferUsage usage)
         : IndexBuffer(mgr, idxType, numIndexes, usage, false)
     {  }
-	//---------------------------------------------------------------------
+
     GLIndexBuffer::~GLIndexBuffer()
     {    }
-	//---------------------------------------------------------------------
+
 	void GLIndexBuffer::initialize_internal()
 	{
-		glGenBuffersARB( 1, &mBufferId );
+		glGenBuffers(1, &mBufferId );
 
 		if (!mBufferId)
 		{
@@ -50,22 +49,22 @@ namespace CamelotFramework {
 				"Cannot create GL index buffer");
 		}
 
-		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId);
+		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mBufferId);
 
 		// Initialise buffer and set usage
-		glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mSizeInBytes, NULL, 
+		glBufferData(GL_ELEMENT_ARRAY_BUFFER, mSizeInBytes, NULL, 
 			GLHardwareBufferManager::getGLUsage(mUsage));
 
 		IndexBuffer::initialize_internal();
 	}
-	//---------------------------------------------------------------------
+
 	void GLIndexBuffer::destroy_internal()
 	{
-		glDeleteBuffersARB(1, &mBufferId);
+		glDeleteBuffers(1, &mBufferId);
 
 		IndexBuffer::destroy_internal();
 	}
-	//---------------------------------------------------------------------
+
     void* GLIndexBuffer::lockImpl(UINT32 offset, 
         UINT32 length, GpuLockOptions options)
     {
@@ -77,126 +76,66 @@ namespace CamelotFramework {
                 "Invalid attempt to lock an index buffer that has already been locked");
         }
 
-        
-		void* retPtr = 0;
-
-		GLHardwareBufferManager* glBufManager = static_cast<GLHardwareBufferManager*>(HardwareBufferManager::instancePtr());
+		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mBufferId);
 
-		// Try to use scratch buffers for smaller buffers
-		if( length < glBufManager->getGLMapBufferThreshold() )
+		if ((options == GBL_WRITE_ONLY) || (options == GBL_WRITE_ONLY_NO_OVERWRITE) || (options == GBL_WRITE_ONLY_DISCARD))
 		{
-			retPtr = glBufManager->allocateScratch((UINT32)length);
-			if (retPtr)
-			{
-				mLockedToScratch = true;
-				mScratchOffset = offset;
-				mScratchSize = length;
-				mScratchPtr = retPtr;
-				mScratchUploadOnUnlock = (options != GBL_READ_ONLY);
-
-				if (options != GBL_WRITE_ONLY_DISCARD)
-				{
-					// have to read back the data before returning the pointer
-					readData(offset, length, retPtr);
-				}
-			}
-		}
+			access = GL_MAP_WRITE_BIT;
 
-		if (!retPtr)
-		{
-			glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId );
-			// Use glMapBuffer
 			if(options == GBL_WRITE_ONLY_DISCARD)
-			{
-				// Discard the buffer
-				glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mSizeInBytes, NULL, 
-					GLHardwareBufferManager::getGLUsage(mUsage));
-			}
-			if (options == GBL_WRITE_ONLY || options == GBL_WRITE_ONLY_NO_OVERWRITE)
-				access = GL_WRITE_ONLY_ARB;
-			else if (options == GBL_READ_ONLY)
-				access = GL_READ_ONLY_ARB;
-			else
-				access = GL_READ_WRITE_ARB;
-
-			void* pBuffer = glMapBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, access );
-
-			if(pBuffer == 0)
-			{
-				CM_EXCEPT(InternalErrorException, 
-					"Index Buffer: Out of memory");
-			}
-
-			// return offsetted
-			retPtr = static_cast<void*>(
-				static_cast<unsigned char*>(pBuffer) + offset);
-
-			mLockedToScratch = false;
+				access |= GL_MAP_INVALIDATE_BUFFER_BIT;
+			else if(options == GBL_WRITE_ONLY_NO_OVERWRITE)
+				access |= GL_MAP_UNSYNCHRONIZED_BIT;
+		}
+		else if (options == GBL_READ_ONLY)
+			access = GL_MAP_READ_BIT;
+		else
+			access = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;
+
+		void* pBuffer = glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, offset, length, access);
 
+		if(pBuffer == 0)
+		{
+			CM_EXCEPT(InternalErrorException, "Index Buffer: Out of memory");
 		}
+
+		void* retPtr = static_cast<void*>(static_cast<unsigned char*>(pBuffer) + offset);
+
 		mIsLocked = true;
 		return retPtr;
     }
-	//---------------------------------------------------------------------
+
 	void GLIndexBuffer::unlockImpl(void)
     {
-		if (mLockedToScratch)
-		{
-			if (mScratchUploadOnUnlock)
-			{
-				// have to write the data back to vertex buffer
-				writeData(mScratchOffset, mScratchSize, mScratchPtr, 
-					mScratchOffset == 0 && mScratchSize == getSizeInBytes());
-			}
-
-			// deallocate from scratch buffer
-			static_cast<GLHardwareBufferManager*>(
-				HardwareBufferManager::instancePtr())->deallocateScratch(mScratchPtr);
-
-			mLockedToScratch = false;
-		}
-		else
-		{
-
-			glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId );
+		glBindBuffer(GL_ARRAY_BUFFER, mBufferId);
 
-			if(!glUnmapBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB ))
-			{
-				CM_EXCEPT(InternalErrorException, 
-					"Buffer data corrupted, please reload");
-			}
+		if(!glUnmapBuffer(GL_ARRAY_BUFFER))
+		{
+			CM_EXCEPT(InternalErrorException, "Buffer data corrupted, please reload");
 		}
 
-        mIsLocked = false;
+		mIsLocked = false;
     }
-	//---------------------------------------------------------------------
+
     void GLIndexBuffer::readData(UINT32 offset, UINT32 length, 
         void* pDest)
     {
-		glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId );
-		glGetBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, pDest);
+		void* bufferData = lock(offset, length, GBL_READ_ONLY);
+		memcpy(pDest, bufferData, length);
+		unlock();
     }
-	//---------------------------------------------------------------------
+
     void GLIndexBuffer::writeData(UINT32 offset, UINT32 length, 
-            const void* pSource, bool discardWholeBuffer)
+		const void* pSource, BufferWriteType writeFlags)
     {
-        glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId );
-
-        if (offset == 0 && length == mSizeInBytes)
-        {
-            glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mSizeInBytes, pSource,
-                GLHardwareBufferManager::getGLUsage(mUsage));
-        }
-        else
-        {
-            if(discardWholeBuffer)
-            {
-                glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mSizeInBytes, NULL,
-                    GLHardwareBufferManager::getGLUsage(mUsage));
-            }
-
-            // Now update the real buffer
-            glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, pSource);
-        }
+		GpuLockOptions lockOption = GBL_WRITE_ONLY;
+		if(writeFlags == BufferWriteType::Discard)
+			lockOption = GBL_WRITE_ONLY_DISCARD;
+		else if(writeFlags == BufferWriteType::NoOverwrite)
+			lockOption = GBL_WRITE_ONLY_NO_OVERWRITE;
+
+		void* bufferData = lock(offset, length, lockOption);
+		memcpy(bufferData, pSource, length);
+		unlock();
     }
 }

+ 52 - 117
CamelotGLRenderer/Source/CmGLVertexBuffer.cpp

@@ -29,19 +29,18 @@ THE SOFTWARE.
 #include "CmGLVertexBuffer.h"
 #include "CmException.h"
 
-namespace CamelotFramework {
-
-	//---------------------------------------------------------------------
+namespace CamelotFramework 
+{
     GLVertexBuffer::GLVertexBuffer(HardwareBufferManager* mgr, UINT32 vertexSize, 
         UINT32 numVertices, GpuBufferUsage usage)
         : VertexBuffer(mgr, vertexSize, numVertices, usage, false)
     {
     }
-	//---------------------------------------------------------------------
+
     GLVertexBuffer::~GLVertexBuffer()
     {
     }
-	//---------------------------------------------------------------------
+
     void* GLVertexBuffer::lockImpl(UINT32 offset, 
         UINT32 length, GpuLockOptions options)
     {
@@ -50,138 +49,74 @@ namespace CamelotFramework {
         if(mIsLocked)
         {
 			CM_EXCEPT(InternalErrorException,
-                "Invalid attempt to lock an index buffer that has already been locked");
+                "Invalid attempt to lock a vertex buffer that has already been locked");
         }
 
+		glBindBuffer(GL_ARRAY_BUFFER, mBufferId);
 
-		void* retPtr = 0;
-
-		GLHardwareBufferManager* glBufManager = static_cast<GLHardwareBufferManager*>(HardwareBufferManager::instancePtr());
-
-		// Try to use scratch buffers for smaller buffers
-		if( length < glBufManager->getGLMapBufferThreshold() )
+		if ((options == GBL_WRITE_ONLY) || (options == GBL_WRITE_ONLY_NO_OVERWRITE) || (options == GBL_WRITE_ONLY_DISCARD))
 		{
-			// if this fails, we fall back on mapping
-			retPtr = glBufManager->allocateScratch((UINT32)length);
-
-			if (retPtr)
-			{
-				mLockedToScratch = true;
-				mScratchOffset = offset;
-				mScratchSize = length;
-				mScratchPtr = retPtr;
-				mScratchUploadOnUnlock = (options != GBL_READ_ONLY);
-
-				if (options != GBL_WRITE_ONLY_DISCARD)
-				{
-					// have to read back the data before returning the pointer
-					readData(offset, length, retPtr);
-				}
-			}
+			access = GL_MAP_WRITE_BIT;
+
+			if(options == GBL_WRITE_ONLY_DISCARD)
+				access |= GL_MAP_INVALIDATE_BUFFER_BIT;
+			else if(options == GBL_WRITE_ONLY_NO_OVERWRITE)
+				access |= GL_MAP_UNSYNCHRONIZED_BIT;
 		}
-		
-		if (!retPtr)
+		else if (options == GBL_READ_ONLY)
+			access = GL_MAP_READ_BIT;
+		else
+			access = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;
+
+		void* pBuffer = glMapBufferRange(GL_ARRAY_BUFFER, offset, length, access);
+
+		if(pBuffer == 0)
 		{
-			// Use glMapBuffer
-			glBindBufferARB( GL_ARRAY_BUFFER_ARB, mBufferId );
-			// Use glMapBuffer
-			if(options == GBL_WRITE_ONLY_DISCARD)
-			{
-				// Discard the buffer
-				glBufferDataARB(GL_ARRAY_BUFFER_ARB, mSizeInBytes, NULL, 
-					GLHardwareBufferManager::getGLUsage(mUsage));
-
-			}
-			if ((options == GBL_WRITE_ONLY) || (options == GBL_WRITE_ONLY_NO_OVERWRITE))
-				access = GL_WRITE_ONLY_ARB;
-			else if (options == GBL_READ_ONLY)
-				access = GL_READ_ONLY_ARB;
-			else
-				access = GL_READ_WRITE_ARB;
-
-			void* pBuffer = glMapBufferARB( GL_ARRAY_BUFFER_ARB, access);
-
-			if(pBuffer == 0)
-			{
-				CM_EXCEPT(InternalErrorException, "Vertex Buffer: Out of memory");
-			}
-
-			// return offsetted
-			retPtr = static_cast<void*>(
-				static_cast<unsigned char*>(pBuffer) + offset);
-
-			mLockedToScratch = false;
+			CM_EXCEPT(InternalErrorException, "Vertex Buffer: Out of memory");
 		}
+
+		void* retPtr = static_cast<void*>(static_cast<unsigned char*>(pBuffer) + offset);
+
 		mIsLocked = true;
 		return retPtr;
     }
-	//---------------------------------------------------------------------
+
 	void GLVertexBuffer::unlockImpl(void)
     {
-		if (mLockedToScratch)
-		{
-			if (mScratchUploadOnUnlock)
-			{
-				// have to write the data back to vertex buffer
-				writeData(mScratchOffset, mScratchSize, mScratchPtr, 
-					mScratchOffset == 0 && mScratchSize == getSizeInBytes());
-			}
-
-			// deallocate from scratch buffer
-			static_cast<GLHardwareBufferManager*>(
-				HardwareBufferManager::instancePtr())->deallocateScratch(mScratchPtr);
-
-			mLockedToScratch = false;
-		}
-		else
-		{
-
-			glBindBufferARB(GL_ARRAY_BUFFER_ARB, mBufferId);
+		glBindBuffer(GL_ARRAY_BUFFER, mBufferId);
 
-			if(!glUnmapBufferARB( GL_ARRAY_BUFFER_ARB ))
-			{
-				CM_EXCEPT(InternalErrorException, "Buffer data corrupted, please reload");
-			}
+		if(!glUnmapBuffer(GL_ARRAY_BUFFER))
+		{
+			CM_EXCEPT(InternalErrorException, "Buffer data corrupted, please reload");
 		}
 
         mIsLocked = false;
     }
-	//---------------------------------------------------------------------
-    void GLVertexBuffer::readData(UINT32 offset, UINT32 length, 
-        void* pDest)
+
+    void GLVertexBuffer::readData(UINT32 offset, UINT32 length, void* pDest)
     {
-        // get data from the real buffer
-        glBindBufferARB(GL_ARRAY_BUFFER_ARB, mBufferId);
-        
-        glGetBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, length, pDest);
+		void* bufferData = lock(offset, length, GBL_READ_ONLY);
+		memcpy(pDest, bufferData, length);
+		unlock();
     }
-	//---------------------------------------------------------------------
+
     void GLVertexBuffer::writeData(UINT32 offset, UINT32 length, 
-            const void* pSource, bool discardWholeBuffer)
+		const void* pSource, BufferWriteType writeFlags)
     {
-        glBindBufferARB(GL_ARRAY_BUFFER_ARB, mBufferId);
-
-        if (offset == 0 && length == mSizeInBytes)
-        {
-            glBufferDataARB(GL_ARRAY_BUFFER_ARB, mSizeInBytes, pSource, 
-                GLHardwareBufferManager::getGLUsage(mUsage));
-        }
-        else
-        {
-            if(discardWholeBuffer)
-            {
-                glBufferDataARB(GL_ARRAY_BUFFER_ARB, mSizeInBytes, NULL, 
-                    GLHardwareBufferManager::getGLUsage(mUsage));
-            }
-
-            // Now update the real buffer
-            glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, length, pSource); 
-        }
+		GpuLockOptions lockOption = GBL_WRITE_ONLY;
+		if(writeFlags == BufferWriteType::Discard)
+			lockOption = GBL_WRITE_ONLY_DISCARD;
+		else if(writeFlags == BufferWriteType::NoOverwrite)
+			lockOption = GBL_WRITE_ONLY_NO_OVERWRITE;
+
+		void* bufferData = lock(offset, length, lockOption);
+		memcpy(bufferData, pSource, length);
+		unlock();
     }
-	//---------------------------------------------------------------------
+
 	void GLVertexBuffer::initialize_internal()
 	{
-		glGenBuffersARB( 1, &mBufferId );
+		glGenBuffers(1, &mBufferId);
 
 		if (!mBufferId)
 		{
@@ -189,18 +124,18 @@ namespace CamelotFramework {
 				"Cannot create GL vertex buffer");
 		}
 
-		glBindBufferARB(GL_ARRAY_BUFFER_ARB, mBufferId);
+		glBindBuffer(GL_ARRAY_BUFFER, mBufferId);
 
 		// Initialise mapped buffer and set usage
-		glBufferDataARB(GL_ARRAY_BUFFER_ARB, mSizeInBytes, NULL, 
+		glBufferData(GL_ARRAY_BUFFER, mSizeInBytes, NULL, 
 			GLHardwareBufferManager::getGLUsage(mUsage));
 
 		VertexBuffer::initialize_internal();
 	}
-	//---------------------------------------------------------------------
+
 	void GLVertexBuffer::destroy_internal()
 	{
-		glDeleteBuffersARB(1, &mBufferId);
+		glDeleteBuffers(1, &mBufferId);
 
 		VertexBuffer::destroy_internal();
 	}

+ 4 - 0
Notes.txt

@@ -55,6 +55,10 @@ Reminders:
   - Add a field that tracks % of resource deserialization in BinarySerializer
   - Add GL Texture buffers (They're equivalent to DX11 buffers) - http://www.opengl.org/wiki/Buffer_Texture
   - Instead of doing setThisPtr on every CoreGpuObject, use intrusive shared_ptr instead?
+  - I should consider creating two special Mesh types:
+     StreamMesh - constantly updated by CPU and read by GPU
+     ReadMesh - written by GPU and easily read by CPU
+	  - OpenGL especially has no good way of reading or streaming data. It has special STREAM and COPY buffer types which I never use.
 
 Potential optimizations:
  - bulkPixelConversion is EXTREMELY poorly unoptimized. Each pixel it calls a separate method that does redudant operations every pixel.