From 6e9feef6f475025e98ef1f1ca133150bf09e0164 Mon Sep 17 00:00:00 2001 From: castano Date: Wed, 21 Oct 2009 07:50:24 +0000 Subject: [PATCH] Enable weighted cluster fit compressor by default. --- src/nvtt/CompressDXT.cpp | 6 +++--- src/nvtt/squish/weightedclusterfit.cpp | 16 +++++++++------- src/nvtt/tools/compress.cpp | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/nvtt/CompressDXT.cpp b/src/nvtt/CompressDXT.cpp index 19124dc..60f5264 100644 --- a/src/nvtt/CompressDXT.cpp +++ b/src/nvtt/CompressDXT.cpp @@ -205,9 +205,9 @@ void nv::SlowCompressor::compressDXT1(const CompressionOptions::Private & compre ColorBlock rgba; BlockDXT1 block; - //squish::WeightedClusterFit fit; + squish::WeightedClusterFit fit; //squish::ClusterFit fit; - squish::FastClusterFit fit; + //squish::FastClusterFit fit; fit.SetMetric(compressionOptions.colorWeight.x(), compressionOptions.colorWeight.y(), compressionOptions.colorWeight.z()); for (uint y = 0; y < h; y += 4) { @@ -221,7 +221,7 @@ void nv::SlowCompressor::compressDXT1(const CompressionOptions::Private & compre } else { - squish::ColourSet colours((uint8 *)rgba.colors(), 0); + squish::ColourSet colours((uint8 *)rgba.colors(), 0, true); fit.SetColourSet(&colours, squish::kDxt1); fit.Compress(&block); } diff --git a/src/nvtt/squish/weightedclusterfit.cpp b/src/nvtt/squish/weightedclusterfit.cpp index 36186b8..6f2318a 100644 --- a/src/nvtt/squish/weightedclusterfit.cpp +++ b/src/nvtt/squish/weightedclusterfit.cpp @@ -131,6 +131,7 @@ float WeightedClusterFit::GetBestError() const void WeightedClusterFit::Compress3( void* block ) { + int const count = m_colours->GetCount(); Vec4 const one = VEC4_CONST(1.0f); Vec4 const zero = VEC4_CONST(0.0f); Vec4 const half(0.5f, 0.5f, 0.5f, 0.25f); @@ -146,11 +147,11 @@ void WeightedClusterFit::Compress3( void* block ) int b0 = 0, b1 = 0; // check all possible clusters for this total order - for( int c0 = 0; c0 <= 16; c0++) + for( int c0 = 0; c0 <= count; c0++) { Vec4 x1 = zero; - for( int c1 = 0; c1 <= 16-c0; c1++) + for( int c1 = 0; c1 <= count-c0; c1++) { Vec4 const x2 = m_xsum - x1 - x0; @@ -228,7 +229,7 @@ void WeightedClusterFit::Compress3( void* block ) // remap the indices u8 ordered[16]; - for( int i = 0; i < 16; ++i ) + for( int i = 0; i < count; ++i ) ordered[m_order[i]] = bestindices[i]; m_colours->RemapIndices( ordered, bestindices ); // Set alpha indices. @@ -244,6 +245,7 @@ void WeightedClusterFit::Compress3( void* block ) void WeightedClusterFit::Compress4( void* block ) { + int const count = m_colours->GetCount(); Vec4 const one = VEC4_CONST(1.0f); Vec4 const zero = VEC4_CONST(0.0f); Vec4 const half = VEC4_CONST(0.5f); @@ -260,15 +262,15 @@ void WeightedClusterFit::Compress4( void* block ) int b0 = 0, b1 = 0, b2 = 0; // check all possible clusters for this total order - for( int c0 = 0; c0 <= 16; c0++) + for( int c0 = 0; c0 <= count; c0++) { Vec4 x1 = zero; - for( int c1 = 0; c1 <= 16-c0; c1++) + for( int c1 = 0; c1 <= count-c0; c1++) { Vec4 x2 = zero; - for( int c2 = 0; c2 <= 16-c0-c1; c2++) + for( int c2 = 0; c2 <= count-c0-c1; c2++) { Vec4 const x3 = m_xsum - x2 - x1 - x0; @@ -353,7 +355,7 @@ void WeightedClusterFit::Compress4( void* block ) // remap the indices u8 ordered[16]; - for( int i = 0; i < 16; ++i ) + for( int i = 0; i < count; ++i ) ordered[m_order[i]] = bestindices[i]; // save the block diff --git a/src/nvtt/tools/compress.cpp b/src/nvtt/tools/compress.cpp index dc45b4b..ea87ac3 100644 --- a/src/nvtt/tools/compress.cpp +++ b/src/nvtt/tools/compress.cpp @@ -424,7 +424,7 @@ int main(int argc, char *argv[]) else { printf("DISABLED\n\n"); - } + } outputHandler.setTotal(compressor.estimateSize(inputOptions, compressionOptions)); outputHandler.setDisplayProgress(!silent);