Mesa (main): v3dv: Implement VK_KHR_create_renderpass2
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Nov 2 08:03:39 UTC 2021
Module: Mesa
Branch: main
Commit: 3c862923219bb4bcb53dd53575a38ab5801bf07f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3c862923219bb4bcb53dd53575a38ab5801bf07f
Author: Ella Stanforth <estanforth at igalia.com>
Date: Thu Oct 28 08:29:33 2021 +0000
v3dv: Implement VK_KHR_create_renderpass2
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13575>
---
src/broadcom/vulkan/v3dv_cmd_buffer.c | 13 ++++++----
src/broadcom/vulkan/v3dv_device.c | 1 +
src/broadcom/vulkan/v3dv_meta_clear.c | 17 +++++++------
src/broadcom/vulkan/v3dv_meta_copy.c | 47 +++++++++++++++++++++++++----------
src/broadcom/vulkan/v3dv_pass.c | 33 +++++++++++++-----------
src/broadcom/vulkan/v3dv_private.h | 2 +-
src/broadcom/vulkan/v3dvx_pipeline.c | 2 +-
7 files changed, 74 insertions(+), 41 deletions(-)
diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c
index ff914e0489b..ba30f34af80 100644
--- a/src/broadcom/vulkan/v3dv_cmd_buffer.c
+++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c
@@ -1319,9 +1319,9 @@ cmd_buffer_ensure_render_pass_attachment_state(struct v3dv_cmd_buffer *cmd_buffe
}
VKAPI_ATTR void VKAPI_CALL
-v3dv_CmdBeginRenderPass(VkCommandBuffer commandBuffer,
- const VkRenderPassBeginInfo *pRenderPassBegin,
- VkSubpassContents contents)
+v3dv_CmdBeginRenderPass2(VkCommandBuffer commandBuffer,
+ const VkRenderPassBeginInfo *pRenderPassBegin,
+ const VkSubpassBeginInfo *pSubpassBeginInfo)
{
V3DV_FROM_HANDLE(v3dv_cmd_buffer, cmd_buffer, commandBuffer);
V3DV_FROM_HANDLE(v3dv_render_pass, pass, pRenderPassBegin->renderPass);
@@ -1359,7 +1359,9 @@ v3dv_CmdBeginRenderPass(VkCommandBuffer commandBuffer,
}
VKAPI_ATTR void VKAPI_CALL
-v3dv_CmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents)
+v3dv_CmdNextSubpass2(VkCommandBuffer commandBuffer,
+ const VkSubpassBeginInfo *pSubpassBeginInfo,
+ const VkSubpassEndInfo *pSubpassEndInfo)
{
V3DV_FROM_HANDLE(v3dv_cmd_buffer, cmd_buffer, commandBuffer);
@@ -1622,7 +1624,8 @@ v3dv_cmd_buffer_subpass_finish(struct v3dv_cmd_buffer *cmd_buffer)
}
VKAPI_ATTR void VKAPI_CALL
-v3dv_CmdEndRenderPass(VkCommandBuffer commandBuffer)
+v3dv_CmdEndRenderPass2(VkCommandBuffer commandBuffer,
+ const VkSubpassEndInfo *pSubpassEndInfo)
{
V3DV_FROM_HANDLE(v3dv_cmd_buffer, cmd_buffer, commandBuffer);
diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c
index 5c36b50ff63..4448078bb12 100644
--- a/src/broadcom/vulkan/v3dv_device.c
+++ b/src/broadcom/vulkan/v3dv_device.c
@@ -115,6 +115,7 @@ get_device_extensions(const struct v3dv_physical_device *device,
*ext = (struct vk_device_extension_table) {
.KHR_bind_memory2 = true,
.KHR_copy_commands2 = true,
+ .KHR_create_renderpass2 = true,
.KHR_dedicated_allocation = true,
.KHR_device_group = true,
.KHR_descriptor_update_template = true,
diff --git a/src/broadcom/vulkan/v3dv_meta_clear.c b/src/broadcom/vulkan/v3dv_meta_clear.c
index 5555c690bb3..23de9833530 100644
--- a/src/broadcom/vulkan/v3dv_meta_clear.c
+++ b/src/broadcom/vulkan/v3dv_meta_clear.c
@@ -712,7 +712,8 @@ create_color_clear_render_pass(struct v3dv_device *device,
uint32_t samples,
VkRenderPass *pass)
{
- VkAttachmentDescription att = {
+ VkAttachmentDescription2 att = {
+ .sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2,
.format = format,
.samples = samples,
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
@@ -721,12 +722,14 @@ create_color_clear_render_pass(struct v3dv_device *device,
.finalLayout = VK_IMAGE_LAYOUT_GENERAL,
};
- VkAttachmentReference att_ref = {
+ VkAttachmentReference2 att_ref = {
+ .sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2,
.attachment = rt_idx,
.layout = VK_IMAGE_LAYOUT_GENERAL,
};
- VkSubpassDescription subpass = {
+ VkSubpassDescription2 subpass = {
+ .sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2,
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
.inputAttachmentCount = 0,
.colorAttachmentCount = 1,
@@ -737,8 +740,8 @@ create_color_clear_render_pass(struct v3dv_device *device,
.pPreserveAttachments = NULL,
};
- VkRenderPassCreateInfo info = {
- .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
+ VkRenderPassCreateInfo2 info = {
+ .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2,
.attachmentCount = 1,
.pAttachments = &att,
.subpassCount = 1,
@@ -747,8 +750,8 @@ create_color_clear_render_pass(struct v3dv_device *device,
.pDependencies = NULL,
};
- return v3dv_CreateRenderPass(v3dv_device_to_handle(device),
- &info, &device->vk.alloc, pass);
+ return v3dv_CreateRenderPass2(v3dv_device_to_handle(device),
+ &info, &device->vk.alloc, pass);
}
static inline uint64_t
diff --git a/src/broadcom/vulkan/v3dv_meta_copy.c b/src/broadcom/vulkan/v3dv_meta_copy.c
index a3237e82f90..1aec0869cc8 100644
--- a/src/broadcom/vulkan/v3dv_meta_copy.c
+++ b/src/broadcom/vulkan/v3dv_meta_copy.c
@@ -2176,7 +2176,12 @@ texel_buffer_shader_copy(struct v3dv_cmd_buffer *cmd_buffer,
.clearValueCount = 0,
};
- v3dv_CmdBeginRenderPass(_cmd_buffer, &rp_info, VK_SUBPASS_CONTENTS_INLINE);
+ VkSubpassBeginInfo sp_info = {
+ .sType = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO,
+ .contents = VK_SUBPASS_CONTENTS_INLINE,
+ };
+
+ v3dv_CmdBeginRenderPass2(_cmd_buffer, &rp_info, &sp_info);
struct v3dv_job *job = cmd_buffer->state.job;
if (!job)
goto fail;
@@ -2243,7 +2248,11 @@ texel_buffer_shader_copy(struct v3dv_cmd_buffer *cmd_buffer,
v3dv_CmdDraw(_cmd_buffer, 4, 1, 0, 0);
} /* For each region */
- v3dv_CmdEndRenderPass(_cmd_buffer);
+ VkSubpassEndInfo sp_end_info = {
+ .sType = VK_STRUCTURE_TYPE_SUBPASS_END_INFO,
+ };
+
+ v3dv_CmdEndRenderPass2(_cmd_buffer, &sp_end_info);
} /* For each layer */
fail:
@@ -2964,7 +2973,8 @@ create_blit_render_pass(struct v3dv_device *device,
const bool is_color_blit = vk_format_is_color(dst_format);
/* Attachment load operation is specified below */
- VkAttachmentDescription att = {
+ VkAttachmentDescription2 att = {
+ .sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2,
.format = dst_format,
.samples = VK_SAMPLE_COUNT_1_BIT,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
@@ -2972,12 +2982,14 @@ create_blit_render_pass(struct v3dv_device *device,
.finalLayout = VK_IMAGE_LAYOUT_GENERAL,
};
- VkAttachmentReference att_ref = {
+ VkAttachmentReference2 att_ref = {
+ .sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2,
.attachment = 0,
.layout = VK_IMAGE_LAYOUT_GENERAL,
};
- VkSubpassDescription subpass = {
+ VkSubpassDescription2 subpass = {
+ .sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2,
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
.inputAttachmentCount = 0,
.colorAttachmentCount = is_color_blit ? 1 : 0,
@@ -2988,8 +3000,8 @@ create_blit_render_pass(struct v3dv_device *device,
.pPreserveAttachments = NULL,
};
- VkRenderPassCreateInfo info = {
- .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
+ VkRenderPassCreateInfo2 info = {
+ .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2,
.attachmentCount = 1,
.pAttachments = &att,
.subpassCount = 1,
@@ -3000,14 +3012,14 @@ create_blit_render_pass(struct v3dv_device *device,
VkResult result;
att.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
- result = v3dv_CreateRenderPass(v3dv_device_to_handle(device),
- &info, &device->vk.alloc, pass_load);
+ result = v3dv_CreateRenderPass2(v3dv_device_to_handle(device),
+ &info, &device->vk.alloc, pass_load);
if (result != VK_SUCCESS)
return false;
att.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
- result = v3dv_CreateRenderPass(v3dv_device_to_handle(device),
- &info, &device->vk.alloc, pass_no_load);
+ result = v3dv_CreateRenderPass2(v3dv_device_to_handle(device),
+ &info, &device->vk.alloc, pass_no_load);
return result == VK_SUCCESS;
}
@@ -4169,7 +4181,12 @@ blit_shader(struct v3dv_cmd_buffer *cmd_buffer,
.clearValueCount = 0,
};
- v3dv_CmdBeginRenderPass(_cmd_buffer, &rp_info, VK_SUBPASS_CONTENTS_INLINE);
+ VkSubpassBeginInfo sp_info = {
+ .sType = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO,
+ .contents = VK_SUBPASS_CONTENTS_INLINE,
+ };
+
+ v3dv_CmdBeginRenderPass2(_cmd_buffer, &rp_info, &sp_info);
struct v3dv_job *job = cmd_buffer->state.job;
if (!job)
goto fail;
@@ -4193,7 +4210,11 @@ blit_shader(struct v3dv_cmd_buffer *cmd_buffer,
v3dv_CmdDraw(_cmd_buffer, 4, 1, 0, 0);
- v3dv_CmdEndRenderPass(_cmd_buffer);
+ VkSubpassEndInfo sp_end_info = {
+ .sType = VK_STRUCTURE_TYPE_SUBPASS_END_INFO,
+ };
+
+ v3dv_CmdEndRenderPass2(_cmd_buffer, &sp_end_info);
dirty_dynamic_state = V3DV_CMD_DIRTY_VIEWPORT | V3DV_CMD_DIRTY_SCISSOR;
}
diff --git a/src/broadcom/vulkan/v3dv_pass.c b/src/broadcom/vulkan/v3dv_pass.c
index 1b03c0d7935..8a262a86e73 100644
--- a/src/broadcom/vulkan/v3dv_pass.c
+++ b/src/broadcom/vulkan/v3dv_pass.c
@@ -24,7 +24,7 @@
#include "v3dv_private.h"
static uint32_t
-num_subpass_attachments(const VkSubpassDescription *desc)
+num_subpass_attachments(const VkSubpassDescription2 *desc)
{
return desc->inputAttachmentCount +
desc->colorAttachmentCount +
@@ -120,19 +120,25 @@ pass_find_subpass_range_for_attachments(struct v3dv_device *device,
VKAPI_ATTR VkResult VKAPI_CALL
-v3dv_CreateRenderPass(VkDevice _device,
- const VkRenderPassCreateInfo *pCreateInfo,
- const VkAllocationCallbacks *pAllocator,
- VkRenderPass *pRenderPass)
+v3dv_CreateRenderPass2(VkDevice _device,
+ const VkRenderPassCreateInfo2 *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkRenderPass *pRenderPass)
{
V3DV_FROM_HANDLE(v3dv_device, device, _device);
struct v3dv_render_pass *pass;
- assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO);
+ assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2);
- const VkRenderPassMultiviewCreateInfo *multiview_info =
- vk_find_struct_const(pCreateInfo->pNext, RENDER_PASS_MULTIVIEW_CREATE_INFO);
- bool multiview_enabled = multiview_info && multiview_info->subpassCount > 0;
+ /* From the VK_KHR_multiview spec:
+ *
+ * When a subpass uses a non-zero view mask, multiview functionality is
+ * considered to be enabled. Multiview is all-or-nothing for a render
+ * pass - that is, either all subpasses must have a non-zero view mask
+ * (though some subpasses may have only one view) or all must be zero.
+ */
+ bool multiview_enabled = pCreateInfo->subpassCount &&
+ pCreateInfo->pSubpasses[0].viewMask;
size_t size = sizeof(*pass);
size_t subpasses_offset = size;
@@ -156,7 +162,7 @@ v3dv_CreateRenderPass(VkDevice _device,
uint32_t subpass_attachment_count = 0;
for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
- const VkSubpassDescription *desc = &pCreateInfo->pSubpasses[i];
+ const VkSubpassDescription2 *desc = &pCreateInfo->pSubpasses[i];
subpass_attachment_count += num_subpass_attachments(desc);
}
@@ -176,13 +182,12 @@ v3dv_CreateRenderPass(VkDevice _device,
struct v3dv_subpass_attachment *p = pass->subpass_attachments;
for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
- const VkSubpassDescription *desc = &pCreateInfo->pSubpasses[i];
+ const VkSubpassDescription2 *desc = &pCreateInfo->pSubpasses[i];
struct v3dv_subpass *subpass = &pass->subpasses[i];
subpass->input_count = desc->inputAttachmentCount;
subpass->color_count = desc->colorAttachmentCount;
- if (multiview_enabled)
- subpass->view_mask = multiview_info->pViewMasks[i];
+ subpass->view_mask = desc->viewMask;
if (desc->inputAttachmentCount > 0) {
subpass->input_attachments = p;
@@ -302,7 +307,7 @@ subpass_get_granularity(struct v3dv_device *device,
uint32_t attachment_idx = subpass->color_attachments[i].attachment;
if (attachment_idx == VK_ATTACHMENT_UNUSED)
continue;
- const VkAttachmentDescription *desc =
+ const VkAttachmentDescription2 *desc =
&pass->attachments[attachment_idx].desc;
const struct v3dv_format *format = v3dv_X(device, get_format)(desc->format);
uint32_t internal_type, internal_bpp;
diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h
index 68c90a88a4d..2a0b8e48fa3 100644
--- a/src/broadcom/vulkan/v3dv_private.h
+++ b/src/broadcom/vulkan/v3dv_private.h
@@ -637,7 +637,7 @@ struct v3dv_subpass {
};
struct v3dv_render_pass_attachment {
- VkAttachmentDescription desc;
+ VkAttachmentDescription2 desc;
uint32_t first_subpass;
uint32_t last_subpass;
diff --git a/src/broadcom/vulkan/v3dvx_pipeline.c b/src/broadcom/vulkan/v3dvx_pipeline.c
index 8623a453701..0345e1954c0 100644
--- a/src/broadcom/vulkan/v3dvx_pipeline.c
+++ b/src/broadcom/vulkan/v3dvx_pipeline.c
@@ -108,7 +108,7 @@ pack_blend(struct v3dv_pipeline *pipeline,
if (!b_state->blendEnable)
continue;
- VkAttachmentDescription *desc =
+ VkAttachmentDescription2 *desc =
&pipeline->pass->attachments[attachment_idx].desc;
const struct v3dv_format *format = v3dX(get_format)(desc->format);
bool dst_alpha_one = (format->swizzle[3] == PIPE_SWIZZLE_1);
More information about the mesa-commit
mailing list