diff --git a/doc/changelog.dox b/doc/changelog.dox index 7440bd68c..647bbe12d 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -360,14 +360,16 @@ See also: @ref MAGNUM_BUILD_DEPRECATED is enabled, the returned type acts as a @ref Corrade::Containers::Optional but has (deprecated) implicit conversion to a @ref Corrade::Containers::Pointer to avoid breaking user code. -- @cpp Vk::hasVkFormat(Magnum::PixelFormat) @ce, +- @cpp Vk::hasVkFormat(Magnum::VertexFormat) @ce, + @cpp Vk::hasVkFormat(Magnum::PixelFormat) @ce, @cpp Vk::hasVkFormat(Magnum::CompressedPixelFormat) @ce, + @cpp Vk::vkFormat(Magnum::VertexFormat) @ce, @cpp Vk::vkFormat(Magnum::PixelFormat) @ce and @cpp Vk::vkFormat(Magnum::CompressedPixelFormat) @ce returning a raw @type_vk{Format} are deprecated in favor of - @ref Vk::hasPixelFormat(Magnum::PixelFormat), + @ref Vk::hasVertexFormat(), @ref Vk::hasPixelFormat(Magnum::PixelFormat), @ref Vk::hasPixelFormat(Magnum::CompressedPixelFormat), - @ref Vk::pixelFormat(Magnum::PixelFormat) and + @ref Vk::vertexFormat(), @ref Vk::pixelFormat(Magnum::PixelFormat) and @ref Vk::pixelFormat(Magnum::CompressedPixelFormat) that return the new @ref Vk::PixelFormat enum that contains only values suitable for a pixel format diff --git a/src/Magnum/VertexFormat.h b/src/Magnum/VertexFormat.h index 2c9ec20c2..87480c185 100644 --- a/src/Magnum/VertexFormat.h +++ b/src/Magnum/VertexFormat.h @@ -56,11 +56,10 @@ See documentation of each value for more information about the mapping. Note that not every format is available on all targets, use @ref GL::hasVertexFormat() to check for its presence. -In case of Vulkan, corresponds to @type_vk_keyword{Format} and is convertible -to it using @ref Vk::vkFormat(Magnum::VertexFormat). See documentation of each -value for more information about the mapping. Note that not every format may be -available, use @ref Vk::hasVkFormat(Magnum::VertexFormat) to check for its -presence. +In case of Vulkan, corresponds to @ref Vk::VertexFormat and is convertible to +it using @ref Vk::vertexFormat(). See documentation of each value for more +information about the mapping. Note that not every format may be available, use +@ref Vk::hasVertexFormat() to check for its presence. For D3D, corresponds to @m_class{m-doc-external} [DXGI_FORMAT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format); for Metal, corresponds to @m_class{m-doc-external} [MTLVertexFormat](https://developer.apple.com/documentation/metal/mtlvertexformat?language=objc). @@ -75,8 +74,7 @@ enum class VertexFormat: UnsignedInt { * @ref Float. * * Corresponds to single-component @ref GL::DynamicAttribute::Kind::Generic - * @ref GL::DynamicAttribute::DataType::Float; - * @val_vk_keyword{FORMAT_R32_SFLOAT,Format}; + * @ref GL::DynamicAttribute::DataType::Float; @ref Vk::VertexFormat::Float; * @m_class{m-doc-external} [DXGI_FORMAT_R32_FLOAT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatFloat](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatfloat?language=objc). * @m_keywords{DXGI_FORMAT_R32_FLOAT MTLVertexFormatFloat} @@ -87,8 +85,7 @@ enum class VertexFormat: UnsignedInt { * @ref Half. * * Corresponds to single-component @ref GL::DynamicAttribute::Kind::Generic - * @ref GL::DynamicAttribute::DataType::Half; - * @val_vk_keyword{FORMAT_R16_SFLOAT,Format}; + * @ref GL::DynamicAttribute::DataType::Half; @ref Vk::VertexFormat::Half; * @m_class{m-doc-external} [DXGI_FORMAT_R16_FLOAT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatHalf](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformathalf?language=objc). * @m_keywords{DXGI_FORMAT_R16_FLOAT MTLVertexFormatHalf} @@ -101,7 +98,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to single-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Long * @ref GL::DynamicAttribute::DataType::Double; - * @val_vk_keyword{FORMAT_R64_SFLOAT,Format}. No D3D or Metal equivalent. + * @ref Vk::VertexFormat::Double. No D3D or Metal equivalent. */ Double, @@ -111,7 +108,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to single-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::UnsignedByte; - * @val_vk_keyword{FORMAT_R8_UINT,Format}; + * @ref Vk::VertexFormat::UnsignedByte; * @m_class{m-doc-external} [DXGI_FORMAT_R8_UINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUChar](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatuchar?language=objc) * @m_keywords{DXGI_FORMAT_R8_UINT MTLVertexFormatUChar} @@ -125,7 +122,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to single-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::UnsignedByte; - * @val_vk_keyword{FORMAT_R8_UNORM,Format}; + * @ref Vk::VertexFormat::UnsignedByteNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R8_UNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUCharNormalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatucharnormalized?language=objc). * @m_keywords{DXGI_FORMAT_R8_UNORM MTLVertexFormatUCharNormalized} @@ -137,8 +134,7 @@ enum class VertexFormat: UnsignedInt { * * Corresponds to single-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral - * @ref GL::DynamicAttribute::DataType::Byte; - * @val_vk_keyword{FORMAT_R8_SINT,Format}; + * @ref GL::DynamicAttribute::DataType::Byte; @ref Vk::VertexFormat::Byte; * @m_class{m-doc-external} [DXGI_FORMAT_R8_SINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatChar](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatchar?language=objc). * @m_keywords{DXGI_FORMAT_R8_SINT MTLVertexFormatChar} @@ -152,7 +148,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to single-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::Byte; - * @val_vk_keyword{FORMAT_R8_SNORM,Format}; + * @ref Vk::VertexFormat::ByteNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R8_SNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatCharNormalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatcharnormalized?language=objc). * @m_keywords{DXGI_FORMAT_R8_SNORM MTLVertexFormatCharNormalized} @@ -165,7 +161,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to single-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::UnsignedShort; - * @val_vk_keyword{FORMAT_R16_UINT,Format}; + * @ref Vk::VertexFormat::UnsignedShort; * @m_class{m-doc-external} [DXGI_FORMAT_R16_UINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUShort](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatushort?language=objc). * @m_keywords{DXGI_FORMAT_R16_UINT MTLVertexFormatUShort} @@ -179,7 +175,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to single-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::UnsignedByte; - * @val_vk_keyword{FORMAT_R16_UNORM,Format}; + * @ref Vk::VertexFormat::UnsignedShortNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R16_UNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUShortNormalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatushortnormalized?language=objc). * @m_keywords{DXGI_FORMAT_R16_UNORM MTLVertexFormatUShortNormalized} @@ -192,7 +188,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to single-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::Short; - * @val_vk_keyword{FORMAT_R16_SINT,Format}; + * @ref Vk::VertexFormat::Short; * @m_class{m-doc-external} [DXGI_FORMAT_R16_SINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatShort](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatshort?language=objc). * @m_keywords{DXGI_FORMAT_R16_SINT MTLVertexFormatShort} @@ -206,7 +202,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to single-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::Short; - * @val_vk_keyword{FORMAT_R16_SNORM,Format}; + * @ref Vk::VertexFormat::ShortNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R16_SNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatShortNormalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatshortnormalized?language=objc). * @m_keywords{DXGI_FORMAT_R16_SNORM MTLVertexFormatShortNormalized} @@ -219,7 +215,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to single-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::UnsignedInt; - * @val_vk_keyword{FORMAT_R32_UINT,Format}; + * @ref Vk::VertexFormat::UnsignedInt; * @m_class{m-doc-external} [DXGI_FORMAT_R32_UINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUInt](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatuint?language=objc). * @m_keywords{DXGI_FORMAT_R32_UINT MTLVertexFormatUInt} @@ -231,8 +227,7 @@ enum class VertexFormat: UnsignedInt { * * Corresponds to single-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral - * @ref GL::DynamicAttribute::DataType::Int; - * @val_vk_keyword{FORMAT_R32_SINT,Format}; + * @ref GL::DynamicAttribute::DataType::Int; @ref Vk::VertexFormat::Int; * @m_class{m-doc-external} [DXGI_FORMAT_R32_SINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatInt](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatint?language=objc). * @m_keywords{DXGI_FORMAT_R32_SINT MTLVertexFormatInt} @@ -244,7 +239,7 @@ enum class VertexFormat: UnsignedInt { * * Corresponds to two-component @ref GL::DynamicAttribute::Kind::Generic * @ref GL::DynamicAttribute::DataType::Float; - * @val_vk_keyword{FORMAT_R32G32_SFLOAT,Format}; + * @ref Vk::VertexFormat::Vector2; * @m_class{m-doc-external} [DXGI_FORMAT_R32G32_FLOAT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatFloat2](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatfloat2?language=objc). * @m_keywords{DXGI_FORMAT_R32G32_FLOAT MTLVertexFormatFloat2} @@ -257,7 +252,7 @@ enum class VertexFormat: UnsignedInt { * * Corresponds to two-component @ref GL::DynamicAttribute::Kind::Generic * @ref GL::DynamicAttribute::DataType::Half; - * @val_vk_keyword{FORMAT_R16G16_SFLOAT,Format}; + * @ref Vk::VertexFormat::Vector2h; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16_FLOAT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatHalf2](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformathalf2?language=objc). * @m_keywords{DXGI_FORMAT_R16G16_FLOAT MTLVertexFormatHalf2} @@ -270,8 +265,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to two-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Long * @ref GL::DynamicAttribute::DataType::Double; - * @val_vk_keyword{FORMAT_R64G64_SFLOAT,Format}. No D3D or Metal - * equivalent. + * @ref Vk::VertexFormat::Vector2d. No D3D or Metal equivalent. */ Vector2d, @@ -283,7 +277,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to two-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::UnsignedByte; - * @val_vk_keyword{FORMAT_R8G8_UINT,Format}; + * @ref Vk::VertexFormat::Vector2ub; * @m_class{m-doc-external} [DXGI_FORMAT_R8G8_UINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUChar2](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatuchar2?language=objc). * @m_keywords{DXGI_FORMAT_R8G8_UINT MTLVertexFormatUChar2} @@ -298,7 +292,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to two-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::UnsignedByte; - * @val_vk_keyword{FORMAT_R8G8_UNORM,Format}; + * @ref Vk::VertexFormat::Vector2ubNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R8G8_UNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUChar2Normalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatuchar2normalized?language=objc). * @m_keywords{DXGI_FORMAT_R8G8_UNORM MTLVertexFormatUChar2Normalized} @@ -313,7 +307,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to two-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::Byte; - * @val_vk_keyword{FORMAT_R8G8_SINT,Format}; + * @ref Vk::VertexFormat::Vector2b; * @m_class{m-doc-external} [DXGI_FORMAT_R8G8_SINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatChar2](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatchar2?language=objc). * @m_keywords{DXGI_FORMAT_R8G8_SINT MTLVertexFormatChar2} @@ -328,7 +322,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to two-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::Byte; - * @val_vk_keyword{FORMAT_R8G8_SNORM,Format}; + * @ref Vk::VertexFormat::Vector2bNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R8G8_SNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatChar2Normalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatchar2normalized?language=objc). * @m_keywords{DXGI_FORMAT_R8G8_SNORM MTLVertexFormatChar2Normalized} @@ -343,7 +337,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to two-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::UnsignedShort; - * @val_vk_keyword{FORMAT_R16G16_UINT,Format}; + * @ref Vk::VertexFormat::Vector2usNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16_UINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUShort2](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatushort2?language=objc). * @m_keywords{DXGI_FORMAT_R16G16_UINT MTLVertexFormatUShort2} @@ -358,7 +352,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to two-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::UnsignedByte; - * @val_vk_keyword{FORMAT_R16G16_UNORM,Format}; + * @ref Vk::VertexFormat::Vector2usNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16_UNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUShort2Normalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatushort2normalized?language=objc). * @m_keywords{DXGI_FORMAT_R16G16_UNORM MTLVertexFormatUShort2Normalized} @@ -373,7 +367,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to two-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::Short; - * @val_vk_keyword{FORMAT_R16G16_SINT,Format}; + * @ref Vk::VertexFormat::Vector2s; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16_SINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatShort2](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatshort2?language=objc). * @m_keywords{DXGI_FORMAT_R16G16_SINT MTLVertexFormatShort2} @@ -388,7 +382,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to two-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::Short; - * @val_vk_keyword{FORMAT_R16G16_SNORM,Format}; + * @ref Vk::VertexFormat::Vector2sNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16_SNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatShort2Normalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatshort2normalized?language=objc). * @m_keywords{DXGI_FORMAT_R16G16_SNORM MTLVertexFormatShort2Normalized} @@ -401,7 +395,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to two-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::UnsignedInt; - * @val_vk_keyword{FORMAT_R32G32_UINT,Format}; + * @ref Vk::VertexFormat::Vector2ui; * @m_class{m-doc-external} [DXGI_FORMAT_R32G32_UINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUInt2](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatuint2?language=objc). * @m_keywords{DXGI_FORMAT_R32G32_UINT MTLVertexFormatUInt2} @@ -414,7 +408,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to two-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::Int; - * @val_vk_keyword{FORMAT_R32G32_SINT,Format}; + * @ref Vk::VertexFormat::Vector2i; * @m_class{m-doc-external} [DXGI_FORMAT_R32G32_SINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatInt2](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatint2?language=objc). * @m_keywords{DXGI_FORMAT_R32G32_SINT MTLVertexFormatInt2} @@ -427,7 +421,7 @@ enum class VertexFormat: UnsignedInt { * * Corresponds to three-component @ref GL::DynamicAttribute::Kind::Generic * @ref GL::DynamicAttribute::DataType::Float; - * @val_vk_keyword{FORMAT_R32G32B32_SFLOAT,Format}; + * @ref Vk::VertexFormat::Vector3; * @m_class{m-doc-external} [DXGI_FORMAT_R32G32B32_FLOAT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatFloat3](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatfloat3?language=objc). * @m_keywords{DXGI_FORMAT_R32G32B32_FLOAT MTLVertexFormatFloat3} @@ -441,7 +435,7 @@ enum class VertexFormat: UnsignedInt { * * Corresponds to three-component @ref GL::DynamicAttribute::Kind::Generic * @ref GL::DynamicAttribute::DataType::Half; - * @val_vk_keyword{FORMAT_R16G16B16_SFLOAT,Format}; + * @ref Vk::VertexFormat::Vector3h; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16B16_FLOAT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatHalf3](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformathalf3?language=objc). * @m_keywords{DXGI_FORMAT_R16G16B16_FLOAT MTLVertexFormatHalf3} @@ -454,8 +448,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to three-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Long * @ref GL::DynamicAttribute::DataType::Double; - * @val_vk_keyword{FORMAT_R64G64B64_SFLOAT,Format}. No D3D or Metal - * equivalent. + * @ref Vk::VertexFormat::Vector3d. No D3D or Metal equivalent. */ Vector3d, @@ -467,7 +460,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to three-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::UnsignedByte; - * @val_vk_keyword{FORMAT_R8G8B8_UINT,Format}; + * @ref Vk::VertexFormat::Vector3ub; * @m_class{m-doc-external} [DXGI_FORMAT_R8G8B8_UINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUChar3](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatuchar3?language=objc). * @m_keywords{DXGI_FORMAT_R8G8B8_UINT MTLVertexFormatUChar3} @@ -482,7 +475,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to three-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::UnsignedByte; - * @val_vk_keyword{FORMAT_R8G8B8_UNORM,Format}; + * @ref Vk::VertexFormat::Vector3ubNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R8G8B8_UNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUChar3Normalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatuchar3normalized?language=objc). * @m_keywords{DXGI_FORMAT_R8G8B8_UNORM MTLVertexFormatUChar3Normalized} @@ -497,7 +490,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to three-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::Byte; - * @val_vk_keyword{FORMAT_R8G8B8_SINT,Format}; + * @ref Vk::VertexFormat::Vector3b; * @m_class{m-doc-external} [DXGI_FORMAT_R8G8B8_SINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatChar3](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatchar3?language=objc). * @m_keywords{DXGI_FORMAT_R8G8B8_SINT MTLVertexFormatChar3} @@ -512,7 +505,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to three-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::Byte; - * @val_vk_keyword{FORMAT_R8G8B8_SNORM,Format}; + * @ref Vk::VertexFormat::Vector3bNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R8G8B8_SNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatChar3Normalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatchar3normalized?language=objc). * @m_keywords{DXGI_FORMAT_R8G8B8_SNORM MTLVertexFormatChar3Normalized} @@ -527,7 +520,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to three-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::UnsignedShort; - * @val_vk_keyword{FORMAT_R16G16B16_UINT,Format}; + * @ref Vk::VertexFormat::Vector3us; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16B16_UINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUShort3](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatushort3?language=objc). * @m_keywords{DXGI_FORMAT_R16G16B16_UINT MTLVertexFormatUShort3} @@ -543,7 +536,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to three-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::UnsignedByte; - * @val_vk_keyword{FORMAT_R16G16B16_UNORM,Format}; + * @ref Vk::VertexFormat::Vector3usNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16B16_UNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUShort3Normalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatushort3normalized?language=objc). * @m_keywords{DXGI_FORMAT_R16G16B16_UNORM MTLVertexFormatUShort3Normalized} @@ -558,7 +551,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to three-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::Short; - * @val_vk_keyword{FORMAT_R16G16B16_SINT,Format}; + * @ref Vk::VertexFormat::Vector3s; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16B16_SINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatShort3](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatshort3?language=objc). * @m_keywords{DXGI_FORMAT_R16G16B16_SINT MTLVertexFormatShort3} @@ -573,7 +566,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to three-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::Short; - * @val_vk_keyword{FORMAT_R16G16B16_SNORM,Format}; + * @ref Vk::VertexFormat::Vector3sNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16B16_SNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatShort3Normalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatshort3normalized?language=objc). * @m_keywords{DXGI_FORMAT_R16G16B16_SNORM MTLVertexFormatShort3Normalized} @@ -586,7 +579,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to three-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::UnsignedInt; - * @val_vk_keyword{FORMAT_R32G32B32_UINT,Format}; + * @ref Vk::VertexFormat::Vector3ui; * @m_class{m-doc-external} [DXGI_FORMAT_R32G32B32_UINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUInt3](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatuint3?language=objc). * @m_keywords{DXGI_FORMAT_R32G32B32_UINT MTLVertexFormatUInt3} @@ -599,7 +592,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to three-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::Int; - * @val_vk_keyword{FORMAT_R32G32B32_SINT,Format}; + * @ref Vk::VertexFormat::Vector3i; * @m_class{m-doc-external} [DXGI_FORMAT_R32G32B32_SINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatInt3](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatint3?language=objc). * @m_keywords{DXGI_FORMAT_R32G32B32_SINT MTLVertexFormatInt3} @@ -611,7 +604,7 @@ enum class VertexFormat: UnsignedInt { * * Corresponds to four-component @ref GL::DynamicAttribute::Kind::Generic * @ref GL::DynamicAttribute::DataType::Float; - * @val_vk_keyword{FORMAT_R32G32B32A32_SFLOAT,Format}; + * @ref Vk::VertexFormat::Vector4; * @m_class{m-doc-external} [DXGI_FORMAT_R32G32B32A32_FLOAT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatFloat4](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatfloat4?language=objc). * @m_keywords{DXGI_FORMAT_R32G32B32A32_FLOAT MTLVertexFormatFloat4} @@ -624,7 +617,7 @@ enum class VertexFormat: UnsignedInt { * * Corresponds to four-component @ref GL::DynamicAttribute::Kind::Generic * @ref GL::DynamicAttribute::DataType::Half; - * @val_vk_keyword{FORMAT_R16G16B16A16_SFLOAT,Format}; + * @ref Vk::VertexFormat::Vector4h; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16B16A16_FLOAT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatHalf4](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformathalf4?language=objc). * @m_keywords{DXGI_FORMAT_R16G16B16A16_FLOAT MTLVertexFormatHalf4} @@ -637,8 +630,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to four-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Long * @ref GL::DynamicAttribute::DataType::Double; - * @val_vk_keyword{FORMAT_R64G64B64A64_SFLOAT,Format}. No D3D or Metal - * equivalent. + * @ref Vk::VertexFormat::Vector4d. No D3D or Metal equivalent. */ Vector4d, @@ -648,7 +640,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to four-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::UnsignedByte; - * @val_vk_keyword{FORMAT_R8G8B8A8_UINT,Format}; + * @ref Vk::VertexFormat::Vector4ub; * @m_class{m-doc-external} [DXGI_FORMAT_R8G8B8A8_UINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUChar4](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatuchar4?language=objc). * @m_keywords{DXGI_FORMAT_R8G8B8A8_UINT MTLVertexFormatUChar4} @@ -663,7 +655,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to four-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::UnsignedByte; - * @val_vk_keyword{FORMAT_R8G8B8A8_UNORM,Format}; + * @ref Vk::VertexFormat::Vector4ubNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R8G8B8A8_UNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUChar4Normalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatuchar4normalized?language=objc). * @m_keywords{DXGI_FORMAT_R8G8B8A8_UNORM MTLVertexFormatUChar4Normalized} @@ -676,7 +668,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to four-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::Byte; - * @val_vk_keyword{FORMAT_R8G8B8A8_SINT,Format}; + * @ref Vk::VertexFormat::Vector4b; * @m_class{m-doc-external} [DXGI_FORMAT_R8G8B8A8_SINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatChar4](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatchar4?language=objc). * @m_keywords{DXGI_FORMAT_R8G8B8A8_SINT MTLVertexFormatChar4} @@ -690,7 +682,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to four-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::Byte; - * @val_vk_keyword{FORMAT_R8G8B8A8_SNORM,Format}; + * @ref Vk::VertexFormat::Vector4bNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R8G8B8A8_SNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatChar4Normalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatchar4normalized?language=objc). * @m_keywords{DXGI_FORMAT_R8G8B8A8_SNORM MTLVertexFormatChar4Normalized} @@ -703,7 +695,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to four-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::UnsignedShort; - * @val_vk_keyword{FORMAT_R16G16B16A16_UINT,Format}; + * @ref Vk::VertexFormat::Vector4us; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16B16A16_UINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUShort4](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatushort4?language=objc). * @m_keywords{DXGI_FORMAT_R16G16B16A16_UINT MTLVertexFormatUShort4} @@ -718,7 +710,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to four-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::UnsignedByte; - * @val_vk_keyword{FORMAT_R16G16B16A16_UNORM,Format}; + * @ref Vk::VertexFormat::Vector4usNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16B16A16_UNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUShort4Normalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatushort4normalized?language=objc). * @m_keywords{DXGI_FORMAT_R16G16B16A16_UNORM MTLVertexFormatUShort4Normalized} @@ -731,7 +723,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to four-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::Short; - * @val_vk_keyword{FORMAT_R16G16B16A16_SINT,Format}; + * @ref Vk::VertexFormat::Vector4s; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16B16A16_SINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatShort4](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatshort4?language=objc). * @m_keywords{DXGI_FORMAT_R16G16B16A16_SINT MTLVertexFormatShort4} @@ -745,7 +737,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to four-component * @ref GL::DynamicAttribute::Kind::GenericNormalized * @ref GL::DynamicAttribute::DataType::Short; - * @val_vk_keyword{FORMAT_R16G16B16A16_SNORM,Format}; + * @ref Vk::VertexFormat::Vector4sNormalized; * @m_class{m-doc-external} [DXGI_FORMAT_R16G16B16A16_SNORM](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatShort4Normalized](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatshort4normalized?language=objc). * @m_keywords{DXGI_FORMAT_R16G16B16A16_SNORM MTLVertexFormatShort4Normalized} @@ -758,7 +750,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to four-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::UnsignedInt; - * @val_vk_keyword{FORMAT_R32G32B32A16_UINT,Format}; + * @ref Vk::VertexFormat::Vector4ui; * @m_class{m-doc-external} [DXGI_FORMAT_R32G32B32A32_UINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatUInt4](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatuint4?language=objc). * @m_keywords{DXGI_FORMAT_R32G32B32A32_UINT MTLVertexFormatUInt4} @@ -771,7 +763,7 @@ enum class VertexFormat: UnsignedInt { * Corresponds to four-component @ref GL::DynamicAttribute::Kind::Generic * or @ref GL::DynamicAttribute::Kind::Integral * @ref GL::DynamicAttribute::DataType::Int; - * @val_vk_keyword{FORMAT_R32G32B32A32_SINT,Format}; + * @ref Vk::VertexFormat::Vector4i; * @m_class{m-doc-external} [DXGI_FORMAT_R32G32B32A32_SINT](https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) * or @m_class{m-doc-external} [MTLVertexFormatInt4](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatint4?language=objc). * @m_keywords{DXGI_FORMAT_R32G32B32A32_SINT MTLVertexFormatInt4} diff --git a/src/Magnum/Vk/CMakeLists.txt b/src/Magnum/Vk/CMakeLists.txt index 0bf36a08e..579b4cf2a 100644 --- a/src/Magnum/Vk/CMakeLists.txt +++ b/src/Magnum/Vk/CMakeLists.txt @@ -57,7 +57,8 @@ set(MagnumVk_GracefulAssert_SRCS LayerProperties.cpp Memory.cpp PixelFormat.cpp - RenderPass.cpp) + RenderPass.cpp + VertexFormat.cpp) set(MagnumVk_HEADERS Assert.h @@ -98,6 +99,7 @@ set(MagnumVk_HEADERS ShaderCreateInfo.h TypeTraits.h Version.h + VertexFormat.h Vk.h Vulkan.h diff --git a/src/Magnum/Vk/Enums.cpp b/src/Magnum/Vk/Enums.cpp index 07b81db0f..49d076ac7 100644 --- a/src/Magnum/Vk/Enums.cpp +++ b/src/Magnum/Vk/Enums.cpp @@ -29,10 +29,10 @@ #include "Magnum/Mesh.h" #include "Magnum/Sampler.h" -#include "Magnum/VertexFormat.h" #ifdef MAGNUM_BUILD_DEPRECATED #include "Magnum/Vk/PixelFormat.h" +#include "Magnum/Vk/VertexFormat.h" #endif namespace Magnum { namespace Vk { @@ -58,19 +58,6 @@ constexpr VkIndexType IndexTypeMapping[]{ VK_INDEX_TYPE_UINT32 }; -#ifndef DOXYGEN_GENERATING_OUTPUT /* It gets *really* confused */ -static_assert(VK_FORMAT_UNDEFINED == 0, "VK_FORMAT_UNDEFINED is assumed to be 0"); - -constexpr VkFormat VertexFormatMapping[] { - /* GCC 4.8 doesn't like just a {} for default enum values */ - #define _c(input, format) VK_FORMAT_ ## format, - #define _s(input) VkFormat{}, - #include "Magnum/Vk/Implementation/vertexFormatMapping.hpp" - #undef _s - #undef _c -}; -#endif - constexpr VkFilter FilterMapping[]{ VK_FILTER_NEAREST, VK_FILTER_LINEAR @@ -128,16 +115,11 @@ VkIndexType vkIndexType(const Magnum::MeshIndexType type) { return out; } +#ifdef MAGNUM_BUILD_DEPRECATED bool hasVkFormat(const Magnum::VertexFormat format) { - if(isVertexFormatImplementationSpecific(format)) - return true; - - CORRADE_ASSERT(UnsignedInt(format) - 1 < Containers::arraySize(VertexFormatMapping), - "Vk::hasVkFormat(): invalid format" << format, {}); - return UnsignedInt(VertexFormatMapping[UnsignedInt(format) - 1]); + return hasVertexFormat(format); } -#ifdef MAGNUM_BUILD_DEPRECATED bool hasVkFormat(const Magnum::PixelFormat format) { return hasPixelFormat(format); } @@ -147,19 +129,11 @@ bool hasVkFormat(const Magnum::CompressedPixelFormat format) { } #endif +#ifdef MAGNUM_BUILD_DEPRECATED VkFormat vkFormat(const Magnum::VertexFormat format) { - if(isVertexFormatImplementationSpecific(format)) - return vertexFormatUnwrap(format); - - CORRADE_ASSERT(UnsignedInt(format) - 1 < Containers::arraySize(VertexFormatMapping), - "Vk::vkFormat(): invalid format" << format, {}); - const VkFormat out = VertexFormatMapping[UnsignedInt(format) - 1]; - CORRADE_ASSERT(UnsignedInt(out), - "Vk::vkFormat(): unsupported format" << format, {}); - return out; + return VkFormat(vertexFormat(format)); } -#ifdef MAGNUM_BUILD_DEPRECATED VkFormat vkFormat(const Magnum::PixelFormat format) { return VkFormat(pixelFormat(format)); } diff --git a/src/Magnum/Vk/Enums.h b/src/Magnum/Vk/Enums.h index 4475a49d6..2a45f570d 100644 --- a/src/Magnum/Vk/Enums.h +++ b/src/Magnum/Vk/Enums.h @@ -91,27 +91,13 @@ of given index type. */ MAGNUM_VK_EXPORT VkIndexType vkIndexType(Magnum::MeshIndexType type); +#ifdef MAGNUM_BUILD_DEPRECATED /** -@brief Check availability of a generic vertex format -@m_since{2020,06} - -Returns @cpp false @ce if Vulkan doesn't support such format, @cpp true @ce -otherwise. Moreover, returns @cpp true @ce also for all formats that are -@ref isVertexFormatImplementationSpecific(). The @p format value is expected -to be valid. Note that for matrix formats the function only returns a -corresponding vector type, and the user is expected to bind the remaining -vectors to consecutive attribute locations based on what -@ref vertexFormatVectorCount() and @ref vertexFormatVectorStride() return. - -@note Support of some formats depends on presence of a particular Vulkan - extension. Such check is outside of the scope of this function and you are - expected to verify extension availability before using such format. - -@see @ref vkFormat(Magnum::VertexFormat) -*/ -MAGNUM_VK_EXPORT bool hasVkFormat(Magnum::VertexFormat format); + * @brief @copybrief hasVertexFormat() + * @m_deprecated_since_latest Use @ref hasVertexFormat() instead. + */ +CORRADE_DEPRECATED("use hasVertexFormat() instead") MAGNUM_VK_EXPORT bool hasVkFormat(Magnum::VertexFormat format); -#ifdef MAGNUM_BUILD_DEPRECATED /** * @brief @copybrief hasPixelFormat(Magnum::PixelFormat) * @m_deprecated_since_latest Use @ref hasPixelFormat(Magnum::PixelFormat) @@ -127,23 +113,13 @@ CORRADE_DEPRECATED("use hasPixelFormat() instead") MAGNUM_VK_EXPORT bool hasVkFo CORRADE_DEPRECATED("use hasPixelFormat() instead") MAGNUM_VK_EXPORT bool hasVkFormat(Magnum::CompressedPixelFormat format); #endif +#ifdef MAGNUM_BUILD_DEPRECATED /** -@brief Convert a generic vertex format to Vulkan format -@m_since{2020,06} - -In case @ref isVertexFormatImplementationSpecific() returns @cpp false @ce for -@p format, maps it to a corresponding Vulkan format. In case -@ref isVertexFormatImplementationSpecific() returns @cpp true @ce, assumes -@p format stores a Vulkan-specific format and returns @ref vertexFormatUnwrap() -cast to @type_vk{Format}. - -Not all generic vertex formats have a Vulkan equivalent and this function -expects that given format is available. Use @ref hasVkFormat(Magnum::VertexFormat) -to query availability of given format. -*/ -MAGNUM_VK_EXPORT VkFormat vkFormat(Magnum::VertexFormat format); + * @brief @copybrief vertexFormat() + * @m_deprecated_since_latest Use @ref vertexFormat() instead. + */ +CORRADE_DEPRECATED("use vertexFormat() instead") MAGNUM_VK_EXPORT VkFormat vkFormat(Magnum::VertexFormat format); -#ifdef MAGNUM_BUILD_DEPRECATED /** * @brief @copybrief pixelFormat(Magnum::PixelFormat) * @m_deprecated_since_latest Use @ref pixelFormat(Magnum::PixelFormat) diff --git a/src/Magnum/Vk/Implementation/vertexFormatMapping.hpp b/src/Magnum/Vk/Implementation/vertexFormatMapping.hpp index 4082f7d9c..65c8c0603 100644 --- a/src/Magnum/Vk/Implementation/vertexFormatMapping.hpp +++ b/src/Magnum/Vk/Implementation/vertexFormatMapping.hpp @@ -25,113 +25,114 @@ /* See Magnum/Vk/Enums.cpp and Magnum/Vk/Test/EnumsTest.cpp */ #ifdef _c -_c(Float, R32_SFLOAT) -_c(Half, R16_SFLOAT) -_c(Double, R64_SFLOAT) -_c(UnsignedByte, R8_UINT) -_c(UnsignedByteNormalized, R8_UNORM) -_c(Byte, R8_SINT) -_c(ByteNormalized, R8_SNORM) -_c(UnsignedShort, R16_UINT) -_c(UnsignedShortNormalized, R16_UNORM) -_c(Short, R16_SINT) -_c(ShortNormalized, R16_SNORM) -_c(UnsignedInt, R32_UINT) -_c(Int, R32_SINT) -_c(Vector2, R32G32_SFLOAT) -_c(Vector2h, R16G16_SFLOAT) -_c(Vector2d, R64G64_SFLOAT) -_c(Vector2ub, R8G8_UINT) -_c(Vector2ubNormalized, R8G8_UNORM) -_c(Vector2b, R8G8_SINT) -_c(Vector2bNormalized, R8G8_SNORM) -_c(Vector2us, R16G16_UINT) -_c(Vector2usNormalized, R16G16_UNORM) -_c(Vector2s, R16G16_SINT) -_c(Vector2sNormalized, R16G16_SNORM) -_c(Vector2ui, R32G32_UINT) -_c(Vector2i, R32G32_SINT) -_c(Vector3, R32G32B32_SFLOAT) -_c(Vector3h, R16G16B16_SFLOAT) -_c(Vector3d, R64G64B64_SFLOAT) -_c(Vector3ub, R8G8B8_UINT) -_c(Vector3ubNormalized, R8G8B8_UNORM) -_c(Vector3b, R8G8B8_SINT) -_c(Vector3bNormalized, R8G8B8_SNORM) -_c(Vector3us, R16G16B16_UINT) -_c(Vector3usNormalized, R16G16B16_UNORM) -_c(Vector3s, R16G16B16_SINT) -_c(Vector3sNormalized, R16G16B16_SNORM) -_c(Vector3ui, R32G32B32_UINT) -_c(Vector3i, R32G32B32_SINT) -_c(Vector4, R32G32B32A32_SFLOAT) -_c(Vector4h, R16G16B16A16_SFLOAT) -_c(Vector4d, R64G64B64A64_SFLOAT) -_c(Vector4ub, R8G8B8A8_UINT) -_c(Vector4ubNormalized, R8G8B8A8_UNORM) -_c(Vector4b, R8G8B8A8_SINT) -_c(Vector4bNormalized, R8G8B8A8_SNORM) -_c(Vector4us, R16G16B16A16_UINT) -_c(Vector4usNormalized, R16G16B16A16_UNORM) -_c(Vector4s, R16G16B16A16_SINT) -_c(Vector4sNormalized, R16G16B16A16_SNORM) -_c(Vector4ui, R32G32B32A32_UINT) -_c(Vector4i, R32G32B32A32_SINT) -_c(Matrix2x2, R32G32_SFLOAT) -_c(Matrix2x2h, R16G16_SFLOAT) -_c(Matrix2x2d, R64G64_SFLOAT) -_c(Matrix2x2bNormalized, R8G8_SNORM) -_c(Matrix2x2sNormalized, R16G16_SNORM) -_c(Matrix2x3, R32G32B32_SFLOAT) -_c(Matrix2x3h, R16G16B16_SFLOAT) -_c(Matrix2x3d, R64G64B64_SFLOAT) -_c(Matrix2x3bNormalized, R8G8B8_SNORM) -_c(Matrix2x3sNormalized, R16G16B16_SNORM) -_c(Matrix2x4, R32G32B32A32_SFLOAT) -_c(Matrix2x4h, R16G16B16A16_SFLOAT) -_c(Matrix2x4d, R64G64B64A64_SFLOAT) -_c(Matrix2x4bNormalized, R8G8B8A8_SNORM) -_c(Matrix2x4sNormalized, R16G16B16A16_SNORM) -_c(Matrix2x2bNormalizedAligned, R8G8_SNORM) -_c(Matrix2x3hAligned, R16G16B16_SFLOAT) -_c(Matrix2x3bNormalizedAligned, R8G8B8_SNORM) -_c(Matrix2x3sNormalizedAligned, R16G16B16_SNORM) -_c(Matrix3x2, R32G32_SFLOAT) -_c(Matrix3x2h, R16G16_SFLOAT) -_c(Matrix3x2d, R64G64_SFLOAT) -_c(Matrix3x2bNormalized, R8G8_SNORM) -_c(Matrix3x2sNormalized, R16G16_SNORM) -_c(Matrix3x3, R32G32B32_SFLOAT) -_c(Matrix3x3h, R16G16B16_SFLOAT) -_c(Matrix3x3d, R64G64B64_SFLOAT) -_c(Matrix3x3bNormalized, R8G8B8_SNORM) -_c(Matrix3x3sNormalized, R16G16B16_SNORM) -_c(Matrix3x4, R32G32B32A32_SFLOAT) -_c(Matrix3x4h, R16G16B16A16_SFLOAT) -_c(Matrix3x4d, R64G64B64A64_SFLOAT) -_c(Matrix3x4bNormalized, R8G8B8A8_SNORM) -_c(Matrix3x4sNormalized, R16G16B16A16_SNORM) -_c(Matrix3x2bNormalizedAligned, R8G8_SNORM) -_c(Matrix3x3hAligned, R16G16B16_SFLOAT) -_c(Matrix3x3bNormalizedAligned, R8G8B8_SNORM) -_c(Matrix3x3sNormalizedAligned, R16G16B16_SNORM) -_c(Matrix4x2, R32G32_SFLOAT) -_c(Matrix4x2h, R16G16_SFLOAT) -_c(Matrix4x2d, R64G64_SFLOAT) -_c(Matrix4x2bNormalized, R8G8_SNORM) -_c(Matrix4x2sNormalized, R16G16_SNORM) -_c(Matrix4x3, R32G32B32_SFLOAT) -_c(Matrix4x3h, R16G16B16_SFLOAT) -_c(Matrix4x3d, R64G64B64_SFLOAT) -_c(Matrix4x3bNormalized, R8G8B8_SNORM) -_c(Matrix4x3sNormalized, R16G16B16_SNORM) -_c(Matrix4x4, R32G32B32A32_SFLOAT) -_c(Matrix4x4h, R16G16B16A16_SFLOAT) -_c(Matrix4x4d, R64G64B64A64_SFLOAT) -_c(Matrix4x4bNormalized, R8G8B8A8_SNORM) -_c(Matrix4x4sNormalized, R16G16B16A16_SNORM) -_c(Matrix4x2bNormalizedAligned, R8G8_SNORM) -_c(Matrix4x3hAligned, R16G16B16_SFLOAT) -_c(Matrix4x3bNormalizedAligned, R8G8B8_SNORM) -_c(Matrix4x3sNormalizedAligned, R16G16B16_SNORM) +#define _c2(value) _c(value, value) +_c2(Float) +_c2(Half) +_c2(Double) +_c2(UnsignedByte) +_c2(UnsignedByteNormalized) +_c2(Byte) +_c2(ByteNormalized) +_c2(UnsignedShort) +_c2(UnsignedShortNormalized) +_c2(Short) +_c2(ShortNormalized) +_c2(UnsignedInt) +_c2(Int) +_c2(Vector2) +_c2(Vector2h) +_c2(Vector2d) +_c2(Vector2ub) +_c2(Vector2ubNormalized) +_c2(Vector2b) +_c2(Vector2bNormalized) +_c2(Vector2us) +_c2(Vector2usNormalized) +_c2(Vector2s) +_c2(Vector2sNormalized) +_c2(Vector2ui) +_c2(Vector2i) +_c2(Vector3) +_c2(Vector3h) +_c2(Vector3d) +_c2(Vector3ub) +_c2(Vector3ubNormalized) +_c2(Vector3b) +_c2(Vector3bNormalized) +_c2(Vector3us) +_c2(Vector3usNormalized) +_c2(Vector3s) +_c2(Vector3sNormalized) +_c2(Vector3ui) +_c2(Vector3i) +_c2(Vector4) +_c2(Vector4h) +_c2(Vector4d) +_c2(Vector4ub) +_c2(Vector4ubNormalized) +_c2(Vector4b) +_c2(Vector4bNormalized) +_c2(Vector4us) +_c2(Vector4usNormalized) +_c2(Vector4s) +_c2(Vector4sNormalized) +_c2(Vector4ui) +_c2(Vector4i) +_c(Matrix2x2, Vector2) +_c(Matrix2x2h, Vector2h) +_c(Matrix2x2d, Vector2d) +_c(Matrix2x2bNormalized, Vector2bNormalized) +_c(Matrix2x2sNormalized, Vector2sNormalized) +_c(Matrix2x3, Vector3) +_c(Matrix2x3h, Vector3h) +_c(Matrix2x3d, Vector3d) +_c(Matrix2x3bNormalized, Vector3bNormalized) +_c(Matrix2x3sNormalized, Vector3sNormalized) +_c(Matrix2x4, Vector4) +_c(Matrix2x4h, Vector4h) +_c(Matrix2x4d, Vector4d) +_c(Matrix2x4bNormalized, Vector4bNormalized) +_c(Matrix2x4sNormalized, Vector4sNormalized) +_c(Matrix2x2bNormalizedAligned, Vector2bNormalized) +_c(Matrix2x3hAligned, Vector3h) +_c(Matrix2x3bNormalizedAligned, Vector3bNormalized) +_c(Matrix2x3sNormalizedAligned, Vector3sNormalized) +_c(Matrix3x2, Vector2) +_c(Matrix3x2h, Vector2h) +_c(Matrix3x2d, Vector2d) +_c(Matrix3x2bNormalized, Vector2bNormalized) +_c(Matrix3x2sNormalized, Vector2sNormalized) +_c(Matrix3x3, Vector3) +_c(Matrix3x3h, Vector3h) +_c(Matrix3x3d, Vector3d) +_c(Matrix3x3bNormalized, Vector3bNormalized) +_c(Matrix3x3sNormalized, Vector3sNormalized) +_c(Matrix3x4, Vector4) +_c(Matrix3x4h, Vector4h) +_c(Matrix3x4d, Vector4d) +_c(Matrix3x4bNormalized, Vector4bNormalized) +_c(Matrix3x4sNormalized, Vector4sNormalized) +_c(Matrix3x2bNormalizedAligned, Vector2bNormalized) +_c(Matrix3x3hAligned, Vector3h) +_c(Matrix3x3bNormalizedAligned, Vector3bNormalized) +_c(Matrix3x3sNormalizedAligned, Vector3sNormalized) +_c(Matrix4x2, Vector2) +_c(Matrix4x2h, Vector2h) +_c(Matrix4x2d, Vector4d) +_c(Matrix4x2bNormalized, Vector2bNormalized) +_c(Matrix4x2sNormalized, Vector2sNormalized) +_c(Matrix4x3, Vector3) +_c(Matrix4x3h, Vector3h) +_c(Matrix4x3d, Vector3d) +_c(Matrix4x3bNormalized, Vector3bNormalized) +_c(Matrix4x3sNormalized, Vector3sNormalized) +_c(Matrix4x4, Vector4) +_c(Matrix4x4h, Vector4h) +_c(Matrix4x4d, Vector4d) +_c(Matrix4x4bNormalized, Vector4bNormalized) +_c(Matrix4x4sNormalized, Vector4sNormalized) +_c(Matrix4x2bNormalizedAligned, Vector2bNormalized) +_c(Matrix4x3hAligned, Vector3h) +_c(Matrix4x3bNormalizedAligned, Vector3b) +_c(Matrix4x3sNormalizedAligned, Vector3s) #endif diff --git a/src/Magnum/Vk/Test/CMakeLists.txt b/src/Magnum/Vk/Test/CMakeLists.txt index b420c09db..f3135d5c2 100644 --- a/src/Magnum/Vk/Test/CMakeLists.txt +++ b/src/Magnum/Vk/Test/CMakeLists.txt @@ -48,6 +48,7 @@ corrade_add_test(VkQueueTest QueueTest.cpp LIBRARIES MagnumVk) corrade_add_test(VkResultTest ResultTest.cpp LIBRARIES MagnumVk) corrade_add_test(VkRenderPassTest RenderPassTest.cpp LIBRARIES MagnumVkTestLib) corrade_add_test(VkShaderTest ShaderTest.cpp LIBRARIES MagnumVk) +corrade_add_test(VkVertexFormatTest VertexFormatTest.cpp LIBRARIES MagnumVkTestLib) corrade_add_test(VkStructureHelpersTest StructureHelpersTest.cpp) target_include_directories(VkStructureHelpersTest PRIVATE $) @@ -144,6 +145,7 @@ set_target_properties( VkShaderTest VkStructureHelpersTest VkVersionTest + VkVertexFormatTest PROPERTIES FOLDER "Magnum/Vk/Test") if(BUILD_VK_TESTS) diff --git a/src/Magnum/Vk/Test/EnumsTest.cpp b/src/Magnum/Vk/Test/EnumsTest.cpp index 714a70ad8..9b96fe889 100644 --- a/src/Magnum/Vk/Test/EnumsTest.cpp +++ b/src/Magnum/Vk/Test/EnumsTest.cpp @@ -47,11 +47,6 @@ struct EnumsTest: TestSuite::Tester { void mapVkIndexTypeUnsupported(); void mapVkIndexTypeInvalid(); - void mapVkFormatVertexFormat(); - void mapVkFormatVertexFormatImplementationSpecific(); - void mapVkFormatVertexFormatUnsupported(); - void mapVkFormatVertexFormatInvalid(); - void mapVkFilter(); void mapVkFilterInvalid(); @@ -74,11 +69,6 @@ EnumsTest::EnumsTest() { &EnumsTest::mapVkIndexTypeUnsupported, &EnumsTest::mapVkIndexTypeInvalid, - &EnumsTest::mapVkFormatVertexFormat, - &EnumsTest::mapVkFormatVertexFormatImplementationSpecific, - &EnumsTest::mapVkFormatVertexFormatUnsupported, - &EnumsTest::mapVkFormatVertexFormatInvalid, - &EnumsTest::mapVkFilter, &EnumsTest::mapVkFilterInvalid, @@ -243,108 +233,6 @@ void EnumsTest::mapVkIndexTypeInvalid() { "Vk::vkIndexType(): invalid type MeshIndexType(0x12)\n"); } -void EnumsTest::mapVkFormatVertexFormat() { - /* Touchstone verification */ - CORRADE_VERIFY(hasVkFormat(Magnum::VertexFormat::Vector3us)); - CORRADE_COMPARE(vkFormat(Magnum::VertexFormat::Vector3us), VK_FORMAT_R16G16B16_UINT); - CORRADE_COMPARE(vkFormat(Magnum::VertexFormat::Matrix2x3bNormalizedAligned), VK_FORMAT_R8G8B8_SNORM); - - /* This goes through the first 16 bits, which should be enough. Going - through 32 bits takes 8 seconds, too much. */ - UnsignedInt firstUnhandled = 0xffff; - UnsignedInt nextHandled = 1; /* 0 is an invalid format */ - for(UnsignedInt i = 1; i <= 0xffff; ++i) { - const auto format = Magnum::VertexFormat(i); - /* Each case verifies: - - that the entries are ordered by number by comparing a function to - expected result (so insertion here is done in proper place) - - that there was no gap (unhandled value inside the range) - - that a particular vertex format maps to a particular VkFormat */ - #ifdef __GNUC__ - #pragma GCC diagnostic push - #pragma GCC diagnostic error "-Wswitch" - #endif - switch(format) { - #define _c(format, expectedFormat) \ - case Magnum::VertexFormat::format: \ - CORRADE_COMPARE(nextHandled, i); \ - CORRADE_COMPARE(firstUnhandled, 0xffff); \ - CORRADE_VERIFY(hasVkFormat(Magnum::VertexFormat::format)); \ - CORRADE_COMPARE(vkFormat(Magnum::VertexFormat::format), VK_FORMAT_ ## expectedFormat); \ - ++nextHandled; \ - continue; - #define _s(format) \ - case Magnum::VertexFormat::format: { \ - CORRADE_COMPARE(nextHandled, i); \ - CORRADE_COMPARE(firstUnhandled, 0xffff); \ - CORRADE_VERIFY(!hasVkFormat(Magnum::VertexFormat::format)); \ - std::ostringstream out; \ - { /* Redirected otherwise graceful assert would abort */ \ - Error redirectError{&out}; \ - vkFormat(Magnum::VertexFormat::format); \ - } \ - Debug{Debug::Flag::NoNewlineAtTheEnd} << out.str(); \ - ++nextHandled; \ - continue; \ - } - #include "Magnum/Vk/Implementation/vertexFormatMapping.hpp" - #undef _s - #undef _c - } - #ifdef __GNUC__ - #pragma GCC diagnostic pop - #endif - - /* Not handled by any value, remember -- we might either be at the end - of the enum range (which is okay) or some value might be unhandled - here */ - firstUnhandled = i; - } - - CORRADE_COMPARE(firstUnhandled, 0xffff); -} - -void EnumsTest::mapVkFormatVertexFormatImplementationSpecific() { - CORRADE_VERIFY(hasVkFormat(Magnum::vertexFormatWrap(VK_FORMAT_A8B8G8R8_SINT_PACK32))); - CORRADE_COMPARE(vkFormat(Magnum::vertexFormatWrap(VK_FORMAT_A8B8G8R8_SINT_PACK32)), - VK_FORMAT_A8B8G8R8_SINT_PACK32); -} - -void EnumsTest::mapVkFormatVertexFormatUnsupported() { - #ifdef CORRADE_NO_ASSERT - CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); - #endif - - #if 1 - CORRADE_SKIP("All vertex formats are supported."); - #else - std::ostringstream out; - Error redirectError{&out}; - - vkFormat(Magnum::VertexFormat::Vector3d); - CORRADE_COMPARE(out.str(), "Vk::vkFormat(): unsupported format VertexFormat::Vector3d\n"); - #endif -} - -void EnumsTest::mapVkFormatVertexFormatInvalid() { - #ifdef CORRADE_NO_ASSERT - CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); - #endif - - std::ostringstream out; - Error redirectError{&out}; - - hasVkFormat(Magnum::VertexFormat{}); - hasVkFormat(Magnum::VertexFormat(0x123)); - vkFormat(Magnum::VertexFormat{}); - vkFormat(Magnum::VertexFormat(0x123)); - CORRADE_COMPARE(out.str(), - "Vk::hasVkFormat(): invalid format VertexFormat(0x0)\n" - "Vk::hasVkFormat(): invalid format VertexFormat(0x123)\n" - "Vk::vkFormat(): invalid format VertexFormat(0x0)\n" - "Vk::vkFormat(): invalid format VertexFormat(0x123)\n"); -} - void EnumsTest::mapVkFilter() { CORRADE_COMPARE(vkFilter(SamplerFilter::Nearest), VK_FILTER_NEAREST); CORRADE_COMPARE(vkFilter(SamplerFilter::Linear), VK_FILTER_LINEAR); diff --git a/src/Magnum/Vk/Test/VertexFormatTest.cpp b/src/Magnum/Vk/Test/VertexFormatTest.cpp new file mode 100644 index 000000000..e711d6263 --- /dev/null +++ b/src/Magnum/Vk/Test/VertexFormatTest.cpp @@ -0,0 +1,172 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include +#include +#include + +#include "Magnum/VertexFormat.h" +#include "Magnum/Vk/VertexFormat.h" + +namespace Magnum { namespace Vk { namespace Test { namespace { + +struct VertexFormatTest: TestSuite::Tester { + explicit VertexFormatTest(); + + void map(); + void mapImplementationSpecific(); + void mapUnsupported(); + void mapInvalid(); + + void debug(); +}; + +VertexFormatTest::VertexFormatTest() { + addTests({&VertexFormatTest::map, + &VertexFormatTest::mapImplementationSpecific, + &VertexFormatTest::mapUnsupported, + &VertexFormatTest::mapInvalid, + + &VertexFormatTest::debug}); +} + +void VertexFormatTest::map() { + /* Touchstone verification */ + CORRADE_VERIFY(hasVertexFormat(Magnum::VertexFormat::Vector3us)); + CORRADE_COMPARE(vertexFormat(Magnum::VertexFormat::Vector3us), VertexFormat::Vector3us); + CORRADE_COMPARE(vertexFormat(Magnum::VertexFormat::Matrix2x3bNormalizedAligned), VertexFormat::Vector3bNormalized); + + /* This goes through the first 16 bits, which should be enough. Going + through 32 bits takes 8 seconds, too much. */ + UnsignedInt firstUnhandled = 0xffff; + UnsignedInt nextHandled = 1; /* 0 is an invalid format */ + for(UnsignedInt i = 1; i <= 0xffff; ++i) { + const auto format = Magnum::VertexFormat(i); + /* Each case verifies: + - that the entries are ordered by number by comparing a function to + expected result (so insertion here is done in proper place) + - that there was no gap (unhandled value inside the range) + - that a particular generic format maps to a particular format + - that the debug output matches what was converted + */ + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif + switch(format) { + #define _c(input, output) \ + case Magnum::VertexFormat::input: \ + CORRADE_COMPARE(nextHandled, i); \ + CORRADE_COMPARE(firstUnhandled, 0xffff); \ + CORRADE_VERIFY(hasVertexFormat(Magnum::VertexFormat::input)); \ + CORRADE_COMPARE(vertexFormat(Magnum::VertexFormat::input), VertexFormat::output); \ + { \ + std::ostringstream out; \ + Debug{&out} << vertexFormat(Magnum::VertexFormat::input); \ + CORRADE_COMPARE(out.str(), "Vk::VertexFormat::" #output "\n"); \ + } \ + ++nextHandled; \ + continue; + #define _s(format) \ + case Magnum::VertexFormat::format: { \ + CORRADE_COMPARE(nextHandled, i); \ + CORRADE_COMPARE(firstUnhandled, 0xffff); \ + CORRADE_VERIFY(!hasVertexFormat(Magnum::VertexFormat::format)); \ + std::ostringstream out; \ + { /* Redirected otherwise graceful assert would abort */ \ + Error redirectError{&out}; \ + vertexFormat(Magnum::VertexFormat::format); \ + } \ + Debug{Debug::Flag::NoNewlineAtTheEnd} << out.str(); \ + ++nextHandled; \ + continue; \ + } + #include "Magnum/Vk/Implementation/vertexFormatMapping.hpp" + #undef _s + #undef _c + } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif + + /* Not handled by any value, remember -- we might either be at the end + of the enum range (which is okay) or some value might be unhandled + here */ + firstUnhandled = i; + } + + CORRADE_COMPARE(firstUnhandled, 0xffff); +} + +void VertexFormatTest::mapImplementationSpecific() { + CORRADE_VERIFY(hasVertexFormat(Magnum::vertexFormatWrap(VK_FORMAT_A8B8G8R8_SINT_PACK32))); + CORRADE_COMPARE(vertexFormat(Magnum::vertexFormatWrap(VK_FORMAT_A8B8G8R8_SINT_PACK32)), + VertexFormat(VK_FORMAT_A8B8G8R8_SINT_PACK32)); +} + +void VertexFormatTest::mapUnsupported() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + #if 1 + CORRADE_SKIP("All vertex formats are supported."); + #else + std::ostringstream out; + Error redirectError{&out}; + + vertexFormat(Magnum::VertexFormat::Vector3d); + CORRADE_COMPARE(out.str(), "Vk::vertexFormat(): unsupported format VertexFormat::Vector3d\n"); + #endif +} + +void VertexFormatTest::mapInvalid() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + std::ostringstream out; + Error redirectError{&out}; + + hasVertexFormat(Magnum::VertexFormat{}); + hasVertexFormat(Magnum::VertexFormat(0x123)); + vertexFormat(Magnum::VertexFormat{}); + vertexFormat(Magnum::VertexFormat(0x123)); + CORRADE_COMPARE(out.str(), + "Vk::hasVertexFormat(): invalid format VertexFormat(0x0)\n" + "Vk::hasVertexFormat(): invalid format VertexFormat(0x123)\n" + "Vk::vertexFormat(): invalid format VertexFormat(0x0)\n" + "Vk::vertexFormat(): invalid format VertexFormat(0x123)\n"); +} + +void VertexFormatTest::debug() { + std::ostringstream out; + Debug{&out} << VertexFormat::Vector2usNormalized << VertexFormat(-10007655); + CORRADE_COMPARE(out.str(), "Vk::VertexFormat::Vector2usNormalized Vk::VertexFormat(-10007655)\n"); +} + +}}}} + +CORRADE_TEST_MAIN(Magnum::Vk::Test::VertexFormatTest) diff --git a/src/Magnum/Vk/VertexFormat.cpp b/src/Magnum/Vk/VertexFormat.cpp new file mode 100644 index 000000000..30df6228e --- /dev/null +++ b/src/Magnum/Vk/VertexFormat.cpp @@ -0,0 +1,137 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "VertexFormat.h" + +#include +#include + +#include "Magnum/VertexFormat.h" + +namespace Magnum { namespace Vk { + +namespace { + +#ifndef DOXYGEN_GENERATING_OUTPUT /* It gets *really* confused */ +constexpr VertexFormat VertexFormatMapping[] { + /* GCC 4.8 doesn't like just a {} for default enum values */ + #define _c(input, output) VertexFormat::output, + #define _s(input) VertexFormat{}, + #include "Magnum/Vk/Implementation/vertexFormatMapping.hpp" + #undef _s + #undef _c +}; +#endif + +} + +Debug& operator<<(Debug& debug, const VertexFormat value) { + debug << "Vk::VertexFormat" << Debug::nospace; + + switch(value) { + /* LCOV_EXCL_START */ + #define _c(value) case Vk::VertexFormat::value: return debug << "::" << Debug::nospace << #value; + _c(Float) + _c(Half) + _c(Double) + _c(UnsignedByte) + _c(UnsignedByteNormalized) + _c(Byte) + _c(ByteNormalized) + _c(UnsignedShort) + _c(UnsignedShortNormalized) + _c(Short) + _c(ShortNormalized) + _c(UnsignedInt) + _c(Int) + _c(Vector2) + _c(Vector2h) + _c(Vector2d) + _c(Vector2ub) + _c(Vector2ubNormalized) + _c(Vector2b) + _c(Vector2bNormalized) + _c(Vector2us) + _c(Vector2usNormalized) + _c(Vector2s) + _c(Vector2sNormalized) + _c(Vector2ui) + _c(Vector2i) + _c(Vector3) + _c(Vector3h) + _c(Vector3d) + _c(Vector3ub) + _c(Vector3ubNormalized) + _c(Vector3b) + _c(Vector3bNormalized) + _c(Vector3us) + _c(Vector3usNormalized) + _c(Vector3s) + _c(Vector3sNormalized) + _c(Vector3ui) + _c(Vector3i) + _c(Vector4) + _c(Vector4h) + _c(Vector4d) + _c(Vector4ub) + _c(Vector4ubNormalized) + _c(Vector4b) + _c(Vector4bNormalized) + _c(Vector4us) + _c(Vector4usNormalized) + _c(Vector4s) + _c(Vector4sNormalized) + _c(Vector4ui) + _c(Vector4i) + #undef _c + /* LCOV_EXCL_STOP */ + } + + /* Vulkan docs have the values in decimal, so not converting to hex */ + return debug << "(" << Debug::nospace << Int(value) << Debug::nospace << ")"; +} + +bool hasVertexFormat(const Magnum::VertexFormat format) { + if(isVertexFormatImplementationSpecific(format)) + return true; + + CORRADE_ASSERT(UnsignedInt(format) - 1 < Containers::arraySize(VertexFormatMapping), + "Vk::hasVertexFormat(): invalid format" << format, {}); + return UnsignedInt(VertexFormatMapping[UnsignedInt(format) - 1]); +} + +VertexFormat vertexFormat(const Magnum::VertexFormat format) { + if(isVertexFormatImplementationSpecific(format)) + return vertexFormatUnwrap(format); + + CORRADE_ASSERT(UnsignedInt(format) - 1 < Containers::arraySize(VertexFormatMapping), + "Vk::vertexFormat(): invalid format" << format, {}); + const VertexFormat out = VertexFormatMapping[UnsignedInt(format) - 1]; + CORRADE_ASSERT(UnsignedInt(out), + "Vk::vertexFormat(): unsupported format" << format, {}); + return out; +} + +}} diff --git a/src/Magnum/Vk/VertexFormat.h b/src/Magnum/Vk/VertexFormat.h new file mode 100644 index 000000000..6aaae1243 --- /dev/null +++ b/src/Magnum/Vk/VertexFormat.h @@ -0,0 +1,371 @@ +#ifndef Magnum_Vk_VertexFormat_h +#define Magnum_Vk_VertexFormat_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "Magnum/Magnum.h" +#include "Magnum/Vk/Vulkan.h" +#include "Magnum/Vk/visibility.h" + +/** @file + * @brief Enum @ref Magnum::Vk::VertexFormat, function @ref Magnum::Vk::hasVertexFormat(), @ref Magnum::Vk::vertexFormat() + * @m_since_latest + */ + +namespace Magnum { namespace Vk { + +/** +@brief Vertex format +@m_since_latest + +Wraps a subset of @type_vk_keyword{Format} that's usable as a vertex format. +Unless said otherwise (mostly in case of 8- and 16-bit three-component +formats and doubles), all formats are guaranteed to be supported by the spec. + +@m_enum_values_as_keywords + +@see @ref Magnum::VertexFormat, @ref hasVertexFormat(), @ref vertexFormat() +*/ +enum class VertexFormat: Int { + /** @ref Magnum::Float "Float" */ + Float = VK_FORMAT_R32_SFLOAT, + + /** @ref Magnum::Half "Half" */ + Half = VK_FORMAT_R16_SFLOAT, + + /** + * @ref Magnum::Double "Double". + * + * Compared to @ref VertexFormat::Float, this format is not guaranteed to + * be supported. + */ + Double = VK_FORMAT_R64_SFLOAT, + + /** @ref Magnum::UnsignedByte "UnsignedByte" */ + UnsignedByte = VK_FORMAT_R8_UINT, + + /** + * @ref Magnum::UnsignedByte "UnsignedByte", with range @f$ [0, 255] @f$ + * interpreted as @f$ [0.0, 1.0] @f$. + */ + UnsignedByteNormalized = VK_FORMAT_R8_UNORM, + + /** @ref Magnum::Byte "Byte" */ + Byte = VK_FORMAT_R8_SINT, + + /** + * @ref Magnum::Byte "Byte", with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + */ + ByteNormalized = VK_FORMAT_R8_SNORM, + + /** @ref Magnum::UnsignedShort "UnsignedShort" */ + UnsignedShort = VK_FORMAT_R16_UINT, + + /** + * @ref Magnum::UnsignedShort "UnsignedShort", with range + * @f$ [0, 65535] @f$ interpreted as @f$ [0.0, 1.0] @f$. + */ + UnsignedShortNormalized = VK_FORMAT_R16_UNORM, + + /** @ref Magnum::Short "Short" */ + Short = VK_FORMAT_R16_SINT, + + /** + * @ref Magnum::Short "Short", with range @f$ [-32767, 32767] @f$ + * interpreted as @f$ [-1.0, 1.0] @f$. + */ + ShortNormalized = VK_FORMAT_R16_SNORM, + + /** @ref Magnum::UnsignedInt "UnsignedInt" */ + UnsignedInt = VK_FORMAT_R32_UINT, + + /** @ref Magnum::Int "Int" */ + Int = VK_FORMAT_R32_SINT, + + /** @ref Magnum::Vector2 "Vector2" */ + Vector2 = VK_FORMAT_R32G32_SFLOAT, + + /** @ref Magnum::Vector2h "Vector2h" */ + Vector2h = VK_FORMAT_R16G16_SFLOAT, + + /** + * @ref Magnum::Vector2d "Vector2d". + * + * Compared to @ref VertexFormat::Vector2, this format is not guaranteed to + * be supported. + */ + Vector2d = VK_FORMAT_R64G64_SFLOAT, + + /** @ref Magnum::Vector2ub "Vector2ub" */ + Vector2ub = VK_FORMAT_R8G8_UINT, + + /** + * @ref Magnum::Vector2ub "Vector2ub", with range @f$ [0, 255] @f$ + * interpreted as @f$ [0.0, 1.0] @f$. + */ + Vector2ubNormalized = VK_FORMAT_R8G8_UNORM, + + /** @ref Magnum::Vector2b "Vector2b" */ + Vector2b = VK_FORMAT_R8G8_SINT, + + /** + * @ref Magnum::Vector2b "Vector2b", with range @f$ [-127, 127] @f$ + * interpreted as @f$ [-1.0, 1.0] @f$. + */ + Vector2bNormalized = VK_FORMAT_R8G8_SNORM, + + /** @ref Magnum::Vector2us "Vector2us" */ + Vector2us = VK_FORMAT_R16G16_UINT, + + /** + * @ref Magnum::Vector2us "Vector2us", with range @f$ [0, 65535] @f$ + * interpreted as @f$ [0.0, 1.0] @f$. + */ + Vector2usNormalized = VK_FORMAT_R16G16_UNORM, + + /** @ref Magnum::Vector2s "Vector2s" */ + Vector2s = VK_FORMAT_R16G16_SINT, + + /** + * @ref Magnum::Vector2s "Vector2s", with range @f$ [-32767, 32767] @f$ + * interpreted as @f$ [-1.0, 1.0] @f$. + */ + Vector2sNormalized = VK_FORMAT_R16G16_SNORM, + + /** @ref Magnum::Vector2ui "Vector2ui" */ + Vector2ui = VK_FORMAT_R32G32_UINT, + + /** @ref Magnum::Vector2i "Vector2i" */ + Vector2i = VK_FORMAT_R32G32_SINT, + + /** @ref Magnum::Vector3 "Vector3" or @ref Magnum::Color3 "Color3" */ + Vector3 = VK_FORMAT_R32G32B32_SFLOAT, + + /** + * @ref Magnum::Vector3h "Vector3h" or @ref Magnum::Color3h "Color3h". + * + * Compared to @ref VertexFormat::Vector3 or @ref VertexFormat::Vector2h / + * @ref VertexFormat::Vector4h, this format is not guaranteed to be + * supported. + */ + Vector3h = VK_FORMAT_R16G16B16_SFLOAT, + + /** + * @ref Magnum::Vector3d "Vector3d". + * + * Compared to @ref VertexFormat::Vector3, this format is not guaranteed to + * be supported. + */ + Vector3d = VK_FORMAT_R64G64B64_SFLOAT, + + /** + * @ref Magnum::Vector3ub "Vector3ub". + * + * Compared to @ref VertexFormat::Vector3ui or @ref VertexFormat::Vector2ub + * / @ref VertexFormat::Vector4ub, this format is not guaranteed to be + * supported. + */ + Vector3ub = VK_FORMAT_R8G8B8_UINT, + + /** + * @ref Magnum::Vector3ub "Vector3ub" or @ref Magnum::Color3ub "Color3ub", + * with range @f$ [0, 255] @f$ interpreted as @f$ [0.0, 1.0] @f$. + * + * Compared to @ref VertexFormat::Vector3 or + * @ref VertexFormat..Vector2ubNormalized / + * @ref VertexFormat::Vector4ubNormalized, this format is not guaranteed to + * be supported. + */ + Vector3ubNormalized = VK_FORMAT_R8G8B8_UNORM, + + /** + * @ref Magnum::Vector3b "Vector3b". + * + * Compared to @ref VertexFormat::Vector3i or @ref VertexFormat::Vector2b / + * @ref VertexFormat::Vector4b, this format is not guaranteed to be + * supported. + */ + Vector3b = VK_FORMAT_R8G8B8_SINT, + + /** + * @ref Magnum::Vector3b "Vector3b", with range @f$ [-127, 127] @f$ + * )interpreted as @f$ [-1.0, 1.0] @f$. + * + * Compared to @ref VertexFormat::Vector3 or + * @ref VertexFormat::Vector2bNormalized / + * @ref VertexFormat::Vector4bNormalized, this format is not guaranteed to + * be supported. + */ + Vector3bNormalized = VK_FORMAT_R8G8B8_SNORM, + + /** + * @ref Magnum::Vector3us "Vector3us". + * + * Compared to @ref VertexFormat::Vector3ui or @ref VertexFormat::Vector2us + * / @ref VertexFormat::Vector4us, this format is not guaranteed to be + * supported. + */ + Vector3us = VK_FORMAT_R16G16B16_UINT, + + /** + * @ref Magnum::Vector3us "Vector3us" or @ref Magnum::Color3us "Color3us", + * with range @f$ [0, 65535] @f$ interpreted as @f$ [0.0, 1.0] @f$. + * + * Compared to @ref VertexFormat::Vector3 or + * @ref VertexFormat::Vector3usNormalized / + * @ref VertexFormat::Vector4usNormalized, this format is not guaranteed to + * be supported. + */ + Vector3usNormalized = VK_FORMAT_R16G16B16_UNORM, + + /** + * @ref Magnum::Vector3s "Vector3s". + * + * Compared to @ref VertexFormat::Vector3i or @ref VertexFormat::Vector2b / + * @ref VertexFormat::Vector4b, this format is not guaranteed to be + * supported. + */ + Vector3s = VK_FORMAT_R16G16B16_SINT, + + /** + * @ref Magnum::Vector3s "Vector3s", with range @f$ [-32767, 32767] @f$ + * interpreted as @f$ [-1.0, 1.0] @f$. + * + * Compared to @ref VertexFormat::Vector3 or + * @ref VertexFormat::Vector3sNormalized / + * @ref VertexFormat::Vector4sNormalized, this format is not guaranteed to + * be supported. + */ + Vector3sNormalized = VK_FORMAT_R16G16B16_SNORM, + + /** @ref Magnum::Vector3ui "Vector3ui" */ + Vector3ui = VK_FORMAT_R32G32B32_UINT, + + /** @ref Magnum::Vector3i "Vector3i" */ + Vector3i = VK_FORMAT_R32G32B32_SINT, + + /** @ref Magnum::Vector4 "Vector4" or @ref Magnum::Color4 "Color4" */ + Vector4 = VK_FORMAT_R32G32B32A32_SFLOAT, + + /** @ref Magnum::Vector4h "Vector4h" or @ref Magnum::Color4h "Color4h" */ + Vector4h = VK_FORMAT_R16G16B16A16_SFLOAT, + + /** + * @ref Magnum::Vector4d "Vector4d". + * + * Compared to @ref VertexFormat::Vector4, this format is not guaranteed to + * be supported. + */ + Vector4d = VK_FORMAT_R64G64B64A64_SFLOAT, + + /** @ref Magnum::Vector4ub "Vector4ub" */ + Vector4ub = VK_FORMAT_R8G8B8A8_UINT, + + /** + * @ref Magnum::Vector4ub "Vector4ub" or @ref Magnum::Color4ub "Color4ub", + * with range @f$ [0, 255] @f$ interpreted as @f$ [0.0, 1.0] @f$. + */ + Vector4ubNormalized = VK_FORMAT_R8G8B8A8_UNORM, + + /** @ref Magnum::Vector4b "Vector4b" */ + Vector4b = VK_FORMAT_R8G8B8A8_SINT, + + /** + * @ref Magnum::Vector4b "Vector4b", with range @f$ [-127, 127] @f$ + * interpreted as @f$ [-1.0, 1.0] @f$. + */ + Vector4bNormalized = VK_FORMAT_R8G8B8A8_SNORM, + + /** @ref Magnum::Vector4us "Vector4us" */ + Vector4us = VK_FORMAT_R16G16B16A16_UINT, + + /** + * @ref Magnum::Vector4us "Vector4us" or @ref Magnum::Color4us "Color4us", + * with range @f$ [0, 65535] @f$ interpreted as @f$ [0.0, 1.0] @f$. + */ + Vector4usNormalized = VK_FORMAT_R16G16B16A16_UNORM, + + /** @ref Magnum::Vector4s "Vector4s" */ + Vector4s = VK_FORMAT_R16G16B16A16_SINT, + + /** + * @ref Magnum::Vector4s "Vector4s", with range @f$ [-32767, 32767] @f$ + * interpreted as @f$ [-1.0, 1.0] @f$. + */ + Vector4sNormalized = VK_FORMAT_R16G16B16A16_SNORM, + + /** @ref Magnum::Vector4ui "Vector4ui" */ + Vector4ui = VK_FORMAT_R32G32B32A32_UINT, + + /** @ref Magnum::Vector4i "Vector4i" */ + Vector4i = VK_FORMAT_R32G32B32A32_SINT, +}; + +/** +@debugoperatorenum{VertexFormat} +@m_since_latest +*/ +MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, VertexFormat value); + +/** +@brief Check availability of a generic vertex format +@m_since_latest + +Returns @cpp false @ce if Vulkan doesn't support such format, @cpp true @ce +otherwise. Moreover, returns @cpp true @ce also for all formats that are +@ref isVertexFormatImplementationSpecific(). The @p format value is expected +to be valid. Note that for matrix formats the function only returns a +corresponding vector type, and the user is expected to bind the remaining +vectors to consecutive attribute locations based on what +@ref vertexFormatVectorCount() and @ref vertexFormatVectorStride() return. + +@note Support of some formats depends on presence of a particular Vulkan + extension. Such check is outside of the scope of this function and you are + expected to verify extension availability before using such format. + +@see @ref vertexFormat() +*/ +MAGNUM_VK_EXPORT bool hasVertexFormat(Magnum::VertexFormat format); + +/** +@brief Convert a generic vertex format to Vulkan vertex format +@m_since_latest + +In case @ref isVertexFormatImplementationSpecific() returns @cpp false @ce for +@p format, maps it to a corresponding Vulkan format. In case +@ref isVertexFormatImplementationSpecific() returns @cpp true @ce, assumes +@p format stores a Vulkan-specific format and returns @ref vertexFormatUnwrap() +cast to @ref VertexFormat. + +Not all generic vertex formats have a Vulkan equivalent and this function +expects that given format is available. Use @ref hasVertexFormat() to query +availability of given format. +*/ +MAGNUM_VK_EXPORT VertexFormat vertexFormat(Magnum::VertexFormat format); + +}} + +#endif diff --git a/src/Magnum/Vk/Vk.h b/src/Magnum/Vk/Vk.h index 0b4967cac..7e0a9a481 100644 --- a/src/Magnum/Vk/Vk.h +++ b/src/Magnum/Vk/Vk.h @@ -113,6 +113,7 @@ class SubmitInfo; class SubpassBeginInfo; class SubpassEndInfo; enum class Version: UnsignedInt; +enum class VertexFormat: Int; #endif }}