vk/gl: Fix flush synchronization to be kinder to weaker CPUs but not harm higher end CPUs

This commit is contained in:
kd-11 2018-05-29 15:11:34 +03:00 committed by kd-11
parent 6362942928
commit f543fb0243
3 changed files with 13 additions and 14 deletions

View File

@ -1557,12 +1557,8 @@ bool GLGSRender::on_access_violation(u32 address, bool is_writing)
work_item &task = post_flush_request(address, result);
vm::temporary_unlock();
{
std::unique_lock<std::mutex> lock(task.guard_mutex);
task.cv.wait(lock, [&task] { return task.processed; });
}
task.producer_wait();
task.received = true;
return true;
}
@ -1594,13 +1590,8 @@ void GLGSRender::do_local_task(rsx::FIFO_state state)
{
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.processed = true;
//Notify thread waiting on this
lock.unlock();
q.cv.notify_one();
}
}
else if (!in_begin_end && state != rsx::FIFO_state::lock_wait)

View File

@ -35,15 +35,23 @@ namespace gl
struct work_item
{
std::condition_variable cv;
std::mutex guard_mutex;
u32 address_to_flush = 0;
gl::texture_cache::thrashed_set section_data;
volatile bool processed = false;
volatile bool result = false;
volatile bool received = false;
void producer_wait()
{
while (!processed)
{
_mm_lfence();
std::this_thread::yield();
}
received = true;
}
};
struct driver_state

View File

@ -241,7 +241,7 @@ struct flush_request_task
while (pending_state.load())
{
_mm_lfence();
_mm_pause();
std::this_thread::yield();
}
}
};