Make stuff constexpr

This commit is contained in:
2021-02-01 12:56:11 +01:00
parent 097613f34b
commit aede8c9e59
2 changed files with 15 additions and 17 deletions

View File

@@ -20,15 +20,4 @@ namespace openVulkanoCpp
if (result.has_value()) return { result.value() };
return { UNDEFINED };
}
bool DataFormat::IsSRGB() const
{
return m_format == R8_SRGB || m_format == R8G8_SRGB || m_format == R8G8B8_SRGB || m_format == B8G8R8_SRGB ||
m_format == B8G8R8A8_SRGB || m_format == R8G8B8A8_SRGB || m_format == A8B8G8R8_SRGB_PACK32 ||
m_format == BC1_RGB_SRGB_BLOCK || m_format == BC1_RGBA_SRGB_BLOCK || m_format == BC2_SRGB_BLOCK ||
m_format == BC3_SRGB_BLOCK || m_format == BC7_SRGB_BLOCK || m_format == ETC2_R8G8B8_SRGB_BLOCK ||
m_format == ETC2_R8G8B8A1_SRGB_BLOCK || m_format == ETC2_R8G8B8A8_SRGB_BLOCK ||
(m_format >= ASTC_4x4_SRGB_BLOCK && m_format <= ASTC_12x12_SRGB_BLOCK && !(m_format & 1)) ||
(m_format >= PVRTC1_2BPP_SRGB_BLOCK_IMG && m_format <= PVRTC2_4BPP_SRGB_BLOCK_IMG);
}
}

View File

@@ -329,25 +329,34 @@ namespace openVulkanoCpp
R16G16_S10_5_NV = 1000464000,
};
DataFormat() : DataFormat(UNDEFINED) {}
constexpr DataFormat() : DataFormat(UNDEFINED) {}
DataFormat(Format format) : m_format(format) {}
constexpr DataFormat(Format format) : m_format(format) {}
[[nodiscard]] std::string_view GetName() const;
[[nodiscard]] bool IsSRGB() const;
[[nodiscard]] constexpr bool IsSRGB() const
{
return m_format == R8_SRGB || m_format == R8G8_SRGB || m_format == R8G8B8_SRGB || m_format == B8G8R8_SRGB ||
m_format == B8G8R8A8_SRGB || m_format == R8G8B8A8_SRGB || m_format == A8B8G8R8_SRGB_PACK32 ||
m_format == BC1_RGB_SRGB_BLOCK || m_format == BC1_RGBA_SRGB_BLOCK || m_format == BC2_SRGB_BLOCK ||
m_format == BC3_SRGB_BLOCK || m_format == BC7_SRGB_BLOCK || m_format == ETC2_R8G8B8_SRGB_BLOCK ||
m_format == ETC2_R8G8B8A1_SRGB_BLOCK || m_format == ETC2_R8G8B8A8_SRGB_BLOCK ||
(m_format >= ASTC_4x4_SRGB_BLOCK && m_format <= ASTC_12x12_SRGB_BLOCK && !(m_format & 1)) ||
(m_format >= PVRTC1_2BPP_SRGB_BLOCK_IMG && m_format <= PVRTC2_4BPP_SRGB_BLOCK_IMG);
}
[[nodiscard]] bool operator ==(Format rhs)
[[nodiscard]] constexpr bool operator ==(Format rhs)
{
return m_format == rhs;
}
[[nodiscard]] bool operator !=(Format rhs)
[[nodiscard]] constexpr bool operator !=(Format rhs)
{
return m_format != rhs;
}
[[nodiscard]] operator uint32_t() const
[[nodiscard]] constexpr operator uint32_t() const
{
return m_format;
}