@ -23,7 +23,9 @@
DEALINGS IN THE SOFTWARE .
*/
# include <sstream>
# include <Corrade/TestSuite/Compare/Container.h>
# include <Corrade/Utility/DebugStl.h>
# include "Magnum/Image.h"
# include "Magnum/ImageView.h"
@ -80,12 +82,20 @@ struct CubeMapTextureGLTest: OpenGLTester {
# ifndef MAGNUM_TARGET_GLES2
void imageBuffer ( ) ;
# endif
# ifndef MAGNUM_TARGET_GLES
void imageQueryView ( ) ;
void imageQueryViewNullptr ( ) ;
void imageQueryViewBadSize ( ) ;
# endif
void subImage ( ) ;
# ifndef MAGNUM_TARGET_GLES2
void subImageBuffer ( ) ;
# endif
# ifndef MAGNUM_TARGET_GLES
void subImageQuery ( ) ;
void subImageQueryView ( ) ;
/* unlike all others, subImage() simply calls into AbstractTexture, so
all assertions are already tested in AbstractTextureGLTest */
void subImageQueryBuffer ( ) ;
# endif
@ -93,6 +103,13 @@ struct CubeMapTextureGLTest: OpenGLTester {
# ifndef MAGNUM_TARGET_GLES2
void compressedImageBuffer ( ) ;
# endif
# ifndef MAGNUM_TARGET_GLES
void compressedImageQueryView ( ) ;
void compressedImageQueryViewNullptr ( ) ;
void compressedImageQueryViewBadSize ( ) ;
void compressedImageQueryViewBadDataSize ( ) ;
void compressedImageQueryViewBadFormat ( ) ;
# endif
# if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void immutableCompressedImage ( ) ;
# endif
@ -102,14 +119,27 @@ struct CubeMapTextureGLTest: OpenGLTester {
# endif
# ifndef MAGNUM_TARGET_GLES
void compressedSubImageQuery ( ) ;
void compressedSubImageQueryView ( ) ;
void compressedSubImageQueryViewNullptr ( ) ;
void compressedSubImageQueryViewBadSize ( ) ;
void compressedSubImageQueryViewBadDataSize ( ) ;
void compressedSubImageQueryViewBadFormat ( ) ;
void compressedSubImageQueryBuffer ( ) ;
# endif
# ifndef MAGNUM_TARGET_GLES
void fullImageQuery ( ) ;
void fullImageQueryView ( ) ;
void fullImageQueryViewNullptr ( ) ;
void fullImageQueryViewBadSize ( ) ;
void fullImageQueryBuffer ( ) ;
void compressedFullImageQuery ( ) ;
void compressedFullImageQueryView ( ) ;
void compressedFullImageQueryViewNullptr ( ) ;
void compressedFullImageQueryViewBadSize ( ) ;
void compressedFullImageQueryViewBadDataSize ( ) ;
void compressedFullImageQueryViewBadFormat ( ) ;
void compressedFullImageQueryBuffer ( ) ;
# endif
@ -306,13 +336,25 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
# ifndef MAGNUM_TARGET_GLES2
& CubeMapTextureGLTest : : imageBuffer ,
# endif
# ifndef MAGNUM_TARGET_GLES
& CubeMapTextureGLTest : : imageQueryView ,
# endif
} , Containers : : arraySize ( PixelStorageData ) ) ;
# ifndef MAGNUM_TARGET_GLES
addTests ( { & CubeMapTextureGLTest : : imageQueryViewNullptr ,
& CubeMapTextureGLTest : : imageQueryViewBadSize } ) ;
# endif
# ifndef MAGNUM_TARGET_GLES
addInstancedTests ( {
& CubeMapTextureGLTest : : fullImageQuery ,
& CubeMapTextureGLTest : : fullImageQueryView ,
& CubeMapTextureGLTest : : fullImageQueryBuffer } ,
Containers : : arraySize ( FullPixelStorageData ) ) ;
addTests ( { & CubeMapTextureGLTest : : fullImageQueryViewNullptr ,
& CubeMapTextureGLTest : : fullImageQueryViewBadSize } ) ;
# endif
addInstancedTests ( {
@ -322,6 +364,7 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
# endif
# ifndef MAGNUM_TARGET_GLES
& CubeMapTextureGLTest : : subImageQuery ,
& CubeMapTextureGLTest : : subImageQueryView ,
& CubeMapTextureGLTest : : subImageQueryBuffer
# endif
} , Containers : : arraySize ( PixelStorageData ) ) ;
@ -331,16 +374,30 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
# ifndef MAGNUM_TARGET_GLES2
& CubeMapTextureGLTest : : compressedImageBuffer ,
# endif
# ifndef MAGNUM_TARGET_GLES
& CubeMapTextureGLTest : : compressedImageQueryView ,
# endif
# if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
& CubeMapTextureGLTest : : immutableCompressedImage ,
# endif
} , Containers : : arraySize ( CompressedPixelStorageData ) ) ;
# ifndef MAGNUM_TARGET_GLES
addTests ( { & CubeMapTextureGLTest : : compressedImageQueryViewNullptr ,
& CubeMapTextureGLTest : : compressedImageQueryViewBadSize ,
& CubeMapTextureGLTest : : compressedImageQueryViewBadDataSize ,
& CubeMapTextureGLTest : : compressedImageQueryViewBadFormat } ) ;
addInstancedTests ( {
& CubeMapTextureGLTest : : compressedFullImageQuery ,
& CubeMapTextureGLTest : : compressedFullImageQueryView ,
& CubeMapTextureGLTest : : compressedFullImageQueryBuffer } ,
Containers : : arraySize ( CompressedFullPixelStorageData ) ) ;
addTests ( { & CubeMapTextureGLTest : : compressedFullImageQueryViewNullptr ,
& CubeMapTextureGLTest : : compressedFullImageQueryViewBadSize ,
& CubeMapTextureGLTest : : compressedFullImageQueryViewBadDataSize ,
& CubeMapTextureGLTest : : compressedFullImageQueryViewBadFormat } ) ;
# endif
addInstancedTests ( {
@ -350,10 +407,18 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
# endif
# ifndef MAGNUM_TARGET_GLES
& CubeMapTextureGLTest : : compressedSubImageQuery ,
& CubeMapTextureGLTest : : compressedSubImageQueryView ,
& CubeMapTextureGLTest : : compressedSubImageQueryBuffer
# endif
} , Containers : : arraySize ( CompressedPixelStorageData ) ) ;
# ifndef MAGNUM_TARGET_GLES
addTests ( { & CubeMapTextureGLTest : : compressedSubImageQueryViewNullptr ,
& CubeMapTextureGLTest : : compressedSubImageQueryViewBadSize ,
& CubeMapTextureGLTest : : compressedSubImageQueryViewBadDataSize ,
& CubeMapTextureGLTest : : compressedSubImageQueryViewBadFormat } ) ;
# endif
addTests ( { & CubeMapTextureGLTest : : generateMipmap ,
& CubeMapTextureGLTest : : invalidateImage ,
@ -807,6 +872,64 @@ void CubeMapTextureGLTest::imageBuffer() {
}
# endif
# ifndef MAGNUM_TARGET_GLES
void CubeMapTextureGLTest : : imageQueryView ( ) {
setTestCaseDescription ( PixelStorageData [ testCaseInstanceId ( ) ] . name ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : RGBA8 , Vector2i { 2 } )
. setSubImage ( CubeMapCoordinate : : PositiveY , 0 , { } ,
ImageView2D { PixelStorageData [ testCaseInstanceId ( ) ] . storage ,
PixelFormat : : RGBA , PixelType : : UnsignedByte , Vector2i ( 2 ) ,
PixelStorageData [ testCaseInstanceId ( ) ] . dataSparse } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
Containers : : Array < char > data { PixelStorageData [ testCaseInstanceId ( ) ] . offset + 2 * 2 * 4 } ;
MutableImageView2D image { PixelStorageData [ testCaseInstanceId ( ) ] . storage ,
PixelFormat : : RGBA , PixelType : : UnsignedByte , Vector2i { 2 } , data } ;
texture . image ( CubeMapCoordinate : : PositiveY , 0 , image ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
CORRADE_COMPARE ( image . size ( ) , Vector2i ( 2 ) ) ;
CORRADE_COMPARE_AS ( Containers : : arrayCast < UnsignedByte > ( image . data ( ) ) . suffix ( PixelStorageData [ testCaseInstanceId ( ) ] . offset ) ,
PixelStorageData [ testCaseInstanceId ( ) ] . data ,
TestSuite : : Compare : : Container ) ;
}
void CubeMapTextureGLTest : : imageQueryViewNullptr ( ) {
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : RGBA8 , Vector2i { 2 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
MutableImageView2D image { PixelFormat : : RGBA , PixelType : : UnsignedByte ,
Vector2i { 2 } , { nullptr , 2 * 2 * 4 } } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . image ( CubeMapCoordinate : : PositiveY , 0 , image ) ;
CORRADE_COMPARE ( out . str ( ) , " GL::CubeMapTexture::image(): image view is nullptr \n " ) ;
}
void CubeMapTextureGLTest : : imageQueryViewBadSize ( ) {
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : RGBA8 , Vector2i { 2 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
char data [ 2 * 4 ] ;
MutableImageView2D image { PixelFormat : : RGBA , PixelType : : UnsignedByte ,
{ 2 , 1 } , data } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . image ( CubeMapCoordinate : : PositiveY , 0 , image ) ;
CORRADE_COMPARE ( out . str ( ) , " GL::CubeMapTexture::image(): expected image view size Vector(2, 2) but got Vector(2, 1) \n " ) ;
}
# endif
# ifndef MAGNUM_TARGET_GLES
constexpr UnsignedByte SubDataComplete [ ] {
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
@ -932,6 +1055,31 @@ void CubeMapTextureGLTest::subImageQuery() {
TestSuite : : Compare : : Container ) ;
}
void CubeMapTextureGLTest : : subImageQueryView ( ) {
setTestCaseDescription ( PixelStorageData [ testCaseInstanceId ( ) ] . name ) ;
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : ARB : : get_texture_sub_image > ( ) )
CORRADE_SKIP ( Extensions : : ARB : : get_texture_sub_image : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : RGBA8 , Vector2i { 4 } )
. setSubImage ( CubeMapCoordinate : : PositiveX , 0 , { } , ImageView2D { PixelFormat : : RGBA , PixelType : : UnsignedByte , { 4 , 4 } , SubDataComplete } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
Containers : : Array < char > data { PixelStorageData [ testCaseInstanceId ( ) ] . offset + 2 * 2 * 4 } ;
MutableImageView3D image { PixelStorageData [ testCaseInstanceId ( ) ] . storage ,
PixelFormat : : RGBA , PixelType : : UnsignedByte , { 2 , 2 , 1 } , data } ;
texture . subImage ( 0 , Range3Di : : fromSize ( { 1 , 1 , 0 } , { 2 , 2 , 1 } ) , image ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
CORRADE_COMPARE ( image . size ( ) , Vector3i ( 2 , 2 , 1 ) ) ;
CORRADE_COMPARE_AS ( Containers : : arrayCast < const UnsignedByte > ( image . data ( ) ) . suffix ( PixelStorageData [ testCaseInstanceId ( ) ] . offset ) ,
PixelStorageData [ testCaseInstanceId ( ) ] . data ,
TestSuite : : Compare : : Container ) ;
}
void CubeMapTextureGLTest : : subImageQueryBuffer ( ) {
setTestCaseDescription ( PixelStorageData [ testCaseInstanceId ( ) ] . name ) ;
@ -1053,6 +1201,111 @@ void CubeMapTextureGLTest::compressedImageBuffer() {
}
# endif
# ifndef MAGNUM_TARGET_GLES
void CubeMapTextureGLTest : : compressedImageQueryView ( ) {
setTestCaseDescription ( CompressedPixelStorageData [ testCaseInstanceId ( ) ] . name ) ;
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : 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 ( ) + std : : string ( " is not supported. " ) ) ;
const CompressedImageView2D view {
CompressedPixelStorageData [ testCaseInstanceId ( ) ] . storage ,
CompressedPixelFormat : : RGBAS3tcDxt3 , Vector2i { 4 } ,
CompressedPixelStorageData [ testCaseInstanceId ( ) ] . dataSparse } ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 4 } )
. setCompressedSubImage ( CubeMapCoordinate : : PositiveZ , 0 , { } , view ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
Containers : : Array < char > data { CompressedPixelStorageData [ testCaseInstanceId ( ) ] . offset + 16 } ;
MutableCompressedImageView2D image { CompressedPixelStorageData [ testCaseInstanceId ( ) ] . storage , CompressedPixelFormat : : RGBAS3tcDxt3 , Vector2i { 4 } , data } ;
texture . compressedImage ( CubeMapCoordinate : : PositiveZ , 0 , image ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
CORRADE_COMPARE ( image . size ( ) , Vector2i { 4 } ) ;
CORRADE_COMPARE_AS ( Containers : : arrayCast < UnsignedByte > ( image . data ( ) ) . suffix ( CompressedPixelStorageData [ testCaseInstanceId ( ) ] . offset ) ,
CompressedPixelStorageData [ testCaseInstanceId ( ) ] . data ,
TestSuite : : Compare : : Container ) ;
}
void CubeMapTextureGLTest : : compressedImageQueryViewNullptr ( ) {
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 4 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
MutableCompressedImageView2D image { CompressedPixelFormat : : RGBAS3tcDxt3 , Vector2i { 4 } , { nullptr , 16 } } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . compressedImage ( CubeMapCoordinate : : PositiveX , 0 , image ) ;
CORRADE_COMPARE ( out . str ( ) , " GL::CubeMapTexture::compressedImage(): image view is nullptr \n " ) ;
}
void CubeMapTextureGLTest : : compressedImageQueryViewBadSize ( ) {
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 4 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
char data [ 2 * 16 ] ;
MutableCompressedImageView2D image { CompressedPixelFormat : : RGBAS3tcDxt3 , Vector2i { 4 , 8 } , data } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . compressedImage ( CubeMapCoordinate : : PositiveX , 0 , image ) ;
CORRADE_COMPARE ( out . str ( ) , " GL::CubeMapTexture::compressedImage(): expected image view size Vector(4, 4) but got Vector(4, 8) \n " ) ;
}
void CubeMapTextureGLTest : : compressedImageQueryViewBadDataSize ( ) {
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 4 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
char data [ 16 - 1 ] ;
MutableCompressedImageView2D image { CompressedPixelFormat : : RGBAS3tcDxt3 , Vector2i { 4 } , data } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . compressedImage ( CubeMapCoordinate : : PositiveX , 0 , image ) ;
CORRADE_COMPARE ( out . str ( ) , " GL::CubeMapTexture::compressedImage(): expected image view data size 16 bytes but got 15 \n " ) ;
}
void CubeMapTextureGLTest : : compressedImageQueryViewBadFormat ( ) {
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 4 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
char data [ 16 ] ;
MutableCompressedImageView2D image { CompressedPixelFormat : : RGBAS3tcDxt1 , Vector2i { 4 } , data } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . compressedImage ( CubeMapCoordinate : : PositiveX , 0 , image ) ;
CORRADE_COMPARE ( out . str ( ) , " GL::CubeMapTexture::compressedImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1 \n " ) ;
}
# endif
# if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void CubeMapTextureGLTest : : immutableCompressedImage ( ) {
setTestCaseDescription ( CompressedPixelStorageData [ testCaseInstanceId ( ) ] . name ) ;
@ -1284,6 +1537,107 @@ void CubeMapTextureGLTest::compressedSubImageQuery() {
TestSuite : : Compare : : Container ) ;
}
void CubeMapTextureGLTest : : compressedSubImageQueryView ( ) {
setTestCaseDescription ( CompressedPixelStorageData [ testCaseInstanceId ( ) ] . name ) ;
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : ARB : : get_texture_sub_image > ( ) )
CORRADE_SKIP ( Extensions : : ARB : : get_texture_sub_image : : string ( ) + std : : string ( " is not supported. " ) ) ;
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : 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 ( ) + std : : string ( " is not supported. " ) ) ;
if ( CompressedPixelStorageData [ testCaseInstanceId ( ) ] . storage = = CompressedPixelStorage { } & & ! Context : : current ( ) . isExtensionSupported < Extensions : : ARB : : internalformat_query2 > ( ) )
CORRADE_SKIP ( Extensions : : ARB : : internalformat_query2 : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 12 } )
. setCompressedSubImage ( CubeMapCoordinate : : PositiveX , 0 , { } , CompressedImageView2D { CompressedPixelFormat : : RGBAS3tcDxt3 , { 12 , 12 } , CompressedSubDataComplete } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
Containers : : Array < char > data { CompressedPixelStorageData [ testCaseInstanceId ( ) ] . offset + 16 } ;
MutableCompressedImageView3D image { CompressedPixelStorageData [ testCaseInstanceId ( ) ] . storage , CompressedPixelFormat : : RGBAS3tcDxt3 , { 4 , 4 , 1 } , data } ;
texture . compressedSubImage ( 0 , Range3Di : : fromSize ( { 4 , 4 , 0 } , { 4 , 4 , 1 } ) , image ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
CORRADE_COMPARE ( image . size ( ) , ( Vector3i { 4 , 4 , 1 } ) ) ;
CORRADE_COMPARE_AS ( Containers : : arrayCast < UnsignedByte > ( image . data ( ) ) . suffix ( CompressedPixelStorageData [ testCaseInstanceId ( ) ] . offset ) ,
CompressedPixelStorageData [ testCaseInstanceId ( ) ] . data ,
TestSuite : : Compare : : Container ) ;
}
void CubeMapTextureGLTest : : compressedSubImageQueryViewNullptr ( ) {
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 12 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
MutableCompressedImageView3D image { CompressedPixelFormat : : RGBAS3tcDxt3 , Vector3i { 4 , 4 , 1 } , { nullptr , 16 } } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . compressedSubImage ( 0 , Range3Di : : fromSize ( { 4 , 4 , 0 } , { 4 , 4 , 1 } ) , image ) ;
CORRADE_COMPARE ( out . str ( ) , " GL::CubeMapTexture::compressedSubImage(): image view is nullptr \n " ) ;
}
void CubeMapTextureGLTest : : compressedSubImageQueryViewBadSize ( ) {
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 12 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
char data [ 2 * 16 ] ;
MutableCompressedImageView3D image { CompressedPixelFormat : : RGBAS3tcDxt3 , Vector3i { 4 , 4 , 2 } , data } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . compressedSubImage ( 0 , Range3Di : : fromSize ( { 4 , 4 , 0 } , { 4 , 4 , 1 } ) , image ) ;
CORRADE_COMPARE ( out . str ( ) , " GL::CubeMapTexture::compressedSubImage(): expected image view size Vector(4, 4, 1) but got Vector(4, 4, 2) \n " ) ;
}
void CubeMapTextureGLTest : : compressedSubImageQueryViewBadDataSize ( ) {
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 12 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
char data [ 16 - 1 ] ;
MutableCompressedImageView3D image { CompressedPixelFormat : : RGBAS3tcDxt3 , Vector3i { 4 , 4 , 1 } , data } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . compressedSubImage ( 0 , Range3Di : : fromSize ( { 4 , 4 , 0 } , { 4 , 4 , 1 } ) , image ) ;
CORRADE_COMPARE ( out . str ( ) , " GL::CubeMapTexture::compressedSubImage(): expected image view data size 16 bytes but got 15 \n " ) ;
}
void CubeMapTextureGLTest : : compressedSubImageQueryViewBadFormat ( ) {
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 12 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
char data [ 16 ] ;
MutableCompressedImageView3D image { CompressedPixelFormat : : RGBAS3tcDxt1 , Vector3i { 4 , 4 , 1 } , data } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . compressedSubImage ( 0 , Range3Di : : fromSize ( { 4 , 4 , 0 } , { 4 , 4 , 1 } ) , image ) ;
CORRADE_COMPARE ( out . str ( ) , " GL::CubeMapTexture::compressedSubImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1 \n " ) ;
}
void CubeMapTextureGLTest : : compressedSubImageQueryBuffer ( ) {
setTestCaseDescription ( CompressedPixelStorageData [ testCaseInstanceId ( ) ] . name ) ;
@ -1356,6 +1710,78 @@ void CubeMapTextureGLTest::fullImageQuery() {
}
}
void CubeMapTextureGLTest : : fullImageQueryView ( ) {
setTestCaseDescription ( FullPixelStorageData [ testCaseInstanceId ( ) ] . name ) ;
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : ARB : : direct_state_access > ( ) )
CORRADE_SKIP ( Extensions : : 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 } ,
FullPixelStorageData [ testCaseInstanceId ( ) ] . data } ) ;
{
# ifdef CORRADE_TARGET_WINDOWS
bool fails ( Context : : current ( ) . detectedDriver ( ) & Context : : DetectedDriver : : IntelWindows ) ;
CORRADE_EXPECT_FAIL_IF ( fails ,
" ARB_DSA 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
}
Containers : : Array < char > data { FullPixelStorageData [ testCaseInstanceId ( ) ] . offset + 2 * 2 * 6 * 4 } ;
MutableImageView3D image { FullPixelStorageData [ testCaseInstanceId ( ) ] . storage , PixelFormat : : RGBA , PixelType : : UnsignedByte , { 2 , 2 , 6 } , data } ;
texture . image ( 0 , image ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
CORRADE_COMPARE ( image . size ( ) , Vector3i ( 2 , 2 , 6 ) ) ;
{
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 > ( image . data ( ) ) . suffix ( FullPixelStorageData [ testCaseInstanceId ( ) ] . offset ) ,
FullPixelStorageData [ testCaseInstanceId ( ) ] . data ,
TestSuite : : Compare : : Container ) ;
}
}
void CubeMapTextureGLTest : : fullImageQueryViewNullptr ( ) {
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : RGBA8 , Vector2i { 2 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
MutableImageView3D image { PixelFormat : : RGBA , PixelType : : UnsignedByte ,
{ 2 , 2 , 6 } , { nullptr , 2 * 2 * 6 * 4 } } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . image ( 0 , image ) ;
CORRADE_COMPARE ( out . str ( ) , " GL::CubeMapTexture::image(): image view is nullptr \n " ) ;
}
void CubeMapTextureGLTest : : fullImageQueryViewBadSize ( ) {
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : RGBA8 , Vector2i { 2 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
char data [ 2 * 4 * 6 ] ;
MutableImageView3D image { PixelFormat : : RGBA , PixelType : : UnsignedByte ,
{ 2 , 1 , 6 } , data } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . image ( 0 , image ) ;
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 ( ) {
setTestCaseDescription ( FullPixelStorageData [ testCaseInstanceId ( ) ] . name ) ;
@ -1441,6 +1867,122 @@ void CubeMapTextureGLTest::compressedFullImageQuery() {
}
}
void CubeMapTextureGLTest : : compressedFullImageQueryView ( ) {
setTestCaseDescription ( CompressedFullPixelStorageData [ testCaseInstanceId ( ) ] . name ) ;
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : ARB : : direct_state_access > ( ) )
CORRADE_SKIP ( Extensions : : ARB : : direct_state_access : : string ( ) + std : : string ( " is not supported. " ) ) ;
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : 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 ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 4 } )
. setCompressedSubImage ( 0 , { } , CompressedImageView3D {
CompressedPixelFormat : : RGBAS3tcDxt3 , { 4 , 4 , 6 } ,
CompressedFullPixelStorageData [ testCaseInstanceId ( ) ] . data } ) ;
{
# ifdef CORRADE_TARGET_WINDOWS
bool fails ( Context : : current ( ) . detectedDriver ( ) & Context : : DetectedDriver : : IntelWindows ) ;
CORRADE_EXPECT_FAIL_IF ( fails ,
" ARB_DSA 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
}
Containers : : Array < char > data { CompressedFullPixelStorageData [ testCaseInstanceId ( ) ] . offset + 16 * 6 } ;
MutableCompressedImageView3D image { CompressedFullPixelStorageData [ testCaseInstanceId ( ) ] . storage , CompressedPixelFormat : : RGBAS3tcDxt3 , { 4 , 4 , 6 } , data } ;
texture . compressedImage ( 0 , image ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
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. " ) ;
CORRADE_COMPARE_AS ( Containers : : arrayCast < UnsignedByte > ( image . data ( ) ) . suffix ( CompressedFullPixelStorageData [ testCaseInstanceId ( ) ] . offset ) ,
CompressedFullPixelStorageData [ testCaseInstanceId ( ) ] . data ,
TestSuite : : Compare : : Container ) ;
}
}
void CubeMapTextureGLTest : : compressedFullImageQueryViewNullptr ( ) {
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 4 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
MutableCompressedImageView3D image { CompressedPixelFormat : : RGBAS3tcDxt3 , Vector3i { 4 , 4 , 6 } , { nullptr , 16 * 6 } } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . compressedImage ( 0 , image ) ;
CORRADE_COMPARE ( out . str ( ) , " GL::CubeMapTexture::compressedImage(): image view is nullptr \n " ) ;
}
void CubeMapTextureGLTest : : compressedFullImageQueryViewBadSize ( ) {
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 4 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
char data [ 2 * 6 * 16 ] ;
MutableCompressedImageView3D image { CompressedPixelFormat : : RGBAS3tcDxt3 , Vector3i { 4 , 8 , 6 } , data } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . compressedImage ( 0 , image ) ;
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 ( ) {
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 4 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
char data [ 16 * 6 - 1 ] ;
MutableCompressedImageView3D image { CompressedPixelFormat : : RGBAS3tcDxt3 , Vector3i { 4 , 4 , 6 } , data } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . compressedImage ( 0 , image ) ;
CORRADE_COMPARE ( out . str ( ) , " GL::CubeMapTexture::compressedImage(): expected image view data size 96 bytes but got 95 \n " ) ;
}
void CubeMapTextureGLTest : : compressedFullImageQueryViewBadFormat ( ) {
if ( ! Context : : current ( ) . isExtensionSupported < Extensions : : EXT : : texture_compression_s3tc > ( ) )
CORRADE_SKIP ( Extensions : : EXT : : texture_compression_s3tc : : string ( ) + std : : string ( " is not supported. " ) ) ;
CubeMapTexture texture ;
texture . setStorage ( 1 , TextureFormat : : CompressedRGBAS3tcDxt3 , Vector2i { 4 } ) ;
MAGNUM_VERIFY_NO_GL_ERROR ( ) ;
char data [ 6 * 16 ] ;
MutableCompressedImageView3D image { CompressedPixelFormat : : RGBAS3tcDxt1 , Vector3i { 4 , 4 , 6 } , data } ;
std : : ostringstream out ;
Error redirectError { & out } ;
texture . compressedImage ( 0 , image ) ;
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 ) ;