anv/pass: Move implicit dependency setup to anv_render_pass_compile
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
@@ -62,6 +62,7 @@ anv_render_pass_compile(struct anv_render_pass *pass)
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
VkImageUsageFlags all_usage = 0;
|
||||||
for (uint32_t i = 0; i < pass->subpass_count; i++) {
|
for (uint32_t i = 0; i < pass->subpass_count; i++) {
|
||||||
struct anv_subpass *subpass = &pass->subpasses[i];
|
struct anv_subpass *subpass = &pass->subpasses[i];
|
||||||
|
|
||||||
@@ -77,6 +78,8 @@ anv_render_pass_compile(struct anv_render_pass *pass)
|
|||||||
pass_att->usage |= subpass_att->usage;
|
pass_att->usage |= subpass_att->usage;
|
||||||
pass_att->last_subpass_idx = i;
|
pass_att->last_subpass_idx = i;
|
||||||
|
|
||||||
|
all_usage |= subpass_att->usage;
|
||||||
|
|
||||||
if (pass_att->first_subpass_layout == VK_IMAGE_LAYOUT_UNDEFINED) {
|
if (pass_att->first_subpass_layout == VK_IMAGE_LAYOUT_UNDEFINED) {
|
||||||
pass_att->first_subpass_layout = subpass_att->layout;
|
pass_att->first_subpass_layout = subpass_att->layout;
|
||||||
assert(pass_att->first_subpass_layout != VK_IMAGE_LAYOUT_UNDEFINED);
|
assert(pass_att->first_subpass_layout != VK_IMAGE_LAYOUT_UNDEFINED);
|
||||||
@@ -105,6 +108,66 @@ anv_render_pass_compile(struct anv_render_pass *pass)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* From the Vulkan 1.0.39 spec:
|
||||||
|
*
|
||||||
|
* If there is no subpass dependency from VK_SUBPASS_EXTERNAL to the
|
||||||
|
* first subpass that uses an attachment, then an implicit subpass
|
||||||
|
* dependency exists from VK_SUBPASS_EXTERNAL to the first subpass it is
|
||||||
|
* used in. The subpass dependency operates as if defined with the
|
||||||
|
* following parameters:
|
||||||
|
*
|
||||||
|
* VkSubpassDependency implicitDependency = {
|
||||||
|
* .srcSubpass = VK_SUBPASS_EXTERNAL;
|
||||||
|
* .dstSubpass = firstSubpass; // First subpass attachment is used in
|
||||||
|
* .srcStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
||||||
|
* .dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
||||||
|
* .srcAccessMask = 0;
|
||||||
|
* .dstAccessMask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT |
|
||||||
|
* VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
|
||||||
|
* VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
|
||||||
|
* VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||||
|
* VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
||||||
|
* .dependencyFlags = 0;
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* Similarly, if there is no subpass dependency from the last subpass
|
||||||
|
* that uses an attachment to VK_SUBPASS_EXTERNAL, then an implicit
|
||||||
|
* subpass dependency exists from the last subpass it is used in to
|
||||||
|
* VK_SUBPASS_EXTERNAL. The subpass dependency operates as if defined
|
||||||
|
* with the following parameters:
|
||||||
|
*
|
||||||
|
* VkSubpassDependency implicitDependency = {
|
||||||
|
* .srcSubpass = lastSubpass; // Last subpass attachment is used in
|
||||||
|
* .dstSubpass = VK_SUBPASS_EXTERNAL;
|
||||||
|
* .srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
||||||
|
* .dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||||
|
* .srcAccessMask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT |
|
||||||
|
* VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
|
||||||
|
* VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
|
||||||
|
* VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||||
|
* VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
||||||
|
* .dstAccessMask = 0;
|
||||||
|
* .dependencyFlags = 0;
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* We could implement this by walking over all of the attachments and
|
||||||
|
* subpasses and checking to see if any of them don't have an external
|
||||||
|
* dependency. Or, we could just be lazy and add a couple extra flushes.
|
||||||
|
* We choose to be lazy.
|
||||||
|
*/
|
||||||
|
if (all_usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) {
|
||||||
|
pass->subpass_flushes[0] |=
|
||||||
|
ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT;
|
||||||
|
}
|
||||||
|
if (all_usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
|
||||||
|
pass->subpass_flushes[pass->subpass_count] |=
|
||||||
|
ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT;
|
||||||
|
}
|
||||||
|
if (all_usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
|
||||||
|
pass->subpass_flushes[pass->subpass_count] |=
|
||||||
|
ANV_PIPE_DEPTH_CACHE_FLUSH_BIT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned
|
static unsigned
|
||||||
@@ -170,7 +233,6 @@ VkResult anv_CreateRenderPass(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_color = false, has_depth = false, has_input = false;
|
|
||||||
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];
|
||||||
struct anv_subpass *subpass = &pass->subpasses[i];
|
struct anv_subpass *subpass = &pass->subpasses[i];
|
||||||
@@ -186,14 +248,11 @@ VkResult anv_CreateRenderPass(
|
|||||||
subpass_attachments += desc->inputAttachmentCount;
|
subpass_attachments += desc->inputAttachmentCount;
|
||||||
|
|
||||||
for (uint32_t j = 0; j < desc->inputAttachmentCount; j++) {
|
for (uint32_t j = 0; j < desc->inputAttachmentCount; j++) {
|
||||||
uint32_t a = desc->pInputAttachments[j].attachment;
|
|
||||||
subpass->input_attachments[j] = (struct anv_subpass_attachment) {
|
subpass->input_attachments[j] = (struct anv_subpass_attachment) {
|
||||||
.usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT,
|
.usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT,
|
||||||
.attachment = desc->pInputAttachments[j].attachment,
|
.attachment = desc->pInputAttachments[j].attachment,
|
||||||
.layout = desc->pInputAttachments[j].layout,
|
.layout = desc->pInputAttachments[j].layout,
|
||||||
};
|
};
|
||||||
if (a != VK_ATTACHMENT_UNUSED)
|
|
||||||
has_input = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,14 +261,11 @@ VkResult anv_CreateRenderPass(
|
|||||||
subpass_attachments += desc->colorAttachmentCount;
|
subpass_attachments += desc->colorAttachmentCount;
|
||||||
|
|
||||||
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
|
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
|
||||||
uint32_t a = desc->pColorAttachments[j].attachment;
|
|
||||||
subpass->color_attachments[j] = (struct anv_subpass_attachment) {
|
subpass->color_attachments[j] = (struct anv_subpass_attachment) {
|
||||||
.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
||||||
.attachment = desc->pColorAttachments[j].attachment,
|
.attachment = desc->pColorAttachments[j].attachment,
|
||||||
.layout = desc->pColorAttachments[j].layout,
|
.layout = desc->pColorAttachments[j].layout,
|
||||||
};
|
};
|
||||||
if (a != VK_ATTACHMENT_UNUSED)
|
|
||||||
has_color = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,15 +283,12 @@ VkResult anv_CreateRenderPass(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (desc->pDepthStencilAttachment) {
|
if (desc->pDepthStencilAttachment) {
|
||||||
uint32_t a = desc->pDepthStencilAttachment->attachment;
|
|
||||||
subpass->depth_stencil_attachment = (struct anv_subpass_attachment) {
|
subpass->depth_stencil_attachment = (struct anv_subpass_attachment) {
|
||||||
.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
||||||
.attachment = desc->pDepthStencilAttachment->attachment,
|
.attachment = desc->pDepthStencilAttachment->attachment,
|
||||||
.layout = desc->pDepthStencilAttachment->layout,
|
.layout = desc->pDepthStencilAttachment->layout,
|
||||||
};
|
};
|
||||||
*subpass_attachments++ = subpass->depth_stencil_attachment;
|
*subpass_attachments++ = subpass->depth_stencil_attachment;
|
||||||
if (a != VK_ATTACHMENT_UNUSED)
|
|
||||||
has_depth = true;
|
|
||||||
} else {
|
} else {
|
||||||
subpass->depth_stencil_attachment = (struct anv_subpass_attachment) {
|
subpass->depth_stencil_attachment = (struct anv_subpass_attachment) {
|
||||||
.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
||||||
@@ -259,66 +312,6 @@ VkResult anv_CreateRenderPass(
|
|||||||
anv_render_pass_add_subpass_dep(pass, &dep2);
|
anv_render_pass_add_subpass_dep(pass, &dep2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* From the Vulkan 1.0.39 spec:
|
|
||||||
*
|
|
||||||
* If there is no subpass dependency from VK_SUBPASS_EXTERNAL to the
|
|
||||||
* first subpass that uses an attachment, then an implicit subpass
|
|
||||||
* dependency exists from VK_SUBPASS_EXTERNAL to the first subpass it is
|
|
||||||
* used in. The subpass dependency operates as if defined with the
|
|
||||||
* following parameters:
|
|
||||||
*
|
|
||||||
* VkSubpassDependency implicitDependency = {
|
|
||||||
* .srcSubpass = VK_SUBPASS_EXTERNAL;
|
|
||||||
* .dstSubpass = firstSubpass; // First subpass attachment is used in
|
|
||||||
* .srcStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
|
||||||
* .dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
|
||||||
* .srcAccessMask = 0;
|
|
||||||
* .dstAccessMask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT |
|
|
||||||
* VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
|
|
||||||
* VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
|
|
||||||
* VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
|
||||||
* VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
|
||||||
* .dependencyFlags = 0;
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* Similarly, if there is no subpass dependency from the last subpass
|
|
||||||
* that uses an attachment to VK_SUBPASS_EXTERNAL, then an implicit
|
|
||||||
* subpass dependency exists from the last subpass it is used in to
|
|
||||||
* VK_SUBPASS_EXTERNAL. The subpass dependency operates as if defined
|
|
||||||
* with the following parameters:
|
|
||||||
*
|
|
||||||
* VkSubpassDependency implicitDependency = {
|
|
||||||
* .srcSubpass = lastSubpass; // Last subpass attachment is used in
|
|
||||||
* .dstSubpass = VK_SUBPASS_EXTERNAL;
|
|
||||||
* .srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
|
||||||
* .dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
|
||||||
* .srcAccessMask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT |
|
|
||||||
* VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
|
|
||||||
* VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
|
|
||||||
* VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
|
||||||
* VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
|
||||||
* .dstAccessMask = 0;
|
|
||||||
* .dependencyFlags = 0;
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* We could implement this by walking over all of the attachments and
|
|
||||||
* subpasses and checking to see if any of them don't have an external
|
|
||||||
* dependency. Or, we could just be lazy and add a couple extra flushes.
|
|
||||||
* We choose to be lazy.
|
|
||||||
*/
|
|
||||||
if (has_input) {
|
|
||||||
pass->subpass_flushes[0] |=
|
|
||||||
ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT;
|
|
||||||
}
|
|
||||||
if (has_color) {
|
|
||||||
pass->subpass_flushes[pass->subpass_count] |=
|
|
||||||
ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT;
|
|
||||||
}
|
|
||||||
if (has_depth) {
|
|
||||||
pass->subpass_flushes[pass->subpass_count] |=
|
|
||||||
ANV_PIPE_DEPTH_CACHE_FLUSH_BIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
vk_foreach_struct(ext, pCreateInfo->pNext) {
|
vk_foreach_struct(ext, pCreateInfo->pNext) {
|
||||||
switch (ext->sType) {
|
switch (ext->sType) {
|
||||||
case VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO_KHR: {
|
case VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO_KHR: {
|
||||||
|
Reference in New Issue
Block a user