From Likasz Izebski, "added support for etc2/eac compression"
This commit is contained in:
parent
ac383e15c1
commit
ff8fe4143e
@ -97,6 +97,19 @@
|
||||
#define GL_ETC1_RGB8_OES 0x8D64
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_ES3_compatibility
|
||||
#define GL_COMPRESSED_RGB8_ETC2 0x9274
|
||||
#define GL_COMPRESSED_SRGB8_ETC2 0x9275
|
||||
#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
|
||||
#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
|
||||
#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
|
||||
#define GL_COMPRESSED_R11_EAC 0x9270
|
||||
#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
|
||||
#define GL_COMPRESSED_RG11_EAC 0x9272
|
||||
#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
|
||||
#endif
|
||||
|
||||
#ifndef GL_DEPTH_COMPONENT
|
||||
#define GL_DEPTH_COMPONENT 0x1902
|
||||
#endif
|
||||
|
@ -553,6 +553,7 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
USE_PVRTC_2BPP_COMPRESSION,
|
||||
USE_PVRTC_4BPP_COMPRESSION,
|
||||
USE_ETC_COMPRESSION,
|
||||
USE_ETC2_COMPRESSION,
|
||||
USE_RGTC1_COMPRESSION,
|
||||
USE_RGTC2_COMPRESSION,
|
||||
USE_S3TC_DXT1c_COMPRESSION,
|
||||
@ -794,6 +795,9 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
void setTextureCompressionETCSupported(bool flag) { _isTextureCompressionETCSupported=flag; }
|
||||
bool isTextureCompressionETCSupported() const { return _isTextureCompressionETCSupported; }
|
||||
|
||||
void setTextureCompressionETC2Supported(bool flag) { _isTextureCompressionETC2Supported=flag; }
|
||||
bool isTextureCompressionETC2Supported() const { return _isTextureCompressionETC2Supported; }
|
||||
|
||||
void setTextureCompressionRGTCSupported(bool flag) { _isTextureCompressionRGTCSupported=flag; }
|
||||
bool isTextureCompressionRGTCSupported() const { return _isTextureCompressionRGTCSupported; }
|
||||
|
||||
@ -916,6 +920,7 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
bool _isTextureCompressionPVRTC2BPPSupported;
|
||||
bool _isTextureCompressionPVRTC4BPPSupported;
|
||||
bool _isTextureCompressionETCSupported;
|
||||
bool _isTextureCompressionETC2Supported;
|
||||
bool _isTextureCompressionRGTCSupported;
|
||||
bool _isTextureCompressionPVRTCSupported;
|
||||
bool _isTextureMirroredRepeatSupported;
|
||||
|
@ -495,6 +495,16 @@ unsigned int Image::computeNumComponents(GLenum pixelFormat)
|
||||
case(GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG): return 4;
|
||||
case(GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG): return 4;
|
||||
case(GL_ETC1_RGB8_OES): return 3;
|
||||
case(GL_COMPRESSED_RGB8_ETC2): return 3;
|
||||
case(GL_COMPRESSED_SRGB8_ETC2): return 3;
|
||||
case(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2): return 4;
|
||||
case(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2): return 4;
|
||||
case(GL_COMPRESSED_RGBA8_ETC2_EAC): return 4;
|
||||
case(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC): return 4;
|
||||
case(GL_COMPRESSED_R11_EAC): return 1;
|
||||
case(GL_COMPRESSED_SIGNED_R11_EAC): return 1;
|
||||
case(GL_COMPRESSED_RG11_EAC): return 2;
|
||||
case(GL_COMPRESSED_SIGNED_RG11_EAC): return 2;
|
||||
case(GL_COLOR_INDEX): return 1;
|
||||
case(GL_STENCIL_INDEX): return 1;
|
||||
case(GL_DEPTH_COMPONENT): return 1;
|
||||
@ -613,6 +623,16 @@ unsigned int Image::computePixelSizeInBits(GLenum format,GLenum type)
|
||||
case(GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG): return 4;
|
||||
case(GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG): return 2;
|
||||
case(GL_ETC1_RGB8_OES): return 4;
|
||||
case(GL_COMPRESSED_RGB8_ETC2): return 4;
|
||||
case(GL_COMPRESSED_SRGB8_ETC2): return 4;
|
||||
case(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2): return 4;
|
||||
case(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2): return 4;
|
||||
case(GL_COMPRESSED_RGBA8_ETC2_EAC): return 8;
|
||||
case(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC): return 8;
|
||||
case(GL_COMPRESSED_R11_EAC): return 4;
|
||||
case(GL_COMPRESSED_SIGNED_R11_EAC): return 4;
|
||||
case(GL_COMPRESSED_RG11_EAC): return 8;
|
||||
case(GL_COMPRESSED_SIGNED_RG11_EAC): return 8;
|
||||
default: break;
|
||||
}
|
||||
|
||||
@ -720,6 +740,20 @@ unsigned int Image::computeBlockSize(GLenum pixelFormat, GLenum packing)
|
||||
case(GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT):
|
||||
case(GL_COMPRESSED_RED_GREEN_RGTC2_EXT):
|
||||
return osg::maximum(16u,packing); // block size of 16
|
||||
|
||||
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_R11_EAC):
|
||||
case(GL_COMPRESSED_SIGNED_R11_EAC):
|
||||
return osg::maximum(8u,packing); // block size of 8
|
||||
|
||||
case(GL_COMPRESSED_RGBA8_ETC2_EAC):
|
||||
case(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC):
|
||||
case(GL_COMPRESSED_RG11_EAC):
|
||||
case(GL_COMPRESSED_SIGNED_RG11_EAC):
|
||||
return osg::maximum(16u,packing); // block size of 16
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -825,6 +859,16 @@ bool Image::isCompressed() const
|
||||
case(GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG):
|
||||
case(GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG):
|
||||
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):
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -1587,6 +1631,16 @@ bool Image::supportsTextureSubloading() const
|
||||
switch(_internalTextureFormat)
|
||||
{
|
||||
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):
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
|
@ -140,6 +140,17 @@ void Texture::TextureProfile::computeSize()
|
||||
case(GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG): numBitsPerTexel = 4; break;
|
||||
|
||||
case(GL_ETC1_RGB8_OES): numBitsPerTexel = 4; 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;
|
||||
}
|
||||
|
||||
_size = (unsigned int)(ceil(double(_width * _height * _depth * numBitsPerTexel)/8.0));
|
||||
@ -1412,6 +1423,24 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
|
||||
}
|
||||
break;
|
||||
|
||||
case(USE_ETC2_COMPRESSION):
|
||||
if (extensions->isTextureCompressionETC2Supported())
|
||||
{
|
||||
switch(image.getPixelFormat())
|
||||
{
|
||||
case(1):
|
||||
case(GL_RED): internalFormat = GL_COMPRESSED_R11_EAC; break;
|
||||
case(2):
|
||||
case(GL_RG): internalFormat = GL_COMPRESSED_RG11_EAC; break;
|
||||
case(3):
|
||||
case(GL_RGB): internalFormat = GL_COMPRESSED_RGB8_ETC2; break;
|
||||
case(4):
|
||||
case(GL_RGBA): internalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC; break;
|
||||
default: internalFormat = image.getInternalTextureFormat(); break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case(USE_RGTC1_COMPRESSION):
|
||||
if (extensions->isTextureCompressionRGTCSupported())
|
||||
{
|
||||
@ -1581,6 +1610,16 @@ bool Texture::isCompressedInternalFormat(GLint internalFormat)
|
||||
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):
|
||||
@ -1597,8 +1636,16 @@ void Texture::getCompressedSize(GLenum internalFormat, GLint width, GLint height
|
||||
blockSize = 8;
|
||||
else if (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT || internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)
|
||||
blockSize = 16;
|
||||
else if (internalFormat == GL_ETC1_RGB8_OES)
|
||||
else if (internalFormat == GL_COMPRESSED_RGB8_ETC2 || internalFormat == GL_COMPRESSED_SRGB8_ETC2)
|
||||
blockSize = 8;
|
||||
else if (internalFormat == GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 || internalFormat == GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2)
|
||||
blockSize = 8;
|
||||
else if (internalFormat == GL_COMPRESSED_RGBA8_ETC2_EAC || internalFormat == GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC)
|
||||
blockSize = 16;
|
||||
else if (internalFormat == GL_COMPRESSED_R11_EAC || internalFormat == GL_COMPRESSED_SIGNED_R11_EAC)
|
||||
blockSize = 8;
|
||||
else if (internalFormat == GL_COMPRESSED_RG11_EAC || internalFormat == GL_COMPRESSED_SIGNED_RG11_EAC)
|
||||
blockSize = 16;
|
||||
else if (internalFormat == GL_COMPRESSED_RED_RGTC1_EXT || internalFormat == GL_COMPRESSED_SIGNED_RED_RGTC1_EXT)
|
||||
blockSize = 8;
|
||||
else if (internalFormat == GL_COMPRESSED_RED_GREEN_RGTC2_EXT || internalFormat == GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT)
|
||||
@ -1878,21 +1925,31 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
|
||||
case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
|
||||
case GL_ETC1_RGB8_OES:
|
||||
case(GL_COMPRESSED_RGB8_ETC2):
|
||||
case(GL_COMPRESSED_SRGB8_ETC2):
|
||||
case GL_COMPRESSED_RGB: _internalFormat = GL_RGB; break;
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||
case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
|
||||
case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
|
||||
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_RGBA: _internalFormat = GL_RGBA; break;
|
||||
case GL_COMPRESSED_ALPHA: _internalFormat = GL_ALPHA; break;
|
||||
case GL_COMPRESSED_LUMINANCE: _internalFormat = GL_LUMINANCE; break;
|
||||
case GL_COMPRESSED_LUMINANCE_ALPHA: _internalFormat = GL_LUMINANCE_ALPHA; break;
|
||||
case GL_COMPRESSED_INTENSITY: _internalFormat = GL_INTENSITY; break;
|
||||
case(GL_COMPRESSED_R11_EAC):
|
||||
case(GL_COMPRESSED_SIGNED_R11_EAC):
|
||||
case GL_COMPRESSED_SIGNED_RED_RGTC1_EXT:
|
||||
case GL_COMPRESSED_RED_RGTC1_EXT: _internalFormat = GL_RED; break;
|
||||
case(GL_COMPRESSED_RG11_EAC):
|
||||
case(GL_COMPRESSED_SIGNED_RG11_EAC):
|
||||
case GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:
|
||||
case GL_COMPRESSED_RED_GREEN_RGTC2_EXT: _internalFormat = GL_LUMINANCE_ALPHA; break;
|
||||
case GL_COMPRESSED_RED_GREEN_RGTC2_EXT: _internalFormat = GL_RG; break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2545,6 +2602,7 @@ Texture::Extensions::Extensions(unsigned int contextID)
|
||||
|
||||
_isTextureCompressionETCSupported = isGLExtensionSupported(contextID,"GL_OES_compressed_ETC1_RGB8_texture");
|
||||
|
||||
_isTextureCompressionETC2Supported = isGLExtensionSupported(contextID,"GL_ARB_ES3_compatibility");
|
||||
|
||||
_isTextureCompressionRGTCSupported = isGLExtensionSupported(contextID,"GL_EXT_texture_compression_rgtc");
|
||||
|
||||
|
@ -491,6 +491,16 @@ ObjectWrapperManager::ObjectWrapperManager()
|
||||
glTable.add( "GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG );
|
||||
glTable.add( "GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG );
|
||||
glTable.add( "GL_ETC1_RGB8_OES",GL_ETC1_RGB8_OES );
|
||||
glTable.add( "GL_COMPRESSED_RGB8_ETC2",GL_COMPRESSED_RGB8_ETC2 );
|
||||
glTable.add( "GL_COMPRESSED_SRGB8_ETC2",GL_COMPRESSED_SRGB8_ETC2 );
|
||||
glTable.add( "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 );
|
||||
glTable.add( "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 );
|
||||
glTable.add( "GL_COMPRESSED_RGBA8_ETC2_EAC",GL_COMPRESSED_RGBA8_ETC2_EAC );
|
||||
glTable.add( "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC );
|
||||
glTable.add( "GL_COMPRESSED_R11_EAC",GL_COMPRESSED_R11_EAC );
|
||||
glTable.add( "GL_COMPRESSED_SIGNED_R11_EAC",GL_COMPRESSED_SIGNED_R11_EAC );
|
||||
glTable.add( "GL_COMPRESSED_RG11_EAC",GL_COMPRESSED_RG11_EAC );
|
||||
glTable.add( "GL_COMPRESSED_SIGNED_RG11_EAC",GL_COMPRESSED_SIGNED_RG11_EAC );
|
||||
|
||||
// Texture source types
|
||||
glTable.add( "GL_BYTE", GL_BYTE );
|
||||
|
Loading…
Reference in New Issue
Block a user