mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
gl: Fix a fence deadlock in fence::wait_for_signal
gl: Fix potential race condition when executing local work queue
This commit is contained in:
parent
cee53fcecf
commit
7062efeb3e
4 changed files with 9 additions and 7 deletions
|
@ -942,6 +942,8 @@ void GLGSRender::do_local_task()
|
|||
{
|
||||
std::lock_guard<std::mutex> lock(queue_guard);
|
||||
|
||||
work_queue.remove_if([](work_item &q) { return q.received; });
|
||||
|
||||
for (work_item& q: work_queue)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(q.guard_mutex);
|
||||
|
@ -954,8 +956,6 @@ void GLGSRender::do_local_task()
|
|||
lock.unlock();
|
||||
q.cv.notify_one();
|
||||
}
|
||||
|
||||
work_queue.clear();
|
||||
}
|
||||
|
||||
work_item& GLGSRender::post_flush_request(u32 address)
|
||||
|
|
|
@ -17,9 +17,10 @@ struct work_item
|
|||
std::condition_variable cv;
|
||||
std::mutex guard_mutex;
|
||||
|
||||
u32 address_to_flush;
|
||||
bool processed;
|
||||
bool result;
|
||||
u32 address_to_flush = 0;
|
||||
bool processed = false;
|
||||
bool result = false;
|
||||
bool received = false;
|
||||
};
|
||||
|
||||
struct gcm_buffer_info
|
||||
|
|
|
@ -80,6 +80,7 @@ namespace gl
|
|||
void create()
|
||||
{
|
||||
m_value = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
flags = GL_SYNC_FLUSH_COMMANDS_BIT;
|
||||
}
|
||||
|
||||
void destroy()
|
||||
|
@ -132,7 +133,7 @@ namespace gl
|
|||
{
|
||||
if (flags)
|
||||
{
|
||||
err = glClientWaitSync(m_value, flags, 1000);
|
||||
err = glClientWaitSync(m_value, flags, 0);
|
||||
flags = 0;
|
||||
|
||||
switch (err)
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace gl
|
|||
task.cv.wait(lock, [&task] { return task.processed; });
|
||||
}
|
||||
|
||||
verify(HERE), task.result == true;
|
||||
task.received = true;
|
||||
return task.result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue