Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

Restore 2 0 8 abi #275

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/nvtt/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ bool Compressor::Private::compress(const InputOptions::Private & inputOptions, c
// Resize input.
img.resize(w, h, d, ResizeFilter_Box);

// Apply color transform.
if (inputOptions.colorTransform == ColorTransform_YCoCg) {
img.toYCoCg();
}

nvtt::Surface tmp = img;
if (!img.isNormalMap()) {
tmp.toGamma(inputOptions.outputGamma);
Expand Down
23 changes: 22 additions & 1 deletion src/nvtt/InputOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ void InputOptions::reset()
m.inputGamma = 2.2f;
m.outputGamma = 2.2f;

m.colorTransform = ColorTransform_None;

m.generateMipmaps = true;
m.maxLevel = -1;
m.mipmapFilter = MipmapFilter_Box;
Expand All @@ -124,7 +126,14 @@ void InputOptions::reset()


// Setup the input image.
void InputOptions::setTextureLayout(TextureType type, int width, int height, int depth /*= 1*/, int arraySize /*= 1*/)
// Overload for ABI compatibility
void InputOptions::setTextureLayout(TextureType type, int width, int height, int depth /*= 1*/)
{
setTextureLayout(type, width, height, depth, 1);
}

// Setup the input image.
void InputOptions::setTextureLayout(TextureType type, int width, int height, int depth, int arraySize)
{
// Validate arguments.
nvCheck(width >= 0);
Expand Down Expand Up @@ -330,6 +339,18 @@ void InputOptions::setNormalizeMipmaps(bool normalize)
m.normalizeMipmaps = normalize;
}

// Set color transform.
void InputOptions::setColorTransform(ColorTransform t)
{
m.colorTransform = t;
}

// Set linear transform for the given channel.
// Stub for ABI compatibily, never implemented
void InputOptions::setLinearTransform(int, float, float, float, float)
{
}

void InputOptions::setMaxExtents(int e)
{
nvDebugCheck(e > 0);
Expand Down
3 changes: 3 additions & 0 deletions src/nvtt/InputOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ namespace nvtt
float inputGamma;
float outputGamma;

// Color transform.
ColorTransform colorTransform;

// Mipmap generation options.
bool generateMipmaps;
int maxLevel;
Expand Down
19 changes: 18 additions & 1 deletion src/nvtt/nvtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ namespace nvtt
ResizeFilter_Mitchell,
};

// Color transformation.
// deprecated since 2.1.0
enum ColorTransform
{
ColorTransform_None,
ColorTransform_Linear,
ColorTransform_Swizzle,
ColorTransform_YCoCg,
ColorTransform_ScaledYCoCg,
};

// Extents rounding mode.
enum RoundMode
{
Expand Down Expand Up @@ -290,7 +301,9 @@ namespace nvtt
NVTT_API void reset();

// Setup input layout.
NVTT_API void setTextureLayout(TextureType type, int w, int h, int d = 1, int arraySize = 1);
// Overload for ABI compatibility
NVTT_API void setTextureLayout(TextureType type, int w, int h, int d = 1 /*, arraysize = 1 */);
NVTT_API void setTextureLayout(TextureType type, int w, int h, int d, int arraySize);
NVTT_API void resetTextureLayout();

// Set mipmap data. Copies the data.
Expand Down Expand Up @@ -320,6 +333,10 @@ namespace nvtt
NVTT_API void setNormalFilter(float sm, float medium, float big, float large);
NVTT_API void setNormalizeMipmaps(bool b);

// Set color transforms.
NVTT_API void setColorTransform(ColorTransform t);
NVTT_API void setLinearTransform(int channel, float w0, float w1, float w2, float w3);

// Set resizing options.
NVTT_API void setMaxExtents(int d);
NVTT_API void setRoundMode(RoundMode mode);
Expand Down