From a0b03cf30feb82857e9d919de01f37fe86d46900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 5 Jul 2025 19:37:01 +0200 Subject: [PATCH] GL: this workaround is no longer used for anything. With the recent changes where compressed image block properties no longer need to be queries from GL, we also no longer need to query GL_TEXTURE_COMPRESSED_IMAGE_SIZE, and thus we don't need the NV-specific workaround where the returned value was sometimes broken for cubemaps. --- src/Magnum/GL/CubeMapTexture.cpp | 34 --------- src/Magnum/GL/CubeMapTexture.h | 7 -- src/Magnum/GL/Implementation/TextureState.cpp | 18 ----- src/Magnum/GL/Implementation/TextureState.h | 1 - .../GL/Implementation/driverSpecific.cpp | 5 -- src/Magnum/GL/Test/ContextTest.cpp | 2 +- src/Magnum/GL/Test/CubeMapTextureGLTest.cpp | 71 ------------------- 7 files changed, 1 insertion(+), 137 deletions(-) diff --git a/src/Magnum/GL/CubeMapTexture.cpp b/src/Magnum/GL/CubeMapTexture.cpp index d9851a43d..fd957b868 100644 --- a/src/Magnum/GL/CubeMapTexture.cpp +++ b/src/Magnum/GL/CubeMapTexture.cpp @@ -683,40 +683,6 @@ void CubeMapTexture::getLevelParameterImplementationDSA(CubeMapTexture& self, co #endif #endif -#ifndef MAGNUM_TARGET_GLES -GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDefault(CubeMapTexture& self, const GLint level) { - self.bindInternal(); - /* Using only parameters of +X in pre-DSA code path and assuming that all - other faces are the same */ - GLint value; - glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &value); - - return value; -} - -GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDefaultImmutableWorkaround(CubeMapTexture& self, const GLint level) { - const GLint value = getLevelCompressedImageSizeImplementationDefault(self, level); - - GLint immutable; - glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_IMMUTABLE_LEVELS, &immutable); - return immutable ? value/6 : value; -} - -GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDSA(CubeMapTexture& self, const GLint level) { - GLint value; - glGetTextureLevelParameteriv(self._id, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &value); - return value; -} - -GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDSANonImmutableWorkaround(CubeMapTexture& self, const GLint level) { - const GLint value = getLevelCompressedImageSizeImplementationDSA(self, level); - - GLint immutable; - glGetTextureParameteriv(self._id, GL_TEXTURE_IMMUTABLE_LEVELS, &immutable); - return immutable ? value/6 : value; -} -#endif - #ifndef MAGNUM_TARGET_GLES void CubeMapTexture::getImageImplementationDSA(CubeMapTexture& self, const GLint level, const Vector3i&, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data, const PixelStorage&) { glGetTextureImage(self._id, level, GLenum(format), GLenum(type), dataSize, data); diff --git a/src/Magnum/GL/CubeMapTexture.h b/src/Magnum/GL/CubeMapTexture.h index e7b221a5f..d1fbc607f 100644 --- a/src/Magnum/GL/CubeMapTexture.h +++ b/src/Magnum/GL/CubeMapTexture.h @@ -1343,13 +1343,6 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture { #endif #endif - #ifndef MAGNUM_TARGET_GLES - static GLint MAGNUM_GL_LOCAL getLevelCompressedImageSizeImplementationDefault(CubeMapTexture& self, GLint level); - static GLint MAGNUM_GL_LOCAL getLevelCompressedImageSizeImplementationDefaultImmutableWorkaround(CubeMapTexture& self, GLint level); - static GLint MAGNUM_GL_LOCAL getLevelCompressedImageSizeImplementationDSA(CubeMapTexture& self, GLint level); - static GLint MAGNUM_GL_LOCAL getLevelCompressedImageSizeImplementationDSANonImmutableWorkaround(CubeMapTexture& self, GLint level); - #endif - #ifndef MAGNUM_TARGET_GLES static void MAGNUM_GL_LOCAL getImageImplementationDSA(CubeMapTexture& self, GLint level, const Vector3i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data, const PixelStorage& storage); static void MAGNUM_GL_LOCAL getImageImplementationDSAAmdSliceBySlice(CubeMapTexture& self, GLint level, const Vector3i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data, const PixelStorage& storage); diff --git a/src/Magnum/GL/Implementation/TextureState.cpp b/src/Magnum/GL/Implementation/TextureState.cpp index 61ff7d0da..4b1d442e9 100644 --- a/src/Magnum/GL/Implementation/TextureState.cpp +++ b/src/Magnum/GL/Implementation/TextureState.cpp @@ -300,24 +300,6 @@ TextureState::TextureState(Context& context, } #ifndef MAGNUM_TARGET_GLES - /* Compressed cubemap image size query implementation (extensions added - above) */ - if((context.detectedDriver() & Context::DetectedDriver::NVidia) && - !context.isDriverWorkaroundDisabled("nv-cubemap-inconsistent-compressed-image-size"_s)) { - if(context.isExtensionSupported()) - getCubeLevelCompressedImageSizeImplementation = &CubeMapTexture::getLevelCompressedImageSizeImplementationDSANonImmutableWorkaround; - else getCubeLevelCompressedImageSizeImplementation = &CubeMapTexture::getLevelCompressedImageSizeImplementationDefaultImmutableWorkaround; - } else if(context.isExtensionSupported() - #ifdef CORRADE_TARGET_WINDOWS - && (!(context.detectedDriver() & Context::DetectedDriver::IntelWindows) || - context.isDriverWorkaroundDisabled("intel-windows-broken-dsa-for-cubemaps"_s)) - #endif - ) { - getCubeLevelCompressedImageSizeImplementation = &CubeMapTexture::getLevelCompressedImageSizeImplementationDSA; - } else { - getCubeLevelCompressedImageSizeImplementation = &CubeMapTexture::getLevelCompressedImageSizeImplementationDefault; - } - /* Image retrieval implementation */ if(context.isExtensionSupported()) { /* Extension name added above */ diff --git a/src/Magnum/GL/Implementation/TextureState.h b/src/Magnum/GL/Implementation/TextureState.h index dd1620c97..20313dabf 100644 --- a/src/Magnum/GL/Implementation/TextureState.h +++ b/src/Magnum/GL/Implementation/TextureState.h @@ -134,7 +134,6 @@ struct TextureState { void(*getCubeLevelParameterivImplementation)(CubeMapTexture&, GLint, GLenum, GLint*); #endif #ifndef MAGNUM_TARGET_GLES - GLint(*getCubeLevelCompressedImageSizeImplementation)(CubeMapTexture&, GLint); void(*getCubeImageImplementation)(CubeMapTexture&, CubeMapCoordinate, GLint, const Vector2i&, PixelFormat, PixelType, std::size_t, GLvoid*); void(*getCubeImage3DImplementation)(CubeMapTexture&, GLint, const Vector3i&, PixelFormat, PixelType, std::size_t, GLvoid*, const PixelStorage&); void(*getCompressedCubeImage3DImplementation)(CubeMapTexture&, GLint, const Vector2i&, std::size_t, std::size_t, GLvoid*); diff --git a/src/Magnum/GL/Implementation/driverSpecific.cpp b/src/Magnum/GL/Implementation/driverSpecific.cpp index 0d9c12a19..a693d8326 100644 --- a/src/Magnum/GL/Implementation/driverSpecific.cpp +++ b/src/Magnum/GL/Implementation/driverSpecific.cpp @@ -192,11 +192,6 @@ constexpr Containers::StringView KnownWorkarounds[]{ query in bits instead of bytes */ "nv-compressed-block-size-in-bits"_s, -/* NVidia drivers (358.16) report different compressed image size for cubemaps - based on whether the texture is immutable or not and not based on whether - I'm querying all faces (ARB_DSA) or a single face (non-DSA, EXT_DSA) */ -"nv-cubemap-inconsistent-compressed-image-size"_s, - /* NVidia drivers (358.16) return only the first slice of compressed cube map image when querying all six slices using the ARB_DSA API */ "nv-cubemap-broken-full-compressed-image-query"_s, diff --git a/src/Magnum/GL/Test/ContextTest.cpp b/src/Magnum/GL/Test/ContextTest.cpp index d4842694e..d0c8edc06 100644 --- a/src/Magnum/GL/Test/ContextTest.cpp +++ b/src/Magnum/GL/Test/ContextTest.cpp @@ -161,7 +161,7 @@ void ContextTest::configurationConstruct() { #ifndef MAGNUM_TARGET_GLES const Containers::StringView a = "no-layout-qualifiers-on-old-glsl!"_s.exceptSuffix(1); const Containers::StringView b = "nv-compressed-block-size-in-bits!"_s.exceptSuffix(1); - const Containers::StringView c = "nv-cubemap-inconsistent-compressed-image-size!"_s.exceptSuffix(1); + const Containers::StringView c = "nv-zero-context-profile-mask!"_s.exceptSuffix(1); #elif !defined(MAGNUM_TARGET_WEBGL) const Containers::StringView a = "swiftshader-no-empty-egl-context-flags!"_s.exceptSuffix(1); const Containers::StringView b = "swiftshader-egl-context-needs-pbuffer!"_s.exceptSuffix(1); diff --git a/src/Magnum/GL/Test/CubeMapTextureGLTest.cpp b/src/Magnum/GL/Test/CubeMapTextureGLTest.cpp index 005242ddb..babbf4a70 100644 --- a/src/Magnum/GL/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/GL/Test/CubeMapTextureGLTest.cpp @@ -132,9 +132,6 @@ struct CubeMapTextureGLTest: OpenGLTester { void compressedImageQueryViewBadSize(); void compressedImageQueryViewBadFormat(); #endif - #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) - void immutableCompressedImage(); - #endif void compressedSubImage(); #ifndef MAGNUM_TARGET_GLES2 void compressedSubImageBuffer(); @@ -421,9 +418,6 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() { #ifndef MAGNUM_TARGET_GLES &CubeMapTextureGLTest::compressedImageQueryView, #endif - #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) - &CubeMapTextureGLTest::immutableCompressedImage, - #endif }, Containers::arraySize(CompressedPixelStorageData)); #ifndef MAGNUM_TARGET_GLES @@ -1478,71 +1472,6 @@ void CubeMapTextureGLTest::compressedImageQueryViewBadFormat() { } #endif -#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) -void CubeMapTextureGLTest::immutableCompressedImage() { - auto&& data = CompressedPixelStorageData[testCaseInstanceId()]; - setTestCaseDescription(data.name); - - #ifndef MAGNUM_TARGET_GLES - if(!Context::current().isExtensionSupported()) - CORRADE_SKIP(Extensions::ARB::texture_storage::string() << "is not supported."); - #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current().isExtensionSupported()) - CORRADE_SKIP(Extensions::EXT::texture_storage::string() << "is not supported."); - #endif - #ifndef MAGNUM_TARGET_GLES - if(!Context::current().isExtensionSupported()) - CORRADE_SKIP(Extensions::EXT::texture_compression_s3tc::string() << "is not supported."); - #elif defined(MAGNUM_TARGET_WEBGL) - if(!Context::current().isExtensionSupported()) - CORRADE_SKIP(Extensions::WEBGL::compressed_texture_s3tc::string() << "is not supported."); - #else - if(!Context::current().isExtensionSupported()) - CORRADE_SKIP(Extensions::ANGLE::texture_compression_dxt3::string() << "is not supported."); - #endif - - #ifndef MAGNUM_TARGET_GLES - if(data.storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported()) - CORRADE_SKIP(Extensions::ARB::compressed_texture_pixel_storage::string() << "is not supported."); - #endif - - /* Testing that GL_TEXTURE_COMPRESSED_IMAGE_SIZE is consistent and returns - the same value regardless whether the texture is immutable or not. (Not - the case, at least on NVidia 358.16, compare with compressedImage() test - case that just calls setImage() six times instead of setStorage() and - gets value that's six times smaller. I couldn't find anything in the - specs so I suspect it's a bug). */ - - const CompressedImageView2D view{ - data.storage, - CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, - data.dataSparse}; - - CubeMapTexture texture; - texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4}) - .setCompressedSubImage(CubeMapCoordinate::PositiveX, 0, {}, view) - .setCompressedSubImage(CubeMapCoordinate::NegativeX, 0, {}, view) - .setCompressedSubImage(CubeMapCoordinate::PositiveY, 0, {}, view) - .setCompressedSubImage(CubeMapCoordinate::NegativeY, 0, {}, view) - .setCompressedSubImage(CubeMapCoordinate::PositiveZ, 0, {}, view) - .setCompressedSubImage(CubeMapCoordinate::NegativeZ, 0, {}, view); - - MAGNUM_VERIFY_NO_GL_ERROR(); - - #ifndef MAGNUM_TARGET_GLES - CompressedImage2D image{data.storage, CompressedPixelFormat::RGBAS3tcDxt3, {}, nullptr}; - texture.compressedImage(CubeMapCoordinate::NegativeY, 0, image); - - MAGNUM_VERIFY_NO_GL_ERROR(); - - CORRADE_COMPARE(image.size(), Vector2i{4}); - CORRADE_COMPARE_AS(Containers::arrayCast(image.data()).exceptPrefix(data.offset), - data.data, - TestSuite::Compare::Container); - #endif -} -#endif - /* Just 12x12 zeros compressed using RGBA DXT3 by the driver */ constexpr UnsignedByte CompressedZero[9*16]{};