Disable CUDA when memory allocations fail.
This commit is contained in:
parent
7933aeea09
commit
8a24a93e2f
@ -215,6 +215,12 @@ Compressor::Compressor() : m(*new Compressor::Private())
|
|||||||
if (m.cudaEnabled)
|
if (m.cudaEnabled)
|
||||||
{
|
{
|
||||||
m.cuda = new CudaCompressor();
|
m.cuda = new CudaCompressor();
|
||||||
|
|
||||||
|
if (!m.cuda->isValid())
|
||||||
|
{
|
||||||
|
m.cudaEnabled = false;
|
||||||
|
m.cuda = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,6 +241,12 @@ void Compressor::enableCudaAcceleration(bool enable)
|
|||||||
if (m.cudaEnabled && m.cuda == NULL)
|
if (m.cudaEnabled && m.cuda == NULL)
|
||||||
{
|
{
|
||||||
m.cuda = new CudaCompressor();
|
m.cuda = new CudaCompressor();
|
||||||
|
|
||||||
|
if (!m.cuda->isValid())
|
||||||
|
{
|
||||||
|
m.cudaEnabled = false;
|
||||||
|
m.cuda = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,10 @@ CudaCompressor::~CudaCompressor()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CudaCompressor::isValid() const
|
||||||
|
{
|
||||||
|
return m_data != NULL && m_result != NULL && m_bitmapTable != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// @@ This code is very repetitive and needs to be cleaned up.
|
// @@ This code is very repetitive and needs to be cleaned up.
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ namespace nv
|
|||||||
CudaCompressor();
|
CudaCompressor();
|
||||||
~CudaCompressor();
|
~CudaCompressor();
|
||||||
|
|
||||||
|
bool isValid() const;
|
||||||
|
|
||||||
void compressDXT1(const Image * image, const nvtt::OutputOptions::Private & outputOptions, const nvtt::CompressionOptions::Private & compressionOptions);
|
void compressDXT1(const Image * image, const nvtt::OutputOptions::Private & outputOptions, const nvtt::CompressionOptions::Private & compressionOptions);
|
||||||
void compressDXT3(const Image * image, const nvtt::OutputOptions::Private & outputOptions, const nvtt::CompressionOptions::Private & compressionOptions);
|
void compressDXT3(const Image * image, const nvtt::OutputOptions::Private & outputOptions, const nvtt::CompressionOptions::Private & compressionOptions);
|
||||||
void compressDXT5(const Image * image, const nvtt::OutputOptions::Private & outputOptions, const nvtt::CompressionOptions::Private & compressionOptions);
|
void compressDXT5(const Image * image, const nvtt::OutputOptions::Private & outputOptions, const nvtt::CompressionOptions::Private & compressionOptions);
|
||||||
|
Loading…
Reference in New Issue
Block a user