Panagiotis Christopoulos Charitos před 10 roky
rodič
revize
b8f90229c7

+ 6 - 10
include/anki/gr/BufferHandle.h

@@ -3,10 +3,10 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
-#ifndef ANKI_GL_GL_BUFFER_HANDLE_H
-#define ANKI_GL_GL_BUFFER_HANDLE_H
+#ifndef ANKI_GR_BUFFER_HANDLE_H
+#define ANKI_GR_BUFFER_HANDLE_H
 
-#include "anki/gr/GlContainerHandle.h"
+#include "anki/gr/GrHandle.h"
 
 namespace anki {
 
@@ -14,10 +14,10 @@ namespace anki {
 /// @{
 
 /// GPU buffer handle
-class BufferHandle: public GlContainerHandle<BufferImpl>
+class BufferHandle: public GrHandle<BufferImpl>
 {
 public:
-	using Base = GlContainerHandle<BufferImpl>;
+	using Base = GrHandle<BufferImpl>;
 
 	BufferHandle();
 
@@ -25,11 +25,7 @@ public:
 
 	/// Create the buffer with data
 	ANKI_USE_RESULT Error create(CommandBufferHandle& commands, GLenum target, 
-		ClientBufferHandle& data, GLbitfield flags);
-
-	/// Create the buffer without data
-	ANKI_USE_RESULT Error create(CommandBufferHandle& commands, GLenum target, 
-		PtrSize size, GLbitfield flags);
+		const void* data, PtrSize size, GLbitfield flags);
 
 	/// Get buffer size. It may serialize 
 	PtrSize getSize() const;

+ 2 - 2
include/anki/gr/gl/BufferImpl.h

@@ -34,12 +34,12 @@ public:
 	/// Creates a new BO with the given parameters and checks if everything
 	/// went OK. Throws exception if fails
 	/// @param target Depends on the BO
-	/// @param sizeInBytes The size of the buffer that we will allocate in bytes
 	/// @param dataPtr Points to the data buffer to copy to the VGA memory.
 	///		   Put NULL if you want just to allocate memory
+	/// @param sizeInBytes The size of the buffer that we will allocate in bytes
 	/// @param flags GL access flags
 	ANKI_USE_RESULT Error create(
-		GLenum target, U32 sizeInBytes, const void* dataPtr, GLbitfield flags);
+		GLenum target, const void* dataPtr, U32 sizeInBytes, GLbitfield flags);
 
 	GLenum getTarget() const
 	{

+ 13 - 32
src/gr/gl/BufferHandle.cpp

@@ -4,63 +4,44 @@
 // http://www.anki3d.org/LICENSE
 
 #include "anki/gr/BufferHandle.h"
-#include "anki/gr/GlHandleDeferredDeleter.h"
-#include "anki/gr/ClientBufferHandle.h"
+#include "anki/gr/gl/HandleDeferredDeleter.h"
 #include "anki/gr/gl/BufferImpl.h"
-#include "anki/gr/GlDevice.h"
+#include "anki/gr/GrManager.h"
 
 namespace anki {
 
 //==============================================================================
 /// Create buffer command
-class GlBufferCreateCommand: public GlCommand
+class BufferCreateCommand: public GlCommand
 {
 public:
 	BufferHandle m_buff;
 	GLenum m_target;
-	ClientBufferHandle m_data;
+	const void* m_data;
 	PtrSize m_size;
 	GLbitfield m_flags;
-	Bool8 m_empty;
 
-	GlBufferCreateCommand(
-		BufferHandle buff, GLenum target, ClientBufferHandle data, 
+	BufferCreateCommand(
+		BufferHandle buff, GLenum target, const void* data, PtrSize size
 		GLenum flags)
 	:	m_buff(buff), 
 		m_target(target), 
 		m_data(data), 
-		m_flags(flags), 
-		m_empty(false)
-	{}
-
-	GlBufferCreateCommand(
-		BufferHandle buff, GLenum target, PtrSize size, GLenum flags)
-	:	m_buff(buff), 
-		m_target(target), 
-		m_size(size), 
-		m_flags(flags), 
-		m_empty(true)
+		m_size(size),
+		m_flags(flags)
 	{}
 
 	Error operator()(CommandBufferImpl*)
 	{
 		Error err = ErrorCode::NONE;
 
-		if(!m_empty)
-		{
-			err = m_buff._get().create(m_target, m_data.getSize(), 
-				m_data.getBaseAddress(), m_flags);
-		}
-		else
-		{
-			err = m_buff._get().create(m_target, m_size, nullptr, m_flags);
-		}
+		err = m_buff.get().create(m_target, m_data, m_size, m_flags);
 
-		GlHandleState oldState = m_buff._setState(
+		GlObject::State oldState = m_buff.get().getStateAtomically(
 			(err) ? GlHandleState::ERROR : GlHandleState::CREATED);
 
 		(void)oldState;
-		ANKI_ASSERT(oldState == GlHandleState::TO_BE_CREATED);
+		ANKI_ASSERT(oldState == GlObject::State::TO_BE_CREATED);
 
 		return err;
 	}
@@ -97,7 +78,7 @@ Error BufferHandle::create(CommandBufferHandle& commands,
 		_setState(GlHandleState::TO_BE_CREATED);
 
 		// Fire the command
-		commands._pushBackNewCommand<GlBufferCreateCommand>(
+		commands._pushBackNewCommand<BufferCreateCommand>(
 			*this, target, data, flags);
 	}
 
@@ -127,7 +108,7 @@ Error BufferHandle::create(CommandBufferHandle& commands,
 		_setState(GlHandleState::TO_BE_CREATED);
 		
 		// Fire the command
-		commands._pushBackNewCommand<GlBufferCreateCommand>(
+		commands._pushBackNewCommand<BufferCreateCommand>(
 			*this, target, size, flags);
 	}
 

+ 2 - 2
src/gr/gl/BufferImpl.cpp

@@ -22,8 +22,8 @@ void BufferImpl::destroy()
 }
 
 //==============================================================================
-Error BufferImpl::create(GLenum target, U32 sizeInBytes,
-	const void* dataPtr, GLbitfield flags)
+Error BufferImpl::create(GLenum target, const void* dataPtr, 
+	U32 sizeInBytes, GLbitfield flags)
 {
 	ANKI_ASSERT(!isCreated());