From 74be64b60a935184ab8afbfee7031811d266e330 Mon Sep 17 00:00:00 2001 From: GPUCode Date: Sat, 25 Feb 2023 16:05:02 +0200 Subject: [PATCH] vk_stream_buffer: Fix synchronization during buffer overflow * Especially with custom textures the bufer would fill up but didn't wait any watchers on overflow overriding some textures --- src/video_core/renderer_vulkan/vk_stream_buffer.cpp | 7 ++++--- src/video_core/renderer_vulkan/vk_texture_runtime.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_stream_buffer.cpp b/src/video_core/renderer_vulkan/vk_stream_buffer.cpp index a40e4652b..3340b8b8c 100644 --- a/src/video_core/renderer_vulkan/vk_stream_buffer.cpp +++ b/src/video_core/renderer_vulkan/vk_stream_buffer.cpp @@ -54,8 +54,6 @@ std::tuple StreamBuffer::Map(u64 size, u64 alignment) { offset = Common::AlignUp(offset, alignment); } - WaitPendingOperations(offset); - bool invalidate{false}; if (offset + size > stream_buffer_size) { // The buffer would overflow, save the amount of used watches and reset the state. @@ -70,6 +68,9 @@ std::tuple StreamBuffer::Map(u64 size, u64 alignment) { wait_bound = 0; } + const u64 mapped_upper_bound = offset + size; + WaitPendingOperations(mapped_upper_bound); + return std::make_tuple(mapped + offset, offset, invalidate); } @@ -128,7 +129,7 @@ void StreamBuffer::WaitPendingOperations(u64 requested_upper_bound) { if (!invalidation_mark) { return; } - while (requested_upper_bound < wait_bound && wait_cursor < *invalidation_mark) { + while (requested_upper_bound > wait_bound && wait_cursor < *invalidation_mark) { auto& watch = previous_watches[wait_cursor]; wait_bound = watch.upper_bound; scheduler.Wait(watch.tick); diff --git a/src/video_core/renderer_vulkan/vk_texture_runtime.cpp b/src/video_core/renderer_vulkan/vk_texture_runtime.cpp index 261c1fc37..43af1ec0e 100644 --- a/src/video_core/renderer_vulkan/vk_texture_runtime.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_runtime.cpp @@ -106,7 +106,7 @@ u32 UnpackDepthStencil(const StagingData& data, vk::Format dest) { return depth_offset; } -constexpr u64 UPLOAD_BUFFER_SIZE = 64 * 1024 * 1024; +constexpr u64 UPLOAD_BUFFER_SIZE = 128 * 1024 * 1024; constexpr u64 DOWNLOAD_BUFFER_SIZE = 16 * 1024 * 1024; } // Anonymous namespace