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
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);

View File

@ -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,

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

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

View File

@ -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);