Browse Source

Vk: expose VK_IMAGE_LAYOUT, finally.

I was pretending to ignore it until now, but it's just easier to expose
it. All newly gained knowledge is now put in the enum docs.
pull/491/head
Vladimír Vondruš 6 years ago
parent
commit
1579a89e47
  1. 13
      src/Magnum/Vk/Image.cpp
  2. 252
      src/Magnum/Vk/Image.h
  3. 2
      src/Magnum/Vk/Test/ImageTest.cpp
  4. 1
      src/Magnum/Vk/Vk.h

13
src/Magnum/Vk/Image.cpp

@ -34,7 +34,7 @@
namespace Magnum { namespace Vk { namespace Magnum { namespace Vk {
ImageCreateInfo::ImageCreateInfo(const VkImageType type, const ImageUsages usages, const VkFormat format, const Vector3i& size, const Int layers, const Int levels, const Int samples, const Flags flags): _info{} { ImageCreateInfo::ImageCreateInfo(const VkImageType type, const ImageUsages usages, const VkFormat format, const Vector3i& size, const Int layers, const Int levels, const Int samples, const ImageLayout initialLayout, const Flags flags): _info{} {
_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; _info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
_info.flags = VkImageCreateFlags(flags); _info.flags = VkImageCreateFlags(flags);
_info.imageType = type; _info.imageType = type;
@ -48,16 +48,7 @@ ImageCreateInfo::ImageCreateInfo(const VkImageType type, const ImageUsages usage
/* _info.sharingMode is implicitly VK_SHARING_MODE_EXCLUSIVE; /* _info.sharingMode is implicitly VK_SHARING_MODE_EXCLUSIVE;
_info.queueFamilyIndexCount and _info.pQueueFamilyIndices should be _info.queueFamilyIndexCount and _info.pQueueFamilyIndices should be
filled only for VK_SHARING_MODE_CONCURRENT */ filled only for VK_SHARING_MODE_CONCURRENT */
/* _info.initialLayout is implicitly VK_IMAGE_LAYOUT_UNDEFINED. The only _info.initialLayout = VkImageLayout(initialLayout);
other possible value is VK_IMAGE_LAYOUT_PREDEFINED, which however also
needs VK_IMAGE_TILING_LINEAR, one sample and possibly other restrictions
-- https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkImageCreateInfo.html#_description
Such images need to be allocated from host-visible memory which on
discrete GPUs is not fast for device access and thus is recommended to
go through a staging buffer (not image) instead. This is however still
useful for iGPUs, as the the memory is shared and this avoid an
expensive extra copy. */
} }
ImageCreateInfo::ImageCreateInfo(NoInitT) noexcept {} ImageCreateInfo::ImageCreateInfo(NoInitT) noexcept {}

252
src/Magnum/Vk/Image.h

@ -26,7 +26,7 @@
*/ */
/** @file /** @file
* @brief Class @ref Magnum::Vk::ImageCreateInfo, @ref Magnum::Vk::ImageCreateInfo1D, @ref Magnum::Vk::ImageCreateInfo2D, @ref Magnum::Vk::ImageCreateInfo3D, @ref Magnum::Vk::ImageCreateInfo1DArray, @ref Magnum::Vk::ImageCreateInfo2DArray, @ref Magnum::Vk::ImageCreateInfoCubeMap, @ref Magnum::Vk::ImageCreateInfoCubeMapArray, @ref Magnum::Vk::Image, enum @ref Magnum::Vk::ImageUsage, enum set @ref Magnum::Vk::ImageUsages * @brief Class @ref Magnum::Vk::ImageCreateInfo, @ref Magnum::Vk::ImageCreateInfo1D, @ref Magnum::Vk::ImageCreateInfo2D, @ref Magnum::Vk::ImageCreateInfo3D, @ref Magnum::Vk::ImageCreateInfo1DArray, @ref Magnum::Vk::ImageCreateInfo2DArray, @ref Magnum::Vk::ImageCreateInfoCubeMap, @ref Magnum::Vk::ImageCreateInfoCubeMapArray, @ref Magnum::Vk::Image, enum @ref Magnum::Vk::ImageLayout, @ref Magnum::Vk::ImageUsage, enum set @ref Magnum::Vk::ImageUsages
* @m_since_latest * @m_since_latest
*/ */
@ -53,28 +53,52 @@ Wraps a @type_vk_keyword{ImageUsageFlagBits}.
@m_enum_values_as_keywords @m_enum_values_as_keywords
*/ */
enum class ImageUsage: UnsignedInt { enum class ImageUsage: UnsignedInt {
/** Source of a transfer command */ /**
* Source of a transfer command
*
* @see @ref ImageLayout::TransferSource
*/
TransferSource = VK_IMAGE_USAGE_TRANSFER_SRC_BIT, TransferSource = VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
/** Destination of a transfer command */ /**
* Destination of a transfer command
*
* @see @ref ImageLayout::TransferDestination
*/
TransferDestination = VK_IMAGE_USAGE_TRANSFER_DST_BIT, TransferDestination = VK_IMAGE_USAGE_TRANSFER_DST_BIT,
/** Sampled by a shader */ /**
* Sampled by a shader
*
* @see @ref ImageLayout::ShaderReadOnly
*/
Sampled = VK_IMAGE_USAGE_SAMPLED_BIT, Sampled = VK_IMAGE_USAGE_SAMPLED_BIT,
/** Shader storage */ /** Shader storage */
Storage = VK_IMAGE_USAGE_STORAGE_BIT, Storage = VK_IMAGE_USAGE_STORAGE_BIT,
/** Color attachment */ /**
* Color attachment
*
* @see @ref ImageLayout::ColorAttachment
*/
ColorAttachment = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, ColorAttachment = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
/** Depth/stencil attachment */ /**
* Depth/stencil attachment
*
* @see @ref ImageLayout::DepthStencilAttachment
*/
DepthStencilAttachment = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, DepthStencilAttachment = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
/** Transient attachment */ /** Transient attachment */
TransientAttachment = VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, TransientAttachment = VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT,
/** Input attachment in a shader or framebuffer */ /**
* Input attachment in a shader or framebuffer
*
* @see @ref ImageLayout::ShaderReadOnly
*/
InputAttachment = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT InputAttachment = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
}; };
@ -89,6 +113,114 @@ typedef Containers::EnumSet<ImageUsage> ImageUsages;
CORRADE_ENUMSET_OPERATORS(ImageUsages) CORRADE_ENUMSET_OPERATORS(ImageUsages)
/**
@brief Image layout
@m_since_latest
@see @ref ImageCreateInfo
@m_enum_values_as_keywords
*/
enum class ImageLayout: Int {
/**
* Undefined. Can only be used as the initial layout in
* @ref ImageCreateInfo structures (and there it's the default). Images in
* this layout are not accessible by the device, the image has to be
* transitioned to a defined layout such as @ref ImageLayout::General
* first; contents of the memory are not guaranteed to be preserved during
* the transition.
* @see @ref ImageLayout::Preinitialized
*/
Undefined = VK_IMAGE_LAYOUT_UNDEFINED,
/**
* Preinitialized. Can only be used as the initial layout in
* @ref ImageCreateInfo structures. Compared to
* @ref ImageLayout::Undefined, contents of the memory are guaranteed to be
* preserved during a transition to a defined layout and thus this layout
* is intended for populating image contents by the host.
*
* Usable only for images created with
* @val_vk{IMAGE_TILING_LINEAR,ImageTiling}, usually with just one sample
* and possibly other restrictions.
*
* @m_class{m-note m-success}
*
* @par
* In order to be populated from the host, such images need to be
* allocated from @ref MemoryFlag::HostVisible memory, which on
* discrete GPUs is not fast for device access and there's thus
* recommended to go through a staging buffer instead. For integrated
* GPUs however, going directly through a linear preinitialized image
* *might* be better to avoid a memory usage spike and a potentially
* expensive copy.
*/
Preinitialized = VK_IMAGE_LAYOUT_PREINITIALIZED,
/**
* General layout, supports all types of device access. This is the
* conservative default used everywhere except the @ref ImageCreateInfo
* structures, which uses @ref ImageLayout::Undefined.
*
* @m_class{m-note m-success}
*
* @par
* While this layout will always work, it's recommended to pick a
* stricter layout where appropriate, as it may result in better
* performance.
*/
General = VK_IMAGE_LAYOUT_GENERAL,
/* The _OPTIMAL suffixes are dropped because it doesn't seem that there
would be any _UNOPTIMAL or whatever variants anytime soon, so this is
redundant. If that time comes, we can always deprecate and rename. */
/**
* Layout optimal for a color or resolve attachment, not guaranteed to be
* usable for anything else.
*
* Only valid for images created with @ref ImageUsage::ColorAttachment.
*/
ColorAttachment = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
/**
* Layout optimal for a read/write depth/stencil attachment, not guaranteed
* to be usable for anything else.
*
* Only valid for images created with
* @ref ImageUsage::DepthStencilAttachment.
*/
DepthStencilAttachment = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
/**
* Layout optimal for read-only access in a shader sampler, combined
* image/sampler or input attachment; not guaranteed to be usable for
* anything else.
*
* Only valid for images created with @ref ImageUsage::Sampled or
* @ref ImageUsage::InputAttachment.
*/
ShaderReadOnly = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
/**
* Layout optimal for transfer sources; not guaranteed to be usable for
* anything else.
*
* Only valid for images created with @ref ImageUsage::TransferSource.
*/
TransferSource = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
/**
* Layout optimal for transfer destination; not guaranteed to be usable for
* anything else.
*
* Only valid for images created with @ref ImageUsage::TransferDestination.
*/
TransferDestination = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
/** @todo remaining ones from @vk_extension{KHR,maintenance2} (1.1),
@vk_extension{KHR,separate_depth_stencil_layouts} (1.2) */
};
/** /**
@brief Image creation info @brief Image creation info
@m_since_latest @m_since_latest
@ -105,7 +237,7 @@ class MAGNUM_VK_EXPORT ImageCreateInfo {
* @brief Image creation flag * @brief Image creation flag
* *
* Wraps @type_vk_keyword{ImageCreateFlagBits}. * Wraps @type_vk_keyword{ImageCreateFlagBits}.
* @see @ref Flags, @ref ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, Flags) * @see @ref Flags, @ref ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, ImageLayout, Flags)
* @m_enum_values_as_keywords * @m_enum_values_as_keywords
*/ */
enum class Flag: UnsignedInt { enum class Flag: UnsignedInt {
@ -128,7 +260,7 @@ class MAGNUM_VK_EXPORT ImageCreateInfo {
* @brief Image creation flags * @brief Image creation flags
* *
* Type-safe wrapper for @type_vk_keyword{ImageCreateFlags}. * Type-safe wrapper for @type_vk_keyword{ImageCreateFlags}.
* @see @ref ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, Flags), * @see @ref ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, ImageLayout, Flags),
* @ref ImageCreateInfo1D, @ref ImageCreateInfo2D, * @ref ImageCreateInfo1D, @ref ImageCreateInfo2D,
* @ref ImageCreateInfo3D, @ref ImageCreateInfo1DArray, * @ref ImageCreateInfo3D, @ref ImageCreateInfo1DArray,
* @ref ImageCreateInfo2DArray, @ref ImageCreateInfoCubeMap, * @ref ImageCreateInfo2DArray, @ref ImageCreateInfoCubeMap,
@ -138,14 +270,17 @@ class MAGNUM_VK_EXPORT ImageCreateInfo {
/** /**
* @brief Constructor * @brief Constructor
* @param type Image type * @param type Image type
* @param usages Desired image usage. At least one flag is required. * @param usages Desired image usage. At least one flag is
* @param format Image format * required.
* @param size Image size * @param format Image format
* @param layers Array layer count * @param size Image size
* @param levels Mip level count * @param layers Array layer count
* @param samples Sample count * @param levels Mip level count
* @param flags Image creation flags * @param samples Sample count
* @param initialLayout Initial layout. Can be only either
* @ref ImageLayout::Undefined or @ref ImageLayout::Preinitialized.
* @param flags Image creation flags
* *
* The following @type_vk{ImageCreateInfo} fields are pre-filled in * The following @type_vk{ImageCreateInfo} fields are pre-filled in
* addition to `sType`, everything else is zero-filled: * addition to `sType`, everything else is zero-filled:
@ -160,7 +295,7 @@ class MAGNUM_VK_EXPORT ImageCreateInfo {
* - `tiling` to @val_vk{IMAGE_TILING_OPTIMAL,ImageTiling} * - `tiling` to @val_vk{IMAGE_TILING_OPTIMAL,ImageTiling}
* - `usage` to @p usages * - `usage` to @p usages
* - `sharingMode` to @val_vk{SHARING_MODE_EXCLUSIVE,SharingMode} * - `sharingMode` to @val_vk{SHARING_MODE_EXCLUSIVE,SharingMode}
* - `initialLayout` to @val_vk{IMAGE_LAYOUT_UNDEFINED,ImageLayout} * - `initialLayout` to @p initialLayout
* *
* There are various restrictions on @p size, @p layers, @p levels for * There are various restrictions on @p size, @p layers, @p levels for
* a particular @p type --- for common image types you're encouraged to * a particular @p type --- for common image types you're encouraged to
@ -170,7 +305,9 @@ class MAGNUM_VK_EXPORT ImageCreateInfo {
* @ref ImageCreateInfoCubeMapArray convenience classes instead of * @ref ImageCreateInfoCubeMapArray convenience classes instead of
* this constructor. * this constructor.
*/ */
explicit ImageCreateInfo(VkImageType type, ImageUsages usages, VkFormat format, const Vector3i& size, Int layers, Int levels, Int samples = 1, Flags flags = {}); explicit ImageCreateInfo(VkImageType type, ImageUsages usages, VkFormat format, const Vector3i& size, Int layers, Int levels, Int samples = 1, ImageLayout initialLayout = ImageLayout::Undefined, Flags flags = {});
/* No overload w/o initialLayout here as the general public is expected
to use the convenience classes anyway */
/** /**
* @brief Construct without initializing the contents * @brief Construct without initializing the contents
@ -215,13 +352,20 @@ Compared to the base @ref ImageCreateInfo constructor creates an image of type
`layers` set to @cpp 1 @ce. `layers` set to @cpp 1 @ce.
Note that same as with the Note that same as with the
@ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, Flags) @ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, ImageLayout, Flags)
constructor, at least one @ref ImageUsage value is required. constructor, at least one @ref ImageUsage value is required.
*/ */
class ImageCreateInfo1D: public ImageCreateInfo { class ImageCreateInfo1D: public ImageCreateInfo {
public: public:
/** @brief Constructor */ /** @brief Constructor */
explicit ImageCreateInfo1D(ImageUsages usages, VkFormat format, Int size, Int levels, Int samples = 1, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_1D, usages, format, {size, 1, 1}, 1, levels, samples, flags} {} explicit ImageCreateInfo1D(ImageUsages usages, VkFormat format, Int size, Int levels, Int samples = 1, ImageLayout initialLayout = ImageLayout::Undefined, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_1D, usages, format, {size, 1, 1}, 1, levels, samples, initialLayout, flags} {}
/** @overload
*
* Equivalent to the above with @p initialLayout set to
* @ref ImageLayout::Undefined.
*/
explicit ImageCreateInfo1D(ImageUsages usages, VkFormat format, Int size, Int levels, Int samples, Flags flags): ImageCreateInfo1D{usages, format, size, levels, samples, ImageLayout::Undefined, flags} {}
}; };
/** /**
@ -233,13 +377,20 @@ Compared to the base @ref ImageCreateInfo constructor creates an image of type
set to @cpp 1 @ce. set to @cpp 1 @ce.
Note that same as with the Note that same as with the
@ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, Flags) @ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, ImageLayout, Flags)
constructor, at least one @ref ImageUsage value is required. constructor, at least one @ref ImageUsage value is required.
*/ */
class ImageCreateInfo2D: public ImageCreateInfo { class ImageCreateInfo2D: public ImageCreateInfo {
public: public:
/** @brief Constructor */ /** @brief Constructor */
explicit ImageCreateInfo2D(ImageUsages usages, VkFormat format, const Vector2i& size, Int levels, Int samples = 1, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_2D, usages, format, {size, 1}, 1, levels, samples, flags} {} explicit ImageCreateInfo2D(ImageUsages usages, VkFormat format, const Vector2i& size, Int levels, Int samples = 1, ImageLayout initialLayout = ImageLayout::Undefined, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_2D, usages, format, {size, 1}, 1, levels, samples, initialLayout, flags} {}
/** @overload
*
* Equivalent to the above with @p initialLayout set to
* @ref ImageLayout::Undefined.
*/
explicit ImageCreateInfo2D(ImageUsages usages, VkFormat format, const Vector2i& size, Int levels, Int samples, Flags flags): ImageCreateInfo2D{usages, format, size, levels, samples, ImageLayout::Undefined, flags} {}
}; };
/** /**
@ -250,13 +401,20 @@ Compared to the base @ref ImageCreateInfo constructor creates an image of type
@val_vk{IMAGE_TYPE_3D,ImageType} with `layers` set to @cpp 1 @ce. @val_vk{IMAGE_TYPE_3D,ImageType} with `layers` set to @cpp 1 @ce.
Note that same as with the Note that same as with the
@ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, Flags) @ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, ImageLayout, Flags)
constructor, at least one @ref ImageUsage value is required. constructor, at least one @ref ImageUsage value is required.
*/ */
class ImageCreateInfo3D: public ImageCreateInfo { class ImageCreateInfo3D: public ImageCreateInfo {
public: public:
/** @brief Constructor */ /** @brief Constructor */
explicit ImageCreateInfo3D(ImageUsages usages, VkFormat format, const Vector3i& size, Int levels, Int samples = 1, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_3D, usages, format, size, 1, levels, samples, flags} {} explicit ImageCreateInfo3D(ImageUsages usages, VkFormat format, const Vector3i& size, Int levels, Int samples = 1, ImageLayout initialLayout = ImageLayout::Undefined, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_3D, usages, format, size, 1, levels, samples, initialLayout, flags} {}
/** @overload
*
* Equivalent to the above with @p initialLayout set to
* @ref ImageLayout::Undefined.
*/
explicit ImageCreateInfo3D(ImageUsages usages, VkFormat format, const Vector3i& size, Int levels, Int samples, Flags flags): ImageCreateInfo3D{usages, format, size, levels, samples, ImageLayout::Undefined, flags} {}
}; };
/** /**
@ -268,13 +426,20 @@ Compared to the base @ref ImageCreateInfo constructor creates an image of type
@cpp 1 @ce and `layers` set to @cpp size.y() @ce. @cpp 1 @ce and `layers` set to @cpp size.y() @ce.
Note that same as with the Note that same as with the
@ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, Flags) @ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, ImageLayout, Flags)
constructor, at least one @ref ImageUsage value is required. constructor, at least one @ref ImageUsage value is required.
*/ */
class ImageCreateInfo1DArray: public ImageCreateInfo { class ImageCreateInfo1DArray: public ImageCreateInfo {
public: public:
/** @brief Constructor */ /** @brief Constructor */
explicit ImageCreateInfo1DArray(ImageUsages usages, VkFormat format, const Vector2i& size, Int levels, Int samples = 1, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_1D, usages, format, {size.x(), 1, 1}, size.y(), levels, samples, flags} {} explicit ImageCreateInfo1DArray(ImageUsages usages, VkFormat format, const Vector2i& size, Int levels, Int samples = 1, ImageLayout initialLayout = ImageLayout::Undefined, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_1D, usages, format, {size.x(), 1, 1}, size.y(), levels, samples, initialLayout, flags} {}
/** @overload
*
* Equivalent to the above with @p initialLayout set to
* @ref ImageLayout::Undefined.
*/
explicit ImageCreateInfo1DArray(ImageUsages usages, VkFormat format, const Vector2i& size, Int levels, Int samples, Flags flags): ImageCreateInfo1DArray{usages, format, size, levels, samples, ImageLayout::Undefined, flags} {}
}; };
/** /**
@ -286,13 +451,20 @@ Compared to the base @ref ImageCreateInfo constructor creates an image of type
@cpp 1 @ce and `layers` set to @cpp size.z() @ce. @cpp 1 @ce and `layers` set to @cpp size.z() @ce.
Note that same as with the Note that same as with the
@ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, Flags) @ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, ImageLayout, Flags)
constructor, at least one @ref ImageUsage value is required. constructor, at least one @ref ImageUsage value is required.
*/ */
class ImageCreateInfo2DArray: public ImageCreateInfo { class ImageCreateInfo2DArray: public ImageCreateInfo {
public: public:
/** @brief Constructor */ /** @brief Constructor */
explicit ImageCreateInfo2DArray(ImageUsages usages, VkFormat format, const Vector3i& size, Int levels, Int samples = 1, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_2D, usages, format, {size.xy(), 1}, size.z(), levels, samples, flags} {} explicit ImageCreateInfo2DArray(ImageUsages usages, VkFormat format, const Vector3i& size, Int levels, Int samples = 1, ImageLayout initialLayout = ImageLayout::Undefined, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_2D, usages, format, {size.xy(), 1}, size.z(), levels, samples, initialLayout, flags} {}
/** @overload
*
* Equivalent to the above with @p initialLayout set to
* @ref ImageLayout::Undefined.
*/
explicit ImageCreateInfo2DArray(ImageUsages usages, VkFormat format, const Vector3i& size, Int levels, Int samples, Flags flags): ImageCreateInfo2DArray{usages, format, size, levels, samples, ImageLayout::Undefined, flags} {}
}; };
/** /**
@ -305,13 +477,20 @@ Compared to the base @ref ImageCreateInfo constructor creates an image of type
@ref Flag::CubeCompatible. @ref Flag::CubeCompatible.
Note that same as with the Note that same as with the
@ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, Flags) @ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, ImageLayout, Flags)
constructor, at least one @ref ImageUsage value is required. constructor, at least one @ref ImageUsage value is required.
*/ */
class ImageCreateInfoCubeMap: public ImageCreateInfo { class ImageCreateInfoCubeMap: public ImageCreateInfo {
public: public:
/** @brief Constructor */ /** @brief Constructor */
explicit ImageCreateInfoCubeMap(ImageUsages usages, VkFormat format, const Vector2i& size, Int levels, Int samples = 1, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_2D, usages, format, {size, 1}, 6, levels, samples, flags|Flag::CubeCompatible} {} explicit ImageCreateInfoCubeMap(ImageUsages usages, VkFormat format, const Vector2i& size, Int levels, Int samples = 1, ImageLayout initialLayout = ImageLayout::Undefined, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_2D, usages, format, {size, 1}, 6, levels, samples, initialLayout, flags|Flag::CubeCompatible} {}
/** @overload
*
* Equivalent to the above with @p initialLayout set to
* @ref ImageLayout::Undefined.
*/
explicit ImageCreateInfoCubeMap(ImageUsages usages, VkFormat format, const Vector2i& size, Int levels, Int samples, Flags flags): ImageCreateInfoCubeMap{usages, format, size, levels, samples, ImageLayout::Undefined, flags} {}
}; };
/** /**
@ -324,13 +503,20 @@ Compared to the base @ref ImageCreateInfo constructor creates an image of type
@ref Flag::CubeCompatible. @ref Flag::CubeCompatible.
Note that same as with the Note that same as with the
@ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, Flags) @ref ImageCreateInfo::ImageCreateInfo(VkImageType, ImageUsages, VkFormat, const Vector3i&, Int, Int, Int, ImageLayout, Flags)
constructor, at least one @ref ImageUsage value is required. constructor, at least one @ref ImageUsage value is required.
*/ */
class ImageCreateInfoCubeMapArray: public ImageCreateInfo { class ImageCreateInfoCubeMapArray: public ImageCreateInfo {
public: public:
/** @brief Constructor */ /** @brief Constructor */
explicit ImageCreateInfoCubeMapArray(ImageUsages usages, VkFormat format, const Vector3i& size, Int levels, Int samples = 1, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_2D, usages, format, {size.xy(), 1}, size.z(), levels, samples, flags|Flag::CubeCompatible} {} explicit ImageCreateInfoCubeMapArray(ImageUsages usages, VkFormat format, const Vector3i& size, Int levels, Int samples = 1, ImageLayout initialLayout = ImageLayout::Undefined, Flags flags = {}): ImageCreateInfo{VK_IMAGE_TYPE_2D, usages, format, {size.xy(), 1}, size.z(), levels, samples, initialLayout, flags|Flag::CubeCompatible} {}
/** @overload
*
* Equivalent to the above with @p initialLayout set to
* @ref ImageLayout::Undefined.
*/
explicit ImageCreateInfoCubeMapArray(ImageUsages usages, VkFormat format, const Vector3i& size, Int levels, Int samples, Flags flags): ImageCreateInfoCubeMapArray{usages, format, size, levels, samples, ImageLayout::Undefined, flags} {}
}; };
/** /**

2
src/Magnum/Vk/Test/ImageTest.cpp

@ -72,7 +72,7 @@ ImageTest::ImageTest() {
} }
void ImageTest::createInfoConstruct() { void ImageTest::createInfoConstruct() {
ImageCreateInfo info{VK_IMAGE_TYPE_2D, ImageUsage::Sampled, VK_FORMAT_R8G8B8A8_UNORM, {256, 128, 1}, 6, 8, 16, ImageCreateInfo::Flag::CubeCompatible}; ImageCreateInfo info{VK_IMAGE_TYPE_2D, ImageUsage::Sampled, VK_FORMAT_R8G8B8A8_UNORM, {256, 128, 1}, 6, 8, 16, ImageLayout::Undefined, ImageCreateInfo::Flag::CubeCompatible};
CORRADE_COMPARE(info->flags, VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT); CORRADE_COMPARE(info->flags, VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT);
CORRADE_COMPARE(info->imageType, VK_IMAGE_TYPE_2D); CORRADE_COMPARE(info->imageType, VK_IMAGE_TYPE_2D);
CORRADE_COMPARE(info->format, VK_FORMAT_R8G8B8A8_UNORM); CORRADE_COMPARE(info->format, VK_FORMAT_R8G8B8A8_UNORM);

1
src/Magnum/Vk/Vk.h

@ -47,6 +47,7 @@ class Extension;
class ExtensionProperties; class ExtensionProperties;
enum class HandleFlag: UnsignedByte; enum class HandleFlag: UnsignedByte;
typedef Containers::EnumSet<HandleFlag> HandleFlags; typedef Containers::EnumSet<HandleFlag> HandleFlags;
enum class ImageLayout: Int;
class Image; class Image;
class Instance; class Instance;
class InstanceCreateInfo; class InstanceCreateInfo;

Loading…
Cancel
Save