From 250b59e07c46b3cbe53adce771b698fd215affe0 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 17 Sep 2015 17:28:52 +0200 Subject: [PATCH] Move compile asserts out, as g++ can't use AllocByteSize in class def --- renderdoc/common/wrapped_pool.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/renderdoc/common/wrapped_pool.h b/renderdoc/common/wrapped_pool.h index 68a123b49..104204847 100644 --- a/renderdoc/common/wrapped_pool.h +++ b/renderdoc/common/wrapped_pool.h @@ -130,15 +130,18 @@ class WrappingPool #endif } + static const size_t AllocCount = PoolCount; + static const size_t AllocMaxByteSize = MaxPoolByteSize; + static const size_t AllocByteSize; + private: WrappingPool() { #ifdef INCLUDE_TYPE_NAMES - RDCDEBUG("WrappingPool<%s> %d in %.2fMB: %p -> %p", GetTypeName::Name(), PoolCount, float(PoolCount*AllocByteSize)/(1024.0f*1024.0f), &m_ImmediatePool.items[0], &m_ImmediatePool.items[AllocCount-1]); + // hack - print in kB because float printing relies on statics that might not be initialised + // yet in loading order. Ugly :( + RDCDEBUG("WrappingPool<%s> %d in %dkB: %p -> %p", GetTypeName::Name(), PoolCount, (PoolCount*AllocByteSize)/1024, &m_ImmediatePool.items[0], &m_ImmediatePool.items[AllocCount-1]); #endif - - RDCCOMPILE_ASSERT(PoolCount*AllocByteSize <= MaxPoolByteSize, "Pool is bigger than max pool size cap"); - RDCCOMPILE_ASSERT(PoolCount > 2, "Pool isn't greater than 2 in size. Bad parameters?"); // make sure parameters are sane } ~WrappingPool() { @@ -148,9 +151,6 @@ class WrappingPool m_AdditionalPools.clear(); } - static const size_t AllocCount = PoolCount; - static const size_t AllocByteSize; - Threading::CriticalSection m_Lock; struct ItemPool @@ -259,5 +259,7 @@ class WrappingPool #define WRAPPED_POOL_INST(a) \ a::PoolType a::m_Pool; \ - const size_t a::PoolType::AllocByteSize = sizeof(a); \ + template<> const size_t a::PoolType::AllocByteSize = sizeof(a); \ + RDCCOMPILE_ASSERT(a::PoolType::AllocCount*a::PoolType::AllocByteSize <= a::PoolType::AllocMaxByteSize, "Pool is bigger than max pool size cap"); \ + RDCCOMPILE_ASSERT(a::PoolType::AllocCount > 2, "Pool isn't greater than 2 in size. Bad parameters?"); \ DECL_TYPENAME(a);