diff --git a/Core/include/BlockStats.h b/Core/include/BlockStats.h index ea75e81..91294de 100644 --- a/Core/include/BlockStats.h +++ b/Core/include/BlockStats.h @@ -114,17 +114,18 @@ class BlockStatManager { private: BlockStatList(const BlockStat &stat); - BlockStat m_Stat; BlockStatList *m_Tail; + BlockStat m_Stat; ReferenceCounter m_Counter; } *m_BlockStatList; uint32 m_BlockStatListSz; - TCMutex *m_Mutex; uint32 m_NextBlock; ReferenceCounter m_Counter; + TCMutex *m_Mutex; + // Note: we probably shouldn't call this... void Copy(const BlockStatManager &); }; diff --git a/Core/include/CompressedImage.h b/Core/include/CompressedImage.h index 378ef21..2310403 100644 --- a/Core/include/CompressedImage.h +++ b/Core/include/CompressedImage.h @@ -55,12 +55,14 @@ enum ECompressionFormat { class CompressedImage { private: - unsigned char *m_Data; - unsigned int m_DataSz; unsigned int m_Width; unsigned int m_Height; + ECompressionFormat m_Format; + unsigned char *m_Data; + unsigned int m_DataSz; + void InitData(const unsigned char *withData); public: CompressedImage(); @@ -71,8 +73,8 @@ class CompressedImage { const unsigned char *data ); - unsigned int GetHeight() const { return m_Height; } - unsigned int GetWidth() const { return m_Width; } + unsigned int GetHeight() const { return m_Height; } + unsigned int GetWidth() const { return m_Width; } CompressedImage( const CompressedImage &other ); ~CompressedImage(); diff --git a/Core/src/BlockStats.cpp b/Core/src/BlockStats.cpp index 8af48e1..a6be70b 100644 --- a/Core/src/BlockStats.cpp +++ b/Core/src/BlockStats.cpp @@ -63,8 +63,8 @@ static T max(const T &a, const T &b) { //////////////////////////////////////////////////////////////////////////////// BlockStat::BlockStat(const CHAR *statName, int stat) - : m_IntStat(stat) - , m_Type(eType_Int) + : m_Type(eType_Int) + , m_IntStat(stat) { #ifdef _MSC_VER strncpy_s(m_StatName, statName, kStatNameSz); @@ -74,8 +74,8 @@ BlockStat::BlockStat(const CHAR *statName, int stat) } BlockStat::BlockStat(const CHAR *statName, double stat) - : m_FloatStat(stat) - , m_Type(eType_Float) + : m_Type(eType_Float) + , m_FloatStat(stat) { #ifdef _MSC_VER strncpy_s(m_StatName, statName, kStatNameSz); @@ -124,19 +124,19 @@ void BlockStat::ToString(CHAR *buf, int bufSz) const { //////////////////////////////////////////////////////////////////////////////// void BlockStatManager::Copy(const BlockStatManager &other) { - // This is a bug. If we copy the manager then all of the lists and pointers - // become shared and can cause dereferencing issues. Check to see where you're - // copying this class and make sure to actually create a new instance. - assert(!"We shouldn't be copying these in this manner!"); - - m_BlockStatList = new BlockStatList(*other.m_BlockStatList); - m_BlockStatListSz = other.m_BlockStatListSz; - m_NextBlock = other.m_NextBlock; + // This is a bug. If we copy the manager then all of the lists and pointers + // become shared and can cause dereferencing issues. Check to see where you're + // copying this class and make sure to actually create a new instance. + assert(!"We shouldn't be copying these in this manner!"); - // If we do copy them, then make sure that we are actually using the exact same - // pointers for our synchronization primitives... otherwise we could run into - // deadlock issues. - m_Mutex = other.m_Mutex; + m_BlockStatList = new BlockStatList(*other.m_BlockStatList); + m_BlockStatListSz = other.m_BlockStatListSz; + m_NextBlock = other.m_NextBlock; + + // If we do copy them, then make sure that we are actually using the exact same + // pointers for our synchronization primitives... otherwise we could run into + // deadlock issues. + m_Mutex = other.m_Mutex; } BlockStatManager::BlockStatManager(const BlockStatManager &other) { diff --git a/Core/src/CompressedImage.cpp b/Core/src/CompressedImage.cpp index de09bee..0b6e949 100644 --- a/Core/src/CompressedImage.cpp +++ b/Core/src/CompressedImage.cpp @@ -89,6 +89,7 @@ void CompressedImage::InitData(const unsigned char *withData) { int uncompDataSz = m_Width * m_Height * 4; switch(m_Format) { + default: assert(!"Not implemented!"); // Fall through V case eCompressionFormat_DXT1: m_DataSz = uncompDataSz / 8; break; case eCompressionFormat_DXT5: m_DataSz = uncompDataSz / 4; break; case eCompressionFormat_BPTC: m_DataSz = uncompDataSz / 4; break; @@ -112,6 +113,7 @@ bool CompressedImage::DecompressImage(unsigned char *outBuf, unsigned int outBuf // First make sure that we have enough data uint32 dataSz = 0; switch(m_Format) { + default: assert(!"Not implemented!"); // Fall through V case eCompressionFormat_DXT1: dataSz = m_DataSz * 8; break; case eCompressionFormat_DXT5: dataSz = m_DataSz * 4; break; case eCompressionFormat_BPTC: dataSz = m_DataSz * 4; break; diff --git a/Core/src/Image.cpp b/Core/src/Image.cpp index d586f4f..6c03f7b 100644 --- a/Core/src/Image.cpp +++ b/Core/src/Image.cpp @@ -70,9 +70,9 @@ Image::Image(const CompressedImage &ci) } Image::Image(const ImageLoader &loader) - : m_PixelData(0) - , m_Width(loader.GetWidth()) + : m_Width(loader.GetWidth()) , m_Height(loader.GetHeight()) + , m_PixelData(0) { if(loader.GetImageData()) { m_PixelData = new uint8[ loader.GetImageDataSz() ]; @@ -93,6 +93,7 @@ CompressedImage *Image::Compress(const SCompressionSettings &settings) const { // Allocate data based on the compression method int cmpDataSz = 0; switch(settings.format) { + default: assert(!"Not implemented!"); case eCompressionFormat_DXT1: cmpDataSz = dataSz / 8; case eCompressionFormat_DXT5: cmpDataSz = dataSz / 4; case eCompressionFormat_BPTC: cmpDataSz = dataSz / 4; diff --git a/Core/src/StopWatchOSX.cpp b/Core/src/StopWatchOSX.cpp index 7980cec..50f6363 100644 --- a/Core/src/StopWatchOSX.cpp +++ b/Core/src/StopWatchOSX.cpp @@ -71,6 +71,7 @@ StopWatch &StopWatch::operator=(const StopWatch &other) { } impl = new StopWatchImpl(); memcpy(impl, other.impl, sizeof(StopWatchImpl)); + return *this; } StopWatch::~StopWatch() { diff --git a/Core/src/TexComp.cpp b/Core/src/TexComp.cpp index 6d2e990..030ee81 100644 --- a/Core/src/TexComp.cpp +++ b/Core/src/TexComp.cpp @@ -93,6 +93,12 @@ static CompressionFuncWithStats ChooseFuncFromSettingsWithStats(const SCompress return BC7C::CompressImageBC7Stats; } break; + + default: + { + assert(!"Not implemented!"); + return NULL; + } } return NULL; } @@ -114,6 +120,12 @@ static CompressionFunc ChooseFuncFromSettings(const SCompressionSettings &s) { #endif } break; + + default: + { + assert(!"Not implemented!"); + return NULL; + } } return NULL; } @@ -270,9 +282,10 @@ bool CompressImageData( // Allocate data based on the compression method uint32 cmpDataSzNeeded = 0; switch(settings.format) { - case eCompressionFormat_DXT1: cmpDataSzNeeded = dataSz / 8; - case eCompressionFormat_DXT5: cmpDataSzNeeded = dataSz / 4; - case eCompressionFormat_BPTC: cmpDataSzNeeded = dataSz / 4; + default: assert(!"Not implemented!"); // Fall through V + case eCompressionFormat_DXT1: cmpDataSzNeeded = dataSz / 8; break; + case eCompressionFormat_DXT5: cmpDataSzNeeded = dataSz / 4; break; + case eCompressionFormat_BPTC: cmpDataSzNeeded = dataSz / 4; break; } if(cmpDataSzNeeded == 0) { diff --git a/Core/src/Thread.cpp b/Core/src/Thread.cpp index d1442d3..fb75f57 100644 --- a/Core/src/Thread.cpp +++ b/Core/src/Thread.cpp @@ -117,8 +117,8 @@ private: public: TCBarrierImpl(int threads) : TCThreadBaseImpl() - , m_ThreadCount(threads) , m_ThreadLimit(threads) + , m_ThreadCount(threads) , m_Times(0) { assert(threads > 0); diff --git a/Core/src/ThreadGroup.h b/Core/src/ThreadGroup.h index 46571cb..9c098f5 100644 --- a/Core/src/ThreadGroup.h +++ b/Core/src/ThreadGroup.h @@ -133,13 +133,13 @@ class ThreadGroup { const unsigned char *const m_ImageData; unsigned char *m_OutBuf; - const unsigned int m_CompressedBlockSize; - const unsigned int m_UncompressedBlockSize; - StopWatch m_StopWatch; EThreadState m_ThreadState; bool m_ExitFlag; + + const unsigned int m_CompressedBlockSize; + const unsigned int m_UncompressedBlockSize; }; #endif // _THREAD_GROUP_H_ diff --git a/Core/src/WorkerQueue.h b/Core/src/WorkerQueue.h index 97d6833..5f42fc8 100644 --- a/Core/src/WorkerQueue.h +++ b/Core/src/WorkerQueue.h @@ -134,9 +134,10 @@ class WorkerQueue { const CompressionFunc m_CompressionFunc; CompressionFunc GetCompressionFunc() const { return m_CompressionFunc; } - BlockStatManager *m_BlockStatManager; const CompressionFuncWithStats m_CompressionFuncWithStats; CompressionFuncWithStats GetCompressionFuncWithStats() const { return m_CompressionFuncWithStats; } + + BlockStatManager *m_BlockStatManager; BlockStatManager *GetBlockStatManager() const { return m_BlockStatManager; } StopWatch m_StopWatch;