Add squish external compressor.

Rename our squish version to nvsquish.
This commit is contained in:
castano
2008-11-23 08:59:56 +00:00
parent 4a85f8e48d
commit 4bbf5e96f4
20 changed files with 126 additions and 77 deletions

View File

@ -36,22 +36,25 @@
// squish // squish
#include "squish/colourset.h" #include "squish/colourset.h"
//#include "squish/clusterfit.h"
#include "squish/fastclusterfit.h" #include "squish/fastclusterfit.h"
#include "squish/weightedclusterfit.h" #include "squish/weightedclusterfit.h"
// s3_quant // s3_quant
#if defined(HAVE_S3QUANT) #if defined(HAVE_S3QUANT)
#include "s3tc/s3_quant.h" #include "extern/s3tc/s3_quant.h"
#endif #endif
// ati tc // ati tc
#if defined(HAVE_ATITC) #if defined(HAVE_ATITC)
#include "atitc/ATI_Compress.h" #include "extern/atitc/ATI_Compress.h"
#endif
// squish
#if defined(HAVE_SQUISH)
#include "extern/squish/squish.h"
#endif #endif
//#include <time.h>
using namespace nv; using namespace nv;
using namespace nvtt; using namespace nvtt;
@ -205,9 +208,9 @@ void nv::SlowCompressor::compressDXT1(const CompressionOptions::Private & compre
ColorBlock rgba; ColorBlock rgba;
BlockDXT1 block; BlockDXT1 block;
//squish::WeightedClusterFit fit; nvsquish::WeightedClusterFit fit;
//squish::ClusterFit fit; //nvsquish::ClusterFit fit;
squish::FastClusterFit fit; //nvsquish::FastClusterFit fit;
fit.SetMetric(compressionOptions.colorWeight.x(), compressionOptions.colorWeight.y(), compressionOptions.colorWeight.z()); fit.SetMetric(compressionOptions.colorWeight.x(), compressionOptions.colorWeight.y(), compressionOptions.colorWeight.z());
for (uint y = 0; y < h; y += 4) { for (uint y = 0; y < h; y += 4) {
@ -221,8 +224,8 @@ void nv::SlowCompressor::compressDXT1(const CompressionOptions::Private & compre
} }
else else
{ {
squish::ColourSet colours((uint8 *)rgba.colors(), 0); nvsquish::ColourSet colours((uint8 *)rgba.colors(), 0, true);
fit.SetColourSet(&colours, squish::kDxt1); fit.SetColourSet(&colours, nvsquish::kDxt1);
fit.Compress(&block); fit.Compress(&block);
} }
@ -242,7 +245,7 @@ void nv::SlowCompressor::compressDXT1a(const CompressionOptions::Private & compr
ColorBlock rgba; ColorBlock rgba;
BlockDXT1 block; BlockDXT1 block;
squish::WeightedClusterFit fit; nvsquish::WeightedClusterFit fit;
fit.SetMetric(compressionOptions.colorWeight.x(), compressionOptions.colorWeight.y(), compressionOptions.colorWeight.z()); fit.SetMetric(compressionOptions.colorWeight.x(), compressionOptions.colorWeight.y(), compressionOptions.colorWeight.z());
for (uint y = 0; y < h; y += 4) { for (uint y = 0; y < h; y += 4) {
@ -265,8 +268,8 @@ void nv::SlowCompressor::compressDXT1a(const CompressionOptions::Private & compr
} }
else else
{ {
squish::ColourSet colours((uint8 *)rgba.colors(), squish::kDxt1|squish::kWeightColourByAlpha); nvsquish::ColourSet colours((uint8 *)rgba.colors(), nvsquish::kDxt1|nvsquish::kWeightColourByAlpha);
fit.SetColourSet(&colours, squish::kDxt1); fit.SetColourSet(&colours, nvsquish::kDxt1);
fit.Compress(&block); fit.Compress(&block);
} }
@ -286,8 +289,7 @@ void nv::SlowCompressor::compressDXT3(const CompressionOptions::Private & compre
ColorBlock rgba; ColorBlock rgba;
BlockDXT3 block; BlockDXT3 block;
squish::WeightedClusterFit fit; nvsquish::WeightedClusterFit fit;
//squish::FastClusterFit fit;
fit.SetMetric(compressionOptions.colorWeight.x(), compressionOptions.colorWeight.y(), compressionOptions.colorWeight.z()); fit.SetMetric(compressionOptions.colorWeight.x(), compressionOptions.colorWeight.y(), compressionOptions.colorWeight.z());
for (uint y = 0; y < h; y += 4) { for (uint y = 0; y < h; y += 4) {
@ -305,7 +307,7 @@ void nv::SlowCompressor::compressDXT3(const CompressionOptions::Private & compre
} }
else else
{ {
squish::ColourSet colours((uint8 *)rgba.colors(), squish::kWeightColourByAlpha); nvsquish::ColourSet colours((uint8 *)rgba.colors(), nvsquish::kWeightColourByAlpha);
fit.SetColourSet(&colours, 0); fit.SetColourSet(&colours, 0);
fit.Compress(&block.color); fit.Compress(&block.color);
} }
@ -325,7 +327,7 @@ void nv::SlowCompressor::compressDXT5(const CompressionOptions::Private & compre
ColorBlock rgba; ColorBlock rgba;
BlockDXT5 block; BlockDXT5 block;
squish::WeightedClusterFit fit; nvsquish::WeightedClusterFit fit;
fit.SetMetric(compressionOptions.colorWeight.x(), compressionOptions.colorWeight.y(), compressionOptions.colorWeight.z()); fit.SetMetric(compressionOptions.colorWeight.x(), compressionOptions.colorWeight.y(), compressionOptions.colorWeight.z());
for (uint y = 0; y < h; y += 4) { for (uint y = 0; y < h; y += 4) {
@ -350,7 +352,7 @@ void nv::SlowCompressor::compressDXT5(const CompressionOptions::Private & compre
} }
else else
{ {
squish::ColourSet colours((uint8 *)rgba.colors(), squish::kWeightColourByAlpha); nvsquish::ColourSet colours((uint8 *)rgba.colors(), nvsquish::kWeightColourByAlpha);
fit.SetColourSet(&colours, 0); fit.SetColourSet(&colours, 0);
fit.Compress(&block.color); fit.Compress(&block.color);
} }
@ -371,7 +373,7 @@ void nv::SlowCompressor::compressDXT5n(const CompressionOptions::Private & compr
ColorBlock rgba; ColorBlock rgba;
BlockDXT5 block; BlockDXT5 block;
squish::WeightedClusterFit fit; nvsquish::WeightedClusterFit fit;
fit.SetMetric(0, 1, 0); fit.SetMetric(0, 1, 0);
for (uint y = 0; y < h; y += 4) { for (uint y = 0; y < h; y += 4) {
@ -400,7 +402,7 @@ void nv::SlowCompressor::compressDXT5n(const CompressionOptions::Private & compr
} }
else*/ else*/
{ {
squish::ColourSet colours((uint8 *)rgba.colors(), squish::kWeightColourByAlpha); nvsquish::ColourSet colours((uint8 *)rgba.colors(), nvsquish::kWeightColourByAlpha);
fit.SetColourSet(&colours, 0); fit.SetColourSet(&colours, 0);
fit.Compress(&block.color); fit.Compress(&block.color);
} }
@ -609,3 +611,27 @@ void nv::atiCompressDXT1(const Image * image, const OutputOptions::Private & out
} }
#endif // defined(HAVE_ATITC) #endif // defined(HAVE_ATITC)
#if defined(HAVE_SQUISH)
void nv::squishCompressDXT1(const Image * image, const OutputOptions::Private & outputOptions)
{
Image img(*image);
int count = img.width() * img.height();
for (int i = 0; i < count; i++)
{
Color32 c = img.pixel(i);
img.pixel(i) = Color32(c.b, c.g, c.r, c.a);
}
int size = squish::GetStorageRequirements(img.width(), img.height(), squish::kDxt1);
void * blocks = malloc(size);
squish::CompressImage((const squish::u8 *)img.pixels(), img.width(), img.height(), blocks, squish::kDxt1 | squish::kColourClusterFit);
if (outputOptions.outputHandler != NULL) {
outputOptions.outputHandler->writeData(blocks, size);
}
}
#endif // defined(HAVE_SQUISH)

View File

@ -81,6 +81,10 @@ namespace nv
void atiCompressDXT1(const Image * image, const nvtt::OutputOptions::Private & outputOptions); void atiCompressDXT1(const Image * image, const nvtt::OutputOptions::Private & outputOptions);
#endif #endif
#if defined(HAVE_SQUISH)
void squishCompressDXT1(const Image * image, const nvtt::OutputOptions::Private & outputOptions);
#endif
} // nv namespace } // nv namespace

View File

@ -935,6 +935,15 @@ bool Compressor::Private::compressMipmap(const Mipmap & mipmap, const InputOptio
} }
else else
#endif #endif
#if defined(HAVE_SQUISH)
if (compressionOptions.externalCompressor == "squish")
{
squishCompressDXT1(image, outputOptions);
}
else
#endif
if (compressionOptions.quality == Quality_Fastest) if (compressionOptions.quality == Quality_Fastest)
{ {
fast.compressDXT1(outputOptions); fast.compressDXT1(outputOptions);

View File

@ -28,7 +28,7 @@
#include "colourblock.h" #include "colourblock.h"
#include <cfloat> #include <cfloat>
namespace squish { namespace nvsquish {
ClusterFit::ClusterFit() ClusterFit::ClusterFit()
{ {

View File

@ -23,15 +23,15 @@
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#ifndef SQUISH_CLUSTERFIT_H #ifndef NV_SQUISH_CLUSTERFIT_H
#define SQUISH_CLUSTERFIT_H #define NV_SQUISH_CLUSTERFIT_H
#include "squish.h" #include "squish.h"
#include "maths.h" #include "maths.h"
#include "simd.h" #include "simd.h"
#include "colourfit.h" #include "colourfit.h"
namespace squish { namespace nvsquish {
class ClusterFit : public ColourFit class ClusterFit : public ColourFit
{ {

View File

@ -25,7 +25,7 @@
#include "colourblock.h" #include "colourblock.h"
namespace squish { namespace nvsquish {
static int FloatToInt( float a, int limit ) static int FloatToInt( float a, int limit )
{ {

View File

@ -23,13 +23,13 @@
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#ifndef SQUISH_COLOURBLOCK_H #ifndef NV_SQUISH_COLOURBLOCK_H
#define SQUISH_COLOURBLOCK_H #define NV_SQUISH_COLOURBLOCK_H
#include "squish.h" #include "squish.h"
#include "maths.h" #include "maths.h"
namespace squish { namespace nvsquish {
void WriteColourBlock3( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ); void WriteColourBlock3( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block );
void WriteColourBlock4( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ); void WriteColourBlock4( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block );

View File

@ -26,7 +26,7 @@
#include "colourfit.h" #include "colourfit.h"
#include "colourset.h" #include "colourset.h"
namespace squish { namespace nvsquish {
ColourFit::ColourFit() ColourFit::ColourFit()
{ {

View File

@ -23,13 +23,13 @@
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#ifndef SQUISH_COLOURFIT_H #ifndef NV_SQUISH_COLOURFIT_H
#define SQUISH_COLOURFIT_H #define NV_SQUISH_COLOURFIT_H
#include "squish.h" #include "squish.h"
#include "maths.h" #include "maths.h"
namespace squish { namespace nvsquish {
class ColourSet; class ColourSet;

View File

@ -25,7 +25,7 @@
#include "colourset.h" #include "colourset.h"
namespace squish { namespace nvsquish {
// @@ Add flags: // @@ Add flags:
// - MatchTransparent // - MatchTransparent

View File

@ -23,14 +23,14 @@
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#ifndef SQUISH_COLOURSET_H #ifndef NV_SQUISH_COLOURSET_H
#define SQUISH_COLOURSET_H #define NV_SQUISH_COLOURSET_H
#include "squish.h" #include "squish.h"
#include "maths.h" #include "maths.h"
#include "simd.h" #include "simd.h"
namespace squish { namespace nvsquish {
/*! @brief Represents a set of block colours /*! @brief Represents a set of block colours
*/ */

View File

@ -31,7 +31,7 @@
#include "fastclusterlookup.inl" #include "fastclusterlookup.inl"
namespace squish { namespace nvsquish {
FastClusterFit::FastClusterFit() FastClusterFit::FastClusterFit()
{ {

View File

@ -24,15 +24,15 @@
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#ifndef SQUISH_FASTCLUSTERFIT_H #ifndef NV_SQUISH_FASTCLUSTERFIT_H
#define SQUISH_FASTCLUSTERFIT_H #define NV_SQUISH_FASTCLUSTERFIT_H
#include "squish.h" #include "squish.h"
#include "maths.h" #include "maths.h"
#include "simd.h" #include "simd.h"
#include "colourfit.h" #include "colourfit.h"
namespace squish { namespace nvsquish {
class FastClusterFit : public ColourFit class FastClusterFit : public ColourFit
{ {

View File

@ -26,7 +26,7 @@
#include "maths.h" #include "maths.h"
#include <cfloat> #include <cfloat>
namespace squish { namespace nvsquish {
Sym3x3 ComputeWeightedCovariance( int n, Vec3 const* points, float const* weights, Vec3::Arg metric ) Sym3x3 ComputeWeightedCovariance( int n, Vec3 const* points, float const* weights, Vec3::Arg metric )
{ {

View File

@ -23,14 +23,14 @@
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#ifndef SQUISH_MATHS_H #ifndef NV_SQUISH_MATHS_H
#define SQUISH_MATHS_H #define NV_SQUISH_MATHS_H
#include <cmath> #include <cmath>
#include <algorithm> #include <algorithm>
#include "config.h" #include "config.h"
namespace squish { namespace nvsquish {
class Vec3 class Vec3
{ {

View File

@ -23,8 +23,8 @@
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#ifndef SQUISH_SIMD_H #ifndef NV_SQUISH_SIMD_H
#define SQUISH_SIMD_H #define NV_SQUISH_SIMD_H
#include "maths.h" #include "maths.h"

View File

@ -23,8 +23,8 @@
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#ifndef SQUISH_SIMD_SSE_H #ifndef NV_SQUISH_SIMD_SSE_H
#define SQUISH_SIMD_SSE_H #define NV_SQUISH_SIMD_SSE_H
#include <xmmintrin.h> #include <xmmintrin.h>
#if ( SQUISH_USE_SSE > 1 ) #if ( SQUISH_USE_SSE > 1 )
@ -35,7 +35,7 @@
#define SQUISH_SSE_SPLAT( a ) \ #define SQUISH_SSE_SPLAT( a ) \
( ( a ) | ( ( a ) << 2 ) | ( ( a ) << 4 ) | ( ( a ) << 6 ) ) ( ( a ) | ( ( a ) << 2 ) | ( ( a ) << 4 ) | ( ( a ) << 6 ) )
namespace squish { namespace nvsquish {
#define VEC4_CONST( X ) Vec4( _mm_set1_ps( X ) ) #define VEC4_CONST( X ) Vec4( _mm_set1_ps( X ) )

View File

@ -23,11 +23,11 @@
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#ifndef SQUISH_H #ifndef NV_SQUISH_H
#define SQUISH_H #define NV_SQUISH_H
//! All squish API functions live in this namespace. //! All squish API functions live in this namespace.
namespace squish { namespace nvsquish {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -30,7 +30,7 @@
#include <cfloat> #include <cfloat>
namespace squish { namespace nvsquish {
WeightedClusterFit::WeightedClusterFit() WeightedClusterFit::WeightedClusterFit()
{ {
@ -131,6 +131,7 @@ float WeightedClusterFit::GetBestError() const
void WeightedClusterFit::Compress3( void* block ) void WeightedClusterFit::Compress3( void* block )
{ {
int const count = m_colours->GetCount();
Vec4 const one = VEC4_CONST(1.0f); Vec4 const one = VEC4_CONST(1.0f);
Vec4 const zero = VEC4_CONST(0.0f); Vec4 const zero = VEC4_CONST(0.0f);
Vec4 const half(0.5f, 0.5f, 0.5f, 0.25f); Vec4 const half(0.5f, 0.5f, 0.5f, 0.25f);
@ -148,11 +149,11 @@ void WeightedClusterFit::Compress3( void* block )
int b0 = 0, b1 = 0; int b0 = 0, b1 = 0;
// check all possible clusters for this total order // 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; 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; Vec4 const x2 = m_xsum - x1 - x0;
@ -220,17 +221,17 @@ void WeightedClusterFit::Compress3( void* block )
for(; i < b0+b1; i++) { for(; i < b0+b1; i++) {
bestindices[i] = 2; bestindices[i] = 2;
} }
for(; i < 16; i++) { for(; i < count; i++) {
bestindices[i] = 1; bestindices[i] = 1;
} }
} }
// remap the indices // remap the indices
u8 ordered[16]; u8 ordered[16];
for( int i = 0; i < 16; ++i ) for( int i = 0; i < count; ++i )
ordered[m_order[i]] = bestindices[i]; ordered[m_order[i]] = bestindices[i];
m_colours->RemapIndices( ordered, bestindices ); // Set alpha indices. m_colours->RemapIndices( ordered, bestindices );
// save the block // save the block
@ -243,6 +244,7 @@ void WeightedClusterFit::Compress3( void* block )
void WeightedClusterFit::Compress4( void* block ) void WeightedClusterFit::Compress4( void* block )
{ {
int const count = m_colours->GetCount();
Vec4 const one = VEC4_CONST(1.0f); Vec4 const one = VEC4_CONST(1.0f);
Vec4 const zero = VEC4_CONST(0.0f); Vec4 const zero = VEC4_CONST(0.0f);
Vec4 const half = VEC4_CONST(0.5f); Vec4 const half = VEC4_CONST(0.5f);
@ -262,15 +264,15 @@ void WeightedClusterFit::Compress4( void* block )
int b0 = 0, b1 = 0, b2 = 0; int b0 = 0, b1 = 0, b2 = 0;
// check all possible clusters for this total order // 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; Vec4 x1 = zero;
for( int c1 = 0; c1 <= 16-c0; c1++) for( int c1 = 0; c1 <= count-c0; c1++)
{ {
Vec4 x2 = zero; 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; Vec4 const x3 = m_xsum - x2 - x1 - x0;
@ -345,18 +347,20 @@ void WeightedClusterFit::Compress4( void* block )
for(; i < b0+b1+b2; i++) { for(; i < b0+b1+b2; i++) {
bestindices[i] = 3; bestindices[i] = 3;
} }
for(; i < 16; i++) { for(; i < count; i++) {
bestindices[i] = 1; bestindices[i] = 1;
} }
} }
// remap the indices // remap the indices
u8 ordered[16]; u8 ordered[16];
for( int i = 0; i < 16; ++i ) for( int i = 0; i < count; ++i )
ordered[m_order[i]] = bestindices[i]; ordered[m_order[i]] = bestindices[i];
m_colours->RemapIndices( ordered, bestindices );
// save the block // save the block
WriteColourBlock4( beststart.GetVec3(), bestend.GetVec3(), ordered, block ); WriteColourBlock4( beststart.GetVec3(), bestend.GetVec3(), bestindices, block );
// save the error // save the error
m_besterror = besterror; m_besterror = besterror;
@ -367,6 +371,7 @@ void WeightedClusterFit::Compress4( void* block )
void WeightedClusterFit::Compress3( void* block ) void WeightedClusterFit::Compress3( void* block )
{ {
int const count = m_colours->GetCount();
Vec3 const one( 1.0f ); Vec3 const one( 1.0f );
Vec3 const zero( 0.0f ); Vec3 const zero( 0.0f );
Vec3 const half( 0.5f ); Vec3 const half( 0.5f );
@ -384,12 +389,12 @@ void WeightedClusterFit::Compress3( void* block )
int b0 = 0, b1 = 0; int b0 = 0, b1 = 0;
// check all possible clusters for this total order // check all possible clusters for this total order
for( int c0 = 0; c0 <= 16; c0++) for( int c0 = 0; c0 <= count; c0++)
{ {
Vec3 x1(0.0f); Vec3 x1(0.0f);
float w1 = 0.0f; float w1 = 0.0f;
for( int c1 = 0; c1 <= 16-c0; c1++) for( int c1 = 0; c1 <= count-c0; c1++)
{ {
float w2 = m_wsum - w0 - w1; float w2 = m_wsum - w0 - w1;
@ -448,18 +453,20 @@ void WeightedClusterFit::Compress3( void* block )
for(; i < b0+b1; i++) { for(; i < b0+b1; i++) {
bestindices[i] = 2; bestindices[i] = 2;
} }
for(; i < 16; i++) { for(; i < count; i++) {
bestindices[i] = 1; bestindices[i] = 1;
} }
} }
// remap the indices // remap the indices
u8 ordered[16]; u8 ordered[16];
for( int i = 0; i < 16; ++i ) for( int i = 0; i < count; ++i )
ordered[m_order[i]] = bestindices[i]; ordered[m_order[i]] = bestindices[i];
m_colours->RemapIndices( ordered, bestindices );
// save the block // save the block
WriteColourBlock3( beststart, bestend, ordered, block ); WriteColourBlock3( beststart, bestend, bestindices, block );
// save the error // save the error
m_besterror = besterror; m_besterror = besterror;
@ -468,6 +475,7 @@ void WeightedClusterFit::Compress3( void* block )
void WeightedClusterFit::Compress4( void* block ) void WeightedClusterFit::Compress4( void* block )
{ {
int const count = m_colours->GetCount();
Vec3 const one( 1.0f ); Vec3 const one( 1.0f );
Vec3 const zero( 0.0f ); Vec3 const zero( 0.0f );
Vec3 const half( 0.5f ); Vec3 const half( 0.5f );
@ -484,17 +492,17 @@ void WeightedClusterFit::Compress4( void* block )
int b0 = 0, b1 = 0, b2 = 0; int b0 = 0, b1 = 0, b2 = 0;
// check all possible clusters for this total order // check all possible clusters for this total order
for( int c0 = 0; c0 <= 16; c0++) for( int c0 = 0; c0 <= count; c0++)
{ {
Vec3 x1(0.0f); Vec3 x1(0.0f);
float w1 = 0.0f; float w1 = 0.0f;
for( int c1 = 0; c1 <= 16-c0; c1++) for( int c1 = 0; c1 <= count-c0; c1++)
{ {
Vec3 x2(0.0f); Vec3 x2(0.0f);
float w2 = 0.0f; float w2 = 0.0f;
for( int c2 = 0; c2 <= 16-c0-c1; c2++) for( int c2 = 0; c2 <= count-c0-c1; c2++)
{ {
float w3 = m_wsum - w0 - w1 - w2; float w3 = m_wsum - w0 - w1 - w2;
@ -560,18 +568,20 @@ void WeightedClusterFit::Compress4( void* block )
for(; i < b0+b1+b2; i++) { for(; i < b0+b1+b2; i++) {
bestindices[i] = 3; bestindices[i] = 3;
} }
for(; i < 16; i++) { for(; i < count; i++) {
bestindices[i] = 1; bestindices[i] = 1;
} }
} }
// remap the indices // remap the indices
u8 ordered[16]; u8 ordered[16];
for( int i = 0; i < 16; ++i ) for( int i = 0; i < count; ++i )
ordered[m_order[i]] = bestindices[i]; ordered[m_order[i]] = bestindices[i];
m_colours->RemapIndices( ordered, bestindices );
// save the block // save the block
WriteColourBlock4( beststart, bestend, ordered, block ); WriteColourBlock4( beststart, bestend, bestindices, block );
// save the error // save the error
m_besterror = besterror; m_besterror = besterror;

View File

@ -24,15 +24,15 @@
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#ifndef SQUISH_WEIGHTEDCLUSTERFIT_H #ifndef NV_SQUISH_WEIGHTEDCLUSTERFIT_H
#define SQUISH_WEIGHTEDCLUSTERFIT_H #define NV_SQUISH_WEIGHTEDCLUSTERFIT_H
#include "squish.h" #include "squish.h"
#include "maths.h" #include "maths.h"
#include "simd.h" #include "simd.h"
#include "colourfit.h" #include "colourfit.h"
namespace squish { namespace nvsquish {
class WeightedClusterFit : public ColourFit class WeightedClusterFit : public ColourFit
{ {