radv: introduce radv_subpass_attachment data structure
Needed for VK_KHR_create_renderpass2. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
This commit is contained in:
@@ -2044,7 +2044,7 @@ static void radv_subpass_barrier(struct radv_cmd_buffer *cmd_buffer, const struc
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void radv_handle_subpass_image_transition(struct radv_cmd_buffer *cmd_buffer,
|
static void radv_handle_subpass_image_transition(struct radv_cmd_buffer *cmd_buffer,
|
||||||
VkAttachmentReference att)
|
struct radv_subpass_attachment att)
|
||||||
{
|
{
|
||||||
unsigned idx = att.attachment;
|
unsigned idx = att.attachment;
|
||||||
struct radv_image_view *view = cmd_buffer->state.framebuffer->attachments[idx].attachment;
|
struct radv_image_view *view = cmd_buffer->state.framebuffer->attachments[idx].attachment;
|
||||||
@@ -3945,7 +3945,7 @@ void radv_CmdEndRenderPass(
|
|||||||
for (unsigned i = 0; i < cmd_buffer->state.framebuffer->attachment_count; ++i) {
|
for (unsigned i = 0; i < cmd_buffer->state.framebuffer->attachment_count; ++i) {
|
||||||
VkImageLayout layout = cmd_buffer->state.pass->attachments[i].final_layout;
|
VkImageLayout layout = cmd_buffer->state.pass->attachments[i].final_layout;
|
||||||
radv_handle_subpass_image_transition(cmd_buffer,
|
radv_handle_subpass_image_transition(cmd_buffer,
|
||||||
(VkAttachmentReference){i, layout});
|
(struct radv_subpass_attachment){i, layout});
|
||||||
}
|
}
|
||||||
|
|
||||||
vk_free(&cmd_buffer->pool->alloc, cmd_buffer->state.attachments);
|
vk_free(&cmd_buffer->pool->alloc, cmd_buffer->state.attachments);
|
||||||
|
@@ -366,10 +366,10 @@ emit_color_clear(struct radv_cmd_buffer *cmd_buffer,
|
|||||||
|
|
||||||
struct radv_subpass clear_subpass = {
|
struct radv_subpass clear_subpass = {
|
||||||
.color_count = 1,
|
.color_count = 1,
|
||||||
.color_attachments = (VkAttachmentReference[]) {
|
.color_attachments = (struct radv_subpass_attachment[]) {
|
||||||
subpass->color_attachments[clear_att->colorAttachment]
|
subpass->color_attachments[clear_att->colorAttachment]
|
||||||
},
|
},
|
||||||
.depth_stencil_attachment = (VkAttachmentReference) { VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_UNDEFINED }
|
.depth_stencil_attachment = (struct radv_subpass_attachment) { VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_UNDEFINED }
|
||||||
};
|
};
|
||||||
|
|
||||||
radv_cmd_buffer_set_subpass(cmd_buffer, &clear_subpass, false);
|
radv_cmd_buffer_set_subpass(cmd_buffer, &clear_subpass, false);
|
||||||
|
@@ -613,8 +613,8 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < subpass->color_count; ++i) {
|
for (uint32_t i = 0; i < subpass->color_count; ++i) {
|
||||||
VkAttachmentReference src_att = subpass->color_attachments[i];
|
struct radv_subpass_attachment src_att = subpass->color_attachments[i];
|
||||||
VkAttachmentReference dest_att = subpass->resolve_attachments[i];
|
struct radv_subpass_attachment dest_att = subpass->resolve_attachments[i];
|
||||||
|
|
||||||
if (src_att.attachment == VK_ATTACHMENT_UNUSED ||
|
if (src_att.attachment == VK_ATTACHMENT_UNUSED ||
|
||||||
dest_att.attachment == VK_ATTACHMENT_UNUSED)
|
dest_att.attachment == VK_ATTACHMENT_UNUSED)
|
||||||
@@ -641,8 +641,8 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer)
|
|||||||
RADV_META_SAVE_GRAPHICS_PIPELINE);
|
RADV_META_SAVE_GRAPHICS_PIPELINE);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < subpass->color_count; ++i) {
|
for (uint32_t i = 0; i < subpass->color_count; ++i) {
|
||||||
VkAttachmentReference src_att = subpass->color_attachments[i];
|
struct radv_subpass_attachment src_att = subpass->color_attachments[i];
|
||||||
VkAttachmentReference dest_att = subpass->resolve_attachments[i];
|
struct radv_subpass_attachment dest_att = subpass->resolve_attachments[i];
|
||||||
|
|
||||||
if (src_att.attachment == VK_ATTACHMENT_UNUSED ||
|
if (src_att.attachment == VK_ATTACHMENT_UNUSED ||
|
||||||
dest_att.attachment == VK_ATTACHMENT_UNUSED)
|
dest_att.attachment == VK_ATTACHMENT_UNUSED)
|
||||||
@@ -657,7 +657,7 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer)
|
|||||||
|
|
||||||
struct radv_subpass resolve_subpass = {
|
struct radv_subpass resolve_subpass = {
|
||||||
.color_count = 2,
|
.color_count = 2,
|
||||||
.color_attachments = (VkAttachmentReference[]) { src_att, dest_att },
|
.color_attachments = (struct radv_subpass_attachment[]) { src_att, dest_att },
|
||||||
.depth_stencil_attachment = { .attachment = VK_ATTACHMENT_UNUSED },
|
.depth_stencil_attachment = { .attachment = VK_ATTACHMENT_UNUSED },
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -684,8 +684,8 @@ radv_decompress_resolve_subpass_src(struct radv_cmd_buffer *cmd_buffer)
|
|||||||
struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
|
struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < subpass->color_count; ++i) {
|
for (uint32_t i = 0; i < subpass->color_count; ++i) {
|
||||||
VkAttachmentReference src_att = subpass->color_attachments[i];
|
struct radv_subpass_attachment src_att = subpass->color_attachments[i];
|
||||||
VkAttachmentReference dest_att = subpass->resolve_attachments[i];
|
struct radv_subpass_attachment dest_att = subpass->resolve_attachments[i];
|
||||||
|
|
||||||
if (src_att.attachment == VK_ATTACHMENT_UNUSED ||
|
if (src_att.attachment == VK_ATTACHMENT_UNUSED ||
|
||||||
dest_att.attachment == VK_ATTACHMENT_UNUSED)
|
dest_att.attachment == VK_ATTACHMENT_UNUSED)
|
||||||
|
@@ -501,8 +501,8 @@ radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer)
|
|||||||
RADV_META_SAVE_DESCRIPTORS);
|
RADV_META_SAVE_DESCRIPTORS);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < subpass->color_count; ++i) {
|
for (uint32_t i = 0; i < subpass->color_count; ++i) {
|
||||||
VkAttachmentReference src_att = subpass->color_attachments[i];
|
struct radv_subpass_attachment src_att = subpass->color_attachments[i];
|
||||||
VkAttachmentReference dest_att = subpass->resolve_attachments[i];
|
struct radv_subpass_attachment dest_att = subpass->resolve_attachments[i];
|
||||||
struct radv_image_view *src_iview = cmd_buffer->state.framebuffer->attachments[src_att.attachment].attachment;
|
struct radv_image_view *src_iview = cmd_buffer->state.framebuffer->attachments[src_att.attachment].attachment;
|
||||||
struct radv_image_view *dst_iview = cmd_buffer->state.framebuffer->attachments[dest_att.attachment].attachment;
|
struct radv_image_view *dst_iview = cmd_buffer->state.framebuffer->attachments[dest_att.attachment].attachment;
|
||||||
if (dest_att.attachment == VK_ATTACHMENT_UNUSED)
|
if (dest_att.attachment == VK_ATTACHMENT_UNUSED)
|
||||||
|
@@ -611,8 +611,8 @@ radv_cmd_buffer_resolve_subpass_fs(struct radv_cmd_buffer *cmd_buffer)
|
|||||||
radv_decompress_resolve_subpass_src(cmd_buffer);
|
radv_decompress_resolve_subpass_src(cmd_buffer);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < subpass->color_count; ++i) {
|
for (uint32_t i = 0; i < subpass->color_count; ++i) {
|
||||||
VkAttachmentReference src_att = subpass->color_attachments[i];
|
struct radv_subpass_attachment src_att = subpass->color_attachments[i];
|
||||||
VkAttachmentReference dest_att = subpass->resolve_attachments[i];
|
struct radv_subpass_attachment dest_att = subpass->resolve_attachments[i];
|
||||||
|
|
||||||
if (src_att.attachment == VK_ATTACHMENT_UNUSED ||
|
if (src_att.attachment == VK_ATTACHMENT_UNUSED ||
|
||||||
dest_att.attachment == VK_ATTACHMENT_UNUSED)
|
dest_att.attachment == VK_ATTACHMENT_UNUSED)
|
||||||
@@ -623,7 +623,7 @@ radv_cmd_buffer_resolve_subpass_fs(struct radv_cmd_buffer *cmd_buffer)
|
|||||||
|
|
||||||
struct radv_subpass resolve_subpass = {
|
struct radv_subpass resolve_subpass = {
|
||||||
.color_count = 1,
|
.color_count = 1,
|
||||||
.color_attachments = (VkAttachmentReference[]) { dest_att },
|
.color_attachments = (struct radv_subpass_attachment[]) { dest_att },
|
||||||
.depth_stencil_attachment = { .attachment = VK_ATTACHMENT_UNUSED },
|
.depth_stencil_attachment = { .attachment = VK_ATTACHMENT_UNUSED },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -80,7 +80,7 @@ VkResult radv_CreateRenderPass(
|
|||||||
// att->stencil_store_op = pCreateInfo->pAttachments[i].stencilStoreOp;
|
// att->stencil_store_op = pCreateInfo->pAttachments[i].stencilStoreOp;
|
||||||
}
|
}
|
||||||
uint32_t subpass_attachment_count = 0;
|
uint32_t subpass_attachment_count = 0;
|
||||||
VkAttachmentReference *p;
|
struct radv_subpass_attachment *p;
|
||||||
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 VkSubpassDescription *desc = &pCreateInfo->pSubpasses[i];
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ VkResult radv_CreateRenderPass(
|
|||||||
if (subpass_attachment_count) {
|
if (subpass_attachment_count) {
|
||||||
pass->subpass_attachments =
|
pass->subpass_attachments =
|
||||||
vk_alloc2(&device->alloc, pAllocator,
|
vk_alloc2(&device->alloc, pAllocator,
|
||||||
subpass_attachment_count * sizeof(VkAttachmentReference), 8,
|
subpass_attachment_count * sizeof(struct radv_subpass_attachment), 8,
|
||||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||||
if (pass->subpass_attachments == NULL) {
|
if (pass->subpass_attachments == NULL) {
|
||||||
vk_free2(&device->alloc, pAllocator, pass);
|
vk_free2(&device->alloc, pAllocator, pass);
|
||||||
@@ -119,8 +119,10 @@ VkResult radv_CreateRenderPass(
|
|||||||
p += desc->inputAttachmentCount;
|
p += desc->inputAttachmentCount;
|
||||||
|
|
||||||
for (uint32_t j = 0; j < desc->inputAttachmentCount; j++) {
|
for (uint32_t j = 0; j < desc->inputAttachmentCount; j++) {
|
||||||
subpass->input_attachments[j]
|
subpass->input_attachments[j] = (struct radv_subpass_attachment) {
|
||||||
= desc->pInputAttachments[j];
|
.attachment = desc->pInputAttachments[j].attachment,
|
||||||
|
.layout = desc->pInputAttachments[j].layout,
|
||||||
|
};
|
||||||
if (desc->pInputAttachments[j].attachment != VK_ATTACHMENT_UNUSED)
|
if (desc->pInputAttachments[j].attachment != VK_ATTACHMENT_UNUSED)
|
||||||
pass->attachments[desc->pInputAttachments[j].attachment].view_mask |= subpass->view_mask;
|
pass->attachments[desc->pInputAttachments[j].attachment].view_mask |= subpass->view_mask;
|
||||||
}
|
}
|
||||||
@@ -131,8 +133,10 @@ VkResult radv_CreateRenderPass(
|
|||||||
p += desc->colorAttachmentCount;
|
p += desc->colorAttachmentCount;
|
||||||
|
|
||||||
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
|
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
|
||||||
subpass->color_attachments[j]
|
subpass->color_attachments[j] = (struct radv_subpass_attachment) {
|
||||||
= desc->pColorAttachments[j];
|
.attachment = desc->pColorAttachments[j].attachment,
|
||||||
|
.layout = desc->pColorAttachments[j].layout,
|
||||||
|
};
|
||||||
if (desc->pColorAttachments[j].attachment != VK_ATTACHMENT_UNUSED) {
|
if (desc->pColorAttachments[j].attachment != VK_ATTACHMENT_UNUSED) {
|
||||||
pass->attachments[desc->pColorAttachments[j].attachment].view_mask |= subpass->view_mask;
|
pass->attachments[desc->pColorAttachments[j].attachment].view_mask |= subpass->view_mask;
|
||||||
color_sample_count = pCreateInfo->pAttachments[desc->pColorAttachments[j].attachment].samples;
|
color_sample_count = pCreateInfo->pAttachments[desc->pColorAttachments[j].attachment].samples;
|
||||||
@@ -147,8 +151,10 @@ VkResult radv_CreateRenderPass(
|
|||||||
|
|
||||||
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
|
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
|
||||||
uint32_t a = desc->pResolveAttachments[j].attachment;
|
uint32_t a = desc->pResolveAttachments[j].attachment;
|
||||||
subpass->resolve_attachments[j]
|
subpass->resolve_attachments[j] = (struct radv_subpass_attachment) {
|
||||||
= desc->pResolveAttachments[j];
|
.attachment = desc->pResolveAttachments[j].attachment,
|
||||||
|
.layout = desc->pResolveAttachments[j].layout,
|
||||||
|
};
|
||||||
if (a != VK_ATTACHMENT_UNUSED) {
|
if (a != VK_ATTACHMENT_UNUSED) {
|
||||||
subpass->has_resolve = true;
|
subpass->has_resolve = true;
|
||||||
pass->attachments[desc->pResolveAttachments[j].attachment].view_mask |= subpass->view_mask;
|
pass->attachments[desc->pResolveAttachments[j].attachment].view_mask |= subpass->view_mask;
|
||||||
@@ -157,8 +163,10 @@ VkResult radv_CreateRenderPass(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (desc->pDepthStencilAttachment) {
|
if (desc->pDepthStencilAttachment) {
|
||||||
subpass->depth_stencil_attachment =
|
subpass->depth_stencil_attachment = (struct radv_subpass_attachment) {
|
||||||
*desc->pDepthStencilAttachment;
|
.attachment = desc->pDepthStencilAttachment->attachment,
|
||||||
|
.layout = desc->pDepthStencilAttachment->layout,
|
||||||
|
};
|
||||||
if (desc->pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) {
|
if (desc->pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) {
|
||||||
pass->attachments[desc->pDepthStencilAttachment->attachment].view_mask |= subpass->view_mask;
|
pass->attachments[desc->pDepthStencilAttachment->attachment].view_mask |= subpass->view_mask;
|
||||||
depth_sample_count = pCreateInfo->pAttachments[desc->pDepthStencilAttachment->attachment].samples;
|
depth_sample_count = pCreateInfo->pAttachments[desc->pDepthStencilAttachment->attachment].samples;
|
||||||
|
@@ -1711,13 +1711,18 @@ struct radv_subpass_barrier {
|
|||||||
VkAccessFlags dst_access_mask;
|
VkAccessFlags dst_access_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct radv_subpass_attachment {
|
||||||
|
uint32_t attachment;
|
||||||
|
VkImageLayout layout;
|
||||||
|
};
|
||||||
|
|
||||||
struct radv_subpass {
|
struct radv_subpass {
|
||||||
uint32_t input_count;
|
uint32_t input_count;
|
||||||
uint32_t color_count;
|
uint32_t color_count;
|
||||||
VkAttachmentReference * input_attachments;
|
struct radv_subpass_attachment * input_attachments;
|
||||||
VkAttachmentReference * color_attachments;
|
struct radv_subpass_attachment * color_attachments;
|
||||||
VkAttachmentReference * resolve_attachments;
|
struct radv_subpass_attachment * resolve_attachments;
|
||||||
VkAttachmentReference depth_stencil_attachment;
|
struct radv_subpass_attachment depth_stencil_attachment;
|
||||||
|
|
||||||
/** Subpass has at least one resolve attachment */
|
/** Subpass has at least one resolve attachment */
|
||||||
bool has_resolve;
|
bool has_resolve;
|
||||||
@@ -1741,7 +1746,7 @@ struct radv_render_pass_attachment {
|
|||||||
struct radv_render_pass {
|
struct radv_render_pass {
|
||||||
uint32_t attachment_count;
|
uint32_t attachment_count;
|
||||||
uint32_t subpass_count;
|
uint32_t subpass_count;
|
||||||
VkAttachmentReference * subpass_attachments;
|
struct radv_subpass_attachment * subpass_attachments;
|
||||||
struct radv_render_pass_attachment * attachments;
|
struct radv_render_pass_attachment * attachments;
|
||||||
struct radv_subpass_barrier end_barrier;
|
struct radv_subpass_barrier end_barrier;
|
||||||
struct radv_subpass subpasses[0];
|
struct radv_subpass subpasses[0];
|
||||||
|
Reference in New Issue
Block a user