vk_renderpass_cache: Bring back renderpass flushing

This commit is contained in:
GPUCode 2023-08-20 16:54:08 +03:00
parent 66c5f59627
commit fd38e33fb2
2 changed files with 11 additions and 0 deletions

View File

@ -12,6 +12,8 @@
namespace Vulkan {
constexpr u32 MIN_DRAWS_TO_FLUSH = 20;
using VideoCore::PixelFormat;
using VideoCore::SurfaceType;
@ -46,6 +48,7 @@ void RenderpassCache::BeginRendering(const Framebuffer* framebuffer,
void RenderpassCache::BeginRendering(const RenderPass& new_pass) {
if (pass == new_pass) [[likely]] {
num_draws++;
return;
}
@ -111,6 +114,13 @@ void RenderpassCache::EndRendering() {
vk::DependencyFlagBits::eByRegion, 0, nullptr, 0, nullptr,
num_barriers, barriers.data());
});
// The Mali guide recommends flushing at the end of each major renderpass
// Testing has shown this has a significant effect on rendering performance
if (num_draws > MIN_DRAWS_TO_FLUSH && instance.ShouldFlush()) {
scheduler.Flush();
num_draws = 0;
}
}
vk::RenderPass RenderpassCache::GetRenderpass(VideoCore::PixelFormat color,

View File

@ -68,6 +68,7 @@ private:
std::array<vk::Image, 2> images;
std::array<vk::ImageAspectFlags, 2> aspects;
RenderPass pass{};
u32 num_draws{};
};
} // namespace Vulkan