Merge changes from The Witness.
This commit is contained in:
@ -61,6 +61,9 @@ struct MyAssertHandler : public nv::AssertHandler {
|
||||
virtual int assertion( const char *exp, const char *file, int line, const char *func, const char *msg, va_list arg ) {
|
||||
fprintf(stderr, "Assertion failed: %s\nIn %s:%d\n", exp, file, line);
|
||||
nv::debug::dumpInfo();
|
||||
if (nv::debug::isDebuggerPresent()) {
|
||||
return NV_ABORT_DEBUG;
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
|
@ -154,11 +154,13 @@ int main(int argc, char *argv[])
|
||||
bool loadAsFloat = false;
|
||||
bool rgbm = false;
|
||||
bool rangescale = false;
|
||||
bool srgb = false;
|
||||
|
||||
const char * externalCompressor = NULL;
|
||||
|
||||
bool silent = false;
|
||||
bool dds10 = false;
|
||||
bool ktx = false;
|
||||
|
||||
nv::Path input;
|
||||
nv::Path output;
|
||||
@ -285,6 +287,31 @@ int main(int argc, char *argv[])
|
||||
format = nvtt::Format_BC3_RGBM;
|
||||
rgbm = true;
|
||||
}
|
||||
else if (strcmp("-etc1", argv[i]) == 0)
|
||||
{
|
||||
format = nvtt::Format_ETC1;
|
||||
}
|
||||
else if (strcmp("-etc2", argv[i]) == 0 || strcmp("-etc2_rgb", argv[i]) == 0)
|
||||
{
|
||||
format = nvtt::Format_ETC2_RGB;
|
||||
}
|
||||
else if (strcmp("-etc2_eac", argv[i]) == 0 || strcmp("-etc2_rgba", argv[i]) == 0)
|
||||
{
|
||||
format = nvtt::Format_ETC2_RGBA;
|
||||
}
|
||||
else if (strcmp("-eac", argv[i]) == 0 || strcmp("-etc2_r", argv[i]) == 0)
|
||||
{
|
||||
format = nvtt::Format_ETC2_R;
|
||||
}
|
||||
else if (strcmp("-etc2_rg", argv[i]) == 0)
|
||||
{
|
||||
format = nvtt::Format_ETC2_R;
|
||||
}
|
||||
else if (strcmp("-etc2_rgbm", argv[i]) == 0)
|
||||
{
|
||||
format = nvtt::Format_ETC2_RGBM;
|
||||
rgbm = true;
|
||||
}
|
||||
|
||||
// Undocumented option. Mainly used for testing.
|
||||
else if (strcmp("-ext", argv[i]) == 0)
|
||||
@ -309,7 +336,15 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
dds10 = true;
|
||||
}
|
||||
|
||||
else if (strcmp("-ktx", argv[i]) == 0)
|
||||
{
|
||||
ktx = true;
|
||||
}
|
||||
else if (strcmp("-srgb", argv[i]) == 0)
|
||||
{
|
||||
srgb = true;
|
||||
}
|
||||
|
||||
else if (argv[i][0] != '-')
|
||||
{
|
||||
input = argv[i];
|
||||
@ -321,15 +356,23 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
output.copy(input.str());
|
||||
output.stripExtension();
|
||||
output.append(".dds");
|
||||
|
||||
if (ktx)
|
||||
{
|
||||
output.append(".ktx");
|
||||
}
|
||||
else
|
||||
{
|
||||
output.append(".dds");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Warning: unrecognized option \"%s\"\n", argv[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Warning: unrecognized option \"%s\"\n", argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
const uint version = nvtt::version();
|
||||
@ -380,7 +423,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf("Output options:\n");
|
||||
printf(" -silent \tDo not output progress messages\n");
|
||||
printf(" -dds10 \tUse DirectX 10 DDS format (enabled by default for BC6/7)\n\n");
|
||||
printf(" -dds10 \tUse DirectX 10 DDS format (enabled by default for BC6/7, unless ktx is being used)\n");
|
||||
printf(" -ktx \tUse KTX container format\n");
|
||||
printf(" -srgb \tIf the requested format allows it, output will be in sRGB color space\n\n");
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@ -398,7 +443,7 @@ int main(int argc, char *argv[])
|
||||
bool useSurface = false; // @@ use Surface API in all cases!
|
||||
nvtt::Surface image;
|
||||
|
||||
if (format == nvtt::Format_BC3_RGBM || rgbm) {
|
||||
if (format == nvtt::Format_BC3_RGBM || format == nvtt::Format_ETC2_RGBM || rgbm) {
|
||||
useSurface = true;
|
||||
|
||||
if (!image.load(input.str())) {
|
||||
@ -440,7 +485,7 @@ int main(int argc, char *argv[])
|
||||
// To gamma.
|
||||
image.toGamma(2);
|
||||
|
||||
if (format != nvtt::Format_BC3_RGBM) {
|
||||
if (format != nvtt::Format_BC3_RGBM || format != nvtt::Format_ETC2_RGBM) {
|
||||
image.setAlphaMode(nvtt::AlphaMode_None);
|
||||
image.toRGBM(1, 0.15f);
|
||||
}
|
||||
@ -494,7 +539,7 @@ int main(int argc, char *argv[])
|
||||
nvDebugCheck(dds.isTextureArray());
|
||||
inputOptions.setTextureLayout(nvtt::TextureType_Array, dds.width(), dds.height(), 1, dds.arraySize());
|
||||
faceCount = dds.arraySize();
|
||||
dds10 = true;
|
||||
dds10 = ktx ? false : true;
|
||||
}
|
||||
|
||||
uint mipmapCount = dds.mipmapCount();
|
||||
@ -569,11 +614,12 @@ int main(int argc, char *argv[])
|
||||
inputOptions.setAlphaMode(nvtt::AlphaMode_None);
|
||||
}
|
||||
|
||||
// IC: Do not enforce D3D9 restrictions anymore.
|
||||
// Block compressed textures with mipmaps must be powers of two.
|
||||
if (!noMipmaps && format != nvtt::Format_RGB)
|
||||
/*if (!noMipmaps && format != nvtt::Format_RGB)
|
||||
{
|
||||
inputOptions.setRoundMode(nvtt::RoundMode_ToPreviousPowerOfTwo);
|
||||
}
|
||||
}*/
|
||||
|
||||
if (normal)
|
||||
{
|
||||
@ -720,15 +766,27 @@ int main(int argc, char *argv[])
|
||||
outputOptions.setOutputHandler(&outputHandler);
|
||||
outputOptions.setErrorHandler(&errorHandler);
|
||||
|
||||
// Automatically use dds10 if compressing to BC6 or BC7
|
||||
if (format == nvtt::Format_BC6 || format == nvtt::Format_BC7)
|
||||
{
|
||||
dds10 = true;
|
||||
}
|
||||
|
||||
if (dds10)
|
||||
if (ktx)
|
||||
{
|
||||
outputOptions.setContainer(nvtt::Container_DDS10);
|
||||
outputOptions.setContainer(nvtt::Container_KTX);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Automatically use dds10 if compressing to BC6 or BC7
|
||||
if (format == nvtt::Format_BC6 || format == nvtt::Format_BC7) {
|
||||
dds10 = true;
|
||||
}
|
||||
|
||||
if (dds10) {
|
||||
outputOptions.setContainer(nvtt::Container_DDS10);
|
||||
}
|
||||
else {
|
||||
outputOptions.setContainer(nvtt::Container_DDS);
|
||||
}
|
||||
}
|
||||
|
||||
if (srgb) {
|
||||
outputOptions.setSrgbFlag(true);
|
||||
}
|
||||
|
||||
// printf("Press ENTER.\n");
|
||||
|
@ -99,8 +99,8 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (input.isNull() || output.isNull())
|
||||
@ -136,21 +136,21 @@ int main(int argc, char *argv[])
|
||||
nv::FloatImage fimage(&image);
|
||||
fimage.toLinear(0, 3, gamma);
|
||||
|
||||
uint thumbW, thumbH;
|
||||
if (image.width() > image.height())
|
||||
{
|
||||
thumbW = size;
|
||||
thumbH = uint ((float (image.height()) / float (image.width())) * size);
|
||||
}
|
||||
else
|
||||
{
|
||||
thumbW = uint ((float (image.width()) / float (image.height())) * size);
|
||||
thumbH = size;
|
||||
}
|
||||
nv::AutoPtr<nv::FloatImage> fresult(fimage.resize(nv::BoxFilter(), thumbW, thumbH, nv::FloatImage::WrapMode_Clamp));
|
||||
uint thumbW, thumbH;
|
||||
if (image.width() > image.height())
|
||||
{
|
||||
thumbW = size;
|
||||
thumbH = uint ((float (image.height()) / float (image.width())) * size);
|
||||
}
|
||||
else
|
||||
{
|
||||
thumbW = uint ((float (image.width()) / float (image.height())) * size);
|
||||
thumbH = size;
|
||||
}
|
||||
nv::AutoPtr<nv::FloatImage> fresult(fimage.resize(nv::BoxFilter(), thumbW, thumbH, nv::FloatImage::WrapMode_Clamp));
|
||||
|
||||
nv::AutoPtr<nv::Image> result(fresult->createImageGammaCorrect(gamma));
|
||||
result->setFormat(nv::Image::Format_ARGB);
|
||||
nv::AutoPtr<nv::Image> result(fresult->createImageGammaCorrect(gamma));
|
||||
result->setFormat(nv::Image::Format_ARGB);
|
||||
|
||||
nv::StdOutputStream stream(output.str());
|
||||
nv::ImageIO::save(output.str(), stream, result.ptr(), metaData.buffer());
|
||||
@ -160,7 +160,7 @@ int main(int argc, char *argv[])
|
||||
nv::StdOutputStream stream(output.str());
|
||||
nv::ImageIO::save(output.str(), stream, &image, metaData.buffer());
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user