| 833 | } |
| 834 | |
| 835 | void VulkanBaseApp::createRenderPass() |
| 836 | { |
| 837 | VkAttachmentDescription colorAttachment = {}; |
| 838 | colorAttachment.format = m_swapChainFormat; |
| 839 | colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT; |
| 840 | colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 841 | colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 842 | colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 843 | colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 844 | colorAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 845 | colorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; |
| 846 | |
| 847 | VkAttachmentReference colorAttachmentRef = {}; |
| 848 | colorAttachmentRef.attachment = 0; |
| 849 | colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 850 | |
| 851 | VkAttachmentDescription depthAttachment = {}; |
| 852 | depthAttachment.format = |
| 853 | findSupportedFormat(m_physicalDevice, |
| 854 | {VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT}, |
| 855 | VK_IMAGE_TILING_OPTIMAL, |
| 856 | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 857 | depthAttachment.samples = VK_SAMPLE_COUNT_1_BIT; |
| 858 | depthAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 859 | depthAttachment.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 860 | depthAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 861 | depthAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 862 | depthAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 863 | depthAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 864 | |
| 865 | VkAttachmentReference depthAttachmentRef = {}; |
| 866 | depthAttachmentRef.attachment = 1; |
| 867 | depthAttachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 868 | |
| 869 | VkSubpassDescription subpass = {}; |
| 870 | subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; |
| 871 | subpass.colorAttachmentCount = 1; |
| 872 | subpass.pColorAttachments = &colorAttachmentRef; |
| 873 | subpass.pDepthStencilAttachment = &depthAttachmentRef; |
| 874 | |
| 875 | VkSubpassDependency dependency = {}; |
| 876 | dependency.srcSubpass = VK_SUBPASS_EXTERNAL; |
| 877 | dependency.dstSubpass = 0; |
| 878 | dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; |
| 879 | dependency.srcAccessMask = 0; |
| 880 | dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; |
| 881 | dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; |
| 882 | |
| 883 | VkAttachmentDescription attachments[] = {colorAttachment, depthAttachment}; |
| 884 | VkRenderPassCreateInfo renderPassInfo = {}; |
| 885 | renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 886 | renderPassInfo.attachmentCount = countof(attachments); |
| 887 | renderPassInfo.pAttachments = attachments; |
| 888 | renderPassInfo.subpassCount = 1; |
| 889 | renderPassInfo.pSubpasses = &subpass; |
| 890 | renderPassInfo.dependencyCount = 1; |
| 891 | renderPassInfo.pDependencies = &dependency; |
| 892 |
nothing calls this directly
no test coverage detected