BC6/7 progress. Work in progress.
This commit is contained in:
parent
f2c581dec1
commit
5c60989043
|
@ -24,10 +24,31 @@
|
||||||
#include "CompressorDX11.h"
|
#include "CompressorDX11.h"
|
||||||
|
|
||||||
#include "nvtt.h"
|
#include "nvtt.h"
|
||||||
|
#include "CompressionOptions.h"
|
||||||
|
|
||||||
|
#include "bc6h/zoh.h"
|
||||||
|
#include "bc6h/utils.h"
|
||||||
|
|
||||||
using namespace nv;
|
using namespace nv;
|
||||||
using namespace nvtt;
|
using namespace nvtt;
|
||||||
|
|
||||||
|
|
||||||
|
void CompressorBC6::compressBlock(Tile & tile, AlphaMode alphaMode, const CompressionOptions::Private & compressionOptions, void * output)
|
||||||
|
{
|
||||||
|
NV_UNUSED(alphaMode); // ZOH does not support alpha.
|
||||||
|
|
||||||
|
if (compressionOptions.pixelType == PixelType_UnsignedFloat ||
|
||||||
|
compressionOptions.pixelType == PixelType_UnsignedNorm ||
|
||||||
|
compressionOptions.pixelType == PixelType_UnsignedInt)
|
||||||
|
{
|
||||||
|
Utils::FORMAT = UNSIGNED_F16; // @@ Do not use globals.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Utils::FORMAT = SIGNED_F16;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZOH::compress(tile, (char *)output);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,15 +28,15 @@
|
||||||
|
|
||||||
namespace nv
|
namespace nv
|
||||||
{
|
{
|
||||||
struct CompressorBC6 : public FixedBlockCompressor
|
struct CompressorBC6 : public TileCompressor
|
||||||
{
|
{
|
||||||
virtual void compressBlock(ColorBlock & rgba, nvtt::AlphaMode alphaMode, const nvtt::CompressionOptions::Private & compressionOptions, void * output);
|
virtual void compressBlock(Tile & tile, nvtt::AlphaMode alphaMode, const nvtt::CompressionOptions::Private & compressionOptions, void * output);
|
||||||
virtual uint blockSize() const { return 16; }
|
virtual uint blockSize() const { return 16; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CompressorBC7 : public FixedBlockCompressor
|
struct CompressorBC7 : public TileCompressor
|
||||||
{
|
{
|
||||||
virtual void compressBlock(ColorBlock & rgba, nvtt::AlphaMode alphaMode, const nvtt::CompressionOptions::Private & compressionOptions, void * output);
|
virtual void compressBlock(Tile & tile, nvtt::AlphaMode alphaMode, const nvtt::CompressionOptions::Private & compressionOptions, void * output);
|
||||||
virtual uint blockSize() const { return 16; }
|
virtual uint blockSize() const { return 16; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ void FixedBlockCompressor::compress(nvtt::InputFormat inputFormat, nvtt::AlphaMo
|
||||||
const uint bs = blockSize();
|
const uint bs = blockSize();
|
||||||
const uint bw = (w + 3) / 4;
|
const uint bw = (w + 3) / 4;
|
||||||
const uint bh = (h + 3) / 4;
|
const uint bh = (h + 3) / 4;
|
||||||
const uint size = bs * bw * bh;
|
|
||||||
|
|
||||||
#if defined(HAVE_OPENMP)
|
#if defined(HAVE_OPENMP)
|
||||||
bool singleThreaded = false;
|
bool singleThreaded = false;
|
||||||
|
@ -61,9 +60,9 @@ void FixedBlockCompressor::compress(nvtt::InputFormat inputFormat, nvtt::AlphaMo
|
||||||
if (bw * bh < 16) singleThreaded = true;
|
if (bw * bh < 16) singleThreaded = true;
|
||||||
|
|
||||||
if (singleThreaded)
|
if (singleThreaded)
|
||||||
{
|
{
|
||||||
nvDebugCheck(bs <= 16);
|
nvDebugCheck(bs <= 16);
|
||||||
uint8 mem[16];
|
uint8 mem[16]; // @@ Output one row at a time!
|
||||||
|
|
||||||
for (int y = 0; y < int(h); y += 4) {
|
for (int y = 0; y < int(h); y += 4) {
|
||||||
for (uint x = 0; x < w; x += 4) {
|
for (uint x = 0; x < w; x += 4) {
|
||||||
|
@ -88,7 +87,8 @@ void FixedBlockCompressor::compress(nvtt::InputFormat inputFormat, nvtt::AlphaMo
|
||||||
#if defined(HAVE_OPENMP)
|
#if defined(HAVE_OPENMP)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint8 * mem = new uint8[size];
|
const uint size = bs * bw * bh;
|
||||||
|
uint8 * mem = new uint8[size];
|
||||||
|
|
||||||
#pragma omp parallel
|
#pragma omp parallel
|
||||||
{
|
{
|
||||||
|
@ -121,3 +121,40 @@ void FixedBlockCompressor::compress(nvtt::InputFormat inputFormat, nvtt::AlphaMo
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "bc6h/tile.h"
|
||||||
|
|
||||||
|
void TileCompressor::compress(InputFormat inputFormat, AlphaMode alphaMode, uint w, uint h, const void * data, const CompressionOptions::Private & compressionOptions, const OutputOptions::Private & outputOptions)
|
||||||
|
{
|
||||||
|
const uint bs = blockSize();
|
||||||
|
const uint bw = (w + 3) / 4;
|
||||||
|
const uint bh = (h + 3) / 4;
|
||||||
|
|
||||||
|
bool singleThreaded = true;
|
||||||
|
|
||||||
|
if (singleThreaded)
|
||||||
|
{
|
||||||
|
nvDebugCheck(bs <= 16);
|
||||||
|
uint8 mem[16]; // @@ Output one row at a time!
|
||||||
|
|
||||||
|
for (uint y = 0; y < h; y += 4) {
|
||||||
|
for (uint x = 0; x < w; x += 4) {
|
||||||
|
|
||||||
|
Tile tile;
|
||||||
|
if (inputFormat == nvtt::InputFormat_BGRA_8UB) {
|
||||||
|
//tile.init((const uint *)data, w, h, x, y);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nvDebugCheck(inputFormat == nvtt::InputFormat_RGBA_32F);
|
||||||
|
//tile.init((const float *)data, w, h, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
compressBlock(tile, alphaMode, compressionOptions, mem);
|
||||||
|
|
||||||
|
if (outputOptions.outputHandler != NULL) {
|
||||||
|
outputOptions.outputHandler->writeData(mem, bs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -26,10 +26,11 @@
|
||||||
|
|
||||||
#include "Compressor.h"
|
#include "Compressor.h"
|
||||||
|
|
||||||
|
struct Tile;
|
||||||
|
|
||||||
namespace nv
|
namespace nv
|
||||||
{
|
{
|
||||||
struct ColorBlock;
|
struct ColorBlock;
|
||||||
struct Tile;
|
|
||||||
|
|
||||||
struct FixedBlockCompressor : public CompressorInterface
|
struct FixedBlockCompressor : public CompressorInterface
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
static const int TILE_H = 4;
|
static const int TILE_H = 4;
|
||||||
static const int TILE_W = 4;
|
static const int TILE_W = 4;
|
||||||
static const int TILE_TOTAL = TILE_H * TILE_W;
|
static const int TILE_TOTAL = TILE_H * TILE_W;
|
||||||
Vector3 data[TILE_H][TILE_W];
|
nv::Vector3 data[TILE_H][TILE_W];
|
||||||
float importance_map[TILE_H][TILE_W];
|
float importance_map[TILE_H][TILE_W];
|
||||||
int size_x, size_y; // actual size of tile
|
int size_x, size_y; // actual size of tile
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,6 @@ See the License for the specific language governing permissions and limitations
|
||||||
|
|
||||||
#include "nvmath/Vector.h"
|
#include "nvmath/Vector.h"
|
||||||
|
|
||||||
using namespace nv; // @@ Move everything to nv namespace instead.
|
|
||||||
|
|
||||||
#define PALETTE_LERP(a, b, i, denom) Utils::lerp(a, b, i, denom)
|
#define PALETTE_LERP(a, b, i, denom) Utils::lerp(a, b, i, denom)
|
||||||
|
|
||||||
|
@ -45,18 +44,18 @@ enum Format { UNSIGNED_F16, SIGNED_F16 };
|
||||||
class Utils
|
class Utils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Format FORMAT; // this is a global -- we're either handling unsigned or unsigned half values
|
static ::Format FORMAT; // this is a global -- we're either handling unsigned or unsigned half values
|
||||||
|
|
||||||
// error metrics
|
// error metrics
|
||||||
static double norm(const Vector3 &a, const Vector3 &b);
|
static double norm(const nv::Vector3 &a, const nv::Vector3 &b);
|
||||||
static double mpsnr_norm(const Vector3 &a, int exposure, const Vector3 &b);
|
static double mpsnr_norm(const nv::Vector3 &a, int exposure, const nv::Vector3 &b);
|
||||||
|
|
||||||
// conversion & clamp
|
// conversion & clamp
|
||||||
static int ushort_to_format(unsigned short input);
|
static int ushort_to_format(unsigned short input);
|
||||||
static unsigned short format_to_ushort(int input);
|
static unsigned short format_to_ushort(int input);
|
||||||
|
|
||||||
// clamp to format
|
// clamp to format
|
||||||
static void clamp(Vector3 &v);
|
static void clamp(nv::Vector3 &v);
|
||||||
|
|
||||||
// quantization and unquantization
|
// quantization and unquantization
|
||||||
static int finish_unquantize(int q, int prec);
|
static int finish_unquantize(int q, int prec);
|
||||||
|
@ -67,7 +66,7 @@ public:
|
||||||
|
|
||||||
// lerping
|
// lerping
|
||||||
static int lerp(int a, int b, int i, int denom);
|
static int lerp(int a, int b, int i, int denom);
|
||||||
static Vector3 lerp(const Vector3 & a, const Vector3 & b, int i, int denom);
|
static nv::Vector3 lerp(const nv::Vector3 & a, const nv::Vector3 & b, int i, int denom);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _UTILS_H
|
#endif // _UTILS_H
|
||||||
|
|
|
@ -29,8 +29,8 @@ See the License for the specific language governing permissions and limitations
|
||||||
|
|
||||||
struct FltEndpts
|
struct FltEndpts
|
||||||
{
|
{
|
||||||
Vector3 A;
|
nv::Vector3 A;
|
||||||
Vector3 B;
|
nv::Vector3 B;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IntEndpts
|
struct IntEndpts
|
||||||
|
|
|
@ -19,12 +19,12 @@ TARGET_LINK_LIBRARIES(nvzoom nvcore nvmath nvimage)
|
||||||
|
|
||||||
SET(TOOLS nvcompress nvdecompress nvddsinfo nvassemble nvzoom)
|
SET(TOOLS nvcompress nvdecompress nvddsinfo nvassemble nvzoom)
|
||||||
|
|
||||||
IF(GLEW_FOUND AND GLUT_FOUND)
|
#IF(GLEW_FOUND AND GLUT_FOUND)
|
||||||
INCLUDE_DIRECTORIES(${GLEW_INCLUDE_PATH} ${GLUT_INCLUDE_DIR})
|
# INCLUDE_DIRECTORIES(${GLEW_INCLUDE_PATH} ${GLUT_INCLUDE_DIR})
|
||||||
ADD_EXECUTABLE(nvddsview ddsview.cpp cmdline.h)
|
# ADD_EXECUTABLE(nvddsview ddsview.cpp cmdline.h)
|
||||||
TARGET_LINK_LIBRARIES(nvddsview nvcore nvmath nvimage ${GLEW_LIBRARY} ${GLUT_LIBRARY})
|
# TARGET_LINK_LIBRARIES(nvddsview nvcore nvmath nvimage ${GLEW_LIBRARY} ${GLUT_LIBRARY})
|
||||||
SET(TOOLS ${TOOLS} nvddsview)
|
# SET(TOOLS ${TOOLS} nvddsview)
|
||||||
ENDIF(GLEW_FOUND AND GLUT_FOUND)
|
#ENDIF(GLEW_FOUND AND GLUT_FOUND)
|
||||||
|
|
||||||
|
|
||||||
ADD_EXECUTABLE(nv-gnome-thumbnailer thumbnailer.cpp cmdline.h)
|
ADD_EXECUTABLE(nv-gnome-thumbnailer thumbnailer.cpp cmdline.h)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user