Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //object picking pass
- //color attachment with 1 msaa samples and a format of VK_FORMAT_R32_SFLOAT, we also clear both color and depth on load
- VkAttachmentDescription object_picking_colorAttachment{};
- object_picking_colorAttachment.format = VK_FORMAT_R32_SFLOAT;
- object_picking_colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
- object_picking_colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
- object_picking_colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
- object_picking_colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
- object_picking_colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
- object_picking_colorAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
- object_picking_colorAttachment.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
- //depth attachment with 1 msaa sample
- VkAttachmentDescription object_picking_depthAttachment{};
- object_picking_depthAttachment.format = find_depth_format();
- object_picking_depthAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
- object_picking_depthAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
- object_picking_depthAttachment.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
- object_picking_depthAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
- object_picking_depthAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
- object_picking_depthAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
- object_picking_depthAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
- VkAttachmentReference object_picking_colorAttachmentRef{};
- object_picking_colorAttachmentRef.attachment = 0;
- object_picking_colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
- VkAttachmentReference object_picking_depthAttachmentRef{};
- object_picking_depthAttachmentRef.attachment = 1;
- object_picking_depthAttachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
- VkSubpassDescription object_picking_subpass{};
- object_picking_subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
- object_picking_subpass.colorAttachmentCount = 1;
- object_picking_subpass.pColorAttachments = &object_picking_colorAttachmentRef;
- object_picking_subpass.pDepthStencilAttachment = &object_picking_depthAttachmentRef;
- VkSubpassDependency object_picking_dependency{};
- object_picking_dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
- object_picking_dependency.dstSubpass = 0;
- object_picking_dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
- object_picking_dependency.srcAccessMask = 0;
- object_picking_dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
- object_picking_dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
- std::array<VkAttachmentDescription, 2 > object_picking_attachments = { object_picking_colorAttachment,object_picking_depthAttachment };
- VkRenderPassCreateInfo object_picking_renderPassInfo{};
- object_picking_renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
- object_picking_renderPassInfo.attachmentCount = static_cast<uint32_t>(object_picking_attachments.size());
- object_picking_renderPassInfo.pAttachments = object_picking_attachments.data();
- object_picking_renderPassInfo.subpassCount = 1;
- object_picking_renderPassInfo.pSubpasses = &object_picking_subpass;
- object_picking_renderPassInfo.dependencyCount = 1;
- object_picking_renderPassInfo.pDependencies = &object_picking_dependency;
- if (vkCreateRenderPass(device, &object_picking_renderPassInfo, nullptr, &object_picking_pass) != VK_SUCCESS)
- {
- throw std::runtime_error("failed to create render pass!");
- }
Add Comment
Please, Sign In to add comment