mirror of https://github.com/mosra/magnum.git
Browse Source
Will be used by SPIR-V reflection APIs, which don't need the whole converter interface and all the pluginmanager stuff dragged along.pull/495/head
12 changed files with 221 additions and 90 deletions
@ -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š <mosra@centrum.cz> |
||||||
|
|
||||||
|
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 <Corrade/Utility/Debug.h> |
||||||
|
|
||||||
|
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<void*>(UnsignedByte(value)) << Debug::nospace << ")"; |
||||||
|
} |
||||||
|
|
||||||
|
}} |
||||||
@ -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š <mosra@centrum.cz> |
||||||
|
|
||||||
|
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 |
||||||
@ -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š <mosra@centrum.cz> |
||||||
|
|
||||||
|
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 <sstream> |
||||||
|
#include <Corrade/TestSuite/Tester.h> |
||||||
|
#include <Corrade/Utility/DebugStl.h> |
||||||
|
|
||||||
|
#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) |
||||||
Loading…
Reference in new issue