Got rid of some more compiler warnings.

This commit is contained in:
Pavel Krajcevski 2013-01-28 16:57:15 -05:00
parent 08df6f6d65
commit 1b30efe488
10 changed files with 53 additions and 32 deletions

View file

@ -114,17 +114,18 @@ class BlockStatManager {
private: private:
BlockStatList(const BlockStat &stat); BlockStatList(const BlockStat &stat);
BlockStat m_Stat;
BlockStatList *m_Tail; BlockStatList *m_Tail;
BlockStat m_Stat;
ReferenceCounter m_Counter; ReferenceCounter m_Counter;
} *m_BlockStatList; } *m_BlockStatList;
uint32 m_BlockStatListSz; uint32 m_BlockStatListSz;
TCMutex *m_Mutex;
uint32 m_NextBlock; uint32 m_NextBlock;
ReferenceCounter m_Counter; ReferenceCounter m_Counter;
TCMutex *m_Mutex;
// Note: we probably shouldn't call this... // Note: we probably shouldn't call this...
void Copy(const BlockStatManager &); void Copy(const BlockStatManager &);
}; };

View file

@ -55,12 +55,14 @@ enum ECompressionFormat {
class CompressedImage { class CompressedImage {
private: private:
unsigned char *m_Data;
unsigned int m_DataSz;
unsigned int m_Width; unsigned int m_Width;
unsigned int m_Height; unsigned int m_Height;
ECompressionFormat m_Format; ECompressionFormat m_Format;
unsigned char *m_Data;
unsigned int m_DataSz;
void InitData(const unsigned char *withData); void InitData(const unsigned char *withData);
public: public:
CompressedImage(); CompressedImage();
@ -71,8 +73,8 @@ class CompressedImage {
const unsigned char *data const unsigned char *data
); );
unsigned int GetHeight() const { return m_Height; } unsigned int GetHeight() const { return m_Height; }
unsigned int GetWidth() const { return m_Width; } unsigned int GetWidth() const { return m_Width; }
CompressedImage( const CompressedImage &other ); CompressedImage( const CompressedImage &other );
~CompressedImage(); ~CompressedImage();

View file

@ -63,8 +63,8 @@ static T max(const T &a, const T &b) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
BlockStat::BlockStat(const CHAR *statName, int stat) BlockStat::BlockStat(const CHAR *statName, int stat)
: m_IntStat(stat) : m_Type(eType_Int)
, m_Type(eType_Int) , m_IntStat(stat)
{ {
#ifdef _MSC_VER #ifdef _MSC_VER
strncpy_s(m_StatName, statName, kStatNameSz); strncpy_s(m_StatName, statName, kStatNameSz);
@ -74,8 +74,8 @@ BlockStat::BlockStat(const CHAR *statName, int stat)
} }
BlockStat::BlockStat(const CHAR *statName, double 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 #ifdef _MSC_VER
strncpy_s(m_StatName, statName, kStatNameSz); strncpy_s(m_StatName, statName, kStatNameSz);
@ -124,19 +124,19 @@ void BlockStat::ToString(CHAR *buf, int bufSz) const {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void BlockStatManager::Copy(const BlockStatManager &other) { void BlockStatManager::Copy(const BlockStatManager &other) {
// This is a bug. If we copy the manager then all of the lists and pointers // 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 // 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. // copying this class and make sure to actually create a new instance.
assert(!"We shouldn't be copying these in this manner!"); 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;
// If we do copy them, then make sure that we are actually using the exact same m_BlockStatList = new BlockStatList(*other.m_BlockStatList);
// pointers for our synchronization primitives... otherwise we could run into m_BlockStatListSz = other.m_BlockStatListSz;
// deadlock issues. m_NextBlock = other.m_NextBlock;
m_Mutex = other.m_Mutex;
// 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) { BlockStatManager::BlockStatManager(const BlockStatManager &other) {

View file

@ -89,6 +89,7 @@ void CompressedImage::InitData(const unsigned char *withData) {
int uncompDataSz = m_Width * m_Height * 4; int uncompDataSz = m_Width * m_Height * 4;
switch(m_Format) { switch(m_Format) {
default: assert(!"Not implemented!"); // Fall through V
case eCompressionFormat_DXT1: m_DataSz = uncompDataSz / 8; break; case eCompressionFormat_DXT1: m_DataSz = uncompDataSz / 8; break;
case eCompressionFormat_DXT5: m_DataSz = uncompDataSz / 4; break; case eCompressionFormat_DXT5: m_DataSz = uncompDataSz / 4; break;
case eCompressionFormat_BPTC: 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 // First make sure that we have enough data
uint32 dataSz = 0; uint32 dataSz = 0;
switch(m_Format) { switch(m_Format) {
default: assert(!"Not implemented!"); // Fall through V
case eCompressionFormat_DXT1: dataSz = m_DataSz * 8; break; case eCompressionFormat_DXT1: dataSz = m_DataSz * 8; break;
case eCompressionFormat_DXT5: dataSz = m_DataSz * 4; break; case eCompressionFormat_DXT5: dataSz = m_DataSz * 4; break;
case eCompressionFormat_BPTC: dataSz = m_DataSz * 4; break; case eCompressionFormat_BPTC: dataSz = m_DataSz * 4; break;

View file

@ -70,9 +70,9 @@ Image::Image(const CompressedImage &ci)
} }
Image::Image(const ImageLoader &loader) Image::Image(const ImageLoader &loader)
: m_PixelData(0) : m_Width(loader.GetWidth())
, m_Width(loader.GetWidth())
, m_Height(loader.GetHeight()) , m_Height(loader.GetHeight())
, m_PixelData(0)
{ {
if(loader.GetImageData()) { if(loader.GetImageData()) {
m_PixelData = new uint8[ loader.GetImageDataSz() ]; m_PixelData = new uint8[ loader.GetImageDataSz() ];
@ -93,6 +93,7 @@ CompressedImage *Image::Compress(const SCompressionSettings &settings) const {
// Allocate data based on the compression method // Allocate data based on the compression method
int cmpDataSz = 0; int cmpDataSz = 0;
switch(settings.format) { switch(settings.format) {
default: assert(!"Not implemented!");
case eCompressionFormat_DXT1: cmpDataSz = dataSz / 8; case eCompressionFormat_DXT1: cmpDataSz = dataSz / 8;
case eCompressionFormat_DXT5: cmpDataSz = dataSz / 4; case eCompressionFormat_DXT5: cmpDataSz = dataSz / 4;
case eCompressionFormat_BPTC: cmpDataSz = dataSz / 4; case eCompressionFormat_BPTC: cmpDataSz = dataSz / 4;

View file

@ -71,6 +71,7 @@ StopWatch &StopWatch::operator=(const StopWatch &other) {
} }
impl = new StopWatchImpl(); impl = new StopWatchImpl();
memcpy(impl, other.impl, sizeof(StopWatchImpl)); memcpy(impl, other.impl, sizeof(StopWatchImpl));
return *this;
} }
StopWatch::~StopWatch() { StopWatch::~StopWatch() {

View file

@ -93,6 +93,12 @@ static CompressionFuncWithStats ChooseFuncFromSettingsWithStats(const SCompress
return BC7C::CompressImageBC7Stats; return BC7C::CompressImageBC7Stats;
} }
break; break;
default:
{
assert(!"Not implemented!");
return NULL;
}
} }
return NULL; return NULL;
} }
@ -114,6 +120,12 @@ static CompressionFunc ChooseFuncFromSettings(const SCompressionSettings &s) {
#endif #endif
} }
break; break;
default:
{
assert(!"Not implemented!");
return NULL;
}
} }
return NULL; return NULL;
} }
@ -270,9 +282,10 @@ bool CompressImageData(
// Allocate data based on the compression method // Allocate data based on the compression method
uint32 cmpDataSzNeeded = 0; uint32 cmpDataSzNeeded = 0;
switch(settings.format) { switch(settings.format) {
case eCompressionFormat_DXT1: cmpDataSzNeeded = dataSz / 8; default: assert(!"Not implemented!"); // Fall through V
case eCompressionFormat_DXT5: cmpDataSzNeeded = dataSz / 4; case eCompressionFormat_DXT1: cmpDataSzNeeded = dataSz / 8; break;
case eCompressionFormat_BPTC: cmpDataSzNeeded = dataSz / 4; case eCompressionFormat_DXT5: cmpDataSzNeeded = dataSz / 4; break;
case eCompressionFormat_BPTC: cmpDataSzNeeded = dataSz / 4; break;
} }
if(cmpDataSzNeeded == 0) { if(cmpDataSzNeeded == 0) {

View file

@ -117,8 +117,8 @@ private:
public: public:
TCBarrierImpl(int threads) TCBarrierImpl(int threads)
: TCThreadBaseImpl() : TCThreadBaseImpl()
, m_ThreadCount(threads)
, m_ThreadLimit(threads) , m_ThreadLimit(threads)
, m_ThreadCount(threads)
, m_Times(0) , m_Times(0)
{ {
assert(threads > 0); assert(threads > 0);

View file

@ -133,13 +133,13 @@ class ThreadGroup {
const unsigned char *const m_ImageData; const unsigned char *const m_ImageData;
unsigned char *m_OutBuf; unsigned char *m_OutBuf;
const unsigned int m_CompressedBlockSize;
const unsigned int m_UncompressedBlockSize;
StopWatch m_StopWatch; StopWatch m_StopWatch;
EThreadState m_ThreadState; EThreadState m_ThreadState;
bool m_ExitFlag; bool m_ExitFlag;
const unsigned int m_CompressedBlockSize;
const unsigned int m_UncompressedBlockSize;
}; };
#endif // _THREAD_GROUP_H_ #endif // _THREAD_GROUP_H_

View file

@ -134,9 +134,10 @@ class WorkerQueue {
const CompressionFunc m_CompressionFunc; const CompressionFunc m_CompressionFunc;
CompressionFunc GetCompressionFunc() const { return m_CompressionFunc; } CompressionFunc GetCompressionFunc() const { return m_CompressionFunc; }
BlockStatManager *m_BlockStatManager;
const CompressionFuncWithStats m_CompressionFuncWithStats; const CompressionFuncWithStats m_CompressionFuncWithStats;
CompressionFuncWithStats GetCompressionFuncWithStats() const { return m_CompressionFuncWithStats; } CompressionFuncWithStats GetCompressionFuncWithStats() const { return m_CompressionFuncWithStats; }
BlockStatManager *m_BlockStatManager;
BlockStatManager *GetBlockStatManager() const { return m_BlockStatManager; } BlockStatManager *GetBlockStatManager() const { return m_BlockStatManager; }
StopWatch m_StopWatch; StopWatch m_StopWatch;