From 56cc8734c77423b1cf7df0c4ae7ef8fba3cde87e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 6 Sep 2022 15:31:54 +0200 Subject: [PATCH] Shaders: the early exit is only for assertion testing, document that. I knew it had to be there, but then forgot and wanted to remove it as superfluous because such case can't happen from user code. Well... --- src/Magnum/Shaders/DistanceFieldVectorGL.cpp | 4 ++++ src/Magnum/Shaders/FlatGL.cpp | 4 ++++ src/Magnum/Shaders/MeshVisualizerGL.cpp | 8 ++++++++ src/Magnum/Shaders/PhongGL.cpp | 4 ++++ src/Magnum/Shaders/VectorGL.cpp | 4 ++++ src/Magnum/Shaders/VertexColorGL.cpp | 4 ++++ 6 files changed, 28 insertions(+) diff --git a/src/Magnum/Shaders/DistanceFieldVectorGL.cpp b/src/Magnum/Shaders/DistanceFieldVectorGL.cpp index ca80137a0..be4dd12f5 100644 --- a/src/Magnum/Shaders/DistanceFieldVectorGL.cpp +++ b/src/Magnum/Shaders/DistanceFieldVectorGL.cpp @@ -164,7 +164,11 @@ template typename DistanceFieldVectorGL::Com } template DistanceFieldVectorGL::DistanceFieldVectorGL(CompileState&& state): DistanceFieldVectorGL{static_cast(std::move(state))} { + #ifdef CORRADE_GRACEFUL_ASSERT + /* When graceful assertions fire from within compile(), we get a NoCreate'd + CompileState. Exiting makes it possible to test the assert. */ if(!id()) return; + #endif CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink()); diff --git a/src/Magnum/Shaders/FlatGL.cpp b/src/Magnum/Shaders/FlatGL.cpp index 939cc04d4..af12286a3 100644 --- a/src/Magnum/Shaders/FlatGL.cpp +++ b/src/Magnum/Shaders/FlatGL.cpp @@ -239,7 +239,11 @@ template typename FlatGL::CompileState FlatG } template FlatGL::FlatGL(CompileState&& state): FlatGL{static_cast(std::move(state))} { + #ifdef CORRADE_GRACEFUL_ASSERT + /* When graceful assertions fire from within compile(), we get a NoCreate'd + CompileState. Exiting makes it possible to test the assert. */ if(!id()) return; + #endif CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink()); diff --git a/src/Magnum/Shaders/MeshVisualizerGL.cpp b/src/Magnum/Shaders/MeshVisualizerGL.cpp index f77d1ac07..80cde4f35 100644 --- a/src/Magnum/Shaders/MeshVisualizerGL.cpp +++ b/src/Magnum/Shaders/MeshVisualizerGL.cpp @@ -530,7 +530,11 @@ MeshVisualizerGL2D::MeshVisualizerGL2D(const Flags flags, const UnsignedInt mate #endif MeshVisualizerGL2D::MeshVisualizerGL2D(CompileState&& state): MeshVisualizerGL2D{static_cast(std::move(state))} { + #ifdef CORRADE_GRACEFUL_ASSERT + /* When graceful assertions fire from within compile(), we get a NoCreate'd + CompileState. Exiting makes it possible to test the assert. */ if(!id()) return; + #endif CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink()); @@ -902,7 +906,11 @@ MeshVisualizerGL3D::CompileState MeshVisualizerGL3D::compile(Flags flags } MeshVisualizerGL3D::MeshVisualizerGL3D(CompileState&& state): MeshVisualizerGL3D{static_cast(std::move(state))} { + #ifdef CORRADE_GRACEFUL_ASSERT + /* When graceful assertions fire from within compile(), we get a NoCreate'd + CompileState. Exiting makes it possible to test the assert. */ if(!id()) return; + #endif CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink()); diff --git a/src/Magnum/Shaders/PhongGL.cpp b/src/Magnum/Shaders/PhongGL.cpp index d857b2bc8..f68258dc8 100644 --- a/src/Magnum/Shaders/PhongGL.cpp +++ b/src/Magnum/Shaders/PhongGL.cpp @@ -349,7 +349,11 @@ PhongGL::CompileState PhongGL::compile(const Flags flags, const UnsignedInt ligh } PhongGL::PhongGL(CompileState&& state): PhongGL{static_cast(std::move(state))} { + #ifdef CORRADE_GRACEFUL_ASSERT + /* When graceful assertions fire from within compile(), we get a NoCreate'd + CompileState. Exiting makes it possible to test the assert. */ if(!id()) return; + #endif CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink()); diff --git a/src/Magnum/Shaders/VectorGL.cpp b/src/Magnum/Shaders/VectorGL.cpp index 061c0a620..b9f1b597b 100644 --- a/src/Magnum/Shaders/VectorGL.cpp +++ b/src/Magnum/Shaders/VectorGL.cpp @@ -166,7 +166,11 @@ template typename VectorGL::CompileState Vec } template VectorGL::VectorGL(CompileState&& state): VectorGL{static_cast(std::move(state))} { + #ifdef CORRADE_GRACEFUL_ASSERT + /* When graceful assertions fire from within compile(), we get a NoCreate'd + CompileState. Exiting makes it possible to test the assert. */ if(!id()) return; + #endif CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink()); diff --git a/src/Magnum/Shaders/VertexColorGL.cpp b/src/Magnum/Shaders/VertexColorGL.cpp index 5ba57d09a..0853e52f2 100644 --- a/src/Magnum/Shaders/VertexColorGL.cpp +++ b/src/Magnum/Shaders/VertexColorGL.cpp @@ -144,7 +144,11 @@ template typename VertexColorGL::CompileStat } template VertexColorGL::VertexColorGL(CompileState&& state): VertexColorGL{static_cast(std::move(state))} { + #ifdef CORRADE_GRACEFUL_ASSERT + /* When graceful assertions fire from within compile(), we get a NoCreate'd + CompileState. Exiting makes it possible to test the assert. */ if(!id()) return; + #endif CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink());