Lib.VideoOut: Fix pending flips limit (#4039)
Some checks failed
Build and Release / reuse (push) Has been cancelled
Build and Release / clang-format (push) Has been cancelled
Build and Release / get-info (push) Has been cancelled
Build and Release / windows-sdl (push) Has been cancelled
Build and Release / macos-sdl (push) Has been cancelled
Build and Release / linux-sdl (push) Has been cancelled
Build and Release / linux-sdl-gcc (push) Has been cancelled
Build and Release / pre-release (push) Has been cancelled

* Hardcoded limit to pending flips

Real hardware has a fixed-size queue, and doesn't depend on the number of registered buffers.
While the kernel supposedly uses an array of 18 elements, my tests suggest the cap is 16 pending flips.

* Assert on trying to flip unregistered buffer

I haven't seen anything do this intentionally yet, but I do have cases where games do this unintentionally (do to unimplemented functions).
This commit is contained in:
Stephen Miller 2026-02-16 00:31:35 -06:00 committed by GitHub
parent 4a370519a5
commit 547198af6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -224,7 +224,7 @@ 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()) {
if (index != -1 && port->flip_status.flip_pending_num > 16) {
LOG_ERROR(Lib_VideoOut, "Flip queue is full");
return false;
}
@ -252,6 +252,7 @@ void VideoOutDriver::SubmitFlipInternal(VideoOutPort* port, s32 index, s64 flip_
frame = presenter->PrepareBlankFrame(false);
} else {
const auto& buffer = port->buffer_slots[index];
ASSERT_MSG(buffer.group_index >= 0, "Trying to flip an unregistered buffer!");
const auto& group = port->groups[buffer.group_index];
frame = presenter->PrepareFrame(group, buffer.address_left);
}