mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2025-01-07 01:25:36 +00:00
Add DXT1/5 to Image*KTX
- Closes #29 - Added GL prefixes to GLDefines.h where they were missing - Added PVRTC4 to ImageLoaderKTX
This commit is contained in:
parent
adcea1bddc
commit
e19d4ec0a8
|
@ -59,20 +59,34 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
#ifndef GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
||||||
#define COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
|
#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGB_PVRTC_2BPPV1_IMG
|
#ifndef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
|
||||||
#define COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
|
#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
#ifndef GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
||||||
#define COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
|
#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
|
#ifndef GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
|
||||||
#define COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
|
#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// DXT definitions
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT
|
||||||
|
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
|
||||||
|
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -81,60 +95,60 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_4x4_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_4x4_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
|
#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_5x4_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_5x4_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
|
#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_5x5_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_5x5_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
|
#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_6x5_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_6x5_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
|
#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_6x6_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_6x6_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
|
#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_8x5_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_8x5_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
|
#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_8x6_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_8x6_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
|
#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_8x8_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_8x8_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
|
#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_10x5_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_10x5_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
|
#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_10x6_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_10x6_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
|
#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_10x8_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_10x8_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
|
#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_10x10_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_10x10_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
|
#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_12x10_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_12x10_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
|
#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMPRESSED_RGBA_ASTC_12x12_KHR
|
#ifndef GL_COMPRESSED_RGBA_ASTC_12x12_KHR
|
||||||
#define COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
|
#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -244,59 +244,72 @@ bool ImageLoaderKTX::ReadData() {
|
||||||
m_Format = FasTC::eCompressionFormat_BPTC;
|
m_Format = FasTC::eCompressionFormat_BPTC;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_4x4_KHR:
|
case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
|
||||||
|
case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
|
||||||
|
m_Format = FasTC::eCompressionFormat_PVRTC4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
||||||
|
m_Format = FasTC::eCompressionFormat_DXT1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||||
|
m_Format = FasTC::eCompressionFormat_DXT5;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_COMPRESSED_RGBA_ASTC_4x4_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC4x4;
|
m_Format = FasTC::eCompressionFormat_ASTC4x4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_5x4_KHR:
|
case GL_COMPRESSED_RGBA_ASTC_5x4_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC5x4;
|
m_Format = FasTC::eCompressionFormat_ASTC5x4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_5x5_KHR:
|
case GL_COMPRESSED_RGBA_ASTC_5x5_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC5x5;
|
m_Format = FasTC::eCompressionFormat_ASTC5x5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_6x5_KHR:
|
case GL_COMPRESSED_RGBA_ASTC_6x5_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC6x5;
|
m_Format = FasTC::eCompressionFormat_ASTC6x5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_6x6_KHR:
|
case GL_COMPRESSED_RGBA_ASTC_6x6_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC6x6;
|
m_Format = FasTC::eCompressionFormat_ASTC6x6;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_8x5_KHR:
|
case GL_COMPRESSED_RGBA_ASTC_8x5_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC8x5;
|
m_Format = FasTC::eCompressionFormat_ASTC8x5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_8x6_KHR:
|
case GL_COMPRESSED_RGBA_ASTC_8x6_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC8x6;
|
m_Format = FasTC::eCompressionFormat_ASTC8x6;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_8x8_KHR:
|
case GL_COMPRESSED_RGBA_ASTC_8x8_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC8x8;
|
m_Format = FasTC::eCompressionFormat_ASTC8x8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_10x5_KHR:
|
case GL_COMPRESSED_RGBA_ASTC_10x5_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC10x5;
|
m_Format = FasTC::eCompressionFormat_ASTC10x5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_10x6_KHR:
|
case GL_COMPRESSED_RGBA_ASTC_10x6_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC10x6;
|
m_Format = FasTC::eCompressionFormat_ASTC10x6;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_10x8_KHR:
|
case GL_COMPRESSED_RGBA_ASTC_10x8_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC10x8;
|
m_Format = FasTC::eCompressionFormat_ASTC10x8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_10x10_KHR:
|
case GL_COMPRESSED_RGBA_ASTC_10x10_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC10x10;
|
m_Format = FasTC::eCompressionFormat_ASTC10x10;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_12x10_KHR:
|
case GL_COMPRESSED_RGBA_ASTC_12x10_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC12x10;
|
m_Format = FasTC::eCompressionFormat_ASTC12x10;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPRESSED_RGBA_ASTC_12x12_KHR:
|
case GL_COMPRESSED_RGBA_ASTC_12x12_KHR:
|
||||||
m_Format = FasTC::eCompressionFormat_ASTC12x12;
|
m_Format = FasTC::eCompressionFormat_ASTC12x12;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,17 @@ bool ImageWriterKTX::WriteImage() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FasTC::eCompressionFormat_PVRTC4:
|
case FasTC::eCompressionFormat_PVRTC4:
|
||||||
wtr.Write(COMPRESSED_RGBA_PVRTC_4BPPV1_IMG); // glInternalFormat
|
wtr.Write(GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG); // glInternalFormat
|
||||||
|
wtr.Write(GL_RGBA); // glBaseFormat
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FasTC::eCompressionFormat_DXT1:
|
||||||
|
wtr.Write(GL_COMPRESSED_RGB_S3TC_DXT1_EXT); // glInternalFormat
|
||||||
|
wtr.Write(GL_RGB); // glBaseFormat
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FasTC::eCompressionFormat_DXT5:
|
||||||
|
wtr.Write(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT); // glInternalFormat
|
||||||
wtr.Write(GL_RGBA); // glBaseFormat
|
wtr.Write(GL_RGBA); // glBaseFormat
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -127,11 +137,15 @@ bool ImageWriterKTX::WriteImage() {
|
||||||
wtr.Write(orientationValue, oValLen + 1); // value
|
wtr.Write(orientationValue, oValLen + 1); // value
|
||||||
wtr.Write(orientationKey, tkvSz - kvSz - 4); // padding
|
wtr.Write(orientationKey, tkvSz - kvSz - 4); // padding
|
||||||
|
|
||||||
if(ci && ci->GetFormat() == FasTC::eCompressionFormat_BPTC) {
|
if(ci &&
|
||||||
|
(ci->GetFormat() == FasTC::eCompressionFormat_BPTC ||
|
||||||
|
ci->GetFormat() == FasTC::eCompressionFormat_DXT5)) {
|
||||||
static const uint32 kImageSize = m_Width * m_Height;
|
static const uint32 kImageSize = m_Width * m_Height;
|
||||||
wtr.Write(kImageSize); // imageSize
|
wtr.Write(kImageSize); // imageSize
|
||||||
wtr.Write(ci->GetCompressedData(), kImageSize); // imagedata...
|
wtr.Write(ci->GetCompressedData(), kImageSize); // imagedata...
|
||||||
} else if(ci && ci->GetFormat() == FasTC::eCompressionFormat_PVRTC4) {
|
} else if(ci &&
|
||||||
|
(ci->GetFormat() == FasTC::eCompressionFormat_PVRTC4 ||
|
||||||
|
ci->GetFormat() == FasTC::eCompressionFormat_DXT1)) {
|
||||||
static const uint32 kImageSize = m_Width * m_Height >> 1;
|
static const uint32 kImageSize = m_Width * m_Height >> 1;
|
||||||
wtr.Write(kImageSize); // imageSize
|
wtr.Write(kImageSize); // imageSize
|
||||||
wtr.Write(ci->GetCompressedData(), kImageSize); // imagedata...
|
wtr.Write(ci->GetCompressedData(), kImageSize); // imagedata...
|
||||||
|
|
Loading…
Reference in a new issue