Set correct DXT5n swizzle code.
Select swizzle codes in nvtt instead of nvimage.
This commit is contained in:
parent
b284669993
commit
68be24bf00
@ -639,15 +639,7 @@ void DDSHeader::setFourCC(uint8 c0, uint8 c1, uint8 c2, uint8 c3)
|
||||
this->pf.flags = DDPF_FOURCC;
|
||||
this->pf.fourcc = MAKEFOURCC(c0, c1, c2, c3);
|
||||
|
||||
if (this->pf.fourcc == FOURCC_ATI2)
|
||||
{
|
||||
this->pf.bitcount = FOURCC_A2XY;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->pf.bitcount = 0;
|
||||
}
|
||||
|
||||
this->pf.bitcount = 0;
|
||||
this->pf.rmask = 0;
|
||||
this->pf.gmask = 0;
|
||||
this->pf.bmask = 0;
|
||||
@ -667,6 +659,11 @@ void DDSHeader::setFormatCode(uint32 code)
|
||||
this->pf.amask = 0;
|
||||
}
|
||||
|
||||
void DDSHeader::setSwizzleCode(uint8 c0, uint8 c1, uint8 c2, uint8 c3)
|
||||
{
|
||||
this->pf.bitcount = MAKEFOURCC(c0, c1, c2, c3);
|
||||
}
|
||||
|
||||
|
||||
void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask)
|
||||
{
|
||||
|
@ -94,6 +94,7 @@ namespace nv
|
||||
void setPitch(uint pitch);
|
||||
void setFourCC(uint8 c0, uint8 c1, uint8 c2, uint8 c3);
|
||||
void setFormatCode(uint code);
|
||||
void setSwizzleCode(uint8 c0, uint8 c1, uint8 c2, uint8 c3);
|
||||
void setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask);
|
||||
void setDX10Format(uint format);
|
||||
void setNormalFlag(bool b);
|
||||
|
@ -371,6 +371,9 @@ void nv::SlowCompressor::compressDXT5n(const CompressionOptions::Private & compr
|
||||
ColorBlock rgba;
|
||||
BlockDXT5 block;
|
||||
|
||||
squish::WeightedClusterFit fit;
|
||||
fit.SetMetric(0, 1, 0);
|
||||
|
||||
for (uint y = 0; y < h; y += 4) {
|
||||
for (uint x = 0; x < w; x += 4) {
|
||||
|
||||
@ -389,7 +392,18 @@ void nv::SlowCompressor::compressDXT5n(const CompressionOptions::Private & compr
|
||||
}
|
||||
|
||||
// Compress Y.
|
||||
OptimalCompress::compressDXT1G(rgba, &block.color);
|
||||
//OptimalCompress::compressDXT1G(rgba, &block.color);
|
||||
|
||||
/*if (rgba.isSingleColor())
|
||||
{
|
||||
OptimalCompress::compressDXT1G(rgba.color(0), &block.color);
|
||||
}
|
||||
else*/
|
||||
{
|
||||
squish::ColourSet colours((uint8 *)rgba.colors(), squish::kWeightColourByAlpha);
|
||||
fit.SetColourSet(&colours, 0);
|
||||
fit.Compress(&block.color);
|
||||
}
|
||||
|
||||
if (outputOptions.outputHandler != NULL) {
|
||||
outputOptions.outputHandler->writeData(&block, sizeof(block));
|
||||
|
@ -453,14 +453,21 @@ bool Compressor::Private::outputHeader(const InputOptions::Private & inputOption
|
||||
}
|
||||
else if (compressionOptions.format == Format_DXT5n) {
|
||||
header.setFourCC('D', 'X', 'T', '5');
|
||||
if (inputOptions.isNormalMap) header.setNormalFlag(true);
|
||||
if (inputOptions.isNormalMap) {
|
||||
header.setNormalFlag(true);
|
||||
header.setSwizzleCode('A', '2', 'D', '5');
|
||||
//header.setSwizzleCode('x', 'G', 'x', 'R');
|
||||
}
|
||||
}
|
||||
else if (compressionOptions.format == Format_BC4) {
|
||||
header.setFourCC('A', 'T', 'I', '1');
|
||||
}
|
||||
else if (compressionOptions.format == Format_BC5) {
|
||||
header.setFourCC('A', 'T', 'I', '2');
|
||||
if (inputOptions.isNormalMap) header.setNormalFlag(true);
|
||||
if (inputOptions.isNormalMap) {
|
||||
header.setNormalFlag(true);
|
||||
header.setSwizzleCode('A', '2', 'X', 'Y');
|
||||
}
|
||||
}
|
||||
else if (compressionOptions.format == Format_CTX1) {
|
||||
header.setFourCC('C', 'T', 'X', '1');
|
||||
@ -905,7 +912,8 @@ bool Compressor::Private::compressMipmap(const Mipmap & mipmap, const InputOptio
|
||||
{
|
||||
nvDebugCheck(cudaSupported);
|
||||
cuda->setImage(image, inputOptions.alphaMode);
|
||||
cuda->compressDXT1(compressionOptions, outputOptions);
|
||||
//cuda->compressDXT1(compressionOptions, outputOptions);
|
||||
cuda->compressDXT1_Tex(compressionOptions, outputOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -993,7 +1001,16 @@ bool Compressor::Private::compressMipmap(const Mipmap & mipmap, const InputOptio
|
||||
}
|
||||
else
|
||||
{
|
||||
slow.compressDXT5n(compressionOptions, outputOptions);
|
||||
/*if (cudaEnabled)
|
||||
{
|
||||
nvDebugCheck(cudaSupported);
|
||||
cuda->setImage(image, inputOptions.alphaMode);
|
||||
cuda->compressDXT5n(compressionOptions, outputOptions);
|
||||
}
|
||||
else*/
|
||||
{
|
||||
slow.compressDXT5n(compressionOptions, outputOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (compressionOptions.format == Format_BC4)
|
||||
|
Loading…
Reference in New Issue
Block a user