Add alpha flag to DXT1a files.
This commit is contained in:
parent
154e117e13
commit
782a127071
@ -62,7 +62,7 @@ void ColorBlock::init(const Image * img, uint x, uint y)
|
||||
nvDebugCheck(bw != 0);
|
||||
nvDebugCheck(bh != 0);
|
||||
|
||||
static int remainder[] = {
|
||||
static const int remainder[] = {
|
||||
0, 0, 0, 0,
|
||||
0, 1, 0, 1,
|
||||
0, 1, 2, 0,
|
||||
|
@ -681,11 +681,18 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask
|
||||
nvCheck((gmask & amask) == 0);
|
||||
nvCheck((bmask & amask) == 0);
|
||||
|
||||
if (rmask != 0 || gmask != 0 || bmask != 0)
|
||||
{
|
||||
this->pf.flags = DDPF_RGB;
|
||||
|
||||
if (amask != 0) {
|
||||
this->pf.flags |= DDPF_ALPHAPIXELS;
|
||||
}
|
||||
}
|
||||
else if (amask != 0)
|
||||
{
|
||||
this->pf.flags |= DDPF_ALPHA;
|
||||
}
|
||||
|
||||
if (bitcount == 0)
|
||||
{
|
||||
@ -726,6 +733,12 @@ void DDSHeader::setNormalFlag(bool b)
|
||||
else this->pf.flags &= ~DDPF_NORMAL;
|
||||
}
|
||||
|
||||
void DDSHeader::setHasAlphaFlag(bool b)
|
||||
{
|
||||
if (b) this->pf.flags |= DDPF_ALPHAPIXELS;
|
||||
else this->pf.flags &= ~DDPF_ALPHAPIXELS;
|
||||
}
|
||||
|
||||
void DDSHeader::swapBytes()
|
||||
{
|
||||
this->fourcc = POSH_LittleU32(this->fourcc);
|
||||
@ -883,7 +896,7 @@ bool DirectDrawSurface::hasAlpha() const
|
||||
{
|
||||
if (header.hasDX10Header())
|
||||
{
|
||||
// @@ TODO: Update with all formats.
|
||||
#pragma message(NV_FILE_LINE "Update hasAlpha to handle all DX10 formats.")
|
||||
return
|
||||
header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM ||
|
||||
header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM ||
|
||||
@ -906,6 +919,7 @@ bool DirectDrawSurface::hasAlpha() const
|
||||
}
|
||||
else
|
||||
{
|
||||
// @@ Here we could check the ALPHA_PIXELS flag, but nobody sets it.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -991,6 +1005,13 @@ void DirectDrawSurface::setNormalFlag(bool b)
|
||||
header.setNormalFlag(b);
|
||||
}
|
||||
|
||||
void DirectDrawSurface::setHasAlphaFlag(bool b)
|
||||
{
|
||||
nvDebugCheck(isValid());
|
||||
header.setHasAlphaFlag(b);
|
||||
}
|
||||
|
||||
|
||||
void DirectDrawSurface::mipmap(Image * img, uint face, uint mipmap)
|
||||
{
|
||||
nvDebugCheck(isValid());
|
||||
|
@ -98,6 +98,7 @@ namespace nv
|
||||
void setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask);
|
||||
void setDX10Format(uint format);
|
||||
void setNormalFlag(bool b);
|
||||
void setHasAlphaFlag(bool b);
|
||||
|
||||
void swapBytes();
|
||||
|
||||
@ -130,6 +131,7 @@ namespace nv
|
||||
bool isTextureCube() const;
|
||||
|
||||
void setNormalFlag(bool b);
|
||||
void setHasAlphaFlag(bool b);
|
||||
|
||||
void mipmap(Image * img, uint f, uint m);
|
||||
// void mipmap(FloatImage * img, uint f, uint m);
|
||||
|
@ -414,6 +414,7 @@ bool Compressor::Private::outputHeader(const InputOptions::Private & inputOption
|
||||
{
|
||||
if (compressionOptions.format == Format_DXT1 || compressionOptions.format == Format_DXT1a || compressionOptions.format == Format_DXT1n) {
|
||||
header.setDX10Format(71);
|
||||
if (compressionOptions.format == Format_DXT1a) header.setHasAlphaFlag(true);
|
||||
if (inputOptions.isNormalMap) header.setNormalFlag(true);
|
||||
}
|
||||
else if (compressionOptions.format == Format_DXT3) {
|
||||
|
Loading…
Reference in New Issue
Block a user