From 990165363494746f80c830fa2d041ca029c9e912 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 11 Sep 2019 01:50:43 -0400 Subject: [PATCH] Backend: Make ExtensionSlot's constructor constexpr These are used within a file-scope lookup table in urde. Without this, technically those constructors are runtime static constructors. This allows the compiler to initialize them at compile-time. --- hecl/include/hecl/Backend.hpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hecl/include/hecl/Backend.hpp b/hecl/include/hecl/Backend.hpp index e8f3eb7ec..8f9853964 100644 --- a/hecl/include/hecl/Backend.hpp +++ b/hecl/include/hecl/Backend.hpp @@ -194,7 +194,7 @@ struct Function { }; struct ExtensionSlot { - const char* shaderMacro; + const char* shaderMacro = nullptr; size_t texCount = 0; const Backend::TextureInfo* texs = nullptr; Backend::BlendFactor srcFactor = Backend::BlendFactor::Original; @@ -209,14 +209,13 @@ struct ExtensionSlot { bool forceAlphaTest = false; bool diffuseOnly = false; - ExtensionSlot(size_t texCount = 0, - const Backend::TextureInfo* texs = nullptr, - Backend::BlendFactor srcFactor = Backend::BlendFactor::Original, - Backend::BlendFactor dstFactor = Backend::BlendFactor::Original, - Backend::ZTest depthTest = Backend::ZTest::Original, - Backend::CullMode cullMode = Backend::CullMode::Backface, bool noDepthWrite = false, - bool noColorWrite = false, bool noAlphaWrite = false, bool noAlphaOverwrite = false, - bool noReflection = false, bool forceAlphaTest = false, bool diffuseOnly = false) + constexpr ExtensionSlot(size_t texCount = 0, const Backend::TextureInfo* texs = nullptr, + Backend::BlendFactor srcFactor = Backend::BlendFactor::Original, + Backend::BlendFactor dstFactor = Backend::BlendFactor::Original, + Backend::ZTest depthTest = Backend::ZTest::Original, + Backend::CullMode cullMode = Backend::CullMode::Backface, bool noDepthWrite = false, + bool noColorWrite = false, bool noAlphaWrite = false, bool noAlphaOverwrite = false, + bool noReflection = false, bool forceAlphaTest = false, bool diffuseOnly = false) noexcept : texCount(texCount) , texs(texs) , srcFactor(srcFactor)