From 28965d488708c8e4782a11e42a5c2bab6b16ca53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 4 May 2020 15:23:28 +0200 Subject: [PATCH] Shaders: I happily forgot SwiftShader has broken gl_VertexID. Sigh. --- .../Shaders/Test/MeshVisualizerGLTest.cpp | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp index 1a12d33e9..a7cc30178 100644 --- a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp +++ b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp @@ -1161,15 +1161,9 @@ void MeshVisualizerGLTest::renderDefaultsVertexId2D() { !(_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 + /* On SwiftShader gl_VertexID doesn't work in this case, skipping */ + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP("gl_VertexID not supported"); MeshVisualizer2D{MeshVisualizer2D::Flag::VertexId} .bindColorMapTexture(_colorMapTexture) @@ -1189,15 +1183,9 @@ void MeshVisualizerGLTest::renderDefaultsVertexId3D() { !(_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 + /* On SwiftShader gl_VertexID doesn't work in this case, skipping */ + if(!GL::Context::current().isExtensionSupported()) + CORRADE_SKIP("gl_VertexID not supported"); MeshVisualizer2D{MeshVisualizer2D::Flag::VertexId} .bindColorMapTexture(_colorMapTexture) @@ -1216,6 +1204,9 @@ void MeshVisualizerGLTest::renderDefaultsPrimitiveId2D() { !(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded)) CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found."); + /* Interestingly in this case gl_VertexID in SwiftShader works (thus not + checking for MAGNUM_shader_vertex_id -- maybe it works only for + nonindexed triangle draws? */ #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) if( #ifndef MAGNUM_TARGET_GLES @@ -1265,6 +1256,9 @@ void MeshVisualizerGLTest::renderDefaultsPrimitiveId3D() { !(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded)) CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found."); + /* Interestingly in this case gl_VertexID in SwiftShader works (thus not + checking for MAGNUM_shader_vertex_id -- maybe it works only for + nonindexed triangle draws? */ #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) if( #ifndef MAGNUM_TARGET_GLES @@ -1548,6 +1542,11 @@ void MeshVisualizerGLTest::renderObjectVertexPrimitiveId2D() { CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); #endif + /* Interestingly for PrimitiveIdFromVertexId gl_VertexID in SwiftShader + works -- maybe it works only for nonindexed triangle draws? */ + if(data.flags2D & MeshVisualizer2D::Flag::VertexId && !GL::Context::current().isExtensionSupported()) + CORRADE_SKIP("gl_VertexID not supported"); + #ifndef MAGNUM_TARGET_WEBGL if(data.flags2D & MeshVisualizer2D::Flag::PrimitiveId && !(data.flags2D >= MeshVisualizer2D::Flag::PrimitiveIdFromVertexId) && #ifndef MAGNUM_TARGET_GLES @@ -1640,6 +1639,11 @@ void MeshVisualizerGLTest::renderObjectVertexPrimitiveId3D() { CORRADE_SKIP(GL::Extensions::EXT::gpu_shader4::string() + std::string(" is not supported")); #endif + /* Interestingly for PrimitiveIdFromVertexId gl_VertexID in SwiftShader + works -- maybe it works only for nonindexed triangle draws? */ + if(data.flags3D & MeshVisualizer3D::Flag::VertexId && !GL::Context::current().isExtensionSupported()) + CORRADE_SKIP("gl_VertexID not supported"); + #ifndef MAGNUM_TARGET_WEBGL if(data.flags3D & MeshVisualizer3D::Flag::PrimitiveId && !(data.flags3D >= MeshVisualizer3D::Flag::PrimitiveIdFromVertexId) && #ifndef MAGNUM_TARGET_GLES