Manually merged "ASTC Compression Support Added; GLExtensions improvements" from 3.6 into master

This commit is contained in:
Robert Osfield 2021-03-29 11:21:37 +01:00
parent 3141cea7c1
commit 60f0dd7d14
3 changed files with 349 additions and 134 deletions

View File

@ -549,6 +549,7 @@ class OSG_EXPORT GLExtensions : public osg::Referenced
bool isTextureCompressionETC2Supported; bool isTextureCompressionETC2Supported;
bool isTextureCompressionRGTCSupported; bool isTextureCompressionRGTCSupported;
bool isTextureCompressionPVRTCSupported; bool isTextureCompressionPVRTCSupported;
bool isTextureCompressionASTCSupported;
bool isTextureMirroredRepeatSupported; bool isTextureMirroredRepeatSupported;
bool isTextureEdgeClampSupported; bool isTextureEdgeClampSupported;
bool isTextureBorderClampSupported; bool isTextureBorderClampSupported;
@ -558,6 +559,7 @@ class OSG_EXPORT GLExtensions : public osg::Referenced
bool isShadowSupported; bool isShadowSupported;
bool isShadowAmbientSupported; bool isShadowAmbientSupported;
bool isTextureMaxLevelSupported; bool isTextureMaxLevelSupported;
bool isTextureLODBiasSupported;
GLint maxTextureSize; GLint maxTextureSize;
bool isClientStorageSupported; bool isClientStorageSupported;
bool isTextureIntegerEXTSupported; bool isTextureIntegerEXTSupported;

View File

@ -755,7 +755,7 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
isOcclusionQuerySupported = validContext && osg::isGLExtensionSupported(contextID, "GL_NV_occlusion_query"); isOcclusionQuerySupported = validContext && osg::isGLExtensionSupported(contextID, "GL_NV_occlusion_query");
isARBOcclusionQuerySupported = validContext && (OSG_GL3_FEATURES || osg::isGLExtensionSupported(contextID, "GL_ARB_occlusion_query")); isARBOcclusionQuerySupported = validContext && (OSG_GL3_FEATURES || osg::isGLExtensionSupported(contextID, "GL_ARB_occlusion_query"));
isTimerQuerySupported = validContext && osg::isGLExtensionSupported(contextID, "GL_EXT_timer_query"); isTimerQuerySupported = validContext && (osg::isGLExtensionSupported(contextID, "GL_EXT_timer_query") || osg::isGLExtensionSupported(contextID, "GL_EXT_disjoint_timer_query"));
isARBTimerQuerySupported = validContext && osg::isGLExtensionSupported(contextID, "GL_ARB_timer_query"); isARBTimerQuerySupported = validContext && osg::isGLExtensionSupported(contextID, "GL_ARB_timer_query");
@ -790,19 +790,19 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
setGLExtensionFuncPtr(glGetOcclusionQueryiv, "glGetOcclusionQueryiv","glGetOcclusionQueryivNV", validContext); setGLExtensionFuncPtr(glGetOcclusionQueryiv, "glGetOcclusionQueryiv","glGetOcclusionQueryivNV", validContext);
setGLExtensionFuncPtr(glGetOcclusionQueryuiv, "glGetOcclusionQueryuiv","glGetOcclusionQueryuivNV", validContext); setGLExtensionFuncPtr(glGetOcclusionQueryuiv, "glGetOcclusionQueryuiv","glGetOcclusionQueryuivNV", validContext);
setGLExtensionFuncPtr(glGenQueries, "glGenQueries", "glGenQueriesARB", validContext); setGLExtensionFuncPtr(glGenQueries, "glGenQueries", "glGenQueriesARB", "glGenQueriesEXT", validContext);
setGLExtensionFuncPtr(glDeleteQueries, "glDeleteQueries", "glDeleteQueriesARB", validContext); setGLExtensionFuncPtr(glDeleteQueries, "glDeleteQueries", "glDeleteQueriesARB", "glDeleteQueriesEXT", validContext);
setGLExtensionFuncPtr(glIsQuery, "glIsQuery", "glIsQueryARB", validContext); setGLExtensionFuncPtr(glIsQuery, "glIsQuery", "glIsQueryARB", "glIsQueryEXT", validContext);
setGLExtensionFuncPtr(glBeginQuery, "glBeginQuery", "glBeginQueryARB", validContext); setGLExtensionFuncPtr(glBeginQuery, "glBeginQuery", "glBeginQueryARB", "glBeginQueryEXT", validContext);
setGLExtensionFuncPtr(glEndQuery, "glEndQuery", "glEndQueryARB", validContext); setGLExtensionFuncPtr(glEndQuery, "glEndQuery", "glEndQueryARB", "glEndQueryEXT", validContext);
setGLExtensionFuncPtr(glBeginQueryIndexed, "glBeginQueryIndexed", "glBeginQueryIndexedARB", validContext); setGLExtensionFuncPtr(glBeginQueryIndexed, "glBeginQueryIndexed", "glBeginQueryIndexedARB", validContext);
setGLExtensionFuncPtr(glEndQueryIndexed, "glEndQueryIndexed", "glEndQueryIndexedARB", validContext); setGLExtensionFuncPtr(glEndQueryIndexed, "glEndQueryIndexed", "glEndQueryIndexedARB", validContext);
setGLExtensionFuncPtr(glGetQueryiv, "glGetQueryiv", "glGetQueryivARB", validContext); setGLExtensionFuncPtr(glGetQueryiv, "glGetQueryiv", "glGetQueryivARB", "glGetQueryivEXT", validContext);
setGLExtensionFuncPtr(glGetQueryObjectiv, "glGetQueryObjectiv","glGetQueryObjectivARB", validContext); setGLExtensionFuncPtr(glGetQueryObjectiv, "glGetQueryObjectiv","glGetQueryObjectivARB", "glGetQueryObjectivEXT", validContext);
setGLExtensionFuncPtr(glGetQueryObjectuiv, "glGetQueryObjectuiv","glGetQueryObjectuivARB", validContext); setGLExtensionFuncPtr(glGetQueryObjectuiv, "glGetQueryObjectuiv","glGetQueryObjectuivARB", "glGetQueryObjectuivEXT", validContext);
setGLExtensionFuncPtr(glGetQueryObjectui64v, "glGetQueryObjectui64v","glGetQueryObjectui64vEXT", validContext); setGLExtensionFuncPtr(glGetQueryObjectui64v, "glGetQueryObjectui64v","glGetQueryObjectui64vEXT", "glGetQueryObjectui64vEXT", validContext);
setGLExtensionFuncPtr(glQueryCounter, "glQueryCounter", validContext); setGLExtensionFuncPtr(glQueryCounter, "glQueryCounter", "glQueryCounterEXT", validContext);
setGLExtensionFuncPtr(glGetInteger64v, "glGetInteger64v", validContext); setGLExtensionFuncPtr(glGetInteger64v, "glGetInteger64v", "glGetInteger64vEXT", validContext);
// SampleMaski functionality // SampleMaski functionality
@ -859,13 +859,26 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
isTextureFilterAnisotropicSupported = validContext && isGLExtensionSupported(contextID,"GL_EXT_texture_filter_anisotropic"); isTextureFilterAnisotropicSupported = validContext && isGLExtensionSupported(contextID,"GL_EXT_texture_filter_anisotropic");
isTextureSwizzleSupported = validContext && isGLExtensionSupported(contextID,"GL_ARB_texture_swizzle"); isTextureSwizzleSupported = validContext && isGLExtensionSupported(contextID,"GL_ARB_texture_swizzle");
isTextureCompressionARBSupported = validContext && (builtInSupport || isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_compression", 1.3f)); isTextureCompressionARBSupported = validContext && (builtInSupport || isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_compression", 1.3f));
isTextureCompressionS3TCSupported = validContext && (isGLExtensionSupported(contextID,"GL_EXT_texture_compression_s3tc") || isGLExtensionSupported(contextID, "GL_S3_s3tc")); isTextureCompressionS3TCSupported = validContext && (isGLExtensionSupported(contextID,"GL_EXT_texture_compression_s3tc") ||
isTextureCompressionPVRTC2BPPSupported = validContext && isGLExtensionSupported(contextID,"GL_IMG_texture_compression_pvrtc"); isGLExtensionSupported(contextID, "GL_S3_s3tc") ||
isGLExtensionSupported(contextID, "WEBGL_compressed_texture_s3tc") ||
isGLExtensionSupported(contextID, "MOZ_WEBGL_compressed_texture_s3tc") ||
isGLExtensionSupported(contextID, "WEBKIT_WEBGL_compressed_texture_s3tc") ||
isGLExtensionSupported(contextID, "WEBGL_compressed_texture_s3tc_srgb") /* TODO: separate flag */);
isTextureCompressionPVRTC2BPPSupported = validContext && (isGLExtensionSupported(contextID,"GL_IMG_texture_compression_pvrtc") ||
isGLExtensionSupported(contextID, "WEBGL_compressed_texture_pvrtc"));
isTextureCompressionPVRTC4BPPSupported = isTextureCompressionPVRTC2BPPSupported;//covered by same extension isTextureCompressionPVRTC4BPPSupported = isTextureCompressionPVRTC2BPPSupported;//covered by same extension
isTextureCompressionETCSupported = validContext && isGLExtensionSupported(contextID,"GL_OES_compressed_ETC1_RGB8_texture"); isTextureCompressionETCSupported = validContext && (isGLExtensionSupported(contextID, "GL_OES_compressed_ETC1_RGB8_texture") ||
isTextureCompressionETC2Supported = validContext && isGLExtensionSupported(contextID,"GL_ARB_ES3_compatibility"); isGLExtensionSupported(contextID, "WEBGL_compressed_texture_etc1"));
isTextureCompressionETC2Supported = validContext && (isGLExtensionSupported(contextID,"GL_ARB_ES3_compatibility") ||
isGLExtensionSupported(contextID, "WEBGL_compressed_texture_etc"));
isTextureCompressionRGTCSupported = validContext && isGLExtensionSupported(contextID,"GL_EXT_texture_compression_rgtc"); isTextureCompressionRGTCSupported = validContext && isGLExtensionSupported(contextID,"GL_EXT_texture_compression_rgtc");
isTextureCompressionPVRTCSupported = validContext && isGLExtensionSupported(contextID,"GL_IMG_texture_compression_pvrtc"); isTextureCompressionPVRTCSupported = isTextureCompressionPVRTC2BPPSupported;//covered by same extension
isTextureCompressionASTCSupported = validContext && (isGLExtensionSupported(contextID, "GL_KHR_texture_compression_astc_hdr") ||
isGLExtensionSupported(contextID, "GL_KHR_texture_compression_astc_ldr") ||
isGLExtensionSupported(contextID, "GL_OES_texture_compression_astc") ||
isGLExtensionSupported(contextID, "WEBGL_compressed_texture_astc"));
isTextureMirroredRepeatSupported = validContext && isTextureMirroredRepeatSupported = validContext &&
(builtInSupport || (builtInSupport ||
@ -907,18 +920,22 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
{ {
maxTextureSize = osg_max_size; maxTextureSize = osg_max_size;
} }
#if defined(__EMSCRIPTEN__)
isTextureMaxLevelSupported = (glVersion >= 3.0f); // WebGL 2.0 (OpenGL ES 3.0)
isTextureLODBiasSupported = (glVersion >= 3.0f) || isGLExtensionSupported(contextID, "GL_EXT_texture_lod_bias");
#else
isTextureMaxLevelSupported = (glVersion >= 1.2f); isTextureMaxLevelSupported = (glVersion >= 1.2f);
isTextureLODBiasSupported = (glVersion >= 1.2f) || isGLExtensionSupported(contextID, "GL_EXT_texture_lod_bias");
#endif
isTextureStorageEnabled = validContext && ((glVersion >= 4.2f) || isGLExtensionSupported(contextID, "GL_ARB_texture_storage")); isTextureStorageEnabled = validContext && ((glVersion >= 4.2f) || isGLExtensionSupported(contextID, "GL_ARB_texture_storage"));
if (isTextureStorageEnabled) if (isTextureStorageEnabled)
{ {
std::string value; std::string value;
if (getEnvVar("OSG_GL_TEXTURE_STORAGE", value)) if (getEnvVar("OSG_GL_TEXTURE_STORAGE", value) && (value == "OFF" || value == "DISABLE"))
{ isTextureStorageEnabled = false;
if (value=="OFF" || value=="DISABLE") isTextureStorageEnabled = false;
else isTextureStorageEnabled = true;
}
} }
setGLExtensionFuncPtr(glTexStorage1D,"glTexStorage1D","glTexStorage1DARB", validContext); setGLExtensionFuncPtr(glTexStorage1D,"glTexStorage1D","glTexStorage1DARB", validContext);

View File

@ -176,30 +176,60 @@ InternalPixelRelations sizedDepthAndStencilInternalFormats[] = {
}; };
InternalPixelRelations compressedInternalFormats[] = { InternalPixelRelations compressedInternalFormats[] = {
// , { GL_COMPRESSED_RED , GL_RED , GL_COMPRESSED_RED } // , { GL_COMPRESSED_RED , GL_RED , GL_COMPRESSED_RED }
// , { GL_COMPRESSED_RG , GL_RG , GL_COMPRESSED_RG } // , { GL_COMPRESSED_RG , GL_RG , GL_COMPRESSED_RG }
{ GL_COMPRESSED_RGB , GL_RGB , GL_COMPRESSED_RGB } { GL_COMPRESSED_RGB , GL_RGB , GL_COMPRESSED_RGB }
, { GL_COMPRESSED_RGBA , GL_RGBA , GL_COMPRESSED_RGBA } , { GL_COMPRESSED_RGBA , GL_RGBA , GL_COMPRESSED_RGBA }
, { GL_COMPRESSED_SRGB , GL_RGB , GL_COMPRESSED_SRGB } , { GL_COMPRESSED_SRGB , GL_RGB , GL_COMPRESSED_SRGB }
, { GL_COMPRESSED_SRGB_ALPHA , GL_RGBA , GL_COMPRESSED_SRGB_ALPHA } , { GL_COMPRESSED_SRGB_ALPHA , GL_RGBA , GL_COMPRESSED_SRGB_ALPHA }
, { GL_COMPRESSED_RED_RGTC1_EXT , GL_RED , GL_COMPRESSED_RED_RGTC1_EXT } , { GL_COMPRESSED_RED_RGTC1_EXT , GL_RED , GL_COMPRESSED_RED_RGTC1_EXT }
, { GL_COMPRESSED_SIGNED_RED_RGTC1_EXT , GL_RED , GL_COMPRESSED_SIGNED_RED_RGTC1_EXT } , { GL_COMPRESSED_SIGNED_RED_RGTC1_EXT , GL_RED , GL_COMPRESSED_SIGNED_RED_RGTC1_EXT }
// , { GL_COMPRESSED_RG_RGTC2 , GL_RG , GL_COMPRESSED_RG_RGTC2 } // , { GL_COMPRESSED_RG_RGTC2 , GL_RG , GL_COMPRESSED_RG_RGTC2 }
// , { GL_COMPRESSED_SIGNED_RG_RGTC2 , GL_RG , GL_COMPRESSED_SIGNED_RG_RGTC2 } // , { GL_COMPRESSED_SIGNED_RG_RGTC2 , GL_RG , GL_COMPRESSED_SIGNED_RG_RGTC2 }
// , { GL_COMPRESSED_RGBA_BPTC_UNORM , GL_RGBA , GL_COMPRESSED_RGBA_BPTC_UNORM } // , { GL_COMPRESSED_RGBA_BPTC_UNORM , GL_RGBA , GL_COMPRESSED_RGBA_BPTC_UNORM }
// , { GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM , GL_RGBA , GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM } // , { GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM , GL_RGBA , GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM }
// , { GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT , GL_RGB , GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT } // , { GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT , GL_RGB , GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT }
// , { GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT , GL_RGB , GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT } // , { GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT , GL_RGB , GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT }
, { GL_COMPRESSED_RGB_S3TC_DXT1_EXT , GL_RGB , GL_COMPRESSED_RGB_S3TC_DXT1_EXT } , { GL_COMPRESSED_RGB_S3TC_DXT1_EXT , GL_RGB , GL_COMPRESSED_RGB_S3TC_DXT1_EXT }
, { GL_COMPRESSED_RGBA_S3TC_DXT1_EXT , GL_RGBA , GL_COMPRESSED_RGBA_S3TC_DXT1_EXT } , { GL_COMPRESSED_RGBA_S3TC_DXT1_EXT , GL_RGBA , GL_COMPRESSED_RGBA_S3TC_DXT1_EXT }
, { GL_COMPRESSED_RGBA_S3TC_DXT3_EXT , GL_RGBA , GL_COMPRESSED_RGBA_S3TC_DXT3_EXT } , { GL_COMPRESSED_RGBA_S3TC_DXT3_EXT , GL_RGBA , GL_COMPRESSED_RGBA_S3TC_DXT3_EXT }
, { GL_COMPRESSED_RGBA_S3TC_DXT5_EXT , GL_RGBA , GL_COMPRESSED_RGBA_S3TC_DXT5_EXT } , { GL_COMPRESSED_RGBA_S3TC_DXT5_EXT , GL_RGBA , GL_COMPRESSED_RGBA_S3TC_DXT5_EXT }
, { GL_COMPRESSED_SRGB_S3TC_DXT1_EXT , GL_RGB , GL_COMPRESSED_SRGB_S3TC_DXT1_EXT } , { GL_COMPRESSED_SRGB_S3TC_DXT1_EXT , GL_RGB , GL_COMPRESSED_SRGB_S3TC_DXT1_EXT }
, { GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT , GL_RGBA , GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT } , { 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_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_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) bool isSizedInternalFormat(GLint internalFormat)
@ -291,57 +321,109 @@ void Texture::TextureProfile::computeSize()
switch(_internalFormat) switch(_internalFormat)
{ {
case(1): numBitsPerTexel = 8; break; case 1:
case(GL_ALPHA): numBitsPerTexel = 8; break; case GL_ALPHA:
case(GL_LUMINANCE): numBitsPerTexel = 8; break; case GL_LUMINANCE:
case(GL_INTENSITY): numBitsPerTexel = 8; break; case GL_INTENSITY:
case GL_RED:
numBitsPerTexel = 8;
break;
case(GL_LUMINANCE_ALPHA): numBitsPerTexel = 16; break; case 2:
case(2): numBitsPerTexel = 16; break; case GL_LUMINANCE_ALPHA:
case GL_RG:
numBitsPerTexel = 16;
break;
case(GL_RGB): numBitsPerTexel = 24; break; case 3:
case(GL_BGR): numBitsPerTexel = 24; break; case GL_RGB:
case(3): numBitsPerTexel = 24; break; case GL_BGR:
numBitsPerTexel = 24;
break;
case(GL_RGBA): numBitsPerTexel = 32; break; case 4:
case(4): numBitsPerTexel = 32; break; case GL_RGBA:
case GL_BGRA:
numBitsPerTexel = 32;
break;
case(GL_COMPRESSED_ALPHA_ARB): numBitsPerTexel = 4; break; case GL_COMPRESSED_ALPHA_ARB: numBitsPerTexel = 4; break;
case(GL_COMPRESSED_INTENSITY_ARB): numBitsPerTexel = 4; break; case GL_COMPRESSED_INTENSITY_ARB: numBitsPerTexel = 4; break;
case(GL_COMPRESSED_LUMINANCE_ALPHA_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_RGB_S3TC_DXT1_EXT: numBitsPerTexel = 4; break;
case(GL_COMPRESSED_SRGB_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_RGBA_S3TC_DXT1_EXT: numBitsPerTexel = 4; break;
case(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT): numBitsPerTexel = 4; break; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: numBitsPerTexel = 4; 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_SIGNED_RED_RGTC1_EXT): numBitsPerTexel = 4; break; case GL_COMPRESSED_RGB_ARB: numBitsPerTexel = 8; break;
case(GL_COMPRESSED_RED_RGTC1_EXT): numBitsPerTexel = 4; break; case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: numBitsPerTexel = 8; break;
case(GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT): numBitsPerTexel = 8; break; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: numBitsPerTexel = 8; break;
case(GL_COMPRESSED_RED_GREEN_RGTC2_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_PVRTC_2BPPV1_IMG): numBitsPerTexel = 2; break; case GL_COMPRESSED_SIGNED_RED_RGTC1_EXT: numBitsPerTexel = 4; break;
case(GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG): numBitsPerTexel = 2; break; case GL_COMPRESSED_RED_RGTC1_EXT: numBitsPerTexel = 4; break;
case(GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG): numBitsPerTexel = 4; break; case GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: numBitsPerTexel = 8; break;
case(GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG): numBitsPerTexel = 4; break; case GL_COMPRESSED_RED_GREEN_RGTC2_EXT: numBitsPerTexel = 8; break;
case(GL_ETC1_RGB8_OES): numBitsPerTexel = 4; 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_RGB8_ETC2): numBitsPerTexel = 4; break; case GL_ETC1_RGB8_OES: numBitsPerTexel = 4; break;
case(GL_COMPRESSED_SRGB8_ETC2): numBitsPerTexel = 4; break;
case(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2): numBitsPerTexel = 8; break; case GL_COMPRESSED_RGB8_ETC2: numBitsPerTexel = 4; break;
case(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2): numBitsPerTexel = 8; break; case GL_COMPRESSED_SRGB8_ETC2: numBitsPerTexel = 4; break;
case(GL_COMPRESSED_RGBA8_ETC2_EAC): numBitsPerTexel = 8; break; case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: numBitsPerTexel = 8; break;
case(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC): numBitsPerTexel = 8; break; case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: numBitsPerTexel = 8; break;
case(GL_COMPRESSED_R11_EAC): numBitsPerTexel = 4; break; case GL_COMPRESSED_RGBA8_ETC2_EAC: numBitsPerTexel = 8; break;
case(GL_COMPRESSED_SIGNED_R11_EAC): numBitsPerTexel = 4; break; case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: numBitsPerTexel = 8; break;
case(GL_COMPRESSED_RG11_EAC): numBitsPerTexel = 8; break; case GL_COMPRESSED_R11_EAC: numBitsPerTexel = 4; break;
case(GL_COMPRESSED_SIGNED_RG11_EAC): numBitsPerTexel = 8; 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;
// ASTC
case GL_COMPRESSED_RGBA_ASTC_4x4_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
case GL_COMPRESSED_RGBA_ASTC_5x4_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:
case GL_COMPRESSED_RGBA_ASTC_5x5_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:
case GL_COMPRESSED_RGBA_ASTC_6x5_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:
case GL_COMPRESSED_RGBA_ASTC_6x6_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:
case GL_COMPRESSED_RGBA_ASTC_8x5_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:
case GL_COMPRESSED_RGBA_ASTC_8x6_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:
case GL_COMPRESSED_RGBA_ASTC_8x8_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:
case GL_COMPRESSED_RGBA_ASTC_10x5_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:
case GL_COMPRESSED_RGBA_ASTC_10x6_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:
case GL_COMPRESSED_RGBA_ASTC_10x8_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:
case GL_COMPRESSED_RGBA_ASTC_10x10_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
case GL_COMPRESSED_RGBA_ASTC_12x10_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
case GL_COMPRESSED_RGBA_ASTC_12x12_KHR:
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
{
_size = 0;
for (int i = 0; i < std::max(_numMipmapLevels, 1); ++i)
{
GLint blockSize;
GLint size;
getCompressedSize(_internalFormat, _width/(1 << i), _height/(1 << i), _depth, blockSize, size);
_size += size;
}
return;
}
} }
_size = (unsigned int)(ceil(double(_width * _height * _depth * numBitsPerTexel)/8.0)); _size = (unsigned int)(ceil(double(_width * _height * _depth * numBitsPerTexel)/8.0));
@ -1794,39 +1876,67 @@ bool Texture::isCompressedInternalFormat() const
bool Texture::isCompressedInternalFormat(GLint internalFormat) bool Texture::isCompressedInternalFormat(GLint internalFormat)
{ {
switch(internalFormat) switch (internalFormat)
{ {
case(GL_COMPRESSED_ALPHA_ARB): case (GL_COMPRESSED_ALPHA_ARB):
case(GL_COMPRESSED_INTENSITY_ARB): case (GL_COMPRESSED_INTENSITY_ARB):
case(GL_COMPRESSED_LUMINANCE_ALPHA_ARB): case (GL_COMPRESSED_LUMINANCE_ALPHA_ARB):
case(GL_COMPRESSED_LUMINANCE_ARB): case (GL_COMPRESSED_LUMINANCE_ARB):
case(GL_COMPRESSED_RGBA_ARB): case (GL_COMPRESSED_RGBA_ARB):
case(GL_COMPRESSED_RGB_ARB): case (GL_COMPRESSED_RGB_ARB):
case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT): case (GL_COMPRESSED_RGB_S3TC_DXT1_EXT):
case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT): case (GL_COMPRESSED_RGBA_S3TC_DXT1_EXT):
case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT): case (GL_COMPRESSED_RGBA_S3TC_DXT3_EXT):
case(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT): case (GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT):
case(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT): case (GL_COMPRESSED_RGBA_S3TC_DXT5_EXT):
case(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT): case (GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT):
case(GL_COMPRESSED_SIGNED_RED_RGTC1_EXT): case (GL_COMPRESSED_SIGNED_RED_RGTC1_EXT):
case(GL_COMPRESSED_RED_RGTC1_EXT): case (GL_COMPRESSED_RED_RGTC1_EXT):
case(GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT): case (GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT):
case(GL_COMPRESSED_RED_GREEN_RGTC2_EXT): case (GL_COMPRESSED_RED_GREEN_RGTC2_EXT):
case(GL_ETC1_RGB8_OES): case (GL_ETC1_RGB8_OES):
case(GL_COMPRESSED_RGB8_ETC2): case (GL_COMPRESSED_RGB8_ETC2):
case(GL_COMPRESSED_SRGB8_ETC2): case (GL_COMPRESSED_SRGB8_ETC2):
case(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2): case (GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2):
case(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2): case (GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2):
case(GL_COMPRESSED_RGBA8_ETC2_EAC): case (GL_COMPRESSED_RGBA8_ETC2_EAC):
case(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC): case (GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC):
case(GL_COMPRESSED_R11_EAC): case (GL_COMPRESSED_R11_EAC):
case(GL_COMPRESSED_SIGNED_R11_EAC): case (GL_COMPRESSED_SIGNED_R11_EAC):
case(GL_COMPRESSED_RG11_EAC): case (GL_COMPRESSED_RG11_EAC):
case(GL_COMPRESSED_SIGNED_RG11_EAC): case (GL_COMPRESSED_SIGNED_RG11_EAC):
case(GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG): case (GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG):
case(GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG): case (GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG):
case(GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG): case (GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG):
case(GL_COMPRESSED_RGBA_PVRTC_2BPPV1_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; return true;
default: default:
return false; return false;
@ -1870,7 +1980,7 @@ void Texture::getCompressedSize(GLenum internalFormat, GLint width, GLint height
size = widthBlocks * heightBlocks * ((blockSize * bpp) / 8); size = widthBlocks * heightBlocks * ((blockSize * bpp) / 8);
return; return;
} }
else if (internalFormat == GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG || internalFormat == GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG) else if (internalFormat == GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG || internalFormat == GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG)
{ {
blockSize = 4 * 4; // Pixel by pixel block size for 4bpp blockSize = 4 * 4; // Pixel by pixel block size for 4bpp
@ -1887,6 +1997,91 @@ void Texture::getCompressedSize(GLenum internalFormat, GLint width, GLint height
size = widthBlocks * heightBlocks * ((blockSize * bpp) / 8); size = widthBlocks * heightBlocks * ((blockSize * bpp) / 8);
return; 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 else
{ {
OSG_WARN<<"Texture::getCompressedSize(...) : cannot compute correct size of compressed format ("<<internalFormat<<") returning 0."<<std::endl; OSG_WARN<<"Texture::getCompressedSize(...) : cannot compute correct size of compressed format ("<<internalFormat<<") returning 0."<<std::endl;
@ -2040,7 +2235,8 @@ void Texture::applyTexParameters(GLenum target, State& state) const
glTexParameterf(target, GL_TEXTURE_MAX_LOD, _maxlod); glTexParameterf(target, GL_TEXTURE_MAX_LOD, _maxlod);
} }
glTexParameterf(target, GL_TEXTURE_LOD_BIAS, _lodbias); if (extensions->isTextureLODBiasSupported)
glTexParameterf(target, GL_TEXTURE_LOD_BIAS, _lodbias);
getTextureParameterDirty(state.getContextID()) = false; getTextureParameterDirty(state.getContextID()) = false;
@ -2164,19 +2360,19 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
OSG_NOTICE<<"Received a request to compress an image, but image size is not a multiple of four ("<<inwidth<<"x"<<inheight<<"). Reverting to uncompressed.\n"; OSG_NOTICE<<"Received a request to compress an image, but image size is not a multiple of four ("<<inwidth<<"x"<<inheight<<"). Reverting to uncompressed.\n";
switch(_internalFormat) switch(_internalFormat)
{ {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
case GL_ETC1_RGB8_OES: case GL_ETC1_RGB8_OES:
case(GL_COMPRESSED_RGB8_ETC2): case(GL_COMPRESSED_RGB8_ETC2):
case(GL_COMPRESSED_SRGB8_ETC2): case(GL_COMPRESSED_SRGB8_ETC2):
case GL_COMPRESSED_RGB: _internalFormat = GL_RGB; break; case GL_COMPRESSED_RGB: _internalFormat = GL_RGB; break;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: