(WiiU) improve task scheduling.

This commit is contained in:
aliaspider 2017-05-22 11:19:26 +01:00
parent b00776b09e
commit 801cc57e82
2 changed files with 24 additions and 7 deletions

View File

@ -48,6 +48,7 @@
#include <sys/iosupport.h>
#include <wiiu/os/foreground.h>
#include <wiiu/gx2/event.h>
#include <wiiu/procui.h>
#include <wiiu/sysapp.h>
#include <wiiu/ios.h>
@ -383,6 +384,16 @@ void SaveCallback()
OSSavesDone_ReadyToRelease();
}
static bool swap_is_pending(void* start_time)
{
uint32_t swap_count, flip_count;
OSTime last_flip , last_vsync;
GX2GetSwapStatus(&swap_count, &flip_count, &last_flip, &last_vsync);
return last_vsync < *(OSTime*)start_time;
}
int main(int argc, char **argv)
{
#if 1
@ -447,12 +458,20 @@ int main(int argc, char **argv)
do
{
unsigned sleep_ms = 0;
if(video_driver_get_ptr(false))
{
OSTime start_time = OSGetSystemTime();
task_queue_wait(swap_is_pending, &start_time);
}
else
task_queue_wait(NULL, NULL);
int ret = runloop_iterate(&sleep_ms);
if (ret == 1 && sleep_ms > 0)
retro_sleep(sleep_ms);
task_queue_wait();
if (ret == -1)
break;

View File

@ -502,12 +502,6 @@ static bool wiiu_gfx_frame(void* data, const void* frame,
wiiu_video_t* wiiu = (wiiu_video_t*) data;
if (!width || !height)
{
GX2WaitForVsync();
return true;
}
if(wiiu->vsync)
{
uint32_t swap_count;
@ -527,6 +521,10 @@ static bool wiiu_gfx_frame(void* data, const void* frame,
}
GX2WaitForFlip();
if (!width || !height)
return true;
static u32 lastTick , currentTick;
currentTick = OSGetSystemTick();
u32 diff = currentTick - lastTick;