Skip to content

Commit 1002fa5

Browse files
Updates to Image Copy (#316)
1 parent 523c66d commit 1002fa5

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

chapters/image_copies.adoc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ There are 3 main ways to copy to/from a `VkImage`
1717
[options="header"]
1818
|===
1919
| Copy Type | Original (Vulkan 1.0) | `VK_KHR_copy_commands2` (Vulkan 1.3) - Added a missing `pNext` in the structs | `VK_EXT_host_image_copy` (Vulkan 1.4) - allows copies on host without a `VkBuffer` or `VkCommandBuffer`
20-
| Buffer Image | `vkCmdCopyBufferToImage` | `vkCmdCopyBufferToImage2` | `vkCopyMemoryToImage`
21-
| Image Buffer | `vkCmdCopyImageToBuffer` | `vkCmdCopyImageToBuffer2` | `vkCopyImageToMemory`
22-
| Image Image | `vkCmdCopyImage` | `vkCmdCopyImage2` | `vkCopyImageToImage`
20+
| Buffer to Image | `vkCmdCopyBufferToImage` | `vkCmdCopyBufferToImage2` | `vkCopyMemoryToImage`
21+
| Image to Buffer | `vkCmdCopyImageToBuffer` | `vkCmdCopyImageToBuffer2` | `vkCopyImageToMemory`
22+
| Image to Image | `vkCmdCopyImage` | `vkCmdCopyImage2` | `vkCopyImageToImage`
2323
|===
2424

2525
== Image Subresource
@@ -39,6 +39,8 @@ When creating an image, the memory is not always going to be tightly packed toge
3939
When dealing with a CPU, you can normally assume a 2D or 3D image is just laid out in as large 1D buffer.
4040
GPU hardware has various memory alignment requirements, and will adjust the memory as required.
4141

42+
While buffers and CPU memory are addressed with a single linear offset, images are addressed in multiple dimensions (ex. 2D image needs an `x` and `y` offset). When copying data in or out of images, each of these dimensions must be specified to describe the data being copied.
43+
4244
The following is a small example to show how two GPU can represent a `VkImage` layout differently.
4345

4446
image::{images}image_copies_buffer_vs_image.svg[image_copies_buffer_vs_image.svg]
@@ -124,6 +126,8 @@ where the `extent.depth` is `8`, which is allowed for a 2D image because it has
124126

125127
You might be thinking what the difference is between a 3D image and 2D image with layers. One main difference is the mipchains they generate.
126128

129+
Each miplevel the `x`,`y`, and `z` are are halved at each mip level, while the layer count is not.
130+
127131
As an example, let's try to copy `miplevel 1`:
128132

129133
- The 3D extent would be `{4, 4, 4}`
@@ -150,7 +154,7 @@ copy.srcSubresource.mipLevel = 1;
150154

151155
== Compressed Image Copies
152156

153-
Dealing with compress images can be a bit tricky, the main thing is to first grasp the terminology of `texel` vs `texel block`
157+
Dealing with compressed images can be a bit tricky, the main thing is to first grasp the terminology of `texel` vs `texel block`
154158

155159
image::{images}image_copies_compressed_terminology.svg[image_copies_compressed_terminology.svg]
156160

@@ -167,7 +171,7 @@ Copying to and from a `VkBuffer`/`VkDeviceMemory` is straight forward, the `exte
167171

168172
image::{images}image_copies_compressed_buffer.svg[image_copies_compressed_buffer.svg]
169173

170-
The tricky part is when you deal with a uncompressed image that has a block extent of `{1, 1, 1}`, here you will set the `VkImageCopy::extent` to match the `srcImage` (link:https://docs.vulkan.org/spec/latest/chapters/formats.html#formats-size-compatibility[details in spec]).
174+
The tricky part is when you deal with a uncompressed image that has a block extent of `{1, 1, 1}`. You will set the `VkImageCopy::extent` to match the `texels` in the `srcImage`, and the `dstImage` is scaled link:https://docs.vulkan.org/spec/latest/chapters/formats.html#formats-size-compatibility[as described in the spec].
171175

172176
image::{images}image_copies_uncompress_to_compress.svg[image_copies_uncompress_to_compress.svg]
173177

@@ -185,7 +189,7 @@ image::{images}image_copies_dst_offset.svg[image_copies_dst_offset.svg]
185189

186190
=== Partial Texel Block
187191

188-
When using a compressed image, it is possible you might even up with a partially full texel block.
192+
When using a compressed image, it is possible you might end up with a partially full texel block.
189193

190194
This can be from just setting the original extent that is not a multiple of the texel block extent.
191195

chapters/images/image_copies_dst_offset.svg

Lines changed: 1 addition & 1 deletion
Loading

chapters/images/image_copies_mismatch_block_size.svg

Lines changed: 1 addition & 1 deletion
Loading

chapters/images/image_copies_uncompress_to_compress.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)