/*
- * Copyright (c) 2015-2016 The Khronos Group Inc.
- * Copyright (c) 2015-2016 Valve Corporation
- * Copyright (c) 2015-2016 LunarG, Inc.
+ * Copyright (c) 2015-2019 The Khronos Group Inc.
+ * Copyright (c) 2015-2019 Valve Corporation
+ * Copyright (c) 2015-2019 LunarG, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
.preserveAttachmentCount = 0,
.pPreserveAttachments = NULL,
};
+
+ VkSubpassDependency attachmentDependencies[2] = {
+ [0] =
+ {
+ // Depth buffer is shared between swapchain images
+ .srcSubpass = VK_SUBPASS_EXTERNAL,
+ .dstSubpass = 0,
+ .srcStageMask = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
+ .dstStageMask = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
+ .srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
+ .dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
+ .dependencyFlags = 0,
+ },
+ [1] =
+ {
+ // Image Layout Transition
+ .srcSubpass = VK_SUBPASS_EXTERNAL,
+ .dstSubpass = 0,
+ .srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
+ .dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
+ .srcAccessMask = 0,
+ .dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
+ .dependencyFlags = 0,
+ },
+ };
+
const VkRenderPassCreateInfo rp_info = {
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
.pNext = NULL,
.pAttachments = attachments,
.subpassCount = 1,
.pSubpasses = &subpass,
- .dependencyCount = 0,
- .pDependencies = NULL,
+ .dependencyCount = 2,
+ .pDependencies = attachmentDependencies,
};
VkResult U_ASSERT_ONLY err;
/*
- * Copyright (c) 2015-2016 The Khronos Group Inc.
- * Copyright (c) 2015-2016 Valve Corporation
- * Copyright (c) 2015-2016 LunarG, Inc.
+ * Copyright (c) 2015-2019 The Khronos Group Inc.
+ * Copyright (c) 2015-2019 Valve Corporation
+ * Copyright (c) 2015-2019 LunarG, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
.setPreserveAttachmentCount(0)
.setPPreserveAttachments(nullptr);
+ vk::PipelineStageFlags stages = vk::PipelineStageFlagBits::eEarlyFragmentTests | vk::PipelineStageFlagBits::eLateFragmentTests;
+ vk::SubpassDependency const dependencies[2] = {
+ vk::SubpassDependency() // Depth buffer is shared between swapchain images
+ .setSrcSubpass(VK_SUBPASS_EXTERNAL)
+ .setDstSubpass(0)
+ .setSrcStageMask(stages)
+ .setDstStageMask(stages)
+ .setSrcAccessMask(vk::AccessFlagBits::eDepthStencilAttachmentWrite)
+ .setDstAccessMask(vk::AccessFlagBits::eDepthStencilAttachmentRead | vk::AccessFlagBits::eDepthStencilAttachmentWrite)
+ .setDependencyFlags(vk::DependencyFlags()),
+ vk::SubpassDependency() // Image layout transition
+ .setSrcSubpass(VK_SUBPASS_EXTERNAL)
+ .setDstSubpass(0)
+ .setSrcStageMask(vk::PipelineStageFlagBits::eColorAttachmentOutput)
+ .setDstStageMask(vk::PipelineStageFlagBits::eColorAttachmentOutput)
+ .setSrcAccessMask(vk::AccessFlagBits())
+ .setDstAccessMask(vk::AccessFlagBits::eColorAttachmentWrite | vk::AccessFlagBits::eColorAttachmentRead)
+ .setDependencyFlags(vk::DependencyFlags()),
+ };
+
auto const rp_info = vk::RenderPassCreateInfo()
.setAttachmentCount(2)
.setPAttachments(attachments)
.setSubpassCount(1)
.setPSubpasses(&subpass)
- .setDependencyCount(0)
- .setPDependencies(nullptr);
+ .setDependencyCount(2)
+ .setPDependencies(dependencies);
auto result = device.createRenderPass(&rp_info, nullptr, &render_pass);
VERIFY(result == vk::Result::eSuccess);