diff --git a/src/Magnum/DebugTools/Test/TextureImageGLTest.cpp b/src/Magnum/DebugTools/Test/TextureImageGLTest.cpp index f777daa01..1f269349e 100644 --- a/src/Magnum/DebugTools/Test/TextureImageGLTest.cpp +++ b/src/Magnum/DebugTools/Test/TextureImageGLTest.cpp @@ -29,7 +29,9 @@ #include "Magnum/ImageView.h" #include "Magnum/PixelFormat.h" #include "Magnum/DebugTools/TextureImage.h" +#include "Magnum/GL/Context.h" #include "Magnum/GL/CubeMapTexture.h" +#include "Magnum/GL/Extensions.h" #include "Magnum/GL/OpenGLTester.h" #include "Magnum/GL/PixelFormat.h" #include "Magnum/GL/Texture.h" @@ -204,6 +206,11 @@ constexpr UnsignedInt Data2DUInt[] = { 0xcafebabe, 0xdeadbabe }; void TextureImageGLTest::subImage2DUInt() { + #ifndef MAGNUM_TARGET_GLES + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::texture_integer::string() + std::string(" is not supported")); + #endif + GL::Texture2D texture; texture.setImage(0, GL::TextureFormat::R32UI, ImageView2D{GL::PixelFormat::RedInteger, GL::PixelType::UnsignedInt, Vector2i{2}, Data2DUInt}); diff --git a/src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp b/src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp index 56c7adaef..33d566e19 100644 --- a/src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp +++ b/src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp @@ -265,6 +265,9 @@ void AbstractShaderProgramGLTest::create() { void AbstractShaderProgramGLTest::createMultipleOutputs() { #ifndef MAGNUM_TARGET_GLES + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + Utility::Resource rs("AbstractShaderProgramGLTest"); Shader vert( @@ -319,6 +322,11 @@ void AbstractShaderProgramGLTest::createMultipleOutputs() { #ifndef MAGNUM_TARGET_GLES void AbstractShaderProgramGLTest::createMultipleOutputsIndexed() { + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::ARB::blend_func_extended::string() + std::string(" is not supported")); + Utility::Resource rs("AbstractShaderProgramGLTest"); Shader vert( @@ -641,6 +649,11 @@ void AbstractShaderProgramGLTest::uniformDoubleArray() { #ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgramGLTest::createUniformBlocks() { + #ifndef MAGNUM_TARGET_GLES + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() + std::string(" is not supported")); + #endif + Utility::Resource rs("AbstractShaderProgramGLTest"); Shader vert( @@ -693,6 +706,11 @@ void AbstractShaderProgramGLTest::createUniformBlocks() { } void AbstractShaderProgramGLTest::uniformBlockIndexNotFound() { + #ifndef MAGNUM_TARGET_GLES + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() + std::string(" is not supported")); + #endif + MyPublicShader program; Shader vert( @@ -767,6 +785,11 @@ UniformBlockShader::UniformBlockShader() { #endif void AbstractShaderProgramGLTest::uniformBlock() { + #ifndef MAGNUM_TARGET_GLES + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() + std::string(" is not supported")); + #endif + UniformBlockShader shader; MAGNUM_VERIFY_NO_GL_ERROR(); diff --git a/src/Magnum/GL/Test/FramebufferGLTest.cpp b/src/Magnum/GL/Test/FramebufferGLTest.cpp index 39df1ee17..a35f175a7 100644 --- a/src/Magnum/GL/Test/FramebufferGLTest.cpp +++ b/src/Magnum/GL/Test/FramebufferGLTest.cpp @@ -179,6 +179,7 @@ constexpr struct { RenderbufferFormat renderbufferFormat; PixelFormat expectedFormat; PixelType expectedType; + bool integer; } ImplementationColorReadFormatData[]{ {"classic", #if !defined(MAGNUM_TARGET_GLES2) || !defined(MAGNUM_TARGET_WEBGL) @@ -188,14 +189,14 @@ constexpr struct { #endif PixelFormat::RGBA, #if !defined(MAGNUM_TARGET_GLES2) || !defined(MAGNUM_TARGET_WEBGL) - PixelType::UnsignedByte + PixelType::UnsignedByte, #else - GL::PixelType::UnsignedShort4444 + GL::PixelType::UnsignedShort4444, #endif - }, + false}, #ifndef MAGNUM_TARGET_GLES2 - {"integer", RenderbufferFormat::RG32UI, PixelFormat::RGInteger, PixelType::UnsignedInt}, - {"float", RenderbufferFormat::RGBA16F, PixelFormat::RGBA, PixelType::Half} + {"integer", RenderbufferFormat::RG32UI, PixelFormat::RGInteger, PixelType::UnsignedInt, true}, + {"float", RenderbufferFormat::RGBA16F, PixelFormat::RGBA, PixelType::Half, false} #endif }; @@ -2255,6 +2256,11 @@ void FramebufferGLTest::implementationColorReadFormat() { auto&& data = ImplementationColorReadFormatData[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if(data.integer && !GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::texture_integer::string() + std::string(" is not supported")); + #endif + Renderbuffer color; color.setStorage(data.renderbufferFormat, {32, 32}); Framebuffer framebuffer{{{}, {32, 32}}}; diff --git a/src/Magnum/MeshTools/Test/CompileGLTest.cpp b/src/Magnum/MeshTools/Test/CompileGLTest.cpp index 84737c65e..114535d39 100644 --- a/src/Magnum/MeshTools/Test/CompileGLTest.cpp +++ b/src/Magnum/MeshTools/Test/CompileGLTest.cpp @@ -120,12 +120,12 @@ struct CompileGLTest: GL::OpenGLTester { Shaders::Flat2D _flat2D; Shaders::Flat2D _flatTextured2D{Shaders::Flat2D::Flag::Textured}; #ifndef MAGNUM_TARGET_GLES2 - Shaders::Flat2D _flatObjectId2D{Shaders::Flat2D::Flag::InstancedObjectId}; + Shaders::Flat2D _flatObjectId2D{NoCreate}; #endif Shaders::Flat3D _flat3D; Shaders::Flat3D _flatTextured3D{Shaders::Flat3D::Flag::Textured}; #ifndef MAGNUM_TARGET_GLES2 - Shaders::Flat3D _flatObjectId3D{Shaders::Flat3D::Flag::InstancedObjectId}; + Shaders::Flat3D _flatObjectId3D{NoCreate}; #endif Shaders::VertexColor2D _color2D; Shaders::VertexColor3D _color3D; @@ -286,18 +286,8 @@ CompileGLTest::CompileGLTest() { GL::RenderbufferFormat::RGBA4, #endif {32, 32}); - #ifndef MAGNUM_TARGET_GLES2 - _objectId.setStorage(GL::RenderbufferFormat::R32UI, {32, 32}); - #endif _framebuffer .attachRenderbuffer(GL::Framebuffer::ColorAttachment{0}, _color) - #ifndef MAGNUM_TARGET_GLES2 - .attachRenderbuffer(GL::Framebuffer::ColorAttachment{1}, _objectId) - .mapForDraw({ - {Shaders::Generic3D::ColorOutput, GL::Framebuffer::ColorAttachment{0}}, - {Shaders::Generic3D::ObjectIdOutput, GL::Framebuffer::ColorAttachment{1}} - }) - #endif .bind(); _texture .setMinificationFilter(SamplerFilter::Linear) @@ -312,6 +302,23 @@ CompileGLTest::CompileGLTest() { {4, 4}) .setSubImage(0, {}, ImageView2D{PixelFormat::RGBA8Unorm, {4, 4}, ImageData}); + #ifndef MAGNUM_TARGET_GLES2 + #ifndef MAGNUM_TARGET_GLES + if(GL::Context::current().isExtensionSupported()) + #endif + { + _flatObjectId2D = Shaders::Flat2D{Shaders::Flat2D::Flag::InstancedObjectId}; + _flatObjectId3D = Shaders::Flat3D{Shaders::Flat3D::Flag::InstancedObjectId}; + _objectId.setStorage(GL::RenderbufferFormat::R32UI, {32, 32}); + _framebuffer + .attachRenderbuffer(GL::Framebuffer::ColorAttachment{1}, _objectId) + .mapForDraw({ + {Shaders::Generic3D::ColorOutput, GL::Framebuffer::ColorAttachment{0}}, + {Shaders::Generic3D::ObjectIdOutput, GL::Framebuffer::ColorAttachment{1}} + }); + } + #endif + /* Mesh visualizer shaders only if we have a GS */ #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #ifndef MAGNUM_TARGET_GLES @@ -363,6 +370,11 @@ template void CompileGLTest::twoDimensions() { auto&& data = Data2D[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if(data.flags & Flag::ObjectId && !GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + #endif + #ifdef MAGNUM_BUILD_DEPRECATED CORRADE_IGNORE_DEPRECATED_PUSH /** @todo remove once MeshDataXD is gone */ if(std::is_same::value && data.flags & Flag::ObjectId) @@ -536,6 +548,11 @@ template void CompileGLTest::threeDimensions() { auto&& data = Data3D[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if(data.flags & Flag::ObjectId && !GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + #endif + #ifdef MAGNUM_BUILD_DEPRECATED CORRADE_IGNORE_DEPRECATED_PUSH /** @todo remove once MeshDataXD is gone */ if(std::is_same::value && data.flags & (Flag::Tangents|Flag::Bitangents|Flag::BitangentsFromTangents|Flag::ObjectId)) @@ -1030,26 +1047,32 @@ void CompileGLTest::packedAttributes() { (DebugTools::CompareImageToFile{_manager, 2.0f, 0.259f})); #ifndef MAGNUM_TARGET_GLES2 - _framebuffer.clearColor(1, Vector4ui{27}); - _flatObjectId3D - .setTransformationProjectionMatrix(projection*transformation) - .draw(mesh); + #ifndef MAGNUM_TARGET_GLES + if(GL::Context::current().isExtensionSupported()) + #endif + { + _framebuffer.clearColor(1, Vector4ui{27}); + _flatObjectId3D + .setTransformationProjectionMatrix(projection*transformation) + .draw(mesh); - MAGNUM_VERIFY_NO_GL_ERROR(); + MAGNUM_VERIFY_NO_GL_ERROR(); - /* Object ID -- no need to verify the whole image, just check that pixels - on known places have expected values. SwiftShader insists that the read - format has to be 32bit, so the renderbuffer format is that too to make - it the same (ES3 Mesa complains if these don't match). */ - _framebuffer.mapForRead(GL::Framebuffer::ColorAttachment{1}); - CORRADE_COMPARE(_framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete); - Image2D image = _framebuffer.read(_framebuffer.viewport(), {PixelFormat::R32UI}); - MAGNUM_VERIFY_NO_GL_ERROR(); - /* Outside of the object, cleared to 27 */ - CORRADE_COMPARE(image.pixels()[2][2], 27); - /* Inside of the object, bottom and top half should be different */ - CORRADE_COMPARE(image.pixels()[11][18], 13562); - CORRADE_COMPARE(image.pixels()[19][15], 26234); + /* Object ID -- no need to verify the whole image, just check that + pixels on known places have expected values. SwiftShader insists + that the read format has to be 32bit, so the renderbuffer format is + that too to make it the same (ES3 Mesa complains if these don't + match). */ + _framebuffer.mapForRead(GL::Framebuffer::ColorAttachment{1}); + CORRADE_COMPARE(_framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete); + Image2D image = _framebuffer.read(_framebuffer.viewport(), {PixelFormat::R32UI}); + MAGNUM_VERIFY_NO_GL_ERROR(); + /* Outside of the object, cleared to 27 */ + CORRADE_COMPARE(image.pixels()[2][2], 27); + /* Inside of the object, bottom and top half should be different */ + CORRADE_COMPARE(image.pixels()[11][18], 13562); + CORRADE_COMPARE(image.pixels()[19][15], 26234); + } #endif } diff --git a/src/Magnum/MeshTools/Test/FullScreenTriangleGLTest.cpp b/src/Magnum/MeshTools/Test/FullScreenTriangleGLTest.cpp index f914a84df..a80539a2c 100644 --- a/src/Magnum/MeshTools/Test/FullScreenTriangleGLTest.cpp +++ b/src/Magnum/MeshTools/Test/FullScreenTriangleGLTest.cpp @@ -74,6 +74,9 @@ void FullScreenTriangleGLTest::test() { auto&& data = VersionData[testCaseInstanceId()]; setTestCaseDescription(data.name); + if(!GL::Context::current().isVersionSupported(data.version)) + CORRADE_SKIP("Version not supported"); + struct FullscreenFlatShader: GL::AbstractShaderProgram { FullscreenFlatShader(GL::Version version) { Utility::Resource rs{"FullScreenTriangleTest"}; diff --git a/src/Magnum/Shaders/Test/FlatGLTest.cpp b/src/Magnum/Shaders/Test/FlatGLTest.cpp index 496bcefc1..6b664577c 100644 --- a/src/Magnum/Shaders/Test/FlatGLTest.cpp +++ b/src/Magnum/Shaders/Test/FlatGLTest.cpp @@ -304,6 +304,11 @@ template void FlatGLTest::construct() { auto&& data = ConstructData[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if((data.flags & Flat2D::Flag::ObjectId) && !GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + #endif + Flat shader{data.flags}; CORRADE_COMPARE(shader.flags(), data.flags); CORRADE_VERIFY(shader.id()); @@ -1002,22 +1007,30 @@ void FlatGLTest::renderObjectIdSetup() { _color = GL::Renderbuffer{}; _color.setStorage(GL::RenderbufferFormat::RGBA8, RenderSize); - _objectId = GL::Renderbuffer{}; - _objectId.setStorage(GL::RenderbufferFormat::R32UI, RenderSize); _framebuffer = GL::Framebuffer{{{}, RenderSize}}; - _framebuffer - .attachRenderbuffer(GL::Framebuffer::ColorAttachment{0}, _color) - .attachRenderbuffer(GL::Framebuffer::ColorAttachment{1}, _objectId) - .mapForDraw({ - {Flat3D::ColorOutput, GL::Framebuffer::ColorAttachment{0}}, - {Flat3D::ObjectIdOutput, GL::Framebuffer::ColorAttachment{1}} - }) + _framebuffer.attachRenderbuffer(GL::Framebuffer::ColorAttachment{0}, _color) /* Pick a color that's directly representable on RGBA4 as well to reduce artifacts (well, and this needs to be consistent with other tests that *need* to run on WebGL 1) */ .clearColor(0, 0x111111_rgbf) - .clearColor(1, Vector4ui{27}) .bind(); + + /* If we don't have EXT_gpu_shader4, we likely don't have integer + framebuffers either (Mesa's Zink), so skip setting up integer + attachments to avoid GL errors */ + #ifndef MAGNUM_TARGET_GLES + if(GL::Context::current().isExtensionSupported()) + #endif + { + _objectId = GL::Renderbuffer{}; + _objectId.setStorage(GL::RenderbufferFormat::R32UI, RenderSize); + _framebuffer.attachRenderbuffer(GL::Framebuffer::ColorAttachment{1}, _objectId) + .mapForDraw({ + {Flat2D::ColorOutput, GL::Framebuffer::ColorAttachment{0}}, + {Flat2D::ObjectIdOutput, GL::Framebuffer::ColorAttachment{1}} + }) + .clearColor(1, Vector4ui{27}); + } } void FlatGLTest::renderObjectIdTeardown() { @@ -1030,6 +1043,11 @@ void FlatGLTest::renderObjectId2D() { auto&& data = RenderObjectIdData[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + #endif + CORRADE_COMPARE(_framebuffer.checkStatus(GL::FramebufferTarget::Draw), GL::Framebuffer::Status::Complete); GL::Mesh circle = MeshTools::compile(Primitives::circle2DSolid(32)); @@ -1083,6 +1101,11 @@ void FlatGLTest::renderObjectId3D() { auto&& data = RenderObjectIdData[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + #endif + CORRADE_COMPARE(_framebuffer.checkStatus(GL::FramebufferTarget::Draw), GL::Framebuffer::Status::Complete); GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32)); diff --git a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp index 9e3871177..5811c6a95 100644 --- a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp +++ b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp @@ -519,6 +519,21 @@ void MeshVisualizerGLTest::construct2D() { auto&& data = ConstructData2D[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if((data.flags & MeshVisualizer2D::Flag::InstancedObjectId) && !GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + #endif + + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + if(data.flags >= MeshVisualizer2D::Flag::PrimitiveIdFromVertexId && + #ifndef MAGNUM_TARGET_GLES + !GL::Context::current().isVersionSupported(GL::Version::GL300) + #else + !GL::Context::current().isVersionSupported(GL::Version::GLES300) + #endif + ) CORRADE_SKIP("gl_VertexID not supported."); + #endif + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) if(data.flags & MeshVisualizer2D::Flag::PrimitiveId && !(data.flags >= MeshVisualizer2D::Flag::PrimitiveIdFromVertexId) && #ifndef MAGNUM_TARGET_GLES @@ -546,6 +561,21 @@ void MeshVisualizerGLTest::construct3D() { auto&& data = ConstructData3D[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if((data.flags & MeshVisualizer3D::Flag::InstancedObjectId) && !GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + #endif + + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + if(data.flags >= MeshVisualizer3D::Flag::PrimitiveIdFromVertexId && + #ifndef MAGNUM_TARGET_GLES + !GL::Context::current().isVersionSupported(GL::Version::GL300) + #else + !GL::Context::current().isVersionSupported(GL::Version::GLES300) + #endif + ) CORRADE_SKIP("gl_VertexID not supported."); + #endif + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) if(data.flags & MeshVisualizer3D::Flag::PrimitiveId && !(data.flags >= MeshVisualizer3D::Flag::PrimitiveIdFromVertexId) && #ifndef MAGNUM_TARGET_GLES @@ -1009,6 +1039,11 @@ void MeshVisualizerGLTest::renderDefaultsObjectId2D() { auto&& data = ObjectIdDefaultsData[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + #endif + /* Configure a texture with preset filtering and wrapping. The goal here is that the default config should be filtering/wrapping-independent for the first 256 items */ @@ -1053,6 +1088,11 @@ void MeshVisualizerGLTest::renderDefaultsObjectId3D() { auto&& data = ObjectIdDefaultsData[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + #endif + /* Configure a texture with preset filtering and wrapping. The goal here is that the default config should be filtering/wrapping-independent for the first 256 items */ @@ -1098,6 +1138,16 @@ void MeshVisualizerGLTest::renderDefaultsPrimitiveId2D() { !(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded)) CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found."); + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + if( + #ifndef MAGNUM_TARGET_GLES + !GL::Context::current().isVersionSupported(GL::Version::GL300) + #else + !GL::Context::current().isVersionSupported(GL::Version::GLES300) + #endif + ) CORRADE_SKIP("gl_VertexID not supported."); + #endif + MeshVisualizer2D::Flags flags; #ifdef MAGNUM_TARGET_WEBGL flags = MeshVisualizer2D::Flag::PrimitiveIdFromVertexId; @@ -1137,6 +1187,16 @@ void MeshVisualizerGLTest::renderDefaultsPrimitiveId3D() { !(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded)) CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found."); + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + if( + #ifndef MAGNUM_TARGET_GLES + !GL::Context::current().isVersionSupported(GL::Version::GL300) + #else + !GL::Context::current().isVersionSupported(GL::Version::GLES300) + #endif + ) CORRADE_SKIP("gl_VertexID not supported."); + #endif + MeshVisualizer2D::Flags flags; #ifdef MAGNUM_TARGET_WEBGL flags = MeshVisualizer2D::Flag::PrimitiveIdFromVertexId; @@ -1405,6 +1465,11 @@ void MeshVisualizerGLTest::renderObjectPrimitiveId2D() { auto&& data = ObjectPrimitiveIdData[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if((data.flags2D & MeshVisualizer2D::Flag::InstancedObjectId) && !GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + #endif + #ifndef MAGNUM_TARGET_WEBGL if(data.flags2D & MeshVisualizer2D::Flag::PrimitiveId && !(data.flags2D >= MeshVisualizer2D::Flag::PrimitiveIdFromVertexId) && #ifndef MAGNUM_TARGET_GLES @@ -1484,6 +1549,11 @@ void MeshVisualizerGLTest::renderObjectPrimitiveId3D() { auto&& data = ObjectPrimitiveIdData[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if((data.flags3D & MeshVisualizer3D::Flag::InstancedObjectId) && !GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + #endif + #ifndef MAGNUM_TARGET_WEBGL if(data.flags3D & MeshVisualizer3D::Flag::PrimitiveId && !(data.flags3D >= MeshVisualizer3D::Flag::PrimitiveIdFromVertexId) && #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Shaders/Test/PhongGLTest.cpp b/src/Magnum/Shaders/Test/PhongGLTest.cpp index 5dd80dd16..976595a4d 100644 --- a/src/Magnum/Shaders/Test/PhongGLTest.cpp +++ b/src/Magnum/Shaders/Test/PhongGLTest.cpp @@ -422,6 +422,11 @@ void PhongGLTest::construct() { auto&& data = ConstructData[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if((data.flags & Phong::Flag::ObjectId) && !GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + #endif + Phong shader{data.flags, data.lightCount}; CORRADE_COMPARE(shader.flags(), data.flags); CORRADE_COMPARE(shader.lightCount(), data.lightCount); @@ -1223,22 +1228,30 @@ void PhongGLTest::renderObjectIdSetup() { _color = GL::Renderbuffer{}; _color.setStorage(GL::RenderbufferFormat::RGBA8, RenderSize); - _objectId = GL::Renderbuffer{}; - _objectId.setStorage(GL::RenderbufferFormat::R32UI, RenderSize); _framebuffer = GL::Framebuffer{{{}, RenderSize}}; - _framebuffer - .attachRenderbuffer(GL::Framebuffer::ColorAttachment{0}, _color) - .attachRenderbuffer(GL::Framebuffer::ColorAttachment{1}, _objectId) - .mapForDraw({ - {Phong::ColorOutput, GL::Framebuffer::ColorAttachment{0}}, - {Phong::ObjectIdOutput, GL::Framebuffer::ColorAttachment{1}} - }) + _framebuffer.attachRenderbuffer(GL::Framebuffer::ColorAttachment{0}, _color) /* Pick a color that's directly representable on RGBA4 as well to reduce artifacts (well, and this needs to be consistent with other tests that *need* to run on WebGL 1) */ .clearColor(0, 0x111111_rgbf) - .clearColor(1, Vector4ui{27}) .bind(); + + /* If we don't have EXT_gpu_shader4, we likely don't have integer + framebuffers either (Mesa's Zink), so skip setting up integer + attachments to avoid GL errors */ + #ifndef MAGNUM_TARGET_GLES + if(GL::Context::current().isExtensionSupported()) + #endif + { + _objectId = GL::Renderbuffer{}; + _objectId.setStorage(GL::RenderbufferFormat::R32UI, RenderSize); + _framebuffer.attachRenderbuffer(GL::Framebuffer::ColorAttachment{1}, _objectId) + .mapForDraw({ + {Phong::ColorOutput, GL::Framebuffer::ColorAttachment{0}}, + {Phong::ObjectIdOutput, GL::Framebuffer::ColorAttachment{1}} + }) + .clearColor(1, Vector4ui{27}); + } } void PhongGLTest::renderObjectIdTeardown() { @@ -1251,6 +1264,11 @@ void PhongGLTest::renderObjectId() { auto&& data = RenderObjectIdData[testCaseInstanceId()]; setTestCaseDescription(data.name); + #ifndef MAGNUM_TARGET_GLES + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); + #endif + CORRADE_COMPARE(_framebuffer.checkStatus(GL::FramebufferTarget::Draw), GL::Framebuffer::Status::Complete); GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32)); @@ -1319,12 +1337,17 @@ void PhongGLTest::renderZeroLights() { GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32, Primitives::UVSphereFlag::TextureCoordinates)); - Phong shader{ - Phong::Flag::AmbientTexture|Phong::Flag::AlphaMask - #ifndef MAGNUM_TARGET_GLES2 - |Phong::Flag::ObjectId - #endif - , 0}; + /* Enable also Object ID, if supported */ + Phong::Flags flags = Phong::Flag::AmbientTexture|Phong::Flag::AlphaMask; + #ifndef MAGNUM_TARGET_GLES2 + #ifndef MAGNUM_TARGET_GLES + if(GL::Context::current().isExtensionSupported()) + #endif + { + flags |= Phong::Flag::ObjectId; + } + #endif + Phong shader{flags, 0}; Containers::Pointer importer = _manager.loadAndInstantiate("AnyImageImporter"); CORRADE_VERIFY(importer); @@ -1349,9 +1372,6 @@ void PhongGLTest::renderZeroLights() { Matrix4::rotationX(15.0_degf)) .setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)) /* Keep alpha mask at the default 0.5 to test the default */ - #ifndef MAGNUM_TARGET_GLES2 - .setObjectId(65534) - #endif /* Passing a zero-sized light position / color array, shouldn't assert */ .setLightPositions({}) .setLightColors({}) @@ -1362,6 +1382,15 @@ void PhongGLTest::renderZeroLights() { .setSpecularColor(0xfa9922_rgbf) .setShininess(0.2f); + #ifndef MAGNUM_TARGET_GLES2 + #ifndef MAGNUM_TARGET_GLES + if(GL::Context::current().isExtensionSupported()) + #endif + { + shader.setObjectId(65534); + } + #endif + /* For proper Z order draw back faces first and then front faces */ GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Front); shader.draw(sphere); @@ -1392,14 +1421,19 @@ void PhongGLTest::renderZeroLights() { on known places have expected values. SwiftShader insists that the read format has to be 32bit, so the renderbuffer format is that too to make it the same (ES3 Mesa complains if these don't match). */ - _framebuffer.mapForRead(GL::Framebuffer::ColorAttachment{1}); - CORRADE_COMPARE(_framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete); - Image2D image = _framebuffer.read(_framebuffer.viewport(), {PixelFormat::R32UI}); - MAGNUM_VERIFY_NO_GL_ERROR(); - /* Outside of the object, cleared to 27 */ - CORRADE_COMPARE(image.pixels()[10][10], 27); - /* Inside of the object. Verify that it can hold 16 bits at least. */ - CORRADE_COMPARE(image.pixels()[40][46], 65534); + #ifndef MAGNUM_TARGET_GLES + if(GL::Context::current().isExtensionSupported()) + #endif + { + _framebuffer.mapForRead(GL::Framebuffer::ColorAttachment{1}); + CORRADE_COMPARE(_framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete); + Image2D image = _framebuffer.read(_framebuffer.viewport(), {PixelFormat::R32UI}); + MAGNUM_VERIFY_NO_GL_ERROR(); + /* Outside of the object, cleared to 27 */ + CORRADE_COMPARE(image.pixels()[10][10], 27); + /* Inside of the object. Verify that it can hold 16 bits at least. */ + CORRADE_COMPARE(image.pixels()[40][46], 65534); + } #endif }