From 57785601af0208d30264be21aff7def2a0d22799 Mon Sep 17 00:00:00 2001 From: Martin Hammerchmidt Date: Thu, 6 Aug 2020 13:47:50 +0200 Subject: [PATCH 1/4] Update README.md Fix a few typo on 2 examples (didn't check more examples) --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6421e65..0ff5bc2 100644 --- a/README.md +++ b/README.md @@ -98,22 +98,22 @@ Especially the first one is hard to detect. Vulkan-Hpp provides constructors for all CreateInfo objects which accept one parameter for each member variable. This way the compiler throws a compiler error if a value has been forgotten. In addition to this `sType` is automatically filled with the correct value and `pNext` set to a `nullptr` by default. Here's how the same code looks with a constructor: ```c++ -vk::ImageCreateInfo ci({}, vk::ImageType::e2D, vk::format::eR8G8B8A8Unorm, +vk::ImageCreateInfo ci({}, vk::ImageType::e2D, vk::Format::eR8G8B8A8Unorm, { width, height, 1 }, - 1, 1, vk::SampleCount::e1, - vk::ImageTiling::eOptimal, vk::ImageUsage:eColorAttachment, - vk::SharingMode::eExclusive, 0, 0, vk::Imagelayout::eUndefined); + 1, 1, vk::SampleCountFlagBits::e1, + vk::ImageTiling::eOptimal, vk::ImageUsageFlagBit::eColorAttachment, + vk::SharingMode::eExclusive, 0, nullptr, vk::ImageLayout::eUndefined); vk::Image image = device.createImage(ci); ``` With constructors for CreateInfo structures one can also pass temporaries to Vulkan functions like this: ```c++ -vk::Image image = device.createImage({{}, vk::ImageType::e2D, vk::format::eR8G8B8A8Unorm, +vk::Image image = device.createImage({{}, vk::ImageType::e2D, vk::Format::eR8G8B8A8Unorm, { width, height, 1 }, - 1, 1, vk::SampleCount::e1, - vk::ImageTiling::eOptimal, vk::ImageUsage:eColorAttachment, - vk::SharingMode::eExclusive, 0, 0, vk::Imagelayout::eUndefined}); + 1, 1, vk::SampleCountFlagBits::e1, + vk::ImageTiling::eOptimal, vk::ImageUsageFlagBits::eColorAttachment, + vk::SharingMode::eExclusive, 0, nullptr, vk::ImageLayout::eUndefined}); ``` ### Designated Initializers From 85f049ba74b00344a9f708cbda2378b9c03e6362 Mon Sep 17 00:00:00 2001 From: Martin Hammerchmidt Date: Thu, 6 Aug 2020 14:11:03 +0200 Subject: [PATCH 2/4] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0ff5bc2..571f4cc 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ vk::Image image = device.createImage({{}, vk::ImageType::e2D, vk::Format::eR8G8B ### Designated Initializers Beginning with C++20, C++ supports designated initializers. As that feature requires to not have any user-declared or inherited constructors, you have to `#define VULKAN_HPP_NO_STRUCT_CONSTRUCTORS`, which removes all the structure constructors from vulkan.hpp. Instead you can then use aggregate initialization. The first few vk-lines in your source might then look like -``` +```c++ // initialize the vk::ApplicationInfo structure vk::ApplicationInfo applicationInfo{ .pApplicationName = AppName, .applicationVersion = 1, @@ -131,7 +131,7 @@ vk::ApplicationInfo applicationInfo{ .pApplicationName = AppName, vk::InstanceCreateInfo instanceCreateInfo{ .pApplicationInfo = & applicationInfo }; ``` instead of -``` +```c++ // initialize the vk::ApplicationInfo structure vk::ApplicationInfo applicationInfo( AppName, 1, EngineName, 1, VK_API_VERSION_1_1 ); @@ -188,7 +188,7 @@ Vulkan-Hpp generates references for pointers to structs. This conversion allows ```c++ // C -VkImageSubResource subResource; +VkImageSubresource subResource; subResource.aspectMask = 0; subResource.mipLevel = 0; subResource.arrayLayer = 0; @@ -203,7 +203,7 @@ auto layout = device.getImageSubresourceLayout(image, { {} /* flags*/, 0 /* mipl Vulkan allows chaining of structures through the pNext pointer. Vulkan-Hpp has a variadic template class which allows constructing of such structure chains with minimal efforts. In addition to this it checks at compile time if the spec allows the construction of such a `pNext` chain. -``` +```c++ // This will compile successfully. vk::StructureChain c; vk::MemoryAllocateInfo &allocInfo = c.get(); @@ -229,7 +229,7 @@ In case that very same structure has to be re-added to the StructureChain again, Sometimes the user has to pass a preallocated structure chain to query information. For those cases there are two corresponding getter functions. One with a variadic template generating a structure chain of at least two elements to construct the return value: -``` +```c++ // Query vk::MemoryRequirements2HR and vk::MemoryDedicatedRequirementsKHR when calling Device::getBufferMemoryRequirements2KHR: auto result = device.getBufferMemoryRequirements2KHR({}); vk::MemoryRequirements2KHR &memReqs = result.get(); From dd2bcdf71909d8f322a2571b5ae42c001e85ad1d Mon Sep 17 00:00:00 2001 From: Martin Hammerchmidt Date: Thu, 6 Aug 2020 14:13:03 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 571f4cc..2387954 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ If the program clang-format is found by CMake, the define CLANG_FORMAT_EXECUTABL To avoid name collisions with the Vulkan C API the C++ bindings reside in the vk namespace. The following rules apply to the new naming * All functions, enums, handles, and structs have the Vk prefix removed. In addition to this the first letter of functions is lower case. - * `vkCreateImage` can be accessed as `vk::createImage` + * `vkCreateInstance` can be accessed as `vk::createInstance` * `VkImageTiling` can be accessed as `vk::ImageTiling` * `VkImageCreateInfo` can be accessed as `vk::ImageCreateInfo` * Enums are mapped to scoped enums to provide compile time type safety. The names have been changed to 'e' + CamelCase with the VK_ prefix and type infix removed. In case the enum type is an extension the extension suffix has been removed from the enum values. From 67cedbb531e1a4c1f81e238c8e64367e90036edf Mon Sep 17 00:00:00 2001 From: Martin Hammerchmidt Date: Mon, 10 Aug 2020 11:04:26 +0200 Subject: [PATCH 4/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2387954..737cf6d 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Vulkan-Hpp provides constructors for all CreateInfo objects which accept one par vk::ImageCreateInfo ci({}, vk::ImageType::e2D, vk::Format::eR8G8B8A8Unorm, { width, height, 1 }, 1, 1, vk::SampleCountFlagBits::e1, - vk::ImageTiling::eOptimal, vk::ImageUsageFlagBit::eColorAttachment, + vk::ImageTiling::eOptimal, vk::ImageUsageFlagBits::eColorAttachment, vk::SharingMode::eExclusive, 0, nullptr, vk::ImageLayout::eUndefined); vk::Image image = device.createImage(ci); ```