diff options
author | Jason Ekstrand <[email protected]> | 2018-04-24 13:08:13 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-07-09 10:11:53 -0700 |
commit | a695de58450a933c735e4e5e22f8dcc6caaa76e1 (patch) | |
tree | ac0e99b73529df50f1491ce18c88aac51fc23e41 /src/intel/vulkan/anv_pass.c | |
parent | 208be8eafa30be6c5e79fe3235f5404fd803baf1 (diff) |
anv: Add support for VK_KHR_create_renderpass2
The implementation of CreateRenderPass2 uses the helpers we broke out in
previous commits. The implementations of the new vkCmd functions just
call the old versions.
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_pass.c')
-rw-r--r-- | src/intel/vulkan/anv_pass.c | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_pass.c b/src/intel/vulkan/anv_pass.c index cb73359af79..72bd99202ec 100644 --- a/src/intel/vulkan/anv_pass.c +++ b/src/intel/vulkan/anv_pass.c @@ -339,6 +339,146 @@ VkResult anv_CreateRenderPass( return VK_SUCCESS; } +static unsigned +num_subpass_attachments2(const VkSubpassDescription2KHR *desc) +{ + return desc->inputAttachmentCount + + desc->colorAttachmentCount + + (desc->pResolveAttachments ? desc->colorAttachmentCount : 0) + + (desc->pDepthStencilAttachment != NULL); +} + +VkResult anv_CreateRenderPass2KHR( + VkDevice _device, + const VkRenderPassCreateInfo2KHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkRenderPass* pRenderPass) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + + assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2_KHR); + + struct anv_render_pass *pass; + struct anv_subpass *subpasses; + struct anv_render_pass_attachment *attachments; + enum anv_pipe_bits *subpass_flushes; + + ANV_MULTIALLOC(ma); + anv_multialloc_add(&ma, &pass, 1); + anv_multialloc_add(&ma, &subpasses, pCreateInfo->subpassCount); + anv_multialloc_add(&ma, &attachments, pCreateInfo->attachmentCount); + anv_multialloc_add(&ma, &subpass_flushes, pCreateInfo->subpassCount + 1); + + struct anv_subpass_attachment *subpass_attachments; + uint32_t subpass_attachment_count = 0; + for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) { + subpass_attachment_count += + num_subpass_attachments2(&pCreateInfo->pSubpasses[i]); + } + anv_multialloc_add(&ma, &subpass_attachments, subpass_attachment_count); + + if (!anv_multialloc_alloc2(&ma, &device->alloc, pAllocator, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)) + return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); + + /* Clear the subpasses along with the parent pass. This required because + * each array member of anv_subpass must be a valid pointer if not NULL. + */ + memset(pass, 0, ma.size); + pass->attachment_count = pCreateInfo->attachmentCount; + pass->subpass_count = pCreateInfo->subpassCount; + pass->attachments = attachments; + pass->subpass_flushes = subpass_flushes; + + for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) { + pass->attachments[i] = (struct anv_render_pass_attachment) { + .format = pCreateInfo->pAttachments[i].format, + .samples = pCreateInfo->pAttachments[i].samples, + .load_op = pCreateInfo->pAttachments[i].loadOp, + .store_op = pCreateInfo->pAttachments[i].storeOp, + .stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp, + .initial_layout = pCreateInfo->pAttachments[i].initialLayout, + .final_layout = pCreateInfo->pAttachments[i].finalLayout, + }; + } + + for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) { + const VkSubpassDescription2KHR *desc = &pCreateInfo->pSubpasses[i]; + struct anv_subpass *subpass = &pass->subpasses[i]; + + subpass->input_count = desc->inputAttachmentCount; + subpass->color_count = desc->colorAttachmentCount; + subpass->attachment_count = num_subpass_attachments2(desc); + subpass->attachments = subpass_attachments; + subpass->view_mask = desc->viewMask; + + if (desc->inputAttachmentCount > 0) { + subpass->input_attachments = subpass_attachments; + subpass_attachments += desc->inputAttachmentCount; + + for (uint32_t j = 0; j < desc->inputAttachmentCount; j++) { + subpass->input_attachments[j] = (struct anv_subpass_attachment) { + .usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, + .attachment = desc->pInputAttachments[j].attachment, + .layout = desc->pInputAttachments[j].layout, + }; + } + } + + if (desc->colorAttachmentCount > 0) { + subpass->color_attachments = subpass_attachments; + subpass_attachments += desc->colorAttachmentCount; + + for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) { + subpass->color_attachments[j] = (struct anv_subpass_attachment) { + .usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, + .attachment = desc->pColorAttachments[j].attachment, + .layout = desc->pColorAttachments[j].layout, + }; + } + } + + if (desc->pResolveAttachments) { + subpass->resolve_attachments = subpass_attachments; + subpass_attachments += desc->colorAttachmentCount; + + for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) { + subpass->resolve_attachments[j] = (struct anv_subpass_attachment) { + .usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT, + .attachment = desc->pResolveAttachments[j].attachment, + .layout = desc->pResolveAttachments[j].layout, + }; + } + } + + if (desc->pDepthStencilAttachment) { + subpass->depth_stencil_attachment = subpass_attachments++; + + *subpass->depth_stencil_attachment = (struct anv_subpass_attachment) { + .usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, + .attachment = desc->pDepthStencilAttachment->attachment, + .layout = desc->pDepthStencilAttachment->layout, + }; + } + } + + for (uint32_t i = 0; i < pCreateInfo->dependencyCount; i++) + anv_render_pass_add_subpass_dep(pass, &pCreateInfo->pDependencies[i]); + + vk_foreach_struct(ext, pCreateInfo->pNext) { + switch (ext->sType) { + default: + anv_debug_ignored_stype(ext->sType); + } + } + + anv_render_pass_compile(pass); + + *pRenderPass = anv_render_pass_to_handle(pass); + + return VK_SUCCESS; +} + void anv_DestroyRenderPass( VkDevice _device, VkRenderPass _pass, |