Add support for D3D9 and D3D10 decoders. Fixes issue 157.
This commit is contained in:
@ -331,7 +331,7 @@ bool ClusterFit::compress4( Vector3 * start, Vector3 * end )
|
||||
|
||||
bool ClusterFit::compress3(Vector3 * start, Vector3 * end)
|
||||
{
|
||||
int const count = m_count;
|
||||
const uint count = m_count;
|
||||
const Vector3 one( 1.0f );
|
||||
const Vector3 zero( 0.0f );
|
||||
const Vector3 half( 0.5f );
|
||||
@ -418,7 +418,7 @@ bool ClusterFit::compress3(Vector3 * start, Vector3 * end)
|
||||
|
||||
bool ClusterFit::compress4(Vector3 * start, Vector3 * end)
|
||||
{
|
||||
int const count = m_count;
|
||||
const uint count = m_count;
|
||||
Vector3 const one( 1.0f );
|
||||
Vector3 const zero( 0.0f );
|
||||
Vector3 const half( 0.5f );
|
||||
|
@ -188,7 +188,7 @@ namespace
|
||||
static uint computeAlphaError(const ColorBlock & rgba, const AlphaBlockDXT5 * block, int bestError = INT_MAX)
|
||||
{
|
||||
uint8 alphas[8];
|
||||
block->evaluatePalette(alphas);
|
||||
block->evaluatePalette(alphas, false); // @@ Use target decoder.
|
||||
|
||||
int totalError = 0;
|
||||
|
||||
@ -218,7 +218,7 @@ namespace
|
||||
static void computeAlphaIndices(const ColorBlock & rgba, AlphaBlockDXT5 * block)
|
||||
{
|
||||
uint8 alphas[8];
|
||||
block->evaluatePalette(alphas);
|
||||
block->evaluatePalette(alphas, false); // @@ Use target decoder.
|
||||
|
||||
for (uint i = 0; i < 16; i++)
|
||||
{
|
||||
@ -375,7 +375,7 @@ void OptimalCompress::compressDXT1G(const ColorBlock & rgba, BlockDXT1 * block)
|
||||
|
||||
|
||||
Color32 palette[4];
|
||||
block->evaluatePalette(palette);
|
||||
block->evaluatePalette(palette, false); // @@ Use target decoder.
|
||||
block->indices = computeGreenIndices(rgba, palette);
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ namespace
|
||||
static uint computeAlphaIndices(const ColorBlock & rgba, AlphaBlockDXT5 * block)
|
||||
{
|
||||
uint8 alphas[8];
|
||||
block->evaluatePalette(alphas);
|
||||
block->evaluatePalette(alphas, false); // @@ Use target decoder.
|
||||
|
||||
uint totalError = 0;
|
||||
|
||||
|
@ -553,8 +553,11 @@ bool TexImage::setImage2D(Format format, Decoder decoder, int w, int h, const vo
|
||||
{
|
||||
const BlockDXT1 * block = (const BlockDXT1 *)ptr;
|
||||
|
||||
if (decoder == Decoder_Reference) {
|
||||
block->decodeBlock(&colors);
|
||||
if (decoder == Decoder_D3D10) {
|
||||
block->decodeBlock(&colors, false);
|
||||
}
|
||||
else if (decoder == Decoder_D3D9) {
|
||||
block->decodeBlock(&colors, false);
|
||||
}
|
||||
else if (decoder == Decoder_NV5x) {
|
||||
block->decodeBlockNV5x(&colors);
|
||||
@ -564,8 +567,11 @@ bool TexImage::setImage2D(Format format, Decoder decoder, int w, int h, const vo
|
||||
{
|
||||
const BlockDXT3 * block = (const BlockDXT3 *)ptr;
|
||||
|
||||
if (decoder == Decoder_Reference) {
|
||||
block->decodeBlock(&colors);
|
||||
if (decoder == Decoder_D3D10) {
|
||||
block->decodeBlock(&colors, false);
|
||||
}
|
||||
else if (decoder == Decoder_D3D9) {
|
||||
block->decodeBlock(&colors, false);
|
||||
}
|
||||
else if (decoder == Decoder_NV5x) {
|
||||
block->decodeBlockNV5x(&colors);
|
||||
@ -575,8 +581,11 @@ bool TexImage::setImage2D(Format format, Decoder decoder, int w, int h, const vo
|
||||
{
|
||||
const BlockDXT5 * block = (const BlockDXT5 *)ptr;
|
||||
|
||||
if (decoder == Decoder_Reference) {
|
||||
block->decodeBlock(&colors);
|
||||
if (decoder == Decoder_D3D10) {
|
||||
block->decodeBlock(&colors, false);
|
||||
}
|
||||
else if (decoder == Decoder_D3D9) {
|
||||
block->decodeBlock(&colors, false);
|
||||
}
|
||||
else if (decoder == Decoder_NV5x) {
|
||||
block->decodeBlockNV5x(&colors);
|
||||
@ -585,12 +594,12 @@ bool TexImage::setImage2D(Format format, Decoder decoder, int w, int h, const vo
|
||||
else if (format == nvtt::Format_BC4)
|
||||
{
|
||||
const BlockATI1 * block = (const BlockATI1 *)ptr;
|
||||
block->decodeBlock(&colors);
|
||||
block->decodeBlock(&colors, decoder == Decoder_D3D9);
|
||||
}
|
||||
else if (format == nvtt::Format_BC5)
|
||||
{
|
||||
const BlockATI2 * block = (const BlockATI2 *)ptr;
|
||||
block->decodeBlock(&colors);
|
||||
block->decodeBlock(&colors, decoder == Decoder_D3D9);
|
||||
}
|
||||
|
||||
for (int yy = 0; yy < 4; yy++)
|
||||
@ -1466,11 +1475,11 @@ void TexImage::quantize(int channel, int bits, bool exactEndPoints, bool dither)
|
||||
float scale, offset;
|
||||
|
||||
if (exactEndPoints) {
|
||||
scale = (1 << bits) - 1;
|
||||
scale = float((1 << bits) - 1);
|
||||
offset = 0.0f;
|
||||
}
|
||||
else {
|
||||
scale = (1 << bits);
|
||||
scale = float(1 << bits);
|
||||
offset = 0.5f;
|
||||
}
|
||||
|
||||
|
@ -380,7 +380,8 @@ namespace nvtt
|
||||
/// DXT decoder.
|
||||
enum Decoder
|
||||
{
|
||||
Decoder_Reference,
|
||||
Decoder_D3D10,
|
||||
Decoder_D3D9,
|
||||
Decoder_NV5x,
|
||||
};
|
||||
|
||||
|
@ -179,7 +179,7 @@ static const char * s_modeNames[] = {
|
||||
"BC3-Normal", // Mode_BC3_Normal,
|
||||
"BC5-Normal", // Mode_BC5_Normal,
|
||||
};
|
||||
nvStaticCheck(ARRAY_SIZE(s_modeNames) == Mode_Count);
|
||||
nvStaticCheck(NV_ARRAY_SIZE(s_modeNames) == Mode_Count);
|
||||
|
||||
struct Test {
|
||||
const char * name;
|
||||
@ -251,7 +251,6 @@ struct MyOutputHandler : public nvtt::OutputHandler
|
||||
{
|
||||
nvtt::TexImage img;
|
||||
img.setImage2D(format, decoder, m_width, m_height, m_data);
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
@ -280,7 +279,7 @@ int main(int argc, char *argv[])
|
||||
bool fast = false;
|
||||
bool nocuda = false;
|
||||
bool showHelp = false;
|
||||
nvtt::Decoder decoder = nvtt::Decoder_Reference;
|
||||
nvtt::Decoder decoder = nvtt::Decoder_D3D10;
|
||||
Path basePath = "";
|
||||
const char * outPath = "output";
|
||||
const char * regressPath = NULL;
|
||||
@ -378,7 +377,8 @@ int main(int argc, char *argv[])
|
||||
printf(" %i: \t%s.\n", i, s_imageTests[i].name);
|
||||
}
|
||||
printf(" -dec x \tDecompressor.\n");
|
||||
printf(" 0: \tReference.\n");
|
||||
printf(" 0: \tReference (D3D10).\n");
|
||||
printf(" 1: \tReference (D3D9).\n");
|
||||
printf(" 1: \tNVIDIA.\n");
|
||||
|
||||
printf("Compression options:\n");
|
||||
|
Reference in New Issue
Block a user