diff --git a/ChangeLog b/ChangeLog
index 2bfac41..e7cec91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@ NVIDIA Texture Tools version 2.0.1
* Fix memory leaks.
* Pre-allocate device memory for CUDA compressor.
* Add single color compressor.
+ * Better CUDA error checking.
NVIDIA Texture Tools version 2.0.0
* Fixed PSNR formula in nvimgdiff.
diff --git a/project/vc8/nvtt/nvtt.vcproj b/project/vc8/nvtt/nvtt.vcproj
index e9110a8..f88c7d6 100644
--- a/project/vc8/nvtt/nvtt.vcproj
+++ b/project/vc8/nvtt/nvtt.vcproj
@@ -96,6 +96,8 @@
/>
isValid())
+ {
+ m.cudaEnabled = false;
+ m.cuda = NULL;
+ }
}
}
@@ -232,6 +238,12 @@ void Compressor::enableCudaAcceleration(bool enable)
if (m.cudaEnabled && m.cuda == NULL)
{
m.cuda = new CudaCompressor();
+
+ if (!m.cuda->isValid())
+ {
+ m.cudaEnabled = false;
+ m.cuda = NULL;
+ }
}
}
diff --git a/src/nvtt/QuickCompressDXT.cpp b/src/nvtt/QuickCompressDXT.cpp
index c4e0abc..fda8165 100644
--- a/src/nvtt/QuickCompressDXT.cpp
+++ b/src/nvtt/QuickCompressDXT.cpp
@@ -360,10 +360,10 @@ void QuickCompress::compressDXT1(Color32 c, BlockDXT1 * dxtBlock)
dxtBlock->col1.b = OMatch5[c.b][1];
dxtBlock->indices = 0xaaaaaaaa;
- if (dxtBlock->col0.u < dxtBlock->col1.u)
- {
- swap(dxtBlock->col0.u, dxtBlock->col1.u);
- dxtBlock->indices ^= 0x55555555;
+ if (dxtBlock->col0.u < dxtBlock->col1.u)
+ {
+ swap(dxtBlock->col0.u, dxtBlock->col1.u);
+ dxtBlock->indices ^= 0x55555555;
}
}
diff --git a/src/nvtt/nvtt.h b/src/nvtt/nvtt.h
index d8a2966..2b691f2 100644
--- a/src/nvtt/nvtt.h
+++ b/src/nvtt/nvtt.h
@@ -49,6 +49,14 @@
#define NVTT_VERSION 200
+#define NVTT_DECLARE_PIMPL(Class) \
+ private: \
+ Class(const Class &); \
+ void operator=(const Class &); \
+ public: \
+ struct Private; \
+ Private & m
+
// Public interface.
namespace nvtt
@@ -89,6 +97,8 @@ namespace nvtt
/// Compression options. This class describes the desired compression format and other compression settings.
struct CompressionOptions
{
+ NVTT_DECLARE_PIMPL(CompressionOptions);
+
NVTT_API CompressionOptions();
NVTT_API ~CompressionOptions();
@@ -104,10 +114,6 @@ namespace nvtt
NVTT_API void setPixelFormat(unsigned int bitcount, unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask);
NVTT_API void setQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold = 127);
-
- //private:
- struct Private;
- Private & m;
};
@@ -170,6 +176,8 @@ namespace nvtt
/// Input options. Specify format and layout of the input texture.
struct InputOptions
{
+ NVTT_DECLARE_PIMPL(InputOptions);
+
NVTT_API InputOptions();
NVTT_API ~InputOptions();
@@ -214,10 +222,6 @@ namespace nvtt
// Set resizing options.
NVTT_API void setMaxExtents(int d);
NVTT_API void setRoundMode(RoundMode mode);
-
- //private:
- struct Private;
- Private & m;
};
@@ -258,6 +262,8 @@ namespace nvtt
/// the compressor to the user.
struct OutputOptions
{
+ NVTT_DECLARE_PIMPL(OutputOptions);
+
NVTT_API OutputOptions();
NVTT_API ~OutputOptions();
@@ -269,16 +275,14 @@ namespace nvtt
NVTT_API void setOutputHandler(OutputHandler * outputHandler);
NVTT_API void setErrorHandler(ErrorHandler * errorHandler);
NVTT_API void setOutputHeader(bool outputHeader);
-
- //private:
- struct Private;
- Private & m;
};
/// Texture compressor.
struct Compressor
{
+ NVTT_DECLARE_PIMPL(Compressor);
+
NVTT_API Compressor();
NVTT_API ~Compressor();
@@ -290,10 +294,6 @@ namespace nvtt
// Estimate the size of compressing the input with the given options.
NVTT_API int estimateSize(const InputOptions & inputOptions, const CompressionOptions & compressionOptions) const;
-
- //private:
- struct Private;
- Private & m;
};
diff --git a/src/nvtt/squish/simd_ve.h b/src/nvtt/squish/simd_ve.h
index d22b370..56ed95e 100644
--- a/src/nvtt/squish/simd_ve.h
+++ b/src/nvtt/squish/simd_ve.h
@@ -50,6 +50,16 @@ public:
return *this;
}
+ Vec4( const float * v )
+ {
+ union { vector float v; float c[4]; } u;
+ u.c[0] = v[0];
+ u.c[1] = v[1];
+ u.c[2] = v[2];
+ u.c[3] = v[3];
+ m_v = u.v;
+ }
+
Vec4( float x, float y, float z, float w )
{
union { vector float v; float c[4]; } u;