From a039e6c41e2a29fbf1f798d88e918a8b4d270686 Mon Sep 17 00:00:00 2001 From: misson20000 Date: Tue, 2 Jan 2018 12:03:45 -0800 Subject: [PATCH] (NSW) temporary fix for graphic buffer dequeue failure --- gfx/drivers/switch_gfx.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/gfx/drivers/switch_gfx.c b/gfx/drivers/switch_gfx.c index a40bdc3893..9872a78cc7 100644 --- a/gfx/drivers/switch_gfx.c +++ b/gfx/drivers/switch_gfx.c @@ -135,6 +135,8 @@ static bool switch_frame(void *data, const void *frame, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { + static uint64_t last_frame = 0; + unsigned x, y; result_t r; uint64_t begin, done_copying, post_vsync, pre_swizzle, post_swizzle, @@ -214,15 +216,14 @@ static bool switch_frame(void *data, const void *frame, if (msg != NULL && strlen(msg) > 0) RARCH_LOG("message: %s\n", msg); - if (sw->vsync) - switch_wait_vsync(sw); - - post_vsync = svcGetSystemTick(); - - r = surface_dequeue_buffer(&surface, &out_buffer); - - if (r != RESULT_OK) - return false; + do { + if (sw->vsync) // vsync seems to sometimes return before the buffer has actually been dequeued? + switch_wait_vsync(sw); + + post_vsync = svcGetSystemTick(); + + r = surface_dequeue_buffer(&surface, &out_buffer); + } while(r != RESULT_OK); pre_swizzle = svcGetSystemTick(); gfx_slow_swizzling_blit(out_buffer, image, 1280, 720, 0, 0); @@ -239,6 +240,7 @@ static bool switch_frame(void *data, const void *frame, RARCH_LOG("frame %d benchmark: copy %ld ms, swizzle %ld ms, vsync %ld ms\n", frame_count, copy_ms, swizzle_ms, vsync_ms); + last_frame = svcGetSystemTick(); return true; }