if (!framebuffer || !subpass)
return;
- att_idx = subpass->depth_stencil_attachment.attachment;
- if (att_idx == VK_ATTACHMENT_UNUSED)
+ if (!subpass->depth_stencil_attachment)
return;
+ att_idx = subpass->depth_stencil_attachment->attachment;
att = &framebuffer->attachments[att_idx];
if (att->attachment->image != image)
return;
*/
if ((aspects & VK_IMAGE_ASPECT_DEPTH_BIT) &&
ds_clear_value.depth == 0.0) {
- VkImageLayout layout = subpass->depth_stencil_attachment.layout;
+ VkImageLayout layout = subpass->depth_stencil_attachment->layout;
radv_update_zrange_precision(cmd_buffer, &att->ds, image,
layout, false);
num_bpp64_colorbufs++;
}
- if(subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED) {
- int idx = subpass->depth_stencil_attachment.attachment;
- VkImageLayout layout = subpass->depth_stencil_attachment.layout;
+ if (subpass->depth_stencil_attachment) {
+ int idx = subpass->depth_stencil_attachment->attachment;
+ VkImageLayout layout = subpass->depth_stencil_attachment->layout;
struct radv_attachment_info *att = &framebuffer->attachments[idx];
struct radv_image *image = att->attachment->image;
radv_cs_add_buffer(cmd_buffer->device->ws, cmd_buffer->cs, att->attachment->bo);
subpass->input_attachments[i]);
}
- if (subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED) {
+ if (subpass->depth_stencil_attachment) {
radv_handle_subpass_image_transition(cmd_buffer,
- subpass->depth_stencil_attachment);
+ *subpass->depth_stencil_attachment);
}
radv_cmd_buffer_set_subpass(cmd_buffer, subpass);
.color_attachments = (struct radv_subpass_attachment[]) {
subpass->color_attachments[clear_att->colorAttachment]
},
- .depth_stencil_attachment = (struct radv_subpass_attachment) { VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_UNDEFINED }
+ .depth_stencil_attachment = NULL,
};
radv_cmd_buffer_set_subpass(cmd_buffer, &clear_subpass);
struct radv_meta_state *meta_state = &device->meta_state;
const struct radv_subpass *subpass = cmd_buffer->state.subpass;
const struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
- const uint32_t pass_att = subpass->depth_stencil_attachment.attachment;
+ const uint32_t pass_att = subpass->depth_stencil_attachment->attachment;
VkClearDepthStencilValue clear_value = clear_att->clearValue.depthStencil;
VkImageAspectFlags aspects = clear_att->aspectMask;
const struct radv_image_view *iview = fb->attachments[pass_att].attachment;
iview,
samples_log2,
aspects,
- subpass->depth_stencil_attachment.layout,
+ subpass->depth_stencil_attachment->layout,
clear_rect,
clear_value);
if (!pipeline)
pipeline);
if (depth_view_can_fast_clear(cmd_buffer, iview, aspects,
- subpass->depth_stencil_attachment.layout,
+ subpass->depth_stencil_attachment->layout,
clear_rect, clear_value))
radv_update_ds_clear_metadata(cmd_buffer, iview->image,
clear_value, aspects);
emit_color_clear(cmd_buffer, clear_att, clear_rect, view_mask);
}
} else {
- const uint32_t pass_att = subpass->depth_stencil_attachment.attachment;
- VkImageLayout image_layout = subpass->depth_stencil_attachment.layout;
+ const uint32_t pass_att = subpass->depth_stencil_attachment->attachment;
+ VkImageLayout image_layout = subpass->depth_stencil_attachment->layout;
const struct radv_image_view *iview = fb->attachments[pass_att].attachment;
VkClearDepthStencilValue clear_value = clear_att->clearValue.depthStencil;
return true;
}
- a = cmd_state->subpass->depth_stencil_attachment.attachment;
+ if (!cmd_state->subpass->depth_stencil_attachment)
+ return false;
+
+ a = cmd_state->subpass->depth_stencil_attachment->attachment;
return radv_attachment_needs_clear(cmd_state, a);
}
&post_flush);
}
- uint32_t ds = cmd_state->subpass->depth_stencil_attachment.attachment;
- if (radv_attachment_needs_clear(cmd_state, ds)) {
- VkClearAttachment clear_att = {
- .aspectMask = cmd_state->attachments[ds].pending_clear_aspects,
- .clearValue = cmd_state->attachments[ds].clear_value,
- };
-
- radv_subpass_clear_attachment(cmd_buffer,
- &cmd_state->attachments[ds],
- &clear_att, &pre_flush,
- &post_flush);
+ if (cmd_state->subpass->depth_stencil_attachment) {
+ uint32_t ds = cmd_state->subpass->depth_stencil_attachment->attachment;
+ if (radv_attachment_needs_clear(cmd_state, ds)) {
+ VkClearAttachment clear_att = {
+ .aspectMask = cmd_state->attachments[ds].pending_clear_aspects,
+ .clearValue = cmd_state->attachments[ds].clear_value,
+ };
+
+ radv_subpass_clear_attachment(cmd_buffer,
+ &cmd_state->attachments[ds],
+ &clear_att, &pre_flush,
+ &post_flush);
+ }
}
radv_meta_restore(&saved_state, cmd_buffer);
struct radv_subpass resolve_subpass = {
.color_count = 2,
.color_attachments = (struct radv_subpass_attachment[]) { src_att, dest_att },
- .depth_stencil_attachment = { .attachment = VK_ATTACHMENT_UNUSED },
+ .depth_stencil_attachment = NULL,
};
radv_cmd_buffer_set_subpass(cmd_buffer, &resolve_subpass);
struct radv_subpass resolve_subpass = {
.color_count = 1,
.color_attachments = (struct radv_subpass_attachment[]) { dest_att },
- .depth_stencil_attachment = { .attachment = VK_ATTACHMENT_UNUSED },
+ .depth_stencil_attachment = NULL,
};
radv_cmd_buffer_set_subpass(cmd_buffer, &resolve_subpass);
#include "vk_util.h"
+static void
+radv_render_pass_compile(struct radv_render_pass *pass)
+{
+ for (uint32_t i = 0; i < pass->subpass_count; i++) {
+ struct radv_subpass *subpass = &pass->subpasses[i];
+
+ /* We don't allow depth_stencil_attachment to be non-NULL and
+ * be VK_ATTACHMENT_UNUSED. This way something can just check
+ * for NULL and be guaranteed that they have a valid
+ * attachment.
+ */
+ if (subpass->depth_stencil_attachment &&
+ subpass->depth_stencil_attachment->attachment == VK_ATTACHMENT_UNUSED)
+ subpass->depth_stencil_attachment = NULL;
+ }
+}
+
+static unsigned
+radv_num_subpass_attachments(const VkSubpassDescription *desc)
+{
+ return desc->inputAttachmentCount +
+ desc->colorAttachmentCount +
+ (desc->pResolveAttachments ? desc->colorAttachmentCount : 0) +
+ (desc->pDepthStencilAttachment != NULL);
+}
+
VkResult radv_CreateRenderPass(
VkDevice _device,
const VkRenderPassCreateInfo* pCreateInfo,
uint32_t subpass_attachment_count = 0;
struct radv_subpass_attachment *p;
for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
- const VkSubpassDescription *desc = &pCreateInfo->pSubpasses[i];
-
subpass_attachment_count +=
- desc->inputAttachmentCount +
- desc->colorAttachmentCount +
- (desc->pResolveAttachments ? desc->colorAttachmentCount : 0) +
- (desc->pDepthStencilAttachment != NULL);
+ radv_num_subpass_attachments(&pCreateInfo->pSubpasses[i]);
}
if (subpass_attachment_count) {
subpass->input_count = desc->inputAttachmentCount;
subpass->color_count = desc->colorAttachmentCount;
+ subpass->attachment_count = radv_num_subpass_attachments(desc);
+ subpass->attachments = p;
+
if (multiview_info)
subpass->view_mask = multiview_info->pViewMasks[i];
}
if (desc->pDepthStencilAttachment) {
- subpass->depth_stencil_attachment = (struct radv_subpass_attachment) {
+ subpass->depth_stencil_attachment = p++;
+
+ *subpass->depth_stencil_attachment = (struct radv_subpass_attachment) {
.attachment = desc->pDepthStencilAttachment->attachment,
.layout = desc->pDepthStencilAttachment->layout,
};
if (desc->pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) {
depth_sample_count = pCreateInfo->pAttachments[desc->pDepthStencilAttachment->attachment].samples;
}
- } else {
- subpass->depth_stencil_attachment.attachment = VK_ATTACHMENT_UNUSED;
}
subpass->max_sample_count = MAX2(color_sample_count,
}
}
+ radv_render_pass_compile(pass);
+
*pRenderPass = radv_render_pass_to_handle(pass);
return VK_SUCCESS;
}
+static unsigned
+radv_num_subpass_attachments2(const VkSubpassDescription2KHR *desc)
+{
+ return desc->inputAttachmentCount +
+ desc->colorAttachmentCount +
+ (desc->pResolveAttachments ? desc->colorAttachmentCount : 0) +
+ (desc->pDepthStencilAttachment != NULL);
+}
+
VkResult radv_CreateRenderPass2KHR(
VkDevice _device,
const VkRenderPassCreateInfo2KHR* pCreateInfo,
uint32_t subpass_attachment_count = 0;
struct radv_subpass_attachment *p;
for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
- const VkSubpassDescription2KHR *desc = &pCreateInfo->pSubpasses[i];
-
subpass_attachment_count +=
- desc->inputAttachmentCount +
- desc->colorAttachmentCount +
- (desc->pResolveAttachments ? desc->colorAttachmentCount : 0) +
- (desc->pDepthStencilAttachment != NULL);
+ radv_num_subpass_attachments2(&pCreateInfo->pSubpasses[i]);
}
if (subpass_attachment_count) {
subpass->input_count = desc->inputAttachmentCount;
subpass->color_count = desc->colorAttachmentCount;
+ subpass->attachment_count = radv_num_subpass_attachments2(desc);
+ subpass->attachments = p;
subpass->view_mask = desc->viewMask;
if (desc->inputAttachmentCount > 0) {
}
if (desc->pDepthStencilAttachment) {
- subpass->depth_stencil_attachment = (struct radv_subpass_attachment) {
+ subpass->depth_stencil_attachment = p++;
+
+ *subpass->depth_stencil_attachment = (struct radv_subpass_attachment) {
.attachment = desc->pDepthStencilAttachment->attachment,
.layout = desc->pDepthStencilAttachment->layout,
};
if (desc->pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) {
depth_sample_count = pCreateInfo->pAttachments[desc->pDepthStencilAttachment->attachment].samples;
}
- } else {
- subpass->depth_stencil_attachment.attachment = VK_ATTACHMENT_UNUSED;
}
subpass->max_sample_count = MAX2(color_sample_count,
}
}
+ radv_render_pass_compile(pass);
+
*pRenderPass = radv_render_pass_to_handle(pass);
return VK_SUCCESS;
};
if (pCreateInfo->pDepthStencilState &&
- subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED) {
+ subpass->depth_stencil_attachment) {
const VkPipelineDepthStencilStateCreateInfo *vkds =
pCreateInfo->pDepthStencilState;
struct radv_render_pass_attachment *attachment =
- pass->attachments + subpass->depth_stencil_attachment.attachment;
+ pass->attachments + subpass->depth_stencil_attachment->attachment;
bool has_stencil = vk_format_is_stencil(attachment->format);
struct radv_dsa_order_invariance order_invariance[2];
struct radv_shader_variant *ps =
* disabled or if the subpass of the render pass the pipeline is created
* against does not use a depth/stencil attachment.
*/
- if (needed_states &&
- subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED) {
+ if (needed_states && subpass->depth_stencil_attachment) {
assert(pCreateInfo->pDepthStencilState);
if (states & RADV_DYNAMIC_DEPTH_BOUNDS) {
extent = color_entry->extent;
- if (subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED) {
- struct radv_render_pass_attachment *attachment = pass->attachments + subpass->depth_stencil_attachment.attachment;
+ if (subpass->depth_stencil_attachment) {
+ struct radv_render_pass_attachment *attachment = pass->attachments + subpass->depth_stencil_attachment->attachment;
/* Coefficients taken from AMDVLK */
unsigned depth_coeff = vk_format_is_depth(attachment->format) ? 5 : 0;
uint32_t db_render_control = 0, db_render_override2 = 0;
uint32_t db_render_override = 0;
- if (subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED)
- attachment = pass->attachments + subpass->depth_stencil_attachment.attachment;
+ if (subpass->depth_stencil_attachment)
+ attachment = pass->attachments + subpass->depth_stencil_attachment->attachment;
bool has_depth_attachment = attachment && vk_format_is_depth(attachment->format);
bool has_stencil_attachment = attachment && vk_format_is_stencil(attachment->format);
};
struct radv_subpass {
+ uint32_t attachment_count;
+ struct radv_subpass_attachment * attachments;
+
uint32_t input_count;
uint32_t color_count;
struct radv_subpass_attachment * input_attachments;
struct radv_subpass_attachment * color_attachments;
struct radv_subpass_attachment * resolve_attachments;
- struct radv_subpass_attachment depth_stencil_attachment;
+ struct radv_subpass_attachment * depth_stencil_attachment;
/** Subpass has at least one resolve attachment */
bool has_resolve;