diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 73804e907..a63d2ba05 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -1616,9 +1616,17 @@ template void MAGNUM_EXPORT AbstractTexture::image<3>(GLint, BufferImage<3>&, Bu template void AbstractTexture::compressedImage(const GLint level, CompressedImage& image) { const Math::Vector size = DataHelper::imageSize(*this, level); - GLint textureDataSize; - (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); - const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); + + /* If the user-provided pixel storage doesn't tell us all properties about + the compression, we need to ask GL for it */ + std::size_t dataSize; + if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) { + GLint textureDataSize; + (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); + dataSize = textureDataSize; + } else dataSize = Implementation::compressedImageDataSizeFor(image, size); + + /* Internal texture format */ GLint format; (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); @@ -1639,9 +1647,17 @@ template void MAGNUM_EXPORT AbstractTexture::compressedImage<3>(GLint, Compresse template void AbstractTexture::compressedImage(const GLint level, CompressedBufferImage& image, BufferUsage usage) { const Math::Vector size = DataHelper::imageSize(*this, level); - GLint textureDataSize; - (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); - const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); + + /* If the user-provided pixel storage doesn't tell us all properties about + the compression, we need to ask GL for it */ + std::size_t dataSize; + if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) { + GLint textureDataSize; + (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); + dataSize = textureDataSize; + } else dataSize = Implementation::compressedImageDataSizeFor(image, size); + + /* Internal texture format */ GLint format; (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); @@ -1720,9 +1736,18 @@ template void AbstractTexture::compressedSubImage(const const Math::Vector size = range.size(); const Vector3i paddedOffset = Vector3i::pad(range.min()); const Vector3i paddedSize = Vector3i::pad(size, 1); + + /* Internal texture format */ GLint format; (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); - const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, compressedSubImageSize(TextureFormat(format), size)); + + /* Calculate compressed subimage size. If the user-provided pixel storage + doesn't tell us all properties about the compression, we need to ask GL + for it. That requires GL_ARB_internalformat_query2. */ + std::size_t dataSize; + if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) + dataSize = compressedSubImageSize(TextureFormat(format), size); + else dataSize = Implementation::compressedImageDataSizeFor(image, size); /* Reallocate only if needed */ Containers::Array data{image.release()}; @@ -1745,9 +1770,18 @@ template void AbstractTexture::compressedSubImage(const const Math::Vector size = range.size(); const Vector3i paddedOffset = Vector3i::pad(range.min()); const Vector3i paddedSize = Vector3i::pad(size, 1); + + /* Internal texture format */ GLint format; (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); - const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, compressedSubImageSize(TextureFormat(format), size)); + + /* Calculate compressed subimage size. If the user-provided pixel storage + doesn't tell us all properties about the compression, we need to ask GL + for it. That requires GL_ARB_internalformat_query2. */ + std::size_t dataSize; + if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) + dataSize = compressedSubImageSize(TextureFormat(format), size); + else dataSize = Implementation::compressedImageDataSizeFor(image, size); /* Reallocate only if needed */ if(image.dataSize() < dataSize) diff --git a/src/Magnum/CubeMapTexture.cpp b/src/Magnum/CubeMapTexture.cpp index bf5b3ee9a..351ecbe72 100644 --- a/src/Magnum/CubeMapTexture.cpp +++ b/src/Magnum/CubeMapTexture.cpp @@ -109,9 +109,16 @@ void CubeMapTexture::compressedImage(const Int level, CompressedImage3D& image) createIfNotAlready(); const Vector3i size{imageSize(level), 6}; - const GLint textureDataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level)*6; + + /* If the user-provided pixel storage doesn't tell us all properties about + the compression, we need to ask GL for it */ std::size_t dataOffset, dataSize; - std::tie(dataOffset, dataSize) = Implementation::compressedImageDataOffsetSizeFor(image, size, textureDataSize); + if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) { + dataOffset = 0; + dataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level)*6; + } else std::tie(dataOffset, dataSize) = Implementation::compressedImageDataOffsetSizeFor(image, size); + + /* Internal texture format */ GLint format; (this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); @@ -135,9 +142,16 @@ void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& i createIfNotAlready(); const Vector3i size{imageSize(level), 6}; - const GLint textureDataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level)*6; + + /* If the user-provided pixel storage doesn't tell us all properties about + the compression, we need to ask GL for it */ std::size_t dataOffset, dataSize; - std::tie(dataOffset, dataSize) = Implementation::compressedImageDataOffsetSizeFor(image, size, textureDataSize); + if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) { + dataOffset = 0; + dataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level)*6; + } else std::tie(dataOffset, dataSize) = Implementation::compressedImageDataOffsetSizeFor(image, size); + + /* Internal texture format */ GLint format; (this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); @@ -199,8 +213,16 @@ BufferImage2D CubeMapTexture::image(const CubeMapCoordinate coordinate, const In void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const Int level, CompressedImage2D& image) { const Vector2i size = imageSize(level); - const GLint textureDataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level); - const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); + + /* If the user-provided pixel storage doesn't tell us all properties about + the compression, we need to ask GL for it */ + std::size_t dataSize; + if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) + dataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level); + else + dataSize = Implementation::compressedImageDataSizeFor(image, size); + + /* Internal texture format */ GLint format; (this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); @@ -222,8 +244,16 @@ CompressedImage2D CubeMapTexture::compressedImage(const CubeMapCoordinate coordi void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const Int level, CompressedBufferImage2D& image, const BufferUsage usage) { const Vector2i size = imageSize(level); - const GLint textureDataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level); - const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); + + /* If the user-provided pixel storage doesn't tell us all properties about + the compression, we need to ask GL for it */ + std::size_t dataSize; + if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) + dataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level); + else + dataSize = Implementation::compressedImageDataSizeFor(image, size); + + /* Internal texture format */ GLint format; (this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); diff --git a/src/Magnum/CubeMapTexture.h b/src/Magnum/CubeMapTexture.h index cb320546c..112e09e4c 100644 --- a/src/Magnum/CubeMapTexture.h +++ b/src/Magnum/CubeMapTexture.h @@ -792,6 +792,10 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedImage&) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl43 Extension @extension{ARB,internalformat_query2} if + * @ref CompressedPixelStorage::compressedBlockSize() and + * @ref CompressedPixelStorage::compressedBlockDataSize() are not + * set to non-zero values * @requires_gl Texture image queries are not available in OpenGL ES or * WebGL. See @ref Framebuffer::read() for possible workaround. */ @@ -814,6 +818,10 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl43 Extension @extension{ARB,internalformat_query2} if + * @ref CompressedPixelStorage::compressedBlockSize() and + * @ref CompressedPixelStorage::compressedBlockDataSize() are not + * set to non-zero values * @requires_gl Texture image queries are not available in OpenGL ES or * WebGL. See @ref Framebuffer::read() for possible workaround. */ diff --git a/src/Magnum/CubeMapTextureArray.h b/src/Magnum/CubeMapTextureArray.h index f0f159ebf..c72f76979 100644 --- a/src/Magnum/CubeMapTextureArray.h +++ b/src/Magnum/CubeMapTextureArray.h @@ -583,6 +583,10 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture { * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedImage&) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl43 Extension @extension{ARB,internalformat_query2} if + * @ref CompressedPixelStorage::compressedBlockSize() and + * @ref CompressedPixelStorage::compressedBlockDataSize() are not + * set to non-zero values * @requires_gl Texture image queries are not available in OpenGL ES. * See @ref Framebuffer::read() for possible workaround. */ @@ -605,6 +609,10 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture { * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl43 Extension @extension{ARB,internalformat_query2} if + * @ref CompressedPixelStorage::compressedBlockSize() and + * @ref CompressedPixelStorage::compressedBlockDataSize() are not + * set to non-zero values * @requires_gl Texture image queries are not available in OpenGL ES. * See @ref Framebuffer::read() for possible workaround. */ diff --git a/src/Magnum/PixelStorage.h b/src/Magnum/PixelStorage.h index 083ea2846..84ae2ee7e 100644 --- a/src/Magnum/PixelStorage.h +++ b/src/Magnum/PixelStorage.h @@ -444,9 +444,8 @@ namespace Implementation { #endif #ifndef MAGNUM_TARGET_GLES - template std::pair compressedImageDataOffsetSizeFor(const T& image, const Math::Vector& size, std::size_t dataSize) { - if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) - return {0, dataSize}; + template std::pair compressedImageDataOffsetSizeFor(const T& image, const Math::Vector& size) { + CORRADE_INTERNAL_ASSERT(image.storage().compressedBlockSize().product() && image.storage().compressedBlockDataSize()); Math::Vector3 offset, blockCount; std::size_t blockDataSize; @@ -458,14 +457,15 @@ namespace Implementation { } /* Used in image query functions */ - template std::size_t compressedImageDataSizeFor(const T& image, const Math::Vector& size, std::size_t dataSize) { - auto r = compressedImageDataOffsetSizeFor(image, size, dataSize); + template std::size_t compressedImageDataSizeFor(const T& image, const Math::Vector& size) { + auto r = compressedImageDataOffsetSizeFor(image, size); return r.first + r.second; } /* Use in compressed image upload functions */ template std::size_t occupiedCompressedImageDataSize(const T& image, std::size_t dataSize) { - return compressedImageDataOffsetSizeFor(image, image.size(), dataSize).second; + return image.storage().compressedBlockSize().product() && image.storage().compressedBlockDataSize() + ? compressedImageDataOffsetSizeFor(image, image.size()).second : dataSize; } #else template std::size_t occupiedCompressedImageDataSize(const T&, std::size_t dataSize) { diff --git a/src/Magnum/RectangleTexture.h b/src/Magnum/RectangleTexture.h index f1698d09b..0475f3650 100644 --- a/src/Magnum/RectangleTexture.h +++ b/src/Magnum/RectangleTexture.h @@ -442,6 +442,10 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedImage&) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl43 Extension @extension{ARB,internalformat_query2} if + * @ref CompressedPixelStorage::compressedBlockSize() and + * @ref CompressedPixelStorage::compressedBlockDataSize() are not + * set to non-zero values */ void compressedSubImage(const Range2Di& range, CompressedImage2D& image) { AbstractTexture::compressedSubImage<2>(0, range, image); @@ -462,6 +466,10 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl43 Extension @extension{ARB,internalformat_query2} if + * @ref CompressedPixelStorage::compressedBlockSize() and + * @ref CompressedPixelStorage::compressedBlockDataSize() are not + * set to non-zero values */ void compressedSubImage(const Range2Di& range, CompressedBufferImage2D& image, BufferUsage usage) { AbstractTexture::compressedSubImage<2>(0, range, image, usage); diff --git a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp index f808dacc8..785851c17 100644 --- a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp @@ -1032,14 +1032,14 @@ void CubeMapTextureArrayGLTest::compressedSubImageQuery() { if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); - if(!Context::current().isExtensionSupported()) - CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported.")); if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); - if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported()) + if(CompressedSubPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); + if(CompressedSubPixelStorageData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported.")); CubeMapTextureArray texture; texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 12, 6}) @@ -1062,14 +1062,14 @@ void CubeMapTextureArrayGLTest::compressedSubImageQueryBuffer() { if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); - if(!Context::current().isExtensionSupported()) - CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported.")); if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); - if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported()) + if(CompressedSubPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); + if(CompressedSubPixelStorageData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported.")); CubeMapTextureArray texture; texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 12, 6}) diff --git a/src/Magnum/Test/CubeMapTextureGLTest.cpp b/src/Magnum/Test/CubeMapTextureGLTest.cpp index ca6af1762..74295baed 100644 --- a/src/Magnum/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureGLTest.cpp @@ -1103,6 +1103,8 @@ void CubeMapTextureGLTest::compressedSubImageQuery() { CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); + if(CompressedPixelStorageData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported.")); CubeMapTexture texture; texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{12}) @@ -1132,6 +1134,8 @@ void CubeMapTextureGLTest::compressedSubImageQueryBuffer() { CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); + if(CompressedPixelStorageData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported.")); CubeMapTexture texture; texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{12}) diff --git a/src/Magnum/Test/PixelStorageTest.cpp b/src/Magnum/Test/PixelStorageTest.cpp index e21fbef0a..93b9b1101 100644 --- a/src/Magnum/Test/PixelStorageTest.cpp +++ b/src/Magnum/Test/PixelStorageTest.cpp @@ -345,11 +345,6 @@ void PixelStorageTest::dataPropertiesCompressedImageHeight() { } void PixelStorageTest::dataOffsetSizeCompressed() { - /* Tf the storage doesn't contain any info about block sizes (the default), - using the provided value */ - CORRADE_COMPARE(Implementation::compressedImageDataOffsetSizeFor(CompressedImage3D{}, - Vector2i{37, 35}, 1579), (std::pair{0, 1579})); - /* The same parameters as in PixelStorageGLTest 3D case */ const CompressedImage3D image{CompressedPixelStorage{} .setCompressedBlockSize({4, 4, 1}) @@ -357,7 +352,7 @@ void PixelStorageTest::dataOffsetSizeCompressed() { .setRowLength(8) .setImageHeight(8) .setSkip({4, 4, 4})}; - CORRADE_COMPARE(Implementation::compressedImageDataOffsetSizeFor(image, Vector3i{4, 4, 1}, 1579), + CORRADE_COMPARE(Implementation::compressedImageDataOffsetSizeFor(image, Vector3i{4, 4, 1}), (std::pair{16*4*4 + 16*2 + 16, 16})); } #endif diff --git a/src/Magnum/Test/TextureArrayGLTest.cpp b/src/Magnum/Test/TextureArrayGLTest.cpp index 812d8f29a..c2d4c08c1 100644 --- a/src/Magnum/Test/TextureArrayGLTest.cpp +++ b/src/Magnum/Test/TextureArrayGLTest.cpp @@ -1434,6 +1434,8 @@ void TextureArrayGLTest::compressedSubImage2DQuery() { CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); if(CompressedPixelStorage2DData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); + if(CompressedPixelStorage2DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported.")); Texture2DArray texture; texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 4, 4}) @@ -1463,6 +1465,8 @@ void TextureArrayGLTest::compressedSubImage2DQueryBuffer() { CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); if(CompressedPixelStorage2DData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); + if(CompressedPixelStorage2DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported.")); Texture2DArray texture; texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 4, 4}) diff --git a/src/Magnum/Test/TextureGLTest.cpp b/src/Magnum/Test/TextureGLTest.cpp index 184e3b3ed..0889d8a74 100644 --- a/src/Magnum/Test/TextureGLTest.cpp +++ b/src/Magnum/Test/TextureGLTest.cpp @@ -1753,6 +1753,8 @@ void TextureGLTest::compressedSubImage2DQuery() { CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); if(CompressedPixelStorage2DData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); + if(CompressedPixelStorage2DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported.")); Texture2D texture; texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 4}) @@ -1780,6 +1782,8 @@ void TextureGLTest::compressedSubImage2DQueryBuffer() { CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); if(CompressedPixelStorage2DData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); + if(CompressedPixelStorage2DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported.")); Texture2D texture; texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 4}) @@ -2199,6 +2203,8 @@ void TextureGLTest::compressedSubImage3DQuery() { CORRADE_SKIP(Extensions::GL::ARB::texture_compression_bptc::string() + std::string(" is not supported.")); if(CompressedPixelStorage3DData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); + if(CompressedPixelStorage3DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported.")); Texture3D texture; texture.setStorage(1, TextureFormat::CompressedRGBABptcUnorm, {12, 4, 4}) @@ -2232,6 +2238,8 @@ void TextureGLTest::compressedSubImage3DQueryBuffer() { CORRADE_SKIP(Extensions::GL::ARB::texture_compression_bptc::string() + std::string(" is not supported.")); if(CompressedPixelStorage3DData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); + if(CompressedPixelStorage3DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported.")); Texture3D texture; texture.setStorage(1, TextureFormat::CompressedRGBABptcUnorm, {12, 4, 4}) diff --git a/src/Magnum/Texture.h b/src/Magnum/Texture.h index c1aed93de..71e0040b6 100644 --- a/src/Magnum/Texture.h +++ b/src/Magnum/Texture.h @@ -129,7 +129,7 @@ template class Texture: public AbstractTexture { * * If @p format is compressed, returns compressed block size (in * pixels). For uncompressed formats returns zero vector. - * @see @ref compressedBlockDataSize(), @fn_gl{Getinternalformat} with + * @see @ref compressedBlockDataSize(), @fn_gl{GetInternalformat} with * @def_gl{TEXTURE_COMPRESSED_BLOCK_WIDTH}, * @def_gl{TEXTURE_COMPRESSED_BLOCK_HEIGHT} * @requires_gl43 Extension @extension{ARB,internalformat_query2} @@ -145,7 +145,7 @@ template class Texture: public AbstractTexture { * * If @p format is compressed, returns compressed block data size (in * bytes). For uncompressed formats returns zero. - * @see @ref compressedBlockSize(), @fn_gl{Getinternalformat} with + * @see @ref compressedBlockSize(), @fn_gl{GetInternalformat} with * @def_gl{TEXTURE_COMPRESSED_BLOCK_SIZE} * @requires_gl43 Extension @extension{ARB,internalformat_query2} * @requires_gl Compressed texture queries are not available in OpenGL @@ -958,9 +958,16 @@ template class Texture: public AbstractTexture { * @see @fn_gl2{GetTextureLevelParameter,GetTexLevelParameter}, * @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access}, * eventually @fn_gl{GetTexLevelParameter} with - * @def_gl{TEXTURE_COMPRESSED_IMAGE_SIZE}, @def_gl{TEXTURE_INTERNAL_FORMAT}, - * then @fn_gl{GetCompressedTextureSubImage} + * @def_gl{TEXTURE_INTERNAL_FORMAT}, then possibly + * @fn_gl{GetInternalformat} with @def_gl{TEXTURE_COMPRESSED_BLOCK_SIZE}, + * @def_gl{TEXTURE_COMPRESSED_BLOCK_WIDTH} and + * @def_gl{TEXTURE_COMPRESSED_BLOCK_HEIGHT}, then + * @fn_gl{GetCompressedTextureSubImage} * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl43 Extension @extension{ARB,internalformat_query2} if + * @ref CompressedPixelStorage::compressedBlockSize() and + * @ref CompressedPixelStorage::compressedBlockDataSize() are not + * set to non-zero values * @requires_gl Texture image queries are not available in OpenGL ES or * WebGL. See @ref Framebuffer::read() for possible workaround. */ @@ -987,6 +994,10 @@ template class Texture: public AbstractTexture { * See @ref compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl43 Extension @extension{ARB,internalformat_query2} if + * @ref CompressedPixelStorage::compressedBlockSize() and + * @ref CompressedPixelStorage::compressedBlockDataSize() are not + * set to non-zero values * @requires_gl Texture image queries are not available in OpenGL ES or * WebGL. See @ref Framebuffer::read() for possible workaround. */ diff --git a/src/Magnum/TextureArray.h b/src/Magnum/TextureArray.h index 1fb77181d..526c491e8 100644 --- a/src/Magnum/TextureArray.h +++ b/src/Magnum/TextureArray.h @@ -606,6 +606,10 @@ template class TextureArray: public AbstractTexture { * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedImage&) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl43 Extension @extension{ARB,internalformat_query2} if + * @ref CompressedPixelStorage::compressedBlockSize() and + * @ref CompressedPixelStorage::compressedBlockDataSize() are not + * set to non-zero values * @requires_gl Texture image queries are not available in OpenGL ES or * WebGL. See @ref Framebuffer::read() for possible workaround. */ @@ -628,6 +632,10 @@ template class TextureArray: public AbstractTexture { * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl43 Extension @extension{ARB,internalformat_query2} if + * @ref CompressedPixelStorage::compressedBlockSize() and + * @ref CompressedPixelStorage::compressedBlockDataSize() are not + * set to non-zero values * @requires_gl Texture image queries are not available in OpenGL ES or * WebGL. See @ref Framebuffer::read() for possible workaround. */