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

Skip to content

Commit 681c588

Browse files
authored
Fix multisampled color attachment sync (#349) (#350)
* Fix multisampled color attachment sync (#349) * Update 10_Multisampling.md fix typo
1 parent e16c142 commit 681c588

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

code/30_multisampling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ class HelloTriangleApplication {
597597
dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
598598
dependency.dstSubpass = 0;
599599
dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
600-
dependency.srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
600+
dependency.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
601601
dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
602602
dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
603603

en/10_Multisampling.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ Set the `pResolveAttachments` subpass struct member to point to the newly create
196196
...
197197
```
198198

199+
Since we're reusing the multisampled color image, it's necessary to update the `srcAccessMask` of the `VkSubpassDependency`. This update ensures that any write operations to the color attachment are completed before subsequent ones begin, thus preventing write-after-write hazards that can lead to unstable rendering results:
200+
201+
```c++
202+
...
203+
dependency.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
204+
...
205+
```
206+
199207
Now update render pass info struct with the new color attachment:
200208

201209
```c++

0 commit comments

Comments
 (0)