mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-26 03:55:37 +00:00
adding pending mutex and flips
This commit is contained in:
parent
61ce2c4294
commit
7bd134ae87
@ -29,6 +29,8 @@ struct VideoOutPort {
|
|||||||
std::vector<Kernel::SceKernelEqueue> vblank_events;
|
std::vector<Kernel::SceKernelEqueue> vblank_events;
|
||||||
std::mutex vo_mutex;
|
std::mutex vo_mutex;
|
||||||
std::mutex port_mutex;
|
std::mutex port_mutex;
|
||||||
|
std::mutex pending_mutex;
|
||||||
|
std::queue<std::tuple<u32, u32>> pending_flips;
|
||||||
std::condition_variable vo_cv;
|
std::condition_variable vo_cv;
|
||||||
std::condition_variable vblank_cv;
|
std::condition_variable vblank_cv;
|
||||||
int flip_rate = 0;
|
int flip_rate = 0;
|
||||||
|
@ -339,25 +339,34 @@ s32 sceVideoOutSubmitEopFlip(s32 handle, u32 buf_id, u32 mode, u32 arg, void** u
|
|||||||
return ORBIS_VIDEO_OUT_ERROR_INVALID_HANDLE;
|
return ORBIS_VIDEO_OUT_ERROR_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::mutex irq_mutex;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(irq_mutex);
|
std::lock_guard lock(port->pending_mutex);
|
||||||
|
port->pending_flips.emplace(buf_id, arg);
|
||||||
Platform::IrqC::Instance()->RegisterOnce(
|
}
|
||||||
Platform::InterruptId::GfxFlip, [=](Platform::InterruptId irq) {
|
Platform::IrqC::Instance()->RegisterOnce(
|
||||||
ASSERT_MSG(irq == Platform::InterruptId::GfxFlip, "Unexpected IRQ occurred");
|
Platform::InterruptId::GfxFlip, [=](Platform::InterruptId irq) {
|
||||||
ASSERT_MSG(port->buffer_labels[buf_id] == 1, "Out-of-order flip IRQ");
|
ASSERT_MSG(irq == Platform::InterruptId::GfxFlip, "Unexpected IRQ");
|
||||||
|
if (port->is_mode_changing) {
|
||||||
const auto result = driver->SubmitFlip(port, buf_id, arg, true);
|
LOG_WARNING(Lib_VideoOut, "Ignoring flip IRQ during mode change");
|
||||||
if (!result) {
|
return;
|
||||||
LOG_ERROR(Lib_VideoOut, "EOP flip submission failed for buffer {}", buf_id);
|
}
|
||||||
|
std::tuple<u32, u32> pending;
|
||||||
|
{
|
||||||
|
std::lock_guard lock(port->pending_mutex);
|
||||||
|
if (port->pending_flips.empty()) {
|
||||||
|
LOG_ERROR(Lib_VideoOut, "Received GfxFlip IRQ but no flips pending");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
pending = port->pending_flips.front();
|
||||||
port->buffer_labels[buf_id] = 0;
|
port->pending_flips.pop();
|
||||||
});
|
}
|
||||||
}
|
const auto [queued_buf_id, queued_arg] = pending;
|
||||||
|
ASSERT_MSG(queued_buf_id == buf_id,
|
||||||
|
"Out-of-order flip IRQ (expected buf_id = {}, got = {})", buf_id,
|
||||||
|
queued_buf_id);
|
||||||
|
const bool result = driver->SubmitFlip(port, queued_buf_id, queued_arg, true);
|
||||||
|
ASSERT_MSG(result, "EOP flip submission failed for buffer {}", queued_buf_id);
|
||||||
|
});
|
||||||
|
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user