Skip to content

Commit 4dd797f

Browse files
vinsentlimeta-codesync[bot]
authored andcommitted
igl | vulkan | Fix resolve depth attachment missing in 'vkCreateRenderPass'. (#342)
Summary: Pull Request resolved: #342 Reviewed By: mmaurer, pixelperfect3 Differential Revision: D91505532 Pulled By: corporateshark fbshipit-source-id: 6c67f23c1866791766c82a1667b807ed1d6918c5
1 parent 8fde3d5 commit 4dd797f

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/igl/vulkan/RenderCommandEncoder.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,25 @@ void RenderCommandEncoder::initialize(const RenderPassDesc& renderPass,
200200
initialLayout,
201201
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
202202
depthTexture.getVulkanTexture().image_.samples_);
203+
204+
// handle MSAA
205+
if (renderPass.depthAttachment.storeAction == StoreAction::MsaaResolve) {
206+
IGL_DEBUG_ASSERT(framebuffer->getResolveDepthAttachment(),
207+
"Framebuffer attachment should contain a resolve depth texture");
208+
const auto& depthResolveTexture =
209+
static_cast<Texture&>(*framebuffer->getResolveDepthAttachment());
210+
builder.addDepthStencilResolve(depthResolveTexture.getVkFormat(),
211+
VK_ATTACHMENT_LOAD_OP_DONT_CARE,
212+
VK_ATTACHMENT_STORE_OP_STORE,
213+
VK_ATTACHMENT_LOAD_OP_DONT_CARE,
214+
VK_ATTACHMENT_STORE_OP_STORE,
215+
initialLayout,
216+
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
217+
clearValues.push_back(VkClearValue{.depthStencil = {
218+
.depth = descDepth.clearDepth,
219+
.stencil = descStencil.clearStencil,
220+
}});
221+
}
203222
}
204223

205224
const auto& fb = static_cast<Framebuffer&>(*framebuffer);

src/igl/vulkan/VulkanRenderPassBuilder.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,19 @@ VkResult VulkanRenderPassBuilder::build(const VulkanFunctionTable& vf,
7272
};
7373
#endif // IGL_VULKAN_HAS_LEGACY_RENDERPASS
7474

75+
const bool hasDepthStencilResolve = refDepthResolve2_.layout != VK_IMAGE_LAYOUT_UNDEFINED;
76+
77+
const VkSubpassDescriptionDepthStencilResolve depthStencilResolve = {
78+
.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE,
79+
.pNext = nullptr,
80+
.depthResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT,
81+
.stencilResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT,
82+
.pDepthStencilResolveAttachment = hasDepthStencilResolve ? &refDepthResolve2_ : nullptr,
83+
};
84+
7585
const VkSubpassDescription2 subpass2 = {
7686
.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2,
87+
.pNext = hasDepthStencilResolve ? &depthStencilResolve : nullptr,
7788
.flags = 0,
7889
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
7990
.viewMask = viewMask_,

0 commit comments

Comments
 (0)