ASTC Texture compression support added

This commit is contained in:
valid-ptr 2020-12-04 18:24:36 +03:00 committed by konstantin.matveyev
parent 6cd699e55f
commit b4eb001d14

View File

@ -200,6 +200,36 @@ InternalPixelRelations compressedInternalFormats[] = {
, { GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT , GL_RGBA , GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT }
, { GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT , GL_RGBA , GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT }
, { GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT , GL_RGBA , GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT }
, { GL_COMPRESSED_RGBA_ASTC_4x4_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_4x4_KHR }
, { GL_COMPRESSED_RGBA_ASTC_5x4_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_5x4_KHR }
, { GL_COMPRESSED_RGBA_ASTC_5x5_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_5x5_KHR }
, { GL_COMPRESSED_RGBA_ASTC_6x5_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_6x5_KHR }
, { GL_COMPRESSED_RGBA_ASTC_6x6_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_6x6_KHR }
, { GL_COMPRESSED_RGBA_ASTC_8x5_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_8x5_KHR }
, { GL_COMPRESSED_RGBA_ASTC_8x6_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_8x6_KHR }
, { GL_COMPRESSED_RGBA_ASTC_8x8_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_8x8_KHR }
, { GL_COMPRESSED_RGBA_ASTC_10x5_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_10x5_KHR }
, { GL_COMPRESSED_RGBA_ASTC_10x6_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_10x6_KHR }
, { GL_COMPRESSED_RGBA_ASTC_10x8_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_10x8_KHR }
, { GL_COMPRESSED_RGBA_ASTC_10x10_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_10x10_KHR }
, { GL_COMPRESSED_RGBA_ASTC_12x10_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_12x10_KHR }
, { GL_COMPRESSED_RGBA_ASTC_12x12_KHR , GL_RGBA , GL_COMPRESSED_RGBA_ASTC_12x12_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR }
, { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR , GL_RGBA , GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR }
};
bool isSizedInternalFormat(GLint internalFormat)
@ -285,61 +315,102 @@ void Texture::TextureObject::setAllocated(GLint numMipmapLevels,
void Texture::TextureProfile::computeSize()
{
unsigned int numBitsPerTexel = 32;
double numBitsPerTexel = 32.0;
switch(_internalFormat)
{
case(1): numBitsPerTexel = 8; break;
case(GL_ALPHA): numBitsPerTexel = 8; break;
case(GL_LUMINANCE): numBitsPerTexel = 8; break;
case(GL_INTENSITY): numBitsPerTexel = 8; break;
case 1:
case GL_ALPHA:
case GL_LUMINANCE:
case GL_INTENSITY:
case GL_RED:
numBitsPerTexel = 8.0;
break;
case(GL_LUMINANCE_ALPHA): numBitsPerTexel = 16; break;
case(2): numBitsPerTexel = 16; break;
case 2:
case GL_LUMINANCE_ALPHA:
case GL_RG:
numBitsPerTexel = 16.0;
break;
case(GL_RGB): numBitsPerTexel = 24; break;
case(GL_BGR): numBitsPerTexel = 24; break;
case(3): numBitsPerTexel = 24; break;
case 3:
case GL_RGB:
case GL_BGR:
numBitsPerTexel = 24.0;
break;
case(GL_RGBA): numBitsPerTexel = 32; break;
case(4): numBitsPerTexel = 32; break;
case 4:
case GL_RGBA:
case GL_BGRA:
numBitsPerTexel = 32.0;
break;
case(GL_COMPRESSED_ALPHA_ARB): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_INTENSITY_ARB): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_LUMINANCE_ALPHA_ARB): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_SRGB_S3TC_DXT1_EXT): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT): numBitsPerTexel = 4; break;
case GL_COMPRESSED_ALPHA_ARB: numBitsPerTexel = 4.0; break;
case GL_COMPRESSED_INTENSITY_ARB: numBitsPerTexel = 4.0; break;
case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: numBitsPerTexel = 4.0; break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: numBitsPerTexel = 4.0; break;
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: numBitsPerTexel = 4.0; break;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: numBitsPerTexel = 4.0; break;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: numBitsPerTexel = 4.0; break;
case(GL_COMPRESSED_RGB_ARB): numBitsPerTexel = 8; break;
case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT): numBitsPerTexel = 8; break;
case(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT): numBitsPerTexel = 8; break;
case(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT): numBitsPerTexel = 8; break;
case(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT): numBitsPerTexel = 8; break;
case GL_COMPRESSED_RGB_ARB: numBitsPerTexel = 8.0; break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: numBitsPerTexel = 8.0; break;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: numBitsPerTexel = 8.0; break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: numBitsPerTexel = 8.0; break;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: numBitsPerTexel = 8.0; break;
case(GL_COMPRESSED_SIGNED_RED_RGTC1_EXT): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_RED_RGTC1_EXT): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT): numBitsPerTexel = 8; break;
case(GL_COMPRESSED_RED_GREEN_RGTC2_EXT): numBitsPerTexel = 8; break;
case GL_COMPRESSED_SIGNED_RED_RGTC1_EXT: numBitsPerTexel = 4.0; break;
case GL_COMPRESSED_RED_RGTC1_EXT: numBitsPerTexel = 4.0; break;
case GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: numBitsPerTexel = 8.0; break;
case GL_COMPRESSED_RED_GREEN_RGTC2_EXT: numBitsPerTexel = 8.0; break;
case(GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG): numBitsPerTexel = 2; break;
case(GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG): numBitsPerTexel = 2; break;
case(GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG): numBitsPerTexel = 4; break;
case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: numBitsPerTexel = 2.0; break;
case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: numBitsPerTexel = 2.0; break;
case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: numBitsPerTexel = 4.0; break;
case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: numBitsPerTexel = 4.0; break;
case(GL_ETC1_RGB8_OES): numBitsPerTexel = 4; break;
case GL_ETC1_RGB8_OES: numBitsPerTexel = 4.0; break;
case(GL_COMPRESSED_RGB8_ETC2): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_SRGB8_ETC2): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2): numBitsPerTexel = 8; break;
case(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2): numBitsPerTexel = 8; break;
case(GL_COMPRESSED_RGBA8_ETC2_EAC): numBitsPerTexel = 8; break;
case(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC): numBitsPerTexel = 8; break;
case(GL_COMPRESSED_R11_EAC): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_SIGNED_R11_EAC): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_RG11_EAC): numBitsPerTexel = 8; break;
case(GL_COMPRESSED_SIGNED_RG11_EAC): numBitsPerTexel = 8; break;
case GL_COMPRESSED_RGB8_ETC2: numBitsPerTexel = 4.0; break;
case GL_COMPRESSED_SRGB8_ETC2: numBitsPerTexel = 4.0; break;
case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: numBitsPerTexel = 8.0; break;
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: numBitsPerTexel = 8.0; break;
case GL_COMPRESSED_RGBA8_ETC2_EAC: numBitsPerTexel = 8.0; break;
case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: numBitsPerTexel = 8.0; break;
case GL_COMPRESSED_R11_EAC: numBitsPerTexel = 4.0; break;
case GL_COMPRESSED_SIGNED_R11_EAC: numBitsPerTexel = 4.0; break;
case GL_COMPRESSED_RG11_EAC: numBitsPerTexel = 8.0; break;
case GL_COMPRESSED_SIGNED_RG11_EAC: numBitsPerTexel = 8.0; break;
// ASTC
case GL_COMPRESSED_RGBA_ASTC_4x4_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: numBitsPerTexel = 8.0; break;
case GL_COMPRESSED_RGBA_ASTC_5x4_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: numBitsPerTexel = 6.4; break;
case GL_COMPRESSED_RGBA_ASTC_5x5_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: numBitsPerTexel = 5.12; break;
case GL_COMPRESSED_RGBA_ASTC_6x5_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: numBitsPerTexel = 4.27; break;
case GL_COMPRESSED_RGBA_ASTC_6x6_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: numBitsPerTexel = 3.56; break;
case GL_COMPRESSED_RGBA_ASTC_8x5_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: numBitsPerTexel = 3.2; break;
case GL_COMPRESSED_RGBA_ASTC_8x6_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: numBitsPerTexel = 2.67; break;
case GL_COMPRESSED_RGBA_ASTC_8x8_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: numBitsPerTexel = 2.0; break;
case GL_COMPRESSED_RGBA_ASTC_10x5_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: numBitsPerTexel = 2.56; break;
case GL_COMPRESSED_RGBA_ASTC_10x6_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: numBitsPerTexel = 2.13; break;
case GL_COMPRESSED_RGBA_ASTC_10x8_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: numBitsPerTexel = 1.6; break;
case GL_COMPRESSED_RGBA_ASTC_10x10_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: numBitsPerTexel = 1.28; break;
case GL_COMPRESSED_RGBA_ASTC_12x10_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: numBitsPerTexel = 1.07; break;
case GL_COMPRESSED_RGBA_ASTC_12x12_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: numBitsPerTexel = 0.89; break;
}
_size = (unsigned int)(ceil(double(_width * _height * _depth * numBitsPerTexel)/8.0));
@ -1786,39 +1857,67 @@ bool Texture::isCompressedInternalFormat() const
bool Texture::isCompressedInternalFormat(GLint internalFormat)
{
switch(internalFormat)
switch (internalFormat)
{
case(GL_COMPRESSED_ALPHA_ARB):
case(GL_COMPRESSED_INTENSITY_ARB):
case(GL_COMPRESSED_LUMINANCE_ALPHA_ARB):
case(GL_COMPRESSED_LUMINANCE_ARB):
case(GL_COMPRESSED_RGBA_ARB):
case(GL_COMPRESSED_RGB_ARB):
case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT):
case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT):
case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT):
case(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT):
case(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT):
case(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT):
case(GL_COMPRESSED_SIGNED_RED_RGTC1_EXT):
case(GL_COMPRESSED_RED_RGTC1_EXT):
case(GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT):
case(GL_COMPRESSED_RED_GREEN_RGTC2_EXT):
case(GL_ETC1_RGB8_OES):
case(GL_COMPRESSED_RGB8_ETC2):
case(GL_COMPRESSED_SRGB8_ETC2):
case(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2):
case(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2):
case(GL_COMPRESSED_RGBA8_ETC2_EAC):
case(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC):
case(GL_COMPRESSED_R11_EAC):
case(GL_COMPRESSED_SIGNED_R11_EAC):
case(GL_COMPRESSED_RG11_EAC):
case(GL_COMPRESSED_SIGNED_RG11_EAC):
case(GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG):
case(GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG):
case(GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG):
case(GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG):
case (GL_COMPRESSED_ALPHA_ARB):
case (GL_COMPRESSED_INTENSITY_ARB):
case (GL_COMPRESSED_LUMINANCE_ALPHA_ARB):
case (GL_COMPRESSED_LUMINANCE_ARB):
case (GL_COMPRESSED_RGBA_ARB):
case (GL_COMPRESSED_RGB_ARB):
case (GL_COMPRESSED_RGB_S3TC_DXT1_EXT):
case (GL_COMPRESSED_RGBA_S3TC_DXT1_EXT):
case (GL_COMPRESSED_RGBA_S3TC_DXT3_EXT):
case (GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT):
case (GL_COMPRESSED_RGBA_S3TC_DXT5_EXT):
case (GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT):
case (GL_COMPRESSED_SIGNED_RED_RGTC1_EXT):
case (GL_COMPRESSED_RED_RGTC1_EXT):
case (GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT):
case (GL_COMPRESSED_RED_GREEN_RGTC2_EXT):
case (GL_ETC1_RGB8_OES):
case (GL_COMPRESSED_RGB8_ETC2):
case (GL_COMPRESSED_SRGB8_ETC2):
case (GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2):
case (GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2):
case (GL_COMPRESSED_RGBA8_ETC2_EAC):
case (GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC):
case (GL_COMPRESSED_R11_EAC):
case (GL_COMPRESSED_SIGNED_R11_EAC):
case (GL_COMPRESSED_RG11_EAC):
case (GL_COMPRESSED_SIGNED_RG11_EAC):
case (GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG):
case (GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG):
case (GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG):
case (GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG):
case (GL_COMPRESSED_RGBA_ASTC_4x4_KHR):
case (GL_COMPRESSED_RGBA_ASTC_5x4_KHR):
case (GL_COMPRESSED_RGBA_ASTC_5x5_KHR):
case (GL_COMPRESSED_RGBA_ASTC_6x5_KHR):
case (GL_COMPRESSED_RGBA_ASTC_6x6_KHR):
case (GL_COMPRESSED_RGBA_ASTC_8x5_KHR):
case (GL_COMPRESSED_RGBA_ASTC_8x6_KHR):
case (GL_COMPRESSED_RGBA_ASTC_8x8_KHR):
case (GL_COMPRESSED_RGBA_ASTC_10x5_KHR):
case (GL_COMPRESSED_RGBA_ASTC_10x6_KHR):
case (GL_COMPRESSED_RGBA_ASTC_10x8_KHR):
case (GL_COMPRESSED_RGBA_ASTC_10x10_KHR):
case (GL_COMPRESSED_RGBA_ASTC_12x10_KHR):
case (GL_COMPRESSED_RGBA_ASTC_12x12_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR):
case (GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR):
return true;
default:
return false;
@ -1879,6 +1978,91 @@ void Texture::getCompressedSize(GLenum internalFormat, GLint width, GLint height
size = widthBlocks * heightBlocks * ((blockSize * bpp) / 8);
return;
}
// ASTC compression (block size is always equal to 16)
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_4x4_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR)
{
blockSize = 16;
size = ceil(width/4.0)*ceil(height/4.0)*blockSize;
return;
}
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_5x4_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR)
{
blockSize = 16;
size = ceil(width/5.0)*ceil(height/4.0)*blockSize;
return;
}
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_5x5_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR)
{
blockSize = 16;
size = ceil(width/5.0)*ceil(height/5.0)*blockSize;
return;
}
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_6x5_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR)
{
blockSize = 16;
size = ceil(width/6.0)*ceil(height/5.0)*blockSize;
return;
}
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_6x6_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR)
{
blockSize = 16;
size = ceil(width/6.0)*ceil(height/6.0)*blockSize;
return;
}
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_8x5_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR)
{
blockSize = 16;
size = ceil(width/8.0)*ceil(height/5.0)*blockSize;
return;
}
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_8x6_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR)
{
blockSize = 16;
size = ceil(width/8.0)*ceil(height/6.0)*blockSize;
return;
}
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_8x8_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR)
{
blockSize = 16;
size = ceil(width/8.0)*ceil(height/8.0)*blockSize;
return;
}
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_10x5_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR)
{
blockSize = 16;
size = ceil(width/10.0)*ceil(height/5.0)*blockSize;
return;
}
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_10x6_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR)
{
blockSize = 16;
size = ceil(width/10.0)*ceil(height/6.0)*blockSize;
return;
}
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_10x8_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR)
{
blockSize = 16;
size = ceil(width/10.0)*ceil(height/8.0)*blockSize;
return;
}
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_10x10_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR)
{
blockSize = 16;
size = ceil(width/10.0)*ceil(height/10.0)*blockSize;
return;
}
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_12x10_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR)
{
blockSize = 16;
size = ceil(width/12.0)*ceil(height/10.0)*blockSize;
return;
}
else if (internalFormat == GL_COMPRESSED_RGBA_ASTC_12x12_KHR || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR)
{
blockSize = 16;
size = ceil(width/12.0)*ceil(height/12.0)*blockSize;
return;
}
else
{
OSG_WARN<<"Texture::getCompressedSize(...) : cannot compute correct size of compressed format ("<<internalFormat<<") returning 0."<<std::endl;