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:
@@ -942,6 +942,8 @@ void GLGSRender::do_local_task()
|
|||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(queue_guard);
|
std::lock_guard<std::mutex> lock(queue_guard);
|
||||||
|
|
||||||
|
work_queue.remove_if([](work_item &q) { return q.received; });
|
||||||
|
|
||||||
for (work_item& q: work_queue)
|
for (work_item& q: work_queue)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(q.guard_mutex);
|
std::unique_lock<std::mutex> lock(q.guard_mutex);
|
||||||
@@ -954,8 +956,6 @@ void GLGSRender::do_local_task()
|
|||||||
lock.unlock();
|
lock.unlock();
|
||||||
q.cv.notify_one();
|
q.cv.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
work_queue.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
work_item& GLGSRender::post_flush_request(u32 address)
|
work_item& GLGSRender::post_flush_request(u32 address)
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ struct work_item
|
|||||||
std::condition_variable cv;
|
std::condition_variable cv;
|
||||||
std::mutex guard_mutex;
|
std::mutex guard_mutex;
|
||||||
|
|
||||||
u32 address_to_flush;
|
u32 address_to_flush = 0;
|
||||||
bool processed;
|
bool processed = false;
|
||||||
bool result;
|
bool result = false;
|
||||||
|
bool received = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gcm_buffer_info
|
struct gcm_buffer_info
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ namespace gl
|
|||||||
void create()
|
void create()
|
||||||
{
|
{
|
||||||
m_value = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
m_value = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||||
|
flags = GL_SYNC_FLUSH_COMMANDS_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy()
|
void destroy()
|
||||||
@@ -132,7 +133,7 @@ namespace gl
|
|||||||
{
|
{
|
||||||
if (flags)
|
if (flags)
|
||||||
{
|
{
|
||||||
err = glClientWaitSync(m_value, flags, 1000);
|
err = glClientWaitSync(m_value, flags, 0);
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
|
||||||
switch (err)
|
switch (err)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace gl
|
|||||||
task.cv.wait(lock, [&task] { return task.processed; });
|
task.cv.wait(lock, [&task] { return task.processed; });
|
||||||
}
|
}
|
||||||
|
|
||||||
verify(HERE), task.result == true;
|
task.received = true;
|
||||||
return task.result;
|
return task.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user