mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-01-06 05:44:48 +08:00
vulkan/render_pass: Use a special layout for self-dependencies
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16953>
This commit is contained in:
parent
f10012a2b2
commit
6216c59dbb
@ -7169,6 +7169,7 @@ void genX(CmdEndRendering)(
|
||||
* - VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
|
||||
* - VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
|
||||
* - VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL
|
||||
* - VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA
|
||||
*
|
||||
* For general, we have no nice opportunity to transition so we do the copy
|
||||
* to the shadow unconditionally at the end of the subpass. For transfer
|
||||
@ -7182,7 +7183,8 @@ void genX(CmdEndRendering)(
|
||||
anv_image_aspect_to_plane(image, VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
|
||||
if (anv_surface_is_valid(&image->planes[plane].shadow_surface) &&
|
||||
gfx->stencil_att.layout == VK_IMAGE_LAYOUT_GENERAL) {
|
||||
(gfx->stencil_att.layout == VK_IMAGE_LAYOUT_GENERAL ||
|
||||
gfx->stencil_att.layout == VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA)) {
|
||||
anv_image_copy_to_shadow(cmd_buffer, image,
|
||||
VK_IMAGE_ASPECT_STENCIL_BIT,
|
||||
iview->planes[plane].isl.base_level, 1,
|
||||
|
@ -521,6 +521,7 @@ dzn_image_layout_to_state(VkImageLayout layout, VkImageAspectFlagBits aspect)
|
||||
case VK_IMAGE_LAYOUT_PREINITIALIZED:
|
||||
case VK_IMAGE_LAYOUT_UNDEFINED:
|
||||
case VK_IMAGE_LAYOUT_GENERAL:
|
||||
case VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA:
|
||||
/* YOLO! */
|
||||
case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
|
||||
return D3D12_RESOURCE_STATE_COMMON;
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "vk_common_entrypoints.h"
|
||||
#include "vk_device.h"
|
||||
#include "vk_format.h"
|
||||
#include "vk_render_pass.h"
|
||||
#include "vk_util.h"
|
||||
#include "vulkan/wsi/wsi_common.h"
|
||||
|
||||
@ -555,6 +556,14 @@ vk_image_layout_is_read_only(VkImageLayout layout,
|
||||
case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL:
|
||||
case VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL:
|
||||
case VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR:
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wswitch"
|
||||
#endif
|
||||
case VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA:
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
return false;
|
||||
|
||||
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
|
||||
@ -703,6 +712,14 @@ vk_image_layout_to_usage_flags(VkImageLayout layout,
|
||||
return 0u;
|
||||
|
||||
case VK_IMAGE_LAYOUT_GENERAL:
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wswitch"
|
||||
#endif
|
||||
case VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA:
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
return ~0u;
|
||||
|
||||
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
|
||||
|
@ -488,11 +488,6 @@ vk_common_CreateRenderPass2(VkDevice _device,
|
||||
subpass->view_mask = desc->viewMask ? desc->viewMask : 1;
|
||||
pass->view_mask |= subpass->view_mask;
|
||||
|
||||
assert(desc->colorAttachmentCount <= 32);
|
||||
uint32_t color_self_deps = 0;
|
||||
bool has_depth_self_dep = false;
|
||||
bool has_stencil_self_dep = false;
|
||||
|
||||
subpass->input_count = desc->inputAttachmentCount;
|
||||
if (desc->inputAttachmentCount > 0) {
|
||||
subpass->input_attachments = next_subpass_attachment;
|
||||
@ -504,25 +499,6 @@ vk_common_CreateRenderPass2(VkDevice _device,
|
||||
&desc->pInputAttachments[a],
|
||||
pCreateInfo->pAttachments,
|
||||
VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
|
||||
|
||||
if (desc->pInputAttachments[a].attachment != VK_ATTACHMENT_UNUSED) {
|
||||
for (uint32_t c = 0; c < desc->colorAttachmentCount; c++) {
|
||||
if (desc->pColorAttachments[c].attachment ==
|
||||
desc->pInputAttachments[a].attachment)
|
||||
color_self_deps |= (1u << c);
|
||||
}
|
||||
|
||||
if (desc->pDepthStencilAttachment != NULL &&
|
||||
desc->pDepthStencilAttachment->attachment ==
|
||||
desc->pInputAttachments[a].attachment) {
|
||||
VkImageAspectFlags aspects =
|
||||
subpass->input_attachments[a].aspects;
|
||||
if (aspects & VK_IMAGE_ASPECT_DEPTH_BIT)
|
||||
has_depth_self_dep = true;
|
||||
if (aspects & VK_IMAGE_ASPECT_STENCIL_BIT)
|
||||
has_stencil_self_dep = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -616,6 +592,48 @@ vk_common_CreateRenderPass2(VkDevice _device,
|
||||
fsr_att_info->shadingRateAttachmentTexelSize;
|
||||
}
|
||||
|
||||
/* Figure out any self-dependencies */
|
||||
assert(desc->colorAttachmentCount <= 32);
|
||||
uint32_t color_self_deps = 0;
|
||||
bool has_depth_self_dep = false;
|
||||
bool has_stencil_self_dep = false;
|
||||
for (uint32_t a = 0; a < desc->inputAttachmentCount; a++) {
|
||||
if (desc->pInputAttachments[a].attachment == VK_ATTACHMENT_UNUSED)
|
||||
continue;
|
||||
|
||||
for (uint32_t c = 0; c < desc->colorAttachmentCount; c++) {
|
||||
if (desc->pColorAttachments[c].attachment ==
|
||||
desc->pInputAttachments[a].attachment) {
|
||||
subpass->input_attachments[a].layout =
|
||||
VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA;
|
||||
subpass->color_attachments[c].layout =
|
||||
VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA;
|
||||
color_self_deps |= (1u << c);
|
||||
}
|
||||
}
|
||||
|
||||
if (desc->pDepthStencilAttachment != NULL &&
|
||||
desc->pDepthStencilAttachment->attachment ==
|
||||
desc->pInputAttachments[a].attachment) {
|
||||
VkImageAspectFlags aspects =
|
||||
subpass->input_attachments[a].aspects;
|
||||
if (aspects & VK_IMAGE_ASPECT_DEPTH_BIT) {
|
||||
subpass->input_attachments[a].layout =
|
||||
VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA;
|
||||
subpass->depth_stencil_attachment->layout =
|
||||
VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA;
|
||||
has_depth_self_dep = true;
|
||||
}
|
||||
if (aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
|
||||
subpass->input_attachments[a].stencil_layout =
|
||||
VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA;
|
||||
subpass->depth_stencil_attachment->stencil_layout =
|
||||
VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA;
|
||||
has_stencil_self_dep = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VkFormat *color_formats = NULL;
|
||||
VkSampleCountFlagBits samples = 0;
|
||||
if (desc->colorAttachmentCount > 0) {
|
||||
@ -974,6 +992,14 @@ vk_image_layout_supports_input_attachment(VkImageLayout layout)
|
||||
case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL:
|
||||
case VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL:
|
||||
case VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR:
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wswitch"
|
||||
#endif
|
||||
case VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA:
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -79,6 +79,8 @@ typedef struct VkRenderingAttachmentInitialLayoutInfoMESA {
|
||||
VkImageLayout initialLayout;
|
||||
} VkRenderingAttachmentInitialLayoutInfoMESA;
|
||||
|
||||
#define VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA (VkImageLayout)1000044902
|
||||
|
||||
struct vk_subpass_attachment {
|
||||
/** VkAttachmentReference2::attachment */
|
||||
uint32_t attachment;
|
||||
|
Loading…
Reference in New Issue
Block a user