Browse Source

Reduce amount of GL queries when asking for compressed (sub)images.

The GL queries are needed only if the user-provided pixel storage
doesn't contain enough information, in particular dimensions and byte
size of compression block.

So in case they are present, no query for compressed image size is done
for full image queries (just saving one API call) and no queries for
block dimensions and byte size for subimage queries (saving four API
calls and not requiring ARB_internalformat_query2).

The documentation was fixed and tests were updated to take the
ARB_internalformat_query2 requirement into account.
pull/203/merge
Vladimír Vondruš 9 years ago
parent
commit
ce6fc52654
  1. 50
      src/Magnum/AbstractTexture.cpp
  2. 46
      src/Magnum/CubeMapTexture.cpp
  3. 8
      src/Magnum/CubeMapTexture.h
  4. 8
      src/Magnum/CubeMapTextureArray.h
  5. 12
      src/Magnum/PixelStorage.h
  6. 8
      src/Magnum/RectangleTexture.h
  7. 12
      src/Magnum/Test/CubeMapTextureArrayGLTest.cpp
  8. 4
      src/Magnum/Test/CubeMapTextureGLTest.cpp
  9. 7
      src/Magnum/Test/PixelStorageTest.cpp
  10. 4
      src/Magnum/Test/TextureArrayGLTest.cpp
  11. 8
      src/Magnum/Test/TextureGLTest.cpp
  12. 19
      src/Magnum/Texture.h
  13. 8
      src/Magnum/TextureArray.h

50
src/Magnum/AbstractTexture.cpp

@ -1616,9 +1616,17 @@ template void MAGNUM_EXPORT AbstractTexture::image<3>(GLint, BufferImage<3>&, Bu
template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLint level, CompressedImage<dimensions>& image) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::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<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLint level, CompressedBufferImage<dimensions>& image, BufferUsage usage) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::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<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const
const Math::Vector<dimensions, Int> 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<dimensions>(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<dimensions>(TextureFormat(format), size);
else dataSize = Implementation::compressedImageDataSizeFor(image, size);
/* Reallocate only if needed */
Containers::Array<char> data{image.release()};
@ -1745,9 +1770,18 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const
const Math::Vector<dimensions, Int> 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<dimensions>(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<dimensions>(TextureFormat(format), size);
else dataSize = Implementation::compressedImageDataSizeFor(image, size);
/* Reallocate only if needed */
if(image.dataSize() < dataSize)

46
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);

8
src/Magnum/CubeMapTexture.h

@ -792,6 +792,10 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
* See @ref Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, 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<dimensions, Int>&, 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.
*/

8
src/Magnum/CubeMapTextureArray.h

@ -583,6 +583,10 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture {
* See @ref Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, 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<dimensions, Int>&, 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.
*/

12
src/Magnum/PixelStorage.h

@ -444,9 +444,8 @@ namespace Implementation {
#endif
#ifndef MAGNUM_TARGET_GLES
template<std::size_t dimensions, class T> std::pair<std::size_t, std::size_t> compressedImageDataOffsetSizeFor(const T& image, const Math::Vector<dimensions, Int>& size, std::size_t dataSize) {
if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize())
return {0, dataSize};
template<std::size_t dimensions, class T> std::pair<std::size_t, std::size_t> compressedImageDataOffsetSizeFor(const T& image, const Math::Vector<dimensions, Int>& size) {
CORRADE_INTERNAL_ASSERT(image.storage().compressedBlockSize().product() && image.storage().compressedBlockDataSize());
Math::Vector3<std::size_t> offset, blockCount;
std::size_t blockDataSize;
@ -458,14 +457,15 @@ namespace Implementation {
}
/* Used in image query functions */
template<std::size_t dimensions, class T> std::size_t compressedImageDataSizeFor(const T& image, const Math::Vector<dimensions, Int>& size, std::size_t dataSize) {
auto r = compressedImageDataOffsetSizeFor(image, size, dataSize);
template<std::size_t dimensions, class T> std::size_t compressedImageDataSizeFor(const T& image, const Math::Vector<dimensions, Int>& size) {
auto r = compressedImageDataOffsetSizeFor(image, size);
return r.first + r.second;
}
/* Use in compressed image upload functions */
template<class T> 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<class T> std::size_t occupiedCompressedImageDataSize(const T&, std::size_t dataSize) {

8
src/Magnum/RectangleTexture.h

@ -442,6 +442,10 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture {
* See @ref Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, 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<dimensions, Int>&, 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);

12
src/Magnum/Test/CubeMapTextureArrayGLTest.cpp

@ -1032,14 +1032,14 @@ void CubeMapTextureArrayGLTest::compressedSubImageQuery() {
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_cube_map_array>())
CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported."));
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported."));
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::get_texture_sub_image>())
CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported."));
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::compressed_texture_pixel_storage>())
if(CompressedSubPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::compressed_texture_pixel_storage>())
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
if(CompressedSubPixelStorageData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
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<Extensions::GL::ARB::texture_cube_map_array>())
CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported."));
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported."));
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::get_texture_sub_image>())
CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported."));
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::compressed_texture_pixel_storage>())
if(CompressedSubPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::compressed_texture_pixel_storage>())
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
if(CompressedSubPixelStorageData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported."));
CubeMapTextureArray texture;
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 12, 6})

4
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<Extensions::GL::ARB::compressed_texture_pixel_storage>())
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
if(CompressedPixelStorageData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
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<Extensions::GL::ARB::compressed_texture_pixel_storage>())
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
if(CompressedPixelStorageData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported."));
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{12})

7
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<std::size_t, std::size_t>{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<std::size_t, std::size_t>{16*4*4 + 16*2 + 16, 16}));
}
#endif

4
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<Extensions::GL::ARB::compressed_texture_pixel_storage>())
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
if(CompressedPixelStorage2DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
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<Extensions::GL::ARB::compressed_texture_pixel_storage>())
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
if(CompressedPixelStorage2DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported."));
Texture2DArray texture;
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 4, 4})

8
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<Extensions::GL::ARB::compressed_texture_pixel_storage>())
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
if(CompressedPixelStorage2DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
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<Extensions::GL::ARB::compressed_texture_pixel_storage>())
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
if(CompressedPixelStorage2DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
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<Extensions::GL::ARB::compressed_texture_pixel_storage>())
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
if(CompressedPixelStorage3DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
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<Extensions::GL::ARB::compressed_texture_pixel_storage>())
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
if(CompressedPixelStorage3DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported."));
Texture3D texture;
texture.setStorage(1, TextureFormat::CompressedRGBABptcUnorm, {12, 4, 4})

19
src/Magnum/Texture.h

@ -129,7 +129,7 @@ template<UnsignedInt dimensions> 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<UnsignedInt dimensions> 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<UnsignedInt dimensions> 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<UnsignedInt dimensions> class Texture: public AbstractTexture {
* See @ref compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, 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.
*/

8
src/Magnum/TextureArray.h

@ -606,6 +606,10 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* See @ref Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, 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<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* See @ref Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, 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.
*/

Loading…
Cancel
Save