mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 23:41:26 +12:00
vk/gl: Fix flush synchronization to be kinder to weaker CPUs but not harm higher end CPUs
This commit is contained in:
parent
6362942928
commit
f543fb0243
3 changed files with 13 additions and 14 deletions
|
@ -1557,12 +1557,8 @@ bool GLGSRender::on_access_violation(u32 address, bool is_writing)
|
||||||
work_item &task = post_flush_request(address, result);
|
work_item &task = post_flush_request(address, result);
|
||||||
|
|
||||||
vm::temporary_unlock();
|
vm::temporary_unlock();
|
||||||
{
|
task.producer_wait();
|
||||||
std::unique_lock<std::mutex> lock(task.guard_mutex);
|
|
||||||
task.cv.wait(lock, [&task] { return task.processed; });
|
|
||||||
}
|
|
||||||
|
|
||||||
task.received = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1594,13 +1590,8 @@ void GLGSRender::do_local_task(rsx::FIFO_state state)
|
||||||
{
|
{
|
||||||
if (q.processed) continue;
|
if (q.processed) continue;
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(q.guard_mutex);
|
|
||||||
q.result = m_gl_texture_cache.flush_all(q.section_data);
|
q.result = m_gl_texture_cache.flush_all(q.section_data);
|
||||||
q.processed = true;
|
q.processed = true;
|
||||||
|
|
||||||
//Notify thread waiting on this
|
|
||||||
lock.unlock();
|
|
||||||
q.cv.notify_one();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!in_begin_end && state != rsx::FIFO_state::lock_wait)
|
else if (!in_begin_end && state != rsx::FIFO_state::lock_wait)
|
||||||
|
|
|
@ -35,15 +35,23 @@ namespace gl
|
||||||
|
|
||||||
struct work_item
|
struct work_item
|
||||||
{
|
{
|
||||||
std::condition_variable cv;
|
|
||||||
std::mutex guard_mutex;
|
|
||||||
|
|
||||||
u32 address_to_flush = 0;
|
u32 address_to_flush = 0;
|
||||||
gl::texture_cache::thrashed_set section_data;
|
gl::texture_cache::thrashed_set section_data;
|
||||||
|
|
||||||
volatile bool processed = false;
|
volatile bool processed = false;
|
||||||
volatile bool result = false;
|
volatile bool result = false;
|
||||||
volatile bool received = false;
|
volatile bool received = false;
|
||||||
|
|
||||||
|
void producer_wait()
|
||||||
|
{
|
||||||
|
while (!processed)
|
||||||
|
{
|
||||||
|
_mm_lfence();
|
||||||
|
std::this_thread::yield();
|
||||||
|
}
|
||||||
|
|
||||||
|
received = true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct driver_state
|
struct driver_state
|
||||||
|
|
|
@ -241,7 +241,7 @@ struct flush_request_task
|
||||||
while (pending_state.load())
|
while (pending_state.load())
|
||||||
{
|
{
|
||||||
_mm_lfence();
|
_mm_lfence();
|
||||||
_mm_pause();
|
std::this_thread::yield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue