ソースを参照

Cleaning up render API

BearishSun 9 年 前
コミット
e2fcd6419d

+ 0 - 2
Source/BansheeCore/CMakeSources.cmake

@@ -135,7 +135,6 @@ set(BS_BANSHEECORE_INC_RENDERAPI
 	"Include/BsRenderStateManager.h"
 	"Include/BsRasterizerState.h"
 	"Include/BsQueryManager.h"
-	"Include/BsPixelBuffer.h"
 	"Include/BsOcclusionQuery.h"
 	"Include/BsMultiRenderTexture.h"
 	"Include/BsMeshManager.h"
@@ -430,7 +429,6 @@ set(BS_BANSHEECORE_SRC_RENDERAPI
 	"Source/BsMeshManager.cpp"
 	"Source/BsMultiRenderTexture.cpp"
 	"Source/BsOcclusionQuery.cpp"
-	"Source/BsPixelBuffer.cpp"
 	"Source/BsQueryManager.cpp"
 	"Source/BsRasterizerState.cpp"
 	"Source/BsRenderStateManager.cpp"

+ 4 - 4
Source/BansheeCore/Include/BsHardwareBuffer.h

@@ -34,7 +34,7 @@ namespace BansheeEngine
 		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);
+            void* ret = map(offset, length, options);
             mIsLocked = true;
 
 			mLockStart = offset;
@@ -59,7 +59,7 @@ namespace BansheeEngine
         {
             assert(isLocked() && "Cannot unlock this buffer, it is not locked!");
 
-            unlockImpl();
+            unmap();
             mIsLocked = false;
         }
 
@@ -142,10 +142,10 @@ namespace BansheeEngine
 		{  }
 
 		/** @copydoc lock */
-		virtual void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) = 0;
+		virtual void* map(UINT32 offset, UINT32 length, GpuLockOptions options) = 0;
 
 		/** @copydoc unlock */
-		virtual void unlockImpl() = 0;
+		virtual void unmap() = 0;
 
 	protected:
 		UINT32 mSizeInBytes;

+ 0 - 96
Source/BansheeCore/Include/BsPixelBuffer.h

@@ -1,96 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsHardwareBuffer.h"
-#include "BsPixelUtil.h"
-
-namespace BansheeEngine 
-{
-	/** @addtogroup RenderAPI-Internal
-	 *  @{
-	 */
-
-	/**
-	 * Represents a hardware buffer that stores a single pixel surface. This may be a 1D, 2D or 3D surface, but unlike a 
-	 * texture it consists only of a single surface (no mip maps, cube map faces or similar).
-	 *
-	 * @note	Core thread only
-	 */
-    class BS_CORE_EXPORT PixelBuffer : public HardwareBuffer
-    {
-    public:
-		/**
-		 * Constructs a new pixel buffer with the provided settings.
-		 *
-		 * @param[in]	width			Width of the pixel buffer in pixels.
-		 * @param[in]	height			Height of the pixel buffer in pixels.
-		 * @param[in]	depth			Depth of the pixel buffer in pixels (number of 2D slices).
-		 * @param[in]	format			Format of each pixel in the buffer.
-		 * @param[in]	usage			Usage signaling the render system how we plan on using the buffer.
-		 * @param[in]	useSystemMemory	True if buffer should be allocated in system memory.
-		 */
-        PixelBuffer(UINT32 width, UINT32 height, UINT32 depth, PixelFormat format, 
-			GpuBufferUsage usage, bool useSystemMemory);
-        ~PixelBuffer();
-
-		// Make the other lock overloads visible.
-        using HardwareBuffer::lock;	
-
-		/**
-		 * Locks a certain region of the pixel buffer for reading and returns a pointer to the locked region.
-		 *
-		 * @param[in]	lockBox		Region of the surface to lock.
-		 * @param[in]	options		Lock options that hint the hardware on what you intend to do with the locked data.
-		 *
-		 * @note	Returned object is only valid while the lock is active.
-		 */
-		virtual const PixelData& lock(const PixelVolume& lockBox, GpuLockOptions options);
-		
-		/** @copydoc HardwareBuffer::lock */
-        virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options);
-		
-		/** @copydoc HardwareBuffer::readData */
-		virtual void readData(UINT32 offset, UINT32 length, void* dest);
-
-		/** @copydoc HardwareBuffer::writeData */
-		virtual void writeData(UINT32 offset, UINT32 length, const void* source, 
-			BufferWriteType writeFlags = BufferWriteType::Normal);
-
-		/**	Returns width of the surface in pixels. */
-        UINT32 getWidth() const { return mWidth; }
-
-		/**	Returns height of the surface in pixels. */
-        UINT32 getHeight() const { return mHeight; }
-
-		/**	Returns depth of the surface in pixels. */
-        UINT32 getDepth() const { return mDepth; }
-
-		/**	Returns format of the pixels in the surface. */
-        PixelFormat getFormat() const { return mFormat; }
-
-	protected:
-		friend class RenderTexture;
-
-		/**	
-		 * Internal implementation of the lock() method. 
-		 *
-		 * @copydoc	lock(const PixelVolume&, GpuLockOptions)
-		 */
-		virtual PixelData lockImpl(PixelVolume lockBox, GpuLockOptions options) = 0;
-
-		/** @copydoc HardwareBuffer::lock(UINT32, UINT32, GpuLockOptions) */
-		virtual void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
-
-	protected:
-		UINT32 mWidth, mHeight, mDepth;
-		UINT32 mRowPitch, mSlicePitch;
-		PixelFormat mFormat;
-
-		PixelData mCurrentLock;
-		PixelVolume mLockedBox;
-    };
-
-	/** @} */
-}

+ 2 - 9
Source/BansheeCore/Include/BsTexture.h

@@ -324,7 +324,7 @@ namespace BansheeEngine
 
 		friend class TextureRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
+		RTTITypeBase* getRTTI() const override;
     };
 
 	/** @} */
@@ -348,7 +348,7 @@ namespace BansheeEngine
 
 
 		/** @copydoc CoreObjectCore::initialize */
-		virtual void initialize() override;
+		void initialize() override;
 
 		/**
 		 * Updates a part of the texture with the provided data.
@@ -425,13 +425,6 @@ namespace BansheeEngine
 		 */
 		virtual void writeData(const PixelData& src, UINT32 mipLevel = 0, UINT32 face = 0, bool discardWholeBuffer = false) = 0;
 
-		/**
-		 * Returns true if the texture can be bound to a shader.
-		 *
-		 * @note	This is only false for some rare special cases (for example AA render texture in DX9). Internal method.
-		 */
-		virtual bool isBindableAsShaderResource() const { return true; }
-
 		/**	Returns properties that contain information about the texture. */
 		const TextureProperties& getProperties() const { return mProperties; }
 

+ 0 - 60
Source/BansheeCore/Source/BsPixelBuffer.cpp

@@ -1,60 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsPixelBuffer.h"
-#include "BsException.h"
-
-namespace BansheeEngine 
-{
-    PixelBuffer::PixelBuffer(UINT32 width, UINT32 height, UINT32 depth,
-            PixelFormat format,
-            GpuBufferUsage usage, bool useSystemMemory):
-        HardwareBuffer(usage, useSystemMemory),
-        mWidth(width), mHeight(height), mDepth(depth),
-        mFormat(format)
-    {
-        mRowPitch = mWidth;
-        mSlicePitch = mHeight*mWidth;
-		mSizeInBytes = mHeight*mWidth*PixelUtil::getNumElemBytes(mFormat);
-    }
-
-    PixelBuffer::~PixelBuffer()
-    {
-    }
-
-    void* PixelBuffer::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");
-        
-        PixelVolume myBox(0, 0, 0, mWidth, mHeight, mDepth);
-        const PixelData &rv = lock(myBox, options);
-        return rv.getData();
-    }
-
-    const PixelData& PixelBuffer::lock(const PixelVolume& lockBox, GpuLockOptions options)
-    {
-        // Lock the real buffer if there is no shadow buffer 
-        mCurrentLock = lockImpl(lockBox, options);
-        mIsLocked = true;
-
-        return mCurrentLock;
-    }
-    
-    void* PixelBuffer::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
-    {
-		BS_EXCEPT(InternalErrorException, "lockImpl(offset,length) is not valid for PixelBuffers and should never be called");
-		return nullptr;
-    }
-
-	void PixelBuffer::readData(UINT32 offset, UINT32 length, void* pDest)
-	{
-		// TODO
-		BS_EXCEPT(NotImplementedException, "Reading a byte range is not implemented. Use blitToMemory.");
-	}
-
-	void PixelBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags)
-	{
-		// TODO
-		BS_EXCEPT(NotImplementedException, "Writing a byte range is not implemented. Use blitFromMemory.");
-	}
-}

+ 0 - 1
Source/BansheeCore/Source/BsRenderTexture.cpp

@@ -2,7 +2,6 @@
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsRenderTexture.h"
 #include "BsException.h"
-#include "BsPixelBuffer.h"
 #include "BsTexture.h"
 #include "BsTextureManager.h"
 #include "BsResources.h"

+ 0 - 1
Source/BansheeCore/Source/BsTexture.cpp

@@ -1,6 +1,5 @@
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsPixelBuffer.h"
 #include "BsTexture.h"
 #include "BsTextureRTTI.h"
 #include "BsDataStream.h"

+ 2 - 2
Source/BansheeD3D11RenderAPI/Include/BsD3D11HardwareBuffer.h

@@ -57,10 +57,10 @@ namespace BansheeEngine
 
 	protected:
 		/** @copydoc HardwareBuffer::lockImpl */
-		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) override;
+		void* map(UINT32 offset, UINT32 length, GpuLockOptions options) override;
 
 		/** @copydoc HardwareBuffer::unlockImpl */
-		void unlockImpl() override;
+		void unmap() override;
 
 		BufferType mBufferType;
 		bool mRandomGpuWrite;

+ 2 - 2
Source/BansheeD3D11RenderAPI/Include/BsD3D11IndexBuffer.h

@@ -36,10 +36,10 @@ namespace BansheeEngine
 
 	protected:
 		/** @copydoc IndexBufferCore::lockImpl */
-		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) override;
+		void* map(UINT32 offset, UINT32 length, GpuLockOptions options) override;
 
 		/** @copydoc IndexBufferCore::unlockImpl */
-		void unlockImpl() override;
+		void unmap() override;
 
 		/** @copydoc IndexBufferCore::initialize */
 		void initialize() override;

+ 2 - 2
Source/BansheeD3D11RenderAPI/Include/BsD3D11VertexBuffer.h

@@ -35,10 +35,10 @@ namespace BansheeEngine
 
 	protected: 
 		/** @copydoc VertexBufferCore::lockImpl */
-		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) override;
+		void* map(UINT32 offset, UINT32 length, GpuLockOptions options) override;
 
 		/** @copydoc VertexBufferCore::unlockImpl */
-		void unlockImpl(void) override;
+		void unmap(void) override;
 
 		/** @copydoc VertexBufferCore::initialize */
 		void initialize() override;

+ 2 - 2
Source/BansheeD3D11RenderAPI/Source/BsD3D11HardwareBuffer.cpp

@@ -92,7 +92,7 @@ namespace BansheeEngine
 			bs_delete(mpTempStagingBuffer);
 	}
 
-	void* D3D11HardwareBuffer::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
+	void* D3D11HardwareBuffer::map(UINT32 offset, UINT32 length, GpuLockOptions options)
 	{
 		if (length > mSizeInBytes)
 			BS_EXCEPT(RenderingAPIException, "Provided length " + toString(length) + " larger than the buffer " + toString(mSizeInBytes) + ".");		
@@ -195,7 +195,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void D3D11HardwareBuffer::unlockImpl(void)
+	void D3D11HardwareBuffer::unmap(void)
 	{
 		if (mUseTempStagingBuffer)
 		{

+ 2 - 2
Source/BansheeD3D11RenderAPI/Source/BsD3D11IndexBuffer.cpp

@@ -28,7 +28,7 @@ namespace BansheeEngine
 		IndexBufferCore::initialize();
 	}
 
-	void* D3D11IndexBufferCore::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
+	void* D3D11IndexBufferCore::map(UINT32 offset, UINT32 length, GpuLockOptions options)
 	{
 #if BS_PROFILING_ENABLED
 		if (options == GBL_READ_ONLY || options == GBL_READ_WRITE)
@@ -45,7 +45,7 @@ namespace BansheeEngine
 		return mBuffer->lock(offset, length, options);
 	}
 
-	void D3D11IndexBufferCore::unlockImpl()
+	void D3D11IndexBufferCore::unmap()
 	{
 		mBuffer->unlock();
 	}

+ 2 - 2
Source/BansheeD3D11RenderAPI/Source/BsD3D11VertexBuffer.cpp

@@ -18,7 +18,7 @@ namespace BansheeEngine
 		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_VertexBuffer);
 	}
 
-	void* D3D11VertexBufferCore::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
+	void* D3D11VertexBufferCore::map(UINT32 offset, UINT32 length, GpuLockOptions options)
 	{
 #if BS_PROFILING_ENABLED
 		if (options == GBL_READ_ONLY || options == GBL_READ_WRITE)
@@ -35,7 +35,7 @@ namespace BansheeEngine
 		return mBuffer->lock(offset, length, options);
 	}
 
-	void D3D11VertexBufferCore::unlockImpl()
+	void D3D11VertexBufferCore::unmap()
 	{
 		mBuffer->unlock();
 	}

+ 2 - 2
Source/BansheeGLRenderAPI/Include/BsGLIndexBuffer.h

@@ -34,10 +34,10 @@ namespace BansheeEngine
 		void initialize() override;	
 
 		/** @copydoc IndexBufferCore::lockImpl */
-		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) override;
+		void* map(UINT32 offset, UINT32 length, GpuLockOptions options) override;
 
 		/** @copydoc IndexBufferCore::unlockImpl */
-		void unlockImpl() override;
+		void unmap() override;
 
 	private:
 		GLBuffer mBuffer;

+ 67 - 12
Source/BansheeGLRenderAPI/Include/BsGLPixelBuffer.h

@@ -3,7 +3,8 @@
 #pragma once
 
 #include "BsGLPrerequisites.h"
-#include "BsPixelBuffer.h"
+#include "BsHardwareBuffer.h"
+#include "BsPixelUtil.h"
 
 namespace BansheeEngine 
 {
@@ -13,8 +14,11 @@ namespace BansheeEngine
 
 	class GLTextureBuffer;
 
-	/** OpenGL implementation of a pixel buffer. Represents a hardware buffer containing a surface of pixels. */
-	class BS_RSGL_EXPORT GLPixelBuffer : public PixelBuffer
+	/**
+	 * Represents a hardware buffer that stores a single pixel surface. This may be a 1D, 2D or 3D surface, but unlike a 
+	 * texture it consists only of a single surface (no mip maps, cube map faces or similar).
+	 */
+	class GLPixelBuffer
 	{
 	public:
 		/**
@@ -27,8 +31,55 @@ namespace BansheeEngine
 		 * @param[in]	usage			Usage signaling the render system how we plan on using the buffer.
 		 */
 		GLPixelBuffer(UINT32 width, UINT32 height, UINT32 depth, PixelFormat format, GpuBufferUsage usage);
+		virtual ~GLPixelBuffer();
+
+		/**	Returns width of the surface in pixels. */
+        UINT32 getWidth() const { return mWidth; }
+
+		/**	Returns height of the surface in pixels. */
+        UINT32 getHeight() const { return mHeight; }
+
+		/**	Returns depth of the surface in pixels. */
+        UINT32 getDepth() const { return mDepth; }
+
+		/**	Returns format of the pixels in the surface. */
+        PixelFormat getFormat() const { return mFormat; }
+
+		/**
+		 * Locks a certain region of the pixel buffer for reading and returns a pointer to the locked region.
+		 *
+		 * @param[in]	lockBox		Region of the surface to lock.
+		 * @param[in]	options		Lock options that hint the hardware on what you intend to do with the locked data.
+		 *
+		 * @note	Returned object is only valid while the lock is active.
+		 */
+		const PixelData& lock(const PixelVolume& lockBox, GpuLockOptions options);
+		
+		/**
+		 * Locks a portion of the buffer and returns pointer to the locked area. You must call unlock() when done.
+		 *
+		 * @param[in]	offset	Offset in bytes from which to lock the buffer.
+		 * @param[in]	length	Length of the area you want to lock, in bytes.
+		 * @param[in]	options	Signifies what you want to do with the returned pointer. Caller must ensure not to do 
+		 *						anything he hasn't requested (for example don't try to read from the buffer unless you
+		 *						requested it here).
+		 */
+        void* lock(UINT32 offset, UINT32 length, GpuLockOptions options);
+
+		/**
+		 * Locks the entire buffer and returns pointer to the locked area. You must call unlock() when done.
+		 *
+		 * @param[in]	options	Signifies what you want to do with the returned pointer. Caller must ensure not to do 
+		 *						anything he hasn't requested (for example don't try to read from the buffer unless you
+		 *						requested it here).
+		 */
+        void* lock(GpuLockOptions options)
+        {
+            return lock(0, mSizeInBytes, options);
+        }
 
-		~GLPixelBuffer();
+		/**	Releases the lock on this buffer. */
+		void unlock();
 
 		/**
 		 * Upload some pixel data to the buffer.
@@ -69,12 +120,6 @@ namespace BansheeEngine
 		virtual void blitFromTexture(GLTextureBuffer* src, const PixelVolume& srcBox, const PixelVolume& dstBox);
 
 	protected:  
-		/** @copydoc PixelBuffer::lockImpl */
-		PixelData lockImpl(PixelVolume lockBox, GpuLockOptions options) override;
-
-		/** @copydoc PixelBuffer::unlockImpl */
-		void unlockImpl() override;
-
 		/**	Allocates an internal buffer on the CPU, the size of the hardware buffer. */
 		void allocateBuffer();
 
@@ -82,13 +127,23 @@ namespace BansheeEngine
 		void freeBuffer();
 
 	protected:
+		UINT32 mSizeInBytes;
+		GpuBufferUsage mUsage;
+		bool mIsLocked;
+
+		UINT32 mWidth, mHeight, mDepth;
+		PixelFormat mFormat;
+
+		PixelData mCurrentLock;
+		PixelVolume mLockedBox;
+
 		PixelData mBuffer;
 		GLenum mGLInternalFormat;
 		GpuLockOptions mCurrentLockOptions;
 	};
 
 	/**	Pixel buffer specialization that represents a single surface in a texture. */
-    class BS_RSGL_EXPORT GLTextureBuffer : public GLPixelBuffer
+    class GLTextureBuffer : public GLPixelBuffer
 	{
     public:
 		/**
@@ -135,7 +190,7 @@ namespace BansheeEngine
     };
 
 	/**	Pixel buffer specialization that represents a render buffer. */
-    class BS_RSGL_EXPORT GLRenderBuffer : public GLPixelBuffer
+    class GLRenderBuffer : public GLPixelBuffer
 	{
     public:
 		/**

+ 2 - 2
Source/BansheeGLRenderAPI/Include/BsGLVertexBuffer.h

@@ -41,10 +41,10 @@ namespace BansheeEngine
 		void initialize() override;
 
 		/** @copydoc VertexBufferCore::lockImpl */
-		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) override;
+		void* map(UINT32 offset, UINT32 length, GpuLockOptions options) override;
 
 		/** @copydoc VertexBufferCore::unlockImpl */
-		void unlockImpl() override;
+		void unmap() override;
 
 	private:
 		GLBuffer mBuffer;

+ 2 - 2
Source/BansheeGLRenderAPI/Source/BsGLIndexBuffer.cpp

@@ -24,12 +24,12 @@ namespace BansheeEngine
 		IndexBufferCore::initialize();
 	}
 
-	void* GLIndexBufferCore::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
+	void* GLIndexBufferCore::map(UINT32 offset, UINT32 length, GpuLockOptions options)
 	{
 		return mBuffer.lock(offset, length, options);
 	}
 
-	void GLIndexBufferCore::unlockImpl()
+	void GLIndexBufferCore::unmap()
 	{
 		mBuffer.unlock();
 	}

+ 26 - 12
Source/BansheeGLRenderAPI/Source/BsGLPixelBuffer.cpp

@@ -11,12 +11,11 @@
 
 namespace BansheeEngine 
 {
-	GLPixelBuffer::GLPixelBuffer(UINT32 inWidth, UINT32 inHeight, UINT32 inDepth,
-					PixelFormat inFormat, GpuBufferUsage usage)
-					: PixelBuffer(inWidth, inHeight, inDepth, inFormat, usage, false),
-					  mBuffer(inWidth, inHeight, inDepth, inFormat),
-					  mGLInternalFormat(GL_NONE)
+	GLPixelBuffer::GLPixelBuffer(UINT32 inWidth, UINT32 inHeight, UINT32 inDepth, PixelFormat inFormat, GpuBufferUsage usage)
+		: mUsage(usage), mIsLocked(false), mWidth(inWidth), mHeight(inHeight), mDepth(inDepth), mFormat(inFormat)
+		, mBuffer(inWidth, inHeight, inDepth, inFormat), mGLInternalFormat(GL_NONE)
 	{
+		mSizeInBytes = mHeight*mWidth*PixelUtil::getNumElemBytes(mFormat);
 		mCurrentLockOptions = (GpuLockOptions)0;
 	}
 
@@ -42,11 +41,21 @@ namespace BansheeEngine
 		}
 	}
 
-	PixelData GLPixelBuffer::lockImpl(PixelVolume lockBox, GpuLockOptions options)
+	void* GLPixelBuffer::lock(UINT32 offset, UINT32 length, GpuLockOptions options)
+	{
+		assert(!mIsLocked && "Cannot lock this buffer, it is already locked!");
+		assert(offset == 0 && length == mSizeInBytes && "Cannot lock memory region, most lock box or entire buffer");
+
+		PixelVolume volume(0, 0, 0, mWidth, mHeight, mDepth);
+		const PixelData& lockedData = lock(volume, options);
+		return lockedData.getData();
+	}
+
+	const PixelData& GLPixelBuffer::lock(const PixelVolume& lockBox, GpuLockOptions options)
 	{
 		allocateBuffer();
 
-		if(options != GBL_WRITE_ONLY_DISCARD) 
+		if (options != GBL_WRITE_ONLY_DISCARD)
 		{
 			// Download the old contents of the texture
 			download(mBuffer);
@@ -54,18 +63,25 @@ namespace BansheeEngine
 
 		mCurrentLockOptions = options;
 		mLockedBox = lockBox;
-		return mBuffer.getSubVolume(lockBox);
+
+		mCurrentLock = mBuffer.getSubVolume(lockBox);
+		mIsLocked = true;
+
+		return mCurrentLock;
 	}
 
-	void GLPixelBuffer::unlockImpl(void)
+	void GLPixelBuffer::unlock()
 	{
+		assert(mIsLocked && "Cannot unlock this buffer, it is not locked!");
+
 		if (mCurrentLockOptions != GBL_READ_ONLY)
 		{
 			// From buffer to card, only upload if was locked for writing
 			upload(mCurrentLock, mLockedBox);
 		}
-	
+
 		freeBuffer();
+		mIsLocked = false;
 	}
 
 	void GLPixelBuffer::upload(const PixelData& data, const PixelVolume& dest)
@@ -135,8 +151,6 @@ namespace BansheeEngine
 		mFormat = GLPixelUtil::getClosestEngineFormat(value);
 	
 		// Default
-		mRowPitch = mWidth;
-		mSlicePitch = mHeight*mWidth;
 		mSizeInBytes = PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);
 	
 		// Set up pixel box

+ 2 - 2
Source/BansheeGLRenderAPI/Source/BsGLVertexBuffer.cpp

@@ -43,12 +43,12 @@ namespace BansheeEngine
 			mVAObjects.erase(iterFind);
 	}
 
-	void* GLVertexBufferCore::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
+	void* GLVertexBufferCore::map(UINT32 offset, UINT32 length, GpuLockOptions options)
     {
 		return mBuffer.lock(offset, length, options);
     }
 
-	void GLVertexBufferCore::unlockImpl()
+	void GLVertexBufferCore::unmap()
     {
 		mBuffer.unlock();
     }