@@ -153,7 +153,9 @@ The parameters for an image are specified in a `VkImageCreateInfo` struct:
153153
154154[,c++]
155155----
156- vk::ImageCreateInfo imageInfo( {}, vk::ImageType::e2D, format, {width, height, 1}, 1, 1, vk::SampleCountFlagBits::e1, tiling, usage, vk::SharingMode::eExclusive, 0);
156+ vk::ImageCreateInfo imageInfo{ .imageType = vk::ImageType::e2D, .format = format,
157+ .extent = {width, height, 1}, .mipLevels = 1, .arrayLayers = 1, .samples = vk::SampleCountFlagBits::e1,
158+ .tiling = tiling, .usage = usage, .sharingMode = vk::SharingMode::eExclusive};
157159----
158160
159161The image type, specified in the `imageType` field, tells Vulkan with what kind of coordinate system the texels in the image are going to be addressed.
@@ -227,12 +229,16 @@ Create the function and move the image object creation and memory allocation to
227229[,c++]
228230----
229231void createImage(uint32_t width, uint32_t height, vk::Format format, vk::ImageTiling tiling, vk::ImageUsageFlags usage, vk::MemoryPropertyFlags properties, vk::raii::Image& image, vk::raii::DeviceMemory& imageMemory) {
230- vk::ImageCreateInfo imageInfo( {}, vk::ImageType::e2D, format, {width, height, 1}, 1, 1, vk::SampleCountFlagBits::e1, tiling, usage, vk::SharingMode::eExclusive, 0);
232+ vk::ImageCreateInfo imageInfo{ .imageType = vk::ImageType::e2D, .format = format,
233+ .extent = {width, height, 1}, .mipLevels = 1, .arrayLayers = 1,
234+ .samples = vk::SampleCountFlagBits::e1, .tiling = tiling,
235+ .usage = usage, .sharingMode = vk::SharingMode::eExclusive };
231236
232237 image = vk::raii::Image( device, imageInfo );
233238
234239 vk::MemoryRequirements memRequirements = image.getMemoryRequirements();
235- vk::MemoryAllocateInfo allocInfo( memRequirements.size, findMemoryType(memRequirements.memoryTypeBits, properties) );
240+ vk::MemoryAllocateInfo allocInfo{ .allocationSize = memRequirements.size,
241+ .memoryTypeIndex = findMemoryType(memRequirements.memoryTypeBits, properties) };
236242 imageMemory = vk::raii::DeviceMemory( device, allocInfo );
237243 image.bindMemory(imageMemory, 0);
238244}
@@ -286,10 +292,10 @@ The function we're going to write now involves recording and executing a command
286292[,c++]
287293----
288294vk::raii::CommandBuffer beginSingleTimeCommands() {
289- vk::CommandBufferAllocateInfo allocInfo( commandPool, vk::CommandBufferLevel::ePrimary, 1) ;
295+ vk::CommandBufferAllocateInfo allocInfo{ . commandPool = commandPool, .level = vk::CommandBufferLevel::ePrimary, .commandBufferCount = 1 } ;
290296 vk::raii::CommandBuffer commandBuffer = std::move(device.allocateCommandBuffers(allocInfo).front());
291297
292- vk::CommandBufferBeginInfo beginInfo( vk::CommandBufferUsageFlagBits::eOneTimeSubmit ) ;
298+ vk::CommandBufferBeginInfo beginInfo{ .flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit } ;
293299 commandBuffer.begin(beginInfo);
294300
295301 return commandBuffer;
@@ -298,7 +304,7 @@ vk::raii::CommandBuffer beginSingleTimeCommands() {
298304void endSingleTimeCommands(vk::raii::CommandBuffer& commandBuffer) {
299305 commandBuffer.end();
300306
301- vk::SubmitInfo submitInfo( {}, {}, { *commandBuffer}) ;
307+ vk::SubmitInfo submitInfo{ .commandBufferCount = 1, .pCommandBuffers = & *commandBuffer } ;
302308 graphicsQueue.submit(submitInfo, nullptr);
303309 graphicsQueue.waitIdle();
304310}
@@ -334,13 +340,12 @@ There is an equivalent _buffer memory barrier_ to do this for buffers.
334340
335341[,c++]
336342----
337- vk::ImageMemoryBarrier barrier( {}, {}, oldLayout, newLayout, {}, {}, image, { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } ) ;
343+ vk::ImageMemoryBarrier barrier{ .oldLayout = oldLayout, . newLayout = newLayout, . image = image, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } } ;
338344----
339-
340- The first two fields specify layout transition.
345+ `oldLayout` and `newLayout` specify the the layout transition.
341346It is possible to use `VK_IMAGE_LAYOUT_UNDEFINED` as `oldLayout` if you don't care about the existing contents of the image.
342347
343- If you are using the barrier to transfer queue family ownership, then these two fields should be the indices of the queue families.
348+ If you are using the barrier to transfer queue family ownership, then `oldLayout` and `newLayout` fields should be the indices of the queue families.
344349They must be set to `VK_QUEUE_FAMILY_IGNORED` if you don't want to do this (not the default value!).
345350
346351The `image` and `subresourceRange` specify the image that is affected and the specific part of the image.
@@ -388,7 +393,8 @@ This happens through `VkBufferImageCopy` structs:
388393
389394[,c++]
390395----
391- vk::BufferImageCopy region( 0, 0, 0, { vk::ImageAspectFlagBits::eColor, 0, 0, 1 }, {0, 0, 0}, {width, height, 1});
396+ vk::BufferImageCopy region{ .bufferOffset = 0, .bufferRowLength = 0, .bufferImageHeight = 0,
397+ .imageSubresource = { vk::ImageAspectFlagBits::eColor, 0, 0, 1 }, .imageOffset = {0, 0, 0}, .imageExtent = {width, height, 1} };
392398----
393399
394400Most of these fields are self-explanatory.
0 commit comments