Browse Source

Compressed image support, part 9: texture upload/download tests.

pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
2419b5f90c
  1. 222
      src/Magnum/Test/CubeMapTextureArrayGLTest.cpp
  2. 227
      src/Magnum/Test/CubeMapTextureGLTest.cpp
  3. 24
      src/Magnum/Test/RectangleTextureGLTest.cpp
  4. 200
      src/Magnum/Test/TextureArrayGLTest.cpp
  5. 337
      src/Magnum/Test/TextureGLTest.cpp

222
src/Magnum/Test/CubeMapTextureArrayGLTest.cpp

@ -57,9 +57,13 @@ struct CubeMapTextureArrayGLTest: AbstractOpenGLTester {
void storage();
void image();
void compressedImage();
void imageBuffer();
void compressedImageBuffer();
void subImage();
void compressedSubImage();
void subImageBuffer();
void compressedSubImageBuffer();
#ifndef MAGNUM_TARGET_GLES
void subImageQuery();
void subImageQueryBuffer();
@ -90,9 +94,13 @@ CubeMapTextureArrayGLTest::CubeMapTextureArrayGLTest() {
&CubeMapTextureArrayGLTest::storage,
&CubeMapTextureArrayGLTest::image,
&CubeMapTextureArrayGLTest::compressedImage,
&CubeMapTextureArrayGLTest::imageBuffer,
&CubeMapTextureArrayGLTest::compressedImageBuffer,
&CubeMapTextureArrayGLTest::subImage,
&CubeMapTextureArrayGLTest::compressedSubImage,
&CubeMapTextureArrayGLTest::subImageBuffer,
&CubeMapTextureArrayGLTest::compressedSubImageBuffer,
#ifndef MAGNUM_TARGET_GLES
&CubeMapTextureArrayGLTest::subImageQuery,
&CubeMapTextureArrayGLTest::subImageQueryBuffer,
@ -349,6 +357,24 @@ namespace {
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f
};
/* Just 4x4 0x00 - 0x3f compressed using RGBA DXT3 by the driver, repeated
six times */
constexpr UnsignedByte CompressedData[] = {
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2
};
}
void CubeMapTextureArrayGLTest::image() {
@ -379,6 +405,35 @@ void CubeMapTextureArrayGLTest::image() {
#endif
}
void CubeMapTextureArrayGLTest::compressedImage() {
#ifndef MAGNUM_TARGET_GLES
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."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_cube_map_array>())
CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported."));
#endif
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
CubeMapTextureArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
{4, 4, 6}, CompressedData});
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedImage3D image = texture.compressedImage(0, {});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6}));
CORRADE_COMPARE_AS(
(Containers::ArrayView<const UnsignedByte>{image.data<UnsignedByte>(), image.data().size()}),
Containers::ArrayView<const UnsignedByte>{CompressedData}, TestSuite::Compare::Container);
#endif
}
void CubeMapTextureArrayGLTest::imageBuffer() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_cube_map_array>())
@ -406,9 +461,41 @@ void CubeMapTextureArrayGLTest::imageBuffer() {
#endif
}
void CubeMapTextureArrayGLTest::compressedImageBuffer() {
#ifndef MAGNUM_TARGET_GLES
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."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_cube_map_array>())
CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported."));
#endif
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
CubeMapTextureArray texture;
texture.setCompressedImage(0, CompressedBufferImage3D{CompressedColorFormat::RGBAS3tcDxt3,
{4, 4, 6}, CompressedData, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
CompressedBufferImage3D image = texture.compressedImage(0, {}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6}));
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{CompressedData}, TestSuite::Compare::Container);
#endif
}
namespace {
constexpr UnsignedByte Zero[4*4*4*6] = {};
/* Just 12x12x6 zeros compressed using RGBA DXT3 by the driver */
constexpr UnsignedByte CompressedZero[9*16*6] = {};
constexpr UnsignedByte SubData[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
@ -423,6 +510,18 @@ namespace {
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f
};
/* Just 4x4x4 0x00 - 0xff compressed using RGBA DXT3 by the driver */
constexpr UnsignedByte CompressedSubData[] = {
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
68, 84, 85, 101, 102, 118, 119, 119,
239, 123, 8, 66, 213, 255, 170, 2,
136, 136, 153, 153, 170, 170, 187, 187,
247, 189, 16, 132, 213, 255, 170, 2,
203, 204, 220, 221, 237, 238, 254, 255,
255, 255, 24, 190, 213, 255, 170, 2
};
constexpr UnsignedByte SubDataComplete[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -454,6 +553,67 @@ namespace {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* Combination of CompressedZero and CompressedSubData */
constexpr UnsignedByte CompressedSubDataComplete[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
68, 84, 85, 101, 102, 118, 119, 119,
239, 123, 8, 66, 213, 255, 170, 2,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
136, 136, 153, 153, 170, 170, 187, 187,
247, 189, 16, 132, 213, 255, 170, 2,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
203, 204, 220, 221, 237, 238, 254, 255,
255, 255, 24, 190, 213, 255, 170, 2,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
}
void CubeMapTextureArrayGLTest::subImage() {
@ -486,6 +646,37 @@ void CubeMapTextureArrayGLTest::subImage() {
#endif
}
void CubeMapTextureArrayGLTest::compressedSubImage() {
#ifndef MAGNUM_TARGET_GLES
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."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_cube_map_array>())
CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported."));
#endif
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
CubeMapTextureArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
{12, 12, 6}, CompressedZero});
texture.setCompressedSubImage(0, {4, 4, 1},
CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3, Vector3i{4}, CompressedSubData});
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedImage3D image = texture.compressedImage(0, {});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector3i{12, 12, 6}));
CORRADE_COMPARE_AS(
(Containers::ArrayView<const UnsignedByte>{image.data<UnsignedByte>(), image.data().size()}),
Containers::ArrayView<const UnsignedByte>{CompressedSubDataComplete}, TestSuite::Compare::Container);
#endif
}
void CubeMapTextureArrayGLTest::subImageBuffer() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_cube_map_array>())
@ -515,6 +706,37 @@ void CubeMapTextureArrayGLTest::subImageBuffer() {
#endif
}
void CubeMapTextureArrayGLTest::compressedSubImageBuffer() {
#ifndef MAGNUM_TARGET_GLES
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."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_cube_map_array>())
CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported."));
#endif
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
CubeMapTextureArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
{12, 12, 6}, CompressedZero});
texture.setCompressedSubImage(0, {4, 4, 1},
CompressedBufferImage3D(CompressedColorFormat::RGBAS3tcDxt3, Vector3i{4}, CompressedSubData, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
CompressedBufferImage3D image = texture.compressedImage(0, {}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector3i{12, 12, 6}));
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{CompressedSubDataComplete}, TestSuite::Compare::Container);
#endif
}
#ifndef MAGNUM_TARGET_GLES
void CubeMapTextureArrayGLTest::subImageQuery() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_cube_map_array>())

227
src/Magnum/Test/CubeMapTextureGLTest.cpp

@ -70,16 +70,22 @@ struct CubeMapTextureGLTest: AbstractOpenGLTester {
#ifndef MAGNUM_TARGET_GLES
void imageFull();
void compressedImageFull();
void imageFullBuffer();
void compressedImageFullBuffer();
#endif
void image();
void compressedImage();
#ifndef MAGNUM_TARGET_GLES2
void imageBuffer();
void compressedImageBuffer();
#endif
void subImage();
void compressedSubImage();
#ifndef MAGNUM_TARGET_GLES2
void subImageBuffer();
void compressedSubImageBuffer();
#endif
#ifndef MAGNUM_TARGET_GLES
void subImageQuery();
@ -121,20 +127,26 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
#ifndef MAGNUM_TARGET_GLES
&CubeMapTextureGLTest::imageFull,
&CubeMapTextureGLTest::compressedImageFull,
&CubeMapTextureGLTest::imageFullBuffer,
&CubeMapTextureGLTest::compressedImageFullBuffer,
#endif
&CubeMapTextureGLTest::image,
&CubeMapTextureGLTest::compressedImage,
#ifndef MAGNUM_TARGET_GLES2
&CubeMapTextureGLTest::imageBuffer,
#endif
#ifndef MAGNUM_TARGET_GLES
&CubeMapTextureGLTest::subImageQuery,
&CubeMapTextureGLTest::subImageQueryBuffer,
&CubeMapTextureGLTest::compressedImageBuffer,
#endif
&CubeMapTextureGLTest::subImage,
&CubeMapTextureGLTest::compressedSubImage,
#ifndef MAGNUM_TARGET_GLES2
&CubeMapTextureGLTest::subImageBuffer,
&CubeMapTextureGLTest::compressedSubImageBuffer,
#endif
#ifndef MAGNUM_TARGET_GLES
&CubeMapTextureGLTest::subImageQuery,
&CubeMapTextureGLTest::subImageQueryBuffer,
#endif
&CubeMapTextureGLTest::generateMipmap,
@ -384,6 +396,24 @@ namespace {
0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x5b,
0x5c, 0x5d, 0x5e, 0x5f };
/* Just 4x4 0x00 - 0x3f compressed using RGBA DXT3 by the driver, repeated
six times */
constexpr UnsignedByte CompressedDataFull[] = {
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2
};
}
#ifndef MAGNUM_TARGET_GLES
@ -407,6 +437,28 @@ void CubeMapTextureGLTest::imageFull() {
Containers::ArrayView<const UnsignedByte>{DataFull}, TestSuite::Compare::Container);
}
void CubeMapTextureGLTest::compressedImageFull() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::direct_state_access>())
CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::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."));
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4})
.setCompressedSubImage(0, {}, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3, {4, 4, 6}, CompressedDataFull});
MAGNUM_VERIFY_NO_ERROR();
CompressedImage3D image = texture.compressedImage(0, {});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6}));
CORRADE_COMPARE_AS(
Containers::ArrayView<const UnsignedByte>(image.data<UnsignedByte>(), image.data().size()),
Containers::ArrayView<const UnsignedByte>{CompressedDataFull}, TestSuite::Compare::Container);
}
void CubeMapTextureGLTest::imageFullBuffer() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::direct_state_access>())
CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported."));
@ -425,6 +477,27 @@ void CubeMapTextureGLTest::imageFullBuffer() {
const auto imageData = image.buffer().data<UnsignedByte>();
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{DataFull}, TestSuite::Compare::Container);
}
void CubeMapTextureGLTest::compressedImageFullBuffer() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::direct_state_access>())
CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::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."));
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4})
.setCompressedSubImage(0, {}, CompressedBufferImage3D{CompressedColorFormat::RGBAS3tcDxt3, {4, 4, 6}, CompressedDataFull, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
CompressedBufferImage3D image = texture.compressedImage(0, {}, BufferUsage::StaticRead);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6}));
const auto imageData = image.buffer().data<UnsignedByte>();
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{CompressedDataFull}, TestSuite::Compare::Container);
}
#endif
namespace {
@ -432,6 +505,12 @@ namespace {
0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f };
/* Just 4x4 0x00 - 0x3f compressed using RGBA DXT3 by the driver */
constexpr UnsignedByte CompressedData[] = {
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2
};
}
void CubeMapTextureGLTest::image() {
@ -454,6 +533,33 @@ void CubeMapTextureGLTest::image() {
#endif
}
void CubeMapTextureGLTest::compressedImage() {
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
CubeMapTexture texture;
texture.setCompressedImage(CubeMapTexture::Coordinate::PositiveX, 0,
CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3, Vector2i{4}, CompressedData});
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedImage2D image = texture.compressedImage(CubeMapTexture::Coordinate::PositiveX, 0, {});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector2i{4});
CORRADE_COMPARE_AS(
(Containers::ArrayView<const UnsignedByte>{image.data<UnsignedByte>(), image.data().size()}),
Containers::ArrayView<const UnsignedByte>{CompressedData}, TestSuite::Compare::Container);
#endif
}
#ifndef MAGNUM_TARGET_GLES2
void CubeMapTextureGLTest::imageBuffer() {
CubeMapTexture texture;
@ -473,16 +579,71 @@ void CubeMapTextureGLTest::imageBuffer() {
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{Data}, TestSuite::Compare::Container);
#endif
}
void CubeMapTextureGLTest::compressedImageBuffer() {
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
CubeMapTexture texture;
texture.setCompressedImage(CubeMapTexture::Coordinate::PositiveX, 0,
CompressedBufferImage2D{CompressedColorFormat::RGBAS3tcDxt3, Vector2i{4}, CompressedData, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedBufferImage2D image = texture.compressedImage(CubeMapTexture::Coordinate::PositiveX, 0,
{}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector2i{4});
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{CompressedData}, TestSuite::Compare::Container);
#endif
}
#endif
namespace {
constexpr UnsignedByte Zero[4*4*4] = {};
/* Just 12x12 zeros compressed using RGBA DXT3 by the driver */
constexpr UnsignedByte CompressedZero[9*16] = {};
constexpr UnsignedByte SubDataComplete[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0,
0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* Combination of CompressedZero and CompressedData */
constexpr UnsignedByte CompressedSubDataComplete[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
}
void CubeMapTextureGLTest::subImage() {
@ -507,6 +668,35 @@ void CubeMapTextureGLTest::subImage() {
#endif
}
void CubeMapTextureGLTest::compressedSubImage() {
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
CubeMapTexture texture;
texture.setCompressedImage(CubeMapTexture::Coordinate::PositiveX, 0,
CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
texture.setCompressedSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i{4},
CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3, Vector2i{4}, CompressedData});
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedImage2D image = texture.compressedImage(CubeMapTexture::Coordinate::PositiveX, 0, {});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector2i{12});
CORRADE_COMPARE_AS(
(Containers::ArrayView<const UnsignedByte>{image.data<UnsignedByte>(), image.data().size()}),
Containers::ArrayView<const UnsignedByte>{CompressedSubDataComplete}, TestSuite::Compare::Container);
#endif
}
#ifndef MAGNUM_TARGET_GLES2
void CubeMapTextureGLTest::subImageBuffer() {
CubeMapTexture texture;
@ -528,6 +718,35 @@ void CubeMapTextureGLTest::subImageBuffer() {
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{SubDataComplete}, TestSuite::Compare::Container);
#endif
}
void CubeMapTextureGLTest::compressedSubImageBuffer() {
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
CubeMapTexture texture;
texture.setCompressedImage(CubeMapTexture::Coordinate::PositiveX, 0,
CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
texture.setCompressedSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i{4},
CompressedBufferImage2D{CompressedColorFormat::RGBAS3tcDxt3, Vector2i{4}, CompressedData, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedBufferImage2D image = texture.compressedImage(CubeMapTexture::Coordinate::PositiveX, 0,
{}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector2i{12});
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{CompressedSubDataComplete}, TestSuite::Compare::Container);
#endif
}
#endif
#ifndef MAGNUM_TARGET_GLES

24
src/Magnum/Test/RectangleTextureGLTest.cpp

@ -56,9 +56,13 @@ struct RectangleTextureGLTest: AbstractOpenGLTester {
void storage();
void image();
void compressedImage();
void imageBuffer();
void compressedImageBuffer();
void subImage();
void compressedSubImage();
void subImageBuffer();
void compressedSubImageBuffer();
void subImageQuery();
void subImageQueryBuffer();
@ -82,10 +86,14 @@ RectangleTextureGLTest::RectangleTextureGLTest() {
&RectangleTextureGLTest::storage,
&RectangleTextureGLTest::image,
&RectangleTextureGLTest::compressedImage,
&RectangleTextureGLTest::imageBuffer,
&RectangleTextureGLTest::compressedImageBuffer,
&RectangleTextureGLTest::subImage,
&RectangleTextureGLTest::compressedSubImage,
&RectangleTextureGLTest::subImageBuffer,
&RectangleTextureGLTest::compressedSubImageBuffer,
&RectangleTextureGLTest::subImageQuery,
&RectangleTextureGLTest::subImageQueryBuffer,
@ -267,6 +275,10 @@ void RectangleTextureGLTest::image() {
Containers::ArrayView<const UnsignedByte>{Data}, TestSuite::Compare::Container);
}
void RectangleTextureGLTest::compressedImage() {
CORRADE_SKIP("No rectangle texture compression format exists.");
}
void RectangleTextureGLTest::imageBuffer() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
@ -286,6 +298,10 @@ void RectangleTextureGLTest::imageBuffer() {
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{Data}, TestSuite::Compare::Container);
}
void RectangleTextureGLTest::compressedImageBuffer() {
CORRADE_SKIP("No rectangle texture compression format exists.");
}
namespace {
constexpr UnsignedByte Zero[4*4*4] = {};
@ -319,6 +335,10 @@ void RectangleTextureGLTest::subImage() {
Containers::ArrayView<const UnsignedByte>{SubDataComplete}, TestSuite::Compare::Container);
}
void RectangleTextureGLTest::compressedSubImage() {
CORRADE_SKIP("No rectangle texture compression format exists.");
}
void RectangleTextureGLTest::subImageBuffer() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
@ -340,6 +360,10 @@ void RectangleTextureGLTest::subImageBuffer() {
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{SubDataComplete}, TestSuite::Compare::Container);
}
void RectangleTextureGLTest::compressedSubImageBuffer() {
CORRADE_SKIP("No rectangle texture compression format exists.");
}
void RectangleTextureGLTest::subImageQuery() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));

200
src/Magnum/Test/TextureArrayGLTest.cpp

@ -100,21 +100,29 @@ struct TextureArrayGLTest: AbstractOpenGLTester {
#ifndef MAGNUM_TARGET_GLES
void image1D();
void compressedImage1D();
void image1DBuffer();
void compressedImage1DBuffer();
#endif
#ifndef MAGNUM_TARGET_GLES2
void image2D();
void compressedImage2D();
void image2DBuffer();
void compressedImage2DBuffer();
#endif
#ifndef MAGNUM_TARGET_GLES
void subImage1D();
void compressedSubImage1D();
void subImage1DBuffer();
void compressedSubImage1DBuffer();
void subImage1DQuery();
void subImage1DQueryBuffer();
#endif
void subImage2D();
void compressedSubImage2D();
void subImage2DBuffer();
void compressedSubImage2DBuffer();
#ifndef MAGNUM_TARGET_GLES
void subImage2DQuery();
void subImage2DQueryBuffer();
@ -197,19 +205,27 @@ TextureArrayGLTest::TextureArrayGLTest() {
#ifndef MAGNUM_TARGET_GLES
&TextureArrayGLTest::image1D,
&TextureArrayGLTest::compressedImage1D,
&TextureArrayGLTest::image1DBuffer,
&TextureArrayGLTest::compressedImage1DBuffer,
#endif
&TextureArrayGLTest::image2D,
&TextureArrayGLTest::compressedImage2D,
&TextureArrayGLTest::image2DBuffer,
&TextureArrayGLTest::compressedImage2DBuffer,
#ifndef MAGNUM_TARGET_GLES
&TextureArrayGLTest::subImage1D,
&TextureArrayGLTest::compressedSubImage1D,
&TextureArrayGLTest::subImage1DBuffer,
&TextureArrayGLTest::compressedSubImage1DBuffer,
&TextureArrayGLTest::subImage1DQuery,
&TextureArrayGLTest::subImage1DQueryBuffer,
#endif
&TextureArrayGLTest::subImage2D,
&TextureArrayGLTest::compressedSubImage2D,
&TextureArrayGLTest::subImage2DBuffer,
&TextureArrayGLTest::compressedSubImage2DBuffer,
#ifndef MAGNUM_TARGET_GLES
&TextureArrayGLTest::subImage2DQuery,
&TextureArrayGLTest::subImage2DQueryBuffer,
@ -665,6 +681,10 @@ void TextureArrayGLTest::image1D() {
Containers::ArrayView<const UnsignedByte>{Data1D}, TestSuite::Compare::Container);
}
void TextureArrayGLTest::compressedImage1D() {
CORRADE_SKIP("No 1D texture compression format exists.");
}
void TextureArrayGLTest::image1DBuffer() {
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_array>())
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported."));
@ -683,6 +703,10 @@ void TextureArrayGLTest::image1DBuffer() {
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{Data1D}, TestSuite::Compare::Container);
}
void TextureArrayGLTest::compressedImage1DBuffer() {
CORRADE_SKIP("No 1D texture compression format exists.");
}
#endif
namespace {
@ -694,6 +718,14 @@ namespace {
0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b,
0x1c, 0x1d, 0x1e, 0x1f };
/* Just 4x4x2 0x00 - 0x7f compressed using RGBA DXT3 by the driver */
constexpr UnsignedByte CompressedData2D[] = {
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
68, 84, 85, 101, 102, 118, 119, 119,
239, 123, 8, 66, 213, 255, 170, 2
};
}
void TextureArrayGLTest::image2D() {
@ -721,6 +753,37 @@ void TextureArrayGLTest::image2D() {
#endif
}
void TextureArrayGLTest::compressedImage2D() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_array>())
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported."));
#endif
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
Texture2DArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
{4, 4, 2}, CompressedData2D});
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedImage3D image = texture.compressedImage(0, {});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 2}));
CORRADE_COMPARE_AS(
(Containers::ArrayView<const UnsignedByte>{image.data<UnsignedByte>(), image.data().size()}),
Containers::ArrayView<const UnsignedByte>{CompressedData2D}, TestSuite::Compare::Container);
#endif
}
void TextureArrayGLTest::image2DBuffer() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_array>())
@ -745,6 +808,36 @@ void TextureArrayGLTest::image2DBuffer() {
#endif
}
void TextureArrayGLTest::compressedImage2DBuffer() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_array>())
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported."));
#endif
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
Texture2DArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
{4, 4, 2}, CompressedData2D});
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedBufferImage3D image = texture.compressedImage(0, {}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 2}));
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{CompressedData2D}, TestSuite::Compare::Container);
#endif
}
namespace {
constexpr UnsignedByte Zero1D[4*4*4] = {};
constexpr UnsignedByte SubData1DComplete[] = {
@ -778,6 +871,10 @@ void TextureArrayGLTest::subImage1D() {
Containers::ArrayView<const UnsignedByte>{SubData1DComplete}, TestSuite::Compare::Container);
}
void TextureArrayGLTest::compressedSubImage1D() {
CORRADE_SKIP("No 1D texture compression format exists.");
}
void TextureArrayGLTest::subImage1DBuffer() {
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_array>())
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported."));
@ -799,6 +896,10 @@ void TextureArrayGLTest::subImage1DBuffer() {
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{SubData1DComplete}, TestSuite::Compare::Container);
}
void TextureArrayGLTest::compressedSubImage1DBuffer() {
CORRADE_SKIP("No 1D texture compression format exists.");
}
void TextureArrayGLTest::subImage1DQuery() {
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_array>())
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported."));
@ -844,6 +945,10 @@ void TextureArrayGLTest::subImage1DQueryBuffer() {
namespace {
constexpr UnsignedByte Zero2D[4*4*4*4] = {};
/* Just 12x4x4 zeros compressed using RGBA DXT3 by the driver */
constexpr UnsignedByte CompressedZero2D[3*4*16] = {};
constexpr UnsignedByte SubData2DComplete[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -865,6 +970,37 @@ namespace {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* Combination of CompressedZero2D and CompressedData2D */
constexpr UnsignedByte CompressedSubData2DComplete[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
68, 84, 85, 101, 102, 118, 119, 119,
239, 123, 8, 66, 213, 255, 170, 2,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
}
void TextureArrayGLTest::subImage2D() {
@ -893,6 +1029,38 @@ void TextureArrayGLTest::subImage2D() {
#endif
}
void TextureArrayGLTest::compressedSubImage2D() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_array>())
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported."));
#endif
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
Texture2DArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
Vector3i{12, 4, 4}, CompressedZero2D});
texture.setCompressedSubImage(0, {4, 0, 1}, CompressedImageView3D(CompressedColorFormat::RGBAS3tcDxt3,
{4, 4, 2}, CompressedData2D));
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedImage3D image = texture.compressedImage(0, {});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector3i{12, 4, 4}));
CORRADE_COMPARE_AS(
Containers::ArrayView<const UnsignedByte>(image.data<UnsignedByte>(), image.data().size()), Containers::ArrayView<const UnsignedByte>{CompressedSubData2DComplete}, TestSuite::Compare::Container);
#endif
}
void TextureArrayGLTest::subImage2DBuffer() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_array>())
@ -919,6 +1087,38 @@ void TextureArrayGLTest::subImage2DBuffer() {
#endif
}
void TextureArrayGLTest::compressedSubImage2DBuffer() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_array>())
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported."));
#endif
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
Texture2DArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
Vector3i{12, 4, 4}, CompressedZero2D});
texture.setCompressedSubImage(0, {4, 0, 1}, CompressedImageView3D(CompressedColorFormat::RGBAS3tcDxt3,
{4, 4, 2}, CompressedData2D));
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedBufferImage3D image = texture.compressedImage(0, {}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector3i{12, 4, 4}));
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{CompressedSubData2DComplete}, TestSuite::Compare::Container);
#endif
}
#ifndef MAGNUM_TARGET_GLES
void TextureArrayGLTest::subImage2DQuery() {
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_array>())

337
src/Magnum/Test/TextureGLTest.cpp

@ -114,36 +114,48 @@ struct TextureGLTest: AbstractOpenGLTester {
#ifndef MAGNUM_TARGET_GLES
void image1D();
void compressedImage1D();
#endif
#ifndef MAGNUM_TARGET_GLES2
void image1DBuffer();
void compressedImage1DBuffer();
#endif
void image2D();
void compressedImage2D();
#ifndef MAGNUM_TARGET_GLES2
void image2DBuffer();
void compressedImage2DBuffer();
#endif
void image3D();
void compressedImage3D();
#ifndef MAGNUM_TARGET_GLES2
void image3DBuffer();
void compressedImage3DBuffer();
#endif
#ifndef MAGNUM_TARGET_GLES
void subImage1D();
void compressedSubImage1D();
void subImage1DBuffer();
void compressedSubImage1DBuffer();
void subImage1DQuery();
void subImage1DQueryBuffer();
#endif
void subImage2D();
void compressedSubImage2D();
#ifndef MAGNUM_TARGET_GLES2
void subImage2DBuffer();
void compressedSubImage2DBuffer();
#endif
#ifndef MAGNUM_TARGET_GLES
void subImage2DQuery();
void subImage2DQueryBuffer();
#endif
void subImage3D();
void compressedSubImage3D();
#ifndef MAGNUM_TARGET_GLES2
void subImage3DBuffer();
void compressedSubImage3DBuffer();
#endif
#ifndef MAGNUM_TARGET_GLES
void subImage3DQuery();
@ -243,34 +255,46 @@ TextureGLTest::TextureGLTest() {
#ifndef MAGNUM_TARGET_GLES
&TextureGLTest::image1D,
&TextureGLTest::compressedImage1D,
&TextureGLTest::image1DBuffer,
&TextureGLTest::compressedImage1DBuffer,
#endif
&TextureGLTest::image2D,
&TextureGLTest::compressedImage2D,
#ifndef MAGNUM_TARGET_GLES2
&TextureGLTest::image2DBuffer,
&TextureGLTest::compressedImage2DBuffer,
#endif
&TextureGLTest::image3D,
&TextureGLTest::compressedImage3D,
#ifndef MAGNUM_TARGET_GLES2
&TextureGLTest::image3DBuffer,
&TextureGLTest::compressedImage3DBuffer,
#endif
#ifndef MAGNUM_TARGET_GLES
&TextureGLTest::subImage1D,
&TextureGLTest::compressedSubImage1D,
&TextureGLTest::subImage1DBuffer,
&TextureGLTest::compressedSubImage1DBuffer,
&TextureGLTest::subImage1DQuery,
&TextureGLTest::subImage1DQueryBuffer,
#endif
&TextureGLTest::subImage2D,
&TextureGLTest::compressedSubImage2D,
#ifndef MAGNUM_TARGET_GLES2
&TextureGLTest::subImage2DBuffer,
&TextureGLTest::compressedSubImage2DBuffer,
#endif
#ifndef MAGNUM_TARGET_GLES
&TextureGLTest::subImage2DQuery,
&TextureGLTest::subImage2DQueryBuffer,
#endif
&TextureGLTest::subImage3D,
&TextureGLTest::compressedSubImage3D,
#ifndef MAGNUM_TARGET_GLES2
&TextureGLTest::subImage3DBuffer,
&TextureGLTest::compressedSubImage3DBuffer,
#endif
#ifndef MAGNUM_TARGET_GLES
&TextureGLTest::subImage3DQuery,
@ -897,6 +921,10 @@ void TextureGLTest::image1D() {
Containers::ArrayView<const UnsignedByte>{Data1D}, TestSuite::Compare::Container);
}
void TextureGLTest::compressedImage1D() {
CORRADE_SKIP("No 1D texture compression format exists.");
}
void TextureGLTest::image1DBuffer() {
Texture1D texture;
texture.setImage(0, TextureFormat::RGBA8,
@ -912,6 +940,10 @@ void TextureGLTest::image1DBuffer() {
CORRADE_COMPARE(image.size(), 2);
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{Data1D}, TestSuite::Compare::Container);
}
void TextureGLTest::compressedImage1DBuffer() {
CORRADE_SKIP("No 1D texture compression format exists.");
}
#endif
namespace {
@ -919,6 +951,12 @@ namespace {
0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f };
/* Just 4x4 0x00 - 0x3f compressed using RGBA DXT3 by the driver */
constexpr UnsignedByte CompressedData2D[] = {
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2
};
}
void TextureGLTest::image2D() {
@ -941,6 +979,34 @@ void TextureGLTest::image2D() {
#endif
}
void TextureGLTest::compressedImage2D() {
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
Texture2D texture;
texture.setCompressedImage(0, CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3,
Vector2i{4}, CompressedData2D});
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedImage2D image = texture.compressedImage(0, {});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector2i{4});
CORRADE_COMPARE_AS(
(Containers::ArrayView<const UnsignedByte>{image.data<UnsignedByte>(), image.data().size()}),
Containers::ArrayView<const UnsignedByte>{CompressedData2D}, TestSuite::Compare::Container);
#endif
}
#ifndef MAGNUM_TARGET_GLES2
void TextureGLTest::image2DBuffer() {
Texture2D texture;
@ -960,6 +1026,32 @@ void TextureGLTest::image2DBuffer() {
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{Data2D}, TestSuite::Compare::Container);
#endif
}
void TextureGLTest::compressedImage2DBuffer() {
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
Texture2D texture;
texture.setCompressedImage(0, CompressedBufferImage2D{CompressedColorFormat::RGBAS3tcDxt3,
Vector2i{4}, CompressedData2D, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedBufferImage2D image = texture.compressedImage(0, {}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector2i{4});
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{CompressedData2D}, TestSuite::Compare::Container);
#endif
}
#endif
namespace {
@ -971,6 +1063,18 @@ namespace {
0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b,
0x1c, 0x1d, 0x1e, 0x1f };
/* Just 4x4x4 0x00 - 0xff compressed using RGBA DXT3 by the driver */
constexpr UnsignedByte CompressedData3D[] = {
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
68, 84, 85, 101, 102, 118, 119, 119,
239, 123, 8, 66, 213, 255, 170, 2,
136, 136, 153, 153, 170, 170, 187, 187,
247, 189, 16, 132, 213, 255, 170, 2,
203, 204, 220, 221, 237, 238, 254, 255,
255, 255, 24, 190, 213, 255, 170, 2
};
}
void TextureGLTest::image3D() {
@ -998,6 +1102,37 @@ void TextureGLTest::image3D() {
#endif
}
void TextureGLTest::compressedImage3D() {
#ifdef MAGNUM_TARGET_GLES2
if(!Context::current()->isExtensionSupported<Extensions::GL::OES::texture_3D>())
CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported."));
#endif
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
Texture3D texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
Vector3i{4}, CompressedData3D});
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedImage3D image = texture.compressedImage(0, {});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector3i{4});
CORRADE_COMPARE_AS(
(Containers::ArrayView<const UnsignedByte>{image.data<UnsignedByte>(), image.data().size()}),
Containers::ArrayView<const UnsignedByte>{CompressedData3D}, TestSuite::Compare::Container);
#endif
}
#ifndef MAGNUM_TARGET_GLES2
void TextureGLTest::image3DBuffer() {
Texture3D texture;
@ -1017,6 +1152,32 @@ void TextureGLTest::image3DBuffer() {
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{Data3D}, TestSuite::Compare::Container);
#endif
}
void TextureGLTest::compressedImage3DBuffer() {
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
Texture3D texture;
texture.setCompressedImage(0, CompressedBufferImage3D{CompressedColorFormat::RGBAS3tcDxt3,
Vector3i{4}, CompressedData3D, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedBufferImage3D image = texture.compressedImage(0, {}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector3i{4});
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{CompressedData3D}, TestSuite::Compare::Container);
#endif
}
#endif
namespace {
@ -1046,6 +1207,10 @@ void TextureGLTest::subImage1D() {
Containers::ArrayView<const UnsignedByte>{SubData1DComplete}, TestSuite::Compare::Container);
}
void TextureGLTest::compressedSubImage1D() {
CORRADE_SKIP("No 1D texture compression format exists.");
}
void TextureGLTest::subImage1DBuffer() {
Texture1D texture;
texture.setImage(0, TextureFormat::RGBA8,
@ -1064,6 +1229,10 @@ void TextureGLTest::subImage1DBuffer() {
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{SubData1DComplete}, TestSuite::Compare::Container);
}
void TextureGLTest::compressedSubImage1DBuffer() {
CORRADE_SKIP("No 1D texture compression format exists.");
}
void TextureGLTest::subImage1DQuery() {
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."));
@ -1105,12 +1274,26 @@ void TextureGLTest::subImage1DQueryBuffer() {
namespace {
constexpr UnsignedByte Zero2D[4*4*4] = {};
/* Just 12x4 zeros compressed using RGBA DXT3 by the driver */
constexpr UnsignedByte CompressedZero2D[3*16] = {};
constexpr UnsignedByte SubData2DComplete[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0,
0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* Combination of CompressedZero2D and CompressedData2D */
constexpr UnsignedByte CompressedSubData2DComplete[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
}
void TextureGLTest::subImage2D() {
@ -1135,6 +1318,35 @@ void TextureGLTest::subImage2D() {
#endif
}
void TextureGLTest::compressedSubImage2D() {
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
Texture2D texture;
texture.setCompressedImage(0, CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3,
{12, 4}, CompressedZero2D});
texture.setCompressedSubImage(0, {4, 0}, CompressedImageView2D(CompressedColorFormat::RGBAS3tcDxt3,
Vector2i{4}, CompressedData2D));
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedImage2D image = texture.compressedImage(0, {});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector2i{12, 4}));
CORRADE_COMPARE_AS(
(Containers::ArrayView<const UnsignedByte>{image.data<UnsignedByte>(), image.data().size()}),
Containers::ArrayView<const UnsignedByte>{CompressedSubData2DComplete}, TestSuite::Compare::Container);
#endif
}
#ifndef MAGNUM_TARGET_GLES2
void TextureGLTest::subImage2DBuffer() {
Texture2D texture;
@ -1156,6 +1368,34 @@ void TextureGLTest::subImage2DBuffer() {
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{SubData2DComplete}, TestSuite::Compare::Container);
#endif
}
void TextureGLTest::compressedSubImage2DBuffer() {
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
Texture2D texture;
texture.setCompressedImage(0, CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3,
{12, 4}, CompressedZero2D});
texture.setCompressedSubImage(0, {4, 0}, CompressedBufferImage2D{CompressedColorFormat::RGBAS3tcDxt3,
Vector2i{4}, CompressedData2D, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedBufferImage2D image = texture.compressedImage(0, {}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector2i{12, 4}));
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{CompressedSubData2DComplete}, TestSuite::Compare::Container);
#endif
}
#endif
#ifndef MAGNUM_TARGET_GLES
@ -1200,6 +1440,10 @@ void TextureGLTest::subImage2DQueryBuffer() {
namespace {
constexpr UnsignedByte Zero3D[4*4*4*4] = {};
/* Just 12x4x4 zeros compressed using RGBA DXT3 by the driver */
constexpr UnsignedByte CompressedZero3D[3*4*16] = {};
constexpr UnsignedByte SubData3DComplete[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -1221,6 +1465,38 @@ namespace {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* Combination of CompressedZero3D and CompressedData3D. Note that, in
contrast to array textures, the data are ordered in "cubes" instead of
slices. */
constexpr UnsignedByte CompressedSubData3DComplete[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
68, 84, 85, 101, 102, 118, 119, 119,
239, 123, 8, 66, 213, 255, 170, 2,
136, 136, 153, 153, 170, 170, 187, 187,
247, 189, 16, 132, 213, 255, 170, 2,
203, 204, 220, 221, 237, 238, 254, 255,
255, 255, 24, 190, 213, 255, 170, 2,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
}
void TextureGLTest::subImage3D() {
@ -1250,6 +1526,39 @@ void TextureGLTest::subImage3D() {
#endif
}
void TextureGLTest::compressedSubImage3D() {
#ifdef MAGNUM_TARGET_GLES2
if(!Context::current()->isExtensionSupported<Extensions::GL::OES::texture_3D>())
CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported."));
#endif
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
Texture3D texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
{12, 4, 4}, CompressedZero3D});
texture.setCompressedSubImage(0, {4, 0, 0}, CompressedImageView3D(CompressedColorFormat::RGBAS3tcDxt3,
Vector3i{4}, CompressedData3D));
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedImage3D image = texture.compressedImage(0, {});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector3i{12, 4, 4}));
CORRADE_COMPARE_AS(
(Containers::ArrayView<const UnsignedByte>{image.data<UnsignedByte>(), image.data().size()}),
Containers::ArrayView<const UnsignedByte>{CompressedSubData3DComplete}, TestSuite::Compare::Container);
#endif
}
#ifndef MAGNUM_TARGET_GLES2
void TextureGLTest::subImage3DBuffer() {
Texture3D texture;
@ -1271,6 +1580,34 @@ void TextureGLTest::subImage3DBuffer() {
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{SubData3DComplete}, TestSuite::Compare::Container);
#endif
}
void TextureGLTest::compressedSubImage3DBuffer() {
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
#endif
Texture3D texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
{12, 4, 4}, CompressedZero3D});
texture.setCompressedSubImage(0, {4, 0, 0}, CompressedImageView3D(CompressedColorFormat::RGBAS3tcDxt3,
Vector3i{4}, CompressedData3D));
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CompressedBufferImage3D image = texture.compressedImage(0, {}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), (Vector3i{12, 4, 4}));
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{CompressedSubData3DComplete}, TestSuite::Compare::Container);
#endif
}
#endif
#ifndef MAGNUM_TARGET_GLES

Loading…
Cancel
Save