#include "anv_private.h"
-#include "util/vk_util.h"
+#include "vk_util.h"
static unsigned
num_subpass_attachments(const VkSubpassDescription *desc)
(desc->pDepthStencilAttachment != NULL);
}
+static void
+init_first_subpass_layout(struct anv_render_pass_attachment * const att,
+ const VkAttachmentReference att_ref)
+{
+ if (att->first_subpass_layout == VK_IMAGE_LAYOUT_UNDEFINED) {
+ att->first_subpass_layout = att_ref.layout;
+ assert(att->first_subpass_layout != VK_IMAGE_LAYOUT_UNDEFINED);
+ }
+}
+
VkResult anv_CreateRenderPass(
VkDevice _device,
const VkRenderPassCreateInfo* pCreateInfo,
anv_multialloc_add(&ma, &attachments, pCreateInfo->attachmentCount);
anv_multialloc_add(&ma, &subpass_flushes, pCreateInfo->subpassCount + 1);
- VkAttachmentReference *subpass_attachments;
+ struct anv_subpass_attachment *subpass_attachments;
uint32_t subpass_attachment_count = 0;
for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
subpass_attachment_count +=
}
anv_multialloc_add(&ma, &subpass_attachments, subpass_attachment_count);
- enum anv_subpass_usage *subpass_usages;
- anv_multialloc_add(&ma, &subpass_usages,
- pCreateInfo->subpassCount * pCreateInfo->attachmentCount);
-
if (!anv_multialloc_alloc2(&ma, &device->alloc, pAllocator,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT))
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
att->stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp;
att->initial_layout = pCreateInfo->pAttachments[i].initialLayout;
att->final_layout = pCreateInfo->pAttachments[i].finalLayout;
- att->subpass_usage = subpass_usages;
- subpass_usages += pass->subpass_count;
+ att->first_subpass_layout = VK_IMAGE_LAYOUT_UNDEFINED;
}
bool has_color = false, has_depth = false, has_input = false;
for (uint32_t j = 0; j < desc->inputAttachmentCount; j++) {
uint32_t a = desc->pInputAttachments[j].attachment;
- subpass->input_attachments[j] = desc->pInputAttachments[j];
+ subpass->input_attachments[j] = (struct anv_subpass_attachment) {
+ .usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT,
+ .attachment = desc->pInputAttachments[j].attachment,
+ .layout = desc->pInputAttachments[j].layout,
+ };
if (a != VK_ATTACHMENT_UNUSED) {
has_input = true;
pass->attachments[a].usage |= VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
- pass->attachments[a].subpass_usage[i] |= ANV_SUBPASS_USAGE_INPUT;
pass->attachments[a].last_subpass_idx = i;
+ init_first_subpass_layout(&pass->attachments[a],
+ desc->pInputAttachments[j]);
if (desc->pDepthStencilAttachment &&
a == desc->pDepthStencilAttachment->attachment)
subpass->has_ds_self_dep = true;
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
uint32_t a = desc->pColorAttachments[j].attachment;
- subpass->color_attachments[j] = desc->pColorAttachments[j];
+ subpass->color_attachments[j] = (struct anv_subpass_attachment) {
+ .usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
+ .attachment = desc->pColorAttachments[j].attachment,
+ .layout = desc->pColorAttachments[j].layout,
+ };
if (a != VK_ATTACHMENT_UNUSED) {
has_color = true;
pass->attachments[a].usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
- pass->attachments[a].subpass_usage[i] |= ANV_SUBPASS_USAGE_DRAW;
pass->attachments[a].last_subpass_idx = i;
+
+ init_first_subpass_layout(&pass->attachments[a],
+ desc->pColorAttachments[j]);
}
}
}
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
uint32_t a = desc->pResolveAttachments[j].attachment;
- subpass->resolve_attachments[j] = desc->pResolveAttachments[j];
+ subpass->resolve_attachments[j] = (struct anv_subpass_attachment) {
+ .usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT,
+ .attachment = desc->pResolveAttachments[j].attachment,
+ .layout = desc->pResolveAttachments[j].layout,
+ };
if (a != VK_ATTACHMENT_UNUSED) {
subpass->has_resolve = true;
uint32_t color_att = desc->pColorAttachments[j].attachment;
pass->attachments[color_att].usage |=
VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
pass->attachments[a].usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
-
- pass->attachments[color_att].subpass_usage[i] |=
- ANV_SUBPASS_USAGE_RESOLVE_SRC;
- pass->attachments[a].subpass_usage[i] |=
- ANV_SUBPASS_USAGE_RESOLVE_DST;
pass->attachments[a].last_subpass_idx = i;
+
+ init_first_subpass_layout(&pass->attachments[a],
+ desc->pResolveAttachments[j]);
}
}
}
if (desc->pDepthStencilAttachment) {
uint32_t a = desc->pDepthStencilAttachment->attachment;
- *subpass_attachments++ = subpass->depth_stencil_attachment =
- *desc->pDepthStencilAttachment;
+ subpass->depth_stencil_attachment = (struct anv_subpass_attachment) {
+ .usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
+ .attachment = desc->pDepthStencilAttachment->attachment,
+ .layout = desc->pDepthStencilAttachment->layout,
+ };
+ *subpass_attachments++ = subpass->depth_stencil_attachment;
if (a != VK_ATTACHMENT_UNUSED) {
has_depth = true;
pass->attachments[a].usage |=
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
- pass->attachments[a].subpass_usage[i] |= ANV_SUBPASS_USAGE_DRAW;
pass->attachments[a].last_subpass_idx = i;
+
+ init_first_subpass_layout(&pass->attachments[a],
+ *desc->pDepthStencilAttachment);
}
} else {
- subpass->depth_stencil_attachment.attachment = VK_ATTACHMENT_UNUSED;
- subpass->depth_stencil_attachment.layout = VK_IMAGE_LAYOUT_UNDEFINED;
+ subpass->depth_stencil_attachment = (struct anv_subpass_attachment) {
+ .usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
+ .attachment = VK_ATTACHMENT_UNUSED,
+ .layout = VK_IMAGE_LAYOUT_UNDEFINED,
+ };
}
}
vk_foreach_struct(ext, pCreateInfo->pNext) {
switch (ext->sType) {
- case VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO_KHX: {
- VkRenderPassMultiviewCreateInfoKHX *mv = (void *)ext;
+ case VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO_KHR: {
+ VkRenderPassMultiviewCreateInfoKHR *mv = (void *)ext;
for (uint32_t i = 0; i < mv->subpassCount; i++) {
pass->subpasses[i].view_mask = mv->pViewMasks[i];