Browse Source

Clearer test case naming.

We're testing just full image query, not full image upload.
pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
31bfff76e7
  1. 270
      src/Magnum/Test/CubeMapTextureGLTest.cpp

270
src/Magnum/Test/CubeMapTextureGLTest.cpp

@ -68,18 +68,18 @@ struct CubeMapTextureGLTest: AbstractOpenGLTester {
void storage();
#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
#ifndef MAGNUM_TARGET_GLES
void fullImageQuery();
void compressedFullImageQuery();
void fullImageQueryBuffer();
void compressedFullImageQueryBuffer();
#endif
void subImage();
void compressedSubImage();
@ -125,18 +125,18 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
&CubeMapTextureGLTest::storage,
#ifndef MAGNUM_TARGET_GLES
&CubeMapTextureGLTest::imageFull,
&CubeMapTextureGLTest::compressedImageFull,
&CubeMapTextureGLTest::imageFullBuffer,
&CubeMapTextureGLTest::compressedImageFullBuffer,
#endif
&CubeMapTextureGLTest::image,
&CubeMapTextureGLTest::compressedImage,
#ifndef MAGNUM_TARGET_GLES2
&CubeMapTextureGLTest::imageBuffer,
&CubeMapTextureGLTest::compressedImageBuffer,
#endif
#ifndef MAGNUM_TARGET_GLES
&CubeMapTextureGLTest::fullImageQuery,
&CubeMapTextureGLTest::compressedFullImageQuery,
&CubeMapTextureGLTest::fullImageQueryBuffer,
&CubeMapTextureGLTest::compressedFullImageQueryBuffer,
#endif
&CubeMapTextureGLTest::subImage,
&CubeMapTextureGLTest::compressedSubImage,
@ -367,7 +367,116 @@ void CubeMapTextureGLTest::storage() {
}
namespace {
constexpr UnsignedByte DataFull[] = { 0x00, 0x01, 0x02, 0x03,
constexpr UnsignedByte Data[] = { 0x00, 0x01, 0x02, 0x03,
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() {
CubeMapTexture texture;
texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(
Containers::ArrayView<const UnsignedByte>(image.data<UnsignedByte>(), image.pixelSize()*image.size().product()),
Containers::ArrayView<const UnsignedByte>{Data}, TestSuite::Compare::Container);
#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{CompressedPixelFormat::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;
texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8,
BufferImage2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
BufferImage2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector2i(2));
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{CompressedPixelFormat::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
#ifndef MAGNUM_TARGET_GLES
namespace {
constexpr UnsignedByte FullData[] = { 0x00, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f,
@ -399,7 +508,7 @@ namespace {
/* Just 4x4 0x00 - 0x3f compressed using RGBA DXT3 by the driver, repeated
six times */
constexpr UnsignedByte CompressedDataFull[] = {
constexpr UnsignedByte CompressedFullData[] = {
0, 17, 17, 34, 34, 51, 51, 67,
232, 57, 0, 0, 213, 255, 170, 2,
0, 17, 17, 34, 34, 51, 51, 67,
@ -416,14 +525,13 @@ namespace {
};
}
#ifndef MAGNUM_TARGET_GLES
void CubeMapTextureGLTest::imageFull() {
void CubeMapTextureGLTest::fullImageQuery() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::direct_state_access>())
CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported."));
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{2, 2})
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6}, DataFull});
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6}, FullData});
MAGNUM_VERIFY_NO_ERROR();
@ -434,10 +542,10 @@ void CubeMapTextureGLTest::imageFull() {
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6));
CORRADE_COMPARE_AS(
Containers::ArrayView<const UnsignedByte>(image.data<UnsignedByte>(), image.pixelSize()*image.size().product()),
Containers::ArrayView<const UnsignedByte>{DataFull}, TestSuite::Compare::Container);
Containers::ArrayView<const UnsignedByte>{FullData}, TestSuite::Compare::Container);
}
void CubeMapTextureGLTest::compressedImageFull() {
void CubeMapTextureGLTest::compressedFullImageQuery() {
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>())
@ -445,7 +553,7 @@ void CubeMapTextureGLTest::compressedImageFull() {
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4})
.setCompressedSubImage(0, {}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6}, CompressedDataFull});
.setCompressedSubImage(0, {}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6}, CompressedFullData});
MAGNUM_VERIFY_NO_ERROR();
@ -456,16 +564,16 @@ void CubeMapTextureGLTest::compressedImageFull() {
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);
Containers::ArrayView<const UnsignedByte>{CompressedFullData}, TestSuite::Compare::Container);
}
void CubeMapTextureGLTest::imageFullBuffer() {
void CubeMapTextureGLTest::fullImageQueryBuffer() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::direct_state_access>())
CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported."));
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{2})
.setSubImage(0, {}, BufferImage3D{PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6}, DataFull, BufferUsage::StaticDraw});
.setSubImage(0, {}, BufferImage3D{PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6}, FullData, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
@ -475,10 +583,10 @@ void CubeMapTextureGLTest::imageFullBuffer() {
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6));
const auto imageData = image.buffer().data<UnsignedByte>();
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{DataFull}, TestSuite::Compare::Container);
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{FullData}, TestSuite::Compare::Container);
}
void CubeMapTextureGLTest::compressedImageFullBuffer() {
void CubeMapTextureGLTest::compressedFullImageQueryBuffer() {
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>())
@ -486,7 +594,7 @@ void CubeMapTextureGLTest::compressedImageFullBuffer() {
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4})
.setCompressedSubImage(0, {}, CompressedBufferImage3D{CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6}, CompressedDataFull, BufferUsage::StaticDraw});
.setCompressedSubImage(0, {}, CompressedBufferImage3D{CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6}, CompressedFullData, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
@ -496,115 +604,7 @@ void CubeMapTextureGLTest::compressedImageFullBuffer() {
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 {
constexpr UnsignedByte Data[] = { 0x00, 0x01, 0x02, 0x03,
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() {
CubeMapTexture texture;
texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(
Containers::ArrayView<const UnsignedByte>(image.data<UnsignedByte>(), image.pixelSize()*image.size().product()),
Containers::ArrayView<const UnsignedByte>{Data}, TestSuite::Compare::Container);
#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{CompressedPixelFormat::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;
texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8,
BufferImage2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
BufferImage2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector2i(2));
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{CompressedPixelFormat::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
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const UnsignedByte>{CompressedFullData}, TestSuite::Compare::Container);
}
#endif

Loading…
Cancel
Save