v3dv: Implement VK_KHR_create_renderpass2

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13575>
This commit is contained in:
Ella Stanforth 2021-10-28 08:29:33 +00:00 committed by Marge Bot
parent 1813c70943
commit 3c86292321
7 changed files with 74 additions and 41 deletions

View file

@ -1319,9 +1319,9 @@ cmd_buffer_ensure_render_pass_attachment_state(struct v3dv_cmd_buffer *cmd_buffe
} }
VKAPI_ATTR void VKAPI_CALL VKAPI_ATTR void VKAPI_CALL
v3dv_CmdBeginRenderPass(VkCommandBuffer commandBuffer, v3dv_CmdBeginRenderPass2(VkCommandBuffer commandBuffer,
const VkRenderPassBeginInfo *pRenderPassBegin, const VkRenderPassBeginInfo *pRenderPassBegin,
VkSubpassContents contents) const VkSubpassBeginInfo *pSubpassBeginInfo)
{ {
V3DV_FROM_HANDLE(v3dv_cmd_buffer, cmd_buffer, commandBuffer); V3DV_FROM_HANDLE(v3dv_cmd_buffer, cmd_buffer, commandBuffer);
V3DV_FROM_HANDLE(v3dv_render_pass, pass, pRenderPassBegin->renderPass); V3DV_FROM_HANDLE(v3dv_render_pass, pass, pRenderPassBegin->renderPass);
@ -1359,7 +1359,9 @@ v3dv_CmdBeginRenderPass(VkCommandBuffer commandBuffer,
} }
VKAPI_ATTR void VKAPI_CALL 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); 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 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); V3DV_FROM_HANDLE(v3dv_cmd_buffer, cmd_buffer, commandBuffer);

View file

@ -115,6 +115,7 @@ get_device_extensions(const struct v3dv_physical_device *device,
*ext = (struct vk_device_extension_table) { *ext = (struct vk_device_extension_table) {
.KHR_bind_memory2 = true, .KHR_bind_memory2 = true,
.KHR_copy_commands2 = true, .KHR_copy_commands2 = true,
.KHR_create_renderpass2 = true,
.KHR_dedicated_allocation = true, .KHR_dedicated_allocation = true,
.KHR_device_group = true, .KHR_device_group = true,
.KHR_descriptor_update_template = true, .KHR_descriptor_update_template = true,

View file

@ -712,7 +712,8 @@ create_color_clear_render_pass(struct v3dv_device *device,
uint32_t samples, uint32_t samples,
VkRenderPass *pass) VkRenderPass *pass)
{ {
VkAttachmentDescription att = { VkAttachmentDescription2 att = {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2,
.format = format, .format = format,
.samples = samples, .samples = samples,
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD, .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
@ -721,12 +722,14 @@ create_color_clear_render_pass(struct v3dv_device *device,
.finalLayout = VK_IMAGE_LAYOUT_GENERAL, .finalLayout = VK_IMAGE_LAYOUT_GENERAL,
}; };
VkAttachmentReference att_ref = { VkAttachmentReference2 att_ref = {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2,
.attachment = rt_idx, .attachment = rt_idx,
.layout = VK_IMAGE_LAYOUT_GENERAL, .layout = VK_IMAGE_LAYOUT_GENERAL,
}; };
VkSubpassDescription subpass = { VkSubpassDescription2 subpass = {
.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2,
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS, .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
.inputAttachmentCount = 0, .inputAttachmentCount = 0,
.colorAttachmentCount = 1, .colorAttachmentCount = 1,
@ -737,8 +740,8 @@ create_color_clear_render_pass(struct v3dv_device *device,
.pPreserveAttachments = NULL, .pPreserveAttachments = NULL,
}; };
VkRenderPassCreateInfo info = { VkRenderPassCreateInfo2 info = {
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2,
.attachmentCount = 1, .attachmentCount = 1,
.pAttachments = &att, .pAttachments = &att,
.subpassCount = 1, .subpassCount = 1,
@ -747,7 +750,7 @@ create_color_clear_render_pass(struct v3dv_device *device,
.pDependencies = NULL, .pDependencies = NULL,
}; };
return v3dv_CreateRenderPass(v3dv_device_to_handle(device), return v3dv_CreateRenderPass2(v3dv_device_to_handle(device),
&info, &device->vk.alloc, pass); &info, &device->vk.alloc, pass);
} }

View file

@ -2176,7 +2176,12 @@ texel_buffer_shader_copy(struct v3dv_cmd_buffer *cmd_buffer,
.clearValueCount = 0, .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; struct v3dv_job *job = cmd_buffer->state.job;
if (!job) if (!job)
goto fail; goto fail;
@ -2243,7 +2248,11 @@ texel_buffer_shader_copy(struct v3dv_cmd_buffer *cmd_buffer,
v3dv_CmdDraw(_cmd_buffer, 4, 1, 0, 0); v3dv_CmdDraw(_cmd_buffer, 4, 1, 0, 0);
} /* For each region */ } /* 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 */ } /* For each layer */
fail: fail:
@ -2964,7 +2973,8 @@ create_blit_render_pass(struct v3dv_device *device,
const bool is_color_blit = vk_format_is_color(dst_format); const bool is_color_blit = vk_format_is_color(dst_format);
/* Attachment load operation is specified below */ /* Attachment load operation is specified below */
VkAttachmentDescription att = { VkAttachmentDescription2 att = {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2,
.format = dst_format, .format = dst_format,
.samples = VK_SAMPLE_COUNT_1_BIT, .samples = VK_SAMPLE_COUNT_1_BIT,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE, .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
@ -2972,12 +2982,14 @@ create_blit_render_pass(struct v3dv_device *device,
.finalLayout = VK_IMAGE_LAYOUT_GENERAL, .finalLayout = VK_IMAGE_LAYOUT_GENERAL,
}; };
VkAttachmentReference att_ref = { VkAttachmentReference2 att_ref = {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2,
.attachment = 0, .attachment = 0,
.layout = VK_IMAGE_LAYOUT_GENERAL, .layout = VK_IMAGE_LAYOUT_GENERAL,
}; };
VkSubpassDescription subpass = { VkSubpassDescription2 subpass = {
.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2,
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS, .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
.inputAttachmentCount = 0, .inputAttachmentCount = 0,
.colorAttachmentCount = is_color_blit ? 1 : 0, .colorAttachmentCount = is_color_blit ? 1 : 0,
@ -2988,8 +3000,8 @@ create_blit_render_pass(struct v3dv_device *device,
.pPreserveAttachments = NULL, .pPreserveAttachments = NULL,
}; };
VkRenderPassCreateInfo info = { VkRenderPassCreateInfo2 info = {
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2,
.attachmentCount = 1, .attachmentCount = 1,
.pAttachments = &att, .pAttachments = &att,
.subpassCount = 1, .subpassCount = 1,
@ -3000,13 +3012,13 @@ create_blit_render_pass(struct v3dv_device *device,
VkResult result; VkResult result;
att.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; att.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
result = v3dv_CreateRenderPass(v3dv_device_to_handle(device), result = v3dv_CreateRenderPass2(v3dv_device_to_handle(device),
&info, &device->vk.alloc, pass_load); &info, &device->vk.alloc, pass_load);
if (result != VK_SUCCESS) if (result != VK_SUCCESS)
return false; return false;
att.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; att.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
result = v3dv_CreateRenderPass(v3dv_device_to_handle(device), result = v3dv_CreateRenderPass2(v3dv_device_to_handle(device),
&info, &device->vk.alloc, pass_no_load); &info, &device->vk.alloc, pass_no_load);
return result == VK_SUCCESS; return result == VK_SUCCESS;
} }
@ -4169,7 +4181,12 @@ blit_shader(struct v3dv_cmd_buffer *cmd_buffer,
.clearValueCount = 0, .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; struct v3dv_job *job = cmd_buffer->state.job;
if (!job) if (!job)
goto fail; goto fail;
@ -4193,7 +4210,11 @@ blit_shader(struct v3dv_cmd_buffer *cmd_buffer,
v3dv_CmdDraw(_cmd_buffer, 4, 1, 0, 0); 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; dirty_dynamic_state = V3DV_CMD_DIRTY_VIEWPORT | V3DV_CMD_DIRTY_SCISSOR;
} }

View file

@ -24,7 +24,7 @@
#include "v3dv_private.h" #include "v3dv_private.h"
static uint32_t static uint32_t
num_subpass_attachments(const VkSubpassDescription *desc) num_subpass_attachments(const VkSubpassDescription2 *desc)
{ {
return desc->inputAttachmentCount + return desc->inputAttachmentCount +
desc->colorAttachmentCount + desc->colorAttachmentCount +
@ -120,19 +120,25 @@ pass_find_subpass_range_for_attachments(struct v3dv_device *device,
VKAPI_ATTR VkResult VKAPI_CALL VKAPI_ATTR VkResult VKAPI_CALL
v3dv_CreateRenderPass(VkDevice _device, v3dv_CreateRenderPass2(VkDevice _device,
const VkRenderPassCreateInfo *pCreateInfo, const VkRenderPassCreateInfo2 *pCreateInfo,
const VkAllocationCallbacks *pAllocator, const VkAllocationCallbacks *pAllocator,
VkRenderPass *pRenderPass) VkRenderPass *pRenderPass)
{ {
V3DV_FROM_HANDLE(v3dv_device, device, _device); V3DV_FROM_HANDLE(v3dv_device, device, _device);
struct v3dv_render_pass *pass; 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 = /* From the VK_KHR_multiview spec:
vk_find_struct_const(pCreateInfo->pNext, RENDER_PASS_MULTIVIEW_CREATE_INFO); *
bool multiview_enabled = multiview_info && multiview_info->subpassCount > 0; * 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 size = sizeof(*pass);
size_t subpasses_offset = size; size_t subpasses_offset = size;
@ -156,7 +162,7 @@ v3dv_CreateRenderPass(VkDevice _device,
uint32_t subpass_attachment_count = 0; uint32_t subpass_attachment_count = 0;
for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) { 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); subpass_attachment_count += num_subpass_attachments(desc);
} }
@ -176,13 +182,12 @@ v3dv_CreateRenderPass(VkDevice _device,
struct v3dv_subpass_attachment *p = pass->subpass_attachments; struct v3dv_subpass_attachment *p = pass->subpass_attachments;
for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) { 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]; struct v3dv_subpass *subpass = &pass->subpasses[i];
subpass->input_count = desc->inputAttachmentCount; subpass->input_count = desc->inputAttachmentCount;
subpass->color_count = desc->colorAttachmentCount; subpass->color_count = desc->colorAttachmentCount;
if (multiview_enabled) subpass->view_mask = desc->viewMask;
subpass->view_mask = multiview_info->pViewMasks[i];
if (desc->inputAttachmentCount > 0) { if (desc->inputAttachmentCount > 0) {
subpass->input_attachments = p; subpass->input_attachments = p;
@ -302,7 +307,7 @@ subpass_get_granularity(struct v3dv_device *device,
uint32_t attachment_idx = subpass->color_attachments[i].attachment; uint32_t attachment_idx = subpass->color_attachments[i].attachment;
if (attachment_idx == VK_ATTACHMENT_UNUSED) if (attachment_idx == VK_ATTACHMENT_UNUSED)
continue; continue;
const VkAttachmentDescription *desc = const VkAttachmentDescription2 *desc =
&pass->attachments[attachment_idx].desc; &pass->attachments[attachment_idx].desc;
const struct v3dv_format *format = v3dv_X(device, get_format)(desc->format); const struct v3dv_format *format = v3dv_X(device, get_format)(desc->format);
uint32_t internal_type, internal_bpp; uint32_t internal_type, internal_bpp;

View file

@ -637,7 +637,7 @@ struct v3dv_subpass {
}; };
struct v3dv_render_pass_attachment { struct v3dv_render_pass_attachment {
VkAttachmentDescription desc; VkAttachmentDescription2 desc;
uint32_t first_subpass; uint32_t first_subpass;
uint32_t last_subpass; uint32_t last_subpass;

View file

@ -108,7 +108,7 @@ pack_blend(struct v3dv_pipeline *pipeline,
if (!b_state->blendEnable) if (!b_state->blendEnable)
continue; continue;
VkAttachmentDescription *desc = VkAttachmentDescription2 *desc =
&pipeline->pass->attachments[attachment_idx].desc; &pipeline->pass->attachments[attachment_idx].desc;
const struct v3dv_format *format = v3dX(get_format)(desc->format); const struct v3dv_format *format = v3dX(get_format)(desc->format);
bool dst_alpha_one = (format->swizzle[3] == PIPE_SWIZZLE_1); bool dst_alpha_one = (format->swizzle[3] == PIPE_SWIZZLE_1);