Browse Source

GL: rename & reorganize cubemap internals and test cases for clarity.

The 3D subimage setters/queries will get enabled on all platforms now,
and naming them "full" just doesn't make sense.
pull/518/head
Vladimír Vondruš 5 years ago
parent
commit
595421da16
  1. 12
      src/Magnum/GL/CubeMapTexture.cpp
  2. 13
      src/Magnum/GL/Implementation/TextureState.cpp
  3. 4
      src/Magnum/GL/Implementation/TextureState.h
  4. 214
      src/Magnum/GL/Test/CubeMapTextureGLTest.cpp

12
src/Magnum/GL/CubeMapTexture.cpp

@ -76,7 +76,7 @@ void CubeMapTexture::image(const Int level, Image3D& image) {
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture.getFullCubeImageImplementation)(level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data, image.storage()); (this->*Context::current().state().texture.getCubeImage3DImplementation)(level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data, image.storage());
image = Image3D{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data)}; image = Image3D{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data)};
} }
@ -94,7 +94,7 @@ void CubeMapTexture::image(const Int level, const MutableImageView3D& image) {
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture.getFullCubeImageImplementation)(level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data(), image.storage()); (this->*Context::current().state().texture.getCubeImage3DImplementation)(level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), image.data().size(), image.data(), image.storage());
} }
void CubeMapTexture::image(const Int level, BufferImage3D& image, const BufferUsage usage) { void CubeMapTexture::image(const Int level, BufferImage3D& image, const BufferUsage usage) {
@ -111,7 +111,7 @@ void CubeMapTexture::image(const Int level, BufferImage3D& image, const BufferUs
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture.getFullCubeImageImplementation)(level, size, image.format(), image.type(), dataSize, nullptr, image.storage()); (this->*Context::current().state().texture.getCubeImage3DImplementation)(level, size, image.format(), image.type(), dataSize, nullptr, image.storage());
} }
BufferImage3D CubeMapTexture::image(const Int level, BufferImage3D&& image, const BufferUsage usage) { BufferImage3D CubeMapTexture::image(const Int level, BufferImage3D&& image, const BufferUsage usage) {
@ -147,7 +147,7 @@ void CubeMapTexture::compressedImage(const Int level, CompressedImage3D& image)
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture.getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, data); (this->*Context::current().state().texture.getCompressedCubeImage3DImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, data);
image = CompressedImage3D{image.storage(), CompressedPixelFormat(format), size, std::move(data)}; image = CompressedImage3D{image.storage(), CompressedPixelFormat(format), size, std::move(data)};
} }
@ -190,7 +190,7 @@ void CubeMapTexture::compressedImage(const Int level, const MutableCompressedIma
Buffer::unbindInternal(Buffer::TargetHint::PixelPack); Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture.getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, image.data()); (this->*Context::current().state().texture.getCompressedCubeImage3DImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, image.data());
} }
void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& image, const BufferUsage usage) { void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& image, const BufferUsage usage) {
@ -222,7 +222,7 @@ void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& i
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage()); Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture.getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, nullptr); (this->*Context::current().state().texture.getCompressedCubeImage3DImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, nullptr);
} }
CompressedBufferImage3D CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D&& image, const BufferUsage usage) { CompressedBufferImage3D CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D&& image, const BufferUsage usage) {

13
src/Magnum/GL/Implementation/TextureState.cpp

@ -326,14 +326,14 @@ TextureState::TextureState(Context& context,
getCompressedCubeImageImplementation = &CubeMapTexture::getCompressedImageImplementationDefault; getCompressedCubeImageImplementation = &CubeMapTexture::getCompressedImageImplementationDefault;
} }
/* Full compressed cubemap image query implementation (extensions added /* 3D compressed cubemap image query implementation (extensions added
above) */ above) */
if((context.detectedDriver() & Context::DetectedDriver::NVidia) && if((context.detectedDriver() & Context::DetectedDriver::NVidia) &&
context.isExtensionSupported<Extensions::ARB::direct_state_access>() && context.isExtensionSupported<Extensions::ARB::direct_state_access>() &&
!context.isDriverWorkaroundDisabled("nv-cubemap-broken-full-compressed-image-query"_s)) !context.isDriverWorkaroundDisabled("nv-cubemap-broken-full-compressed-image-query"_s))
getFullCompressedCubeImageImplementation = &CubeMapTexture::getCompressedImageImplementationDSASingleSliceWorkaround; getCompressedCubeImage3DImplementation = &CubeMapTexture::getCompressedImageImplementationDSASingleSliceWorkaround;
else else
getFullCompressedCubeImageImplementation = &CubeMapTexture::getCompressedImageImplementationDSA; getCompressedCubeImage3DImplementation = &CubeMapTexture::getCompressedImageImplementationDSA;
#ifdef CORRADE_TARGET_WINDOWS #ifdef CORRADE_TARGET_WINDOWS
/** @todo those *might* be happening with the proprietary AMD driver on /** @todo those *might* be happening with the proprietary AMD driver on
@ -341,15 +341,14 @@ TextureState::TextureState(Context& context,
if((context.detectedDriver() & Context::DetectedDriver::Amd) && if((context.detectedDriver() & Context::DetectedDriver::Amd) &&
context.isExtensionSupported<Extensions::ARB::direct_state_access>() && context.isExtensionSupported<Extensions::ARB::direct_state_access>() &&
!context.isDriverWorkaroundDisabled("amd-windows-cubemap-image3d-slice-by-slice"_s)) !context.isDriverWorkaroundDisabled("amd-windows-cubemap-image3d-slice-by-slice"_s))
getFullCubeImageImplementation = &CubeMapTexture::getImageImplementationDSAAmdSliceBySlice; getCubeImage3DImplementation = &CubeMapTexture::getImageImplementationDSAAmdSliceBySlice;
else if((context.detectedDriver() & Context::DetectedDriver::IntelWindows) && else if((context.detectedDriver() & Context::DetectedDriver::IntelWindows) &&
context.isExtensionSupported<Extensions::ARB::direct_state_access>() && context.isExtensionSupported<Extensions::ARB::direct_state_access>() &&
!context.isDriverWorkaroundDisabled("intel-windows-broken-dsa-for-cubemaps"_s)) !context.isDriverWorkaroundDisabled("intel-windows-broken-dsa-for-cubemaps"_s))
getFullCubeImageImplementation = &CubeMapTexture::getImageImplementationSliceBySlice; getCubeImage3DImplementation = &CubeMapTexture::getImageImplementationSliceBySlice;
else else
#endif #endif
{ getCubeImage3DImplementation = &CubeMapTexture::getImageImplementationSliceBySlice;
getFullCubeImageImplementation = &CubeMapTexture::getImageImplementationDSA;
} }
#endif #endif

4
src/Magnum/GL/Implementation/TextureState.h

@ -122,8 +122,8 @@ struct TextureState {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
GLint(CubeMapTexture::*getCubeLevelCompressedImageSizeImplementation)(GLint); GLint(CubeMapTexture::*getCubeLevelCompressedImageSizeImplementation)(GLint);
void(CubeMapTexture::*getCubeImageImplementation)(CubeMapCoordinate, GLint, const Vector2i&, PixelFormat, PixelType, std::size_t, GLvoid*); void(CubeMapTexture::*getCubeImageImplementation)(CubeMapCoordinate, GLint, const Vector2i&, PixelFormat, PixelType, std::size_t, GLvoid*);
void(CubeMapTexture::*getFullCubeImageImplementation)(GLint, const Vector3i&, PixelFormat, PixelType, std::size_t, GLvoid*, const PixelStorage&); void(CubeMapTexture::*getCubeImage3DImplementation)(GLint, const Vector3i&, PixelFormat, PixelType, std::size_t, GLvoid*, const PixelStorage&);
void(CubeMapTexture::*getFullCompressedCubeImageImplementation)(GLint, const Vector2i&, std::size_t, std::size_t, GLvoid*); void(CubeMapTexture::*getCompressedCubeImage3DImplementation)(GLint, const Vector2i&, std::size_t, std::size_t, GLvoid*);
void(CubeMapTexture::*getCompressedCubeImageImplementation)(CubeMapCoordinate, GLint, const Vector2i&, std::size_t, GLvoid*); void(CubeMapTexture::*getCompressedCubeImageImplementation)(CubeMapCoordinate, GLint, const Vector2i&, std::size_t, GLvoid*);
void(CubeMapTexture::*cubeSubImage3DImplementation)(GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&); void(CubeMapTexture::*cubeSubImage3DImplementation)(GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*, const PixelStorage&);
#endif #endif

214
src/Magnum/GL/Test/CubeMapTextureGLTest.cpp

@ -129,19 +129,19 @@ struct CubeMapTextureGLTest: OpenGLTester {
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void fullImageQuery(); void image3D();
void fullImageQueryView(); void image3DBuffer();
void fullImageQueryViewNullptr(); void image3DQueryView();
void fullImageQueryViewBadSize(); void image3DQueryViewNullptr();
void fullImageQueryBuffer(); void image3DQueryViewBadSize();
void compressedFullImageQuery(); void compressedImage3D();
void compressedFullImageQueryView(); void compressedImage3DBuffer();
void compressedFullImageQueryViewNullptr(); void compressedImage3DQueryView();
void compressedFullImageQueryViewBadSize(); void compressedImage3DQueryViewNullptr();
void compressedFullImageQueryViewBadDataSize(); void compressedImage3DQueryViewBadSize();
void compressedFullImageQueryViewBadFormat(); void compressedImage3DQueryViewBadDataSize();
void compressedFullImageQueryBuffer(); void compressedImage3DQueryViewBadFormat();
#endif #endif
void generateMipmap(); void generateMipmap();
@ -350,13 +350,13 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
addInstancedTests({ addInstancedTests({
&CubeMapTextureGLTest::fullImageQuery, &CubeMapTextureGLTest::image3D,
&CubeMapTextureGLTest::fullImageQueryView, &CubeMapTextureGLTest::image3DBuffer,
&CubeMapTextureGLTest::fullImageQueryBuffer}, &CubeMapTextureGLTest::image3DQueryView},
Containers::arraySize(FullPixelStorageData)); Containers::arraySize(FullPixelStorageData));
addTests({&CubeMapTextureGLTest::fullImageQueryViewNullptr, addTests({&CubeMapTextureGLTest::image3DQueryViewNullptr,
&CubeMapTextureGLTest::fullImageQueryViewBadSize}); &CubeMapTextureGLTest::image3DQueryViewBadSize});
#endif #endif
addInstancedTests({ addInstancedTests({
@ -391,15 +391,15 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
&CubeMapTextureGLTest::compressedImageQueryViewBadFormat}); &CubeMapTextureGLTest::compressedImageQueryViewBadFormat});
addInstancedTests({ addInstancedTests({
&CubeMapTextureGLTest::compressedFullImageQuery, &CubeMapTextureGLTest::compressedImage3D,
&CubeMapTextureGLTest::compressedFullImageQueryView, &CubeMapTextureGLTest::compressedImage3DBuffer,
&CubeMapTextureGLTest::compressedFullImageQueryBuffer}, &CubeMapTextureGLTest::compressedImage3DQueryView},
Containers::arraySize(CompressedFullPixelStorageData)); Containers::arraySize(CompressedFullPixelStorageData));
addTests({&CubeMapTextureGLTest::compressedFullImageQueryViewNullptr, addTests({&CubeMapTextureGLTest::compressedImage3DQueryViewNullptr,
&CubeMapTextureGLTest::compressedFullImageQueryViewBadSize, &CubeMapTextureGLTest::compressedImage3DQueryViewBadSize,
&CubeMapTextureGLTest::compressedFullImageQueryViewBadDataSize, &CubeMapTextureGLTest::compressedImage3DQueryViewBadDataSize,
&CubeMapTextureGLTest::compressedFullImageQueryViewBadFormat}); &CubeMapTextureGLTest::compressedImage3DQueryViewBadFormat});
#endif #endif
addInstancedTests({ addInstancedTests({
@ -1736,7 +1736,7 @@ void CubeMapTextureGLTest::compressedSubImageQueryBuffer() {
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void CubeMapTextureGLTest::fullImageQuery() { void CubeMapTextureGLTest::image3D() {
setTestCaseDescription(FullPixelStorageData[testCaseInstanceId()].name); setTestCaseDescription(FullPixelStorageData[testCaseInstanceId()].name);
if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>()) if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>())
@ -1765,7 +1765,38 @@ void CubeMapTextureGLTest::fullImageQuery() {
} }
} }
void CubeMapTextureGLTest::fullImageQueryView() { void CubeMapTextureGLTest::image3DBuffer() {
setTestCaseDescription(FullPixelStorageData[testCaseInstanceId()].name);
if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>())
CORRADE_SKIP(Extensions::ARB::direct_state_access::string() << "is not supported.");
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{2})
.setSubImage(0, {}, BufferImage3D{
PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6},
FullPixelStorageData[testCaseInstanceId()].data,
BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_GL_ERROR();
BufferImage3D image = texture.image(0,
{FullPixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA,
PixelType::UnsignedByte}, BufferUsage::StaticRead);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6));
const auto imageData = image.buffer().data();
{
CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa) && FullPixelStorageData[testCaseInstanceId()].storage != PixelStorage{},
"Mesa drivers can't handle non-default pixel storage for full cubemap image queries.");
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData).suffix(FullPixelStorageData[testCaseInstanceId()].offset),
FullPixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container);
}
}
void CubeMapTextureGLTest::image3DQueryView() {
setTestCaseDescription(FullPixelStorageData[testCaseInstanceId()].name); setTestCaseDescription(FullPixelStorageData[testCaseInstanceId()].name);
if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>()) if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>())
@ -1795,7 +1826,7 @@ void CubeMapTextureGLTest::fullImageQueryView() {
} }
} }
void CubeMapTextureGLTest::fullImageQueryViewNullptr() { void CubeMapTextureGLTest::image3DQueryViewNullptr() {
#ifdef CORRADE_NO_ASSERT #ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif #endif
@ -1814,7 +1845,7 @@ void CubeMapTextureGLTest::fullImageQueryViewNullptr() {
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::image(): image view is nullptr\n"); CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::image(): image view is nullptr\n");
} }
void CubeMapTextureGLTest::fullImageQueryViewBadSize() { void CubeMapTextureGLTest::image3DQueryViewBadSize() {
#ifdef CORRADE_NO_ASSERT #ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif #endif
@ -1834,38 +1865,57 @@ void CubeMapTextureGLTest::fullImageQueryViewBadSize() {
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::image(): expected image view size Vector(2, 2, 6) but got Vector(2, 1, 6)\n"); CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::image(): expected image view size Vector(2, 2, 6) but got Vector(2, 1, 6)\n");
} }
void CubeMapTextureGLTest::fullImageQueryBuffer() { void CubeMapTextureGLTest::compressedImage3D() {
setTestCaseDescription(FullPixelStorageData[testCaseInstanceId()].name); setTestCaseDescription(CompressedFullPixelStorageData[testCaseInstanceId()].name);
if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>()) if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>())
CORRADE_SKIP(Extensions::ARB::direct_state_access::string() << "is not supported."); CORRADE_SKIP(Extensions::ARB::direct_state_access::string() << "is not supported.");
if(!Context::current().isExtensionSupported<Extensions::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::EXT::texture_compression_s3tc::string() << "is not supported.");
if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::ARB::compressed_texture_pixel_storage>())
CORRADE_SKIP(Extensions::ARB::compressed_texture_pixel_storage::string() << "is not supported.");
CubeMapTexture texture; CubeMapTexture texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{2}) texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4})
.setSubImage(0, {}, BufferImage3D{ .setCompressedSubImage(0, {}, CompressedImageView3D{
PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6}, CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6},
FullPixelStorageData[testCaseInstanceId()].data, CompressedFullPixelStorageData[testCaseInstanceId()].data});
BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_GL_ERROR(); {
bool fails(Context::current().detectedDriver() & Context::DetectedDriver::Amd);
CORRADE_EXPECT_FAIL_IF(fails,
"ARB_DSA compressed cubemap APIs are broken on AMD drivers.");
BufferImage3D image = texture.image(0, MAGNUM_VERIFY_NO_GL_ERROR();
{FullPixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, if(fails) CORRADE_SKIP("Skipping the rest of the test");
PixelType::UnsignedByte}, BufferUsage::StaticRead); }
MAGNUM_VERIFY_NO_GL_ERROR(); CompressedImage3D image = texture.compressedImage(0, {CompressedFullPixelStorageData[testCaseInstanceId()].storage});
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6));
const auto imageData = image.buffer().data();
{ {
CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa) && FullPixelStorageData[testCaseInstanceId()].storage != PixelStorage{}, #ifdef CORRADE_TARGET_WINDOWS
bool fails(Context::current().detectedDriver() & Context::DetectedDriver::IntelWindows);
CORRADE_EXPECT_FAIL_IF(fails,
"ARB_DSA compressed cubemap APIs are broken on Intel Windows drivers.");
#endif
MAGNUM_VERIFY_NO_GL_ERROR();
#ifdef CORRADE_TARGET_WINDOWS
if(fails) CORRADE_SKIP("Skipping the rest of the test");
#endif
}
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6}));
{
CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa) && CompressedFullPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{},
"Mesa drivers can't handle non-default pixel storage for full cubemap image queries."); "Mesa drivers can't handle non-default pixel storage for full cubemap image queries.");
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData).suffix(FullPixelStorageData[testCaseInstanceId()].offset), CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).suffix(CompressedFullPixelStorageData[testCaseInstanceId()].offset),
FullPixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container); CompressedFullPixelStorageData[testCaseInstanceId()].data,
TestSuite::Compare::Container);
} }
} }
void CubeMapTextureGLTest::compressedFullImageQuery() { void CubeMapTextureGLTest::compressedImage3DBuffer() {
setTestCaseDescription(CompressedFullPixelStorageData[testCaseInstanceId()].name); setTestCaseDescription(CompressedFullPixelStorageData[testCaseInstanceId()].name);
if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>()) if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>())
@ -1877,9 +1927,10 @@ void CubeMapTextureGLTest::compressedFullImageQuery() {
CubeMapTexture texture; CubeMapTexture texture;
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4}) texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4})
.setCompressedSubImage(0, {}, CompressedImageView3D{ .setCompressedSubImage(0, {}, CompressedBufferImage3D{
CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6}, CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6},
CompressedFullPixelStorageData[testCaseInstanceId()].data}); CompressedFullPixelStorageData[testCaseInstanceId()].data,
BufferUsage::StaticDraw});
{ {
bool fails(Context::current().detectedDriver() & Context::DetectedDriver::Amd); bool fails(Context::current().detectedDriver() & Context::DetectedDriver::Amd);
@ -1890,7 +1941,7 @@ void CubeMapTextureGLTest::compressedFullImageQuery() {
if(fails) CORRADE_SKIP("Skipping the rest of the test"); if(fails) CORRADE_SKIP("Skipping the rest of the test");
} }
CompressedImage3D image = texture.compressedImage(0, {CompressedFullPixelStorageData[testCaseInstanceId()].storage}); CompressedBufferImage3D image = texture.compressedImage(0, {CompressedFullPixelStorageData[testCaseInstanceId()].storage}, BufferUsage::StaticRead);
{ {
#ifdef CORRADE_TARGET_WINDOWS #ifdef CORRADE_TARGET_WINDOWS
@ -1906,16 +1957,17 @@ void CubeMapTextureGLTest::compressedFullImageQuery() {
} }
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6})); CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6}));
const auto imageData = image.buffer().data();
{ {
CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa) && CompressedFullPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{}, CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa) && CompressedFullPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{},
"Mesa drivers can't handle non-default pixel storage for full cubemap image queries."); "Mesa drivers can't handle non-default pixel storage for full cubemap image queries.");
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).suffix(CompressedFullPixelStorageData[testCaseInstanceId()].offset), CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData).suffix(CompressedFullPixelStorageData[testCaseInstanceId()].offset),
CompressedFullPixelStorageData[testCaseInstanceId()].data, CompressedFullPixelStorageData[testCaseInstanceId()].data,
TestSuite::Compare::Container); TestSuite::Compare::Container);
} }
} }
void CubeMapTextureGLTest::compressedFullImageQueryView() { void CubeMapTextureGLTest::compressedImage3DQueryView() {
setTestCaseDescription(CompressedFullPixelStorageData[testCaseInstanceId()].name); setTestCaseDescription(CompressedFullPixelStorageData[testCaseInstanceId()].name);
if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>()) if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>())
@ -1967,7 +2019,7 @@ void CubeMapTextureGLTest::compressedFullImageQueryView() {
} }
} }
void CubeMapTextureGLTest::compressedFullImageQueryViewNullptr() { void CubeMapTextureGLTest::compressedImage3DQueryViewNullptr() {
#ifdef CORRADE_NO_ASSERT #ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif #endif
@ -1988,7 +2040,7 @@ void CubeMapTextureGLTest::compressedFullImageQueryViewNullptr() {
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): image view is nullptr\n"); CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): image view is nullptr\n");
} }
void CubeMapTextureGLTest::compressedFullImageQueryViewBadSize() { void CubeMapTextureGLTest::compressedImage3DQueryViewBadSize() {
#ifdef CORRADE_NO_ASSERT #ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif #endif
@ -2010,7 +2062,7 @@ void CubeMapTextureGLTest::compressedFullImageQueryViewBadSize() {
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): expected image view size Vector(4, 4, 6) but got Vector(4, 8, 6)\n"); CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): expected image view size Vector(4, 4, 6) but got Vector(4, 8, 6)\n");
} }
void CubeMapTextureGLTest::compressedFullImageQueryViewBadDataSize() { void CubeMapTextureGLTest::compressedImage3DQueryViewBadDataSize() {
#ifdef CORRADE_NO_ASSERT #ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif #endif
@ -2032,7 +2084,7 @@ void CubeMapTextureGLTest::compressedFullImageQueryViewBadDataSize() {
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): expected image view data size 96 bytes but got 95\n"); CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): expected image view data size 96 bytes but got 95\n");
} }
void CubeMapTextureGLTest::compressedFullImageQueryViewBadFormat() { void CubeMapTextureGLTest::compressedImage3DQueryViewBadFormat() {
#ifdef CORRADE_NO_ASSERT #ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif #endif
@ -2053,58 +2105,6 @@ void CubeMapTextureGLTest::compressedFullImageQueryViewBadFormat() {
texture.compressedImage(0, image); texture.compressedImage(0, image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1\n"); CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1\n");
} }
void CubeMapTextureGLTest::compressedFullImageQueryBuffer() {
setTestCaseDescription(CompressedFullPixelStorageData[testCaseInstanceId()].name);
if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>())
CORRADE_SKIP(Extensions::ARB::direct_state_access::string() << "is not supported.");
if(!Context::current().isExtensionSupported<Extensions::EXT::texture_compression_s3tc>())
CORRADE_SKIP(Extensions::EXT::texture_compression_s3tc::string() << "is not supported.");
if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::ARB::compressed_texture_pixel_storage>())
CORRADE_SKIP(Extensions::ARB::compressed_texture_pixel_storage::string() << "is not supported.");
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4})
.setCompressedSubImage(0, {}, CompressedBufferImage3D{
CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6},
CompressedFullPixelStorageData[testCaseInstanceId()].data,
BufferUsage::StaticDraw});
{
bool fails(Context::current().detectedDriver() & Context::DetectedDriver::Amd);
CORRADE_EXPECT_FAIL_IF(fails,
"ARB_DSA compressed cubemap APIs are broken on AMD drivers.");
MAGNUM_VERIFY_NO_GL_ERROR();
if(fails) CORRADE_SKIP("Skipping the rest of the test");
}
CompressedBufferImage3D image = texture.compressedImage(0, {CompressedFullPixelStorageData[testCaseInstanceId()].storage}, BufferUsage::StaticRead);
{
#ifdef CORRADE_TARGET_WINDOWS
bool fails(Context::current().detectedDriver() & Context::DetectedDriver::IntelWindows);
CORRADE_EXPECT_FAIL_IF(fails,
"ARB_DSA compressed cubemap APIs are broken on Intel Windows drivers.");
#endif
MAGNUM_VERIFY_NO_GL_ERROR();
#ifdef CORRADE_TARGET_WINDOWS
if(fails) CORRADE_SKIP("Skipping the rest of the test");
#endif
}
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6}));
const auto imageData = image.buffer().data();
{
CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa) && CompressedFullPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{},
"Mesa drivers can't handle non-default pixel storage for full cubemap image queries.");
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData).suffix(CompressedFullPixelStorageData[testCaseInstanceId()].offset),
CompressedFullPixelStorageData[testCaseInstanceId()].data,
TestSuite::Compare::Container);
}
}
#endif #endif
void CubeMapTextureGLTest::generateMipmap() { void CubeMapTextureGLTest::generateMipmap() {

Loading…
Cancel
Save