mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-31 14:35:19 +00:00
tentative fix for cpu flips racing
This commit is contained in:
parent
2beff82c1b
commit
c94190b69b
@ -203,7 +203,17 @@ std::chrono::microseconds VideoOutDriver::Flip(const Request& req) {
|
|||||||
|
|
||||||
bool VideoOutDriver::SubmitFlip(VideoOutPort* port, s32 index, s64 flip_arg,
|
bool VideoOutDriver::SubmitFlip(VideoOutPort* port, s32 index, s64 flip_arg,
|
||||||
bool is_eop /*= false*/) {
|
bool is_eop /*= false*/) {
|
||||||
bool flip_result = true;
|
u32 num_requests_pending{};
|
||||||
|
{
|
||||||
|
std::scoped_lock lock{mutex};
|
||||||
|
num_requests_pending = requests.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index != -1 && num_requests_pending >= port->NumRegisteredBuffers()) {
|
||||||
|
LOG_ERROR(Lib_VideoOut, "Flip queue is full");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_eop) {
|
if (!is_eop) {
|
||||||
// Before processing the flip we need to ask GPU thread to flush command list as at this
|
// Before processing the flip we need to ask GPU thread to flush command list as at this
|
||||||
// point VO surface is ready to be presented, and we will need have an actual state of
|
// point VO surface is ready to be presented, and we will need have an actual state of
|
||||||
@ -213,12 +223,16 @@ bool VideoOutDriver::SubmitFlip(VideoOutPort* port, s32 index, s64 flip_arg,
|
|||||||
SubmitFlipInternal(port, index, flip_arg, is_eop);
|
SubmitFlipInternal(port, index, flip_arg, is_eop);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
flip_result = SubmitFlipInternal(port, index, flip_arg, is_eop);
|
SubmitFlipInternal(port, index, flip_arg, is_eop);
|
||||||
}
|
}
|
||||||
return flip_result;
|
|
||||||
|
port->flip_status.flipPendingNum = num_requests_pending + 1;
|
||||||
|
port->flip_status.gcQueueNum = 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoOutDriver::SubmitFlipInternal(VideoOutPort* port, s32 index, s64 flip_arg,
|
void VideoOutDriver::SubmitFlipInternal(VideoOutPort* port, s32 index, s64 flip_arg,
|
||||||
bool is_eop /*= false*/) {
|
bool is_eop /*= false*/) {
|
||||||
Vulkan::Frame* frame;
|
Vulkan::Frame* frame;
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
@ -229,11 +243,6 @@ bool VideoOutDriver::SubmitFlipInternal(VideoOutPort* port, s32 index, s64 flip_
|
|||||||
frame = renderer->PrepareFrame(group, buffer.address_left, is_eop);
|
frame = renderer->PrepareFrame(group, buffer.address_left, is_eop);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index != -1 && requests.size() >= port->NumRegisteredBuffers()) {
|
|
||||||
LOG_ERROR(Lib_VideoOut, "Flip queue is full");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::scoped_lock lock{mutex};
|
std::scoped_lock lock{mutex};
|
||||||
requests.push({
|
requests.push({
|
||||||
.frame = frame,
|
.frame = frame,
|
||||||
@ -243,11 +252,6 @@ bool VideoOutDriver::SubmitFlipInternal(VideoOutPort* port, s32 index, s64 flip_
|
|||||||
.submit_tsc = Libraries::Kernel::sceKernelReadTsc(),
|
.submit_tsc = Libraries::Kernel::sceKernelReadTsc(),
|
||||||
.eop = is_eop,
|
.eop = is_eop,
|
||||||
});
|
});
|
||||||
|
|
||||||
port->flip_status.flipPendingNum = static_cast<int>(requests.size());
|
|
||||||
port->flip_status.gcQueueNum = 0;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoOutDriver::PresentThread(std::stop_token token) {
|
void VideoOutDriver::PresentThread(std::stop_token token) {
|
||||||
|
@ -102,7 +102,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::chrono::microseconds Flip(const Request& req);
|
std::chrono::microseconds Flip(const Request& req);
|
||||||
bool SubmitFlipInternal(VideoOutPort* port, s32 index, s64 flip_arg, bool is_eop = false);
|
void SubmitFlipInternal(VideoOutPort* port, s32 index, s64 flip_arg, bool is_eop = false);
|
||||||
void PresentThread(std::stop_token token);
|
void PresentThread(std::stop_token token);
|
||||||
|
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
|
Loading…
Reference in New Issue
Block a user