Browse Source

Vk: port away from std::pair in remaining APIs.

As usual, Corrade/Containers/PairStl.h is included for backwards
compatibility. Since both cases are constructors I don't expect many
breakages.
pull/617/head
Vladimír Vondruš 3 years ago
parent
commit
9a089ad2cf
  1. 10
      doc/changelog.dox
  2. 12
      src/Magnum/Vk/DescriptorPool.cpp
  3. 10
      src/Magnum/Vk/DescriptorPoolCreateInfo.h
  4. 14
      src/Magnum/Vk/RenderPass.cpp
  5. 14
      src/Magnum/Vk/RenderPassCreateInfo.h

10
doc/changelog.dox

@ -1304,10 +1304,14 @@ See also:
@ref GL::Buffer::setLabel() "setLabel()" APIs now work with a
@relativeref{Corrade,Containers::StringView} /
@relativeref{Corrade,Containers::String} instead of a @ref std::string
- @ref Vk::DescriptorPoolCreateInfo and @ref Vk::AttachmentDescription
APIs now take a @relativeref{Corrade,Containers::Pair} instead of a
@ref std::pair
To handle most backwards compatibility, @ref Corrade/Containers/StringStl.h
is included in affected headers for implicit conversions from/to a
@ref std::string, but in some cases you may be forced to change the code
that uses those APIs.
and/or @ref Corrade/Containers/PairStl.h is included in affected headers
for implicit conversions from/to a @ref std::string and/or @ref std::pair,
but in some cases you may be forced to change the code that uses those
APIs.
- @ref Image, @ref ImageView and @ref Trade::ImageData now look for a
@cpp pixelFormatSize() @ce API via ADL instead of @cpp pixelSize() @ce. In
case you were passing a custom pixel format enum to the image classes, you

12
src/Magnum/Vk/DescriptorPool.cpp

@ -38,7 +38,7 @@
namespace Magnum { namespace Vk {
DescriptorPoolCreateInfo::DescriptorPoolCreateInfo(const UnsignedInt maxSets, const Containers::ArrayView<const std::pair<DescriptorType, UnsignedInt>> poolSizes, const Flags flags): _info{} {
DescriptorPoolCreateInfo::DescriptorPoolCreateInfo(const UnsignedInt maxSets, const Containers::ArrayView<const Containers::Pair<DescriptorType, UnsignedInt>> poolSizes, const Flags flags): _info{} {
CORRADE_ASSERT(maxSets,
"Vk::DescriptorPoolCreateInfo: there has to be at least one set", );
/* On certain compilers, {} (empty initializer list) gets converted to an
@ -52,10 +52,10 @@ DescriptorPoolCreateInfo::DescriptorPoolCreateInfo(const UnsignedInt maxSets, co
{NoInit, poolSizes.size(), poolSizesCopy}
};
for(std::size_t i = 0; i != poolSizes.size(); ++i) {
CORRADE_ASSERT(poolSizes[i].second,
"Vk::DescriptorPoolCreateInfo: pool" << i << "of" << poolSizes[i].first << "has no descriptors", );
poolSizesCopy[i].type = VkDescriptorType(poolSizes[i].first);
poolSizesCopy[i].descriptorCount = poolSizes[i].second;
CORRADE_ASSERT(poolSizes[i].second(),
"Vk::DescriptorPoolCreateInfo: pool" << i << "of" << poolSizes[i].first() << "has no descriptors", );
poolSizesCopy[i].type = VkDescriptorType(poolSizes[i].first());
poolSizesCopy[i].descriptorCount = poolSizes[i].second();
}
_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
@ -65,7 +65,7 @@ DescriptorPoolCreateInfo::DescriptorPoolCreateInfo(const UnsignedInt maxSets, co
_info.pPoolSizes = poolSizesCopy;
}
DescriptorPoolCreateInfo::DescriptorPoolCreateInfo(const UnsignedInt maxSets, const std::initializer_list<std::pair<DescriptorType, UnsignedInt>> poolSizes, const Flags flags): DescriptorPoolCreateInfo{maxSets, Containers::arrayView(poolSizes), flags} {}
DescriptorPoolCreateInfo::DescriptorPoolCreateInfo(const UnsignedInt maxSets, const std::initializer_list<Containers::Pair<DescriptorType, UnsignedInt>> poolSizes, const Flags flags): DescriptorPoolCreateInfo{maxSets, Containers::arrayView(poolSizes), flags} {}
DescriptorPoolCreateInfo::DescriptorPoolCreateInfo(NoInitT) noexcept {}

10
src/Magnum/Vk/DescriptorPoolCreateInfo.h

@ -30,7 +30,6 @@
* @m_since_latest
*/
#include <utility>
#include <Corrade/Containers/ArrayTuple.h>
#include <Corrade/Containers/EnumSet.h>
@ -40,6 +39,11 @@
#include "Magnum/Vk/Vk.h"
#include "Magnum/Vk/Vulkan.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* DescriptorPoolCreateInfo constructors used to take a std::pair */
#include <Corrade/Containers/PairStl.h>
#endif
namespace Magnum { namespace Vk {
/**
@ -126,9 +130,9 @@ class MAGNUM_VK_EXPORT DescriptorPoolCreateInfo {
* - `poolSizeCount` and `pPoolSizes` to @p poolSizes converted to
* a list of @type_vk{DescriptorPoolSize} structures
*/
explicit DescriptorPoolCreateInfo(UnsignedInt maxSets, Containers::ArrayView<const std::pair<DescriptorType, UnsignedInt>> poolSizes, Flags flags = {});
explicit DescriptorPoolCreateInfo(UnsignedInt maxSets, Containers::ArrayView<const Containers::Pair<DescriptorType, UnsignedInt>> poolSizes, Flags flags = {});
/** @overload */
explicit DescriptorPoolCreateInfo(UnsignedInt maxSets, std::initializer_list<std::pair<DescriptorType, UnsignedInt>> poolSizes, Flags flags = {});
explicit DescriptorPoolCreateInfo(UnsignedInt maxSets, std::initializer_list<Containers::Pair<DescriptorType, UnsignedInt>> poolSizes, Flags flags = {});
/**
* @brief Construct without initializing the contents

14
src/Magnum/Vk/RenderPass.cpp

@ -59,22 +59,22 @@ AttachmentDescription::AttachmentDescription(const Magnum::PixelFormat format, c
AttachmentDescription::AttachmentDescription(const Magnum::CompressedPixelFormat format, const AttachmentLoadOperation loadOperation, const AttachmentStoreOperation storeOperation, const ImageLayout initialLayout, const ImageLayout finalLayout, const Int samples, const Flags flags): AttachmentDescription{pixelFormat(format), loadOperation, storeOperation, initialLayout, finalLayout, samples, flags} {}
AttachmentDescription::AttachmentDescription(const PixelFormat format, const std::pair<AttachmentLoadOperation, AttachmentLoadOperation> depthStencilLoadOperation, const std::pair<AttachmentStoreOperation, AttachmentStoreOperation> depthStencilStoreOperation, const ImageLayout initialLayout, const ImageLayout finalLayout, const Int samples, const Flags flags): _description{} {
AttachmentDescription::AttachmentDescription(const PixelFormat format, const Containers::Pair<AttachmentLoadOperation, AttachmentLoadOperation> depthStencilLoadOperation, const Containers::Pair<AttachmentStoreOperation, AttachmentStoreOperation> depthStencilStoreOperation, const ImageLayout initialLayout, const ImageLayout finalLayout, const Int samples, const Flags flags): _description{} {
_description.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2;
_description.flags = VkAttachmentDescriptionFlags(flags);
_description.format = VkFormat(format);
_description.samples = VkSampleCountFlagBits(samples);
_description.loadOp = VkAttachmentLoadOp(depthStencilLoadOperation.first);
_description.storeOp = VkAttachmentStoreOp(depthStencilStoreOperation.first);
_description.stencilLoadOp = VkAttachmentLoadOp(depthStencilLoadOperation.second);
_description.stencilStoreOp = VkAttachmentStoreOp(depthStencilStoreOperation.second);
_description.loadOp = VkAttachmentLoadOp(depthStencilLoadOperation.first());
_description.storeOp = VkAttachmentStoreOp(depthStencilStoreOperation.first());
_description.stencilLoadOp = VkAttachmentLoadOp(depthStencilLoadOperation.second());
_description.stencilStoreOp = VkAttachmentStoreOp(depthStencilStoreOperation.second());
_description.initialLayout = VkImageLayout(initialLayout);
_description.finalLayout = VkImageLayout(finalLayout);
}
AttachmentDescription::AttachmentDescription(const Magnum::PixelFormat format, const std::pair<AttachmentLoadOperation, AttachmentLoadOperation> depthStencilLoadOperation, const std::pair<AttachmentStoreOperation, AttachmentStoreOperation> depthStencilStoreOperation, const ImageLayout initialLayout, const ImageLayout finalLayout, const Int samples, const Flags flags): AttachmentDescription{pixelFormat(format), depthStencilLoadOperation, depthStencilStoreOperation, initialLayout, finalLayout, samples, flags} {}
AttachmentDescription::AttachmentDescription(const Magnum::PixelFormat format, const Containers::Pair<AttachmentLoadOperation, AttachmentLoadOperation> depthStencilLoadOperation, const Containers::Pair<AttachmentStoreOperation, AttachmentStoreOperation> depthStencilStoreOperation, const ImageLayout initialLayout, const ImageLayout finalLayout, const Int samples, const Flags flags): AttachmentDescription{pixelFormat(format), depthStencilLoadOperation, depthStencilStoreOperation, initialLayout, finalLayout, samples, flags} {}
AttachmentDescription::AttachmentDescription(const Magnum::CompressedPixelFormat format, const std::pair<AttachmentLoadOperation, AttachmentLoadOperation> depthStencilLoadOperation, const std::pair<AttachmentStoreOperation, AttachmentStoreOperation> depthStencilStoreOperation, const ImageLayout initialLayout, const ImageLayout finalLayout, const Int samples, const Flags flags): AttachmentDescription{pixelFormat(format), depthStencilLoadOperation, depthStencilStoreOperation, initialLayout, finalLayout, samples, flags} {}
AttachmentDescription::AttachmentDescription(const Magnum::CompressedPixelFormat format, const Containers::Pair<AttachmentLoadOperation, AttachmentLoadOperation> depthStencilLoadOperation, const Containers::Pair<AttachmentStoreOperation, AttachmentStoreOperation> depthStencilStoreOperation, const ImageLayout initialLayout, const ImageLayout finalLayout, const Int samples, const Flags flags): AttachmentDescription{pixelFormat(format), depthStencilLoadOperation, depthStencilStoreOperation, initialLayout, finalLayout, samples, flags} {}
AttachmentDescription::AttachmentDescription(NoInitT) noexcept {}

14
src/Magnum/Vk/RenderPassCreateInfo.h

@ -30,7 +30,6 @@
* @m_since_latest
*/
#include <utility>
#include <Corrade/Containers/EnumSet.h>
#include <Corrade/Containers/Pointer.h>
@ -40,6 +39,11 @@
#include "Magnum/Vk/Vulkan.h"
#include "Magnum/Vk/visibility.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* AttachmentDescription constructors used to take a std::pair */
#include <Corrade/Containers/PairStl.h>
#endif
namespace Magnum { namespace Vk {
/**
@ -201,7 +205,7 @@ class MAGNUM_VK_EXPORT AttachmentDescription {
* - `initialLayout`
* - `finalLayout`
*
* See also @ref AttachmentDescription(PixelFormat, std::pair<AttachmentLoadOperation, AttachmentLoadOperation>, std::pair<AttachmentStoreOperation, AttachmentStoreOperation>, ImageLayout, ImageLayout, Int, Flags)
* See also @ref AttachmentDescription(PixelFormat, Containers::Pair<AttachmentLoadOperation, AttachmentLoadOperation>, Containers::Pair<AttachmentStoreOperation, AttachmentStoreOperation>, ImageLayout, ImageLayout, Int, Flags)
* for a constructing a combined depth/stencil attachment description.
*/
/* These were implicit at first, but I realized code gets way too
@ -250,11 +254,11 @@ class MAGNUM_VK_EXPORT AttachmentDescription {
*/
/* These were implicit at first, but I realized code gets way too
confusing with all the {{}} so it's not anymore */
explicit AttachmentDescription(PixelFormat format, std::pair<AttachmentLoadOperation, AttachmentLoadOperation> depthStencilLoadOperation, std::pair<AttachmentStoreOperation, AttachmentStoreOperation> depthStencilStoreOperation, ImageLayout initialLayout, ImageLayout finalLayout, Int samples = 1, Flags flags = {});
explicit AttachmentDescription(PixelFormat format, Containers::Pair<AttachmentLoadOperation, AttachmentLoadOperation> depthStencilLoadOperation, Containers::Pair<AttachmentStoreOperation, AttachmentStoreOperation> depthStencilStoreOperation, ImageLayout initialLayout, ImageLayout finalLayout, Int samples = 1, Flags flags = {});
/** @overload */
explicit AttachmentDescription(Magnum::PixelFormat format, std::pair<AttachmentLoadOperation, AttachmentLoadOperation> depthStencilLoadOperation, std::pair<AttachmentStoreOperation, AttachmentStoreOperation> depthStencilStoreOperation, ImageLayout initialLayout, ImageLayout finalLayout, Int samples = 1, Flags flags = {});
explicit AttachmentDescription(Magnum::PixelFormat format, Containers::Pair<AttachmentLoadOperation, AttachmentLoadOperation> depthStencilLoadOperation, Containers::Pair<AttachmentStoreOperation, AttachmentStoreOperation> depthStencilStoreOperation, ImageLayout initialLayout, ImageLayout finalLayout, Int samples = 1, Flags flags = {});
/** @overload */
explicit AttachmentDescription(Magnum::CompressedPixelFormat format, std::pair<AttachmentLoadOperation, AttachmentLoadOperation> depthStencilLoadOperation, std::pair<AttachmentStoreOperation, AttachmentStoreOperation> depthStencilStoreOperation, ImageLayout initialLayout, ImageLayout finalLayout, Int samples = 1, Flags flags = {});
explicit AttachmentDescription(Magnum::CompressedPixelFormat format, Containers::Pair<AttachmentLoadOperation, AttachmentLoadOperation> depthStencilLoadOperation, Containers::Pair<AttachmentStoreOperation, AttachmentStoreOperation> depthStencilStoreOperation, ImageLayout initialLayout, ImageLayout finalLayout, Int samples = 1, Flags flags = {});
/**
* @brief Construct without initializing the contents

Loading…
Cancel
Save