aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2020-03-17 09:45:50 +0100
committerSamuel Pitoiset <[email protected]>2020-03-17 13:24:36 +0100
commit46e8ba1344e840f9406537ae73c841a357278924 (patch)
tree404e4e4967591ffd870aa859795f53ce54ac8c28 /src
parenta0591863db891fd39bdbae199f740b0d4b5f0173 (diff)
radv: only inject implicit subpass dependencies if necessary
The Vulkan 1.2.134 spec update clarified when implicit subpass dependencies should be injected by the driver. They only make sense if automatic layout transitions are performed. This should fix a performance regression with RPCS3 (although they added a workaround for RADV since the regression has been found). Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2502 Fixes: e60de085473 ("radv: handle missing implicit subpass dependencies") Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4210> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4210>
Diffstat (limited to 'src')
-rw-r--r--src/amd/vulkan/radv_pass.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/amd/vulkan/radv_pass.c b/src/amd/vulkan/radv_pass.c
index 89343d8a0d9..4df3e81eead 100644
--- a/src/amd/vulkan/radv_pass.c
+++ b/src/amd/vulkan/radv_pass.c
@@ -59,6 +59,32 @@ radv_render_pass_add_subpass_dep(struct radv_render_pass *pass,
}
}
+static bool
+radv_pass_has_layout_transitions(const struct radv_render_pass *pass)
+{
+ for (unsigned i = 0; i < pass->subpass_count; i++) {
+ const struct radv_subpass *subpass = &pass->subpasses[i];
+ for (unsigned j = 0; j < subpass->attachment_count; j++) {
+ const uint32_t a = subpass->attachments[j].attachment;
+ if (a == VK_ATTACHMENT_UNUSED)
+ continue;
+
+ uint32_t initial_layout = pass->attachments[a].initial_layout;
+ uint32_t stencil_initial_layout = pass->attachments[a].stencil_initial_layout;
+ uint32_t final_layout = pass->attachments[a].final_layout;
+ uint32_t stencil_final_layout = pass->attachments[a].stencil_final_layout;
+
+ if (subpass->attachments[j].layout != initial_layout ||
+ subpass->attachments[j].layout != stencil_initial_layout ||
+ subpass->attachments[j].layout != final_layout ||
+ subpass->attachments[j].layout != stencil_final_layout)
+ return true;
+ }
+ }
+
+ return false;
+}
+
static void
radv_render_pass_add_implicit_deps(struct radv_render_pass *pass,
bool has_ingoing_dep, bool has_outgoing_dep)
@@ -68,7 +94,9 @@ radv_render_pass_add_implicit_deps(struct radv_render_pass *pass,
* 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
+ * used in. The implicit subpass dependency only exists if there
+ * exists an automatic layout transition away from initialLayout.
+ * The subpass dependency operates as if defined with the
* following parameters:
*
* VkSubpassDependency implicitDependency = {
@@ -88,8 +116,10 @@ radv_render_pass_add_implicit_deps(struct radv_render_pass *pass,
* 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:
+ * VK_SUBPASS_EXTERNAL. The implicit subpass dependency only exists
+ * if there exists an automatic layout transition into finalLayout.
+ * The subpass dependency operates as if defined with the following
+ * parameters:
*
* VkSubpassDependency implicitDependency = {
* .srcSubpass = lastSubpass; // Last subpass attachment is used in
@@ -106,6 +136,12 @@ radv_render_pass_add_implicit_deps(struct radv_render_pass *pass,
* };
*/
+ /* Implicit subpass dependencies only make sense if automatic layout
+ * transitions are performed.
+ */
+ if (!radv_pass_has_layout_transitions(pass))
+ return;
+
if (!has_ingoing_dep) {
const VkSubpassDependency2KHR implicit_ingoing_dep = {
.srcSubpass = VK_SUBPASS_EXTERNAL,