mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-25 11:34:55 +00:00
wait for space on flip queue and ensuring the queue gets properly drained
This commit is contained in:
parent
7bd134ae87
commit
8a4eb9ef7a
@ -220,10 +220,11 @@ bool VideoOutDriver::SubmitFlip(VideoOutPort* port, s32 index, s64 flip_arg,
|
||||
bool is_eop /*= false*/) {
|
||||
{
|
||||
std::unique_lock lock{port->port_mutex};
|
||||
if (index != -1 && port->flip_status.flip_pending_num >= port->NumRegisteredBuffers()) {
|
||||
LOG_ERROR(Lib_VideoOut, "Flip queue is full");
|
||||
return false;
|
||||
}
|
||||
|
||||
// wait until there is space in the flip queue
|
||||
port->vo_cv.wait(lock, [&]() {
|
||||
return index == -1 || port->flip_status.flip_pending_num < port->NumRegisteredBuffers();
|
||||
});
|
||||
|
||||
if (is_eop) {
|
||||
++port->flip_status.gc_queue_num;
|
||||
@ -310,6 +311,15 @@ void VideoOutDriver::PresentThread(std::stop_token token) {
|
||||
}
|
||||
} else {
|
||||
Flip(request);
|
||||
{
|
||||
std::scoped_lock lock{request.port->port_mutex};
|
||||
request.port->flip_status.flip_pending_num--;
|
||||
if (request.eop) {
|
||||
request.port->flip_status.gc_queue_num--;
|
||||
}
|
||||
request.port->vo_cv
|
||||
.notify_one(); // this wake up threads waiting to submit more flips
|
||||
}
|
||||
FRAME_END;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user