Got rid of SHEnumWrapper

This commit is contained in:
Brandon Mak 2022-12-30 15:54:45 +08:00
parent ce16ca6f8d
commit 118ad33109
3 changed files with 81 additions and 66 deletions

View File

@ -198,12 +198,13 @@ namespace SHADE
InitDummyPipelineLayouts (logicalDevice);
}
std::vector<Handle<SHVkDescriptorSetLayout>> SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHEnumWrapper<SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes> types) noexcept
std::vector<Handle<SHVkDescriptorSetLayout>> SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes types) noexcept
{
std::vector<Handle<SHVkDescriptorSetLayout>> layoutsFound;
for (uint8_t i = 0; i < numPredefinedDescSetLayoutTypes; ++i)
{
if (types & (static_cast<uint64_t>(1) << i))
auto result = types & static_cast<SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes>(static_cast<uint64_t>(1) << i);
if (static_cast<uint64_t>(result))
layoutsFound.push_back(predefinedLayouts[i]);
}
@ -226,6 +227,17 @@ namespace SHADE
return perSystemData[static_cast<uint32_t>(systemType)].descMappings.GetMappings();
}
SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes operator|(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes lhs, SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes rhs) noexcept
{
return static_cast<SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes>(static_cast<uint64_t>(lhs) | static_cast<uint64_t>(rhs));
}
SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes operator&(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes lhs, SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes rhs) noexcept
{
return static_cast<SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes>(static_cast<uint64_t>(lhs) & static_cast<uint64_t>(rhs));
}
//SHGraphicsPredefinedData::PerSystem const& SHGraphicsPredefinedData::GetBatchingSystemData(void) noexcept
//{
// return batchingSystemData;

View File

@ -88,12 +88,15 @@ namespace SHADE
/*-----------------------------------------------------------------------*/
/* SETTERS AND GETTERS */
/*-----------------------------------------------------------------------*/
static std::vector<Handle<SHVkDescriptorSetLayout>> GetPredefinedDescSetLayouts (SHEnumWrapper<SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes> types) noexcept;
static std::vector<Handle<SHVkDescriptorSetLayout>> 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;
}

View File

@ -2,66 +2,66 @@
#include <iostream>
namespace SHADE
{
template<typename BitType>
class SHEnumWrapper
{
public:
using UnderlyingType = typename std::underlying_type_t<BitType>;
private:
UnderlyingType mask;
public:
constexpr SHEnumWrapper(void) noexcept
: mask{ 0 }
{
};
constexpr SHEnumWrapper(BitType bit) noexcept
: mask{ static_cast<UnderlyingType>(bit) }
{
};
constexpr SHEnumWrapper(SHEnumWrapper<BitType> const& rhs) noexcept = default;
constexpr SHEnumWrapper& operator= (SHEnumWrapper<BitType> const& rhs) noexcept = default;
constexpr explicit SHEnumWrapper(UnderlyingType flags) noexcept
: mask{ flags }
{
};
constexpr SHEnumWrapper<BitType> operator| (SHEnumWrapper<BitType> const& rhs) const noexcept
{
return static_cast<SHEnumWrapper<BitType>> (mask | rhs.mask);
};
constexpr SHEnumWrapper<BitType> operator& (SHEnumWrapper<BitType> const& rhs) const noexcept
{
return static_cast<SHEnumWrapper<BitType>> (mask & rhs.mask);
};
constexpr operator UnderlyingType() const noexcept
{
return mask;
};
};
template<typename BitType, typename = std::enable_if_t<std::is_enum_v<BitType>>>
inline BitType operator|(const BitType& left, const BitType& right)
{
return static_cast<BitType>(static_cast<int>(left) | static_cast<int>(right));
}
template<typename BitType, typename = std::enable_if_t<std::is_enum_v<BitType>>>
inline BitType operator&(const BitType& left, const BitType& right)
{
return static_cast<BitType>(static_cast<int>(left) & static_cast<int>(right));
}
}
//namespace SHADE
//{
// template<typename BitType>
// class SHEnumWrapper
// {
// public:
// using UnderlyingType = typename std::underlying_type_t<BitType>;
//
// private:
// UnderlyingType mask;
//
// public:
//
// constexpr SHEnumWrapper(void) noexcept
// : mask{ 0 }
// {
//
// };
//
// constexpr SHEnumWrapper(BitType bit) noexcept
// : mask{ static_cast<UnderlyingType>(bit) }
// {
//
// };
//
// constexpr SHEnumWrapper(SHEnumWrapper<BitType> const& rhs) noexcept = default;
// constexpr SHEnumWrapper& operator= (SHEnumWrapper<BitType> const& rhs) noexcept = default;
//
// constexpr explicit SHEnumWrapper(UnderlyingType flags) noexcept
// : mask{ flags }
// {
//
// };
//
// constexpr SHEnumWrapper<BitType> operator| (SHEnumWrapper<BitType> const& rhs) const noexcept
// {
// return static_cast<SHEnumWrapper<BitType>> (mask | rhs.mask);
// };
//
// constexpr SHEnumWrapper<BitType> operator& (SHEnumWrapper<BitType> const& rhs) const noexcept
// {
// return static_cast<SHEnumWrapper<BitType>> (mask & rhs.mask);
// };
//
// constexpr operator UnderlyingType() const noexcept
// {
// return mask;
// };
// };
//
// template<typename BitType, typename = std::enable_if_t<std::is_enum_v<BitType>>>
// inline BitType operator|(const BitType& left, const BitType& right)
// {
// return static_cast<BitType>(static_cast<int>(left) | static_cast<int>(right));
// }
//
// template<typename BitType, typename = std::enable_if_t<std::is_enum_v<BitType>>>
// inline BitType operator&(const BitType& left, const BitType& right)
// {
// return static_cast<BitType>(static_cast<int>(left) & static_cast<int>(right));
// }
//
//}