Browse Source

Fixing bugs

Panagiotis Christopoulos Charitos 10 years ago
parent
commit
d62a02a92d

+ 2 - 2
include/anki/gr/Common.h

@@ -48,8 +48,8 @@ const U MAX_COLOR_ATTACHMENTS = 4;
 const U MAX_MIPMAPS = 16;
 const U MAX_MIPMAPS = 16;
 const U MAX_TEXTURE_LAYERS = 32;
 const U MAX_TEXTURE_LAYERS = 32;
 const U MAX_TEXTURE_BINDINGS = 8;
 const U MAX_TEXTURE_BINDINGS = 8;
-const U MAX_UNIFORM_BUFFER_BINDINGS = 4;
-const U MAX_STORAGE_BUFFER_BINDINGS = 4;
+const U MAX_UNIFORM_BUFFER_BINDINGS = 8;
+const U MAX_STORAGE_BUFFER_BINDINGS = 8;
 const U MAX_FRAMES_IN_FLIGHT = 3;
 const U MAX_FRAMES_IN_FLIGHT = 3;
 
 
 /// GL generic callback
 /// GL generic callback

+ 2 - 2
include/anki/gr/GrManager.h

@@ -86,9 +86,9 @@ private:
 template<typename T, typename... Args>
 template<typename T, typename... Args>
 IntrusivePtr<T> GrManager::newInstance(Args&&... args)
 IntrusivePtr<T> GrManager::newInstance(Args&&... args)
 {
 {
-	T* ptr = m_alloc.newInstance<T>(this);
+	IntrusivePtr<T> ptr(m_alloc.newInstance<T>(this));
 	ptr->create(args...);
 	ptr->create(args...);
-	return IntrusivePtr<T>(ptr);
+	return ptr;
 }
 }
 /// @}
 /// @}
 
 

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

@@ -18,7 +18,9 @@ class BufferImpl: public GlObject
 public:
 public:
 	U32 m_size = 0; ///< The size of the buffer
 	U32 m_size = 0; ///< The size of the buffer
 	void* m_persistentMapping = nullptr;
 	void* m_persistentMapping = nullptr;
-	BufferUsageBit m_usage;
+	BufferUsageBit m_usage = BufferUsageBit::NONE;
+	BufferAccessBit m_access = BufferAccessBit::NONE;
+	GLenum m_target = GL_NONE; ///< A guess
 #if ANKI_ASSERTIONS
 #if ANKI_ASSERTIONS
 	Bool m_mapped = false;
 	Bool m_mapped = false;
 #endif
 #endif
@@ -46,7 +48,10 @@ public:
 	{
 	{
 		ANKI_ASSERT(isCreated());
 		ANKI_ASSERT(isCreated());
 		ANKI_ASSERT(offset + size <= m_size);
 		ANKI_ASSERT(offset + size <= m_size);
-		glNamedBufferSubData(m_glName, offset, size, buff);
+		ANKI_ASSERT((m_access & BufferAccessBit::CLIENT_WRITE)
+			!= BufferAccessBit::NONE);
+		glBindBuffer(m_target, m_glName);
+		glBufferSubData(m_target, offset, size, buff);
 	}
 	}
 };
 };
 /// @}
 /// @}

+ 1 - 1
include/anki/gr/gl/RenderingThread.h

@@ -14,7 +14,7 @@ namespace anki {
 /// @addtogroup opengl
 /// @addtogroup opengl
 /// @{
 /// @{
 
 
-#define ANKI_DISABLE_GL_RENDERING_THREAD 0
+#define ANKI_DISABLE_GL_RENDERING_THREAD 1
 
 
 /// Command queue. It's essentialy a queue of command buffers waiting for
 /// Command queue. It's essentialy a queue of command buffers waiting for
 /// execution and a server
 /// execution and a server

+ 4 - 11
include/anki/renderer/Is.h

@@ -58,19 +58,13 @@ public:
 
 
 	void generateMipmaps(CommandBufferPtr& cmdb)
 	void generateMipmaps(CommandBufferPtr& cmdb)
 	{
 	{
-		ANKI_ASSERT(0 && "TODO");
-		//m_rt.generateMipmaps(cmdb);
+		cmdb->generateMipmaps(m_rt);
 	}
 	}
 
 
 	void setAmbientColor(const Vec4& color)
 	void setAmbientColor(const Vec4& color)
 	{
 	{
 		m_ambientColor = color;
 		m_ambientColor = color;
 	}
 	}
-
-	FramebufferPtr& getFramebuffer()
-	{
-		return m_fb;
-	}
 	/// @}
 	/// @}
 
 
 private:
 private:
@@ -95,9 +89,6 @@ private:
 	/// @name GPU buffers
 	/// @name GPU buffers
 	/// @{
 	/// @{
 
 
-	/// Contains common data for all shader programs
-	BufferPtr m_commonBuffer;
-
 	/// Track the updates of commonUbo
 	/// Track the updates of commonUbo
 	Timestamp m_commonBuffUpdateTimestamp = 0;
 	Timestamp m_commonBuffUpdateTimestamp = 0;
 
 
@@ -149,6 +140,8 @@ private:
 
 
 	Vec4 m_ambientColor = Vec4(0.0);
 	Vec4 m_ambientColor = Vec4(0.0);
 
 
+	WeakPtr<Barrier> m_barrier;
+
 	/// Called by init
 	/// Called by init
 	ANKI_USE_RESULT Error initInternal(const ConfigSet& initializer);
 	ANKI_USE_RESULT Error initInternal(const ConfigSet& initializer);
 
 
@@ -161,7 +154,7 @@ private:
 	/// Calculate the size of the tile
 	/// Calculate the size of the tile
 	PtrSize calcTileSize() const;
 	PtrSize calcTileSize() const;
 
 
-	ANKI_USE_RESULT Error updateCommonBlock(CommandBufferPtr& cmdBuff);
+	void updateCommonBlock(CommandBufferPtr& cmdBuff);
 
 
 	// Binning
 	// Binning
 	void binLights(U32 threadId, PtrSize threadsCount, TaskCommonData& data);
 	void binLights(U32 threadId, PtrSize threadsCount, TaskCommonData& data);

+ 1 - 0
include/anki/renderer/Sslr.h

@@ -41,6 +41,7 @@ private:
 	ResourceGroupPtr m_rcGroupBlit;
 	ResourceGroupPtr m_rcGroupBlit;
 
 
 	// 2nd pass: blit
 	// 2nd pass: blit
+	FramebufferPtr m_isFb;
 	ShaderResourcePtr m_blitFrag;
 	ShaderResourcePtr m_blitFrag;
 	PipelinePtr m_blitPpline;
 	PipelinePtr m_blitPpline;
 };
 };

+ 13 - 15
include/anki/util/Ptr.h

@@ -3,8 +3,7 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-#ifndef ANKI_UTIL_PTR_H
-#define ANKI_UTIL_PTR_H
+#pragma once
 
 
 #include "anki/util/Assert.h"
 #include "anki/util/Assert.h"
 #include "anki/util/StdTypes.h"
 #include "anki/util/StdTypes.h"
@@ -95,11 +94,11 @@ protected:
 	T* m_ptr;
 	T* m_ptr;
 
 
 	PtrBase()
 	PtrBase()
-	:	m_ptr(nullptr)
+		: m_ptr(nullptr)
 	{}
 	{}
 
 
 	PtrBase(T* ptr)
 	PtrBase(T* ptr)
-	:	m_ptr(ptr)
+		: m_ptr(ptr)
 	{}
 	{}
 };
 };
 
 
@@ -111,19 +110,19 @@ public:
 	using Base = PtrBase<T>;
 	using Base = PtrBase<T>;
 
 
 	WeakPtr()
 	WeakPtr()
-	:	Base()
+		: Base()
 	{}
 	{}
 
 
 	WeakPtr(T* ptr)
 	WeakPtr(T* ptr)
-	:	Base(ptr)
+		: Base(ptr)
 	{}
 	{}
 
 
 	WeakPtr(const WeakPtr& other)
 	WeakPtr(const WeakPtr& other)
-	:	Base(other.m_ptr)
+		: Base(other.m_ptr)
 	{}
 	{}
 
 
 	WeakPtr(WeakPtr&& other)
 	WeakPtr(WeakPtr&& other)
-	:	Base(other.m_ptr)
+		: Base(other.m_ptr)
 	{
 	{
 		other.m_ptr = nullptr;
 		other.m_ptr = nullptr;
 	}
 	}
@@ -215,11 +214,11 @@ public:
 	using Base = PtrBase<T>;
 	using Base = PtrBase<T>;
 
 
 	UniquePtr()
 	UniquePtr()
-	:	Base()
+		: Base()
 	{}
 	{}
 
 
 	explicit UniquePtr(T* ptr)
 	explicit UniquePtr(T* ptr)
-	:	Base(ptr)
+		: Base(ptr)
 	{}
 	{}
 
 
 	/// Non-copyable.
 	/// Non-copyable.
@@ -284,18 +283,18 @@ public:
 	using Base = PtrBase<T>;
 	using Base = PtrBase<T>;
 
 
 	IntrusivePtr()
 	IntrusivePtr()
-	:	Base()
+		: Base()
 	{}
 	{}
 
 
 	IntrusivePtr(T* ptr)
 	IntrusivePtr(T* ptr)
-	:	Base()
+		: Base()
 	{
 	{
 		reset(ptr);
 		reset(ptr);
 	}
 	}
 
 
 	/// Copy.
 	/// Copy.
 	IntrusivePtr(const IntrusivePtr& other)
 	IntrusivePtr(const IntrusivePtr& other)
-	:	Base()
+		: Base()
 	{
 	{
 		reset(other.m_ptr);
 		reset(other.m_ptr);
 	}
 	}
@@ -303,7 +302,7 @@ public:
 	/// Copy, compatible pointer.
 	/// Copy, compatible pointer.
 	template<typename Y>
 	template<typename Y>
 	IntrusivePtr(const IntrusivePtr<Y, TDeleter>& other)
 	IntrusivePtr(const IntrusivePtr<Y, TDeleter>& other)
-	:	Base()
+		: Base()
 	{
 	{
 		reset(other.m_ptr);
 		reset(other.m_ptr);
 	}
 	}
@@ -360,5 +359,4 @@ private:
 
 
 } // end namespace anki
 } // end namespace anki
 
 
-#endif
 
 

+ 12 - 0
shaders/BsCommonFrag.glsl

@@ -73,6 +73,18 @@ void particleSoftTextureAlpha(in sampler2D depthMap, in sampler2D tex,
 }
 }
 #endif
 #endif
 
 
+//==============================================================================
+#if PASS == COLOR
+#	define particleTextureAlpha_DEFINED
+void particleTextureAlpha(in sampler2D tex, in float alpha)
+{
+	vec4 color = texture(tex, gl_PointCoord);
+	color.a *= alpha;
+
+	writeGBuffer(color);
+}
+#endif
+
 //==============================================================================
 //==============================================================================
 #if PASS == COLOR
 #if PASS == COLOR
 #	define particleSoftColorAlpha_DEFINED
 #	define particleSoftColorAlpha_DEFINED

+ 0 - 1
shaders/IsLp.frag.glsl

@@ -71,7 +71,6 @@ layout(binding = 0) uniform sampler2D u_msRt0;
 layout(binding = 1) uniform sampler2D u_msRt1;
 layout(binding = 1) uniform sampler2D u_msRt1;
 layout(binding = 2) uniform sampler2D u_msRt2;
 layout(binding = 2) uniform sampler2D u_msRt2;
 layout(binding = 3) uniform sampler2D u_msDepthRt;
 layout(binding = 3) uniform sampler2D u_msDepthRt;
-
 layout(binding = 4) uniform highp sampler2DArrayShadow u_shadowMapArr;
 layout(binding = 4) uniform highp sampler2DArrayShadow u_shadowMapArr;
 
 
 layout(location = 0) in vec2 in_texCoord;
 layout(location = 0) in vec2 in_texCoord;

+ 1 - 1
shaders/PpsSslr.frag.glsl

@@ -16,7 +16,7 @@ layout(location = 0) in vec2 in_texCoords;
 
 
 layout(location = 0) out vec3 out_color;
 layout(location = 0) out vec3 out_color;
 
 
-layout(std140, binding = 0) readonly buffer _blk
+layout(std140, binding = 0) uniform _u0
 {
 {
 	vec4 u_projectionParams;
 	vec4 u_projectionParams;
 
 

+ 7 - 6
src/gr/gl/BufferImpl.cpp

@@ -15,6 +15,7 @@ void BufferImpl::create(
 {
 {
 	ANKI_ASSERT(!isCreated());
 	ANKI_ASSERT(!isCreated());
 	m_usage = usage;
 	m_usage = usage;
+	m_access = access;
 
 
 	///
 	///
 	// Check size
 	// Check size
@@ -24,7 +25,7 @@ void BufferImpl::create(
 
 
 	// This is a guess, not very important since DSA doesn't care about it on
 	// This is a guess, not very important since DSA doesn't care about it on
 	// creation
 	// creation
-	GLenum target = GL_ARRAY_BUFFER;
+	m_target = GL_ARRAY_BUFFER;
 
 
 	if((usage & BufferUsageBit::UNIFORM) != BufferUsageBit::NONE)
 	if((usage & BufferUsageBit::UNIFORM) != BufferUsageBit::NONE)
 	{
 	{
@@ -42,7 +43,7 @@ void BufferImpl::create(
 				"than the implementation's min (%u)", size, maxBufferSize);
 				"than the implementation's min (%u)", size, maxBufferSize);
 		}
 		}
 
 
-		target = GL_UNIFORM_BUFFER;
+		m_target = GL_UNIFORM_BUFFER;
 	}
 	}
 
 
 	if((usage & BufferUsageBit::STORAGE) != BufferUsageBit::NONE)
 	if((usage & BufferUsageBit::STORAGE) != BufferUsageBit::NONE)
@@ -61,7 +62,7 @@ void BufferImpl::create(
 				"than the implementation's min (%u)", size, maxBufferSize);
 				"than the implementation's min (%u)", size, maxBufferSize);
 		}
 		}
 
 
-		target = GL_SHADER_STORAGE_BUFFER;
+		m_target = GL_SHADER_STORAGE_BUFFER;
 	}
 	}
 
 
 	m_size = size;
 	m_size = size;
@@ -98,8 +99,8 @@ void BufferImpl::create(
 	// Create
 	// Create
 	//
 	//
 	glGenBuffers(1, &m_glName);
 	glGenBuffers(1, &m_glName);
-	glBindBuffer(target, m_glName);
-	glBufferStorage(target, size, nullptr, flags);
+	glBindBuffer(m_target, m_glName);
+	glBufferStorage(m_target, size, nullptr, flags);
 
 
 	//
 	//
 	// Map
 	// Map
@@ -110,7 +111,7 @@ void BufferImpl::create(
 			| GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
 			| GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
 
 
 		m_persistentMapping =
 		m_persistentMapping =
-			glMapBufferRange(target, 0, size, flags & MAP_BITS);
+			glMapBufferRange(m_target, 0, size, flags & MAP_BITS);
 		ANKI_ASSERT(m_persistentMapping != nullptr);
 		ANKI_ASSERT(m_persistentMapping != nullptr);
 	}
 	}
 }
 }

+ 18 - 4
src/gr/gl/CommandBuffer.cpp

@@ -157,6 +157,7 @@ public:
 
 
 void CommandBuffer::bindResourceGroup(ResourceGroupPtr rc)
 void CommandBuffer::bindResourceGroup(ResourceGroupPtr rc)
 {
 {
+	ANKI_ASSERT(rc.isCreated());
 	m_impl->pushBackNewCommand<BindResourcesCommand>(rc);
 	m_impl->pushBackNewCommand<BindResourcesCommand>(rc);
 }
 }
 
 
@@ -418,19 +419,26 @@ public:
 	U32 m_slice;
 	U32 m_slice;
 	PtrSize m_dataSize;
 	PtrSize m_dataSize;
 	void* m_data;
 	void* m_data;
+	CommandBufferAllocator<U8> m_alloc; ///< Alloc that was used for m_data.
 
 
 	TexUploadCommand(const TexturePtr& handle, U32 mipmap, U32 slice,
 	TexUploadCommand(const TexturePtr& handle, U32 mipmap, U32 slice,
-		PtrSize dataSize, void* data)
+		PtrSize dataSize, void* data, const CommandBufferAllocator<U8>& alloc)
 		: m_handle(handle)
 		: m_handle(handle)
 		, m_mipmap(mipmap)
 		, m_mipmap(mipmap)
 		, m_slice(slice)
 		, m_slice(slice)
+		, m_dataSize(dataSize)
 		, m_data(data)
 		, m_data(data)
+		, m_alloc(alloc)
 	{}
 	{}
 
 
 	Error operator()(GlState&)
 	Error operator()(GlState&)
 	{
 	{
 		m_handle->getImplementation().write(
 		m_handle->getImplementation().write(
 			m_mipmap, m_slice, m_data, m_dataSize);
 			m_mipmap, m_slice, m_data, m_dataSize);
+
+		// Cleanup to avoid warnings
+		m_alloc.deallocate(m_data, 1);
+
 		return ErrorCode::NONE;
 		return ErrorCode::NONE;
 	}
 	}
 };
 };
@@ -444,7 +452,7 @@ void CommandBuffer::textureUploadInternal(TexturePtr tex, U32 mipmap, U32 slice,
 	data = m_impl->getInternalAllocator().allocate(dataSize);
 	data = m_impl->getInternalAllocator().allocate(dataSize);
 
 
 	m_impl->pushBackNewCommand<TexUploadCommand>(
 	m_impl->pushBackNewCommand<TexUploadCommand>(
-		tex, mipmap, slice, dataSize, data);
+		tex, mipmap, slice, dataSize, data, m_impl->getInternalAllocator());
 }
 }
 
 
 //==============================================================================
 //==============================================================================
@@ -455,18 +463,24 @@ public:
 	PtrSize m_offset;
 	PtrSize m_offset;
 	PtrSize m_range;
 	PtrSize m_range;
 	void* m_data;
 	void* m_data;
+	CommandBufferAllocator<U8> m_alloc;
 
 
 	BuffWriteCommand(const BufferPtr& handle, PtrSize offset, PtrSize range,
 	BuffWriteCommand(const BufferPtr& handle, PtrSize offset, PtrSize range,
-		void* data)
+		void* data, const CommandBufferAllocator<U8>& alloc)
 		: m_handle(handle)
 		: m_handle(handle)
 		, m_offset(offset)
 		, m_offset(offset)
 		, m_range(range)
 		, m_range(range)
 		, m_data(data)
 		, m_data(data)
+		, m_alloc(alloc)
 	{}
 	{}
 
 
 	Error operator()(GlState&)
 	Error operator()(GlState&)
 	{
 	{
 		m_handle->getImplementation().write(m_data, m_offset, m_range);
 		m_handle->getImplementation().write(m_data, m_offset, m_range);
+
+		// Cleanup to avoid warnings
+		m_alloc.deallocate(m_data, 1);
+
 		return ErrorCode::NONE;
 		return ErrorCode::NONE;
 	}
 	}
 };
 };
@@ -480,7 +494,7 @@ void CommandBuffer::writeBufferInternal(BufferPtr buff, PtrSize offset,
 	data = m_impl->getInternalAllocator().allocate(range);
 	data = m_impl->getInternalAllocator().allocate(range);
 
 
 	m_impl->pushBackNewCommand<BuffWriteCommand>(
 	m_impl->pushBackNewCommand<BuffWriteCommand>(
-		buff, offset, range, data);
+		buff, offset, range, data, m_impl->getInternalAllocator());
 }
 }
 
 
 //==============================================================================
 //==============================================================================

+ 3 - 2
src/gr/gl/FramebufferImpl.cpp

@@ -96,12 +96,13 @@ void FramebufferImpl::attachTextureInternal(
 	case GL_TEXTURE_CUBE_MAP:
 	case GL_TEXTURE_CUBE_MAP:
 		ANKI_ASSERT(layer < 6);
 		ANKI_ASSERT(layer < 6);
 		glFramebufferTexture2D(target, attachment,
 		glFramebufferTexture2D(target, attachment,
-			GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer, tex.m_target, 0);
+			GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer, tex.getGlName(), 0);
 		break;
 		break;
 	case GL_TEXTURE_2D_ARRAY:
 	case GL_TEXTURE_2D_ARRAY:
 	case GL_TEXTURE_3D:
 	case GL_TEXTURE_3D:
 		ANKI_ASSERT((GLuint)layer < tex.m_depth);
 		ANKI_ASSERT((GLuint)layer < tex.m_depth);
-		glFramebufferTextureLayer(target, attachment, tex.m_target, 0, layer);
+		glFramebufferTextureLayer(
+			target, attachment, tex.getGlName(), 0, layer);
 		break;
 		break;
 	default:
 	default:
 		ANKI_ASSERT(0);
 		ANKI_ASSERT(0);

+ 2 - 0
src/gr/gl/PipelineImpl.cpp

@@ -483,6 +483,8 @@ void PipelineImpl::setInputAssemblerState(GlState& state) const
 
 
 	state.m_stateHashes.m_inputAssembler = m_hashes.m_inputAssembler;
 	state.m_stateHashes.m_inputAssembler = m_hashes.m_inputAssembler;
 
 
+	state.m_topology = m_cache.m_topology;
+
 	if(m_in.m_inputAssembler.m_primitiveRestartEnabled)
 	if(m_in.m_inputAssembler.m_primitiveRestartEnabled)
 	{
 	{
 		glEnable(GL_PRIMITIVE_RESTART);
 		glEnable(GL_PRIMITIVE_RESTART);

+ 1 - 1
src/gr/gl/RenderingThread.cpp

@@ -97,7 +97,7 @@ void RenderingThread::flushCommandBuffer(CommandBufferPtr commands)
 
 
 	m_condVar.notifyOne(); // Wake the thread
 	m_condVar.notifyOne(); // Wake the thread
 #else
 #else
-	Error err = commands.get().executeAllCommands();
+	Error err = commands->getImplementation().executeAllCommands();
 	if(err)
 	if(err)
 	{
 	{
 		ANKI_LOGF("Error in command buffer execution");
 		ANKI_LOGF("Error in command buffer execution");

+ 34 - 1
src/gr/gl/ResourceGroup.cpp

@@ -22,10 +22,43 @@ ResourceGroup::~ResourceGroup()
 {}
 {}
 
 
 //==============================================================================
 //==============================================================================
+class RcgCreateCommand final: public GlCommand
+{
+public:
+	ResourceGroupPtr m_ptr;
+	ResourceGroupInitializer m_init;
+
+	RcgCreateCommand(ResourceGroup* ptr,
+		const ResourceGroupInitializer& init)
+		: m_ptr(ptr)
+		, m_init(init)
+	{}
+
+	Error operator()(GlState&)
+	{
+		ResourceGroupImpl& impl = m_ptr->getImplementation();
+
+		impl.create(m_init);
+
+		GlObject::State oldState =
+			impl.setStateAtomically(GlObject::State::CREATED);
+
+		(void)oldState;
+		ANKI_ASSERT(oldState == GlObject::State::TO_BE_CREATED);
+
+		return ErrorCode::NONE;
+	}
+};
+
 void ResourceGroup::create(const ResourceGroupInitializer& init)
 void ResourceGroup::create(const ResourceGroupInitializer& init)
 {
 {
+	// NOTE: Create asynchronously because the initialization touches GL names
 	m_impl.reset(getAllocator().newInstance<ResourceGroupImpl>(&getManager()));
 	m_impl.reset(getAllocator().newInstance<ResourceGroupImpl>(&getManager()));
-	m_impl->create(init);
+
+	CommandBufferPtr cmdb = getManager().newInstance<CommandBuffer>();
+
+	cmdb->getImplementation().pushBackNewCommand<RcgCreateCommand>(this, init);
+	cmdb->flush();
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 9 - 4
src/gr/gl/ResourceGroupImpl.cpp

@@ -118,7 +118,10 @@ void ResourceGroupImpl::bind(GlState& state)
 		if(binding.m_buffer.isCreated())
 		if(binding.m_buffer.isCreated())
 		{
 		{
 			const BufferImpl& buff = binding.m_buffer->getImplementation();
 			const BufferImpl& buff = binding.m_buffer->getImplementation();
-			buff.bind(GL_UNIFORM_BUFFER, i, binding.m_offset, binding.m_range);
+			PtrSize range = (binding.m_range != 0)
+				? binding.m_range
+				: (buff.m_size - binding.m_offset);
+			buff.bind(GL_UNIFORM_BUFFER, i, binding.m_offset, range);
 		}
 		}
 	}
 	}
 
 
@@ -129,9 +132,11 @@ void ResourceGroupImpl::bind(GlState& state)
 
 
 		if(binding.m_buffer.isCreated())
 		if(binding.m_buffer.isCreated())
 		{
 		{
-			BufferImpl& buff = binding.m_buffer->getImplementation();
-			buff.bind(
-				GL_SHADER_STORAGE_BUFFER, i, binding.m_offset, binding.m_range);
+			const BufferImpl& buff = binding.m_buffer->getImplementation();
+			PtrSize range = (binding.m_range != 0)
+				? binding.m_range
+				: (buff.m_size - binding.m_offset);
+			buff.bind(GL_SHADER_STORAGE_BUFFER, i, binding.m_offset, range);
 		}
 		}
 	}
 	}
 
 

+ 4 - 2
src/gr/gl/TextureImpl.cpp

@@ -398,7 +398,7 @@ void TextureImpl::write(U32 mipmap, U32 slice, void* data, PtrSize dataSize)
 				slice,
 				slice,
 				w,
 				w,
 				h,
 				h,
-				slice + 1,
+				1,
 				m_format,
 				m_format,
 				m_type,
 				m_type,
 				data);
 				data);
@@ -413,7 +413,7 @@ void TextureImpl::write(U32 mipmap, U32 slice, void* data, PtrSize dataSize)
 				slice,
 				slice,
 				w,
 				w,
 				h,
 				h,
-				slice + 1,
+				1,
 				m_format,
 				m_format,
 				dataSize,
 				dataSize,
 				data);
 				data);
@@ -422,6 +422,8 @@ void TextureImpl::write(U32 mipmap, U32 slice, void* data, PtrSize dataSize)
 	default:
 	default:
 		ANKI_ASSERT(0);
 		ANKI_ASSERT(0);
 	}
 	}
+
+	ANKI_CHECK_GL_ERROR();
 }
 }
 
 
 //==============================================================================
 //==============================================================================

+ 14 - 15
src/renderer/Is.cpp

@@ -106,7 +106,7 @@ public:
 	VisibilityTestResults::Container::ConstIterator m_lightsBegin = nullptr;
 	VisibilityTestResults::Container::ConstIterator m_lightsBegin = nullptr;
 	VisibilityTestResults::Container::ConstIterator m_lightsEnd = nullptr;
 	VisibilityTestResults::Container::ConstIterator m_lightsEnd = nullptr;
 
 
-	Barrier* m_barrier = nullptr;
+	WeakPtr<Barrier> m_barrier;
 	Is* m_is = nullptr;
 	Is* m_is = nullptr;
 };
 };
 
 
@@ -245,10 +245,6 @@ Error Is::initInternal(const ConfigSet& config)
 	//
 	//
 	// Create UBOs
 	// Create UBOs
 	//
 	//
-	m_commonBuffer = getGrManager().newInstance<Buffer>(
-		sizeof(shader::CommonUniforms), BufferUsageBit::UNIFORM,
-		BufferAccessBit::CLIENT_WRITE);
-
 	m_pLightsBuffSize = m_maxPointLights * sizeof(shader::PointLight);
 	m_pLightsBuffSize = m_maxPointLights * sizeof(shader::PointLight);
 	m_sLightsBuffSize = m_maxSpotLights * sizeof(shader::SpotLight);
 	m_sLightsBuffSize = m_maxSpotLights * sizeof(shader::SpotLight);
 	m_stLightsBuffSize = m_maxSpotTexLights * sizeof(shader::SpotLight);
 	m_stLightsBuffSize = m_maxSpotTexLights * sizeof(shader::SpotLight);
@@ -294,8 +290,6 @@ Error Is::initInternal(const ConfigSet& config)
 		init.m_textures[3].m_texture = m_r->getMs().getDepthRt();
 		init.m_textures[3].m_texture = m_r->getMs().getDepthRt();
 		init.m_textures[4].m_texture = m_sm.getTextureArray();
 		init.m_textures[4].m_texture = m_sm.getTextureArray();
 
 
-		init.m_uniformBuffers[0].m_buffer = m_commonBuffer;
-
 		init.m_storageBuffers[0].m_buffer = m_pLightsBuffs[i];
 		init.m_storageBuffers[0].m_buffer = m_pLightsBuffs[i];
 		init.m_storageBuffers[1].m_buffer = m_sLightsBuffs[i];
 		init.m_storageBuffers[1].m_buffer = m_sLightsBuffs[i];
 		init.m_storageBuffers[2].m_buffer = m_stLightsBuffs[i];
 		init.m_storageBuffers[2].m_buffer = m_stLightsBuffs[i];
@@ -305,6 +299,13 @@ Error Is::initInternal(const ConfigSet& config)
 		m_rcGroups[i] = getGrManager().newInstance<ResourceGroup>(init);
 		m_rcGroups[i] = getGrManager().newInstance<ResourceGroup>(init);
 	}
 	}
 
 
+	//
+	// Misc
+	//
+	Threadpool& threadPool = m_r->getThreadpool();
+	m_barrier = getAllocator().newInstance<Barrier>(
+		threadPool.getThreadsCount());
+
 	return ErrorCode::NONE;
 	return ErrorCode::NONE;
 }
 }
 
 
@@ -412,8 +413,7 @@ Error Is::lightPass(CommandBufferPtr& cmdBuff)
 	taskData.m_lightsBegin = vi.getLightsBegin();
 	taskData.m_lightsBegin = vi.getLightsBegin();
 	taskData.m_lightsEnd = vi.getLightsEnd();
 	taskData.m_lightsEnd = vi.getLightsEnd();
 
 
-	Barrier barrier(threadPool.getThreadsCount()); // TODO opt
-	taskData.m_barrier = &barrier;
+	taskData.m_barrier = m_barrier;
 
 
 	taskData.m_is = this;
 	taskData.m_is = this;
 
 
@@ -444,6 +444,9 @@ Error Is::lightPass(CommandBufferPtr& cmdBuff)
 	// In the meantime set the state
 	// In the meantime set the state
 	setState(cmdBuff);
 	setState(cmdBuff);
 
 
+	// Update uniforms
+	updateCommonBlock(cmdBuff);
+
 	// Sync
 	// Sync
 	ANKI_CHECK(threadPool.waitForAllThreadsToFinish());
 	ANKI_CHECK(threadPool.waitForAllThreadsToFinish());
 
 
@@ -594,8 +597,6 @@ void Is::binLights(U32 threadId, PtrSize threadsCount, TaskCommonData& task)
 			ANKI_LOGW("Light IDs buffer too small");
 			ANKI_LOGW("Light IDs buffer too small");
 		}
 		}
 	}
 	}
-
-	m_tilesBuffers[m_currentFrame]->unmap();
 }
 }
 
 
 //==============================================================================
 //==============================================================================
@@ -771,10 +772,10 @@ Error Is::run(CommandBufferPtr& cmdBuff)
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-Error Is::updateCommonBlock(CommandBufferPtr& cmdb)
+void Is::updateCommonBlock(CommandBufferPtr& cmdb)
 {
 {
 	shader::CommonUniforms* blk;
 	shader::CommonUniforms* blk;
-	cmdb->writeBuffer(m_commonBuffer, 0, sizeof(shader::CommonUniforms), blk);
+	cmdb->updateDynamicUniforms(sizeof(*blk), blk);
 
 
 	// Start writing
 	// Start writing
 	blk->m_projectionParams = m_r->getProjectionParameters();
 	blk->m_projectionParams = m_r->getProjectionParameters();
@@ -787,8 +788,6 @@ Error Is::updateCommonBlock(CommandBufferPtr& cmdb)
 			m_cam->getComponent<FrustumComponent>().getViewMatrix();
 			m_cam->getComponent<FrustumComponent>().getViewMatrix();
 		blk->m_groundLightDir = Vec4(-viewMat.getColumn(1).xyz(), 1.0);
 		blk->m_groundLightDir = Vec4(-viewMat.getColumn(1).xyz(), 1.0);
 	}
 	}
-
-	return ErrorCode::NONE;
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 2 - 0
src/renderer/Pps.cpp

@@ -121,6 +121,8 @@ Error Pps::initInternal(const ConfigSet& config)
 
 
 	rcInit.m_storageBuffers[0].m_buffer = m_tm->getAverageLuminanceBuffer();
 	rcInit.m_storageBuffers[0].m_buffer = m_tm->getAverageLuminanceBuffer();
 
 
+	m_rcGroup = getGrManager().newInstance<ResourceGroup>(rcInit);
+
 	return ErrorCode::NONE;
 	return ErrorCode::NONE;
 }
 }
 
 

+ 3 - 3
src/renderer/Renderer.cpp

@@ -101,12 +101,12 @@ Error Renderer::initInternal(const ConfigSet& config)
 	ANKI_CHECK(m_drawQuadVert.load("shaders/Quad.vert.glsl", m_resources));
 	ANKI_CHECK(m_drawQuadVert.load("shaders/Quad.vert.glsl", m_resources));
 
 
 	// Init the stages. Careful with the order!!!!!!!!!!
 	// Init the stages. Careful with the order!!!!!!!!!!
-	m_tiler.reset(m_alloc.newInstance<Tiler>(this));
-	ANKI_CHECK(m_tiler->init());
-
 	m_ms.reset(m_alloc.newInstance<Ms>(this));
 	m_ms.reset(m_alloc.newInstance<Ms>(this));
 	ANKI_CHECK(m_ms->init(config));
 	ANKI_CHECK(m_ms->init(config));
 
 
+	m_tiler.reset(m_alloc.newInstance<Tiler>(this));
+	ANKI_CHECK(m_tiler->init());
+
 	m_is.reset(m_alloc.newInstance<Is>(this));
 	m_is.reset(m_alloc.newInstance<Is>(this));
 	ANKI_CHECK(m_is->init(config));
 	ANKI_CHECK(m_is->init(config));
 
 

+ 4 - 5
src/renderer/Ssao.cpp

@@ -137,11 +137,10 @@ Error Ssao::initInternal(const ConfigSet& config)
 
 
 	PtrSize noiseSize = NOISE_TEX_SIZE * NOISE_TEX_SIZE * sizeof(Vec3);
 	PtrSize noiseSize = NOISE_TEX_SIZE * NOISE_TEX_SIZE * sizeof(Vec3);
 
 
-	void* data = nullptr;
-	cmdb->textureUpload(m_noiseTex, 0, 0, noiseSize, data);
+	Vec3* noise = nullptr;
+	cmdb->textureUpload(m_noiseTex, 0, 0, noiseSize, noise);
 
 
-	genNoise(static_cast<Vec3*>(data),
-		static_cast<Vec3*>(data) + NOISE_TEX_SIZE * NOISE_TEX_SIZE);
+	genNoise(noise, noise + NOISE_TEX_SIZE * NOISE_TEX_SIZE);
 
 
 	cmdb->flush();
 	cmdb->flush();
 
 
@@ -240,7 +239,7 @@ Error Ssao::initInternal(const ConfigSet& config)
 
 
 	rcinit = ResourceGroupInitializer();
 	rcinit = ResourceGroupInitializer();
 	rcinit.m_textures[0].m_texture = m_hblurRt;
 	rcinit.m_textures[0].m_texture = m_hblurRt;
-	m_hblurRc = getGrManager().newInstance<ResourceGroup>(rcinit);
+	m_vblurRc = getGrManager().newInstance<ResourceGroup>(rcinit);
 
 
 	return ErrorCode::NONE;
 	return ErrorCode::NONE;
 }
 }

+ 10 - 4
src/renderer/Sslr.cpp

@@ -70,10 +70,10 @@ Error Sslr::init(const ConfigSet& config)
 	fbInit.m_colorAttachmentsCount = 1;
 	fbInit.m_colorAttachmentsCount = 1;
 	fbInit.m_colorAttachments[0].m_texture = m_rt;
 	fbInit.m_colorAttachments[0].m_texture = m_rt;
 	fbInit.m_colorAttachments[0].m_loadOperation =
 	fbInit.m_colorAttachments[0].m_loadOperation =
-		AttachmentLoadOperation::LOAD;
+		AttachmentLoadOperation::DONT_CARE;
 	m_fb = getGrManager().newInstance<Framebuffer>(fbInit);
 	m_fb = getGrManager().newInstance<Framebuffer>(fbInit);
 
 
-	// Create resource group
+	// Create resource groups
 	ResourceGroupInitializer rcInit;
 	ResourceGroupInitializer rcInit;
 	rcInit.m_textures[0].m_texture = m_r->getIs().getRt();
 	rcInit.m_textures[0].m_texture = m_r->getIs().getRt();
 	rcInit.m_textures[1].m_texture = m_r->getMs().getDepthRt();
 	rcInit.m_textures[1].m_texture = m_r->getMs().getDepthRt();
@@ -84,12 +84,18 @@ Error Sslr::init(const ConfigSet& config)
 
 
 	m_rcGroup = getGrManager().newInstance<ResourceGroup>(rcInit);
 	m_rcGroup = getGrManager().newInstance<ResourceGroup>(rcInit);
 
 
-
 	ResourceGroupInitializer rcInitBlit;
 	ResourceGroupInitializer rcInitBlit;
 	rcInitBlit.m_textures[0].m_texture = m_rt;
 	rcInitBlit.m_textures[0].m_texture = m_rt;
 
 
 	m_rcGroupBlit = getGrManager().newInstance<ResourceGroup>(rcInitBlit);
 	m_rcGroupBlit = getGrManager().newInstance<ResourceGroup>(rcInitBlit);
 
 
+	// Create IS FB
+	fbInit.m_colorAttachmentsCount = 1;
+	fbInit.m_colorAttachments[0].m_texture = m_r->getIs().getRt();
+	fbInit.m_colorAttachments[0].m_loadOperation =
+		AttachmentLoadOperation::LOAD;
+	m_isFb = getGrManager().newInstance<Framebuffer>(fbInit);
+
 	return ErrorCode::NONE;
 	return ErrorCode::NONE;
 }
 }
 
 
@@ -109,7 +115,7 @@ void Sslr::run(CommandBufferPtr& cmdBuff)
 
 
 	// Write the reflection back to IS RT
 	// Write the reflection back to IS RT
 	//
 	//
-	cmdBuff->bindFramebuffer(m_r->getIs().getFramebuffer());
+	cmdBuff->bindFramebuffer(m_isFb);
 	cmdBuff->bindPipeline(m_blitPpline);
 	cmdBuff->bindPipeline(m_blitPpline);
 	cmdBuff->setViewport(0, 0, m_r->getWidth(), m_r->getHeight());
 	cmdBuff->setViewport(0, 0, m_r->getWidth(), m_r->getHeight());
 	cmdBuff->bindResourceGroup(m_rcGroupBlit);
 	cmdBuff->bindResourceGroup(m_rcGroupBlit);

+ 1 - 2
src/resource/Material.cpp

@@ -27,7 +27,6 @@ namespace anki {
 class UpdateTexturesVisitor
 class UpdateTexturesVisitor
 {
 {
 public:
 public:
-	U m_count = 0;
 	ResourceGroupInitializer* m_init = nullptr;
 	ResourceGroupInitializer* m_init = nullptr;
 
 
 	template<typename TMaterialVariableTemplate>
 	template<typename TMaterialVariableTemplate>
@@ -44,7 +43,7 @@ Error UpdateTexturesVisitor
 	::visit<MaterialVariableTemplate<TextureResourcePtr>>(
 	::visit<MaterialVariableTemplate<TextureResourcePtr>>(
 	const MaterialVariableTemplate<TextureResourcePtr>& var)
 	const MaterialVariableTemplate<TextureResourcePtr>& var)
 {
 {
-	m_init->m_textures[m_count++].m_texture =
+	m_init->m_textures[var.getTextureUnit()].m_texture =
 		(*var.begin())->getGlTexture();
 		(*var.begin())->getGlTexture();
 	return ErrorCode::NONE;
 	return ErrorCode::NONE;
 }
 }

+ 2 - 0
src/scene/ParticleEmitter.cpp

@@ -511,6 +511,8 @@ Error ParticleEmitter::frameUpdate(F32 prevUpdateTime, F32 crntTime)
 		}
 		}
 	}
 	}
 
 
+	m_vertBuffs[frame]->unmap();
+
 	if(m_aliveParticlesCount != 0)
 	if(m_aliveParticlesCount != 0)
 	{
 	{
 		Vec4 min = aabbmin - m_particle.m_size;
 		Vec4 min = aabbmin - m_particle.m_size;

+ 21 - 16
src/util/Memory.cpp

@@ -12,6 +12,7 @@
 #include "anki/util/Logger.h"
 #include "anki/util/Logger.h"
 #include <cstdlib>
 #include <cstdlib>
 #include <cstring>
 #include <cstring>
+#include <cstdio>
 
 
 namespace anki {
 namespace anki {
 
 
@@ -46,14 +47,18 @@ static Signature computeSignature(void* ptr)
 //==============================================================================
 //==============================================================================
 void* mallocAligned(PtrSize size, PtrSize alignmentBytes)
 void* mallocAligned(PtrSize size, PtrSize alignmentBytes)
 {
 {
-#if ANKI_POSIX 
+	ANKI_ASSERT(size > 0);
+	ANKI_ASSERT(alignmentBytes > 0);
+
+#if ANKI_POSIX
 #	if ANKI_OS != ANKI_OS_ANDROID
 #	if ANKI_OS != ANKI_OS_ANDROID
-	void* out;
+	void* out = nullptr;
 	U alignment = getAlignedRoundUp(alignmentBytes, sizeof(void*));
 	U alignment = getAlignedRoundUp(alignmentBytes, sizeof(void*));
 	int err = posix_memalign(&out, alignment, size);
 	int err = posix_memalign(&out, alignment, size);
 
 
 	if(!err)
 	if(!err)
 	{
 	{
+		ANKI_ASSERT(out != nullptr);
 		// Make sure it's aligned
 		// Make sure it's aligned
 		ANKI_ASSERT(isAligned(alignmentBytes, out));
 		ANKI_ASSERT(isAligned(alignmentBytes, out));
 	}
 	}
@@ -202,7 +207,7 @@ void BaseMemoryPool::free(void* ptr)
 
 
 //==============================================================================
 //==============================================================================
 HeapMemoryPool::HeapMemoryPool()
 HeapMemoryPool::HeapMemoryPool()
-:	BaseMemoryPool(Type::HEAP)
+	: BaseMemoryPool(Type::HEAP)
 {}
 {}
 
 
 //==============================================================================
 //==============================================================================
@@ -286,7 +291,7 @@ void HeapMemoryPool::free(void* ptr)
 
 
 //==============================================================================
 //==============================================================================
 StackMemoryPool::StackMemoryPool()
 StackMemoryPool::StackMemoryPool()
-:	BaseMemoryPool(Type::STACK)
+	: BaseMemoryPool(Type::STACK)
 {}
 {}
 
 
 //==============================================================================
 //==============================================================================
@@ -332,7 +337,7 @@ void StackMemoryPool::create(
 		m_top.store(m_memory);
 		m_top.store(m_memory);
 
 
 		// Calc header size
 		// Calc header size
-		m_headerSize = 
+		m_headerSize =
 			getAlignedRoundUp(m_alignmentBytes, sizeof(MemoryBlockHeader));
 			getAlignedRoundUp(m_alignmentBytes, sizeof(MemoryBlockHeader));
 	}
 	}
 	else
 	else
@@ -362,7 +367,7 @@ void* StackMemoryPool::allocate(PtrSize size, PtrSize alignment)
 #endif
 #endif
 
 
 		// Write the block header
 		// Write the block header
-		MemoryBlockHeader* header = 
+		MemoryBlockHeader* header =
 			reinterpret_cast<MemoryBlockHeader*>(out);
 			reinterpret_cast<MemoryBlockHeader*>(out);
 		U32 size32 = size;
 		U32 size32 = size;
 		memcpy(&header->m_size[0], &size32, sizeof(U32));
 		memcpy(&header->m_size[0], &size32, sizeof(U32));
@@ -390,7 +395,7 @@ void StackMemoryPool::free(void* ptr)
 {
 {
 	ANKI_ASSERT(isCreated());
 	ANKI_ASSERT(isCreated());
 
 
-	// ptr shouldn't be null or not aligned. If not aligned it was not 
+	// ptr shouldn't be null or not aligned. If not aligned it was not
 	// allocated by this class
 	// allocated by this class
 	ANKI_ASSERT(ptr != nullptr && isAligned(m_alignmentBytes, ptr));
 	ANKI_ASSERT(ptr != nullptr && isAligned(m_alignmentBytes, ptr));
 
 
@@ -474,7 +479,7 @@ void StackMemoryPool::resetUsingSnapshot(Snapshot s)
 
 
 //==============================================================================
 //==============================================================================
 ChainMemoryPool::ChainMemoryPool()
 ChainMemoryPool::ChainMemoryPool()
-:	BaseMemoryPool(Type::CHAIN)
+	: BaseMemoryPool(Type::CHAIN)
 {}
 {}
 
 
 //==============================================================================
 //==============================================================================
@@ -503,11 +508,11 @@ ChainMemoryPool::~ChainMemoryPool()
 
 
 //==============================================================================
 //==============================================================================
 void ChainMemoryPool::create(
 void ChainMemoryPool::create(
-	AllocAlignedCallback allocCb, 
+	AllocAlignedCallback allocCb,
 	void* allocCbUserData,
 	void* allocCbUserData,
 	PtrSize initialChunkSize,
 	PtrSize initialChunkSize,
 	F32 nextChunkScale,
 	F32 nextChunkScale,
-	PtrSize nextChunkBias, 
+	PtrSize nextChunkBias,
 	PtrSize alignmentBytes)
 	PtrSize alignmentBytes)
 {
 {
 	ANKI_ASSERT(!isCreated());
 	ANKI_ASSERT(!isCreated());
@@ -521,7 +526,7 @@ void ChainMemoryPool::create(
 	m_scale = nextChunkScale;
 	m_scale = nextChunkScale;
 	m_bias = nextChunkBias;
 	m_bias = nextChunkBias;
 	m_headerSize = max(m_alignmentBytes, sizeof(Chunk*));
 	m_headerSize = max(m_alignmentBytes, sizeof(Chunk*));
-	
+
 	m_lock = reinterpret_cast<SpinLock*>(m_allocCb(
 	m_lock = reinterpret_cast<SpinLock*>(m_allocCb(
 		m_allocCbUserData, nullptr, sizeof(SpinLock), alignof(SpinLock)));
 		m_allocCbUserData, nullptr, sizeof(SpinLock), alignof(SpinLock)));
 	if(!m_lock)
 	if(!m_lock)
@@ -554,7 +559,7 @@ void* ChainMemoryPool::allocate(PtrSize size, PtrSize alignment)
 	ch = m_tailChunk;
 	ch = m_tailChunk;
 
 
 	// Create new chunk if needed
 	// Create new chunk if needed
-	if(ch == nullptr 
+	if(ch == nullptr
 		|| (mem = allocateFromChunk(ch, size, alignment)) == nullptr)
 		|| (mem = allocateFromChunk(ch, size, alignment)) == nullptr)
 	{
 	{
 		// Create new chunk
 		// Create new chunk
@@ -594,7 +599,7 @@ void ChainMemoryPool::free(void* ptr)
 	Chunk* chunk = *reinterpret_cast<Chunk**>(mem);
 	Chunk* chunk = *reinterpret_cast<Chunk**>(mem);
 
 
 	ANKI_ASSERT(chunk != nullptr);
 	ANKI_ASSERT(chunk != nullptr);
-	ANKI_ASSERT((mem >= chunk->m_memory 
+	ANKI_ASSERT((mem >= chunk->m_memory
 		&& mem < (chunk->m_memory + chunk->m_memsize))
 		&& mem < (chunk->m_memory + chunk->m_memsize))
 		&& "Wrong chunk");
 		&& "Wrong chunk");
 
 
@@ -694,7 +699,7 @@ ChainMemoryPool::Chunk* ChainMemoryPool::createNewChunk(PtrSize size)
 
 
 		// Initialize it
 		// Initialize it
 		chunk->m_memory = reinterpret_cast<U8*>(chunk) + chunkAllocSize;
 		chunk->m_memory = reinterpret_cast<U8*>(chunk) + chunkAllocSize;
-		
+
 		chunk->m_memsize = memAllocSize;
 		chunk->m_memsize = memAllocSize;
 		chunk->m_top = chunk->m_memory;
 		chunk->m_top = chunk->m_memory;
 
 
@@ -715,7 +720,7 @@ ChainMemoryPool::Chunk* ChainMemoryPool::createNewChunk(PtrSize size)
 	{
 	{
 		ANKI_OOM_ACTION();
 		ANKI_OOM_ACTION();
 	}
 	}
-	
+
 	return chunk;
 	return chunk;
 }
 }
 
 
@@ -775,7 +780,7 @@ void ChainMemoryPool::destroyChunk(Chunk* ch)
 	}
 	}
 
 
 #if ANKI_DEBUG
 #if ANKI_DEBUG
-	memset(ch, 0xCC, 
+	memset(ch, 0xCC,
 		getAlignedRoundUp(m_alignmentBytes, sizeof(Chunk)) + ch->m_memsize);
 		getAlignedRoundUp(m_alignmentBytes, sizeof(Chunk)) + ch->m_memsize);
 #endif
 #endif
 	m_allocCb(m_allocCbUserData, ch, 0, 0);
 	m_allocCb(m_allocCbUserData, ch, 0, 0);