1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-23 03:02:53 +01:00

RSX: Rewrite frame limit

This commit is contained in:
Nekotekina 2017-11-10 17:31:02 +03:00
parent 916851bd4a
commit 9ef00b4a12
2 changed files with 25 additions and 5 deletions

View File

@ -15,7 +15,6 @@
#include <Utilities/GSL.h>
#include "Utilities/Thread.h"
#include "Utilities/Timer.h"
#include "Utilities/geometry.h"
#include "rsx_trace.h"
#include "restore_new.h"
@ -155,8 +154,6 @@ namespace rsx
RsxDmaControl* ctrl = nullptr;
atomic_t<u32> internal_get{ 0 };
Timer timer_sync;
GcmTileInfo tiles[limits::tiles_count];
GcmZcullInfo zculls[limits::zculls_count];
@ -218,6 +215,8 @@ namespace rsx
double fps_limit = 59.94;
public:
u64 start_rsx_time = 0;
u64 int_flip_index = 0;
u64 last_flip_time;
vm::ps3::ptr<void(u32)> flip_handler = vm::null;
vm::ps3::ptr<void(u32)> user_handler = vm::null;

View File

@ -940,12 +940,33 @@ namespace rsx
case frame_limit_type::_30: limit = 30.; break;
case frame_limit_type::_auto: limit = rsx->fps_limit; break; // TODO
}
if (limit)
{
std::this_thread::sleep_for(std::chrono::milliseconds((s64)(1000.0 / limit - rsx->timer_sync.GetElapsedTimeInMilliSec())));
rsx->timer_sync.Start();
const u64 time = get_system_time() - Emu.GetPauseTime() - rsx->start_rsx_time;
if (rsx->int_flip_index == 0)
{
rsx->start_rsx_time = time;
}
else
{
// Convert limit to expected time value
double expected = rsx->int_flip_index * 1000000. / limit;
while (time >= expected + 1000000. / limit)
{
expected = rsx->int_flip_index++ * 1000000. / limit;
}
if (expected > time + 1000)
{
std::this_thread::sleep_for(std::chrono::milliseconds{static_cast<s64>(expected - time) / 1000});
}
}
}
rsx->int_flip_index++;
rsx->current_display_buffer = arg;
rsx->flip(arg);
// After each flip PS3 system is executing a routine that changes registers value to some default.