Fix VkSubpassDependency for Depth/Stencil Attachments

The stage/access mask for `VkSubpassDependency` were hardcoded to only be valid for color attachments earlier, this has now been fixed by branching based on the format aspect.
This commit is contained in:
PixelyIon 2021-12-08 01:54:28 +05:30
parent aa32f6b017
commit 6f6413f02d

View File

@ -83,12 +83,18 @@ namespace skyline::gpu::interconnect::node {
vk::SubpassDependency dependency{ vk::SubpassDependency dependency{
.srcSubpass = static_cast<u32>(std::distance(subpassDescriptions.begin(), lastUsageIt)), .srcSubpass = static_cast<u32>(std::distance(subpassDescriptions.begin(), lastUsageIt)),
.dstSubpass = static_cast<uint32_t>(subpassDescriptions.size()), // We assume that the next subpass is using the attachment .dstSubpass = static_cast<uint32_t>(subpassDescriptions.size()), // We assume that the next subpass is using the attachment
.srcStageMask = vk::PipelineStageFlagBits::eColorAttachmentOutput, .dstStageMask = vk::PipelineStageFlagBits::eAllGraphics,
.dstStageMask = vk::PipelineStageFlagBits::eColorAttachmentOutput,
.srcAccessMask = vk::AccessFlagBits::eColorAttachmentWrite,
.dstAccessMask = vk::AccessFlagBits::eColorAttachmentRead,
.dependencyFlags = vk::DependencyFlagBits::eByRegion, .dependencyFlags = vk::DependencyFlagBits::eByRegion,
}; };
if (view->format->vkAspect & vk::ImageAspectFlagBits::eColor) {
dependency.srcStageMask = vk::PipelineStageFlagBits::eColorAttachmentOutput;
dependency.srcAccessMask = vk::AccessFlagBits::eColorAttachmentWrite;
dependency.dstAccessMask = vk::AccessFlagBits::eColorAttachmentRead;
} else if (view->format->vkAspect & (vk::ImageAspectFlagBits::eDepth | vk::ImageAspectFlagBits::eStencil)) {
dependency.srcStageMask = vk::PipelineStageFlagBits::eEarlyFragmentTests | vk::PipelineStageFlagBits::eLateFragmentTests;
dependency.srcAccessMask = vk::AccessFlagBits::eDepthStencilAttachmentRead;
dependency.dstAccessMask = vk::AccessFlagBits::eDepthStencilAttachmentWrite;
}
if (std::find(subpassDependencies.begin(), subpassDependencies.end(), dependency) == subpassDependencies.end()) if (std::find(subpassDependencies.begin(), subpassDependencies.end(), dependency) == subpassDependencies.end())
subpassDependencies.push_back(dependency); subpassDependencies.push_back(dependency);