Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f6a9d88

Browse files
committed
Elaborate a bit more on why we need resolve attachments.
1 parent 399353e commit f6a9d88

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

10_Multisampling.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void createRenderPass() {
176176
...
177177
```
178178

179-
Apart from the obvious change that tells the attachments to use more samples, you'll notice a change to the `finalLayout` parameter for the color attachment. This is because the multisampled color buffer will be only used to store color pixels - for presentation, we can only use a single-sampled attachment. This also applies to multisampled depth, which means we need to create additional resolve attachments:
179+
Apart from the obvious change that tells both color and depth to use more samples, you'll notice an update to the `finalLayout` parameter for the color attachment. This is because a multisampled image is a fairly complex structure containing more information than a regular image. One of the consequences of this is that it cannot be processed by a sampler, so it cannot be drawn directly to the screen. For that reason, a multisampled image has to be translated (resolved) to a regular image before it can be used. This also applies to the depth buffer, so we need to define two additional attachments:
180180

181181
```c++
182182
...
@@ -202,19 +202,25 @@ Apart from the obvious change that tells the attachments to use more samples, yo
202202
...
203203
```
204204

205-
We now have to add new color resolve attachment to the subpass. Create a new attachment reference and update the `pResolveAttachments` pointer:
205+
The render pass now has to be instructed to perform color image resolution. Create a new attachment reference that will point to the color buffer which will serve as the resolve target:
206206

207207
```c++
208208
...
209209
VkAttachmentReference colorAttachmentResolveRef = {};
210210
colorAttachmentResolveRef.attachment = 2;
211211
colorAttachmentResolveRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
212212
...
213+
```
214+
215+
Set the `pResolveAttachments` subpass struct member to point to the newly created attachment reference. This is enough to let the render pass define a multisample resolve operation which will let us render the image to screen:
216+
217+
```
218+
...
213219
subpass.pResolveAttachments = &colorAttachmentResolveRef;
214220
...
215221
```
216222

217-
Update render pass info struct with new attachments:
223+
Now update render pass info struct with new attachments:
218224

219225
```c++
220226
...

0 commit comments

Comments
 (0)