Skip to content

Commit 033c51f

Browse files
committed
Use aggregate initialization to match demo code and the rest of the tutorial.
Modify text to explain the aggregate initialization.
1 parent f4b1cee commit 033c51f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

en/06_Texture_mapping/00_Images.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ The function we're going to write now involves recording and executing a command
292292
[,c++]
293293
----
294294
vk::raii::CommandBuffer beginSingleTimeCommands() {
295-
vk::CommandBufferAllocateInfo allocInfo(commandPool, vk::CommandBufferLevel::ePrimary, 1);
295+
vk::CommandBufferAllocateInfo allocInfo{ .commandPool = commandPool, .level = vk::CommandBufferLevel::ePrimary, .commandBufferCount = 1 };
296296
vk::raii::CommandBuffer commandBuffer = std::move(device.allocateCommandBuffers(allocInfo).front());
297297
298-
vk::CommandBufferBeginInfo beginInfo( vk::CommandBufferUsageFlagBits::eOneTimeSubmit );
298+
vk::CommandBufferBeginInfo beginInfo{ .flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit };
299299
commandBuffer.begin(beginInfo);
300300
301301
return commandBuffer;
@@ -304,7 +304,7 @@ vk::raii::CommandBuffer beginSingleTimeCommands() {
304304
void endSingleTimeCommands(vk::raii::CommandBuffer& commandBuffer) {
305305
commandBuffer.end();
306306
307-
vk::SubmitInfo submitInfo( {}, {}, {*commandBuffer});
307+
vk::SubmitInfo submitInfo{ .commandBufferCount = 1, .pCommandBuffers = &*commandBuffer };
308308
graphicsQueue.submit(submitInfo, nullptr);
309309
graphicsQueue.waitIdle();
310310
}
@@ -340,13 +340,12 @@ There is an equivalent _buffer memory barrier_ to do this for buffers.
340340

341341
[,c++]
342342
----
343-
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 } };
344344
----
345-
346-
The first two fields specify layout transition.
345+
`oldLayout` and `newLayout` specify the the layout transition.
347346
It is possible to use `VK_IMAGE_LAYOUT_UNDEFINED` as `oldLayout` if you don't care about the existing contents of the image.
348347

349-
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.
350349
They must be set to `VK_QUEUE_FAMILY_IGNORED` if you don't want to do this (not the default value!).
351350

352351
The `image` and `subresourceRange` specify the image that is affected and the specific part of the image.
@@ -394,7 +393,8 @@ This happens through `VkBufferImageCopy` structs:
394393

395394
[,c++]
396395
----
397-
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} };
398398
----
399399

400400
Most of these fields are self-explanatory.

0 commit comments

Comments
 (0)