mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-23 18:45:36 +00:00
buffer_cache: Fix race condition
This commit is contained in:
parent
1af9e17176
commit
0edfa4643f
@ -17,6 +17,8 @@
|
|||||||
#include "video_core/renderer_vulkan/vk_rasterizer.h"
|
#include "video_core/renderer_vulkan/vk_rasterizer.h"
|
||||||
#include "video_core/renderer_vulkan/vk_scheduler.h"
|
#include "video_core/renderer_vulkan/vk_scheduler.h"
|
||||||
|
|
||||||
|
std::thread::id gpu_id;
|
||||||
|
|
||||||
namespace AmdGpu {
|
namespace AmdGpu {
|
||||||
|
|
||||||
static const char* dcb_task_name{"DCB_TASK"};
|
static const char* dcb_task_name{"DCB_TASK"};
|
||||||
@ -89,7 +91,7 @@ void Liverpool::ProcessCommands() {
|
|||||||
|
|
||||||
void Liverpool::Process(std::stop_token stoken) {
|
void Liverpool::Process(std::stop_token stoken) {
|
||||||
Common::SetCurrentThreadName("shadPS4:GpuCommandProcessor");
|
Common::SetCurrentThreadName("shadPS4:GpuCommandProcessor");
|
||||||
|
gpu_id = std::this_thread::get_id();
|
||||||
while (!stoken.stop_requested()) {
|
while (!stoken.stop_requested()) {
|
||||||
{
|
{
|
||||||
std::unique_lock lk{submit_mutex};
|
std::unique_lock lk{submit_mutex};
|
||||||
|
@ -288,13 +288,13 @@ bool BufferCache::CommitPendingDownloads(bool wait_done) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const u64 wait_tick = scheduler.CurrentTick();
|
||||||
|
scheduler.Flush();
|
||||||
{
|
{
|
||||||
std::scoped_lock lk{queue_mutex};
|
std::scoped_lock lk{queue_mutex};
|
||||||
async_downloads.emplace(std::move(writeback_host), scheduler.CurrentTick(),
|
async_downloads.emplace(std::move(writeback_host), wait_tick, current_download_tick);
|
||||||
current_download_tick);
|
|
||||||
}
|
}
|
||||||
queue_cv.notify_one();
|
queue_cv.notify_one();
|
||||||
scheduler.Flush();
|
|
||||||
if (wait_done) {
|
if (wait_done) {
|
||||||
WaitForTargetTick(current_download_tick);
|
WaitForTargetTick(current_download_tick);
|
||||||
}
|
}
|
||||||
|
@ -62,9 +62,6 @@ void Rasterizer::CpSync() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Rasterizer::CommitPendingDownloads(bool wait_done) {
|
bool Rasterizer::CommitPendingDownloads(bool wait_done) {
|
||||||
SCOPE_EXIT {
|
|
||||||
scheduler.PopPendingOperations();
|
|
||||||
};
|
|
||||||
return buffer_cache.CommitPendingDownloads(wait_done);
|
return buffer_cache.CommitPendingDownloads(wait_done);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||||
#include "video_core/renderer_vulkan/vk_scheduler.h"
|
#include "video_core/renderer_vulkan/vk_scheduler.h"
|
||||||
|
|
||||||
|
extern std::thread::id gpu_id;
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
std::mutex Scheduler::submit_mutex;
|
std::mutex Scheduler::submit_mutex;
|
||||||
@ -68,6 +70,7 @@ void Scheduler::EndRendering() {
|
|||||||
void Scheduler::PopPendingOperations() {
|
void Scheduler::PopPendingOperations() {
|
||||||
master_semaphore.Refresh();
|
master_semaphore.Refresh();
|
||||||
while (!pending_ops.empty() && master_semaphore.IsFree(pending_ops.front().gpu_tick)) {
|
while (!pending_ops.empty() && master_semaphore.IsFree(pending_ops.front().gpu_tick)) {
|
||||||
|
ASSERT(gpu_id == std::this_thread::get_id());
|
||||||
ASSERT(op_scope == 0);
|
ASSERT(op_scope == 0);
|
||||||
++op_scope;
|
++op_scope;
|
||||||
pending_ops.front().callback();
|
pending_ops.front().callback();
|
||||||
|
Loading…
Reference in New Issue
Block a user