Merge branch 'master' of https://github.com/castano/nvidia-texture-tools
This commit is contained in:
@ -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)
|
||||
|
@ -79,25 +79,6 @@ namespace nv
|
||||
|
||||
|
||||
// External compressors.
|
||||
#if defined(HAVE_ATITC)
|
||||
struct AtiCompressorDXT1 : public CompressorInterface
|
||||
{
|
||||
virtual void compress(nvtt::InputFormat inputFormat, nvtt::AlphaMode alphaMode, uint w, uint h, uint d, void * data, const nvtt::CompressionOptions::Private & compressionOptions, const nvtt::OutputOptions::Private & outputOptions);
|
||||
};
|
||||
|
||||
struct AtiCompressorDXT5 : public CompressorInterface
|
||||
{
|
||||
virtual void compress(nvtt::InputFormat inputFormat, nvtt::AlphaMode alphaMode, uint w, uint h, uint d, void * data, const nvtt::CompressionOptions::Private & compressionOptions, const nvtt::OutputOptions::Private & outputOptions);
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SQUISH)
|
||||
struct SquishCompressorDXT1 : public CompressorInterface
|
||||
{
|
||||
virtual void compress(nvtt::InputFormat inputFormat, nvtt::AlphaMode alphaMode, uint w, uint h, uint d, void * data, const nvtt::CompressionOptions::Private & compressionOptions, const nvtt::OutputOptions::Private & outputOptions);
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_D3DX)
|
||||
struct D3DXCompressorDXT1 : public CompressorInterface
|
||||
{
|
||||
|
@ -1043,22 +1043,12 @@ CompressorInterface * Compressor::Private::chooseCpuCompressor(const Compression
|
||||
}
|
||||
else if (compressionOptions.format == Format_DXT1)
|
||||
{
|
||||
#if defined(HAVE_ATITC)
|
||||
if (compressionOptions.externalCompressor == "ati") return new AtiCompressorDXT1;
|
||||
else
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SQUISH)
|
||||
if (compressionOptions.externalCompressor == "squish") return new SquishCompressorDXT1;
|
||||
else
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_D3DX)
|
||||
if (compressionOptions.externalCompressor == "d3dx") return new D3DXCompressorDXT1;
|
||||
else
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_D3DX)
|
||||
#if defined(HAVE_STB)
|
||||
if (compressionOptions.externalCompressor == "stb") return new StbCompressorDXT1;
|
||||
else
|
||||
#endif
|
||||
@ -1094,11 +1084,6 @@ CompressorInterface * Compressor::Private::chooseCpuCompressor(const Compression
|
||||
}
|
||||
else if (compressionOptions.format == Format_DXT5)
|
||||
{
|
||||
#if defined(HAVE_ATITC)
|
||||
if (compressionOptions.externalCompressor == "ati") return new AtiCompressorDXT5;
|
||||
else
|
||||
#endif
|
||||
|
||||
if (compressionOptions.quality == Quality_Fastest)
|
||||
{
|
||||
return new FastCompressorDXT5;
|
||||
|
@ -1027,21 +1027,6 @@ CubeSurface CubeSurface::fastResample(int size, EdgeFixup fixupMethod) const
|
||||
return resampledCube;
|
||||
}
|
||||
|
||||
|
||||
void CubeSurface::_irradianceFilter(int size, EdgeFixup fixupMethod) {
|
||||
*this = irradianceFilter(size, fixupMethod);
|
||||
}
|
||||
|
||||
void CubeSurface::_cosinePowerFilter(int size, float cosinePower, EdgeFixup fixupMethod) {
|
||||
*this = cosinePowerFilter(size, cosinePower, fixupMethod);
|
||||
}
|
||||
|
||||
void CubeSurface::_fastResample(int size, EdgeFixup fixupMethod) {
|
||||
*this = fastResample(size, fixupMethod);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CubeSurface::toLinear(float gamma)
|
||||
{
|
||||
if (isNull()) return;
|
||||
|
@ -49,7 +49,7 @@
|
||||
# define NVTT_API
|
||||
#endif
|
||||
|
||||
#define NVTT_VERSION 20100
|
||||
#define NVTT_VERSION 20101
|
||||
|
||||
#define NVTT_FORBID_COPY(Class) \
|
||||
private: \
|
||||
@ -463,8 +463,8 @@ namespace nvtt
|
||||
ToneMapper_Lightmap,
|
||||
};
|
||||
|
||||
// Transform the given x,y coordinates.
|
||||
typedef void WarpFunction(float & x, float & y, float & d);
|
||||
// Transform the given x,y,z coordinates.
|
||||
typedef void WarpFunction(float & x, float & y, float & z);
|
||||
|
||||
|
||||
// A surface is one level of a 2D or 3D texture. (New in NVTT 2.1)
|
||||
@ -664,11 +664,6 @@ namespace nvtt
|
||||
|
||||
NVTT_API CubeSurface fastResample(int size, EdgeFixup fixupMethod) const;
|
||||
|
||||
// Jai doesn't support non-pod structs as return types, so expose some other function to do the same, but operate in place:
|
||||
NVTT_API void _irradianceFilter(int size, EdgeFixup fixupMethod);
|
||||
NVTT_API void _cosinePowerFilter(int size, float cosinePower, EdgeFixup fixupMethod);
|
||||
NVTT_API void _fastResample(int size, EdgeFixup fixupMethod);
|
||||
|
||||
// Spherical Harmonics:
|
||||
NVTT_API void computeLuminanceIrradianceSH3(float sh[9]) const;
|
||||
NVTT_API void computeIrradianceSH3(int channel, float sh[9]) const;
|
||||
|
@ -21,8 +21,8 @@
|
||||
#define ICETC_IMPLEMENTATION
|
||||
#include "nvtt/icetc.h"
|
||||
|
||||
#define GOOFYTC_IMPLEMENTATION
|
||||
#include "../extern/goofy_tc.h"
|
||||
//#define GOOFYTC_IMPLEMENTATION
|
||||
//#include "../extern/goofy_tc.h"
|
||||
|
||||
#include "../extern/rg_etc1_v104/rg_etc1.h"
|
||||
#include "../extern/rg_etc1_v104/rg_etc1.cpp"
|
||||
|
Reference in New Issue
Block a user