Skip to content

Commit 3e131b7

Browse files
buffer_cache: Fix CopyBuffers bug
1 parent cf9f6ef commit 3e131b7

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

src/video_core/amdgpu/liverpool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
22
// SPDX-License-Identifier: GPL-2.0-or-later
3-
3+
#pragma clang optimize off
44
#include <boost/preprocessor/stringize.hpp>
55

66
#include "common/assert.h"

src/video_core/buffer_cache/buffer_cache.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
22
// SPDX-License-Identifier: GPL-2.0-or-later
3-
3+
#pragma clang optimize off
44
#include <algorithm>
55
#include <semaphore>
66
#include "common/alignment.h"
@@ -288,13 +288,17 @@ void BufferCache::CopyBuffer(VAddr dst, VAddr src, u32 num_bytes, bool dst_gds,
288288
if (src_gds) {
289289
return gds_buffer;
290290
}
291-
const auto [buffer, offset] = ObtainBuffer(src, num_bytes, false);
292-
return *buffer;
291+
// Avoid using ObtainBuffer here as that might give us the stream buffer.
292+
const BufferId buffer_id = FindBuffer(src, num_bytes);
293+
auto& buffer = slot_buffers[buffer_id];
294+
SynchronizeBuffer(buffer, src, num_bytes, false);
295+
return buffer;
293296
}();
294297
auto& dst_buffer = [&] -> const Buffer& {
295298
if (dst_gds) {
296299
return gds_buffer;
297300
}
301+
// Prefer using ObtainBuffer here as that will auto-mark the region as GPU modified.
298302
const auto [buffer, offset] = ObtainBuffer(dst, num_bytes, true);
299303
return *buffer;
300304
}();

src/video_core/renderer_vulkan/vk_platform.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
22
// SPDX-License-Identifier: GPL-2.0-or-later
3-
3+
#pragma clang optimize off
44
// Include the vulkan platform specific header
55
#if defined(ANDROID)
66
#define VK_USE_PLATFORM_ANDROID_KHR
@@ -30,7 +30,9 @@ static const char* const CRASH_DIAGNOSTIC_LAYER_NAME = "VK_LAYER_LUNARG_crash_di
3030
static VKAPI_ATTR VkBool32 VKAPI_CALL DebugUtilsCallback(
3131
vk::DebugUtilsMessageSeverityFlagBitsEXT severity, vk::DebugUtilsMessageTypeFlagsEXT type,
3232
const vk::DebugUtilsMessengerCallbackDataEXT* callback_data, void* user_data) {
33-
33+
if (std::string_view(callback_data->pMessage).contains("vkCmdCopyBuffer")) {
34+
printf("bad\n");
35+
}
3436
Common::Log::Level level{};
3537
switch (severity) {
3638
case vk::DebugUtilsMessageSeverityFlagBitsEXT::eError:

src/video_core/renderer_vulkan/vk_rasterizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
22
// SPDX-License-Identifier: GPL-2.0-or-later
3-
3+
#pragma clang optimize off
44
#include "common/config.h"
55
#include "common/debug.h"
66
#include "core/memory.h"

0 commit comments

Comments
 (0)