Add missing changes.
This commit is contained in:
parent
ebe47a0f78
commit
3dae7f9b70
@ -48,7 +48,8 @@ using namespace nvtt;
|
|||||||
|
|
||||||
#if defined HAVE_CUDA
|
#if defined HAVE_CUDA
|
||||||
|
|
||||||
#define MAX_BLOCKS 32768 // 49152, 65535
|
#define MAX_BLOCKS 8192U // 32768, 65535
|
||||||
|
|
||||||
|
|
||||||
extern "C" void setupCompressKernel(const float weights[3]);
|
extern "C" void setupCompressKernel(const float weights[3]);
|
||||||
extern "C" void compressKernelDXT1(uint blockNum, uint * d_data, uint * d_result, uint * d_bitmaps);
|
extern "C" void compressKernelDXT1(uint blockNum, uint * d_data, uint * d_result, uint * d_bitmaps);
|
||||||
@ -79,12 +80,15 @@ static void convertToBlockLinear(const Image * image, uint * blockLinearImage)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
CudaCompressor::CudaCompressor()
|
CudaCompressor::CudaCompressor() : m_bitmapTable(NULL), m_data(NULL), m_result(NULL)
|
||||||
{
|
{
|
||||||
#if defined HAVE_CUDA
|
#if defined HAVE_CUDA
|
||||||
// Allocate and upload bitmaps.
|
// Allocate and upload bitmaps.
|
||||||
cudaMalloc((void**) &m_bitmapTable, 992 * sizeof(uint));
|
cudaMalloc((void**) &m_bitmapTable, 992 * sizeof(uint));
|
||||||
|
if (m_bitmapTable != NULL)
|
||||||
|
{
|
||||||
cudaMemcpy(m_bitmapTable, s_bitmapTable, 992 * sizeof(uint), cudaMemcpyHostToDevice);
|
cudaMemcpy(m_bitmapTable, s_bitmapTable, 992 * sizeof(uint), cudaMemcpyHostToDevice);
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate scratch buffers.
|
// Allocate scratch buffers.
|
||||||
cudaMalloc((void**) &m_data, MAX_BLOCKS * 64U);
|
cudaMalloc((void**) &m_data, MAX_BLOCKS * 64U);
|
||||||
@ -102,7 +106,16 @@ CudaCompressor::~CudaCompressor()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CudaCompressor::isValid() const
|
||||||
|
{
|
||||||
|
#if defined HAVE_CUDA
|
||||||
|
if (cudaGetLastError() != cudaSuccess)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
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.
|
||||||
|
|
||||||
@ -119,7 +132,7 @@ void CudaCompressor::compressDXT1(const Image * image, const OutputOptions::Priv
|
|||||||
|
|
||||||
uint imageSize = w * h * 16 * sizeof(Color32);
|
uint imageSize = w * h * 16 * sizeof(Color32);
|
||||||
uint * blockLinearImage = (uint *) malloc(imageSize);
|
uint * blockLinearImage = (uint *) malloc(imageSize);
|
||||||
convertToBlockLinear(image, blockLinearImage); // @@ Do this on the GPU!
|
convertToBlockLinear(image, blockLinearImage); // @@ Do this in parallel with the GPU, or in the GPU!
|
||||||
|
|
||||||
const uint blockNum = w * h;
|
const uint blockNum = w * h;
|
||||||
const uint compressedSize = blockNum * 8;
|
const uint compressedSize = blockNum * 8;
|
||||||
|
@ -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