From ccced843e363d43c6ed40f049278e24b553f7d80 Mon Sep 17 00:00:00 2001 From: castano Date: Thu, 28 Feb 2008 21:45:04 +0000 Subject: [PATCH] Use smaller allocations to prevent errors. Check for allocation errors. --- src/nvtt/cuda/CudaCompressDXT.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/nvtt/cuda/CudaCompressDXT.cpp b/src/nvtt/cuda/CudaCompressDXT.cpp index 433f318..09972b7 100644 --- a/src/nvtt/cuda/CudaCompressDXT.cpp +++ b/src/nvtt/cuda/CudaCompressDXT.cpp @@ -48,8 +48,7 @@ using namespace nvtt; #if defined HAVE_CUDA -//#define MAX_BLOCKS 32768U // 49152, 65535 -#define MAX_BLOCKS 8192U // 49152, 65535 +#define MAX_BLOCKS 8192U // 32768, 65535 extern "C" void setupCompressKernel(const float weights[3]); @@ -84,12 +83,15 @@ static void convertToBlockLinear(const Image * image, uint * blockLinearImage) #endif -CudaCompressor::CudaCompressor() +CudaCompressor::CudaCompressor() : m_bitmapTable(NULL), m_data(NULL), m_result(NULL) { #if defined HAVE_CUDA // Allocate and upload bitmaps. cudaMalloc((void**) &m_bitmapTable, 992 * sizeof(uint)); - cudaMemcpy(m_bitmapTable, s_bitmapTable, 992 * sizeof(uint), cudaMemcpyHostToDevice); + if (m_bitmapTable != NULL) + { + cudaMemcpy(m_bitmapTable, s_bitmapTable, 992 * sizeof(uint), cudaMemcpyHostToDevice); + } // Allocate scratch buffers. cudaMalloc((void**) &m_data, MAX_BLOCKS * 64U);