Changed implementation of logging macros.
We have observed some strange performance-related behavior as described here: https://stackoverflow.com/questions/29652787/adding-stringstream-cout-hurts-performance-even-when-the-code-is-never-called This set of changes addresses this problem. The old macros would simply expand the logging code in place, whereas we now have logging functions and the macros call these. Overall I believe it is tidier.
This commit is contained in:
parent
4dadbbffd1
commit
f16a247934
@ -198,9 +198,9 @@ namespace PolyVox
|
|||||||
m_meshCurrent->setOffset(m_regSizeInVoxels.getLowerCorner());
|
m_meshCurrent->setOffset(m_regSizeInVoxels.getLowerCorner());
|
||||||
m_meshCurrent->removeUnusedVertices();
|
m_meshCurrent->removeUnusedVertices();
|
||||||
|
|
||||||
POLYVOX_LOG_TRACE("Cubic surface extraction took " << timer.elapsedTimeInMilliSeconds()
|
POLYVOX_LOG_TRACE("Cubic surface extraction took ", timer.elapsedTimeInMilliSeconds(),
|
||||||
<< "ms (Region size = " << m_regSizeInVoxels.getWidthInVoxels() << "x" << m_regSizeInVoxels.getHeightInVoxels()
|
"ms (Region size = ", m_regSizeInVoxels.getWidthInVoxels(), "x", m_regSizeInVoxels.getHeightInVoxels(),
|
||||||
<< "x" << m_regSizeInVoxels.getDepthInVoxels() << ")");
|
"x", m_regSizeInVoxels.getDepthInVoxels(), ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename VolumeType, typename MeshType, typename IsQuadNeeded>
|
template<typename VolumeType, typename MeshType, typename IsQuadNeeded>
|
||||||
|
@ -69,7 +69,7 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
for(std::vector<std::string>::iterator iter = m_vecCreatedFiles.begin(); iter < m_vecCreatedFiles.end(); iter++)
|
for(std::vector<std::string>::iterator iter = m_vecCreatedFiles.begin(); iter < m_vecCreatedFiles.end(); iter++)
|
||||||
{
|
{
|
||||||
POLYVOX_LOG_WARNING_IF(std::remove(iter->c_str()) != 0, "Failed to delete '" << *iter << "' when destroying FilePager");
|
POLYVOX_LOG_WARNING_IF(std::remove(iter->c_str()) != 0, "Failed to delete '", *iter, "' when destroying FilePager");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vecCreatedFiles.clear();
|
m_vecCreatedFiles.clear();
|
||||||
@ -94,7 +94,7 @@ namespace PolyVox
|
|||||||
FILE* pFile = fopen(filename.c_str(), "rb");
|
FILE* pFile = fopen(filename.c_str(), "rb");
|
||||||
if(pFile)
|
if(pFile)
|
||||||
{
|
{
|
||||||
POLYVOX_LOG_TRACE("Paging in data for " << region);
|
POLYVOX_LOG_TRACE("Paging in data for ", region);
|
||||||
|
|
||||||
/*fseek(pFile, 0L, SEEK_END);
|
/*fseek(pFile, 0L, SEEK_END);
|
||||||
size_t fileSizeInBytes = ftell(pFile);
|
size_t fileSizeInBytes = ftell(pFile);
|
||||||
@ -116,7 +116,7 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
POLYVOX_LOG_TRACE("No data found for " << region << " during paging in.");
|
POLYVOX_LOG_TRACE("No data found for ", region, " during paging in.");
|
||||||
|
|
||||||
// Just fill with zeros. This feels hacky... perhaps we should just throw
|
// Just fill with zeros. This feels hacky... perhaps we should just throw
|
||||||
// an exception and let the calling code handle it and fill with zeros.
|
// an exception and let the calling code handle it and fill with zeros.
|
||||||
@ -130,7 +130,7 @@ namespace PolyVox
|
|||||||
POLYVOX_ASSERT(pChunk, "Attempting to page out NULL chunk");
|
POLYVOX_ASSERT(pChunk, "Attempting to page out NULL chunk");
|
||||||
POLYVOX_ASSERT(pChunk->getData(), "Chunk must have valid data");
|
POLYVOX_ASSERT(pChunk->getData(), "Chunk must have valid data");
|
||||||
|
|
||||||
POLYVOX_LOG_TRACE("Paging out data for " << region);
|
POLYVOX_LOG_TRACE("Paging out data for ", region);
|
||||||
|
|
||||||
std::stringstream ssFilename;
|
std::stringstream ssFilename;
|
||||||
ssFilename << m_strFolderName << "/"
|
ssFilename << m_strFolderName << "/"
|
||||||
|
@ -116,40 +116,26 @@ freely, subject to the following restrictions:
|
|||||||
* ...
|
* ...
|
||||||
*/
|
*/
|
||||||
#ifdef POLYVOX_THROW_ENABLED
|
#ifdef POLYVOX_THROW_ENABLED
|
||||||
|
namespace PolyVox
|
||||||
|
{
|
||||||
|
template< typename ExceptionType, typename ... Args >
|
||||||
|
void polyvox_throw(Args const& ... messageArgs)
|
||||||
|
{
|
||||||
|
std::string message = Impl::argListToString(messageArgs...);
|
||||||
|
#ifdef POLYVOX_LOG_ERROR_ENABLED
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logErrorMessage(message);
|
||||||
|
#endif
|
||||||
|
throw ExceptionType(message);
|
||||||
|
}
|
||||||
|
|
||||||
#define POLYVOX_THROW_IF(condition, type, message) \
|
template< typename ExceptionType, typename ... Args >
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
void polyvox_throw_if(bool condition, Args const& ... messageArgs)
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
{
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
if(condition) { polyvox_throw<ExceptionType>(messageArgs...); }
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
}
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
}
|
||||||
do \
|
#define POLYVOX_THROW(type, ...) PolyVox::polyvox_throw<type>(__VA_ARGS__)
|
||||||
{ \
|
#define POLYVOX_THROW_IF(condition, type, ...) PolyVox::polyvox_throw_if<type>(condition, __VA_ARGS__)
|
||||||
if ((condition)) \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logErrorMessage(ss.str()); \
|
|
||||||
throw type(ss.str()); \
|
|
||||||
} \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#define POLYVOX_THROW(type, message) \
|
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logErrorMessage(ss.str()); \
|
|
||||||
throw type(ss.str()); \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
|
@ -81,270 +81,152 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
Impl::getLoggerInstance() = pLogger;
|
Impl::getLoggerInstance() = pLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Impl
|
||||||
|
{
|
||||||
|
// Used for building the log messages - convert a list of variables into a string.
|
||||||
|
// Based on second approach here: http://stackoverflow.com/a/25386444/2337254
|
||||||
|
template< typename ... Args >
|
||||||
|
std::string argListToString(const Args& ... args)
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
int a[] = { 0, ((void)(oss << args), 0) ... };
|
||||||
|
(void)a; // Prevent warnings about unused param
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log trace message
|
||||||
|
template< typename ... Args >
|
||||||
|
void logTraceMessage(Args const& ... messageArgs)
|
||||||
|
{
|
||||||
|
std::string message = argListToString(messageArgs...);
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logTraceMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
template< typename ... Args >
|
||||||
|
void logTraceMessageIf(bool condition, Args const& ... messageArgs)
|
||||||
|
{
|
||||||
|
if (condition) { logTraceMessage(messageArgs...); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log debug message
|
||||||
|
template< typename ... Args >
|
||||||
|
void logDebugMessage(Args const& ... messageArgs)
|
||||||
|
{
|
||||||
|
std::string message = argListToString(messageArgs...);
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logDebugMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
template< typename ... Args >
|
||||||
|
void logDebugMessageIf(bool condition, Args const& ... messageArgs)
|
||||||
|
{
|
||||||
|
if (condition) { logDebugMessage(messageArgs...); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log info message
|
||||||
|
template< typename ... Args >
|
||||||
|
void logInfoMessage(Args const& ... messageArgs)
|
||||||
|
{
|
||||||
|
std::string message = argListToString(messageArgs...);
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logInfoMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
template< typename ... Args >
|
||||||
|
void logInfoMessageIf(bool condition, Args const& ... messageArgs)
|
||||||
|
{
|
||||||
|
if (condition) { logInfoMessage(messageArgs...); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log warning message
|
||||||
|
template< typename ... Args >
|
||||||
|
void logWarningMessage(Args const& ... messageArgs)
|
||||||
|
{
|
||||||
|
std::string message = argListToString(messageArgs...);
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logWarningMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
template< typename ... Args >
|
||||||
|
void logWarningMessageIf(bool condition, Args const& ... messageArgs)
|
||||||
|
{
|
||||||
|
if (condition) { logWarningMessage(messageArgs...); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log error message
|
||||||
|
template< typename ... Args >
|
||||||
|
void logErrorMessage(Args const& ... messageArgs)
|
||||||
|
{
|
||||||
|
std::string message = argListToString(messageArgs...);
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logErrorMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
template< typename ... Args >
|
||||||
|
void logErrorMessageIf(bool condition, Args const& ... messageArgs)
|
||||||
|
{
|
||||||
|
if (condition) { logErrorMessage(messageArgs...); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log fatal message
|
||||||
|
template< typename ... Args >
|
||||||
|
void logFatalMessage(Args const& ... messageArgs)
|
||||||
|
{
|
||||||
|
std::string message = argListToString(messageArgs...);
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logFatalMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
template< typename ... Args >
|
||||||
|
void logFatalMessageIf(bool condition, Args const& ... messageArgs)
|
||||||
|
{
|
||||||
|
if (condition) { logFatalMessage(messageArgs...); }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef POLYVOX_LOG_TRACE_ENABLED
|
#ifdef POLYVOX_LOG_TRACE_ENABLED
|
||||||
|
#define POLYVOX_LOG_TRACE(...) PolyVox::Impl::logTraceMessage(__VA_ARGS__)
|
||||||
#define POLYVOX_LOG_TRACE(message) \
|
#define POLYVOX_LOG_TRACE_IF(condition, ...) PolyVox::Impl::logTraceMessageIf(condition, __VA_ARGS__)
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logTraceMessage(ss.str()); \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#define POLYVOX_LOG_TRACE_IF(condition, message) \
|
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
if ((condition)) \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logTraceMessage(ss.str()); \
|
|
||||||
} \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#define POLYVOX_LOG_TRACE(...)
|
||||||
// We don't bother with the do...while(0) construct here as we're not executing multiple statements
|
#define POLYVOX_LOG_TRACE_IF(condition, ...)
|
||||||
// We also don't bother with forcing variables to be 'used'. If this causes a problem then calling
|
|
||||||
// code can just force them to be used itself in addition to calling the logging macro. Basically
|
|
||||||
// we just want to reduce the chance of extra code being generated.
|
|
||||||
#define POLYVOX_LOG_TRACE(message)
|
|
||||||
#define POLYVOX_LOG_TRACE_IF(condition, message)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef POLYVOX_LOG_DEBUG_ENABLED
|
#ifdef POLYVOX_LOG_DEBUG_ENABLED
|
||||||
|
#define POLYVOX_LOG_DEBUG(...) PolyVox::Impl::logDebugMessage(__VA_ARGS__)
|
||||||
#define POLYVOX_LOG_DEBUG(message) \
|
#define POLYVOX_LOG_DEBUG_IF(condition, ...) PolyVox::Impl::logDebugMessageIf(condition, __VA_ARGS__)
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logDebugMessage(ss.str()); \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#define POLYVOX_LOG_DEBUG_IF(condition, message) \
|
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
if ((condition)) \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logDebugMessage(ss.str()); \
|
|
||||||
} \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#define POLYVOX_LOG_DEBUG(...)
|
||||||
// We don't bother with the do...while(0) construct here as we're not executing multiple statements
|
#define POLYVOX_LOG_DEBUG_IF(condition, ...)
|
||||||
// We also don't bother with forcing variables to be 'used'. If this causes a problem then calling
|
|
||||||
// code can just force them to be used itself in addition to calling the logging macro. Basically
|
|
||||||
// we just want to reduce the chance of extra code being generated.
|
|
||||||
#define POLYVOX_LOG_DEBUG(message)
|
|
||||||
#define POLYVOX_LOG_DEBUG_IF(condition, message)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef POLYVOX_LOG_INFO_ENABLED
|
#ifdef POLYVOX_LOG_INFO_ENABLED
|
||||||
|
#define POLYVOX_LOG_INFO(...) PolyVox::Impl::logInfoMessage(__VA_ARGS__)
|
||||||
#define POLYVOX_LOG_INFO(message) \
|
#define POLYVOX_LOG_INFO_IF(condition, ...) PolyVox::Impl::logInfoMessageIf(condition, __VA_ARGS__)
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logInfoMessage(ss.str()); \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#define POLYVOX_LOG_INFO_IF(condition, message) \
|
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
if ((condition)) \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logInfoMessage(ss.str()); \
|
|
||||||
} \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#define POLYVOX_LOG_INFO(...)
|
||||||
// We don't bother with the do...while(0) construct here as we're not executing multiple statements
|
#define POLYVOX_LOG_INFO_IF(condition, ...)
|
||||||
// We also don't bother with forcing variables to be 'used'. If this causes a problem then calling
|
|
||||||
// code can just force them to be used itself in addition to calling the logging macro. Basically
|
|
||||||
// we just want to reduce the chance of extra code being generated.
|
|
||||||
#define POLYVOX_LOG_INFO(message)
|
|
||||||
#define POLYVOX_LOG_INFO_IF(condition, message)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef POLYVOX_LOG_WARNING_ENABLED
|
#ifdef POLYVOX_LOG_WARNING_ENABLED
|
||||||
|
#define POLYVOX_LOG_WARNING(...) PolyVox::Impl::logWarningMessage(__VA_ARGS__)
|
||||||
#define POLYVOX_LOG_WARNING(message) \
|
#define POLYVOX_LOG_WARNING_IF(condition, ...) PolyVox::Impl::logWarningMessageIf(condition, __VA_ARGS__)
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logWarningMessage(ss.str()); \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#define POLYVOX_LOG_WARNING_IF(condition, message) \
|
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
if ((condition)) \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logWarningMessage(ss.str()); \
|
|
||||||
} \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#define POLYVOX_LOG_WARNING(...)
|
||||||
// We don't bother with the do...while(0) construct here as we're not executing multiple statements
|
#define POLYVOX_LOG_WARNING_IF(condition, ...)
|
||||||
// We also don't bother with forcing variables to be 'used'. If this causes a problem then calling
|
|
||||||
// code can just force them to be used itself in addition to calling the logging macro. Basically
|
|
||||||
// we just want to reduce the chance of extra code being generated.
|
|
||||||
#define POLYVOX_LOG_WARNING(message)
|
|
||||||
#define POLYVOX_LOG_WARNING_IF(condition, message)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef POLYVOX_LOG_ERROR_ENABLED
|
#ifdef POLYVOX_LOG_ERROR_ENABLED
|
||||||
|
#define POLYVOX_LOG_ERROR(...) PolyVox::Impl::logErrorMessage(__VA_ARGS__)
|
||||||
#define POLYVOX_LOG_ERROR(message) \
|
#define POLYVOX_LOG_ERROR_IF(condition, ...) PolyVox::Impl::logErrorMessageIf(condition, __VA_ARGS__)
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logErrorMessage(ss.str()); \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#define POLYVOX_LOG_ERROR_IF(condition, message) \
|
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
if ((condition)) \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logErrorMessage(ss.str()); \
|
|
||||||
} \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#define POLYVOX_LOG_ERROR(...)
|
||||||
// We don't bother with the do...while(0) construct here as we're not executing multiple statements
|
#define POLYVOX_LOG_ERROR_IF(condition, ...)
|
||||||
// We also don't bother with forcing variables to be 'used'. If this causes a problem then calling
|
|
||||||
// code can just force them to be used itself in addition to calling the logging macro. Basically
|
|
||||||
// we just want to reduce the chance of extra code being generated.
|
|
||||||
#define POLYVOX_LOG_ERROR(message)
|
|
||||||
#define POLYVOX_LOG_ERROR_IF(condition, message)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef POLYVOX_LOG_FATAL_ENABLED
|
#ifdef POLYVOX_LOG_FATAL_ENABLED
|
||||||
|
#define POLYVOX_LOG_FATAL(...) PolyVox::Impl::logFatalMessage(__VA_ARGS__)
|
||||||
#define POLYVOX_LOG_FATAL(message) \
|
#define POLYVOX_LOG_FATAL_IF(condition, ...) PolyVox::Impl::logFatalMessageIf(condition, __VA_ARGS__)
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logFatalMessage(ss.str()); \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#define POLYVOX_LOG_FATAL_IF(condition, message) \
|
|
||||||
/* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \
|
|
||||||
but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \
|
|
||||||
(http://stackoverflow.com/a/1946485) is to disable these warnings. */ \
|
|
||||||
POLYVOX_MSC_WARNING_PUSH \
|
|
||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
|
||||||
do \
|
|
||||||
{ \
|
|
||||||
if ((condition)) \
|
|
||||||
{ \
|
|
||||||
std::stringstream ss; \
|
|
||||||
ss << message; \
|
|
||||||
PolyVox::Impl::getLoggerInstance()->logFatalMessage(ss.str()); \
|
|
||||||
} \
|
|
||||||
} while(0) \
|
|
||||||
POLYVOX_MSC_WARNING_POP
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#define POLYVOX_LOG_FATAL(...)
|
||||||
// We don't bother with the do...while(0) construct here as we're not executing multiple statements
|
#define POLYVOX_LOG_FATAL_IF(condition, ...)
|
||||||
// We also don't bother with forcing variables to be 'used'. If this causes a problem then calling
|
|
||||||
// code can just force them to be used itself in addition to calling the logging macro. Basically
|
|
||||||
// we just want to reduce the chance of extra code being generated.
|
|
||||||
#define POLYVOX_LOG_FATAL(message)
|
|
||||||
#define POLYVOX_LOG_FATAL_IF(condition, message)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //__PolyVox_Logging_H__
|
#endif //__PolyVox_Logging_H__
|
@ -122,9 +122,9 @@ namespace PolyVox
|
|||||||
|
|
||||||
m_meshCurrent->setOffset(m_regSizeInVoxels.getLowerCorner());
|
m_meshCurrent->setOffset(m_regSizeInVoxels.getLowerCorner());
|
||||||
|
|
||||||
POLYVOX_LOG_TRACE("Marching cubes surface extraction took " << timer.elapsedTimeInMilliSeconds()
|
POLYVOX_LOG_TRACE("Marching cubes surface extraction took ", timer.elapsedTimeInMilliSeconds(),
|
||||||
<< "ms (Region size = " << m_regSizeInVoxels.getWidthInVoxels() << "x" << m_regSizeInVoxels.getHeightInVoxels()
|
"ms (Region size = ", m_regSizeInVoxels.getWidthInVoxels(), "x", m_regSizeInVoxels.getHeightInVoxels(),
|
||||||
<< "x" << m_regSizeInVoxels.getDepthInVoxels() << ")");
|
"x", m_regSizeInVoxels.getDepthInVoxels(), ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename VolumeType, typename MeshType, typename ControllerType>
|
template<typename VolumeType, typename MeshType, typename ControllerType>
|
||||||
|
@ -59,14 +59,14 @@ namespace PolyVox
|
|||||||
// Enforce sensible limits on the number of chunks.
|
// Enforce sensible limits on the number of chunks.
|
||||||
const uint32_t uMinPracticalNoOfChunks = 32; // Enough to make sure a chunks and it's neighbours can be loaded, with a few to spare.
|
const uint32_t uMinPracticalNoOfChunks = 32; // Enough to make sure a chunks and it's neighbours can be loaded, with a few to spare.
|
||||||
const uint32_t uMaxPracticalNoOfChunks = uChunkArraySize / 2; // A hash table should only become half-full to avoid too many clashes.
|
const uint32_t uMaxPracticalNoOfChunks = uChunkArraySize / 2; // A hash table should only become half-full to avoid too many clashes.
|
||||||
POLYVOX_LOG_WARNING_IF(m_uChunkCountLimit < uMinPracticalNoOfChunks, "Requested memory usage limit of "
|
POLYVOX_LOG_WARNING_IF(m_uChunkCountLimit < uMinPracticalNoOfChunks, "Requested memory usage limit of ",
|
||||||
<< uTargetMemoryUsageInBytes / (1024 * 1024) << "Mb is too low and cannot be adhered to.");
|
uTargetMemoryUsageInBytes / (1024 * 1024), "Mb is too low and cannot be adhered to.");
|
||||||
m_uChunkCountLimit = (std::max)(m_uChunkCountLimit, uMinPracticalNoOfChunks);
|
m_uChunkCountLimit = (std::max)(m_uChunkCountLimit, uMinPracticalNoOfChunks);
|
||||||
m_uChunkCountLimit = (std::min)(m_uChunkCountLimit, uMaxPracticalNoOfChunks);
|
m_uChunkCountLimit = (std::min)(m_uChunkCountLimit, uMaxPracticalNoOfChunks);
|
||||||
|
|
||||||
// Inform the user about the chosen memory configuration.
|
// Inform the user about the chosen memory configuration.
|
||||||
POLYVOX_LOG_DEBUG("Memory usage limit for volume now set to " << (m_uChunkCountLimit * uChunkSizeInBytes) / (1024 * 1024)
|
POLYVOX_LOG_DEBUG("Memory usage limit for volume now set to ", (m_uChunkCountLimit * uChunkSizeInBytes) / (1024 * 1024),
|
||||||
<< "Mb (" << m_uChunkCountLimit << " chunks of " << uChunkSizeInBytes / 1024 << "Kb each).");
|
"Mb (", m_uChunkCountLimit, " chunks of ", uChunkSizeInBytes / 1024, "Kb each).");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -335,7 +335,7 @@ namespace PolyVox
|
|||||||
|
|
||||||
// This should never really happen unless we are failing to keep our number of active chunks
|
// This should never really happen unless we are failing to keep our number of active chunks
|
||||||
// significantly under the target amount. Perhaps if chunks are 'pinned' for threading purposes?
|
// significantly under the target amount. Perhaps if chunks are 'pinned' for threading purposes?
|
||||||
//POLYVOX_THROW_IF(!bInsertedSucessfully, std::logic_error, "No space in chunk array for new chunk.");
|
POLYVOX_THROW_IF(!bInsertedSucessfully, std::logic_error, "No space in chunk array for new chunk.");
|
||||||
|
|
||||||
// As we have added a chunk we may have exceeded our target chunk limit. Search through the array to
|
// As we have added a chunk we may have exceeded our target chunk limit. Search through the array to
|
||||||
// determine how many chunks we have, as well as finding the oldest timestamp. Note that this is potentially
|
// determine how many chunks we have, as well as finding the oldest timestamp. Note that this is potentially
|
||||||
|
Loading…
x
Reference in New Issue
Block a user