Setup renderpass and its subpass dependencies
| 977 | |
| 978 | // Setup renderpass and its subpass dependencies |
| 979 | void setupRenderpass() |
| 980 | { |
| 981 | std::array<VkAttachmentDescription, 2> attachmentDescriptions{}; |
| 982 | |
| 983 | // Color attachment |
| 984 | attachmentDescriptions[0] = VkAttachmentDescription(); |
| 985 | attachmentDescriptions[0].format = swapchainFormat.format; |
| 986 | attachmentDescriptions[0].samples = VK_SAMPLE_COUNT_1_BIT; |
| 987 | attachmentDescriptions[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 988 | attachmentDescriptions[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 989 | attachmentDescriptions[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 990 | attachmentDescriptions[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 991 | attachmentDescriptions[0].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 992 | attachmentDescriptions[0].finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; |
| 993 | |
| 994 | // Depth attachment |
| 995 | attachmentDescriptions[1] = VkAttachmentDescription(); |
| 996 | attachmentDescriptions[1].format = depthFormat; |
| 997 | attachmentDescriptions[1].samples = VK_SAMPLE_COUNT_1_BIT; |
| 998 | attachmentDescriptions[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 999 | attachmentDescriptions[1].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 1000 | attachmentDescriptions[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 1001 | attachmentDescriptions[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 1002 | attachmentDescriptions[1].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 1003 | attachmentDescriptions[1].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 1004 | |
| 1005 | VkAttachmentReference colorAttachmentReference = {}; |
| 1006 | colorAttachmentReference.attachment = 0; |
| 1007 | colorAttachmentReference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 1008 | |
| 1009 | VkAttachmentReference depthStencilAttachmentReference = {}; |
| 1010 | depthStencilAttachmentReference.attachment = 1; |
| 1011 | depthStencilAttachmentReference.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 1012 | |
| 1013 | // Set up the renderpass to depend on commands that execute before the renderpass begins |
| 1014 | VkSubpassDescription subpassDescription = VkSubpassDescription(); |
| 1015 | subpassDescription.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; |
| 1016 | subpassDescription.colorAttachmentCount = 1; |
| 1017 | subpassDescription.pColorAttachments = &colorAttachmentReference; |
| 1018 | subpassDescription.pDepthStencilAttachment = &depthStencilAttachmentReference; |
| 1019 | |
| 1020 | VkSubpassDependency subpassDependency = VkSubpassDependency(); |
| 1021 | subpassDependency.srcSubpass = VK_SUBPASS_EXTERNAL; |
| 1022 | subpassDependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; |
| 1023 | subpassDependency.srcAccessMask = 0; |
| 1024 | subpassDependency.dstSubpass = 0; |
| 1025 | subpassDependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; |
| 1026 | subpassDependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; |
| 1027 | |
| 1028 | VkRenderPassCreateInfo renderPassCreateInfo = VkRenderPassCreateInfo(); |
| 1029 | renderPassCreateInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 1030 | renderPassCreateInfo.attachmentCount = static_cast<std::uint32_t>(attachmentDescriptions.size()); |
| 1031 | renderPassCreateInfo.pAttachments = attachmentDescriptions.data(); |
| 1032 | renderPassCreateInfo.subpassCount = 1; |
| 1033 | renderPassCreateInfo.pSubpasses = &subpassDescription; |
| 1034 | renderPassCreateInfo.dependencyCount = 1; |
| 1035 | renderPassCreateInfo.pDependencies = &subpassDependency; |
| 1036 |
nothing calls this directly
no test coverage detected