From 118ad33109f7c3fb88410f5ee1b84698955c9f6d Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Fri, 30 Dec 2022 15:54:45 +0800 Subject: [PATCH] Got rid of SHEnumWrapper --- .../GlobalData/SHGraphicsPredefinedData.cpp | 16 ++- .../GlobalData/SHGraphicsPredefinedData.h | 5 +- SHADE_Engine/src/Tools/SHEnumWrapper.h | 126 +++++++++--------- 3 files changed, 81 insertions(+), 66 deletions(-) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp index a533249b..ffe29b36 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp @@ -198,12 +198,13 @@ namespace SHADE InitDummyPipelineLayouts (logicalDevice); } - std::vector> SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHEnumWrapper types) noexcept + std::vector> SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes types) noexcept { std::vector> layoutsFound; for (uint8_t i = 0; i < numPredefinedDescSetLayoutTypes; ++i) { - if (types & (static_cast(1) << i)) + auto result = types & static_cast(static_cast(1) << i); + if (static_cast(result)) layoutsFound.push_back(predefinedLayouts[i]); } @@ -226,6 +227,17 @@ namespace SHADE return perSystemData[static_cast(systemType)].descMappings.GetMappings(); } + SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes operator|(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes lhs, SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes rhs) noexcept + { + return static_cast(static_cast(lhs) | static_cast(rhs)); + } + + SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes operator&(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes lhs, SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes rhs) noexcept + { + return static_cast(static_cast(lhs) & static_cast(rhs)); + + } + //SHGraphicsPredefinedData::PerSystem const& SHGraphicsPredefinedData::GetBatchingSystemData(void) noexcept //{ // return batchingSystemData; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h index f46cb883..11bfc469 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h @@ -88,12 +88,15 @@ namespace SHADE /*-----------------------------------------------------------------------*/ /* SETTERS AND GETTERS */ /*-----------------------------------------------------------------------*/ - static std::vector> GetPredefinedDescSetLayouts (SHEnumWrapper types) noexcept; + static std::vector> GetPredefinedDescSetLayouts (SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes types) noexcept; static SHVertexInputState const& GetDefaultViState (void) noexcept; static PerSystem const& GetSystemData (SystemType systemType) noexcept; static SHDescriptorMappings::MapType const& GetMappings (SystemType systemType) noexcept; //static PerSystem const& GetBatchingSystemData(void) noexcept; //static PerSystem const& GetTextSystemData(void) noexcept; //static PerSystem const& GetRenderGraphNodeComputeData(void) noexcept; + }; + SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes operator| (SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes lhs, SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes rhs) noexcept; + SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes operator& (SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes lhs, SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes rhs) noexcept; } diff --git a/SHADE_Engine/src/Tools/SHEnumWrapper.h b/SHADE_Engine/src/Tools/SHEnumWrapper.h index 7c37659e..07c92fab 100644 --- a/SHADE_Engine/src/Tools/SHEnumWrapper.h +++ b/SHADE_Engine/src/Tools/SHEnumWrapper.h @@ -2,66 +2,66 @@ #include -namespace SHADE -{ - template - class SHEnumWrapper - { - public: - using UnderlyingType = typename std::underlying_type_t; - - private: - UnderlyingType mask; - - public: - - constexpr SHEnumWrapper(void) noexcept - : mask{ 0 } - { - - }; - - constexpr SHEnumWrapper(BitType bit) noexcept - : mask{ static_cast(bit) } - { - - }; - - constexpr SHEnumWrapper(SHEnumWrapper const& rhs) noexcept = default; - constexpr SHEnumWrapper& operator= (SHEnumWrapper const& rhs) noexcept = default; - - constexpr explicit SHEnumWrapper(UnderlyingType flags) noexcept - : mask{ flags } - { - - }; - - constexpr SHEnumWrapper operator| (SHEnumWrapper const& rhs) const noexcept - { - return static_cast> (mask | rhs.mask); - }; - - constexpr SHEnumWrapper operator& (SHEnumWrapper const& rhs) const noexcept - { - return static_cast> (mask & rhs.mask); - }; - - constexpr operator UnderlyingType() const noexcept - { - return mask; - }; - }; - - template>> - inline BitType operator|(const BitType& left, const BitType& right) - { - return static_cast(static_cast(left) | static_cast(right)); - } - - template>> - inline BitType operator&(const BitType& left, const BitType& right) - { - return static_cast(static_cast(left) & static_cast(right)); - } - -} +//namespace SHADE +//{ +// template +// class SHEnumWrapper +// { +// public: +// using UnderlyingType = typename std::underlying_type_t; +// +// private: +// UnderlyingType mask; +// +// public: +// +// constexpr SHEnumWrapper(void) noexcept +// : mask{ 0 } +// { +// +// }; +// +// constexpr SHEnumWrapper(BitType bit) noexcept +// : mask{ static_cast(bit) } +// { +// +// }; +// +// constexpr SHEnumWrapper(SHEnumWrapper const& rhs) noexcept = default; +// constexpr SHEnumWrapper& operator= (SHEnumWrapper const& rhs) noexcept = default; +// +// constexpr explicit SHEnumWrapper(UnderlyingType flags) noexcept +// : mask{ flags } +// { +// +// }; +// +// constexpr SHEnumWrapper operator| (SHEnumWrapper const& rhs) const noexcept +// { +// return static_cast> (mask | rhs.mask); +// }; +// +// constexpr SHEnumWrapper operator& (SHEnumWrapper const& rhs) const noexcept +// { +// return static_cast> (mask & rhs.mask); +// }; +// +// constexpr operator UnderlyingType() const noexcept +// { +// return mask; +// }; +// }; +// +// template>> +// inline BitType operator|(const BitType& left, const BitType& right) +// { +// return static_cast(static_cast(left) | static_cast(right)); +// } +// +// template>> +// inline BitType operator&(const BitType& left, const BitType& right) +// { +// return static_cast(static_cast(left) & static_cast(right)); +// } +// +//}