aboutsummaryrefslogtreecommitdiffstats
path: root/src/intel
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-04-24 13:08:13 -0700
committerJason Ekstrand <[email protected]>2018-07-09 10:11:53 -0700
commita695de58450a933c735e4e5e22f8dcc6caaa76e1 (patch)
treeac0e99b73529df50f1491ce18c88aac51fc23e41 /src/intel
parent208be8eafa30be6c5e79fe3235f5404fd803baf1 (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')
-rw-r--r--src/intel/vulkan/anv_extensions.py1
-rw-r--r--src/intel/vulkan/anv_pass.c140
-rw-r--r--src/intel/vulkan/genX_cmd_buffer.c24
3 files changed, 165 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py
index 3dd217f333c..0df85c16112 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -73,6 +73,7 @@ EXTENSIONS = [
Extension('VK_ANDROID_native_buffer', 5, 'ANDROID'),
Extension('VK_KHR_16bit_storage', 1, 'device->info.gen >= 8'),
Extension('VK_KHR_bind_memory2', 1, True),
+ Extension('VK_KHR_create_renderpass2', 1, True),
Extension('VK_KHR_dedicated_allocation', 1, True),
Extension('VK_KHR_descriptor_update_template', 1, True),
Extension('VK_KHR_device_group', 1, True),
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,
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index fbe4bf72815..8bb08a45d03 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -3892,6 +3892,15 @@ void genX(CmdBeginRenderPass)(
cmd_buffer_begin_subpass(cmd_buffer, 0);
}
+void genX(CmdBeginRenderPass2KHR)(
+ VkCommandBuffer commandBuffer,
+ const VkRenderPassBeginInfo* pRenderPassBeginInfo,
+ const VkSubpassBeginInfoKHR* pSubpassBeginInfo)
+{
+ genX(CmdBeginRenderPass)(commandBuffer, pRenderPassBeginInfo,
+ pSubpassBeginInfo->contents);
+}
+
void genX(CmdNextSubpass)(
VkCommandBuffer commandBuffer,
VkSubpassContents contents)
@@ -3908,6 +3917,14 @@ void genX(CmdNextSubpass)(
cmd_buffer_begin_subpass(cmd_buffer, prev_subpass + 1);
}
+void genX(CmdNextSubpass2KHR)(
+ VkCommandBuffer commandBuffer,
+ const VkSubpassBeginInfoKHR* pSubpassBeginInfo,
+ const VkSubpassEndInfoKHR* pSubpassEndInfo)
+{
+ genX(CmdNextSubpass)(commandBuffer, pSubpassBeginInfo->contents);
+}
+
void genX(CmdEndRenderPass)(
VkCommandBuffer commandBuffer)
{
@@ -3931,3 +3948,10 @@ void genX(CmdEndRenderPass)(
cmd_buffer->state.pass = NULL;
cmd_buffer->state.subpass = NULL;
}
+
+void genX(CmdEndRenderPass2KHR)(
+ VkCommandBuffer commandBuffer,
+ const VkSubpassEndInfoKHR* pSubpassEndInfo)
+{
+ genX(CmdEndRenderPass)(commandBuffer);
+}