|
|
|
@ -276,145 +276,6 @@ void CompressorETC2_RGBM::compressBlock(Vector4 colors[16], float weights[16], c
|
|
|
|
|
|
|
|
|
|
// External compressors.
|
|
|
|
|
|
|
|
|
|
#if defined(HAVE_ATITC)
|
|
|
|
|
|
|
|
|
|
typedef int BOOL;
|
|
|
|
|
typedef _W64 unsigned long ULONG_PTR;
|
|
|
|
|
typedef ULONG_PTR DWORD_PTR;
|
|
|
|
|
#include "atitc/ATI_Compress.h"
|
|
|
|
|
|
|
|
|
|
void AtiCompressorDXT1::compress(InputFormat inputFormat, AlphaMode alphaMode, uint w, uint h, uint d, void * data, const CompressionOptions::Private & compressionOptions, const OutputOptions::Private & outputOptions)
|
|
|
|
|
{
|
|
|
|
|
nvDebugCheck(d == 1);
|
|
|
|
|
|
|
|
|
|
// Init source texture
|
|
|
|
|
ATI_TC_Texture srcTexture;
|
|
|
|
|
srcTexture.dwSize = sizeof(srcTexture);
|
|
|
|
|
srcTexture.dwWidth = w;
|
|
|
|
|
srcTexture.dwHeight = h;
|
|
|
|
|
if (inputFormat == InputFormat_BGRA_8UB)
|
|
|
|
|
{
|
|
|
|
|
srcTexture.dwPitch = w * 4;
|
|
|
|
|
srcTexture.format = ATI_TC_FORMAT_ARGB_8888;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// @@ Floating point input is not swizzled.
|
|
|
|
|
srcTexture.dwPitch = w * 16;
|
|
|
|
|
srcTexture.format = ATI_TC_FORMAT_ARGB_32F;
|
|
|
|
|
}
|
|
|
|
|
srcTexture.dwDataSize = ATI_TC_CalculateBufferSize(&srcTexture);
|
|
|
|
|
srcTexture.pData = (ATI_TC_BYTE*) data;
|
|
|
|
|
|
|
|
|
|
// Init dest texture
|
|
|
|
|
ATI_TC_Texture destTexture;
|
|
|
|
|
destTexture.dwSize = sizeof(destTexture);
|
|
|
|
|
destTexture.dwWidth = w;
|
|
|
|
|
destTexture.dwHeight = h;
|
|
|
|
|
destTexture.dwPitch = 0;
|
|
|
|
|
destTexture.format = ATI_TC_FORMAT_DXT1;
|
|
|
|
|
destTexture.dwDataSize = ATI_TC_CalculateBufferSize(&destTexture);
|
|
|
|
|
destTexture.pData = (ATI_TC_BYTE*) mem::malloc(destTexture.dwDataSize);
|
|
|
|
|
|
|
|
|
|
ATI_TC_CompressOptions options;
|
|
|
|
|
options.dwSize = sizeof(options);
|
|
|
|
|
options.bUseChannelWeighting = false;
|
|
|
|
|
options.bUseAdaptiveWeighting = false;
|
|
|
|
|
options.bDXT1UseAlpha = false;
|
|
|
|
|
options.nCompressionSpeed = ATI_TC_Speed_Normal;
|
|
|
|
|
options.bDisableMultiThreading = false;
|
|
|
|
|
//options.bDisableMultiThreading = true;
|
|
|
|
|
|
|
|
|
|
// Compress
|
|
|
|
|
ATI_TC_ConvertTexture(&srcTexture, &destTexture, &options, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
if (outputOptions.outputHandler != NULL) {
|
|
|
|
|
outputOptions.outputHandler->writeData(destTexture.pData, destTexture.dwDataSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mem::free(destTexture.pData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AtiCompressorDXT5::compress(InputFormat inputFormat, AlphaMode alphaMode, uint w, uint h, uint d, void * data, const CompressionOptions::Private & compressionOptions, const OutputOptions::Private & outputOptions)
|
|
|
|
|
{
|
|
|
|
|
nvDebugCheck(d == 1);
|
|
|
|
|
|
|
|
|
|
// Init source texture
|
|
|
|
|
ATI_TC_Texture srcTexture;
|
|
|
|
|
srcTexture.dwSize = sizeof(srcTexture);
|
|
|
|
|
srcTexture.dwWidth = w;
|
|
|
|
|
srcTexture.dwHeight = h;
|
|
|
|
|
if (inputFormat == InputFormat_BGRA_8UB)
|
|
|
|
|
{
|
|
|
|
|
srcTexture.dwPitch = w * 4;
|
|
|
|
|
srcTexture.format = ATI_TC_FORMAT_ARGB_8888;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
srcTexture.dwPitch = w * 16;
|
|
|
|
|
srcTexture.format = ATI_TC_FORMAT_ARGB_32F;
|
|
|
|
|
}
|
|
|
|
|
srcTexture.dwDataSize = ATI_TC_CalculateBufferSize(&srcTexture);
|
|
|
|
|
srcTexture.pData = (ATI_TC_BYTE*) data;
|
|
|
|
|
|
|
|
|
|
// Init dest texture
|
|
|
|
|
ATI_TC_Texture destTexture;
|
|
|
|
|
destTexture.dwSize = sizeof(destTexture);
|
|
|
|
|
destTexture.dwWidth = w;
|
|
|
|
|
destTexture.dwHeight = h;
|
|
|
|
|
destTexture.dwPitch = 0;
|
|
|
|
|
destTexture.format = ATI_TC_FORMAT_DXT5;
|
|
|
|
|
destTexture.dwDataSize = ATI_TC_CalculateBufferSize(&destTexture);
|
|
|
|
|
destTexture.pData = (ATI_TC_BYTE*) mem::malloc(destTexture.dwDataSize);
|
|
|
|
|
|
|
|
|
|
// Compress
|
|
|
|
|
ATI_TC_ConvertTexture(&srcTexture, &destTexture, NULL, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
if (outputOptions.outputHandler != NULL) {
|
|
|
|
|
outputOptions.outputHandler->writeData(destTexture.pData, destTexture.dwDataSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mem::free(destTexture.pData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // defined(HAVE_ATITC)
|
|
|
|
|
|
|
|
|
|
#if defined(HAVE_SQUISH)
|
|
|
|
|
|
|
|
|
|
//#include "squish/squish.h"
|
|
|
|
|
#include "squish-1.10/squish.h"
|
|
|
|
|
|
|
|
|
|
void SquishCompressorDXT1::compress(InputFormat inputFormat, AlphaMode alphaMode, uint w, uint h, uint d, void * data, const CompressionOptions::Private & compressionOptions, const OutputOptions::Private & outputOptions)
|
|
|
|
|
{
|
|
|
|
|
nvDebugCheck(d == 1);
|
|
|
|
|
nvDebugCheck(false);
|
|
|
|
|
|
|
|
|
|
#pragma message(NV_FILE_LINE "TODO: Convert input to fixed point ABGR format instead of ARGB")
|
|
|
|
|
/*
|
|
|
|
|
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 = mem::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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mem::free(blocks);
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // defined(HAVE_SQUISH)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(HAVE_D3DX)
|
|
|
|
|
|
|
|
|
|
void D3DXCompressorDXT1::compress(InputFormat inputFormat, AlphaMode alphaMode, uint w, uint h, uint d, void * data, const CompressionOptions::Private & compressionOptions, const OutputOptions::Private & outputOptions)
|
|
|
|
|