From 22ce531e6f379f73bf23e634a37481e993968fb2 Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Sat, 22 Jan 2022 05:43:18 +0530 Subject: [PATCH] Force Memory Barrier at `VkRenderPass` Start We depend on past commands to have completed execution in a renderpass, a subpass dependency on all graphics stages from `VK_SUBPASS_EXTERNAL` to subpass #0 is used to enforce this. Nvidia and Adreno proprietary drivers implicitly do this but Turnip or Mali drivers require this or they execute out of order. --- .../cpp/skyline/gpu/interconnect/command_nodes.cpp | 14 ++++++++++++++ .../cpp/skyline/gpu/interconnect/command_nodes.h | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/command_nodes.cpp b/app/src/main/cpp/skyline/gpu/interconnect/command_nodes.cpp index 5e2cd77c..b5066908 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/command_nodes.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/command_nodes.cpp @@ -4,6 +4,20 @@ #include "command_nodes.h" namespace skyline::gpu::interconnect::node { + RenderPassNode::RenderPassNode(vk::Rect2D renderArea) : subpassDependencies( + { + // We assume all past commands have been executed when this RP starts + vk::SubpassDependency{ + .srcSubpass = VK_SUBPASS_EXTERNAL, + .dstSubpass = 0, + .srcStageMask = vk::PipelineStageFlagBits::eAllGraphics, + .dstStageMask = vk::PipelineStageFlagBits::eAllGraphics, + .srcAccessMask = vk::AccessFlagBits::eMemoryRead | vk::AccessFlagBits::eMemoryWrite, + .dstAccessMask = vk::AccessFlagBits::eMemoryRead | vk::AccessFlagBits::eMemoryWrite, + } + } + ), storage(std::make_shared()), renderArea(renderArea) {} + RenderPassNode::Storage::~Storage() { if (device) { if (framebuffer) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/command_nodes.h b/app/src/main/cpp/skyline/gpu/interconnect/command_nodes.h index 95da0c00..75061594 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/command_nodes.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/command_nodes.h @@ -64,7 +64,7 @@ namespace skyline::gpu::interconnect::node { vk::Rect2D renderArea; std::vector clearValues; - RenderPassNode(vk::Rect2D renderArea) : storage(std::make_shared()), renderArea(renderArea) {} + RenderPassNode(vk::Rect2D renderArea); /** * @note Any preservation of attachments from previous subpasses is automatically handled by this