Merge changes from 2.0.

This commit is contained in:
castano
2010-06-01 19:23:37 +00:00
parent caff2c9006
commit c3bc24b165
2 changed files with 30 additions and 9 deletions

View File

@ -682,8 +682,15 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask
nvCheck((bmask & amask) == 0); nvCheck((bmask & amask) == 0);
if (rmask != 0 || gmask != 0 || bmask != 0) if (rmask != 0 || gmask != 0 || bmask != 0)
{
if (gmask == 0 && bmask == 0)
{
this->pf.flags = DDPF_LUMINANCE;
}
else
{ {
this->pf.flags = DDPF_RGB; this->pf.flags = DDPF_RGB;
}
if (amask != 0) { if (amask != 0) {
this->pf.flags |= DDPF_ALPHAPIXELS; this->pf.flags |= DDPF_ALPHAPIXELS;
@ -867,9 +874,9 @@ bool DirectDrawSurface::isSupported() const
return false; return false;
} }
} }
else if (header.pf.flags & DDPF_RGB) else if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE))
{ {
// All RGB formats are supported now. // All RGB and luminance formats are supported now.
} }
else else
{ {
@ -1294,7 +1301,7 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const
} }
else else
{ {
nvDebugCheck(header.pf.flags & DDPF_RGB); nvDebugCheck((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE));
// Align pixels to bytes. // Align pixels to bytes.
uint byteCount = (header.pf.bitcount + 7) / 8; uint byteCount = (header.pf.bitcount + 7) / 8;
@ -1364,6 +1371,7 @@ void DirectDrawSurface::printInfo() const
printf("Pixel Format:\n"); printf("Pixel Format:\n");
printf("\tFlags: 0x%.8X\n", header.pf.flags); printf("\tFlags: 0x%.8X\n", header.pf.flags);
if (header.pf.flags & DDPF_RGB) printf("\t\tDDPF_RGB\n"); if (header.pf.flags & DDPF_RGB) printf("\t\tDDPF_RGB\n");
if (header.pf.flags & DDPF_LUMINANCE) printf("\t\tDDPF_LUMINANCE\n");
if (header.pf.flags & DDPF_FOURCC) printf("\t\tDDPF_FOURCC\n"); if (header.pf.flags & DDPF_FOURCC) printf("\t\tDDPF_FOURCC\n");
if (header.pf.flags & DDPF_ALPHAPIXELS) printf("\t\tDDPF_ALPHAPIXELS\n"); if (header.pf.flags & DDPF_ALPHAPIXELS) printf("\t\tDDPF_ALPHAPIXELS\n");
if (header.pf.flags & DDPF_ALPHA) printf("\t\tDDPF_ALPHA\n"); if (header.pf.flags & DDPF_ALPHA) printf("\t\tDDPF_ALPHA\n");

View File

@ -142,6 +142,7 @@ int main(int argc, char *argv[])
bool fast = false; bool fast = false;
bool nocuda = false; bool nocuda = false;
bool bc1n = false; bool bc1n = false;
bool luminance = false;
nvtt::Format format = nvtt::Format_BC1; nvtt::Format format = nvtt::Format_BC1;
bool premultiplyAlpha = false; bool premultiplyAlpha = false;
nvtt::MipmapFilter mipmapFilter = nvtt::MipmapFilter_Box; nvtt::MipmapFilter mipmapFilter = nvtt::MipmapFilter_Box;
@ -217,6 +218,11 @@ int main(int argc, char *argv[])
{ {
format = nvtt::Format_RGB; format = nvtt::Format_RGB;
} }
else if (strcmp("-lumi", argv[i]) == 0)
{
luminance = true;
format = nvtt::Format_RGB;
}
else if (strcmp("-bc1", argv[i]) == 0) else if (strcmp("-bc1", argv[i]) == 0)
{ {
format = nvtt::Format_BC1; format = nvtt::Format_BC1;
@ -315,6 +321,7 @@ int main(int argc, char *argv[])
printf(" -fast \tFast compression.\n"); printf(" -fast \tFast compression.\n");
printf(" -nocuda \tDo not use cuda compressor.\n"); printf(" -nocuda \tDo not use cuda compressor.\n");
printf(" -rgb \tRGBA format\n"); printf(" -rgb \tRGBA format\n");
printf(" -lumi \tLUMINANCE format\n");
printf(" -bc1 \tBC1 format (DXT1)\n"); printf(" -bc1 \tBC1 format (DXT1)\n");
printf(" -bc1n \tBC1 normal map format (DXT1nm)\n"); printf(" -bc1n \tBC1 normal map format (DXT1nm)\n");
printf(" -bc1a \tBC1 format with binary alpha (DXT1a)\n"); printf(" -bc1a \tBC1 format with binary alpha (DXT1a)\n");
@ -478,12 +485,18 @@ int main(int argc, char *argv[])
if (format == nvtt::Format_RGBA) if (format == nvtt::Format_RGBA)
{ {
if (luminance)
{
compressionOptions.setPixelFormat(8, 0xff, 0, 0, 0);
}
else {
// @@ Edit this to choose the desired pixel format: // @@ Edit this to choose the desired pixel format:
// compressionOptions.setPixelType(nvtt::PixelType_Float); // compressionOptions.setPixelType(nvtt::PixelType_Float);
// compressionOptions.setPixelFormat(16, 16, 16, 16); // compressionOptions.setPixelFormat(16, 16, 16, 16);
// compressionOptions.setPixelType(nvtt::PixelType_UnsignedNorm); // compressionOptions.setPixelType(nvtt::PixelType_UnsignedNorm);
// compressionOptions.setPixelFormat(16, 0, 0, 0); // compressionOptions.setPixelFormat(16, 0, 0, 0);
} }
}
if (fast) if (fast)
{ {