diff --git a/src/nvtt/CompressionOptions.cpp b/src/nvtt/CompressionOptions.cpp index 1b3ff10..43c7ad6 100644 --- a/src/nvtt/CompressionOptions.cpp +++ b/src/nvtt/CompressionOptions.cpp @@ -69,6 +69,8 @@ void CompressionOptions::reset() m.enableAlphaDithering = false; m.binaryAlpha = false; m.alphaThreshold = 127; + + m.decoder = Decoder_D3D10; } @@ -185,6 +187,13 @@ void CompressionOptions::setQuantization(bool colorDithering, bool alphaDitherin m.alphaThreshold = alphaThreshold; } +/// Set target decoder to optimize for. +void CompressionOptions::setTargetDecoder(Decoder decoder) +{ + m.decoder = decoder; +} + + // Translate to and from D3D formats. unsigned int CompressionOptions::d3d9Format() const diff --git a/src/nvtt/CompressionOptions.h b/src/nvtt/CompressionOptions.h index 7c2d658..c7df221 100644 --- a/src/nvtt/CompressionOptions.h +++ b/src/nvtt/CompressionOptions.h @@ -32,45 +32,47 @@ namespace nvtt { - struct CompressionOptions::Private - { - Format format; - - Quality quality; - - nv::Vector4 colorWeight; - - // Pixel format description. - uint bitcount; - uint rmask; - uint gmask; - uint bmask; - uint amask; - uint8 rsize; - uint8 gsize; - uint8 bsize; - uint8 asize; - - PixelType pixelType; + struct CompressionOptions::Private + { + Format format; + + Quality quality; + + nv::Vector4 colorWeight; + + // Pixel format description. + uint bitcount; + uint rmask; + uint gmask; + uint bmask; + uint amask; + uint8 rsize; + uint8 gsize; + uint8 bsize; + uint8 asize; + + PixelType pixelType; uint pitchAlignment; - nv::String externalCompressor; + nv::String externalCompressor; + + // Quantization. + bool enableColorDithering; + bool enableAlphaDithering; + bool binaryAlpha; + int alphaThreshold; // reference value used for binary alpha quantization. - // Quantization. - bool enableColorDithering; - bool enableAlphaDithering; - bool binaryAlpha; - int alphaThreshold; // reference value used for binary alpha quantization. + Decoder decoder; - uint getBitCount() const - { - if (format == Format_RGBA) { - if (bitcount != 0) return bitcount; - else return rsize + gsize + bsize + asize; - } - return 0; - } - }; + uint getBitCount() const + { + if (format == Format_RGBA) { + if (bitcount != 0) return bitcount; + else return rsize + gsize + bsize + asize; + } + return 0; + } + }; } // nvtt namespace diff --git a/src/nvtt/nvtt.h b/src/nvtt/nvtt.h index 19aa307..7151638 100644 --- a/src/nvtt/nvtt.h +++ b/src/nvtt/nvtt.h @@ -121,6 +121,15 @@ namespace nvtt Quality_Highest, }; + /// DXT decoder. + enum Decoder + { + Decoder_D3D10, + Decoder_D3D9, + Decoder_NV5x, + }; + + /// Compression options. This class describes the desired compression format and other compression settings. struct CompressionOptions { @@ -148,6 +157,8 @@ namespace nvtt NVTT_API void setQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold = 127); + NVTT_API void setTargetDecoder(Decoder decoder); + // Translate to and from D3D formats. NVTT_API unsigned int d3d9Format() const; //NVTT_API bool setD3D9Format(unsigned int format); @@ -377,14 +388,6 @@ namespace nvtt typedef Compressor Context; - /// DXT decoder. - enum Decoder - { - Decoder_D3D10, - Decoder_D3D9, - Decoder_NV5x, - }; - /// A texture mipmap. struct TexImage {