From 13ea0b9c0f03bd9cd513e14bd530ba23c2330592 Mon Sep 17 00:00:00 2001 From: Shaun Inman Date: Mon, 6 Feb 2023 19:27:31 -0500 Subject: [PATCH] PAN_DISPLAY before WAITFORVSYNC this eliminates tearing when double instead of triple buffering, might be the proper way to use these two together? --- src/common/api.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/common/api.c b/src/common/api.c index 686462f..c5766c7 100644 --- a/src/common/api.c +++ b/src/common/api.c @@ -96,7 +96,8 @@ struct owlfb_sync_info { /////////////////////////////// -#define GFX_BUFFER_COUNT 3 +// is triple buffering necessary without threaded rendering? +#define GFX_BUFFER_COUNT 2 /////////////////////////////// @@ -278,6 +279,14 @@ void GFX_startFrame(void) { void GFX_flip(SDL_Surface* screen) { static int ticks = 0; ticks += 1; + + gfx.vinfo.yoffset = gfx.buffer * SCREEN_HEIGHT; + ioctl(gfx.fb, FBIOPAN_DISPLAY, &gfx.vinfo); + + gfx.buffer += 1; + if (gfx.buffer>=GFX_BUFFER_COUNT) gfx.buffer -= GFX_BUFFER_COUNT; + screen->pixels = gfx.map + (gfx.buffer * gfx.buffer_size); + if (gfx.vsync!=VSYNC_OFF) { // this limiting condition helps SuperFX chip games #define FRAME_BUDGET 17 // 60fps @@ -286,13 +295,6 @@ void GFX_flip(SDL_Surface* screen) { ioctl(gfx.fb, OWLFB_WAITFORVSYNC, &arg); } } - - gfx.vinfo.yoffset = gfx.buffer * SCREEN_HEIGHT; - ioctl(gfx.fb, FBIOPAN_DISPLAY, &gfx.vinfo); - - gfx.buffer += 1; - if (gfx.buffer>=GFX_BUFFER_COUNT) gfx.buffer -= GFX_BUFFER_COUNT; - screen->pixels = gfx.map + (gfx.buffer * gfx.buffer_size); } void GFX_sync(void) { #define FRAME_BUDGET 17 // ~60fps