diff --git a/doc/snippets/MagnumShaderTools.cpp b/doc/snippets/MagnumShaderTools.cpp index f900e9d01..2a2757bbc 100644 --- a/doc/snippets/MagnumShaderTools.cpp +++ b/doc/snippets/MagnumShaderTools.cpp @@ -31,6 +31,7 @@ #include "Magnum/FileCallback.h" #include "Magnum/ShaderTools/AbstractConverter.h" +#include "Magnum/ShaderTools/Stage.h" #define DOXYGEN_IGNORE(...) __VA_ARGS__ diff --git a/src/Magnum/ShaderTools/AbstractConverter.cpp b/src/Magnum/ShaderTools/AbstractConverter.cpp index 8a57fe8aa..0443bb7db 100644 --- a/src/Magnum/ShaderTools/AbstractConverter.cpp +++ b/src/Magnum/ShaderTools/AbstractConverter.cpp @@ -741,32 +741,4 @@ Debug& operator<<(Debug& debug, const Format value) { return debug << "(" << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << ")"; } -Debug& operator<<(Debug& debug, const Stage value) { - debug << "ShaderTools::Stage" << Debug::nospace; - - switch(value) { - /* LCOV_EXCL_START */ - #define _c(v) case Stage::v: return debug << "::" #v; - _c(Unspecified) - _c(Vertex) - _c(Fragment) - _c(Geometry) - _c(TessellationControl) - _c(TessellationEvaluation) - _c(Compute) - _c(RayGeneration) - _c(RayAnyHit) - _c(RayClosestHit) - _c(RayMiss) - _c(RayIntersection) - _c(RayCallable) - _c(MeshTask) - _c(Mesh) - #undef _c - /* LCOV_EXCL_STOP */ - } - - return debug << "(" << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << ")"; -} - }} diff --git a/src/Magnum/ShaderTools/AbstractConverter.h b/src/Magnum/ShaderTools/AbstractConverter.h index bd57a7451..5dd8b9694 100644 --- a/src/Magnum/ShaderTools/AbstractConverter.h +++ b/src/Magnum/ShaderTools/AbstractConverter.h @@ -26,7 +26,7 @@ */ /** @file - * @brief Class @ref Magnum::ShaderTools::AbstractConverter, enum @ref Magnum::ShaderTools::ConverterFeature, @ref Magnum::ShaderTools::ConverterFlag, @ref Magnum::ShaderTools::Format, @ref Magnum::ShaderTools::Stage, enum set @ref Magnum::ShaderTools::ConverterFeatures, @ref Magnum::ShaderTools::ConverterFlags + * @brief Class @ref Magnum::ShaderTools::AbstractConverter, enum @ref Magnum::ShaderTools::ConverterFeature, @ref Magnum::ShaderTools::ConverterFlag, @ref Magnum::ShaderTools::Format, enum set @ref Magnum::ShaderTools::ConverterFeatures, @ref Magnum::ShaderTools::ConverterFlags * @m_since_latest */ @@ -34,8 +34,13 @@ #include #include "Magnum/Magnum.h" +#include "Magnum/ShaderTools/ShaderTools.h" #include "Magnum/ShaderTools/visibility.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include "Magnum/ShaderTools/Stage.h" +#endif + namespace Magnum { namespace ShaderTools { /** @@ -264,55 +269,6 @@ enum class Format: UnsignedInt { */ MAGNUM_SHADERTOOLS_EXPORT Debug& operator<<(Debug& debug, Format value); -/** -@brief Shader stage -@m_since_latest - -@see @ref AbstractConverter -*/ -enum class Stage: UnsignedInt { - /** - * Unspecified stage. When used in the - * @ref AbstractConverter::validateFile(), - * @ref AbstractConverter::convertFileToFile() "convertFileToFile()", - * @ref AbstractConverter::convertFileToData() "convertFileToData()", - * @ref AbstractConverter::linkFilesToFile() "linkFilesToFile()" or - * @ref AbstractConverter::linkFilesToData() "linkFilesToData()" APIs, - * particular plugins may attempt to detect the stage from filename, the - * shader stage might also be encoded directly in certain - * @ref Format "Format"s. Leaving the stage unspecified might limit - * validation and conversion capabilities, see documentation of a - * particular converter for concrete behavior. - * - * This value is guaranteed to be @cpp 0 @ce, which means you're encouraged - * to simply use @cpp {} @ce in function calls and elsewhere. - */ - Unspecified = 0, - - Vertex, /**< Vertex stage */ - Fragment, /**< Fragment stage */ - Geometry, /**< Geometry stage */ - TessellationControl, /**< Tessellation control stage */ - TessellationEvaluation, /**< Tessellation evaluation stage */ - Compute, /**< Compute stage */ - - RayGeneration, /**< Ray generation stage */ - RayAnyHit, /**< Ray any hit stage */ - RayClosestHit, /**< Ray closest hit stage */ - RayMiss, /**< Ray miss stage */ - RayIntersection, /**< Ray intersection stage */ - RayCallable, /**< Ray callable stage */ - - MeshTask, /**< Mesh task stage */ - Mesh /**< Mesh stage */ -}; - -/** -@debugoperatorenum{Stage} -@m_since_latest -*/ -MAGNUM_SHADERTOOLS_EXPORT Debug& operator<<(Debug& debug, Stage value); - /** @brief Base for shader converter plugins @m_since_latest diff --git a/src/Magnum/ShaderTools/CMakeLists.txt b/src/Magnum/ShaderTools/CMakeLists.txt index 02a9ccb6d..041995e5d 100644 --- a/src/Magnum/ShaderTools/CMakeLists.txt +++ b/src/Magnum/ShaderTools/CMakeLists.txt @@ -30,11 +30,13 @@ set(MagnumShaderTools_SRCS ) # Files compiled with different flags for main library and unit test library set(MagnumShaderTools_GracefulAssert_SRCS - AbstractConverter.cpp) + AbstractConverter.cpp + Stage.cpp) set(MagnumShaderTools_HEADERS AbstractConverter.h ShaderTools.h + Stage.h visibility.h) diff --git a/src/Magnum/ShaderTools/ShaderTools.h b/src/Magnum/ShaderTools/ShaderTools.h index 701bb83f4..6440c1d65 100644 --- a/src/Magnum/ShaderTools/ShaderTools.h +++ b/src/Magnum/ShaderTools/ShaderTools.h @@ -29,11 +29,14 @@ * @brief Forward declarations for the @ref Magnum::ShaderTools namespace */ +#include "Magnum/Types.h" + namespace Magnum { namespace ShaderTools { #ifndef DOXYGEN_GENERATING_OUTPUT class AbstractConverter; #endif +enum class Stage: UnsignedInt; }} diff --git a/src/Magnum/ShaderTools/Stage.cpp b/src/Magnum/ShaderTools/Stage.cpp new file mode 100644 index 000000000..84fb6d6dd --- /dev/null +++ b/src/Magnum/ShaderTools/Stage.cpp @@ -0,0 +1,60 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020, 2021 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "Stage.h" + +#include + +namespace Magnum { namespace ShaderTools { + +Debug& operator<<(Debug& debug, const Stage value) { + debug << "ShaderTools::Stage" << Debug::nospace; + + switch(value) { + /* LCOV_EXCL_START */ + #define _c(v) case Stage::v: return debug << "::" #v; + _c(Unspecified) + _c(Vertex) + _c(Fragment) + _c(Geometry) + _c(TessellationControl) + _c(TessellationEvaluation) + _c(Compute) + _c(RayGeneration) + _c(RayAnyHit) + _c(RayClosestHit) + _c(RayMiss) + _c(RayIntersection) + _c(RayCallable) + _c(MeshTask) + _c(Mesh) + #undef _c + /* LCOV_EXCL_STOP */ + } + + return debug << "(" << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << ")"; +} + +}} diff --git a/src/Magnum/ShaderTools/Stage.h b/src/Magnum/ShaderTools/Stage.h new file mode 100644 index 000000000..ebc44e7b5 --- /dev/null +++ b/src/Magnum/ShaderTools/Stage.h @@ -0,0 +1,89 @@ +#ifndef Magnum_ShaderTools_Stage_h +#define Magnum_ShaderTools_Stage_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020, 2021 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/** @file + * @brief Enum @ref Magnum::ShaderTools::Stage + * @m_since_latest + */ + +#include "Magnum/Magnum.h" +#include "Magnum/ShaderTools/visibility.h" + +namespace Magnum { namespace ShaderTools { + +/** +@brief Shader stage +@m_since_latest + +@see @ref AbstractConverter +*/ +enum class Stage: UnsignedInt { + /** + * Unspecified stage. When used in the + * @ref AbstractConverter::validateFile(), + * @ref AbstractConverter::convertFileToFile() "convertFileToFile()", + * @ref AbstractConverter::convertFileToData() "convertFileToData()", + * @ref AbstractConverter::linkFilesToFile() "linkFilesToFile()" or + * @ref AbstractConverter::linkFilesToData() "linkFilesToData()" APIs, + * particular plugins may attempt to detect the stage from filename, the + * shader stage might also be encoded directly in certain + * @ref Format "Format"s. Leaving the stage unspecified might limit + * validation and conversion capabilities, see documentation of a + * particular converter for concrete behavior. + * + * This value is guaranteed to be @cpp 0 @ce, which means you're encouraged + * to simply use @cpp {} @ce in function calls and elsewhere. + */ + Unspecified = 0, + + Vertex, /**< Vertex stage */ + Fragment, /**< Fragment stage */ + Geometry, /**< Geometry stage */ + TessellationControl, /**< Tessellation control stage */ + TessellationEvaluation, /**< Tessellation evaluation stage */ + Compute, /**< Compute stage */ + + RayGeneration, /**< Ray generation stage */ + RayAnyHit, /**< Ray any hit stage */ + RayClosestHit, /**< Ray closest hit stage */ + RayMiss, /**< Ray miss stage */ + RayIntersection, /**< Ray intersection stage */ + RayCallable, /**< Ray callable stage */ + + MeshTask, /**< Mesh task stage */ + Mesh /**< Mesh stage */ +}; + +/** +@debugoperatorenum{Stage} +@m_since_latest +*/ +MAGNUM_SHADERTOOLS_EXPORT Debug& operator<<(Debug& debug, Stage value); + +}} + +#endif diff --git a/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp b/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp index 20be04c71..56b75ac64 100644 --- a/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp +++ b/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp @@ -36,6 +36,7 @@ #include "Magnum/FileCallback.h" #include "Magnum/ShaderTools/AbstractConverter.h" +#include "Magnum/ShaderTools/Stage.h" #include "configure.h" @@ -180,7 +181,6 @@ struct AbstractConverterTest: TestSuite::Tester { void debugFlag(); void debugFlags(); void debugFormat(); - void debugStage(); }; AbstractConverterTest::AbstractConverterTest() { @@ -319,8 +319,7 @@ AbstractConverterTest::AbstractConverterTest() { &AbstractConverterTest::debugFeatures, &AbstractConverterTest::debugFlag, &AbstractConverterTest::debugFlags, - &AbstractConverterTest::debugFormat, - &AbstractConverterTest::debugStage}); + &AbstractConverterTest::debugFormat}); /* Create testing dir */ Utility::Directory::mkpath(SHADERTOOLS_TEST_OUTPUT_DIR); @@ -3428,13 +3427,6 @@ void AbstractConverterTest::debugFormat() { CORRADE_COMPARE(out.str(), "ShaderTools::Format::Glsl ShaderTools::Format(0xf0)\n"); } -void AbstractConverterTest::debugStage() { - std::ostringstream out; - - Debug{&out} << Stage::RayMiss << Stage(0xf0); - CORRADE_COMPARE(out.str(), "ShaderTools::Stage::RayMiss ShaderTools::Stage(0xf0)\n"); -} - }}}} CORRADE_TEST_MAIN(Magnum::ShaderTools::Test::AbstractConverterTest) diff --git a/src/Magnum/ShaderTools/Test/CMakeLists.txt b/src/Magnum/ShaderTools/Test/CMakeLists.txt index e0d394d58..a17fbfce7 100644 --- a/src/Magnum/ShaderTools/Test/CMakeLists.txt +++ b/src/Magnum/ShaderTools/Test/CMakeLists.txt @@ -37,9 +37,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake corrade_add_test(ShaderToolsAbstractConverterTest AbstractConverterTest.cpp LIBRARIES MagnumShaderToolsTestLib FILES file.dat another.dat) - target_include_directories(ShaderToolsAbstractConverterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +corrade_add_test(ShaderToolsStageTest StageTest.cpp LIBRARIES MagnumShaderTools) set_target_properties( ShaderToolsAbstractConverterTest + ShaderToolsStageTest PROPERTIES FOLDER "Magnum/ShaderTools/Test") diff --git a/src/Magnum/ShaderTools/Test/StageTest.cpp b/src/Magnum/ShaderTools/Test/StageTest.cpp new file mode 100644 index 000000000..fc4fb44c9 --- /dev/null +++ b/src/Magnum/ShaderTools/Test/StageTest.cpp @@ -0,0 +1,53 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020, 2021 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include +#include +#include + +#include "Magnum/ShaderTools/Stage.h" + +namespace Magnum { namespace ShaderTools { namespace Test { namespace { + +struct StageTest: TestSuite::Tester { + explicit StageTest(); + + void debug(); +}; + +StageTest::StageTest() { + addTests({&StageTest::debug}); +} + +void StageTest::debug() { + std::ostringstream out; + + Debug{&out} << Stage::RayMiss << Stage(0xf0); + CORRADE_COMPARE(out.str(), "ShaderTools::Stage::RayMiss ShaderTools::Stage(0xf0)\n"); +} + +}}}} + +CORRADE_TEST_MAIN(Magnum::ShaderTools::Test::StageTest) diff --git a/src/Magnum/ShaderTools/shaderconverter.cpp b/src/Magnum/ShaderTools/shaderconverter.cpp index 5b437b027..b2f722b34 100644 --- a/src/Magnum/ShaderTools/shaderconverter.cpp +++ b/src/Magnum/ShaderTools/shaderconverter.cpp @@ -33,6 +33,7 @@ #include "Magnum/Implementation/converterUtilities.h" #include "Magnum/Math/Functions.h" #include "Magnum/ShaderTools/AbstractConverter.h" +#include "Magnum/ShaderTools/Stage.h" namespace Magnum { diff --git a/src/MagnumPlugins/AnyShaderConverter/Test/AnyConverterTest.cpp b/src/MagnumPlugins/AnyShaderConverter/Test/AnyConverterTest.cpp index 06452901d..af4469284 100644 --- a/src/MagnumPlugins/AnyShaderConverter/Test/AnyConverterTest.cpp +++ b/src/MagnumPlugins/AnyShaderConverter/Test/AnyConverterTest.cpp @@ -34,6 +34,7 @@ #include #include "Magnum/ShaderTools/AbstractConverter.h" +#include "Magnum/ShaderTools/Stage.h" #include "configure.h"