From 06b5bae5c88f19960a0c37934f109c11110a7642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 2 Jul 2022 14:49:00 +0200 Subject: [PATCH 01/14] CMake: drop notes about old CMake on old Xcode Travis images. None of that is relevant anymore, especially given the broken feature affects something we don't even support. --- src/Magnum/DebugTools/Test/CMakeLists.txt | 5 ----- src/Magnum/GL/Test/CMakeLists.txt | 5 ----- src/Magnum/MeshTools/Test/CMakeLists.txt | 5 ----- src/Magnum/Shaders/Test/CMakeLists.txt | 5 ----- src/Magnum/TextureTools/Test/CMakeLists.txt | 5 ----- src/Magnum/Vk/Test/CMakeLists.txt | 5 ----- src/MagnumPlugins/AnyAudioImporter/Test/CMakeLists.txt | 4 ---- src/MagnumPlugins/AnyImageConverter/Test/CMakeLists.txt | 4 ---- src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt | 4 ---- src/MagnumPlugins/AnySceneConverter/Test/CMakeLists.txt | 4 ---- src/MagnumPlugins/AnySceneImporter/Test/CMakeLists.txt | 4 ---- src/MagnumPlugins/AnyShaderConverter/Test/CMakeLists.txt | 4 ---- src/MagnumPlugins/MagnumFont/Test/CMakeLists.txt | 4 ---- src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt | 4 ---- src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt | 4 ---- src/MagnumPlugins/TgaImageConverter/Test/CMakeLists.txt | 4 ---- src/MagnumPlugins/TgaImporter/Test/CMakeLists.txt | 4 ---- src/MagnumPlugins/WavAudioImporter/Test/CMakeLists.txt | 4 ---- 18 files changed, 78 deletions(-) diff --git a/src/Magnum/DebugTools/Test/CMakeLists.txt b/src/Magnum/DebugTools/Test/CMakeLists.txt index 02094a6c5..6e9e3db21 100644 --- a/src/Magnum/DebugTools/Test/CMakeLists.txt +++ b/src/Magnum/DebugTools/Test/CMakeLists.txt @@ -44,11 +44,6 @@ if(MAGNUM_WITH_TRADE) set(COMPAREIMAGETEST_SAVE_DIR ${CMAKE_CURRENT_BINARY_DIR}/write) endif() - # CMake before 3.8 has broken $ expressions for iOS (see - # https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since - # Corrade doesn't support dynamic plugins on iOS, this sorta works around - # that. Should be revisited when updating Travis to newer Xcode (xcode7.3 - # has CMake 3.6). if(NOT MAGNUM_BUILD_PLUGINS_STATIC) if(MAGNUM_WITH_ANYIMAGEIMPORTER) set(ANYIMAGEIMPORTER_PLUGIN_FILENAME $) diff --git a/src/Magnum/GL/Test/CMakeLists.txt b/src/Magnum/GL/Test/CMakeLists.txt index 6aeb80b08..29ba9d095 100644 --- a/src/Magnum/GL/Test/CMakeLists.txt +++ b/src/Magnum/GL/Test/CMakeLists.txt @@ -104,11 +104,6 @@ if(MAGNUM_BUILD_GL_TESTS) set(RENDERERGLTEST_FILES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/RendererGLTestFiles) endif() - # CMake before 3.8 has broken $ expressions for iOS (see - # https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since - # Corrade doesn't support dynamic plugins on iOS, this sorta works around - # that. Should be revisited when updating Travis to newer Xcode (xcode7.3 - # has CMake 3.6). if(NOT MAGNUM_BUILD_PLUGINS_STATIC) if(MAGNUM_WITH_ANYIMAGEIMPORTER) set(ANYIMAGEIMPORTER_PLUGIN_FILENAME $) diff --git a/src/Magnum/MeshTools/Test/CMakeLists.txt b/src/Magnum/MeshTools/Test/CMakeLists.txt index 1c2d37f82..5281f7976 100644 --- a/src/Magnum/MeshTools/Test/CMakeLists.txt +++ b/src/Magnum/MeshTools/Test/CMakeLists.txt @@ -75,11 +75,6 @@ if(MAGNUM_BUILD_GL_TESTS) set(MESHTOOLS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) endif() - # CMake before 3.8 has broken $ expressions for iOS (see - # https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since - # Corrade doesn't support dynamic plugins on iOS, this sorta works around - # that. Should be revisited when updating Travis to newer Xcode (xcode7.3 - # has CMake 3.6). if(NOT MAGNUM_BUILD_PLUGINS_STATIC) if(MAGNUM_WITH_ANYIMAGEIMPORTER) set(ANYIMAGEIMPORTER_PLUGIN_FILENAME $) diff --git a/src/Magnum/Shaders/Test/CMakeLists.txt b/src/Magnum/Shaders/Test/CMakeLists.txt index 1ba6d15b5..968adb16c 100644 --- a/src/Magnum/Shaders/Test/CMakeLists.txt +++ b/src/Magnum/Shaders/Test/CMakeLists.txt @@ -54,11 +54,6 @@ if(MAGNUM_BUILD_GL_TESTS) set(SHADERS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) endif() - # CMake before 3.8 has broken $ expressions for iOS (see - # https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since - # Corrade doesn't support dynamic plugins on iOS, this sorta works around - # that. Should be revisited when updating Travis to newer Xcode (xcode7.3 - # has CMake 3.6). if(NOT MAGNUM_BUILD_PLUGINS_STATIC) if(MAGNUM_WITH_ANYIMAGEIMPORTER) set(ANYIMAGEIMPORTER_PLUGIN_FILENAME $) diff --git a/src/Magnum/TextureTools/Test/CMakeLists.txt b/src/Magnum/TextureTools/Test/CMakeLists.txt index 8e20ebaa3..a6a007e7e 100644 --- a/src/Magnum/TextureTools/Test/CMakeLists.txt +++ b/src/Magnum/TextureTools/Test/CMakeLists.txt @@ -39,11 +39,6 @@ if(MAGNUM_BUILD_GL_TESTS) # Otherwise CMake complains that Corrade::PluginManager is not found, wtf find_package(Corrade REQUIRED PluginManager) - # CMake before 3.8 has broken $ expressions for iOS (see - # https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since - # Corrade doesn't support dynamic plugins on iOS, this sorta works around - # that. Should be revisited when updating Travis to newer Xcode (xcode7.3 - # has CMake 3.6). if(NOT MAGNUM_BUILD_PLUGINS_STATIC) if(MAGNUM_WITH_ANYIMAGEIMPORTER) set(ANYIMAGEIMPORTER_PLUGIN_FILENAME $) diff --git a/src/Magnum/Vk/Test/CMakeLists.txt b/src/Magnum/Vk/Test/CMakeLists.txt index 492492f6d..9cdde0518 100644 --- a/src/Magnum/Vk/Test/CMakeLists.txt +++ b/src/Magnum/Vk/Test/CMakeLists.txt @@ -39,11 +39,6 @@ if(MAGNUM_BUILD_VK_TESTS) set(VK_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) endif() - # CMake before 3.8 has broken $ expressions for iOS (see - # https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since - # Corrade doesn't support dynamic plugins on iOS, this sorta works around - # that. Should be revisited when updating Travis to newer Xcode (xcode7.3 - # has CMake 3.6). if(NOT MAGNUM_BUILD_PLUGINS_STATIC) if(MAGNUM_WITH_ANYIMAGEIMPORTER) set(ANYIMAGEIMPORTER_PLUGIN_FILENAME $) diff --git a/src/MagnumPlugins/AnyAudioImporter/Test/CMakeLists.txt b/src/MagnumPlugins/AnyAudioImporter/Test/CMakeLists.txt index 130ca3dfa..8767544cf 100644 --- a/src/MagnumPlugins/AnyAudioImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/AnyAudioImporter/Test/CMakeLists.txt @@ -33,10 +33,6 @@ else() set(WAVAUDIOIMPORTER_TEST_DIR ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/WavAudioImporter/Test) endif() -# CMake before 3.8 has broken $ expressions for iOS (see -# https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since Corrade -# doesn't support dynamic plugins on iOS, this sorta works around that. Should -# be revisited when updating Travis to newer Xcode (xcode7.3 has CMake 3.6). if(NOT MAGNUM_ANYAUDIOIMPORTER_BUILD_STATIC) set(ANYAUDIOIMPORTER_PLUGIN_FILENAME $) if(MAGNUM_WITH_WAVAUDIOIMPORTER) diff --git a/src/MagnumPlugins/AnyImageConverter/Test/CMakeLists.txt b/src/MagnumPlugins/AnyImageConverter/Test/CMakeLists.txt index ee4606a40..34f416f36 100644 --- a/src/MagnumPlugins/AnyImageConverter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/AnyImageConverter/Test/CMakeLists.txt @@ -40,10 +40,6 @@ else() set(ANYIMAGEIMPORTER_TEST_DIR ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/AnyImageImporter/Test) endif() -# CMake before 3.8 has broken $ expressions for iOS (see -# https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since Corrade -# doesn't support dynamic plugins on iOS, this sorta works around that. Should -# be revisited when updating Travis to newer Xcode (xcode7.3 has CMake 3.6). if(NOT MAGNUM_ANYIMAGECONVERTER_BUILD_STATIC) set(ANYIMAGECONVERTER_PLUGIN_FILENAME $) if(MAGNUM_WITH_TGAIMAGECONVERTER) diff --git a/src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt b/src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt index af0706345..f6599c548 100644 --- a/src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt @@ -33,10 +33,6 @@ else() set(ANYIMAGEIMPORTER_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) endif() -# CMake before 3.8 has broken $ expressions for iOS (see -# https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since Corrade -# doesn't support dynamic plugins on iOS, this sorta works around that. Should -# be revisited when updating Travis to newer Xcode (xcode7.3 has CMake 3.6). if(NOT MAGNUM_ANYIMAGEIMPORTER_BUILD_STATIC) set(ANYIMAGEIMPORTER_PLUGIN_FILENAME $) if(MAGNUM_WITH_TGAIMPORTER) diff --git a/src/MagnumPlugins/AnySceneConverter/Test/CMakeLists.txt b/src/MagnumPlugins/AnySceneConverter/Test/CMakeLists.txt index f8db40c1f..7a5c7fbf8 100644 --- a/src/MagnumPlugins/AnySceneConverter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/AnySceneConverter/Test/CMakeLists.txt @@ -37,10 +37,6 @@ else() set(ANYSCENEIMPORTER_TEST_DIR ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/AnySceneImporter/Test) endif() -# CMake before 3.8 has broken $ expressions for iOS (see -# https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since Corrade -# doesn't support dynamic plugins on iOS, this sorta works around that. Should -# be revisited when updating Travis to newer Xcode (xcode7.3 has CMake 3.6). if(NOT MAGNUM_ANYSCENECONVERTER_BUILD_STATIC) set(ANYSCENECONVERTER_PLUGIN_FILENAME $) if(MAGNUM_WITH_TGAIMAGECONVERTER) diff --git a/src/MagnumPlugins/AnySceneImporter/Test/CMakeLists.txt b/src/MagnumPlugins/AnySceneImporter/Test/CMakeLists.txt index 272fe208a..aba0c51ff 100644 --- a/src/MagnumPlugins/AnySceneImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/AnySceneImporter/Test/CMakeLists.txt @@ -35,10 +35,6 @@ else() set(OBJIMPORTER_TEST_DIR ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/ObjImporter/Test) endif() -# CMake before 3.8 has broken $ expressions for iOS (see -# https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since Corrade -# doesn't support dynamic plugins on iOS, this sorta works around that. Should -# be revisited when updating Travis to newer Xcode (xcode7.3 has CMake 3.6). if(NOT MAGNUM_ANYSCENEIMPORTER_BUILD_STATIC) set(ANYSCENEIMPORTER_PLUGIN_FILENAME $) if(MAGNUM_WITH_OBJIMPORTER) diff --git a/src/MagnumPlugins/AnyShaderConverter/Test/CMakeLists.txt b/src/MagnumPlugins/AnyShaderConverter/Test/CMakeLists.txt index 8d0425c5e..abd44cddf 100644 --- a/src/MagnumPlugins/AnyShaderConverter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/AnyShaderConverter/Test/CMakeLists.txt @@ -35,10 +35,6 @@ else() set(ANYSHADERCONVERTER_TEST_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) endif() -# CMake before 3.8 has broken $ expressions for iOS (see -# https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since Corrade -# doesn't support dynamic plugins on iOS, this sorta works around that. Should -# be revisited when updating Travis to newer Xcode (xcode7.3 has CMake 3.6). if(NOT MAGNUM_ANYSHADERCONVERTER_BUILD_STATIC) set(ANYSHADERCONVERTER_PLUGIN_FILENAME $) endif() diff --git a/src/MagnumPlugins/MagnumFont/Test/CMakeLists.txt b/src/MagnumPlugins/MagnumFont/Test/CMakeLists.txt index 6983d5415..4c6c3a904 100644 --- a/src/MagnumPlugins/MagnumFont/Test/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFont/Test/CMakeLists.txt @@ -33,10 +33,6 @@ else() set(MAGNUMFONT_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) endif() -# CMake before 3.8 has broken $ expressions for iOS (see -# https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since Corrade -# doesn't support dynamic plugins on iOS, this sorta works around that. Should -# be revisited when updating Travis to newer Xcode (xcode7.3 has CMake 3.6). if(NOT MAGNUM_MAGNUMFONT_BUILD_STATIC) set(MAGNUMFONT_PLUGIN_FILENAME $) set(TGAIMPORTER_PLUGIN_FILENAME $) diff --git a/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt b/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt index 2b52cc976..cecaa048b 100644 --- a/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt @@ -35,10 +35,6 @@ else() set(MAGNUMFONT_TEST_DIR ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/MagnumFont/Test) endif() -# CMake before 3.8 has broken $ expressions for iOS (see -# https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since Corrade -# doesn't support dynamic plugins on iOS, this sorta works around that. Should -# be revisited when updating Travis to newer Xcode (xcode7.3 has CMake 3.6). if(NOT MAGNUM_MAGNUMFONTCONVERTER_BUILD_STATIC) set(MAGNUMFONTCONVERTER_PLUGIN_FILENAME $) set(TGAIMAGECONVERTER_PLUGIN_FILENAME $) diff --git a/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt b/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt index 2bd91f662..833f15a65 100644 --- a/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt @@ -33,10 +33,6 @@ else() set(OBJIMPORTER_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) endif() -# CMake before 3.8 has broken $ expressions for iOS (see -# https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since Corrade -# doesn't support dynamic plugins on iOS, this sorta works around that. Should -# be revisited when updating Travis to newer Xcode (xcode7.3 has CMake 3.6). if(NOT MAGNUM_OBJIMPORTER_BUILD_STATIC) set(OBJIMPORTER_PLUGIN_FILENAME $) endif() diff --git a/src/MagnumPlugins/TgaImageConverter/Test/CMakeLists.txt b/src/MagnumPlugins/TgaImageConverter/Test/CMakeLists.txt index da4d4acf2..40e5c707e 100644 --- a/src/MagnumPlugins/TgaImageConverter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/TgaImageConverter/Test/CMakeLists.txt @@ -27,10 +27,6 @@ # property that would have to be set on each target separately. set(CMAKE_FOLDER "MagnumPlugins/TgaImageConverter/Test") -# CMake before 3.8 has broken $ expressions for iOS (see -# https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since Corrade -# doesn't support dynamic plugins on iOS, this sorta works around that. Should -# be revisited when updating Travis to newer Xcode (xcode7.3 has CMake 3.6). if(NOT MAGNUM_TGAIMAGECONVERTER_BUILD_STATIC) set(TGAIMAGECONVERTER_PLUGIN_FILENAME $) if(MAGNUM_WITH_TGAIMPORTER) diff --git a/src/MagnumPlugins/TgaImporter/Test/CMakeLists.txt b/src/MagnumPlugins/TgaImporter/Test/CMakeLists.txt index f28f6f425..2dc529fd3 100644 --- a/src/MagnumPlugins/TgaImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/TgaImporter/Test/CMakeLists.txt @@ -33,10 +33,6 @@ else() set(TGAIMPORTER_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) endif() -# CMake before 3.8 has broken $ expressions for iOS (see -# https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since Corrade -# doesn't support dynamic plugins on iOS, this sorta works around that. Should -# be revisited when updating Travis to newer Xcode (xcode7.3 has CMake 3.6). if(NOT MAGNUM_TGAIMPORTER_BUILD_STATIC) set(TGAIMPORTER_PLUGIN_FILENAME $) endif() diff --git a/src/MagnumPlugins/WavAudioImporter/Test/CMakeLists.txt b/src/MagnumPlugins/WavAudioImporter/Test/CMakeLists.txt index 0204a028e..f1e46c78c 100644 --- a/src/MagnumPlugins/WavAudioImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/WavAudioImporter/Test/CMakeLists.txt @@ -33,10 +33,6 @@ else() set(WAVAUDIOIMPORTER_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) endif() -# CMake before 3.8 has broken $ expressions for iOS (see -# https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since Corrade -# doesn't support dynamic plugins on iOS, this sorta works around that. Should -# be revisited when updating Travis to newer Xcode (xcode7.3 has CMake 3.6). if(NOT MAGNUM_WAVAUDIOIMPORTER_BUILD_STATIC) set(WAVAUDIOIMPORTER_PLUGIN_FILENAME $) endif() From a1095262b41d349323136631dd394a49313a9d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 2 Jul 2022 14:14:56 +0200 Subject: [PATCH 02/14] ObjImporter: clean up and deduplicate the tests. Basically just making use of all APIs that got invented over the last 10 years, such as using instanced test cases instead of repeatedly having the same test code with just different strings or accessing meshes directly by name instead of meshForName(). Additionally the test files were renamed to better group them visually, with invalid cases being separated from valid cases so it's possible to have instanced tests for those. --- .../Test/AnySceneImporterTest.cpp | 6 +- .../AnySceneImporter/Test/CMakeLists.txt | 2 +- .../ObjImporter/Test/CMakeLists.txt | 37 +- .../ObjImporter/Test/ObjImporterTest.cpp | 702 +++++++----------- .../Test/{emptyFile.obj => empty.obj} | 0 ...ngData.obj => invalid-incomplete-data.obj} | 0 ...j => invalid-inconsistent-index-tuple.obj} | 0 .../ObjImporter/Test/invalid-keyword.obj | 1 + ...tives.obj => invalid-mixed-primitives.obj} | 0 ...mberCount.obj => invalid-number-count.obj} | 0 .../{wrongNumbers.obj => invalid-numbers.obj} | 0 ...es.obj => invalid-optional-coordinate.obj} | 13 +- .../ObjImporter/Test/keywords.obj | 7 - .../ObjImporter/Test/mesh-ignored-keyword.obj | 3 + .../{moreMeshes.obj => mesh-multiple.obj} | 0 ...tMesh.obj => mesh-named-first-unnamed.obj} | 0 .../Test/{namedMesh.obj => mesh-named.obj} | 0 .../Test/{normals.obj => mesh-normals.obj} | 0 .../mesh-positions-optional-coordinate.obj | 2 + ...{lineMesh.obj => mesh-primitive-lines.obj} | 0 ...ointMesh.obj => mesh-primitive-points.obj} | 0 ...eMesh.obj => mesh-primitive-triangles.obj} | 0 ...j => mesh-texture-coordinates-normals.obj} | 0 ...exture-coordinates-optional-coordinate.obj | 3 + ...nates.obj => mesh-texture-coordinates.obj} | 0 25 files changed, 295 insertions(+), 481 deletions(-) rename src/MagnumPlugins/ObjImporter/Test/{emptyFile.obj => empty.obj} (100%) rename src/MagnumPlugins/ObjImporter/Test/{missingData.obj => invalid-incomplete-data.obj} (100%) rename src/MagnumPlugins/ObjImporter/Test/{wrongIndexCount.obj => invalid-inconsistent-index-tuple.obj} (100%) create mode 100644 src/MagnumPlugins/ObjImporter/Test/invalid-keyword.obj rename src/MagnumPlugins/ObjImporter/Test/{mixedPrimitives.obj => invalid-mixed-primitives.obj} (100%) rename src/MagnumPlugins/ObjImporter/Test/{wrongNumberCount.obj => invalid-number-count.obj} (100%) rename src/MagnumPlugins/ObjImporter/Test/{wrongNumbers.obj => invalid-numbers.obj} (100%) rename src/MagnumPlugins/ObjImporter/Test/{optionalCoordinates.obj => invalid-optional-coordinate.obj} (50%) delete mode 100644 src/MagnumPlugins/ObjImporter/Test/keywords.obj create mode 100644 src/MagnumPlugins/ObjImporter/Test/mesh-ignored-keyword.obj rename src/MagnumPlugins/ObjImporter/Test/{moreMeshes.obj => mesh-multiple.obj} (100%) rename src/MagnumPlugins/ObjImporter/Test/{unnamedFirstMesh.obj => mesh-named-first-unnamed.obj} (100%) rename src/MagnumPlugins/ObjImporter/Test/{namedMesh.obj => mesh-named.obj} (100%) rename src/MagnumPlugins/ObjImporter/Test/{normals.obj => mesh-normals.obj} (100%) create mode 100644 src/MagnumPlugins/ObjImporter/Test/mesh-positions-optional-coordinate.obj rename src/MagnumPlugins/ObjImporter/Test/{lineMesh.obj => mesh-primitive-lines.obj} (100%) rename src/MagnumPlugins/ObjImporter/Test/{pointMesh.obj => mesh-primitive-points.obj} (100%) rename src/MagnumPlugins/ObjImporter/Test/{triangleMesh.obj => mesh-primitive-triangles.obj} (100%) rename src/MagnumPlugins/ObjImporter/Test/{textureCoordinatesNormals.obj => mesh-texture-coordinates-normals.obj} (100%) create mode 100644 src/MagnumPlugins/ObjImporter/Test/mesh-texture-coordinates-optional-coordinate.obj rename src/MagnumPlugins/ObjImporter/Test/{textureCoordinates.obj => mesh-texture-coordinates.obj} (100%) diff --git a/src/MagnumPlugins/AnySceneImporter/Test/AnySceneImporterTest.cpp b/src/MagnumPlugins/AnySceneImporter/Test/AnySceneImporterTest.cpp index 267916528..4887ae510 100644 --- a/src/MagnumPlugins/AnySceneImporter/Test/AnySceneImporterTest.cpp +++ b/src/MagnumPlugins/AnySceneImporter/Test/AnySceneImporterTest.cpp @@ -78,7 +78,7 @@ const struct { const char* name; Containers::String filename; } LoadData[]{ - {"OBJ", Utility::Path::join(OBJIMPORTER_TEST_DIR, "pointMesh.obj")}, + {"OBJ", Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-primitive-points.obj")}, }; constexpr struct { @@ -157,7 +157,7 @@ void AnySceneImporterTest::loadDeprecatedMeshData() { CORRADE_SKIP("ObjImporter plugin not enabled, cannot test"); Containers::Pointer importer = _manager.instantiate("AnySceneImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "pointMesh.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-primitive-points.obj"))); /* Check only size, as it is good enough proof that it is working */ @@ -298,7 +298,7 @@ void AnySceneImporterTest::propagateFileCallback() { Containers::Array storage; importer->setFileCallback([](const std::string&, InputFileCallbackPolicy, Containers::Array& storage) -> Containers::Optional> { - Containers::Optional> data = Utility::Path::read(Utility::Path::join(OBJIMPORTER_TEST_DIR, "pointMesh.obj")); + Containers::Optional> data = Utility::Path::read(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-primitive-points.obj")); CORRADE_VERIFY(data); storage = *std::move(data); return Containers::ArrayView{storage}; diff --git a/src/MagnumPlugins/AnySceneImporter/Test/CMakeLists.txt b/src/MagnumPlugins/AnySceneImporter/Test/CMakeLists.txt index aba0c51ff..48a5ce9aa 100644 --- a/src/MagnumPlugins/AnySceneImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/AnySceneImporter/Test/CMakeLists.txt @@ -51,7 +51,7 @@ file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/configure.h corrade_add_test(AnySceneImporterTest AnySceneImporterTest.cpp LIBRARIES MagnumTrade FILES - ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/ObjImporter/Test/pointMesh.obj + ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/ObjImporter/Test/mesh-primitive-points.obj mesh-custom-attribute.gltf scene-custom-field.gltf triangle.ply) diff --git a/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt b/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt index 833f15a65..6dc2f46a9 100644 --- a/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt @@ -46,23 +46,26 @@ file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/configure.h corrade_add_test(ObjImporterTest ObjImporterTest.cpp LIBRARIES MagnumTrade FILES - emptyFile.obj - keywords.obj - lineMesh.obj - missingData.obj - mixedPrimitives.obj - moreMeshes.obj - namedMesh.obj - normals.obj - optionalCoordinates.obj - pointMesh.obj - textureCoordinatesNormals.obj - textureCoordinates.obj - triangleMesh.obj - unnamedFirstMesh.obj - wrongIndexCount.obj - wrongNumberCount.obj - wrongNumbers.obj) + empty.obj + invalid-incomplete-data.obj + invalid-inconsistent-index-tuple.obj + invalid-keyword.obj + invalid-mixed-primitives.obj + invalid-number-count.obj + invalid-numbers.obj + invalid-optional-coordinate.obj + mesh-ignored-keyword.obj + mesh-multiple.obj + mesh-named-first-unnamed.obj + mesh-named.obj + mesh-normals.obj + mesh-positions-optional-coordinate.obj + mesh-primitive-lines.obj + mesh-primitive-points.obj + mesh-primitive-triangles.obj + mesh-texture-coordinates.obj + mesh-texture-coordinates-normals.obj + mesh-texture-coordinates-optional-coordinate.obj) target_include_directories(ObjImporterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/$) if(MAGNUM_OBJIMPORTER_BUILD_STATIC) target_link_libraries(ObjImporterTest PRIVATE ObjImporter) diff --git a/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp b/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp index e89db9777..08b988f7e 100644 --- a/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp +++ b/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include "Magnum/Mesh.h" @@ -43,55 +44,37 @@ namespace Magnum { namespace Trade { namespace Test { namespace { struct ObjImporterTest: TestSuite::Tester { explicit ObjImporterTest(); - void pointMesh(); - void lineMesh(); - void triangleMesh(); - void mixedPrimitives(); + void empty(); - void positionsOnly(); - void textureCoordinates(); - void normals(); - void textureCoordinatesNormals(); + void meshPrimitivePoints(); + void meshPrimitiveLines(); + void meshPrimitiveTriangles(); + + /* Positions alone are tested above */ + void meshPositionsOptionalCoordinate(); + void meshTextureCoordinates(); + void meshTextureCoordinatesOptionalCoordinate(); + void meshNormals(); + void meshTextureCoordinatesNormals(); + + void meshIgnoredKeyword(); + + void meshNamed(); + void meshNamedFirstUnnamed(); - void emptyFile(); - void unnamedMesh(); - void namedMesh(); void moreMeshes(); - void unnamedFirstMesh(); - - void wrongFloat(); - void wrongInteger(); - void unmergedIndexOutOfRange(); - void mergedIndexOutOfRange(); - void zeroIndex(); - - void explicitOptionalPositionCoordinate(); - void explicitOptionalTextureCoordinate(); - void unsupportedOptionalPositionCoordinate(); - void unsupportedOptionalTextureCoordinate(); - - void shortFloatData(); - void longFloatData(); - void longOptionalFloatData(); - - void longIndexData(); - void wrongPointIndexData(); - void wrongLineIndexData(); - void wrongTriangleIndexData(); - void polygonIndexData(); - - void missingPositionData(); - void missingNormalData(); - void missingTextureCoordinateData(); - void missingPositionIndices(); - void missingNormalIndices(); - void missingTextureCoordinateIndices(); - - void wrongTextureCoordinateIndexCount(); - void wrongNormalIndexCount(); - - void unsupportedKeyword(); - void unknownKeyword(); + + /* Technically, all invalid cases could be put into a single file, but + because the indexing is global, it would get increasingly hard to + maintain. So it's instead grouped into files by a common error scenario + with each case testing one file and just the invalid() case testing + separate files. */ + void invalid(); + void invalidNumbers(); + void invalidNumberCount(); + void invalidInconsistentIndexTuple(); + void invalidIncompleteData(); + void invalidOptionalCoordinate(); void openTwice(); void importTwice(); @@ -100,58 +83,109 @@ struct ObjImporterTest: TestSuite::Tester { PluginManager::Manager _manager{"nonexistent"}; }; +const struct { + const char* name; + const char* filename; + const char* message; +} InvalidData[]{ + {"mixed primitives", "invalid-mixed-primitives.obj", + "mixed primitive MeshPrimitive::Points and MeshPrimitive::Lines"}, + {"unknown keyword", "invalid-keyword.obj", + "unknown keyword bleh"} +}; + +const struct { + const char* name; + const char* message; +} InvalidNumbersData[]{ + {"WrongFloat", "error while converting numeric data"}, + {"WrongInteger", "error while converting numeric data"}, + {"PositionIndexOutOfRange", "index 1 out of range for 1 vertices"}, + {"TextureIndexOutOfRange", "index 2 out of range for 1 vertices"}, + {"ZeroIndex", "index 0 out of range for 1 vertices"} +}; + +const struct { + const char* name; + const char* message; +} InvalidNumberCountData[]{ + {"ShortFloat", "invalid float array size"}, + {"LongFloat", "invalid float array size"}, + {"LongOptionalFloat", "invalid float array size"}, + {"InvalidIndices", "invalid index data"}, + {"WrongPointIndices", "wrong index count for point"}, + {"WrongLineIndices", "wrong index count for line"}, + {"WrongTriangleIndices", "wrong index count for triangle"}, + {"PolygonIndices", "polygons are not supported"} +}; + +const struct { + const char* name; + const char* message; +} InvalidInconsistentIndexTupleData[]{ + {"ShortNormalIndices", "some normal indices are missing"}, + {"ShortTextureIndices", "some texture coordinate indices are missing"}, +}; + +const struct { + const char* name; + const char* message; +} InvalidIncompleteDataData[]{ + {"MissingPositionData", "incomplete position data"}, + {"MissingPositionIndices", "incomplete position data"}, + {"MissingNormalData", "incomplete normal data"}, + {"MissingNormalIndices", "incomplete normal data"}, + {"MissingTextureData", "incomplete texture coordinate data"}, + {"MissingTextureIndices", "incomplete texture coordinate data"}, +}; + +const struct { + const char* name; + const char* message; +} InvalidOptionalCoordinateData[]{ + {"UnsupportedPositionW", "homogeneous coordinates are not supported"}, + {"UnsupportedTextureW", "3D texture coordinates are not supported"} +}; + ObjImporterTest::ObjImporterTest() { - addTests({&ObjImporterTest::pointMesh, - &ObjImporterTest::lineMesh, - &ObjImporterTest::triangleMesh, - &ObjImporterTest::mixedPrimitives, - - &ObjImporterTest::positionsOnly, - &ObjImporterTest::textureCoordinates, - &ObjImporterTest::normals, - &ObjImporterTest::textureCoordinatesNormals, - - &ObjImporterTest::emptyFile, - &ObjImporterTest::unnamedMesh, - &ObjImporterTest::namedMesh, - &ObjImporterTest::moreMeshes, - &ObjImporterTest::unnamedFirstMesh, - - &ObjImporterTest::wrongFloat, - &ObjImporterTest::wrongInteger, - &ObjImporterTest::unmergedIndexOutOfRange, - &ObjImporterTest::mergedIndexOutOfRange, - &ObjImporterTest::zeroIndex, - - &ObjImporterTest::explicitOptionalPositionCoordinate, - &ObjImporterTest::explicitOptionalTextureCoordinate, - &ObjImporterTest::unsupportedOptionalPositionCoordinate, - &ObjImporterTest::unsupportedOptionalTextureCoordinate, - - &ObjImporterTest::shortFloatData, - &ObjImporterTest::longFloatData, - &ObjImporterTest::longOptionalFloatData, - - &ObjImporterTest::longIndexData, - &ObjImporterTest::wrongPointIndexData, - &ObjImporterTest::wrongLineIndexData, - &ObjImporterTest::wrongTriangleIndexData, - &ObjImporterTest::polygonIndexData, - - &ObjImporterTest::missingPositionData, - &ObjImporterTest::missingNormalData, - &ObjImporterTest::missingTextureCoordinateData, - &ObjImporterTest::missingPositionIndices, - &ObjImporterTest::missingNormalIndices, - &ObjImporterTest::missingTextureCoordinateIndices, - - &ObjImporterTest::wrongTextureCoordinateIndexCount, - &ObjImporterTest::wrongNormalIndexCount, - - &ObjImporterTest::unsupportedKeyword, - &ObjImporterTest::unknownKeyword, - - &ObjImporterTest::openTwice, + addTests({&ObjImporterTest::empty, + + &ObjImporterTest::meshPrimitivePoints, + &ObjImporterTest::meshPrimitiveLines, + &ObjImporterTest::meshPrimitiveTriangles, + + &ObjImporterTest::meshPositionsOptionalCoordinate, + &ObjImporterTest::meshTextureCoordinates, + &ObjImporterTest::meshTextureCoordinatesOptionalCoordinate, + &ObjImporterTest::meshNormals, + &ObjImporterTest::meshTextureCoordinatesNormals, + + &ObjImporterTest::meshIgnoredKeyword, + + &ObjImporterTest::meshNamed, + &ObjImporterTest::meshNamedFirstUnnamed, + + &ObjImporterTest::moreMeshes}); + + addInstancedTests({&ObjImporterTest::invalid}, + Containers::arraySize(InvalidData)); + + addInstancedTests({&ObjImporterTest::invalidNumbers}, + Containers::arraySize(InvalidNumbersData)); + + addInstancedTests({&ObjImporterTest::invalidNumberCount}, + Containers::arraySize(InvalidNumberCountData)); + + addInstancedTests({&ObjImporterTest::invalidInconsistentIndexTuple}, + Containers::arraySize(InvalidInconsistentIndexTupleData)); + + addInstancedTests({&ObjImporterTest::invalidIncompleteData}, + Containers::arraySize(InvalidIncompleteDataData)); + + addInstancedTests({&ObjImporterTest::invalidOptionalCoordinate}, + Containers::arraySize(InvalidOptionalCoordinateData)); + + addTests({&ObjImporterTest::openTwice, &ObjImporterTest::importTwice}); #ifdef OBJIMPORTER_PLUGIN_FILENAME @@ -159,9 +193,25 @@ ObjImporterTest::ObjImporterTest() { #endif } -void ObjImporterTest::pointMesh() { +void ObjImporterTest::empty() { + /* Duplicates what's in invalidIncompleteData(MissingPositionData), but + it's good to have such case explicit. It also tests for empty naming. */ + + Containers::Pointer importer = _manager.instantiate("ObjImporter"); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "empty.obj"))); + CORRADE_COMPARE(importer->meshCount(), 1); + CORRADE_COMPARE(importer->meshName(0), ""); + CORRADE_COMPARE(importer->meshForName(""), -1); + + std::ostringstream out; + Error redirectError{&out}; + CORRADE_VERIFY(!importer->mesh(0)); + CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): incomplete position data\n"); +} + +void ObjImporterTest::meshPrimitivePoints() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "pointMesh.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-primitive-points.obj"))); CORRADE_COMPARE(importer->meshCount(), 1); const Containers::Optional data = importer->mesh(0); @@ -183,9 +233,9 @@ void ObjImporterTest::pointMesh() { TestSuite::Compare::Container); } -void ObjImporterTest::lineMesh() { +void ObjImporterTest::meshPrimitiveLines() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "lineMesh.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-primitive-lines.obj"))); CORRADE_COMPARE(importer->meshCount(), 1); const Containers::Optional data = importer->mesh(0); @@ -205,9 +255,9 @@ void ObjImporterTest::lineMesh() { TestSuite::Compare::Container); } -void ObjImporterTest::triangleMesh() { +void ObjImporterTest::meshPrimitiveTriangles() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "triangleMesh.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-primitive-triangles.obj"))); CORRADE_COMPARE(importer->meshCount(), 1); const Containers::Optional data = importer->mesh(0); @@ -228,31 +278,23 @@ void ObjImporterTest::triangleMesh() { TestSuite::Compare::Container); } -void ObjImporterTest::mixedPrimitives() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mixedPrimitives.obj"))); - CORRADE_COMPARE(importer->meshCount(), 1); - - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(0)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): mixed primitive MeshPrimitive::Points and MeshPrimitive::Lines\n"); -} - -void ObjImporterTest::positionsOnly() { +void ObjImporterTest::meshPositionsOptionalCoordinate() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "triangleMesh.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-positions-optional-coordinate.obj"))); CORRADE_COMPARE(importer->meshCount(), 1); const Containers::Optional data = importer->mesh(0); CORRADE_VERIFY(data); CORRADE_COMPARE(data->attributeCount(), 1); - CORRADE_VERIFY(data->hasAttribute(MeshAttribute::Position)); + CORRADE_COMPARE_AS(data->attribute(MeshAttribute::Position), + Containers::arrayView({ + {1.5f, 2.0f, 3.0f} + }), TestSuite::Compare::Container); } -void ObjImporterTest::textureCoordinates() { +void ObjImporterTest::meshTextureCoordinates() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "textureCoordinates.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-texture-coordinates.obj"))); CORRADE_COMPARE(importer->meshCount(), 1); const Containers::Optional data = importer->mesh(0); @@ -280,9 +322,23 @@ void ObjImporterTest::textureCoordinates() { TestSuite::Compare::Container); } -void ObjImporterTest::normals() { +void ObjImporterTest::meshTextureCoordinatesOptionalCoordinate() { + Containers::Pointer importer = _manager.instantiate("ObjImporter"); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-texture-coordinates-optional-coordinate.obj"))); + CORRADE_COMPARE(importer->meshCount(), 1); + + const Containers::Optional data = importer->mesh(0); + CORRADE_VERIFY(data); + CORRADE_COMPARE(data->attributeCount(MeshAttribute::TextureCoordinates), 1); + CORRADE_COMPARE_AS(data->attribute(MeshAttribute::TextureCoordinates), + Containers::arrayView({ + {0.5f, 0.7f} + }), TestSuite::Compare::Container); +} + +void ObjImporterTest::meshNormals() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "normals.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-normals.obj"))); CORRADE_COMPARE(importer->meshCount(), 1); const Containers::Optional data = importer->mesh(0); @@ -310,9 +366,9 @@ void ObjImporterTest::normals() { TestSuite::Compare::Container); } -void ObjImporterTest::textureCoordinatesNormals() { +void ObjImporterTest::meshTextureCoordinatesNormals() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "textureCoordinatesNormals.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-texture-coordinates-normals.obj"))); CORRADE_COMPARE(importer->meshCount(), 1); const Containers::Optional data = importer->mesh(0); @@ -350,31 +406,50 @@ void ObjImporterTest::textureCoordinatesNormals() { TestSuite::Compare::Container); } -void ObjImporterTest::emptyFile() { +void ObjImporterTest::meshIgnoredKeyword() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "emptyFile.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-ignored-keyword.obj"))); CORRADE_COMPARE(importer->meshCount(), 1); -} -void ObjImporterTest::unnamedMesh() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "emptyFile.obj"))); - CORRADE_COMPARE(importer->meshCount(), 1); - CORRADE_COMPARE(importer->meshName(0), ""); - CORRADE_COMPARE(importer->meshForName(""), -1); + /* Everything should be parsed properly */ + const Containers::Optional data = importer->mesh(0); + CORRADE_VERIFY(data); + CORRADE_COMPARE(data->primitive(), MeshPrimitive::Points); + CORRADE_COMPARE(data->attributeCount(), 1); + CORRADE_COMPARE_AS(data->attribute(MeshAttribute::Position), + Containers::arrayView({ + {0.0f, 1.0f, 2.0f} + }), TestSuite::Compare::Container); + CORRADE_VERIFY(data->isIndexed()); + CORRADE_COMPARE(data->indexType(), MeshIndexType::UnsignedInt); + CORRADE_COMPARE_AS(data->indices(), + Containers::arrayView({0}), + TestSuite::Compare::Container); } -void ObjImporterTest::namedMesh() { +void ObjImporterTest::meshNamed() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "namedMesh.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-named.obj"))); CORRADE_COMPARE(importer->meshCount(), 1); CORRADE_COMPARE(importer->meshName(0), "MyMesh"); CORRADE_COMPARE(importer->meshForName("MyMesh"), 0); } +void ObjImporterTest::meshNamedFirstUnnamed() { + Containers::Pointer importer = _manager.instantiate("ObjImporter"); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-named-first-unnamed.obj"))); + CORRADE_COMPARE(importer->meshCount(), 2); + + CORRADE_COMPARE(importer->meshName(0), ""); + CORRADE_COMPARE(importer->meshForName(""), -1); + + CORRADE_COMPARE(importer->meshName(1), "SecondMesh"); + CORRADE_COMPARE(importer->meshForName("SecondMesh"), 1); +} + void ObjImporterTest::moreMeshes() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "moreMeshes.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-multiple.obj"))); CORRADE_COMPARE(importer->meshCount(), 3); CORRADE_COMPARE(importer->meshName(0), "PointMesh"); @@ -452,370 +527,113 @@ void ObjImporterTest::moreMeshes() { TestSuite::Compare::Container); } -void ObjImporterTest::unnamedFirstMesh() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "unnamedFirstMesh.obj"))); - CORRADE_COMPARE(importer->meshCount(), 2); - - CORRADE_COMPARE(importer->meshName(0), ""); - CORRADE_COMPARE(importer->meshForName(""), -1); - - CORRADE_COMPARE(importer->meshName(1), "SecondMesh"); - CORRADE_COMPARE(importer->meshForName("SecondMesh"), 1); -} - -void ObjImporterTest::wrongFloat() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongNumbers.obj"))); - const Int id = importer->meshForName("WrongFloat"); - CORRADE_VERIFY(id > -1); - - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): error while converting numeric data\n"); -} - -void ObjImporterTest::wrongInteger() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongNumbers.obj"))); - const Int id = importer->meshForName("WrongInteger"); - CORRADE_VERIFY(id > -1); - - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): error while converting numeric data\n"); -} - -void ObjImporterTest::unmergedIndexOutOfRange() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongNumbers.obj"))); - const Int id = importer->meshForName("PositionIndexOutOfRange"); - CORRADE_VERIFY(id > -1); - - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): index 1 out of range for 1 vertices\n"); -} - -void ObjImporterTest::mergedIndexOutOfRange() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongNumbers.obj"))); - const Int id = importer->meshForName("TextureIndexOutOfRange"); - CORRADE_VERIFY(id > -1); - - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): index 2 out of range for 1 vertices\n"); -} - -void ObjImporterTest::zeroIndex() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongNumbers.obj"))); - const Int id = importer->meshForName("ZeroIndex"); - CORRADE_VERIFY(id > -1); - - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): index 0 out of range for 1 vertices\n"); -} - -void ObjImporterTest::explicitOptionalPositionCoordinate() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "optionalCoordinates.obj"))); - const Int id = importer->meshForName("SupportedPositionW"); - CORRADE_VERIFY(id > -1); - - const Containers::Optional data = importer->mesh(id); - CORRADE_VERIFY(data); - CORRADE_COMPARE(data->attributeCount(), 1); - CORRADE_COMPARE_AS(data->attribute(MeshAttribute::Position), - Containers::arrayView({ - {1.5f, 2.0f, 3.0f} - }), TestSuite::Compare::Container); -} - -void ObjImporterTest::explicitOptionalTextureCoordinate() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "optionalCoordinates.obj"))); - const Int id = importer->meshForName("SupportedTextureW"); - CORRADE_VERIFY(id > -1); - - const Containers::Optional data = importer->mesh(id); - CORRADE_VERIFY(data); - CORRADE_COMPARE(data->attributeCount(MeshAttribute::TextureCoordinates), 1); - CORRADE_COMPARE_AS(data->attribute(MeshAttribute::TextureCoordinates), - Containers::arrayView({ - {0.5f, 0.7f} - }), TestSuite::Compare::Container); -} - -void ObjImporterTest::unsupportedOptionalPositionCoordinate() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "optionalCoordinates.obj"))); - const Int id = importer->meshForName("UnsupportedPositionW"); - CORRADE_VERIFY(id > -1); - - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): homogeneous coordinates are not supported\n"); -} - -void ObjImporterTest::unsupportedOptionalTextureCoordinate() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "optionalCoordinates.obj"))); - const Int id = importer->meshForName("UnsupportedTextureW"); - CORRADE_VERIFY(id > -1); - - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): 3D texture coordinates are not supported\n"); -} - -void ObjImporterTest::shortFloatData() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongNumberCount.obj"))); - const Int id = importer->meshForName("ShortFloat"); - CORRADE_VERIFY(id > -1); - - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): invalid float array size\n"); -} +void ObjImporterTest::invalid() { + auto&& data = InvalidData[testCaseInstanceId()]; + setTestCaseDescription(data.name); -void ObjImporterTest::longFloatData() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongNumberCount.obj"))); - const Int id = importer->meshForName("LongFloat"); - CORRADE_VERIFY(id > -1); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, data.filename))); - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): invalid float array size\n"); -} - -void ObjImporterTest::longOptionalFloatData() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongNumberCount.obj"))); - const Int id = importer->meshForName("LongOptionalFloat"); - CORRADE_VERIFY(id > -1); + CORRADE_COMPARE(importer->meshCount(), 1); std::ostringstream out; Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): invalid float array size\n"); + CORRADE_VERIFY(!importer->mesh(0)); + CORRADE_COMPARE(out.str(), Utility::formatString("Trade::ObjImporter::mesh(): {}\n", data.message)); } -void ObjImporterTest::longIndexData() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongNumberCount.obj"))); - const Int id = importer->meshForName("InvalidIndices"); - CORRADE_VERIFY(id > -1); - - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): invalid index data\n"); -} +void ObjImporterTest::invalidNumbers() { + auto&& data = InvalidNumbersData[testCaseInstanceId()]; + setTestCaseDescription(data.name); -void ObjImporterTest::wrongPointIndexData() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongNumberCount.obj"))); - const Int id = importer->meshForName("WrongPointIndices"); - CORRADE_VERIFY(id > -1); - - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): wrong index count for point\n"); -} + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "invalid-numbers.obj"))); -void ObjImporterTest::wrongLineIndexData() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongNumberCount.obj"))); - const Int id = importer->meshForName("WrongLineIndices"); - CORRADE_VERIFY(id > -1); + /* Ensure we didn't forget to test any case */ + CORRADE_COMPARE(importer->meshCount(), Containers::arraySize(InvalidNumbersData)); std::ostringstream out; Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): wrong index count for line\n"); + CORRADE_VERIFY(!importer->mesh(data.name)); + CORRADE_COMPARE(out.str(), Utility::formatString("Trade::ObjImporter::mesh(): {}\n", data.message)); } -void ObjImporterTest::wrongTriangleIndexData() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongNumberCount.obj"))); - const Int id = importer->meshForName("WrongTriangleIndices"); - CORRADE_VERIFY(id > -1); +void ObjImporterTest::invalidNumberCount() { + auto&& data = InvalidNumberCountData[testCaseInstanceId()]; + setTestCaseDescription(data.name); - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): wrong index count for triangle\n"); -} - -void ObjImporterTest::polygonIndexData() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongNumberCount.obj"))); - const Int id = importer->meshForName("PolygonIndices"); - CORRADE_VERIFY(id > -1); - - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): polygons are not supported\n"); -} + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "invalid-number-count.obj"))); -void ObjImporterTest::missingPositionData() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "missingData.obj"))); - const Int id = importer->meshForName("MissingPositionData"); - CORRADE_VERIFY(id > -1); + /* Ensure we didn't forget to test any case */ + CORRADE_COMPARE(importer->meshCount(), Containers::arraySize(InvalidNumberCountData)); std::ostringstream out; Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): incomplete position data\n"); + CORRADE_VERIFY(!importer->mesh(data.name)); + CORRADE_COMPARE(out.str(), Utility::formatString("Trade::ObjImporter::mesh(): {}\n", data.message)); } -void ObjImporterTest::missingPositionIndices() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "missingData.obj"))); - const Int id = importer->meshForName("MissingPositionIndices"); - CORRADE_VERIFY(id > -1); +void ObjImporterTest::invalidInconsistentIndexTuple() { + auto&& data = InvalidInconsistentIndexTupleData[testCaseInstanceId()]; + setTestCaseDescription(data.name); - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): incomplete position data\n"); -} - -void ObjImporterTest::missingNormalData() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "missingData.obj"))); - const Int id = importer->meshForName("MissingNormalData"); - CORRADE_VERIFY(id > -1); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "invalid-inconsistent-index-tuple.obj"))); - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): incomplete normal data\n"); -} - -void ObjImporterTest::missingNormalIndices() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "missingData.obj"))); - const Int id = importer->meshForName("MissingNormalIndices"); - CORRADE_VERIFY(id > -1); + /* Ensure we didn't forget to test any case */ + CORRADE_COMPARE(importer->meshCount(), Containers::arraySize(InvalidInconsistentIndexTupleData)); std::ostringstream out; Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): incomplete normal data\n"); + CORRADE_VERIFY(!importer->mesh(data.name)); + CORRADE_COMPARE(out.str(), Utility::formatString("Trade::ObjImporter::mesh(): {}\n", data.message)); } -void ObjImporterTest::missingTextureCoordinateData() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "missingData.obj"))); - const Int id = importer->meshForName("MissingTextureData"); - CORRADE_VERIFY(id > -1); - - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): incomplete texture coordinate data\n"); -} +void ObjImporterTest::invalidIncompleteData() { + auto&& data = InvalidIncompleteDataData[testCaseInstanceId()]; + setTestCaseDescription(data.name); -void ObjImporterTest::missingTextureCoordinateIndices() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "missingData.obj"))); - const Int id = importer->meshForName("MissingTextureIndices"); - CORRADE_VERIFY(id > -1); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "invalid-incomplete-data.obj"))); - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): incomplete texture coordinate data\n"); -} - -void ObjImporterTest::wrongNormalIndexCount() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongIndexCount.obj"))); - const Int id = importer->meshForName("ShortNormalIndices"); - CORRADE_VERIFY(id > -1); + /* Ensure we didn't forget to test any case */ + CORRADE_COMPARE(importer->meshCount(), Containers::arraySize(InvalidIncompleteDataData)); std::ostringstream out; Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): some normal indices are missing\n"); + CORRADE_VERIFY(!importer->mesh(data.name)); + CORRADE_COMPARE(out.str(), Utility::formatString("Trade::ObjImporter::mesh(): {}\n", data.message)); } -void ObjImporterTest::wrongTextureCoordinateIndexCount() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "wrongIndexCount.obj"))); - const Int id = importer->meshForName("ShortTextureIndices"); - CORRADE_VERIFY(id > -1); +void ObjImporterTest::invalidOptionalCoordinate() { + auto&& data = InvalidOptionalCoordinateData[testCaseInstanceId()]; + setTestCaseDescription(data.name); - std::ostringstream out; - Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): some texture coordinate indices are missing\n"); -} - -void ObjImporterTest::unsupportedKeyword() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "keywords.obj"))); - const Int id = importer->meshForName("UnsupportedKeyword"); - CORRADE_VERIFY(id > -1); - - /* Everything should be parsed properly */ - const Containers::Optional data = importer->mesh(id); - CORRADE_VERIFY(data); - CORRADE_COMPARE(data->primitive(), MeshPrimitive::Points); - CORRADE_COMPARE(data->attributeCount(), 1); - CORRADE_COMPARE_AS(data->attribute(MeshAttribute::Position), - Containers::arrayView({ - {0.0f, 1.0f, 2.0f} - }), TestSuite::Compare::Container); - CORRADE_VERIFY(data->isIndexed()); - CORRADE_COMPARE(data->indexType(), MeshIndexType::UnsignedInt); - CORRADE_COMPARE_AS(data->indices(), - Containers::arrayView({0}), - TestSuite::Compare::Container); -} + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "invalid-optional-coordinate.obj"))); -void ObjImporterTest::unknownKeyword() { - Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "keywords.obj"))); - const Int id = importer->meshForName("UnknownKeyword"); - CORRADE_VERIFY(id > -1); + /* Ensure we didn't forget to test any case */ + CORRADE_COMPARE(importer->meshCount(), Containers::arraySize(InvalidOptionalCoordinateData)); std::ostringstream out; Error redirectError{&out}; - CORRADE_VERIFY(!importer->mesh(id)); - CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh(): unknown keyword bleh\n"); + CORRADE_VERIFY(!importer->mesh(data.name)); + CORRADE_COMPARE(out.str(), Utility::formatString("Trade::ObjImporter::mesh(): {}\n", data.message)); } void ObjImporterTest::openTwice() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "pointMesh.obj"))); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "pointMesh.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-primitive-points.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-primitive-points.obj"))); /* Shouldn't crash, leak or anything */ } void ObjImporterTest::importTwice() { Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "pointMesh.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-primitive-points.obj"))); /* Verify that everything is working the same way on second use */ { diff --git a/src/MagnumPlugins/ObjImporter/Test/emptyFile.obj b/src/MagnumPlugins/ObjImporter/Test/empty.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/emptyFile.obj rename to src/MagnumPlugins/ObjImporter/Test/empty.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/missingData.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-incomplete-data.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/missingData.obj rename to src/MagnumPlugins/ObjImporter/Test/invalid-incomplete-data.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/wrongIndexCount.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-inconsistent-index-tuple.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/wrongIndexCount.obj rename to src/MagnumPlugins/ObjImporter/Test/invalid-inconsistent-index-tuple.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/invalid-keyword.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-keyword.obj new file mode 100644 index 000000000..3149e4c0a --- /dev/null +++ b/src/MagnumPlugins/ObjImporter/Test/invalid-keyword.obj @@ -0,0 +1 @@ +bleh diff --git a/src/MagnumPlugins/ObjImporter/Test/mixedPrimitives.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-mixed-primitives.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/mixedPrimitives.obj rename to src/MagnumPlugins/ObjImporter/Test/invalid-mixed-primitives.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/wrongNumberCount.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-number-count.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/wrongNumberCount.obj rename to src/MagnumPlugins/ObjImporter/Test/invalid-number-count.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/wrongNumbers.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-numbers.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/wrongNumbers.obj rename to src/MagnumPlugins/ObjImporter/Test/invalid-numbers.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/optionalCoordinates.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-optional-coordinate.obj similarity index 50% rename from src/MagnumPlugins/ObjImporter/Test/optionalCoordinates.obj rename to src/MagnumPlugins/ObjImporter/Test/invalid-optional-coordinate.obj index 7e9132465..205e2fef1 100644 --- a/src/MagnumPlugins/ObjImporter/Test/optionalCoordinates.obj +++ b/src/MagnumPlugins/ObjImporter/Test/invalid-optional-coordinate.obj @@ -1,17 +1,8 @@ -o SupportedPositionW -v 1.5 2 3 1.0 -p 1 - -o SupportedTextureW -v 1.5 2 3 -vt 0.5 0.7 0.0 -p 2/1 - o UnsupportedPositionW v 1.5 2 3 0.8 -p 3 +p 1 o UnsupportedTextureW v 1.5 2 3 vt 0.5 0.7 0.5 -p 4/2 +p 2/1 diff --git a/src/MagnumPlugins/ObjImporter/Test/keywords.obj b/src/MagnumPlugins/ObjImporter/Test/keywords.obj deleted file mode 100644 index c93dce27f..000000000 --- a/src/MagnumPlugins/ObjImporter/Test/keywords.obj +++ /dev/null @@ -1,7 +0,0 @@ -o UnsupportedKeyword -g VertexGroup -v 0 1 2 -p 1 - -o UnknownKeyword -bleh diff --git a/src/MagnumPlugins/ObjImporter/Test/mesh-ignored-keyword.obj b/src/MagnumPlugins/ObjImporter/Test/mesh-ignored-keyword.obj new file mode 100644 index 000000000..b0ccfc957 --- /dev/null +++ b/src/MagnumPlugins/ObjImporter/Test/mesh-ignored-keyword.obj @@ -0,0 +1,3 @@ +g VertexGroup +v 0 1 2 +p 1 diff --git a/src/MagnumPlugins/ObjImporter/Test/moreMeshes.obj b/src/MagnumPlugins/ObjImporter/Test/mesh-multiple.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/moreMeshes.obj rename to src/MagnumPlugins/ObjImporter/Test/mesh-multiple.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/unnamedFirstMesh.obj b/src/MagnumPlugins/ObjImporter/Test/mesh-named-first-unnamed.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/unnamedFirstMesh.obj rename to src/MagnumPlugins/ObjImporter/Test/mesh-named-first-unnamed.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/namedMesh.obj b/src/MagnumPlugins/ObjImporter/Test/mesh-named.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/namedMesh.obj rename to src/MagnumPlugins/ObjImporter/Test/mesh-named.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/normals.obj b/src/MagnumPlugins/ObjImporter/Test/mesh-normals.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/normals.obj rename to src/MagnumPlugins/ObjImporter/Test/mesh-normals.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/mesh-positions-optional-coordinate.obj b/src/MagnumPlugins/ObjImporter/Test/mesh-positions-optional-coordinate.obj new file mode 100644 index 000000000..b6c111625 --- /dev/null +++ b/src/MagnumPlugins/ObjImporter/Test/mesh-positions-optional-coordinate.obj @@ -0,0 +1,2 @@ +v 1.5 2 3 1.0 +p 1 diff --git a/src/MagnumPlugins/ObjImporter/Test/lineMesh.obj b/src/MagnumPlugins/ObjImporter/Test/mesh-primitive-lines.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/lineMesh.obj rename to src/MagnumPlugins/ObjImporter/Test/mesh-primitive-lines.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/pointMesh.obj b/src/MagnumPlugins/ObjImporter/Test/mesh-primitive-points.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/pointMesh.obj rename to src/MagnumPlugins/ObjImporter/Test/mesh-primitive-points.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/triangleMesh.obj b/src/MagnumPlugins/ObjImporter/Test/mesh-primitive-triangles.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/triangleMesh.obj rename to src/MagnumPlugins/ObjImporter/Test/mesh-primitive-triangles.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/textureCoordinatesNormals.obj b/src/MagnumPlugins/ObjImporter/Test/mesh-texture-coordinates-normals.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/textureCoordinatesNormals.obj rename to src/MagnumPlugins/ObjImporter/Test/mesh-texture-coordinates-normals.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/mesh-texture-coordinates-optional-coordinate.obj b/src/MagnumPlugins/ObjImporter/Test/mesh-texture-coordinates-optional-coordinate.obj new file mode 100644 index 000000000..82933e5dc --- /dev/null +++ b/src/MagnumPlugins/ObjImporter/Test/mesh-texture-coordinates-optional-coordinate.obj @@ -0,0 +1,3 @@ +v 1.5 2 3 +vt 0.5 0.7 0.0 +p 1/1 diff --git a/src/MagnumPlugins/ObjImporter/Test/textureCoordinates.obj b/src/MagnumPlugins/ObjImporter/Test/mesh-texture-coordinates.obj similarity index 100% rename from src/MagnumPlugins/ObjImporter/Test/textureCoordinates.obj rename to src/MagnumPlugins/ObjImporter/Test/mesh-texture-coordinates.obj From 1226c9506b7d53bceda1c5455430d0a0afd482d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 2 Jul 2022 14:31:56 +0200 Subject: [PATCH 03/14] ObjImporter: use human readable names for invalid meshes. NoReasonToMakeThoseCrypticCamelCase. --- .../ObjImporter/Test/ObjImporterTest.cpp | 46 +++++++++---------- .../Test/invalid-incomplete-data.obj | 12 ++--- .../Test/invalid-inconsistent-index-tuple.obj | 4 +- .../ObjImporter/Test/invalid-number-count.obj | 20 ++++---- .../ObjImporter/Test/invalid-numbers.obj | 10 ++-- .../Test/invalid-optional-coordinate.obj | 4 +- 6 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp b/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp index 08b988f7e..44a64356e 100644 --- a/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp +++ b/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp @@ -98,53 +98,53 @@ const struct { const char* name; const char* message; } InvalidNumbersData[]{ - {"WrongFloat", "error while converting numeric data"}, - {"WrongInteger", "error while converting numeric data"}, - {"PositionIndexOutOfRange", "index 1 out of range for 1 vertices"}, - {"TextureIndexOutOfRange", "index 2 out of range for 1 vertices"}, - {"ZeroIndex", "index 0 out of range for 1 vertices"} + {"invalid float literal", "error while converting numeric data"}, + {"invalid integer literal", "error while converting numeric data"}, + {"position index out of range", "index 1 out of range for 1 vertices"}, + {"texture index out of range", "index 2 out of range for 1 vertices"}, + {"zero index", "index 0 out of range for 1 vertices"} }; const struct { const char* name; const char* message; } InvalidNumberCountData[]{ - {"ShortFloat", "invalid float array size"}, - {"LongFloat", "invalid float array size"}, - {"LongOptionalFloat", "invalid float array size"}, - {"InvalidIndices", "invalid index data"}, - {"WrongPointIndices", "wrong index count for point"}, - {"WrongLineIndices", "wrong index count for line"}, - {"WrongTriangleIndices", "wrong index count for triangle"}, - {"PolygonIndices", "polygons are not supported"} + {"two-component position", "invalid float array size"}, + {"five-component position with optional fourth component", "invalid float array size"}, + {"four-component normal", "invalid float array size"}, + {"four-component index tuple", "invalid index data"}, + {"point with two indices", "wrong index count for point"}, + {"line with one index", "wrong index count for line"}, + {"triangle with two indices", "wrong index count for triangle"}, + {"quad", "polygons are not supported"} }; const struct { const char* name; const char* message; } InvalidInconsistentIndexTupleData[]{ - {"ShortNormalIndices", "some normal indices are missing"}, - {"ShortTextureIndices", "some texture coordinate indices are missing"}, + {"missing normal reference", "some normal indices are missing"}, + {"missing texture reference", "some texture coordinate indices are missing"}, }; const struct { const char* name; const char* message; } InvalidIncompleteDataData[]{ - {"MissingPositionData", "incomplete position data"}, - {"MissingPositionIndices", "incomplete position data"}, - {"MissingNormalData", "incomplete normal data"}, - {"MissingNormalIndices", "incomplete normal data"}, - {"MissingTextureData", "incomplete texture coordinate data"}, - {"MissingTextureIndices", "incomplete texture coordinate data"}, + {"missing position data", "incomplete position data"}, + {"missing position indices", "incomplete position data"}, + {"missing normal data", "incomplete normal data"}, + {"missing normal indices", "incomplete normal data"}, + {"missing texture coordinate data", "incomplete texture coordinate data"}, + {"missing texture coordinate indices", "incomplete texture coordinate data"}, }; const struct { const char* name; const char* message; } InvalidOptionalCoordinateData[]{ - {"UnsupportedPositionW", "homogeneous coordinates are not supported"}, - {"UnsupportedTextureW", "3D texture coordinates are not supported"} + {"position with optional fourth component not one", "homogeneous coordinates are not supported"}, + {"texture with optional third component not zero", "3D texture coordinates are not supported"} }; ObjImporterTest::ObjImporterTest() { diff --git a/src/MagnumPlugins/ObjImporter/Test/invalid-incomplete-data.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-incomplete-data.obj index 554d520b9..3133e1127 100644 --- a/src/MagnumPlugins/ObjImporter/Test/invalid-incomplete-data.obj +++ b/src/MagnumPlugins/ObjImporter/Test/invalid-incomplete-data.obj @@ -1,23 +1,23 @@ -o MissingPositionData +o missing position data p 1 -o MissingPositionIndices +o missing position indices v 1 2 3 -o MissingNormalData +o missing normal data v 1 2 3 p 3//3 -o MissingNormalIndices +o missing normal indices v 1 2 3 vn 1 2 3 p 4 -o MissingTextureData +o missing texture coordinate data v 1 2 3 p 5/1 -o MissingTextureIndices +o missing texture coordinate indices v 1 2 3 vt 1 2 p 6 diff --git a/src/MagnumPlugins/ObjImporter/Test/invalid-inconsistent-index-tuple.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-inconsistent-index-tuple.obj index 0a98d1573..f71889bab 100644 --- a/src/MagnumPlugins/ObjImporter/Test/invalid-inconsistent-index-tuple.obj +++ b/src/MagnumPlugins/ObjImporter/Test/invalid-inconsistent-index-tuple.obj @@ -1,11 +1,11 @@ -o ShortNormalIndices +o missing normal reference v 1 2 3 vn 1 2 3 p 1//1 p 1 p 1//1 -o ShortTextureIndices +o missing texture reference v 1 2 3 vt 1 2 p 2/2 diff --git a/src/MagnumPlugins/ObjImporter/Test/invalid-number-count.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-number-count.obj index 4bfab647f..088b54fed 100644 --- a/src/MagnumPlugins/ObjImporter/Test/invalid-number-count.obj +++ b/src/MagnumPlugins/ObjImporter/Test/invalid-number-count.obj @@ -1,29 +1,29 @@ -o ShortFloat +o two-component position v 0.5 1.0 -o LongFloat +o five-component position with optional fourth component +v 0.5 1 2 0.0 3.5 + +o four-component normal v 0.5 1 2 vn 0.5 1.0 2.3 7.4 -o LongOptionalFloat -v 0.5 1 2 0.0 3.5 - -o InvalidIndices +o four-component index tuple v 1 2 3 p 4/1/1/1 -o WrongPointIndices +o point with two indices v 1 2 3 p 5 5 -o WrongLineIndices +o line with one index v 1 2 3 l 6 -o WrongTriangleIndices +o triangle with two indices v 1 2 3 f 7 7 -o PolygonIndices +o quad v 1 2 3 f 8 8 8 8 diff --git a/src/MagnumPlugins/ObjImporter/Test/invalid-numbers.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-numbers.obj index ce6589a05..f93ecf811 100644 --- a/src/MagnumPlugins/ObjImporter/Test/invalid-numbers.obj +++ b/src/MagnumPlugins/ObjImporter/Test/invalid-numbers.obj @@ -1,22 +1,22 @@ -o WrongFloat +o invalid float literal v 1 bleh 2 p 1 -o WrongInteger +o invalid integer literal v 1 0 2 p bleh -o PositionIndexOutOfRange +o position index out of range v 1 0 2 # Should be 3 p 1 -o TextureIndexOutOfRange +o texture index out of range v 1 0 2 vt 0 1 # Should be 4/1 p 4/2 -o ZeroIndex +o zero index v 1 0 2 p 0 diff --git a/src/MagnumPlugins/ObjImporter/Test/invalid-optional-coordinate.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-optional-coordinate.obj index 205e2fef1..0ffafa3e7 100644 --- a/src/MagnumPlugins/ObjImporter/Test/invalid-optional-coordinate.obj +++ b/src/MagnumPlugins/ObjImporter/Test/invalid-optional-coordinate.obj @@ -1,8 +1,8 @@ -o UnsupportedPositionW +o position with optional fourth component not one v 1.5 2 3 0.8 p 1 -o UnsupportedTextureW +o texture with optional third component not zero v 1.5 2 3 vt 0.5 0.7 0.5 p 2/1 From 79aa6f3546a1f8d81c3b26cccc793ddd48cf0c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 2 Jul 2022 14:58:20 +0200 Subject: [PATCH 04/14] ObjImporter: test also normal index out of range. Coverage says this isn't covered! --- .../ObjImporter/Test/ObjImporterTest.cpp | 3 ++- .../ObjImporter/Test/invalid-numbers.obj | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp b/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp index 44a64356e..a2849e616 100644 --- a/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp +++ b/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp @@ -101,7 +101,8 @@ const struct { {"invalid float literal", "error while converting numeric data"}, {"invalid integer literal", "error while converting numeric data"}, {"position index out of range", "index 1 out of range for 1 vertices"}, - {"texture index out of range", "index 2 out of range for 1 vertices"}, + {"texture index out of range", "index 4 out of range for 3 vertices"}, + {"normal index out of range", "index 3 out of range for 2 vertices"}, {"zero index", "index 0 out of range for 1 vertices"} }; diff --git a/src/MagnumPlugins/ObjImporter/Test/invalid-numbers.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-numbers.obj index f93ecf811..88eb62e51 100644 --- a/src/MagnumPlugins/ObjImporter/Test/invalid-numbers.obj +++ b/src/MagnumPlugins/ObjImporter/Test/invalid-numbers.obj @@ -14,8 +14,17 @@ p 1 o texture index out of range v 1 0 2 vt 0 1 -# Should be 4/1 -p 4/2 +vt 0 1 +vt 0 1 +# Should be 4/3 +p 4/4 + +o normal index out of range +v 1 0 2 +vn 0 0 1 +vn 0 0 1 +# Should be 5/2 +p 5//3 o zero index v 1 0 2 From d3e16d8435e18ff4ef173d2024b9babc7f551030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 2 Jul 2022 15:04:47 +0200 Subject: [PATCH 05/14] ObjImporter: test all cases of invalid mixed primitives. This might eventually be a supported case (an object referencing three meshes with different primitives), but let's just cover the existing code for now. --- .../ObjImporter/Test/ObjImporterTest.cpp | 34 +++++++++++++++++-- .../Test/invalid-mixed-primitives.obj | 19 ++++++----- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp b/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp index a2849e616..e2610b3cf 100644 --- a/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp +++ b/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp @@ -70,6 +70,7 @@ struct ObjImporterTest: TestSuite::Tester { with each case testing one file and just the invalid() case testing separate files. */ void invalid(); + void invalidMixedPrimitives(); void invalidNumbers(); void invalidNumberCount(); void invalidInconsistentIndexTuple(); @@ -88,12 +89,22 @@ const struct { const char* filename; const char* message; } InvalidData[]{ - {"mixed primitives", "invalid-mixed-primitives.obj", - "mixed primitive MeshPrimitive::Points and MeshPrimitive::Lines"}, {"unknown keyword", "invalid-keyword.obj", "unknown keyword bleh"} }; +const struct { + const char* name; + const char* message; +} InvalidMixedPrimitivesData[]{ + {"points after some other", + "mixed primitive MeshPrimitive::Triangles and MeshPrimitive::Points"}, + {"lines after some other", + "mixed primitive MeshPrimitive::Points and MeshPrimitive::Lines"}, + {"triangles after some other", + "mixed primitive MeshPrimitive::Lines and MeshPrimitive::Triangles"}, +}; + const struct { const char* name; const char* message; @@ -171,6 +182,9 @@ ObjImporterTest::ObjImporterTest() { addInstancedTests({&ObjImporterTest::invalid}, Containers::arraySize(InvalidData)); + addInstancedTests({&ObjImporterTest::invalidMixedPrimitives}, + Containers::arraySize(InvalidMixedPrimitivesData)); + addInstancedTests({&ObjImporterTest::invalidNumbers}, Containers::arraySize(InvalidNumbersData)); @@ -543,6 +557,22 @@ void ObjImporterTest::invalid() { CORRADE_COMPARE(out.str(), Utility::formatString("Trade::ObjImporter::mesh(): {}\n", data.message)); } +void ObjImporterTest::invalidMixedPrimitives() { + auto&& data = InvalidMixedPrimitivesData[testCaseInstanceId()]; + setTestCaseDescription(data.name); + + Containers::Pointer importer = _manager.instantiate("ObjImporter"); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "invalid-mixed-primitives.obj"))); + + /* Ensure we didn't forget to test any case */ + CORRADE_COMPARE(importer->meshCount(), Containers::arraySize(InvalidMixedPrimitivesData)); + + std::ostringstream out; + Error redirectError{&out}; + CORRADE_VERIFY(!importer->mesh(data.name)); + CORRADE_COMPARE(out.str(), Utility::formatString("Trade::ObjImporter::mesh(): {}\n", data.message)); +} + void ObjImporterTest::invalidNumbers() { auto&& data = InvalidNumbersData[testCaseInstanceId()]; setTestCaseDescription(data.name); diff --git a/src/MagnumPlugins/ObjImporter/Test/invalid-mixed-primitives.obj b/src/MagnumPlugins/ObjImporter/Test/invalid-mixed-primitives.obj index e4ab55130..825fd24c6 100644 --- a/src/MagnumPlugins/ObjImporter/Test/invalid-mixed-primitives.obj +++ b/src/MagnumPlugins/ObjImporter/Test/invalid-mixed-primitives.obj @@ -1,13 +1,14 @@ -# Positions -v 0.5 2 3 -v 0 1.5 1 +o points after some other v 2 3 5.0 - -# Points +f 1 1 1 p 1 -p 3 + +o lines after some other +v 2 3 5.0 p 2 +l 2 2 2 -# Lines -l 1 2 -l 2 3 +o triangles after some other +v 2 3 5.0 +l 3 3 +f 3 3 3 From 6439cfac105539b8d9a4a429910e1786278848e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 4 Jul 2022 11:12:45 +0200 Subject: [PATCH 06/14] ObjImporter: test also when the first entry in the file is an index. That's the last important uncovered bit in the code. --- .../ObjImporter/Test/CMakeLists.txt | 1 + .../ObjImporter/Test/ObjImporterTest.cpp | 21 +++++++++++++++---- .../mesh-named-first-unnamed-index-first.obj | 3 +++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/MagnumPlugins/ObjImporter/Test/mesh-named-first-unnamed-index-first.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt b/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt index 6dc2f46a9..880f94c1c 100644 --- a/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt @@ -57,6 +57,7 @@ corrade_add_test(ObjImporterTest ObjImporterTest.cpp mesh-ignored-keyword.obj mesh-multiple.obj mesh-named-first-unnamed.obj + mesh-named-first-unnamed-index-first.obj mesh-named.obj mesh-normals.obj mesh-positions-optional-coordinate.obj diff --git a/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp b/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp index e2610b3cf..925bfbdca 100644 --- a/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp +++ b/src/MagnumPlugins/ObjImporter/Test/ObjImporterTest.cpp @@ -84,6 +84,14 @@ struct ObjImporterTest: TestSuite::Tester { PluginManager::Manager _manager{"nonexistent"}; }; +const struct { + const char* name; + const char* filename; +} MeshNamedFirstUnnamedData[]{ + {"", "mesh-named-first-unnamed.obj"}, + {"index first", "mesh-named-first-unnamed-index-first.obj"}, +}; + const struct { const char* name; const char* filename; @@ -174,10 +182,12 @@ ObjImporterTest::ObjImporterTest() { &ObjImporterTest::meshIgnoredKeyword, - &ObjImporterTest::meshNamed, - &ObjImporterTest::meshNamedFirstUnnamed, + &ObjImporterTest::meshNamed}); - &ObjImporterTest::moreMeshes}); + addInstancedTests({&ObjImporterTest::meshNamedFirstUnnamed}, + Containers::arraySize(MeshNamedFirstUnnamedData)); + + addTests({&ObjImporterTest::moreMeshes}); addInstancedTests({&ObjImporterTest::invalid}, Containers::arraySize(InvalidData)); @@ -451,8 +461,11 @@ void ObjImporterTest::meshNamed() { } void ObjImporterTest::meshNamedFirstUnnamed() { + auto&& data = MeshNamedFirstUnnamedData[testCaseInstanceId()]; + setTestCaseDescription(data.name); + Containers::Pointer importer = _manager.instantiate("ObjImporter"); - CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, "mesh-named-first-unnamed.obj"))); + CORRADE_VERIFY(importer->openFile(Utility::Path::join(OBJIMPORTER_TEST_DIR, data.filename))); CORRADE_COMPARE(importer->meshCount(), 2); CORRADE_COMPARE(importer->meshName(0), ""); diff --git a/src/MagnumPlugins/ObjImporter/Test/mesh-named-first-unnamed-index-first.obj b/src/MagnumPlugins/ObjImporter/Test/mesh-named-first-unnamed-index-first.obj new file mode 100644 index 000000000..89a8ea72d --- /dev/null +++ b/src/MagnumPlugins/ObjImporter/Test/mesh-named-first-unnamed-index-first.obj @@ -0,0 +1,3 @@ +p 1 +v 1 2 3 +o SecondMesh From ba111be8932387d86b59418510ecdec41b17f8ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 4 Jul 2022 21:57:30 +0200 Subject: [PATCH 07/14] ObjImporter: unneeded include. --- src/MagnumPlugins/ObjImporter/ObjImporter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/MagnumPlugins/ObjImporter/ObjImporter.cpp b/src/MagnumPlugins/ObjImporter/ObjImporter.cpp index 8c2a0e707..71b551690 100644 --- a/src/MagnumPlugins/ObjImporter/ObjImporter.cpp +++ b/src/MagnumPlugins/ObjImporter/ObjImporter.cpp @@ -38,7 +38,6 @@ #include #include "Magnum/Mesh.h" -#include "Magnum/MeshTools/CompressIndices.h" #include "Magnum/MeshTools/RemoveDuplicates.h" #include "Magnum/MeshTools/Duplicate.h" #include "Magnum/Math/Color.h" From 46e65477ec31ee9df94b23506cb3906ca9c1535b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 6 Jul 2022 16:01:14 +0200 Subject: [PATCH 08/14] Updated toolchains submodule. --- toolchains | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolchains b/toolchains index 8847ed069..65568a98f 160000 --- a/toolchains +++ b/toolchains @@ -1 +1 @@ -Subproject commit 8847ed06932798f884d8edc7f58d8c0ccf5f1620 +Subproject commit 65568a98fa48de0369f35e9788779fdfbe14cacc From fee2d94946cfca7c629fab26b716e00d3dca6dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 6 Jul 2022 16:01:23 +0200 Subject: [PATCH 09/14] package/archlinux: updated AUR PKGBUILD version. --- package/archlinux/magnum-git/PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/archlinux/magnum-git/PKGBUILD b/package/archlinux/magnum-git/PKGBUILD index f347ad388..68480f08c 100644 --- a/package/archlinux/magnum-git/PKGBUILD +++ b/package/archlinux/magnum-git/PKGBUILD @@ -1,6 +1,6 @@ # Author: mosra pkgname=magnum-git -pkgver=2020.06.r481.ga4979e2cd +pkgver=2020.06.r1626.g67d37c9ed pkgrel=1 pkgdesc="C++11/C++14 graphics middleware for games and data visualization (Git version)" arch=('i686' 'x86_64') From d75adc68724740711df5ea3eec97f6b27485e246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 9 Jul 2022 12:19:27 +0200 Subject: [PATCH 10/14] Cleanup and improve comments for various tag definitions. --- src/Magnum/Tags.h | 4 ++-- src/Magnum/Test/TagsTest.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Magnum/Tags.h b/src/Magnum/Tags.h index d03446574..7725ad848 100644 --- a/src/Magnum/Tags.h +++ b/src/Magnum/Tags.h @@ -83,10 +83,10 @@ using Corrade::NoCreateT; Used to distinguish construction without allocating memory. @see @ref NoAllocate */ -/* Explicit constructor to avoid ambiguous calls when using {} */ struct NoAllocateT { #ifndef DOXYGEN_GENERATING_OUTPUT - struct Init{}; + struct Init {}; + /* Explicit constructor to avoid ambiguous calls when using {} */ constexpr explicit NoAllocateT(Init) {} #endif }; diff --git a/src/Magnum/Test/TagsTest.cpp b/src/Magnum/Test/TagsTest.cpp index 0fd60736c..5c19b7eb7 100644 --- a/src/Magnum/Test/TagsTest.cpp +++ b/src/Magnum/Test/TagsTest.cpp @@ -43,12 +43,15 @@ TagsTest::TagsTest() { } void TagsTest::noDefaultConstructor() { + /* Isn't default constructible to prevent ambiguity when calling + foo({}) if both foo(TagT) and foo(whatever) is available */ CORRADE_VERIFY(!std::is_default_constructible::value); CORRADE_VERIFY(!std::is_default_constructible::value); CORRADE_VERIFY(!std::is_default_constructible::value); } void TagsTest::inlineDefinition() { + /* Just a sanity check that the types match */ CORRADE_VERIFY(std::is_same::value); CORRADE_VERIFY(std::is_same::value); CORRADE_VERIFY(std::is_same::value); From 7d08742341e23f7c2b92e6a82eddf7018214edf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 12 Jul 2022 11:59:16 +0200 Subject: [PATCH 11/14] doc: fix GL/VK extension and version checklist to match actual workflow. It got written once and never updated, and the order that was there needed a lot more brain cycles than strictly necessary. --- doc/developers.dox | 170 ++++++++++++------ .../OpenGL/GLES2/Emscripten/extensions.txt | 4 +- .../OpenGL/GLES2/extensions.txt | 1 + 3 files changed, 122 insertions(+), 53 deletions(-) diff --git a/doc/developers.dox b/doc/developers.dox index 8ba8a5c6c..eca282ff5 100644 --- a/doc/developers.dox +++ b/doc/developers.dox @@ -561,14 +561,41 @@ in inverse --- but usually @ref developers-deprecation "deprecate first". 10. Iterate until the CIs are green 11. Merge to `master` -@section developers-gl-extensions Checklist for adding / removing GL versions and extensions - -1. Install [flextGL](https://github.com/mosra/flextgl) -2. Go to `src/MagnumExternal/OpenGL/`: - - Update `GL/extensions.txt`, `GLES2/extensions.txt`, +@section developers-gl-extensions Checklist for adding / removing GL extensions + +1. Add new extensions to the GL, GLES and WebGL sections of + `src/Magnum/GL/Extensions.h` + - Order them by extension ID that is mentioned in every extension spec + file. If the extension isn't in the official Khronos registry (such as + various ANGLE extensions), at it at the end of the range. + - Update the numbering to stay monotonic and unique, round up start index + of next section to nearest ten to make the updates bearable + - In case there's a lot of new extensions, + @cpp Implementation::ExtensionCount @ce might needed to be increased. +2. Add them alphabetically ordered to the correct list in + `src/magnum/GL/Context.cpp` + - run GL, ES2, ES3, WebGL1 and WebGL2 build of `GLContextTest` to verify + everything is still okay + - run GL, ES2, ES3, WebGL1 and WebGL2 build of `magnum-gl-info` + - the extension should be listed unless it's not available on given + GL flavor + - and also marked as supported unless the machine doesn't support it + (cross-check with `--extension-strings`) +3. Get [flextGL](https://github.com/mosra/flextgl) and go to + `src/MagnumExternal/OpenGL/`: + - Add/remove extensions in `GL/extensions.txt`, `GLES2/extensions.txt`, `GLES2/Emscripten/extensions.txt`, `GLES3/extensions.txt`, - `GLES3/Emscripten/extensions.txt` (bump versions or add/remove - extensions) + `GLES3/Emscripten/extensions.txt`, in the same order as in + `src/Magnum/GL/Extensions.h` + - For GLES and WebGL extensions, if they aren't in the official Khronos + registry (such as various ANGLE extensions), check if they're in + ANGLE's [gl_angle_ext.xml](https://raw.githubusercontent.com/google/angle/master/scripts/gl_angle_ext.xml) + at least. If not, like with core WebGL functionality that has no match + in the base GLES spec, you may need to craft your own XML file. See + `src/MagnumExternal/OpenGL/GLES3/webgl.xml` for an example. + - WebGL extensions usually have a GLES extension as a base, but then may + remove certains entrypoints from it. If that's the case, add it to the + function blacklist at the end of the Emscripten-specific files. - Run `./update-flextgl.sh` to update everything. Reason there is so many variants of the files are the following: - Desktop GLES on Windows still links to the ancient `opengl32.dll` @@ -580,11 +607,44 @@ in inverse --- but usually @ref developers-deprecation "deprecate first". set the function pointers to those exported symbols in case the system GL header defines them. - Emscripten doesn't have the ability to manually load extension - pointers, thus it has only header files. -3. Check @cb{.sh} git diff @ce for suspicious changes and whitespace-at-EOL -4. For every new added function, add an entry to `doc/opengl-mapping.dox` -5. For every new added limit query (various `GL_MIN_*` and `GL_MAX_*` macros - etc.), add an entry to the bottom of `doc/opengl-mapping.dox` + pointers either, thus it has only header files. +4. Check @cb{.sh} git diff @ce for suspicious changes and whitespace-at-EOL + - If any extensions don't add any useful symbols, comment them out in + the `extensions.txt` files and regenerate to avoid needless bloat +5. For every new function that appeared in the regenerated extension headers, + add an entry to `doc/opengl-mapping.dox` +6. For every new added limit query that appeared in the regenerated extension + headers (various `GL_MIN_*` and `GL_MAX_*` macros etc.), add an entry to + the bottom of `doc/opengl-mapping.dox` +7. Add new extensions to the general GL, GLES and WebGL lists in + `doc/opengl-support.dox`, again matching the order in `Extensions.h` --- + grouped by prefix, but then ordered by extension number + +In order to remove GL functionality, be sure to touch all places mentioned +above, only in inverse --- but usually @ref developers-deprecation "deprecate first", +unless it doesn't affect public API at all. + +@see @ref developers-gl-versions, @ref developers-vk-extensions + +@section developers-gl-versions Checklist for adding / removing GL versions + +1. Add new version enum value: + - to `src/Magnum/GL/Version.h` + - to debug output in `src/Magnum/GL/Version.cpp` + - to @cpp GL::Extension::extensions() @ce in `src/Magnum/GL/Context.cpp` + - to @cpp GL::Context::tryCreate() @ce in `src/Magnum/GL/Context.cpp` + - to specify GLSL version in `src/Magnum/GL/Shader.cpp` + - to the list in `src/Magnum/Platform/gl-info.cpp` + - to the test in `src/Magnum/GL/Test/ContextTest.cpp` +2. Update existing extensions with version in which they became core (last + parameter of the `_extension()` macro in `src/Magnum/GL/Extensions.h`) +3. Go to `src/MagnumExternal/OpenGL/`, bump versions in `GL/extensions.txt`, + `GLES2/extensions.txt`, `GLES2/Emscripten/extensions.txt`, + `GLES3/extensions.txt`, `GLES3/Emscripten/extensions.txt` +4. Continue with @ref developers-gl-extensions for all extensions that were + added by the new version and were not already present +5. For all existing extensions APIs that lose their suffix in the new version, + update doc references to be without the suffix 6. Add a table listing the new version and all new extensions in it to `doc/opengl-support.dox` (take a list of them from the changelog in the official spec PDF). Some extensions might be already present in the general @@ -595,31 +655,13 @@ in inverse --- but usually @ref developers-deprecation "deprecate first". 8. Add a new `requires-glXY`, `requires-glesXY` or `requires-webglXY` alias to `Doxyfile`, `Doxyfile-mcss` and `Doxyfile-public`, copypaste it from existing and change the numbers -9. Add new version enum value: - - to `src/Magnum/GL/Version.h` - - to debug output in `src/Magnum/GL/Version.cpp` - - to @ref GL::Extension::extensions() in `src/Magnum/GL/Context.cpp` - - to @cpp GL::Context::tryCreate() @ce in `src/Magnum/GL/Context.cpp` - - to specify GLSL version in `src/Magnum/GL/Shader.cpp` - - to the list in `src/Magnum/Platform/gl-info.cpp` - - to the test in `src/Magnum/GL/Test/ContextTest.cpp` -10. Add new extensions to `src/Magnum/GL/Extensions.h` - - order them by extension ID that is mentioned in every extension spec - file - - update the numbering to stay monotonic and unique, round up start index - of next section to nearest ten to make the updates bearable - - in case there's a lot of new extensions, @cpp Implementation::ExtensionCount @ce - might needed to be increased - - run `ContextTest` to verify everything is still okay -11. Update existing extensions with version in which they become core (last - parameter of the `_extension()` macro) -12. Update extension list in `src/magnum/GL/Context.cpp` according to changes - in `src/Magnum/GL/Extensions.h` In order to remove GL functionality, be sure to touch all places mentioned above, only in inverse --- but usually @ref developers-deprecation "deprecate first", unless it doesn't affect public API at all. +@see @ref developers-vk-versions + @section developers-gl-functionality Checklist for adding / removing GL functionality 1. Check if given desktop functionality has equivalent in ES or WebGL, add @@ -728,11 +770,11 @@ In order to remove OpenAL functionality, be sure to touch all places mentioned above, only in inverse --- but usually @ref developers-deprecation "deprecate first", unless it doesn't affect public API at all. -@section developers-vk-extensions Checklist for adding / removing Vulkan versions and extensions +@section developers-vk-extensions Checklist for adding / removing Vulkan extensions -1. Add new extensions to `src/Magnum/Vk/Extensions.h` +1. Add new extensions to `src/Magnum/Vk/Extensions.h` - there's a separate list for instance and device extensions, ensure each - in the right list + is in the right list - order them by extension ID that is mentioned on every extension spec page - update the numbering to stay monotonic and unique, round up start index @@ -743,37 +785,61 @@ unless it doesn't affect public API at all. need to be increased 2. Add them alphabetically ordered to the correct list in `src/Magnum/Vk/Extensions.cpp` -3. Update existing extensions with version in which they become core (last - parameter of the `_extension()` macro) -4. Get [flextGL](https://github.com/mosra/flextgl) and go to + - run `VkExtensionsTest` to verify everything is still okay + - run `magnum-vk-info`, the extension should be listed and also marked as + supported, unless the machine doesn't support it (cross-check with + `--extension-strings`) +3. Get [flextGL](https://github.com/mosra/flextgl) and go to `src/MagnumExternal/Vulkan/`: - - Update `extensions.txt` (bump a version or add/remove extensions), - in the same order as `Extensions.h` + - Add/remove extensions in `extensions.txt`, in the same order as in + `src/Magnum/Vk/Extensions.h` - Run `./update-flexgl.sh` to update everything -5. Check @cb{.sh} git diff @ce for suspicious changes and whitespace-at-EOL -6. For every new added function and structure, add an entry to +4. Check @cb{.sh} git diff @ce for suspicious changes and whitespace-at-EOL + - If any extensions don't add any useful symbols, comment them out in + the `extensions.txt` file and regenerate to avoid needless bloat +5. For every new added function and structure, add an entry to `doc/vulkan-mapping.dox` -7. For every new `*Feature` structure, expand the @ref Vk::DeviceFeatures +6. For every new `*Feature` structure, expand the @ref Vk::DeviceFeatures enum according to @ref developers-vk-features -8. Add a table listing the new version and all new extensions in it to +7. Add new extensions to the general list in `doc/vulkan-support.dox`, again + matching the order in `Extensions.h` --- grouped by prefix, but then + ordered by extension number + +In order to remove Vulkan functionality, be sure to touch all places mentioned +above, only in inverse --- but usually @ref developers-deprecation "deprecate first", +unless it doesn't affect public API at all. + +@see @ref developers-vk-versions, @ref developers-gl-extensions + +@section developers-vk-versions Checklist for adding / removing Vulkan versions + +1. Add new version enum value: + - to `src/Magnum/Vk/Version.h` + - to the list in `src/Magnum/Vk/vk-info.cpp` + - to @cpp Vk::InstanceExtension::extensions() @ce and + @cpp Vk::Extension::extensions() @ce in `src/Magnum/Vk/Extensions.cpp` +2. Update existing extensions with version in which they became core (last + parameter of the `_extension()` macro) +3. Continue with @ref developers-vk-extensions for all extensions that were + added by the new version and were not already present +4. For all existing extensions APIs that lose their suffix in the new version, + update doc references to be without the suffix +5. Add a table listing the new version and all new extensions in it to `doc/vulkan-support.dox` (take a list of them from the changelog in the - official spec PDF). Some extensions might be already present in the general + official spec). Some extensions might be already present in the general extension list, move them out of there. -9. Add a new `requires-vkXY` page with @c \@m_footernavigation to +6. Add a new `requires-vkXY` page with @c \@m_footernavigation to `doc/vulkan-support.dox`, mention it as a @c \@subpage at a correct position in the list -10. Add a new `requires-vkXY` alias to `Doxyfile`, `Doxyfile-mcss` and +7. Add a new `requires-vkXY` alias to `Doxyfile`, `Doxyfile-mcss` and `Doxyfile-public`, copypaste it from existing and change the numbers -11. Add new version enum value: - - to `src/Magnum/Vk/Version.h` - - to the list in `src/Magnum/Vk/vk-info.cpp` - - to @ref Vk::InstanceExtension::extensions() and - @ref Vk::Extension::extensions() in `src/Magnum/Vk/Extensions.cpp` In order to remove Vulkan functionality, be sure to touch all places mentioned above, only in inverse --- but usually @ref developers-deprecation "deprecate first", unless it doesn't affect public API at all. +@see @ref developers-gl-versions + @section developers-vk-functionality Checklist for adding / removing Vulkan functionality @todoc adapt from the GL section diff --git a/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt b/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt index 1c9250f82..cb8ccd371 100644 --- a/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt +++ b/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt @@ -6,6 +6,7 @@ version 2.0 es extraspec https://raw.githubusercontent.com/google/angle/master/scripts/gl_angle_ext.xml +# WebGL 1 only extensions extension ANGLE_instanced_arrays optional extension EXT_color_buffer_half_float optional extension EXT_sRGB optional @@ -23,6 +24,7 @@ extension OES_fbo_render_mipmap optional extension ANGLE_depth_texture optional extension EXT_draw_buffers optional +# WebGL 1 and 2 extensions extension EXT_texture_filter_anisotropic optional extension EXT_disjoint_timer_query optional extension EXT_texture_compression_rgtc optional @@ -36,7 +38,7 @@ extension KHR_texture_compression_astc_ldr optional # WEBGL_blend_equation_advanced_coherent includes just the enums but not the # barrier -extension KHR_blend_equation_advanced optional +extension KHR_blend_equation_advanced optional # From the gl_angle_ext file, base for WEBGL_multi_draw extension ANGLE_multi_draw optional diff --git a/src/MagnumExternal/OpenGL/GLES2/extensions.txt b/src/MagnumExternal/OpenGL/GLES2/extensions.txt index fff42a6ef..11e43e78a 100644 --- a/src/MagnumExternal/OpenGL/GLES2/extensions.txt +++ b/src/MagnumExternal/OpenGL/GLES2/extensions.txt @@ -6,6 +6,7 @@ version 2.0 es extraspec https://raw.githubusercontent.com/google/angle/master/scripts/gl_angle_ext.xml +# ES2-only extensions extension ANGLE_framebuffer_blit optional extension ANGLE_framebuffer_multisample optional extension ANGLE_instanced_arrays optional From 74f1778759d226fc3464f6adb045f370f4c14206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 12 Jul 2022 13:04:25 +0200 Subject: [PATCH 12/14] GL: recognize KHR_parallel_shader_compile on GL, GLES and WebGL. --- doc/changelog.dox | 7 +++++-- doc/opengl-mapping.dox | 1 + doc/opengl-support.dox | 3 +++ src/Magnum/GL/Context.cpp | 3 +++ src/Magnum/GL/Extensions.h | 6 +++++- src/MagnumExternal/OpenGL/GL/extensions.txt | 1 + src/MagnumExternal/OpenGL/GL/flextGL.cpp | 3 +++ src/MagnumExternal/OpenGL/GL/flextGL.h | 13 +++++++++++++ src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp | 3 +++ .../OpenGL/GLES2/Emscripten/extensions.txt | 6 ++++++ src/MagnumExternal/OpenGL/GLES2/extensions.txt | 1 + src/MagnumExternal/OpenGL/GLES2/flextGL.h | 13 +++++++++++++ src/MagnumExternal/OpenGL/GLES2/flextGLEmscripten.h | 5 +++++ src/MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp | 3 +++ .../OpenGL/GLES2/flextGLPlatformIOS.cpp | 6 ++++++ .../OpenGL/GLES2/flextGLPlatformWindowsDesktop.cpp | 3 +++ .../OpenGL/GLES2/flextGLWindowsDesktop.h | 13 +++++++++++++ .../OpenGL/GLES3/Emscripten/extensions.txt | 6 ++++++ src/MagnumExternal/OpenGL/GLES3/extensions.txt | 1 + src/MagnumExternal/OpenGL/GLES3/flextGL.h | 13 +++++++++++++ src/MagnumExternal/OpenGL/GLES3/flextGLEmscripten.h | 5 +++++ src/MagnumExternal/OpenGL/GLES3/flextGLPlatform.cpp | 3 +++ .../OpenGL/GLES3/flextGLPlatformIOS.cpp | 6 ++++++ .../OpenGL/GLES3/flextGLPlatformWindowsDesktop.cpp | 3 +++ .../OpenGL/GLES3/flextGLWindowsDesktop.h | 13 +++++++++++++ 25 files changed, 137 insertions(+), 3 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 9b44637b3..50e188a76 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -108,8 +108,11 @@ See also: resulted in a new @cpp "firefox-deprecated-debug-renderer-info" @ce workaround being added, see @ref opengl-workarounds for more info. - Recognizing @webgl_extension{EXT,float_blend} and - @webgl_extension{WEBGL,debug_shaders} extensions, no implementation done - yet + @webgl_extension{WEBGL,debug_shaders} WebGL extensions, no implementation + done yet +- Recognizing @gl_extension{KHR,parallel_shader_compile} GL, GLES and + @webgl_extension{KHR,parallel_shader_compile} WebGL extensions, no + implementation done yet - Recognizing ANGLE GLES and WebGL base vertex, base instance and multi-draw extensions and using them in @ref GL::AbstractShaderProgram::draw(Mesh&) and @ref GL::AbstractShaderProgram::draw(Containers::ArrayView>): diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index 2b9d03527..2d0dbe60e 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -290,6 +290,7 @@ OpenGL function | Matching API @fn_gl_extension{MakeTextureHandleResident,ARB,bindless_texture} | | @fn_gl_extension{MakeTextureHandleNonResident,ARB,bindless_texture} | | @fn_gl{MapBuffer}, \n `glMapNamedBuffer()`, \n @fn_gl{MapBufferRange}, \n `glMapNamedBufferRange()`, \n @fn_gl{UnmapBuffer}, \n `glUnmapNamedBuffer()` | @ref GL::Buffer::map(), @ref GL::Buffer::unmap() +@fn_gl_extension{MaxShaderCompilerThreads,KHR,parallel_shader_compile} | | @fn_gl{MemoryBarrier}, \n `glMemoryBarrierByRegion()` | @ref GL::Renderer::setMemoryBarrier(), \n @ref GL::Renderer::setMemoryBarrierByRegion() @fn_gl{MinSampleShading} | @ref GL::Renderer::setMinSampleShading() @fn_gl{MultiDrawArrays}, \n @fn_gl{MultiDrawElements}, \n @fn_gl{MultiDrawElementsBaseVertex} | @ref GL::AbstractShaderProgram::draw(Containers::ArrayView>) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 1eeaa9c4a..cf85a07b6 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -297,6 +297,7 @@ Extension | Status @gl_extension{KHR,blend_equation_advanced} | done @gl_extension2{KHR,blend_equation_advanced_coherent,KHR_blend_equation_advanced} | done @gl_extension{KHR,texture_compression_astc_sliced_3d} | done (nothing to do) +@gl_extension{KHR,parallel_shader_compile} | | @subsection opengl-support-extensions-vendor Vendor OpenGL extensions @@ -489,6 +490,7 @@ Extension | Status @gl_extension{KHR,context_flush_control} | | @gl_extension{KHR,no_error} | done @gl_extension{KHR,texture_compression_astc_sliced_3d} | done (nothing to do) +@gl_extension{KHR,parallel_shader_compile} | | @gl_extension2{NV,read_buffer_front,NV_read_buffer} | done @gl_extension2{NV,read_depth,NV_read_depth_stencil} | done @gl_extension2{NV,read_stencil,NV_read_depth_stencil} | done @@ -564,6 +566,7 @@ Extension | Status @webgl_extension{EXT,clip_cull_distance} | done @webgl_extension{EXT,texture_norm16} | done @webgl_extension{EXT,draw_buffers_indexed} | done +@webgl_extension{KHR,parallel_shader_compile} | | @webgl_extension{OES,texture_float_linear} | done @webgl_extension{OVR,multiview2} | | @webgl_extension{WEBGL,lose_context} | | diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index 7f8835403..a9ae98e2c 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -104,6 +104,7 @@ constexpr Extension ExtensionList[]{ Extensions::GREMEDY::string_marker{}, Extensions::KHR::blend_equation_advanced{}, Extensions::KHR::blend_equation_advanced_coherent{}, + Extensions::KHR::parallel_shader_compile{}, Extensions::KHR::texture_compression_astc_hdr{}, Extensions::KHR::texture_compression_astc_ldr{}, Extensions::KHR::texture_compression_astc_sliced_3d{}, @@ -290,6 +291,7 @@ constexpr Extension ExtensionList[]{ #ifndef MAGNUM_TARGET_GLES2 Extensions::EXT::texture_norm16{}, #endif + Extensions::KHR::parallel_shader_compile{}, Extensions::OES::texture_float_linear{}, #ifndef MAGNUM_TARGET_GLES2 Extensions::OVR::multiview2{}, @@ -394,6 +396,7 @@ constexpr Extension ExtensionList[]{ Extensions::KHR::blend_equation_advanced_coherent{}, Extensions::KHR::context_flush_control{}, Extensions::KHR::no_error{}, + Extensions::KHR::parallel_shader_compile{}, Extensions::KHR::texture_compression_astc_hdr{}, Extensions::KHR::texture_compression_astc_sliced_3d{}, #ifndef MAGNUM_TARGET_GLES2 diff --git a/src/Magnum/GL/Extensions.h b/src/Magnum/GL/Extensions.h index 11ec946b3..f0255e1f6 100644 --- a/src/Magnum/GL/Extensions.h +++ b/src/Magnum/GL/Extensions.h @@ -256,8 +256,9 @@ namespace AMD { _extension(167,KHR,blend_equation_advanced_coherent, GL210, None) // #174 _extension(168,KHR,no_error, GL210, GL460) // #175 _extension(169,KHR,texture_compression_astc_sliced_3d, GL210, None) // #189 + _extension(170,KHR,parallel_shader_compile, GL210, None) // #192 } namespace MAGNUM { - _extension(170,MAGNUM,shader_vertex_id, GL300, GL300) + _extension(171,MAGNUM,shader_vertex_id, GL300, GL300) } namespace NV { _extension(175,NV,primitive_restart, GL210, GL310) // #285 _extension(176,NV,depth_buffer_float, GL210, GL300) // #334 @@ -305,6 +306,8 @@ namespace ANGLE { #ifndef MAGNUM_TARGET_GLES2 _extension(16,EXT,draw_buffers_indexed, GLES300, None) // #45 #endif +} namespace KHR { + _extension(17,KHR,parallel_shader_compile, GLES200, None) // #37 } namespace OES { #ifdef MAGNUM_TARGET_GLES2 _extension(20,OES,texture_float, GLES200, GLES300) // #1 @@ -488,6 +491,7 @@ namespace ANDROID { _extension( 87,KHR,context_flush_control, GLES200, None) // #191 _extension( 88,KHR,no_error, GLES200, None) // #243 _extension( 89,KHR,texture_compression_astc_sliced_3d, GLES200, None) // #249 + _extension( 90,KHR,parallel_shader_compile, GLES200, None) // #288 } namespace NV { #ifdef MAGNUM_TARGET_GLES2 _extension(100,NV,draw_buffers, GLES200, GLES300) // #91 diff --git a/src/MagnumExternal/OpenGL/GL/extensions.txt b/src/MagnumExternal/OpenGL/GL/extensions.txt index cb8f6593f..b48691380 100644 --- a/src/MagnumExternal/OpenGL/GL/extensions.txt +++ b/src/MagnumExternal/OpenGL/GL/extensions.txt @@ -41,6 +41,7 @@ extension KHR_texture_compression_astc_ldr optional extension KHR_blend_equation_advanced optional extension KHR_blend_equation_advanced_coherent optional # extension KHR_texture_compression_astc_sliced_3d optional +extension KHR_parallel_shader_compile optional extension NV_sample_locations optional extension NV_fragment_shader_barycentric optional extension OVR_multiview optional diff --git a/src/MagnumExternal/OpenGL/GL/flextGL.cpp b/src/MagnumExternal/OpenGL/GL/flextGL.cpp index 1ad0e42b8..d289c4428 100644 --- a/src/MagnumExternal/OpenGL/GL/flextGL.cpp +++ b/src/MagnumExternal/OpenGL/GL/flextGL.cpp @@ -222,6 +222,9 @@ FlextGL flextGL{ /* GL_KHR_blend_equation_advanced */ nullptr, + /* GL_KHR_parallel_shader_compile */ + nullptr, + /* GL_NV_sample_locations */ nullptr, nullptr, diff --git a/src/MagnumExternal/OpenGL/GL/flextGL.h b/src/MagnumExternal/OpenGL/GL/flextGL.h index f2f2bc72e..d11cc1880 100644 --- a/src/MagnumExternal/OpenGL/GL/flextGL.h +++ b/src/MagnumExternal/OpenGL/GL/flextGL.h @@ -1773,6 +1773,11 @@ typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum #define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +/* GL_KHR_parallel_shader_compile */ + +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 + /* GL_NV_sample_locations */ #define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D @@ -1876,6 +1881,10 @@ struct FlextGL { void(APIENTRY *BlendBarrierKHR)(void); + /* GL_KHR_parallel_shader_compile */ + + void(APIENTRY *MaxShaderCompilerThreadsKHR)(GLuint); + /* GL_NV_sample_locations */ void(APIENTRY *FramebufferSampleLocationsfvNV)(GLenum, GLuint, GLsizei, const GLfloat *); @@ -2680,6 +2689,10 @@ extern FLEXTGL_EXPORT FlextGL flextGL; #define glBlendBarrierKHR flextGL.BlendBarrierKHR +/* GL_KHR_parallel_shader_compile */ + +#define glMaxShaderCompilerThreadsKHR flextGL.MaxShaderCompilerThreadsKHR + /* GL_NV_sample_locations */ #define glFramebufferSampleLocationsfvNV flextGL.FramebufferSampleLocationsfvNV diff --git a/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp b/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp index f95454ebb..46da39b00 100644 --- a/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp +++ b/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp @@ -186,6 +186,9 @@ void flextGLInit(Magnum::GL::Context& context) { /* GL_KHR_blend_equation_advanced */ flextGL.BlendBarrierKHR = reinterpret_cast(loader.load("glBlendBarrierKHR")); + /* GL_KHR_parallel_shader_compile */ + flextGL.MaxShaderCompilerThreadsKHR = reinterpret_cast(loader.load("glMaxShaderCompilerThreadsKHR")); + /* GL_NV_sample_locations */ flextGL.FramebufferSampleLocationsfvNV = reinterpret_cast(loader.load("glFramebufferSampleLocationsfvNV")); flextGL.NamedFramebufferSampleLocationsfvNV = reinterpret_cast(loader.load("glNamedFramebufferSampleLocationsfvNV")); diff --git a/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt b/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt index cb8ccd371..31cb7bb1b 100644 --- a/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt +++ b/src/MagnumExternal/OpenGL/GLES2/Emscripten/extensions.txt @@ -40,6 +40,10 @@ extension KHR_texture_compression_astc_ldr optional # barrier extension KHR_blend_equation_advanced optional +# KHR_parallel_shader_compile includes just GL_COMPLETION_STATUS_KHR and not +# the max threads setting +extension KHR_parallel_shader_compile optional + # From the gl_angle_ext file, base for WEBGL_multi_draw extension ANGLE_multi_draw optional # Base for WEBGL_{multi_,}draw_instanced_base_vertex_base_instance @@ -52,6 +56,8 @@ extension ANGLE_base_vertex_base_instance optional begin functions blacklist # Not present in WEBGL_blend_equation_advanced_coherent BlendBarrierKHR + # Not present in WebGL variant of KHR_parallel_shader_compile + MaxShaderCompilerThreadsKHR end functions blacklist # kate: hl python diff --git a/src/MagnumExternal/OpenGL/GLES2/extensions.txt b/src/MagnumExternal/OpenGL/GLES2/extensions.txt index 11e43e78a..f95b2a0f4 100644 --- a/src/MagnumExternal/OpenGL/GLES2/extensions.txt +++ b/src/MagnumExternal/OpenGL/GLES2/extensions.txt @@ -99,6 +99,7 @@ extension KHR_blend_equation_advanced_coherent optional extension KHR_context_flush_control optional extension KHR_no_error optional # extension KHR_texture_compression_astc_sliced_3d optional +extension KHR_parallel_shader_compile optional extension NV_read_buffer_front optional extension NV_read_depth optional extension NV_read_stencil optional diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGL.h b/src/MagnumExternal/OpenGL/GLES2/flextGL.h index 5b24d7ccc..ad7a639df 100644 --- a/src/MagnumExternal/OpenGL/GLES2/flextGL.h +++ b/src/MagnumExternal/OpenGL/GLES2/flextGL.h @@ -1019,6 +1019,11 @@ typedef void (APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLen #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +/* GL_KHR_parallel_shader_compile */ + +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 + /* GL_NV_texture_border_clamp */ #define GL_TEXTURE_BORDER_COLOR_NV 0x1004 @@ -1393,6 +1398,10 @@ struct FlextGL { void(APIENTRY *PopDebugGroupKHR)(void); void(APIENTRY *PushDebugGroupKHR)(GLenum, GLuint, GLsizei, const GLchar *); + /* GL_KHR_parallel_shader_compile */ + + void(APIENTRY *MaxShaderCompilerThreadsKHR)(GLuint); + /* GL_KHR_robustness */ GLenum(APIENTRY *GetGraphicsResetStatusKHR)(void); @@ -1643,6 +1652,10 @@ extern FLEXTGL_EXPORT FlextGL flextGL; #define glPopDebugGroupKHR flextGL.PopDebugGroupKHR #define glPushDebugGroupKHR flextGL.PushDebugGroupKHR +/* GL_KHR_parallel_shader_compile */ + +#define glMaxShaderCompilerThreadsKHR flextGL.MaxShaderCompilerThreadsKHR + /* GL_KHR_robustness */ #define glGetGraphicsResetStatusKHR flextGL.GetGraphicsResetStatusKHR diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGLEmscripten.h b/src/MagnumExternal/OpenGL/GLES2/flextGLEmscripten.h index cad27e2b0..37ac07123 100644 --- a/src/MagnumExternal/OpenGL/GLES2/flextGLEmscripten.h +++ b/src/MagnumExternal/OpenGL/GLES2/flextGLEmscripten.h @@ -576,6 +576,11 @@ typedef khronos_uint64_t GLuint64; #define GL_HSL_COLOR_KHR 0x92AF #define GL_HSL_LUMINOSITY_KHR 0x92B0 +/* GL_KHR_parallel_shader_compile */ + +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 + /* Function prototypes */ /* GL_ANGLE_base_vertex_base_instance */ diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp b/src/MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp index b6c9e75c3..b1cad512f 100644 --- a/src/MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp +++ b/src/MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp @@ -187,6 +187,9 @@ void flextGLInit(Magnum::GL::Context&) { flextGL.PopDebugGroupKHR = reinterpret_cast(loader.load("glPopDebugGroupKHR")); flextGL.PushDebugGroupKHR = reinterpret_cast(loader.load("glPushDebugGroupKHR")); + /* GL_KHR_parallel_shader_compile */ + flextGL.MaxShaderCompilerThreadsKHR = reinterpret_cast(loader.load("glMaxShaderCompilerThreadsKHR")); + /* GL_KHR_robustness */ flextGL.GetGraphicsResetStatusKHR = reinterpret_cast(loader.load("glGetGraphicsResetStatusKHR")); flextGL.GetnUniformfvKHR = reinterpret_cast(loader.load("glGetnUniformfvKHR")); diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformIOS.cpp b/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformIOS.cpp index a5d27abd9..83152cd05 100644 --- a/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformIOS.cpp +++ b/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformIOS.cpp @@ -131,6 +131,7 @@ #undef glObjectPtrLabelKHR #undef glPopDebugGroupKHR #undef glPushDebugGroupKHR +#undef glMaxShaderCompilerThreadsKHR #undef glGetGraphicsResetStatusKHR #undef glGetnUniformfvKHR #undef glGetnUniformivKHR @@ -372,6 +373,11 @@ void flextGLInit(Magnum::GL::Context&) { flextGL.PushDebugGroupKHR = reinterpret_cast(glPushDebugGroupKHR); #endif + /* GL_KHR_parallel_shader_compile */ + #if GL_KHR_parallel_shader_compile + flextGL.MaxShaderCompilerThreadsKHR = reinterpret_cast(glMaxShaderCompilerThreadsKHR); + #endif + /* GL_KHR_robustness */ #if GL_KHR_robustness flextGL.GetGraphicsResetStatusKHR = reinterpret_cast(glGetGraphicsResetStatusKHR); diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformWindowsDesktop.cpp b/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformWindowsDesktop.cpp index 43806c227..81f64cac9 100644 --- a/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformWindowsDesktop.cpp +++ b/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformWindowsDesktop.cpp @@ -286,6 +286,9 @@ void flextGLInit(Magnum::GL::Context&) { flextGL.PopDebugGroupKHR = reinterpret_cast(loader.load("glPopDebugGroupKHR")); flextGL.PushDebugGroupKHR = reinterpret_cast(loader.load("glPushDebugGroupKHR")); + /* GL_KHR_parallel_shader_compile */ + flextGL.MaxShaderCompilerThreadsKHR = reinterpret_cast(loader.load("glMaxShaderCompilerThreadsKHR")); + /* GL_KHR_robustness */ flextGL.GetGraphicsResetStatusKHR = reinterpret_cast(loader.load("glGetGraphicsResetStatusKHR")); flextGL.GetnUniformfvKHR = reinterpret_cast(loader.load("glGetnUniformfvKHR")); diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGLWindowsDesktop.h b/src/MagnumExternal/OpenGL/GLES2/flextGLWindowsDesktop.h index a245c1844..fe9a05fa2 100644 --- a/src/MagnumExternal/OpenGL/GLES2/flextGLWindowsDesktop.h +++ b/src/MagnumExternal/OpenGL/GLES2/flextGLWindowsDesktop.h @@ -1015,6 +1015,11 @@ typedef void (APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLen #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +/* GL_KHR_parallel_shader_compile */ + +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 + /* GL_NV_texture_border_clamp */ #define GL_TEXTURE_BORDER_COLOR_NV 0x1004 @@ -1393,6 +1398,10 @@ struct FlextGL { void(APIENTRY *PopDebugGroupKHR)(void); void(APIENTRY *PushDebugGroupKHR)(GLenum, GLuint, GLsizei, const GLchar *); + /* GL_KHR_parallel_shader_compile */ + + void(APIENTRY *MaxShaderCompilerThreadsKHR)(GLuint); + /* GL_KHR_robustness */ GLenum(APIENTRY *GetGraphicsResetStatusKHR)(void); @@ -1743,6 +1752,10 @@ extern FLEXTGL_EXPORT FlextGL flextGL; #define glPopDebugGroupKHR flextGL.PopDebugGroupKHR #define glPushDebugGroupKHR flextGL.PushDebugGroupKHR +/* GL_KHR_parallel_shader_compile */ + +#define glMaxShaderCompilerThreadsKHR flextGL.MaxShaderCompilerThreadsKHR + /* GL_KHR_robustness */ #define glGetGraphicsResetStatusKHR flextGL.GetGraphicsResetStatusKHR diff --git a/src/MagnumExternal/OpenGL/GLES3/Emscripten/extensions.txt b/src/MagnumExternal/OpenGL/GLES3/Emscripten/extensions.txt index 41d4d1ba9..3727199cc 100644 --- a/src/MagnumExternal/OpenGL/GLES3/Emscripten/extensions.txt +++ b/src/MagnumExternal/OpenGL/GLES3/Emscripten/extensions.txt @@ -29,6 +29,10 @@ extension KHR_texture_compression_astc_ldr optional # barrier extension KHR_blend_equation_advanced optional +# KHR_parallel_shader_compile includes just GL_COMPLETION_STATUS_KHR and not +# the max threads setting +extension KHR_parallel_shader_compile optional + # From the gl_angle_ext file, base for WEBGL_multi_draw etc extension ANGLE_multi_draw optional extension ANGLE_base_vertex_base_instance optional @@ -41,6 +45,8 @@ extension MAGNUM_what_webgl_has_but_es_not optional begin functions blacklist # Not present in WEBGL_blend_equation_advanced_coherent BlendBarrierKHR + # Not present in WebGL variant of KHR_parallel_shader_compile + MaxShaderCompilerThreadsKHR end functions blacklist # kate: hl python diff --git a/src/MagnumExternal/OpenGL/GLES3/extensions.txt b/src/MagnumExternal/OpenGL/GLES3/extensions.txt index a18dada00..32a066bd2 100644 --- a/src/MagnumExternal/OpenGL/GLES3/extensions.txt +++ b/src/MagnumExternal/OpenGL/GLES3/extensions.txt @@ -73,6 +73,7 @@ extension KHR_blend_equation_advanced_coherent optional extension KHR_context_flush_control optional extension KHR_no_error optional # extension KHR_texture_compression_astc_sliced_3d optional +extension KHR_parallel_shader_compile optional extension NV_read_buffer_front optional extension NV_read_depth optional extension NV_read_stencil optional diff --git a/src/MagnumExternal/OpenGL/GLES3/flextGL.h b/src/MagnumExternal/OpenGL/GLES3/flextGL.h index 9cae0d86a..7aeabd6ac 100644 --- a/src/MagnumExternal/OpenGL/GLES3/flextGL.h +++ b/src/MagnumExternal/OpenGL/GLES3/flextGL.h @@ -1634,6 +1634,11 @@ typedef void (APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLen #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +/* GL_KHR_parallel_shader_compile */ + +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 + /* GL_NV_texture_border_clamp */ #define GL_TEXTURE_BORDER_COLOR_NV 0x1004 @@ -2238,6 +2243,10 @@ struct FlextGL { void(APIENTRY *PopDebugGroupKHR)(void); void(APIENTRY *PushDebugGroupKHR)(GLenum, GLuint, GLsizei, const GLchar *); + /* GL_KHR_parallel_shader_compile */ + + void(APIENTRY *MaxShaderCompilerThreadsKHR)(GLuint); + /* GL_KHR_robustness */ GLenum(APIENTRY *GetGraphicsResetStatusKHR)(void); @@ -2577,6 +2586,10 @@ extern FLEXTGL_EXPORT FlextGL flextGL; #define glPopDebugGroupKHR flextGL.PopDebugGroupKHR #define glPushDebugGroupKHR flextGL.PushDebugGroupKHR +/* GL_KHR_parallel_shader_compile */ + +#define glMaxShaderCompilerThreadsKHR flextGL.MaxShaderCompilerThreadsKHR + /* GL_KHR_robustness */ #define glGetGraphicsResetStatusKHR flextGL.GetGraphicsResetStatusKHR diff --git a/src/MagnumExternal/OpenGL/GLES3/flextGLEmscripten.h b/src/MagnumExternal/OpenGL/GLES3/flextGLEmscripten.h index cb3afe11b..d7fc39281 100644 --- a/src/MagnumExternal/OpenGL/GLES3/flextGLEmscripten.h +++ b/src/MagnumExternal/OpenGL/GLES3/flextGLEmscripten.h @@ -879,6 +879,11 @@ typedef struct __GLsync *GLsync; #define GL_HSL_COLOR_KHR 0x92AF #define GL_HSL_LUMINOSITY_KHR 0x92B0 +/* GL_KHR_parallel_shader_compile */ + +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 + /* Function prototypes */ /* GL_ANGLE_base_vertex_base_instance */ diff --git a/src/MagnumExternal/OpenGL/GLES3/flextGLPlatform.cpp b/src/MagnumExternal/OpenGL/GLES3/flextGLPlatform.cpp index e19832b11..cd13791b1 100644 --- a/src/MagnumExternal/OpenGL/GLES3/flextGLPlatform.cpp +++ b/src/MagnumExternal/OpenGL/GLES3/flextGLPlatform.cpp @@ -305,6 +305,9 @@ void flextGLInit(Magnum::GL::Context&) { flextGL.PopDebugGroupKHR = reinterpret_cast(loader.load("glPopDebugGroupKHR")); flextGL.PushDebugGroupKHR = reinterpret_cast(loader.load("glPushDebugGroupKHR")); + /* GL_KHR_parallel_shader_compile */ + flextGL.MaxShaderCompilerThreadsKHR = reinterpret_cast(loader.load("glMaxShaderCompilerThreadsKHR")); + /* GL_KHR_robustness */ flextGL.GetGraphicsResetStatusKHR = reinterpret_cast(loader.load("glGetGraphicsResetStatusKHR")); flextGL.GetnUniformfvKHR = reinterpret_cast(loader.load("glGetnUniformfvKHR")); diff --git a/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformIOS.cpp b/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformIOS.cpp index 81cc5911b..64ee4375e 100644 --- a/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformIOS.cpp +++ b/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformIOS.cpp @@ -141,6 +141,7 @@ #undef glObjectPtrLabelKHR #undef glPopDebugGroupKHR #undef glPushDebugGroupKHR +#undef glMaxShaderCompilerThreadsKHR #undef glGetGraphicsResetStatusKHR #undef glGetnUniformfvKHR #undef glGetnUniformivKHR @@ -361,6 +362,11 @@ void flextGLInit(Magnum::GL::Context&) { flextGL.PushDebugGroupKHR = reinterpret_cast(glPushDebugGroupKHR); #endif + /* GL_KHR_parallel_shader_compile */ + #if GL_KHR_parallel_shader_compile + flextGL.MaxShaderCompilerThreadsKHR = reinterpret_cast(glMaxShaderCompilerThreadsKHR); + #endif + /* GL_KHR_robustness */ #if GL_KHR_robustness flextGL.GetGraphicsResetStatusKHR = reinterpret_cast(glGetGraphicsResetStatusKHR); diff --git a/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformWindowsDesktop.cpp b/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformWindowsDesktop.cpp index 6c8a520a1..3dceb07db 100644 --- a/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformWindowsDesktop.cpp +++ b/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformWindowsDesktop.cpp @@ -507,6 +507,9 @@ void flextGLInit(Magnum::GL::Context&) { flextGL.PopDebugGroupKHR = reinterpret_cast(loader.load("glPopDebugGroupKHR")); flextGL.PushDebugGroupKHR = reinterpret_cast(loader.load("glPushDebugGroupKHR")); + /* GL_KHR_parallel_shader_compile */ + flextGL.MaxShaderCompilerThreadsKHR = reinterpret_cast(loader.load("glMaxShaderCompilerThreadsKHR")); + /* GL_KHR_robustness */ flextGL.GetGraphicsResetStatusKHR = reinterpret_cast(loader.load("glGetGraphicsResetStatusKHR")); flextGL.GetnUniformfvKHR = reinterpret_cast(loader.load("glGetnUniformfvKHR")); diff --git a/src/MagnumExternal/OpenGL/GLES3/flextGLWindowsDesktop.h b/src/MagnumExternal/OpenGL/GLES3/flextGLWindowsDesktop.h index 12adf192c..2ad781e50 100644 --- a/src/MagnumExternal/OpenGL/GLES3/flextGLWindowsDesktop.h +++ b/src/MagnumExternal/OpenGL/GLES3/flextGLWindowsDesktop.h @@ -1627,6 +1627,11 @@ typedef void (APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLen #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +/* GL_KHR_parallel_shader_compile */ + +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 + /* GL_NV_texture_border_clamp */ #define GL_TEXTURE_BORDER_COLOR_NV 0x1004 @@ -2242,6 +2247,10 @@ struct FlextGL { void(APIENTRY *PopDebugGroupKHR)(void); void(APIENTRY *PushDebugGroupKHR)(GLenum, GLuint, GLsizei, const GLchar *); + /* GL_KHR_parallel_shader_compile */ + + void(APIENTRY *MaxShaderCompilerThreadsKHR)(GLuint); + /* GL_KHR_robustness */ GLenum(APIENTRY *GetGraphicsResetStatusKHR)(void); @@ -2785,6 +2794,10 @@ extern FLEXTGL_EXPORT FlextGL flextGL; #define glPopDebugGroupKHR flextGL.PopDebugGroupKHR #define glPushDebugGroupKHR flextGL.PushDebugGroupKHR +/* GL_KHR_parallel_shader_compile */ + +#define glMaxShaderCompilerThreadsKHR flextGL.MaxShaderCompilerThreadsKHR + /* GL_KHR_robustness */ #define glGetGraphicsResetStatusKHR flextGL.GetGraphicsResetStatusKHR From d12b675e6297dd04af23cde6414514270dcf57c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 12 Jul 2022 13:37:54 +0200 Subject: [PATCH 13/14] GL: implement packed debug output for Context::Flags and DetectedDrivers. --- src/Magnum/GL/Context.cpp | 22 ++++++---- src/Magnum/GL/Test/ContextTest.cpp | 68 +++++++++++++++++++++++++++--- 2 files changed, 75 insertions(+), 15 deletions(-) diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index a9ae98e2c..58de84b38 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -1284,11 +1284,14 @@ Context::Configuration& Context::Configuration::addDisabledExtensions(std::initi #ifndef DOXYGEN_GENERATING_OUTPUT #ifndef MAGNUM_TARGET_WEBGL Debug& operator<<(Debug& debug, const Context::Flag value) { - debug << "GL::Context::Flag" << Debug::nospace; + const bool packed = debug.immediateFlags() >= Debug::Flag::Packed; + + if(!packed) + debug << "GL::Context::Flag" << Debug::nospace; switch(value) { /* LCOV_EXCL_START */ - #define _c(value) case Context::Flag::value: return debug << "::" #value; + #define _c(value) case Context::Flag::value: return debug << (packed ? "" : "::") << Debug::nospace << #value; _c(Debug) #ifndef MAGNUM_TARGET_GLES _c(ForwardCompatible) @@ -1301,11 +1304,11 @@ Debug& operator<<(Debug& debug, const Context::Flag value) { /* LCOV_EXCL_STOP */ } - return debug << "(" << Debug::nospace << reinterpret_cast(GLint(value)) << Debug::nospace << ")"; + return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast(GLint(value)) << Debug::nospace << (packed ? "" : ")"); } Debug& operator<<(Debug& debug, const Context::Flags value) { - return Containers::enumSetDebugOutput(debug, value, "GL::Context::Flags{}", { + return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "GL::Context::Flags{}", { Context::Flag::Debug, #ifndef MAGNUM_TARGET_GLES Context::Flag::ForwardCompatible, @@ -1319,11 +1322,14 @@ Debug& operator<<(Debug& debug, const Context::Flags value) { #endif Debug& operator<<(Debug& debug, const Context::DetectedDriver value) { - debug << "GL::Context::DetectedDriver" << Debug::nospace; + const bool packed = debug.immediateFlags() >= Debug::Flag::Packed; + + if(!packed) + debug << "GL::Context::DetectedDriver" << Debug::nospace; switch(value) { /* LCOV_EXCL_START */ - #define _c(value) case Context::DetectedDriver::value: return debug << "::" #value; + #define _c(value) case Context::DetectedDriver::value: return debug << (packed ? "" : "::") << Debug::nospace << #value; _c(Amd) #ifdef MAGNUM_TARGET_GLES _c(Angle) @@ -1342,11 +1348,11 @@ Debug& operator<<(Debug& debug, const Context::DetectedDriver value) { /* LCOV_EXCL_STOP */ } - return debug << "(" << Debug::nospace << reinterpret_cast(GLint(value)) << Debug::nospace << ")"; + return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast(GLint(value)) << Debug::nospace << (packed ? "" : ")"); } Debug& operator<<(Debug& debug, const Context::DetectedDrivers value) { - return Containers::enumSetDebugOutput(debug, value, "GL::Context::DetectedDrivers{}", { + return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "GL::Context::DetectedDrivers{}", { #ifndef MAGNUM_TARGET_WEBGL Context::DetectedDriver::Amd, #endif diff --git a/src/Magnum/GL/Test/ContextTest.cpp b/src/Magnum/GL/Test/ContextTest.cpp index eaa2afde1..c9070c4c3 100644 --- a/src/Magnum/GL/Test/ContextTest.cpp +++ b/src/Magnum/GL/Test/ContextTest.cpp @@ -56,10 +56,14 @@ struct ContextTest: TestSuite::Tester { void extensions(); void debugFlag(); + void debugFlagPacked(); void debugFlags(); + void debugFlagsPacked(); void debugDetectedDriver(); + void debugDetectedDriverPacked(); void debugDetectedDrivers(); + void debugDetectedDriversPacked(); }; ContextTest::ContextTest() { @@ -78,10 +82,14 @@ ContextTest::ContextTest() { &ContextTest::extensions, &ContextTest::debugFlag, + &ContextTest::debugFlagPacked, &ContextTest::debugFlags, + &ContextTest::debugFlagsPacked, &ContextTest::debugDetectedDriver, - &ContextTest::debugDetectedDrivers}); + &ContextTest::debugDetectedDriverPacked, + &ContextTest::debugDetectedDrivers, + &ContextTest::debugDetectedDriversPacked}); } void ContextTest::isExtension() { @@ -453,13 +461,35 @@ void ContextTest::debugFlag() { #endif } +void ContextTest::debugFlagPacked() { + #ifdef MAGNUM_TARGET_WEBGL + CORRADE_SKIP("No context flags on Emscripten yet."); + #else + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << Context::Flag::Debug << Debug::packed << Context::Flag(0xdead) << Context::Flag::NoError; + CORRADE_COMPARE(out.str(), "Debug 0xdead GL::Context::Flag::NoError\n"); + #endif +} + void ContextTest::debugFlags() { #ifdef MAGNUM_TARGET_WEBGL CORRADE_SKIP("No context flags on Emscripten yet."); #else std::ostringstream out; - Debug(&out) << Context::Flags{} << (Context::Flag::Debug|Context::Flag::NoError) << (Context::Flag::Debug|Context::Flag(0xded0)); - CORRADE_COMPARE(out.str(), "GL::Context::Flags{} GL::Context::Flag::Debug|GL::Context::Flag::NoError GL::Context::Flag::Debug|GL::Context::Flag(0xded0)\n"); + Debug{&out} << (Context::Flag::Debug|Context::Flag::NoError|Context::Flag(0xded0)) << Context::Flags{}; + CORRADE_COMPARE(out.str(), "GL::Context::Flag::Debug|GL::Context::Flag::NoError|GL::Context::Flag(0xded0) GL::Context::Flags{}\n"); + #endif +} + +void ContextTest::debugFlagsPacked() { + #ifdef MAGNUM_TARGET_WEBGL + CORRADE_SKIP("No context flags on Emscripten yet."); + #else + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << (Context::Flag::Debug|Context::Flag::NoError|Context::Flag(0xded0)) << Debug::packed << Context::Flags{} << (Context::Flag::Debug|Context::Flag::NoError); + CORRADE_COMPARE(out.str(), "Debug|NoError|0xded0 {} GL::Context::Flag::Debug|GL::Context::Flag::NoError\n"); #endif } @@ -474,14 +504,38 @@ void ContextTest::debugDetectedDriver() { #endif } +void ContextTest::debugDetectedDriverPacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + #ifndef MAGNUM_TARGET_WEBGL + Debug{&out} << Debug::packed << Context::DetectedDriver::Amd << Debug::packed << Context::DetectedDriver(0xdead) << Context::DetectedDriver::NVidia; + CORRADE_COMPARE(out.str(), "Amd 0xdead GL::Context::DetectedDriver::NVidia\n"); + #else + Debug{&out} << Debug::packed << Context::DetectedDriver::Angle << Debug::packed << Context::DetectedDriver(0xdead) << Context::DetectedDriver::Angle; + CORRADE_COMPARE(out.str(), "Angle 0xdead GL::Context::DetectedDriver::Angle\n"); + #endif +} + void ContextTest::debugDetectedDrivers() { std::ostringstream out; #ifndef MAGNUM_TARGET_WEBGL - Debug{&out} << Context::DetectedDrivers{} << (Context::DetectedDriver::Amd|Context::DetectedDriver::NVidia) << (Context::DetectedDriver::Mesa|Context::DetectedDriver(0xde00)); - CORRADE_COMPARE(out.str(), "GL::Context::DetectedDrivers{} GL::Context::DetectedDriver::Amd|GL::Context::DetectedDriver::NVidia GL::Context::DetectedDriver::Mesa|GL::Context::DetectedDriver(0xde00)\n"); + Debug{&out} << (Context::DetectedDriver::Amd|Context::DetectedDriver::Mesa|Context::DetectedDriver(0xde00)) << Context::DetectedDrivers{}; + CORRADE_COMPARE(out.str(), "GL::Context::DetectedDriver::Amd|GL::Context::DetectedDriver::Mesa|GL::Context::DetectedDriver(0xde00) GL::Context::DetectedDrivers{}\n"); + #else + Debug{&out} << (Context::DetectedDriver::Angle|Context::DetectedDriver(0xde00)) << Context::DetectedDrivers{}; + CORRADE_COMPARE(out.str(), "GL::Context::DetectedDriver::Angle|GL::Context::DetectedDriver(0xde00) GL::Context::DetectedDrivers{}\n"); + #endif +} + +void ContextTest::debugDetectedDriversPacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + #ifndef MAGNUM_TARGET_WEBGL + Debug{&out} << Debug::packed << (Context::DetectedDriver::Amd|Context::DetectedDriver::Mesa|Context::DetectedDriver(0xde00)) << Debug::packed << Context::DetectedDrivers{} << (Context::DetectedDriver::Amd|Context::DetectedDriver::Mesa); + CORRADE_COMPARE(out.str(), "Amd|Mesa|0xde00 {} GL::Context::DetectedDriver::Amd|GL::Context::DetectedDriver::Mesa\n"); #else - Debug{&out} << Context::DetectedDrivers{} << (Context::DetectedDriver::Angle) << (Context::DetectedDriver::Angle|Context::DetectedDriver(0xde00)); - CORRADE_COMPARE(out.str(), "GL::Context::DetectedDrivers{} GL::Context::DetectedDriver::Angle GL::Context::DetectedDriver::Angle|GL::Context::DetectedDriver(0xde00)\n"); + Debug{&out} << Debug::packed << (Context::DetectedDriver::Angle|Context::DetectedDriver(0xde00)) << Debug::packed << Context::DetectedDrivers{} << (Context::DetectedDriver::Angle|Context::DetectedDriver(0xde00)); + CORRADE_COMPARE(out.str(), "Angle|0xde00 {} GL::Context::DetectedDriver::Angle|GL::Context::DetectedDriver(0xde00)\n"); #endif } From 59a973c678ed669045765174aad66b09ce92e138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 12 Jul 2022 13:38:32 +0200 Subject: [PATCH 14/14] gl-info: print more compact driver and flags info. --- src/Magnum/Platform/gl-info.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Magnum/Platform/gl-info.cpp b/src/Magnum/Platform/gl-info.cpp index cd0d8534e..d0a317823 100644 --- a/src/Magnum/Platform/gl-info.cpp +++ b/src/Magnum/Platform/gl-info.cpp @@ -413,9 +413,9 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat Debug{} << "Core profile:" << (c.isCoreProfile() ? "yes" : "no"); #endif #ifndef MAGNUM_TARGET_WEBGL - Debug{} << "Context flags:" << c.flags(); + Debug{} << "Context flags:" << Debug::packed << c.flags(); #endif - Debug{} << "Detected driver:" << c.detectedDriver(); + Debug{} << "Detected driver:" << Debug::packed << c.detectedDriver(); Debug{} << "Supported GLSL versions:"; Debug{} << " " << ", "_s.joinWithoutEmptyParts(c.shadingLanguageVersionStrings());