Browse Source

Test: make the GL tests compile on WebGL 1.

Not WebGL 2 yet, though.
pull/205/head
Vladimír Vondruš 8 years ago
parent
commit
cb2a20aced
  1. 11
      src/Magnum/DebugTools/Test/CMakeLists.txt
  2. 28
      src/Magnum/DebugTools/Test/TextureImageGLTest.cpp
  3. 9
      src/Magnum/Test/AbstractQueryGLTest.cpp
  4. 6
      src/Magnum/Test/AbstractShaderProgramGLTest.cpp
  5. 9
      src/Magnum/Test/AbstractTextureGLTest.cpp
  6. 12
      src/Magnum/Test/BufferGLTest.cpp
  7. 46
      src/Magnum/Test/CMakeLists.txt
  8. 111
      src/Magnum/Test/CubeMapTextureGLTest.cpp
  9. 232
      src/Magnum/Test/FramebufferGLTest.cpp
  10. 49
      src/Magnum/Test/MeshGLTest.cpp
  11. 16
      src/Magnum/Test/RenderbufferGLTest.cpp
  12. 6
      src/Magnum/Test/ShaderGLTest.cpp
  13. 152
      src/Magnum/Test/TextureGLTest.cpp
  14. 2
      src/Magnum/Test/configure.h.cmake
  15. 5
      src/Magnum/Text/Test/RendererGLTest.cpp

11
src/Magnum/DebugTools/Test/CMakeLists.txt

@ -46,11 +46,12 @@ if(Corrade_TestSuite_FOUND)
endif() endif()
if(BUILD_GL_TESTS) if(BUILD_GL_TESTS)
corrade_add_test(DebugToolsBufferDataGLTest BufferDataGLTest.cpp LIBRARIES MagnumDebugTools MagnumOpenGLTester)
corrade_add_test(DebugToolsTextureImageGLTest TextureImageGLTest.cpp LIBRARIES MagnumDebugTools MagnumOpenGLTester) corrade_add_test(DebugToolsTextureImageGLTest TextureImageGLTest.cpp LIBRARIES MagnumDebugTools MagnumOpenGLTester)
set_target_properties(DebugToolsTextureImageGLTest PROPERTIES FOLDER "Magnum/DebugTools/Test")
set_target_properties( if(NOT (MAGNUM_TARGET_GLES2 AND MAGNUM_TARGET_WEBGL))
DebugToolsBufferDataGLTest corrade_add_test(DebugToolsBufferDataGLTest BufferDataGLTest.cpp LIBRARIES MagnumDebugTools MagnumOpenGLTester)
DebugToolsTextureImageGLTest
PROPERTIES FOLDER "Magnum/DebugTools/Test") set_target_properties(DebugToolsBufferDataGLTest PROPERTIES FOLDER "Magnum/DebugTools/Test")
endif()
endif() endif()

28
src/Magnum/DebugTools/Test/TextureImageGLTest.cpp

@ -31,11 +31,11 @@
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Texture.h" #include "Magnum/Texture.h"
#include "Magnum/TextureFormat.h" #include "Magnum/TextureFormat.h"
#include "Magnum/DebugTools/BufferData.h"
#include "Magnum/DebugTools/TextureImage.h" #include "Magnum/DebugTools/TextureImage.h"
#include "Magnum/Math/Range.h" #include "Magnum/Math/Range.h"
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
#include "Magnum/DebugTools/BufferData.h"
#include "Magnum/BufferImage.h" #include "Magnum/BufferImage.h"
#endif #endif
@ -87,7 +87,13 @@ namespace {
void TextureImageGLTest::subImage2D() { void TextureImageGLTest::subImage2D() {
Texture2D texture; Texture2D texture;
texture.setImage(0, TextureFormat::RGBA8, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, Data2D}); texture.setImage(0,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::RGBA8,
#else
TextureFormat::RGBA,
#endif
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, Data2D});
Image2D image = textureSubImage(texture, 0, {{}, Vector2i{2}}, {PixelFormat::RGBA, PixelType::UnsignedByte}); Image2D image = textureSubImage(texture, 0, {{}, Vector2i{2}}, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
@ -113,13 +119,19 @@ void TextureImageGLTest::subImage2DBuffer() {
void TextureImageGLTest::subImageCube() { void TextureImageGLTest::subImageCube() {
ImageView2D view{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, Data2D}; ImageView2D view{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, Data2D};
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
constexpr TextureFormat format = TextureFormat::RGBA8;
#else
constexpr TextureFormat format = TextureFormat::RGBA;
#endif
CubeMapTexture texture; CubeMapTexture texture;
texture.setImage(CubeMapCoordinate::PositiveX, 0, TextureFormat::RGBA8, view) texture.setImage(CubeMapCoordinate::PositiveX, 0, format, view)
.setImage(CubeMapCoordinate::NegativeX, 0, TextureFormat::RGBA8, view) .setImage(CubeMapCoordinate::NegativeX, 0, format, view)
.setImage(CubeMapCoordinate::PositiveY, 0, TextureFormat::RGBA8, view) .setImage(CubeMapCoordinate::PositiveY, 0, format, view)
.setImage(CubeMapCoordinate::NegativeY, 0, TextureFormat::RGBA8, view) .setImage(CubeMapCoordinate::NegativeY, 0, format, view)
.setImage(CubeMapCoordinate::PositiveZ, 0, TextureFormat::RGBA8, view) .setImage(CubeMapCoordinate::PositiveZ, 0, format, view)
.setImage(CubeMapCoordinate::NegativeZ, 0, TextureFormat::RGBA8, view); .setImage(CubeMapCoordinate::NegativeZ, 0, format, view);
Image2D image = textureSubImage(texture, CubeMapCoordinate::PositiveX, 0, {{}, Vector2i{2}}, {PixelFormat::RGBA, PixelType::UnsignedByte}); Image2D image = textureSubImage(texture, CubeMapCoordinate::PositiveX, 0, {{}, Vector2i{2}}, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();

9
src/Magnum/Test/AbstractQueryGLTest.cpp

@ -37,7 +37,9 @@ struct AbstractQueryGLTest: OpenGLTester {
void constructCopy(); void constructCopy();
void constructMove(); void constructMove();
#ifndef MAGNUM_TARGET_WEBGL
void label(); void label();
#endif
}; };
AbstractQueryGLTest::AbstractQueryGLTest() { AbstractQueryGLTest::AbstractQueryGLTest() {
@ -45,7 +47,10 @@ AbstractQueryGLTest::AbstractQueryGLTest() {
&AbstractQueryGLTest::constructCopy, &AbstractQueryGLTest::constructCopy,
&AbstractQueryGLTest::constructMove, &AbstractQueryGLTest::constructMove,
&AbstractQueryGLTest::label}); #ifndef MAGNUM_TARGET_WEBGL
&AbstractQueryGLTest::label
#endif
});
} }
void AbstractQueryGLTest::construct() { void AbstractQueryGLTest::construct() {
@ -108,6 +113,7 @@ void AbstractQueryGLTest::constructMove() {
CORRADE_COMPARE(c.id(), id); CORRADE_COMPARE(c.id(), id);
} }
#ifndef MAGNUM_TARGET_WEBGL
void AbstractQueryGLTest::label() { void AbstractQueryGLTest::label() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::occlusion_query_boolean>()) if(!Context::current().isExtensionSupported<Extensions::GL::EXT::occlusion_query_boolean>())
@ -142,6 +148,7 @@ void AbstractQueryGLTest::label() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
}} }}

6
src/Magnum/Test/AbstractShaderProgramGLTest.cpp

@ -53,7 +53,9 @@ struct AbstractShaderProgramGLTest: OpenGLTester {
void constructCopy(); void constructCopy();
void constructMove(); void constructMove();
#ifndef MAGNUM_TARGET_WEBGL
void label(); void label();
#endif
void create(); void create();
void createMultipleOutputs(); void createMultipleOutputs();
@ -81,7 +83,9 @@ AbstractShaderProgramGLTest::AbstractShaderProgramGLTest() {
&AbstractShaderProgramGLTest::constructCopy, &AbstractShaderProgramGLTest::constructCopy,
&AbstractShaderProgramGLTest::constructMove, &AbstractShaderProgramGLTest::constructMove,
#ifndef MAGNUM_TARGET_WEBGL
&AbstractShaderProgramGLTest::label, &AbstractShaderProgramGLTest::label,
#endif
&AbstractShaderProgramGLTest::create, &AbstractShaderProgramGLTest::create,
&AbstractShaderProgramGLTest::createMultipleOutputs, &AbstractShaderProgramGLTest::createMultipleOutputs,
@ -150,6 +154,7 @@ void AbstractShaderProgramGLTest::constructMove() {
CORRADE_COMPARE(c.id(), id); CORRADE_COMPARE(c.id(), id);
} }
#ifndef MAGNUM_TARGET_WEBGL
void AbstractShaderProgramGLTest::label() { void AbstractShaderProgramGLTest::label() {
/* No-Op version is tested in AbstractObjectGLTest */ /* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::GL::KHR::debug>() && if(!Context::current().isExtensionSupported<Extensions::GL::KHR::debug>() &&
@ -164,6 +169,7 @@ void AbstractShaderProgramGLTest::label() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
namespace { namespace {
struct MyPublicShader: AbstractShaderProgram { struct MyPublicShader: AbstractShaderProgram {

9
src/Magnum/Test/AbstractTextureGLTest.cpp

@ -37,7 +37,9 @@ struct AbstractTextureGLTest: OpenGLTester {
void constructCopy(); void constructCopy();
void constructMove(); void constructMove();
#ifndef MAGNUM_TARGET_WEBGL
void label(); void label();
#endif
}; };
AbstractTextureGLTest::AbstractTextureGLTest() { AbstractTextureGLTest::AbstractTextureGLTest() {
@ -45,7 +47,10 @@ AbstractTextureGLTest::AbstractTextureGLTest() {
&AbstractTextureGLTest::constructCopy, &AbstractTextureGLTest::constructCopy,
&AbstractTextureGLTest::constructMove, &AbstractTextureGLTest::constructMove,
&AbstractTextureGLTest::label}); #ifndef MAGNUM_TARGET_WEBGL
&AbstractTextureGLTest::label
#endif
});
} }
void AbstractTextureGLTest::construct() { void AbstractTextureGLTest::construct() {
@ -86,6 +91,7 @@ void AbstractTextureGLTest::constructMove() {
CORRADE_COMPARE(c.id(), id); CORRADE_COMPARE(c.id(), id);
} }
#ifndef MAGNUM_TARGET_WEBGL
void AbstractTextureGLTest::label() { void AbstractTextureGLTest::label() {
/* No-Op version is tested in AbstractObjectGLTest */ /* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::GL::KHR::debug>() && if(!Context::current().isExtensionSupported<Extensions::GL::KHR::debug>() &&
@ -102,6 +108,7 @@ void AbstractTextureGLTest::label() {
CORRADE_COMPARE(texture.label(), "MyTexture"); CORRADE_COMPARE(texture.label(), "MyTexture");
} }
#endif
}} }}

12
src/Magnum/Test/BufferGLTest.cpp

@ -43,7 +43,9 @@ struct BufferGLTest: OpenGLTester {
void constructMove(); void constructMove();
void wrap(); void wrap();
#ifndef MAGNUM_TARGET_WEBGL
void label(); void label();
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void bindBase(); void bindBase();
@ -51,9 +53,11 @@ struct BufferGLTest: OpenGLTester {
#endif #endif
void data(); void data();
#ifndef MAGNUM_TARGET_WEBGL
void map(); void map();
void mapRange(); void mapRange();
void mapRangeExplicitFlush(); void mapRangeExplicitFlush();
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void copy(); void copy();
#endif #endif
@ -66,7 +70,9 @@ BufferGLTest::BufferGLTest() {
&BufferGLTest::constructMove, &BufferGLTest::constructMove,
&BufferGLTest::wrap, &BufferGLTest::wrap,
#ifndef MAGNUM_TARGET_WEBGL
&BufferGLTest::label, &BufferGLTest::label,
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
&BufferGLTest::bindBase, &BufferGLTest::bindBase,
@ -74,9 +80,11 @@ BufferGLTest::BufferGLTest() {
#endif #endif
&BufferGLTest::data, &BufferGLTest::data,
#ifndef MAGNUM_TARGET_WEBGL
&BufferGLTest::map, &BufferGLTest::map,
&BufferGLTest::mapRange, &BufferGLTest::mapRange,
&BufferGLTest::mapRangeExplicitFlush, &BufferGLTest::mapRangeExplicitFlush,
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
&BufferGLTest::copy, &BufferGLTest::copy,
#endif #endif
@ -138,6 +146,7 @@ void BufferGLTest::wrap() {
glDeleteBuffers(1, &id); glDeleteBuffers(1, &id);
} }
#ifndef MAGNUM_TARGET_WEBGL
void BufferGLTest::label() { void BufferGLTest::label() {
/* No-Op version is tested in AbstractObjectGLTest */ /* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::GL::KHR::debug>() && if(!Context::current().isExtensionSupported<Extensions::GL::KHR::debug>() &&
@ -154,6 +163,7 @@ void BufferGLTest::label() {
CORRADE_COMPARE(buffer.label(), "MyBuffer"); CORRADE_COMPARE(buffer.label(), "MyBuffer");
} }
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void BufferGLTest::bindBase() { void BufferGLTest::bindBase() {
@ -262,6 +272,7 @@ void BufferGLTest::data() {
#endif #endif
} }
#ifndef MAGNUM_TARGET_WEBGL
void BufferGLTest::map() { void BufferGLTest::map() {
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::OES::mapbuffer>()) if(!Context::current().isExtensionSupported<Extensions::GL::OES::mapbuffer>())
@ -369,6 +380,7 @@ void BufferGLTest::mapRangeExplicitFlush() {
CORRADE_COMPARE(changedContents[4], 107); CORRADE_COMPARE(changedContents[4], 107);
#endif #endif
} }
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void BufferGLTest::copy() { void BufferGLTest::copy() {

46
src/Magnum/Test/CMakeLists.txt

@ -128,20 +128,14 @@ set_target_properties(
PROPERTIES FOLDER "Magnum/Test") PROPERTIES FOLDER "Magnum/Test")
if(BUILD_GL_TESTS) if(BUILD_GL_TESTS)
corrade_add_test(AbstractObjectGLTest AbstractObjectGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(AbstractQueryGLTest AbstractQueryGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(AbstractTextureGLTest AbstractTextureGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(AbstractTextureGLTest AbstractTextureGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(BufferGLTest BufferGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(BufferGLTest BufferGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(ContextGLTest ContextGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(ContextGLTest ContextGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(CubeMapTextureGLTest CubeMapTextureGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(CubeMapTextureGLTest CubeMapTextureGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(DebugOutputGLTest DebugOutputGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(FramebufferGLTest FramebufferGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(FramebufferGLTest FramebufferGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(MeshGLTest MeshGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(MeshGLTest MeshGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(PixelStorageGLTest PixelStorageGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(RenderbufferGLTest RenderbufferGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(RenderbufferGLTest RenderbufferGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(SampleQueryGLTest SampleQueryGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(TextureGLTest TextureGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(TextureGLTest TextureGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(TimeQueryGLTest TimeQueryGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_resource(AbstractShaderProgramGLTest_RES AbstractShaderProgramGLTestFiles/resources.conf) corrade_add_resource(AbstractShaderProgramGLTest_RES AbstractShaderProgramGLTestFiles/resources.conf)
corrade_add_test(AbstractShaderProgramGLTest corrade_add_test(AbstractShaderProgramGLTest
@ -149,26 +143,28 @@ if(BUILD_GL_TESTS)
${AbstractShaderProgramGLTest_RES} ${AbstractShaderProgramGLTest_RES}
LIBRARIES MagnumOpenGLTester) LIBRARIES MagnumOpenGLTester)
if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID)
set(SHADERGLTEST_FILES_DIR "ShaderGLTestFiles")
else()
set(SHADERGLTEST_FILES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ShaderGLTestFiles)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/configure.h) ${CMAKE_CURRENT_BINARY_DIR}/configure.h)
corrade_add_test(ShaderGLTest ShaderGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(ShaderGLTest ShaderGLTest.cpp
LIBRARIES MagnumOpenGLTester
FILES ShaderGLTestFiles/shader.glsl)
target_include_directories(ShaderGLTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(ShaderGLTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties( set_target_properties(
AbstractObjectGLTest
AbstractQueryGLTest
AbstractTextureGLTest AbstractTextureGLTest
BufferGLTest BufferGLTest
ContextGLTest ContextGLTest
CubeMapTextureGLTest CubeMapTextureGLTest
DebugOutputGLTest
FramebufferGLTest FramebufferGLTest
MeshGLTest MeshGLTest
PixelStorageGLTest
RenderbufferGLTest RenderbufferGLTest
SampleQueryGLTest
TextureGLTest TextureGLTest
TimeQueryGLTest
AbstractShaderProgramGLTest AbstractShaderProgramGLTest
AbstractShaderProgramGLTest_RES-dependencies AbstractShaderProgramGLTest_RES-dependencies
@ -176,6 +172,30 @@ if(BUILD_GL_TESTS)
ShaderGLTest ShaderGLTest
PROPERTIES FOLDER "Magnum/Test") PROPERTIES FOLDER "Magnum/Test")
if(NOT MAGNUM_TARGET_WEBGL)
corrade_add_test(AbstractObjectGLTest AbstractObjectGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(DebugOutputGLTest DebugOutputGLTest.cpp LIBRARIES MagnumOpenGLTester)
set_target_properties(
AbstractObjectGLTest
DebugOutputGLTest
PROPERTIES FOLDER "Magnum/Test")
endif()
if(NOT (MAGNUM_TARGET_WEBGL AND MAGNUM_TARGET_GLES2))
corrade_add_test(AbstractQueryGLTest AbstractQueryGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(PixelStorageGLTest PixelStorageGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(SampleQueryGLTest SampleQueryGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(TimeQueryGLTest TimeQueryGLTest.cpp LIBRARIES MagnumOpenGLTester)
set_target_properties(
AbstractQueryGLTest
PixelStorageGLTest
SampleQueryGLTest
TimeQueryGLTest
PROPERTIES FOLDER "Magnum/Test")
endif()
if(NOT MAGNUM_TARGET_GLES2) if(NOT MAGNUM_TARGET_GLES2)
corrade_add_test(BufferImageGLTest BufferImageGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(BufferImageGLTest BufferImageGLTest.cpp LIBRARIES MagnumOpenGLTester)
corrade_add_test(BufferTextureGLTest BufferTextureGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(BufferTextureGLTest BufferTextureGLTest.cpp LIBRARIES MagnumOpenGLTester)

111
src/Magnum/Test/CubeMapTextureGLTest.cpp

@ -55,10 +55,12 @@ struct CubeMapTextureGLTest: OpenGLTester {
#endif #endif
void sampling(); void sampling();
#ifndef MAGNUM_TARGET_WEBGL
void samplingSRGBDecode(); void samplingSRGBDecode();
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void samplingSwizzle(); void samplingSwizzle();
#else #elif !defined(MAGNUM_TARGET_WEBGL)
void samplingMaxLevel(); void samplingMaxLevel();
void samplingCompare(); void samplingCompare();
#endif #endif
@ -68,7 +70,7 @@ struct CubeMapTextureGLTest: OpenGLTester {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void samplingDepthStencilMode(); void samplingDepthStencilMode();
#endif #endif
#ifdef MAGNUM_TARGET_GLES #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
void samplingBorder(); void samplingBorder();
#endif #endif
@ -91,7 +93,9 @@ struct CubeMapTextureGLTest: OpenGLTester {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void compressedImageBuffer(); void compressedImageBuffer();
#endif #endif
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void immutableCompressedImage(); void immutableCompressedImage();
#endif
void compressedSubImage(); void compressedSubImage();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void compressedSubImageBuffer(); void compressedSubImageBuffer();
@ -121,7 +125,13 @@ namespace {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
enum: std::size_t { PixelStorageDataCount = 2 }; enum: std::size_t { PixelStorageDataCount =
#if !defined(MAGNUM_TARGET_GLES2) || !defined(MAGNUM_TARGET_WEBGL)
2
#else
1
#endif
};
const struct { const struct {
const char* name; const char* name;
@ -288,10 +298,12 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
#endif #endif
&CubeMapTextureGLTest::sampling, &CubeMapTextureGLTest::sampling,
#ifndef MAGNUM_TARGET_WEBGL
&CubeMapTextureGLTest::samplingSRGBDecode, &CubeMapTextureGLTest::samplingSRGBDecode,
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
&CubeMapTextureGLTest::samplingSwizzle, &CubeMapTextureGLTest::samplingSwizzle,
#else #elif !defined(MAGNUM_TARGET_WEBGL)
&CubeMapTextureGLTest::samplingMaxLevel, &CubeMapTextureGLTest::samplingMaxLevel,
&CubeMapTextureGLTest::samplingCompare, &CubeMapTextureGLTest::samplingCompare,
#endif #endif
@ -301,7 +313,7 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
&CubeMapTextureGLTest::samplingDepthStencilMode, &CubeMapTextureGLTest::samplingDepthStencilMode,
#endif #endif
#ifdef MAGNUM_TARGET_GLES #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
&CubeMapTextureGLTest::samplingBorder, &CubeMapTextureGLTest::samplingBorder,
#endif #endif
@ -331,7 +343,9 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
&CubeMapTextureGLTest::compressedImageBuffer, &CubeMapTextureGLTest::compressedImageBuffer,
#endif #endif
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&CubeMapTextureGLTest::immutableCompressedImage, &CubeMapTextureGLTest::immutableCompressedImage,
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&CubeMapTextureGLTest::compressedFullImageQuery, &CubeMapTextureGLTest::compressedFullImageQuery,
&CubeMapTextureGLTest::compressedFullImageQueryBuffer, &CubeMapTextureGLTest::compressedFullImageQueryBuffer,
@ -468,6 +482,7 @@ void CubeMapTextureGLTest::sampling() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#ifndef MAGNUM_TARGET_WEBGL
void CubeMapTextureGLTest::samplingSRGBDecode() { void CubeMapTextureGLTest::samplingSRGBDecode() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::sRGB>()) if(!Context::current().isExtensionSupported<Extensions::GL::EXT::sRGB>())
@ -481,6 +496,7 @@ void CubeMapTextureGLTest::samplingSRGBDecode() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void CubeMapTextureGLTest::samplingSwizzle() { void CubeMapTextureGLTest::samplingSwizzle() {
@ -494,7 +510,7 @@ void CubeMapTextureGLTest::samplingSwizzle() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#else #elif !defined(MAGNUM_TARGET_WEBGL)
void CubeMapTextureGLTest::samplingMaxLevel() { void CubeMapTextureGLTest::samplingMaxLevel() {
if(!Context::current().isExtensionSupported<Extensions::GL::APPLE::texture_max_level>()) if(!Context::current().isExtensionSupported<Extensions::GL::APPLE::texture_max_level>())
CORRADE_SKIP(Extensions::GL::APPLE::texture_max_level::string() + std::string(" is not supported.")); CORRADE_SKIP(Extensions::GL::APPLE::texture_max_level::string() + std::string(" is not supported."));
@ -556,7 +572,7 @@ void CubeMapTextureGLTest::samplingDepthStencilMode() {
} }
#endif #endif
#ifdef MAGNUM_TARGET_GLES #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
void CubeMapTextureGLTest::samplingBorder() { void CubeMapTextureGLTest::samplingBorder() {
if(!Context::current().isExtensionSupported<Extensions::GL::NV::texture_border_clamp>() && if(!Context::current().isExtensionSupported<Extensions::GL::NV::texture_border_clamp>() &&
!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_border_clamp>()) !Context::current().isExtensionSupported<Extensions::GL::EXT::texture_border_clamp>())
@ -572,7 +588,13 @@ void CubeMapTextureGLTest::samplingBorder() {
void CubeMapTextureGLTest::storage() { void CubeMapTextureGLTest::storage() {
CubeMapTexture texture; CubeMapTexture texture;
texture.setStorage(5, TextureFormat::RGBA8, Vector2i(32)); texture.setStorage(5,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::RGBA8,
#else
TextureFormat::RGBA,
#endif
Vector2i(32));
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
@ -598,12 +620,22 @@ void CubeMapTextureGLTest::image() {
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name); setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_WEBGL
if(PixelStorageData[testCaseInstanceId()].storage != PixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::EXT::unpack_subimage>()) if(PixelStorageData[testCaseInstanceId()].storage != PixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::EXT::unpack_subimage>())
CORRADE_SKIP(Extensions::GL::EXT::unpack_subimage::string() + std::string(" is not supported.")); CORRADE_SKIP(Extensions::GL::EXT::unpack_subimage::string() + std::string(" is not supported."));
#else
if(PixelStorageData[testCaseInstanceId()].storage != PixelStorage{})
CORRADE_SKIP("Image unpack is not supported in WebGL 1.");
#endif
#endif #endif
CubeMapTexture texture; CubeMapTexture texture;
texture.setImage(CubeMapCoordinate::PositiveX, 0, TextureFormat::RGBA8, texture.setImage(CubeMapCoordinate::PositiveX, 0,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::RGBA8,
#else
TextureFormat::RGBA,
#endif
ImageView2D{PixelStorageData[testCaseInstanceId()].storage, ImageView2D{PixelStorageData[testCaseInstanceId()].storage,
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2),
PixelStorageData[testCaseInstanceId()].dataSparse}); PixelStorageData[testCaseInstanceId()].dataSparse});
@ -671,22 +703,33 @@ void CubeMapTextureGLTest::subImage() {
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name); setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_WEBGL
if(PixelStorageData[testCaseInstanceId()].storage != PixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::EXT::unpack_subimage>()) if(PixelStorageData[testCaseInstanceId()].storage != PixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::EXT::unpack_subimage>())
CORRADE_SKIP(Extensions::GL::EXT::unpack_subimage::string() + std::string(" is not supported.")); CORRADE_SKIP(Extensions::GL::EXT::unpack_subimage::string() + std::string(" is not supported."));
#else
if(PixelStorageData[testCaseInstanceId()].storage != PixelStorage{})
CORRADE_SKIP("Image unpack is not supported in WebGL 1.");
#endif
#endif
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
constexpr TextureFormat format = TextureFormat::RGBA8;
#else
constexpr TextureFormat format = TextureFormat::RGBA;
#endif #endif
CubeMapTexture texture; CubeMapTexture texture;
texture.setImage(CubeMapCoordinate::PositiveX, 0, TextureFormat::RGBA8, texture.setImage(CubeMapCoordinate::PositiveX, 0, format,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
texture.setImage(CubeMapCoordinate::NegativeX, 0, TextureFormat::RGBA8, texture.setImage(CubeMapCoordinate::NegativeX, 0, format,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
texture.setImage(CubeMapCoordinate::PositiveY, 0, TextureFormat::RGBA8, texture.setImage(CubeMapCoordinate::PositiveY, 0, format,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
texture.setImage(CubeMapCoordinate::NegativeY, 0, TextureFormat::RGBA8, texture.setImage(CubeMapCoordinate::NegativeY, 0, format,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
texture.setImage(CubeMapCoordinate::PositiveZ, 0, TextureFormat::RGBA8, texture.setImage(CubeMapCoordinate::PositiveZ, 0, format,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
texture.setImage(CubeMapCoordinate::NegativeZ, 0, TextureFormat::RGBA8, texture.setImage(CubeMapCoordinate::NegativeZ, 0, format,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
texture.setSubImage(CubeMapCoordinate::PositiveX, 0, Vector2i(1), ImageView2D{ texture.setSubImage(CubeMapCoordinate::PositiveX, 0, Vector2i(1), ImageView2D{
PixelStorageData[testCaseInstanceId()].storage, PixelStorageData[testCaseInstanceId()].storage,
@ -899,6 +942,7 @@ void CubeMapTextureGLTest::compressedImageBuffer() {
} }
#endif #endif
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void CubeMapTextureGLTest::immutableCompressedImage() { void CubeMapTextureGLTest::immutableCompressedImage() {
setTestCaseDescription(CompressedPixelStorageData[testCaseInstanceId()].name); setTestCaseDescription(CompressedPixelStorageData[testCaseInstanceId()].name);
@ -953,6 +997,7 @@ void CubeMapTextureGLTest::immutableCompressedImage() {
TestSuite::Compare::Container); TestSuite::Compare::Container);
#endif #endif
} }
#endif
namespace { namespace {
/* Just 12x12 zeros compressed using RGBA DXT3 by the driver */ /* Just 12x12 zeros compressed using RGBA DXT3 by the driver */
@ -1275,18 +1320,24 @@ void CubeMapTextureGLTest::compressedFullImageQueryBuffer() {
#endif #endif
void CubeMapTextureGLTest::generateMipmap() { void CubeMapTextureGLTest::generateMipmap() {
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
constexpr TextureFormat format = TextureFormat::RGBA8;
#else
constexpr TextureFormat format = TextureFormat::RGBA;
#endif
CubeMapTexture texture; CubeMapTexture texture;
texture.setImage(CubeMapCoordinate::PositiveX, 0, TextureFormat::RGBA8, texture.setImage(CubeMapCoordinate::PositiveX, 0, format,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32))); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapCoordinate::PositiveY, 0, TextureFormat::RGBA8, texture.setImage(CubeMapCoordinate::PositiveY, 0, format,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32))); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapCoordinate::PositiveZ, 0, TextureFormat::RGBA8, texture.setImage(CubeMapCoordinate::PositiveZ, 0, format,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32))); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapCoordinate::NegativeX, 0, TextureFormat::RGBA8, texture.setImage(CubeMapCoordinate::NegativeX, 0, format,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32))); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapCoordinate::NegativeY, 0, TextureFormat::RGBA8, texture.setImage(CubeMapCoordinate::NegativeY, 0, format,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32))); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapCoordinate::NegativeZ, 0, TextureFormat::RGBA8, texture.setImage(CubeMapCoordinate::NegativeZ, 0, format,
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32))); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
/** @todo How to test this on ES? */ /** @todo How to test this on ES? */
@ -1314,7 +1365,13 @@ void CubeMapTextureGLTest::generateMipmap() {
void CubeMapTextureGLTest::invalidateImage() { void CubeMapTextureGLTest::invalidateImage() {
CubeMapTexture texture; CubeMapTexture texture;
texture.setStorage(2, TextureFormat::RGBA8, Vector2i(32)); texture.setStorage(2,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::RGBA8,
#else
TextureFormat::RGBA,
#endif
Vector2i(32));
texture.invalidateImage(1); texture.invalidateImage(1);
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
@ -1322,16 +1379,24 @@ void CubeMapTextureGLTest::invalidateImage() {
void CubeMapTextureGLTest::invalidateSubImage() { void CubeMapTextureGLTest::invalidateSubImage() {
CubeMapTexture texture; CubeMapTexture texture;
texture.setStorage(2, TextureFormat::RGBA8, Vector2i(32)); texture.setStorage(2,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::RGBA8,
#else
TextureFormat::RGBA,
#endif
Vector2i(32));
texture.invalidateSubImage(1, Vector3i(2), Vector3i(Vector2i(8), 4)); texture.invalidateSubImage(1, Vector3i(2), Vector3i(Vector2i(8), 4));
{ {
#ifndef MAGNUM_TARGET_WEBGL
/* Mesa (last checked version 12.0.6) treats cube map images as having /* Mesa (last checked version 12.0.6) treats cube map images as having
only single layer instead of 6, so the above invalidation call only single layer instead of 6, so the above invalidation call
fails. Relevant source code (scroll up to see imageDepth = 1): fails. Relevant source code (scroll up to see imageDepth = 1):
https://github.com/anholt/mesa/blob/1c0ac1976ac7a87bfd2ade47f25047c31527f18a/src/mesa/main/texobj.c#L2179 */ https://github.com/anholt/mesa/blob/1c0ac1976ac7a87bfd2ade47f25047c31527f18a/src/mesa/main/texobj.c#L2179 */
CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa), CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa),
"Broken on Mesa."); "Broken on Mesa.");
#endif
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }

232
src/Magnum/Test/FramebufferGLTest.cpp

@ -60,16 +60,22 @@ struct FramebufferGLTest: OpenGLTester {
void constructMove(); void constructMove();
void wrap(); void wrap();
#ifndef MAGNUM_TARGET_WEBGL
void label(); void label();
#endif
void attachRenderbuffer(); void attachRenderbuffer();
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void attachRenderbufferMultisample(); void attachRenderbufferMultisample();
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void attachTexture1D(); void attachTexture1D();
#endif #endif
void attachTexture2D(); void attachTexture2D();
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void attachTexture3D(); void attachTexture3D();
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void attachTexture1DArray(); void attachTexture1DArray();
#endif #endif
@ -110,7 +116,9 @@ struct FramebufferGLTest: OpenGLTester {
void clearStencil(); void clearStencil();
void clearDepthStencil(); void clearDepthStencil();
#endif #endif
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void invalidate(); void invalidate();
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void invalidateSub(); void invalidateSub();
#endif #endif
@ -133,7 +141,9 @@ struct FramebufferGLTest: OpenGLTester {
void copySubImageTexture1D(); void copySubImageTexture1D();
#endif #endif
void copySubImageTexture2D(); void copySubImageTexture2D();
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void copySubImageTexture3D(); void copySubImageTexture3D();
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void copySubImageTexture1DArray(); void copySubImageTexture1DArray();
#endif #endif
@ -147,9 +157,11 @@ struct FramebufferGLTest: OpenGLTester {
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void copySubImageCubeMapTextureArray(); void copySubImageCubeMapTextureArray();
#endif #endif
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void blit(); void blit();
#endif
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
private: private:
TextureFormat rgbaFormatES2, depthStencilFormatES2; TextureFormat rgbaFormatES2, depthStencilFormatES2;
#endif #endif
@ -161,16 +173,22 @@ FramebufferGLTest::FramebufferGLTest() {
&FramebufferGLTest::constructMove, &FramebufferGLTest::constructMove,
&FramebufferGLTest::wrap, &FramebufferGLTest::wrap,
#ifndef MAGNUM_TARGET_WEBGL
&FramebufferGLTest::label, &FramebufferGLTest::label,
#endif
&FramebufferGLTest::attachRenderbuffer, &FramebufferGLTest::attachRenderbuffer,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&FramebufferGLTest::attachRenderbufferMultisample, &FramebufferGLTest::attachRenderbufferMultisample,
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&FramebufferGLTest::attachTexture1D, &FramebufferGLTest::attachTexture1D,
#endif #endif
&FramebufferGLTest::attachTexture2D, &FramebufferGLTest::attachTexture2D,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&FramebufferGLTest::attachTexture3D, &FramebufferGLTest::attachTexture3D,
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&FramebufferGLTest::attachTexture1DArray, &FramebufferGLTest::attachTexture1DArray,
#endif #endif
@ -211,7 +229,9 @@ FramebufferGLTest::FramebufferGLTest() {
&FramebufferGLTest::clearStencil, &FramebufferGLTest::clearStencil,
&FramebufferGLTest::clearDepthStencil, &FramebufferGLTest::clearDepthStencil,
#endif #endif
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&FramebufferGLTest::invalidate, &FramebufferGLTest::invalidate,
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
&FramebufferGLTest::invalidateSub, &FramebufferGLTest::invalidateSub,
#endif #endif
@ -234,7 +254,9 @@ FramebufferGLTest::FramebufferGLTest() {
&FramebufferGLTest::copySubImageTexture1D, &FramebufferGLTest::copySubImageTexture1D,
#endif #endif
&FramebufferGLTest::copySubImageTexture2D, &FramebufferGLTest::copySubImageTexture2D,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&FramebufferGLTest::copySubImageTexture3D, &FramebufferGLTest::copySubImageTexture3D,
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&FramebufferGLTest::copySubImageTexture1DArray, &FramebufferGLTest::copySubImageTexture1DArray,
#endif #endif
@ -248,9 +270,12 @@ FramebufferGLTest::FramebufferGLTest() {
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
&FramebufferGLTest::copySubImageCubeMapTextureArray, &FramebufferGLTest::copySubImageCubeMapTextureArray,
#endif #endif
&FramebufferGLTest::blit}); #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&FramebufferGLTest::blit
#endif
});
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(Context::current().isExtensionSupported<Extensions::GL::EXT::texture_storage>()) { if(Context::current().isExtensionSupported<Extensions::GL::EXT::texture_storage>()) {
rgbaFormatES2 = TextureFormat::RGBA8; rgbaFormatES2 = TextureFormat::RGBA8;
depthStencilFormatES2 = TextureFormat::Depth24Stencil8; depthStencilFormatES2 = TextureFormat::Depth24Stencil8;
@ -332,6 +357,7 @@ void FramebufferGLTest::wrap() {
glDeleteFramebuffers(1, &id); glDeleteFramebuffers(1, &id);
} }
#ifndef MAGNUM_TARGET_WEBGL
void FramebufferGLTest::label() { void FramebufferGLTest::label() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
@ -353,6 +379,7 @@ void FramebufferGLTest::label() {
CORRADE_COMPARE(framebuffer.label(), "MyFramebuffer"); CORRADE_COMPARE(framebuffer.label(), "MyFramebuffer");
} }
#endif
void FramebufferGLTest::attachRenderbuffer() { void FramebufferGLTest::attachRenderbuffer() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -370,16 +397,22 @@ void FramebufferGLTest::attachRenderbuffer() {
/* Separate depth and stencil renderbuffers are not supported (or at least /* Separate depth and stencil renderbuffers are not supported (or at least
on my NVidia, thus we need to do this juggling with one renderbuffer */ on my NVidia, thus we need to do this juggling with one renderbuffer */
Renderbuffer depthStencil; Renderbuffer depthStencil;
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>()) if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
#endif #endif
{ {
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string(); Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string();
#endif #endif
depthStencil.setStorage(RenderbufferFormat::Depth24Stencil8, Vector2i(128)); depthStencil.setStorage(
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
RenderbufferFormat::Depth24Stencil8,
#else
RenderbufferFormat::DepthStencil,
#endif
Vector2i(128));
} }
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
else depthStencil.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128)); else depthStencil.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128));
#endif #endif
@ -387,7 +420,7 @@ void FramebufferGLTest::attachRenderbuffer() {
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color) framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color)
.attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil); .attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil);
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>()) if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
#endif #endif
{ {
@ -399,6 +432,7 @@ void FramebufferGLTest::attachRenderbuffer() {
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete); CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
} }
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void FramebufferGLTest::attachRenderbufferMultisample() { void FramebufferGLTest::attachRenderbufferMultisample() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
@ -416,7 +450,7 @@ void FramebufferGLTest::attachRenderbufferMultisample() {
color.setStorageMultisample(Renderbuffer::maxSamples(), RenderbufferFormat::RGBA4, Vector2i(128)); color.setStorageMultisample(Renderbuffer::maxSamples(), RenderbufferFormat::RGBA4, Vector2i(128));
#endif #endif
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::OES::packed_depth_stencil); MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::OES::packed_depth_stencil);
#endif #endif
@ -436,6 +470,7 @@ void FramebufferGLTest::attachRenderbufferMultisample() {
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete); CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete); CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
} }
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void FramebufferGLTest::attachTexture1D() { void FramebufferGLTest::attachTexture1D() {
@ -471,11 +506,15 @@ void FramebufferGLTest::attachTexture2D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
Texture2D color; Texture2D color;
#ifndef MAGNUM_TARGET_GLES2 color.setStorage(1,
color.setStorage(1, TextureFormat::RGBA8, Vector2i(128)); #ifndef MAGNUM_TARGET_GLES2
#else TextureFormat::RGBA8,
color.setStorage(1, rgbaFormatES2, Vector2i(128)); #elif !defined(MAGNUM_TARGET_WEBGL)
#endif rgbaFormatES2,
#else
TextureFormat::RGBA,
#endif
Vector2i(128));
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
@ -483,18 +522,24 @@ void FramebufferGLTest::attachTexture2D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>()) if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
#endif #endif
{ {
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string(); Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string();
#endif #endif
/** @todo Is there any better way to select proper sized/unsized format on ES2? */ /** @todo Is there any better way to select proper sized/unsized format on ES2? */
Texture2D depthStencil; Texture2D depthStencil;
#ifndef MAGNUM_TARGET_GLES2 #if !defined(MAGNUM_TARGET_GLES2) || defined(MAGNUM_TARGET_WEBGL)
depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, Vector2i(128)); depthStencil.setStorage(1,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::Depth24Stencil8,
#else
TextureFormat::DepthStencil,
#endif
Vector2i(128));
framebuffer.attachTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0); framebuffer.attachTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0);
#else #else
depthStencil.setStorage(1, depthStencilFormatES2, Vector2i(128)); depthStencil.setStorage(1, depthStencilFormatES2, Vector2i(128));
@ -503,7 +548,7 @@ void FramebufferGLTest::attachTexture2D() {
#endif #endif
} }
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
else if(Context::current().isExtensionSupported<Extensions::GL::OES::depth_texture>()) { else if(Context::current().isExtensionSupported<Extensions::GL::OES::depth_texture>()) {
Debug() << "Using" << Extensions::GL::OES::depth_texture::string(); Debug() << "Using" << Extensions::GL::OES::depth_texture::string();
@ -518,6 +563,7 @@ void FramebufferGLTest::attachTexture2D() {
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete); CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
} }
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void FramebufferGLTest::attachTexture3D() { void FramebufferGLTest::attachTexture3D() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
@ -528,11 +574,13 @@ void FramebufferGLTest::attachTexture3D() {
#endif #endif
Texture3D color; Texture3D color;
#ifndef MAGNUM_TARGET_GLES2 color.setStorage(1,
color.setStorage(1, TextureFormat::RGBA8, Vector3i(128)); #ifndef MAGNUM_TARGET_GLES2
#else TextureFormat::RGBA8,
color.setStorage(1, rgbaFormatES2, Vector3i(128)); #else
#endif rgbaFormatES2,
#endif
Vector3i(128));
Framebuffer framebuffer({{}, Vector2i(128)}); Framebuffer framebuffer({{}, Vector2i(128)});
framebuffer.attachTextureLayer(Framebuffer::ColorAttachment(0), color, 0, 0); framebuffer.attachTextureLayer(Framebuffer::ColorAttachment(0), color, 0, 0);
@ -541,6 +589,7 @@ void FramebufferGLTest::attachTexture3D() {
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete); CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete); CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
} }
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void FramebufferGLTest::attachTexture1DArray() { void FramebufferGLTest::attachTexture1DArray() {
@ -686,25 +735,35 @@ void FramebufferGLTest::attachCubeMapTexture() {
Framebuffer framebuffer({{}, Vector2i(128)}); Framebuffer framebuffer({{}, Vector2i(128)});
CubeMapTexture color; CubeMapTexture color;
#ifndef MAGNUM_TARGET_GLES2 color.setStorage(1,
color.setStorage(1, TextureFormat::RGBA8, Vector2i(128)); #ifndef MAGNUM_TARGET_GLES2
#else TextureFormat::RGBA8,
color.setStorage(1, rgbaFormatES2, Vector2i(128)); #elif !defined(MAGNUM_TARGET_WEBGL)
#endif rgbaFormatES2,
#else
TextureFormat::RGBA,
#endif
Vector2i(128));
framebuffer.attachCubeMapTexture(Framebuffer::ColorAttachment(0), color, CubeMapCoordinate::NegativeZ, 0); framebuffer.attachCubeMapTexture(Framebuffer::ColorAttachment(0), color, CubeMapCoordinate::NegativeZ, 0);
CubeMapTexture depthStencil; CubeMapTexture depthStencil;
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>()) if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
#endif #endif
{ {
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string(); Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string();
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #if !defined(MAGNUM_TARGET_GLES2) || defined(MAGNUM_TARGET_WEBGL)
depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, Vector2i(128)); depthStencil.setStorage(1,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::Depth24Stencil8,
#else
TextureFormat::DepthStencil,
#endif
Vector2i(128));
framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, CubeMapCoordinate::NegativeZ, 0); framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, CubeMapCoordinate::NegativeZ, 0);
#else #else
depthStencil.setStorage(1, depthStencilFormatES2, Vector2i(128)); depthStencil.setStorage(1, depthStencilFormatES2, Vector2i(128));
@ -713,7 +772,7 @@ void FramebufferGLTest::attachCubeMapTexture() {
#endif #endif
} }
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
else if(Context::current().isExtensionSupported<Extensions::GL::OES::depth_texture>()) { else if(Context::current().isExtensionSupported<Extensions::GL::OES::depth_texture>()) {
Debug() << "Using" << Extensions::GL::OES::depth_texture::string(); Debug() << "Using" << Extensions::GL::OES::depth_texture::string();
@ -937,24 +996,37 @@ void FramebufferGLTest::multipleColorOutputs() {
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
#elif defined(MAGNUM_TARGET_GLES2) #elif defined(MAGNUM_TARGET_GLES2)
#ifdef MAGNUM_TARGET_WEBGL
if(!Context::current().isExtensionSupported<Extensions::GL::WEBGL::draw_buffers>())
CORRADE_SKIP(Extensions::GL::WEBGL::draw_buffers::string() + std::string(" is not available."));
#else
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::draw_buffers>() && if(!Context::current().isExtensionSupported<Extensions::GL::EXT::draw_buffers>() &&
!Context::current().isExtensionSupported<Extensions::GL::NV::draw_buffers>()) !Context::current().isExtensionSupported<Extensions::GL::NV::draw_buffers>())
CORRADE_SKIP("No required extension available."); CORRADE_SKIP("No required extension available.");
#endif #endif
#endif
Texture2D color1; Texture2D color1;
#ifndef MAGNUM_TARGET_GLES2 color1.setStorage(1,
color1.setStorage(1, TextureFormat::RGBA8, Vector2i(128)); #ifndef MAGNUM_TARGET_GLES2
#else TextureFormat::RGBA8,
color1.setStorage(1, rgbaFormatES2, Vector2i(128)); #elif !defined(MAGNUM_TARGET_WEBGL)
#endif rgbaFormatES2,
#else
TextureFormat::RGBA,
#endif
Vector2i(128));
Texture2D color2; Texture2D color2;
#ifndef MAGNUM_TARGET_GLES2 color2.setStorage(1,
color2.setStorage(1, TextureFormat::RGBA8, Vector2i(128)); #ifndef MAGNUM_TARGET_GLES2
#else TextureFormat::RGBA8,
color2.setStorage(1, rgbaFormatES2, Vector2i(128)); #elif !defined(MAGNUM_TARGET_WEBGL)
#endif rgbaFormatES2,
#else
TextureFormat::RGBA,
#endif
Vector2i(128));
Renderbuffer depth; Renderbuffer depth;
depth.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128)); depth.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128));
@ -967,6 +1039,7 @@ void FramebufferGLTest::multipleColorOutputs() {
{1, Framebuffer::ColorAttachment(0)}, {1, Framebuffer::ColorAttachment(0)},
{2, Framebuffer::DrawAttachment::None}}); {2, Framebuffer::DrawAttachment::None}});
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
if(Context::current().isExtensionSupported<Extensions::GL::NV::read_buffer>()) if(Context::current().isExtensionSupported<Extensions::GL::NV::read_buffer>())
#endif #endif
@ -976,6 +1049,7 @@ void FramebufferGLTest::multipleColorOutputs() {
#endif #endif
framebuffer.mapForRead(Framebuffer::ColorAttachment(1)); framebuffer.mapForRead(Framebuffer::ColorAttachment(1));
} }
#endif
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete); CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
@ -998,16 +1072,22 @@ void FramebufferGLTest::clear() {
/* Separate depth and stencil renderbuffers are not supported (or at least /* Separate depth and stencil renderbuffers are not supported (or at least
on my NVidia, thus we need to do this juggling with one renderbuffer */ on my NVidia, thus we need to do this juggling with one renderbuffer */
Renderbuffer depthStencil; Renderbuffer depthStencil;
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>()) if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
#endif #endif
{ {
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string(); Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string();
#endif #endif
depthStencil.setStorage(RenderbufferFormat::Depth24Stencil8, Vector2i(128)); depthStencil.setStorage(
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
RenderbufferFormat::Depth24Stencil8,
#else
RenderbufferFormat::DepthStencil,
#endif
Vector2i(128));
} }
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
else depthStencil.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128)); else depthStencil.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128));
#endif #endif
@ -1015,7 +1095,7 @@ void FramebufferGLTest::clear() {
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color) framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color)
.attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil); .attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil);
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>()) if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
#endif #endif
{ {
@ -1234,6 +1314,7 @@ void FramebufferGLTest::clearDepthStencil() {
} }
#endif #endif
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void FramebufferGLTest::invalidate() { void FramebufferGLTest::invalidate() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
@ -1260,6 +1341,7 @@ void FramebufferGLTest::invalidate() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void FramebufferGLTest::invalidateSub() { void FramebufferGLTest::invalidateSub() {
@ -1310,16 +1392,22 @@ void FramebufferGLTest::read() {
/* Separate depth and stencil renderbuffers are not supported (or at least /* Separate depth and stencil renderbuffers are not supported (or at least
on my NVidia, thus we need to do this juggling with one renderbuffer */ on my NVidia, thus we need to do this juggling with one renderbuffer */
Renderbuffer depthStencil; Renderbuffer depthStencil;
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>()) if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
#endif #endif
{ {
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string(); Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string();
#endif #endif
depthStencil.setStorage(RenderbufferFormat::Depth24Stencil8, Vector2i(128)); depthStencil.setStorage(
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
RenderbufferFormat::Depth24Stencil8,
#else
RenderbufferFormat::DepthStencil,
#endif
Vector2i(128));
} }
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
else depthStencil.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128)); else depthStencil.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128));
#endif #endif
@ -1327,7 +1415,7 @@ void FramebufferGLTest::read() {
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color) framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color)
.attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil); .attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil);
#ifdef MAGNUM_TARGET_GLES2 #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>()) if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
#endif #endif
{ {
@ -1351,6 +1439,7 @@ void FramebufferGLTest::read() {
CORRADE_COMPARE(colorImage.data().size(), (DataOffset + 8*16)*sizeof(Color4ub)); CORRADE_COMPARE(colorImage.data().size(), (DataOffset + 8*16)*sizeof(Color4ub));
CORRADE_COMPARE(colorImage.data<Color4ub>()[DataOffset], Color4ub(128, 64, 32, 17)); CORRADE_COMPARE(colorImage.data<Color4ub>()[DataOffset], Color4ub(128, 64, 32, 17));
#ifndef MAGNUM_TARGET_WEBGL
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
if(Context::current().isExtensionSupported<Extensions::GL::NV::read_depth>()) if(Context::current().isExtensionSupported<Extensions::GL::NV::read_depth>())
#endif #endif
@ -1394,6 +1483,7 @@ void FramebufferGLTest::read() {
CORRADE_COMPARE(depthStencilImage.data<UnsignedInt>()[0] >> 8, 12378300); CORRADE_COMPARE(depthStencilImage.data<UnsignedInt>()[0] >> 8, 12378300);
CORRADE_COMPARE(depthStencilImage.data<UnsignedByte>()[0], 67); CORRADE_COMPARE(depthStencilImage.data<UnsignedByte>()[0], 67);
} }
#endif
} }
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -1481,8 +1571,10 @@ void FramebufferGLTest::copyImageTexture2D() {
storage.setStorage(1, storage.setStorage(1,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
TextureFormat::RGBA8, TextureFormat::RGBA8,
#else #elif !defined(MAGNUM_TARGET_WEBGL)
rgbaFormatES2, rgbaFormatES2,
#else
TextureFormat::RGBA,
#endif #endif
Vector2i{4}) Vector2i{4})
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData}); .setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
@ -1494,8 +1586,10 @@ void FramebufferGLTest::copyImageTexture2D() {
fb.copyImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, 0, fb.copyImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, 0,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
TextureFormat::RGBA8 TextureFormat::RGBA8
#else #elif !defined(MAGNUM_TARGET_WEBGL)
rgbaFormatES2 rgbaFormatES2
#else
TextureFormat::RGBA
#endif #endif
); );
@ -1575,8 +1669,10 @@ void FramebufferGLTest::copyImageCubeMapTexture() {
storage.setStorage(1, storage.setStorage(1,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
TextureFormat::RGBA8, TextureFormat::RGBA8,
#else #elif !defined(MAGNUM_TARGET_WEBGL)
rgbaFormatES2, rgbaFormatES2,
#else
TextureFormat::RGBA,
#endif #endif
Vector2i{4}) Vector2i{4})
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData}); .setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
@ -1588,8 +1684,10 @@ void FramebufferGLTest::copyImageCubeMapTexture() {
fb.copyImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, CubeMapCoordinate::PositiveX, 0, fb.copyImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, CubeMapCoordinate::PositiveX, 0,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
TextureFormat::RGBA8 TextureFormat::RGBA8
#else #elif !defined(MAGNUM_TARGET_WEBGL)
rgbaFormatES2 rgbaFormatES2
#else
TextureFormat::RGBA
#endif #endif
); );
@ -1641,8 +1739,10 @@ void FramebufferGLTest::copySubImageTexture2D() {
storage.setStorage(1, storage.setStorage(1,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
TextureFormat::RGBA8, TextureFormat::RGBA8,
#else #elif !defined(MAGNUM_TARGET_WEBGL)
rgbaFormatES2, rgbaFormatES2,
#else
TextureFormat::RGBA,
#endif #endif
Vector2i{4}) Vector2i{4})
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData}); .setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
@ -1654,8 +1754,10 @@ void FramebufferGLTest::copySubImageTexture2D() {
texture.setStorage(1, texture.setStorage(1,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
TextureFormat::RGBA8, TextureFormat::RGBA8,
#else #elif !defined(MAGNUM_TARGET_WEBGL)
rgbaFormatES2, rgbaFormatES2,
#else
TextureFormat::RGBA,
#endif #endif
Vector2i{4}) Vector2i{4})
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, ZeroStorage}); .setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, ZeroStorage});
@ -1839,8 +1941,10 @@ void FramebufferGLTest::copySubImageCubeMapTexture() {
storage.setStorage(1, storage.setStorage(1,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
TextureFormat::RGBA8, TextureFormat::RGBA8,
#else #elif !defined(MAGNUM_TARGET_WEBGL)
rgbaFormatES2, rgbaFormatES2,
#else
TextureFormat::RGBA,
#endif #endif
Vector2i{4}) Vector2i{4})
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData}); .setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
@ -1852,8 +1956,10 @@ void FramebufferGLTest::copySubImageCubeMapTexture() {
texture.setStorage(1, texture.setStorage(1,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
TextureFormat::RGBA8, TextureFormat::RGBA8,
#else #elif !defined(MAGNUM_TARGET_WEBGL)
rgbaFormatES2, rgbaFormatES2,
#else
TextureFormat::RGBA,
#endif #endif
Vector2i{4}) Vector2i{4})
.setSubImage(CubeMapCoordinate::NegativeY, 0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, ZeroStorage}); .setSubImage(CubeMapCoordinate::NegativeY, 0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, ZeroStorage});
@ -1935,6 +2041,7 @@ void FramebufferGLTest::copySubImageCubeMapTextureArray() {
} }
#endif #endif
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void FramebufferGLTest::blit() { void FramebufferGLTest::blit() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
@ -1983,6 +2090,7 @@ void FramebufferGLTest::blit() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(imageAfter.data<Color4ub>()[0], Color4ub(128, 64, 32, 17)); CORRADE_COMPARE(imageAfter.data<Color4ub>()[0], Color4ub(128, 64, 32, 17));
} }
#endif
}} }}

49
src/Magnum/Test/MeshGLTest.cpp

@ -43,7 +43,7 @@
namespace Magnum { namespace Test { namespace Magnum { namespace Test {
/* Tests also MeshView class. */ /* Tests also the MeshView class. */
struct MeshGLTest: OpenGLTester { struct MeshGLTest: OpenGLTester {
explicit MeshGLTest(); explicit MeshGLTest();
@ -53,7 +53,9 @@ struct MeshGLTest: OpenGLTester {
void constructMove(); void constructMove();
void wrap(); void wrap();
#ifndef MAGNUM_TARGET_WEBGL
void label(); void label();
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void addVertexBufferUnsignedInt(); void addVertexBufferUnsignedInt();
@ -88,8 +90,10 @@ struct MeshGLTest: OpenGLTester {
void addVertexBufferIntWithUnsignedShort(); void addVertexBufferIntWithUnsignedShort();
void addVertexBufferIntWithShort(); void addVertexBufferIntWithShort();
#endif #endif
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
/* Other Float types omitted (covered by addVertexBufferNormalized()) */ /* Other Float types omitted (covered by addVertexBufferNormalized()) */
void addVertexBufferFloatWithHalfFloat(); void addVertexBufferFloatWithHalfFloat();
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void addVertexBufferFloatWithDouble(); void addVertexBufferFloatWithDouble();
void addVertexBufferVector3WithUnsignedInt10f11f11fRev(); void addVertexBufferVector3WithUnsignedInt10f11f11fRev();
@ -148,7 +152,10 @@ MeshGLTest::MeshGLTest() {
&MeshGLTest::constructMove, &MeshGLTest::constructMove,
&MeshGLTest::wrap, &MeshGLTest::wrap,
&MeshGLTest::label}); #ifndef MAGNUM_TARGET_WEBGL
&MeshGLTest::label
#endif
});
/* First instance is always using Attribute, second DynamicAttribute */ /* First instance is always using Attribute, second DynamicAttribute */
addInstancedTests({ addInstancedTests({
@ -185,7 +192,9 @@ MeshGLTest::MeshGLTest() {
&MeshGLTest::addVertexBufferIntWithUnsignedShort, &MeshGLTest::addVertexBufferIntWithUnsignedShort,
&MeshGLTest::addVertexBufferIntWithShort, &MeshGLTest::addVertexBufferIntWithShort,
#endif #endif
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
&MeshGLTest::addVertexBufferFloatWithHalfFloat, &MeshGLTest::addVertexBufferFloatWithHalfFloat,
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&MeshGLTest::addVertexBufferFloatWithDouble, &MeshGLTest::addVertexBufferFloatWithDouble,
&MeshGLTest::addVertexBufferVector3WithUnsignedInt10f11f11fRev, &MeshGLTest::addVertexBufferVector3WithUnsignedInt10f11f11fRev,
@ -215,8 +224,10 @@ MeshGLTest::MeshGLTest() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&MeshGLTest::setBaseVertex, &MeshGLTest::setBaseVertex,
#endif #endif
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
&MeshGLTest::setInstanceCount, &MeshGLTest::setInstanceCount,
&MeshGLTest::setInstanceCountIndexed, &MeshGLTest::setInstanceCountIndexed,
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&MeshGLTest::setInstanceCountBaseInstance, &MeshGLTest::setInstanceCountBaseInstance,
&MeshGLTest::setInstanceCountBaseInstanceIndexed, &MeshGLTest::setInstanceCountBaseInstanceIndexed,
@ -224,7 +235,9 @@ MeshGLTest::MeshGLTest() {
&MeshGLTest::setInstanceCountBaseVertexBaseInstance, &MeshGLTest::setInstanceCountBaseVertexBaseInstance,
#endif #endif
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
&MeshGLTest::addVertexBufferInstancedFloat, &MeshGLTest::addVertexBufferInstancedFloat,
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
&MeshGLTest::addVertexBufferInstancedInteger, &MeshGLTest::addVertexBufferInstancedInteger,
#endif #endif
@ -334,6 +347,7 @@ void MeshGLTest::wrap() {
#endif #endif
} }
#ifndef MAGNUM_TARGET_WEBGL
void MeshGLTest::label() { void MeshGLTest::label() {
/* No-Op version is tested in AbstractObjectGLTest */ /* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::GL::KHR::debug>() && if(!Context::current().isExtensionSupported<Extensions::GL::KHR::debug>() &&
@ -350,6 +364,7 @@ void MeshGLTest::label() {
CORRADE_COMPARE(mesh.label(), "MyMesh"); CORRADE_COMPARE(mesh.label(), "MyMesh");
} }
#endif
namespace { namespace {
struct FloatShader: AbstractShaderProgram { struct FloatShader: AbstractShaderProgram {
@ -849,7 +864,12 @@ void MeshGLTest::addVertexBufferMatrixNxN() {
const auto value = Checker(FloatShader("mat3", const auto value = Checker(FloatShader("mat3",
"vec4(valueInterpolated[0][0], valueInterpolated[1][1], valueInterpolated[2][2], 0.0)"), "vec4(valueInterpolated[0][0], valueInterpolated[1][1], valueInterpolated[2][2], 0.0)"),
RenderbufferFormat::RGBA8, mesh).get<Color3ub>(PixelFormat::RGBA, PixelType::UnsignedByte); #ifndef MAGNUM_TARGET_GLES2
RenderbufferFormat::RGBA8,
#else
RenderbufferFormat::RGBA4,
#endif
mesh).get<Color3ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, Color3ub(96, 24, 156)); CORRADE_COMPARE(value, Color3ub(96, 24, 156));
@ -1142,6 +1162,7 @@ void MeshGLTest::addVertexBufferIntWithShort() {
} }
#endif #endif
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void MeshGLTest::addVertexBufferFloatWithHalfFloat() { void MeshGLTest::addVertexBufferFloatWithHalfFloat() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::half_float_vertex>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::half_float_vertex>())
@ -1179,6 +1200,7 @@ void MeshGLTest::addVertexBufferFloatWithHalfFloat() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 186); CORRADE_COMPARE(value, 186);
} }
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void MeshGLTest::addVertexBufferFloatWithDouble() { void MeshGLTest::addVertexBufferFloatWithDouble() {
@ -1827,10 +1849,15 @@ void MeshGLTest::setInstanceCount() {
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::draw_instanced>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::draw_instanced>())
CORRADE_SKIP(Extensions::GL::ARB::draw_instanced::string() + std::string(" is not available.")); CORRADE_SKIP(Extensions::GL::ARB::draw_instanced::string() + std::string(" is not available."));
#elif defined(MAGNUM_TARGET_GLES2) #elif defined(MAGNUM_TARGET_GLES2)
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current().isExtensionSupported<Extensions::GL::ANGLE::instanced_arrays>() && if(!Context::current().isExtensionSupported<Extensions::GL::ANGLE::instanced_arrays>() &&
!Context::current().isExtensionSupported<Extensions::GL::EXT::draw_instanced>() && !Context::current().isExtensionSupported<Extensions::GL::EXT::draw_instanced>() &&
!Context::current().isExtensionSupported<Extensions::GL::NV::draw_instanced>()) !Context::current().isExtensionSupported<Extensions::GL::NV::draw_instanced>())
CORRADE_SKIP("Required extension is not available."); CORRADE_SKIP("Required extension is not available.");
#else
if(!Context::current().isExtensionSupported<Extensions::GL::ANGLE::instanced_arrays>())
CORRADE_SKIP(Extensions::GL::ANGLE::instanced_arrays::string() + std::string(" is not available."));
#endif
#endif #endif
typedef Attribute<0, Float> Attribute; typedef Attribute<0, Float> Attribute;
@ -1868,10 +1895,15 @@ void MeshGLTest::setInstanceCountIndexed() {
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::draw_instanced>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::draw_instanced>())
CORRADE_SKIP(Extensions::GL::ARB::draw_instanced::string() + std::string(" is not available.")); CORRADE_SKIP(Extensions::GL::ARB::draw_instanced::string() + std::string(" is not available."));
#elif defined(MAGNUM_TARGET_GLES2) #elif defined(MAGNUM_TARGET_GLES2)
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current().isExtensionSupported<Extensions::GL::ANGLE::instanced_arrays>() && if(!Context::current().isExtensionSupported<Extensions::GL::ANGLE::instanced_arrays>() &&
!Context::current().isExtensionSupported<Extensions::GL::EXT::draw_instanced>() && !Context::current().isExtensionSupported<Extensions::GL::EXT::draw_instanced>() &&
!Context::current().isExtensionSupported<Extensions::GL::NV::draw_instanced>()) !Context::current().isExtensionSupported<Extensions::GL::NV::draw_instanced>())
CORRADE_SKIP("Required extension is not available."); CORRADE_SKIP("Required extension is not available.");
#else
if(!Context::current().isExtensionSupported<Extensions::GL::ANGLE::instanced_arrays>())
CORRADE_SKIP(Extensions::GL::ANGLE::instanced_arrays::string() + std::string(" is not available."));
#endif
#endif #endif
Buffer vertices; Buffer vertices;
@ -2041,6 +2073,7 @@ void MeshGLTest::setInstanceCountBaseVertexBaseInstance() {
} }
#endif #endif
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void MeshGLTest::addVertexBufferInstancedFloat() { void MeshGLTest::addVertexBufferInstancedFloat() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::draw_instanced>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::draw_instanced>())
@ -2048,6 +2081,7 @@ void MeshGLTest::addVertexBufferInstancedFloat() {
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::instanced_arrays>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::instanced_arrays>())
CORRADE_SKIP(Extensions::GL::ARB::instanced_arrays::string() + std::string(" is not available.")); CORRADE_SKIP(Extensions::GL::ARB::instanced_arrays::string() + std::string(" is not available."));
#elif defined(MAGNUM_TARGET_GLES2) #elif defined(MAGNUM_TARGET_GLES2)
#ifndef MAGNUM_TARGET_WEBGL
if(!Context::current().isExtensionSupported<Extensions::GL::ANGLE::instanced_arrays>() && if(!Context::current().isExtensionSupported<Extensions::GL::ANGLE::instanced_arrays>() &&
!Context::current().isExtensionSupported<Extensions::GL::EXT::instanced_arrays>() && !Context::current().isExtensionSupported<Extensions::GL::EXT::instanced_arrays>() &&
!Context::current().isExtensionSupported<Extensions::GL::NV::instanced_arrays>()) !Context::current().isExtensionSupported<Extensions::GL::NV::instanced_arrays>())
@ -2056,6 +2090,10 @@ void MeshGLTest::addVertexBufferInstancedFloat() {
!Context::current().isExtensionSupported<Extensions::GL::EXT::draw_instanced>() && !Context::current().isExtensionSupported<Extensions::GL::EXT::draw_instanced>() &&
!Context::current().isExtensionSupported<Extensions::GL::NV::draw_instanced>()) !Context::current().isExtensionSupported<Extensions::GL::NV::draw_instanced>())
CORRADE_SKIP("Required drawing extension is not available."); CORRADE_SKIP("Required drawing extension is not available.");
#else
if(!Context::current().isExtensionSupported<Extensions::GL::ANGLE::instanced_arrays>())
CORRADE_SKIP(Extensions::GL::ANGLE::instanced_arrays::string() + std::string(" is not available."));
#endif
#endif #endif
typedef Attribute<0, Float> Attribute; typedef Attribute<0, Float> Attribute;
@ -2087,6 +2125,7 @@ void MeshGLTest::addVertexBufferInstancedFloat() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 96); CORRADE_COMPARE(value, 96);
} }
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void MeshGLTest::addVertexBufferInstancedInteger() { void MeshGLTest::addVertexBufferInstancedInteger() {
@ -2211,7 +2250,7 @@ template<class T> T MultiChecker::get(PixelFormat format, PixelType type) {
#endif #endif
void MeshGLTest::multiDraw() { void MeshGLTest::multiDraw() {
#ifdef MAGNUM_TARGET_GLES #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::multi_draw_arrays>()) if(!Context::current().isExtensionSupported<Extensions::GL::EXT::multi_draw_arrays>())
Debug() << Extensions::GL::EXT::multi_draw_arrays::string() << "not supported, using fallback implementation"; Debug() << Extensions::GL::EXT::multi_draw_arrays::string() << "not supported, using fallback implementation";
#endif #endif
@ -2235,7 +2274,7 @@ void MeshGLTest::multiDraw() {
} }
void MeshGLTest::multiDrawIndexed() { void MeshGLTest::multiDrawIndexed() {
#ifdef MAGNUM_TARGET_GLES #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::multi_draw_arrays>()) if(!Context::current().isExtensionSupported<Extensions::GL::EXT::multi_draw_arrays>())
Debug() << Extensions::GL::EXT::multi_draw_arrays::string() << "not supported, using fallback implementation"; Debug() << Extensions::GL::EXT::multi_draw_arrays::string() << "not supported, using fallback implementation";
#endif #endif

16
src/Magnum/Test/RenderbufferGLTest.cpp

@ -40,10 +40,14 @@ struct RenderbufferGLTest: OpenGLTester {
void constructMove(); void constructMove();
void wrap(); void wrap();
#ifndef MAGNUM_TARGET_WEBGL
void label(); void label();
#endif
void setStorage(); void setStorage();
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void setStorageMultisample(); void setStorageMultisample();
#endif
}; };
RenderbufferGLTest::RenderbufferGLTest() { RenderbufferGLTest::RenderbufferGLTest() {
@ -52,10 +56,16 @@ RenderbufferGLTest::RenderbufferGLTest() {
&RenderbufferGLTest::constructMove, &RenderbufferGLTest::constructMove,
&RenderbufferGLTest::wrap, &RenderbufferGLTest::wrap,
#ifndef MAGNUM_TARGET_WEBGL
&RenderbufferGLTest::label, &RenderbufferGLTest::label,
#endif
&RenderbufferGLTest::setStorage, &RenderbufferGLTest::setStorage,
&RenderbufferGLTest::setStorageMultisample});
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&RenderbufferGLTest::setStorageMultisample
#endif
});
} }
void RenderbufferGLTest::construct() { void RenderbufferGLTest::construct() {
@ -126,6 +136,7 @@ void RenderbufferGLTest::wrap() {
glDeleteRenderbuffers(1, &id); glDeleteRenderbuffers(1, &id);
} }
#ifndef MAGNUM_TARGET_WEBGL
void RenderbufferGLTest::label() { void RenderbufferGLTest::label() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
@ -145,6 +156,7 @@ void RenderbufferGLTest::label() {
CORRADE_COMPARE(renderbuffer.label(), "MyRenderbuffer"); CORRADE_COMPARE(renderbuffer.label(), "MyRenderbuffer");
} }
#endif
void RenderbufferGLTest::setStorage() { void RenderbufferGLTest::setStorage() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -163,6 +175,7 @@ void RenderbufferGLTest::setStorage() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void RenderbufferGLTest::setStorageMultisample() { void RenderbufferGLTest::setStorageMultisample() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
@ -183,6 +196,7 @@ void RenderbufferGLTest::setStorageMultisample() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
}} }}

6
src/Magnum/Test/ShaderGLTest.cpp

@ -42,7 +42,9 @@ struct ShaderGLTest: OpenGLTester {
void constructCopy(); void constructCopy();
void constructMove(); void constructMove();
#ifndef MAGNUM_TARGET_WEBGL
void label(); void label();
#endif
void addSource(); void addSource();
void addSourceNoVersion(); void addSourceNoVersion();
@ -58,7 +60,9 @@ ShaderGLTest::ShaderGLTest() {
&ShaderGLTest::constructCopy, &ShaderGLTest::constructCopy,
&ShaderGLTest::constructMove, &ShaderGLTest::constructMove,
#ifndef MAGNUM_TARGET_WEBGL
&ShaderGLTest::label, &ShaderGLTest::label,
#endif
&ShaderGLTest::addSource, &ShaderGLTest::addSource,
&ShaderGLTest::addSourceNoVersion, &ShaderGLTest::addSourceNoVersion,
@ -141,6 +145,7 @@ void ShaderGLTest::constructMove() {
#endif #endif
} }
#ifndef MAGNUM_TARGET_WEBGL
void ShaderGLTest::label() { void ShaderGLTest::label() {
/* No-Op version is tested in AbstractObjectGLTest */ /* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::GL::KHR::debug>() && if(!Context::current().isExtensionSupported<Extensions::GL::KHR::debug>() &&
@ -159,6 +164,7 @@ void ShaderGLTest::label() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
void ShaderGLTest::addSource() { void ShaderGLTest::addSource() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES

152
src/Magnum/Test/TextureGLTest.cpp

@ -50,19 +50,25 @@ struct TextureGLTest: OpenGLTester {
void construct1D(); void construct1D();
#endif #endif
void construct2D(); void construct2D();
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void construct3D(); void construct3D();
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void wrap1D(); void wrap1D();
#endif #endif
void wrap2D(); void wrap2D();
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void wrap3D(); void wrap3D();
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void bind1D(); void bind1D();
#endif #endif
void bind2D(); void bind2D();
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void bind3D(); void bind3D();
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -76,13 +82,17 @@ struct TextureGLTest: OpenGLTester {
void sampling1D(); void sampling1D();
#endif #endif
void sampling2D(); void sampling2D();
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void sampling3D(); void sampling3D();
#endif
#ifndef MAGNUM_TARGET_WEBGL
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void samplingSRGBDecode1D(); void samplingSRGBDecode1D();
#endif #endif
void samplingSRGBDecode2D(); void samplingSRGBDecode2D();
void samplingSRGBDecode3D(); void samplingSRGBDecode3D();
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -90,7 +100,7 @@ struct TextureGLTest: OpenGLTester {
#endif #endif
void samplingSwizzle2D(); void samplingSwizzle2D();
void samplingSwizzle3D(); void samplingSwizzle3D();
#else #elif !defined(MAGNUM_TARGET_WEBGL)
void samplingMaxLevel2D(); void samplingMaxLevel2D();
void samplingMaxLevel3D(); void samplingMaxLevel3D();
void samplingCompare2D(); void samplingCompare2D();
@ -110,7 +120,7 @@ struct TextureGLTest: OpenGLTester {
void samplingDepthStencilMode2D(); void samplingDepthStencilMode2D();
void samplingDepthStencilMode3D(); void samplingDepthStencilMode3D();
#endif #endif
#ifdef MAGNUM_TARGET_GLES #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
void samplingBorder2D(); void samplingBorder2D();
void samplingBorder3D(); void samplingBorder3D();
#endif #endif
@ -119,7 +129,9 @@ struct TextureGLTest: OpenGLTester {
void storage1D(); void storage1D();
#endif #endif
void storage2D(); void storage2D();
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void storage3D(); void storage3D();
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void image1D(); void image1D();
@ -163,6 +175,7 @@ struct TextureGLTest: OpenGLTester {
void compressedSubImage2DQueryBuffer(); void compressedSubImage2DQueryBuffer();
#endif #endif
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void image3D(); void image3D();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void image3DBuffer(); void image3DBuffer();
@ -188,24 +201,31 @@ struct TextureGLTest: OpenGLTester {
void compressedSubImage3DQuery(); void compressedSubImage3DQuery();
void compressedSubImage3DQueryBuffer(); void compressedSubImage3DQueryBuffer();
#endif #endif
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void generateMipmap1D(); void generateMipmap1D();
#endif #endif
void generateMipmap2D(); void generateMipmap2D();
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void generateMipmap3D(); void generateMipmap3D();
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void invalidateImage1D(); void invalidateImage1D();
#endif #endif
void invalidateImage2D(); void invalidateImage2D();
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void invalidateImage3D(); void invalidateImage3D();
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void invalidateSubImage1D(); void invalidateSubImage1D();
#endif #endif
void invalidateSubImage2D(); void invalidateSubImage2D();
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void invalidateSubImage3D(); void invalidateSubImage3D();
#endif
void srgbStorage(); void srgbStorage();
void srgbAlphaStorage(); void srgbAlphaStorage();
@ -403,19 +423,25 @@ TextureGLTest::TextureGLTest() {
&TextureGLTest::construct1D, &TextureGLTest::construct1D,
#endif #endif
&TextureGLTest::construct2D, &TextureGLTest::construct2D,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&TextureGLTest::construct3D, &TextureGLTest::construct3D,
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&TextureGLTest::wrap1D, &TextureGLTest::wrap1D,
#endif #endif
&TextureGLTest::wrap2D, &TextureGLTest::wrap2D,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&TextureGLTest::wrap3D, &TextureGLTest::wrap3D,
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&TextureGLTest::bind1D, &TextureGLTest::bind1D,
#endif #endif
&TextureGLTest::bind2D, &TextureGLTest::bind2D,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&TextureGLTest::bind3D, &TextureGLTest::bind3D,
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -429,13 +455,17 @@ TextureGLTest::TextureGLTest() {
&TextureGLTest::sampling1D, &TextureGLTest::sampling1D,
#endif #endif
&TextureGLTest::sampling2D, &TextureGLTest::sampling2D,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&TextureGLTest::sampling3D, &TextureGLTest::sampling3D,
#endif
#ifndef MAGNUM_TARGET_WEBGL
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&TextureGLTest::samplingSRGBDecode1D, &TextureGLTest::samplingSRGBDecode1D,
#endif #endif
&TextureGLTest::samplingSRGBDecode2D, &TextureGLTest::samplingSRGBDecode2D,
&TextureGLTest::samplingSRGBDecode3D, &TextureGLTest::samplingSRGBDecode3D,
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -443,7 +473,7 @@ TextureGLTest::TextureGLTest() {
#endif #endif
&TextureGLTest::samplingSwizzle2D, &TextureGLTest::samplingSwizzle2D,
&TextureGLTest::samplingSwizzle3D, &TextureGLTest::samplingSwizzle3D,
#else #elif !defined(MAGNUM_TARGET_WEBGL)
&TextureGLTest::samplingMaxLevel2D, &TextureGLTest::samplingMaxLevel2D,
&TextureGLTest::samplingMaxLevel3D, &TextureGLTest::samplingMaxLevel3D,
&TextureGLTest::samplingCompare2D, &TextureGLTest::samplingCompare2D,
@ -463,7 +493,7 @@ TextureGLTest::TextureGLTest() {
&TextureGLTest::samplingDepthStencilMode2D, &TextureGLTest::samplingDepthStencilMode2D,
&TextureGLTest::samplingDepthStencilMode3D, &TextureGLTest::samplingDepthStencilMode3D,
#endif #endif
#ifdef MAGNUM_TARGET_GLES #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
&TextureGLTest::samplingBorder2D, &TextureGLTest::samplingBorder2D,
&TextureGLTest::samplingBorder3D, &TextureGLTest::samplingBorder3D,
#endif #endif
@ -472,7 +502,10 @@ TextureGLTest::TextureGLTest() {
&TextureGLTest::storage1D, &TextureGLTest::storage1D,
#endif #endif
&TextureGLTest::storage2D, &TextureGLTest::storage2D,
&TextureGLTest::storage3D}); #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&TextureGLTest::storage3D
#endif
});
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
addInstancedTests({ addInstancedTests({
@ -522,6 +555,7 @@ TextureGLTest::TextureGLTest() {
#endif #endif
}, CompressedPixelStorage2DDataCount); }, CompressedPixelStorage2DDataCount);
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
addInstancedTests({ addInstancedTests({
&TextureGLTest::image3D, &TextureGLTest::image3D,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -551,25 +585,32 @@ TextureGLTest::TextureGLTest() {
&TextureGLTest::compressedSubImage3DQueryBuffer &TextureGLTest::compressedSubImage3DQueryBuffer
#endif #endif
}, CompressedPixelStorage3DDataCount); }, CompressedPixelStorage3DDataCount);
#endif
addTests({ addTests({
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&TextureGLTest::generateMipmap1D, &TextureGLTest::generateMipmap1D,
#endif #endif
&TextureGLTest::generateMipmap2D, &TextureGLTest::generateMipmap2D,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&TextureGLTest::generateMipmap3D, &TextureGLTest::generateMipmap3D,
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&TextureGLTest::invalidateImage1D, &TextureGLTest::invalidateImage1D,
#endif #endif
&TextureGLTest::invalidateImage2D, &TextureGLTest::invalidateImage2D,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&TextureGLTest::invalidateImage3D, &TextureGLTest::invalidateImage3D,
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&TextureGLTest::invalidateSubImage1D, &TextureGLTest::invalidateSubImage1D,
#endif #endif
&TextureGLTest::invalidateSubImage2D, &TextureGLTest::invalidateSubImage2D,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
&TextureGLTest::invalidateSubImage3D, &TextureGLTest::invalidateSubImage3D,
#endif
&TextureGLTest::srgbStorage, &TextureGLTest::srgbStorage,
&TextureGLTest::srgbAlphaStorage}); &TextureGLTest::srgbAlphaStorage});
@ -599,6 +640,7 @@ void TextureGLTest::construct2D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void TextureGLTest::construct3D() { void TextureGLTest::construct3D() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>()) if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>())
@ -614,6 +656,7 @@ void TextureGLTest::construct3D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void TextureGLTest::wrap1D() { void TextureGLTest::wrap1D() {
@ -647,6 +690,7 @@ void TextureGLTest::wrap2D() {
glDeleteTextures(1, &id); glDeleteTextures(1, &id);
} }
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void TextureGLTest::wrap3D() { void TextureGLTest::wrap3D() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>()) if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>())
@ -666,6 +710,7 @@ void TextureGLTest::wrap3D() {
Texture3D::wrap(id); Texture3D::wrap(id);
glDeleteTextures(1, &id); glDeleteTextures(1, &id);
} }
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void TextureGLTest::bind1D() { void TextureGLTest::bind1D() {
@ -707,6 +752,7 @@ void TextureGLTest::bind2D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void TextureGLTest::bind3D() { void TextureGLTest::bind3D() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>()) if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>())
@ -730,6 +776,7 @@ void TextureGLTest::bind3D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -905,12 +952,16 @@ void TextureGLTest::sampling2D() {
.setWrapping(Sampler::Wrapping::ClampToEdge) .setWrapping(Sampler::Wrapping::ClampToEdge)
#endif #endif
.setMaxAnisotropy(Sampler::maxMaxAnisotropy()) .setMaxAnisotropy(Sampler::maxMaxAnisotropy())
#ifndef MAGNUM_TARGET_GLES2
.setCompareMode(Sampler::CompareMode::CompareRefToTexture) .setCompareMode(Sampler::CompareMode::CompareRefToTexture)
.setCompareFunction(Sampler::CompareFunction::GreaterOrEqual); .setCompareFunction(Sampler::CompareFunction::GreaterOrEqual)
#endif
;
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#ifndef MAGNUM_TARGET_WEBGL
void TextureGLTest::samplingSRGBDecode2D() { void TextureGLTest::samplingSRGBDecode2D() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::sRGB>()) if(!Context::current().isExtensionSupported<Extensions::GL::EXT::sRGB>())
@ -924,6 +975,7 @@ void TextureGLTest::samplingSRGBDecode2D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void TextureGLTest::samplingSwizzle2D() { void TextureGLTest::samplingSwizzle2D() {
@ -937,7 +989,7 @@ void TextureGLTest::samplingSwizzle2D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#else #elif !defined(MAGNUM_TARGET_WEBGL)
void TextureGLTest::samplingMaxLevel2D() { void TextureGLTest::samplingMaxLevel2D() {
if(!Context::current().isExtensionSupported<Extensions::GL::APPLE::texture_max_level>()) if(!Context::current().isExtensionSupported<Extensions::GL::APPLE::texture_max_level>())
CORRADE_SKIP(Extensions::GL::APPLE::texture_max_level::string() + std::string(" is not supported.")); CORRADE_SKIP(Extensions::GL::APPLE::texture_max_level::string() + std::string(" is not supported."));
@ -998,7 +1050,7 @@ void TextureGLTest::samplingDepthStencilMode2D() {
} }
#endif #endif
#ifdef MAGNUM_TARGET_GLES #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
void TextureGLTest::samplingBorder2D() { void TextureGLTest::samplingBorder2D() {
if(!Context::current().isExtensionSupported<Extensions::GL::NV::texture_border_clamp>() && if(!Context::current().isExtensionSupported<Extensions::GL::NV::texture_border_clamp>() &&
!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_border_clamp>()) !Context::current().isExtensionSupported<Extensions::GL::EXT::texture_border_clamp>())
@ -1012,6 +1064,7 @@ void TextureGLTest::samplingBorder2D() {
} }
#endif #endif
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void TextureGLTest::sampling3D() { void TextureGLTest::sampling3D() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>()) if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>())
@ -1139,6 +1192,7 @@ void TextureGLTest::samplingBorder3D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif #endif
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void TextureGLTest::storage1D() { void TextureGLTest::storage1D() {
@ -1160,7 +1214,13 @@ void TextureGLTest::storage1D() {
void TextureGLTest::storage2D() { void TextureGLTest::storage2D() {
Texture2D texture; Texture2D texture;
texture.setStorage(5, TextureFormat::RGBA8, Vector2i(32)); texture.setStorage(5,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::RGBA8,
#else
TextureFormat::RGBA,
#endif
Vector2i(32));
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
@ -1181,6 +1241,7 @@ void TextureGLTest::storage2D() {
#endif #endif
} }
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void TextureGLTest::storage3D() { void TextureGLTest::storage3D() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>()) if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>())
@ -1208,6 +1269,7 @@ void TextureGLTest::storage3D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
#endif #endif
} }
#endif
namespace { namespace {
@ -1392,12 +1454,23 @@ void TextureGLTest::image2D() {
setTestCaseDescription(PixelStorage2DData[testCaseInstanceId()].name); setTestCaseDescription(PixelStorage2DData[testCaseInstanceId()].name);
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_WEBGL
if(PixelStorage2DData[testCaseInstanceId()].storage != PixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::EXT::unpack_subimage>()) if(PixelStorage2DData[testCaseInstanceId()].storage != PixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::EXT::unpack_subimage>())
CORRADE_SKIP(Extensions::GL::EXT::unpack_subimage::string() + std::string(" is not supported.")); CORRADE_SKIP(Extensions::GL::EXT::unpack_subimage::string() + std::string(" is not supported."));
#else
if(PixelStorage2DData[testCaseInstanceId()].storage != PixelStorage{})
CORRADE_SKIP("Image unpack is not supported in WebGL 1.");
#endif
#endif #endif
Texture2D texture; Texture2D texture;
texture.setImage(0, TextureFormat::RGBA8, ImageView2D{ texture.setImage(0,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::RGBA8,
#else
TextureFormat::RGBA,
#endif
ImageView2D{
PixelStorage2DData[testCaseInstanceId()].storage, PixelStorage2DData[testCaseInstanceId()].storage,
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2),
PixelStorage2DData[testCaseInstanceId()].dataSparse}); PixelStorage2DData[testCaseInstanceId()].dataSparse});
@ -1465,12 +1538,22 @@ void TextureGLTest::subImage2D() {
setTestCaseDescription(PixelStorage2DData[testCaseInstanceId()].name); setTestCaseDescription(PixelStorage2DData[testCaseInstanceId()].name);
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_WEBGL
if(PixelStorage2DData[testCaseInstanceId()].storage != PixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::EXT::unpack_subimage>()) if(PixelStorage2DData[testCaseInstanceId()].storage != PixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::EXT::unpack_subimage>())
CORRADE_SKIP(Extensions::GL::EXT::unpack_subimage::string() + std::string(" is not supported.")); CORRADE_SKIP(Extensions::GL::EXT::unpack_subimage::string() + std::string(" is not supported."));
#else
if(PixelStorage2DData[testCaseInstanceId()].storage != PixelStorage{})
CORRADE_SKIP("Image unpack is not supported in WebGL 1.");
#endif
#endif #endif
Texture2D texture; Texture2D texture;
texture.setImage(0, TextureFormat::RGBA8, texture.setImage(0,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::RGBA8,
#else
TextureFormat::RGBA,
#endif
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero2D)); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero2D));
texture.setSubImage(0, Vector2i(1), ImageView2D{PixelStorage2DData[testCaseInstanceId()].storage, texture.setSubImage(0, Vector2i(1), ImageView2D{PixelStorage2DData[testCaseInstanceId()].storage,
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2),
@ -1813,6 +1896,7 @@ void TextureGLTest::compressedSubImage2DQueryBuffer() {
} }
#endif #endif
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void TextureGLTest::image3D() { void TextureGLTest::image3D() {
setTestCaseDescription(PixelStorage3DData[testCaseInstanceId()].name); setTestCaseDescription(PixelStorage3DData[testCaseInstanceId()].name);
@ -2279,6 +2363,7 @@ void TextureGLTest::compressedSubImage3DQueryBuffer() {
} }
} }
#endif #endif
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void TextureGLTest::generateMipmap1D() { void TextureGLTest::generateMipmap1D() {
@ -2314,7 +2399,12 @@ void TextureGLTest::generateMipmap2D() {
#endif #endif
Texture2D texture; Texture2D texture;
texture.setImage(0, TextureFormat::RGBA8, texture.setImage(0,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::RGBA8,
#else
TextureFormat::RGBA,
#endif
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32))); ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
/** @todo How to test this on ES? */ /** @todo How to test this on ES? */
@ -2340,6 +2430,7 @@ void TextureGLTest::generateMipmap2D() {
#endif #endif
} }
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void TextureGLTest::generateMipmap3D() { void TextureGLTest::generateMipmap3D() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
@ -2375,6 +2466,7 @@ void TextureGLTest::generateMipmap3D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
#endif #endif
} }
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void TextureGLTest::invalidateImage1D() { void TextureGLTest::invalidateImage1D() {
@ -2388,12 +2480,19 @@ void TextureGLTest::invalidateImage1D() {
void TextureGLTest::invalidateImage2D() { void TextureGLTest::invalidateImage2D() {
Texture2D texture; Texture2D texture;
texture.setStorage(2, TextureFormat::RGBA8, Vector2i(32)); texture.setStorage(2,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::RGBA8,
#else
TextureFormat::RGBA,
#endif
Vector2i(32));
texture.invalidateImage(1); texture.invalidateImage(1);
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void TextureGLTest::invalidateImage3D() { void TextureGLTest::invalidateImage3D() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>()) if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>())
@ -2406,6 +2505,7 @@ void TextureGLTest::invalidateImage3D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void TextureGLTest::invalidateSubImage1D() { void TextureGLTest::invalidateSubImage1D() {
@ -2419,12 +2519,19 @@ void TextureGLTest::invalidateSubImage1D() {
void TextureGLTest::invalidateSubImage2D() { void TextureGLTest::invalidateSubImage2D() {
Texture2D texture; Texture2D texture;
texture.setStorage(2, TextureFormat::RGBA8, Vector2i(32)); texture.setStorage(2,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::RGBA8,
#else
TextureFormat::RGBA,
#endif
Vector2i(32));
texture.invalidateSubImage(1, Vector2i(2), Vector2i(8)); texture.invalidateSubImage(1, Vector2i(2), Vector2i(8));
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
void TextureGLTest::invalidateSubImage3D() { void TextureGLTest::invalidateSubImage3D() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>()) if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>())
@ -2437,6 +2544,7 @@ void TextureGLTest::invalidateSubImage3D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
void TextureGLTest::srgbStorage() { void TextureGLTest::srgbStorage() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
@ -2461,7 +2569,13 @@ void TextureGLTest::srgbStorage() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
texture.setStorage(1, TextureFormat::SRGB8, Vector2i{32}); texture.setStorage(1,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::SRGB8,
#else
TextureFormat::SRGB,
#endif
Vector2i{32});
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
@ -2489,7 +2603,13 @@ void TextureGLTest::srgbAlphaStorage() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
texture.setStorage(1, TextureFormat::SRGB8Alpha8, Vector2i{32}); texture.setStorage(1,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
TextureFormat::SRGB8Alpha8,
#else
TextureFormat::SRGBAlpha,
#endif
Vector2i{32});
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }

2
src/Magnum/Test/configure.h.cmake

@ -23,4 +23,4 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#define SHADERGLTEST_FILES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ShaderGLTestFiles" #define SHADERGLTEST_FILES_DIR "${SHADERGLTEST_FILES_DIR}"

5
src/Magnum/Text/Test/RendererGLTest.cpp

@ -178,7 +178,8 @@ void RendererGLTest::renderData() {
void RendererGLTest::renderMesh() { void RendererGLTest::renderMesh() {
TestFont font; TestFont font;
Mesh mesh{NoCreate}; Mesh mesh{NoCreate};
Buffer vertexBuffer, indexBuffer; Buffer vertexBuffer{Buffer::TargetHint::Array},
indexBuffer{Buffer::TargetHint::ElementArray};
Range2D bounds; Range2D bounds;
std::tie(mesh, bounds) = Text::Renderer3D::render(font, nullGlyphCache, std::tie(mesh, bounds) = Text::Renderer3D::render(font, nullGlyphCache,
0.25f, "abc", vertexBuffer, indexBuffer, BufferUsage::StaticDraw, Alignment::TopCenter); 0.25f, "abc", vertexBuffer, indexBuffer, BufferUsage::StaticDraw, Alignment::TopCenter);
@ -267,7 +268,7 @@ void RendererGLTest::mutableText() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::map_buffer_range>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::map_buffer_range>())
CORRADE_SKIP(Extensions::GL::ARB::map_buffer_range::string() + std::string(" is not supported")); CORRADE_SKIP(Extensions::GL::ARB::map_buffer_range::string() + std::string(" is not supported"));
#elif defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_EMSCRIPTEN) #elif defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::map_buffer_range>() && if(!Context::current().isExtensionSupported<Extensions::GL::EXT::map_buffer_range>() &&
!Context::current().isExtensionSupported<Extensions::GL::OES::mapbuffer>()) !Context::current().isExtensionSupported<Extensions::GL::OES::mapbuffer>())
CORRADE_SKIP("No required extension is supported"); CORRADE_SKIP("No required extension is supported");

Loading…
Cancel
Save