Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
finally fixed GFX_clearAll()
Browse files Browse the repository at this point in the history
waits till front buffer is the backbuffer before clearing
  • Loading branch information
Shaun Inman committed Mar 20, 2023
1 parent 7882f9b commit 989079a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/common/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static void ion_alloc(int fd_ion, ion_alloc_info_t* info) {
iad.len = info->size;
iad.align = sysconf(_SC_PAGESIZE);
iad.heap_id_mask = (1<<ION_HEAP_ID_PMEM);
iad.flags = ION_FLAG_CACHED_NEEDS_SYNC;
iad.flags = 0;
if (ioctl(fd_ion, ION_IOC_ALLOC, &iad)<0) fprintf(stderr, "ION_ALLOC failed %s\n",strerror(errno));
icd.cmd = OWL_ION_GET_PHY;
icd.arg = (uintptr_t)&ipd;
Expand Down Expand Up @@ -310,6 +310,7 @@ static struct GFX_Context {
int width;
int height;
int pitch;
int cleared;
} gfx;

static SDL_Rect asset_rects[] = {
Expand Down Expand Up @@ -466,8 +467,8 @@ void GFX_clear(SDL_Surface* screen) {
memset(screen->pixels, 0, PAGE_SIZE);
}
void GFX_clearAll(void) {
// TODO: one buffer is onscreen when cleared producing tearing
memset(gfx.fb_info.vadd, 0, PAGE_SIZE * PAGE_COUNT);
GFX_clear(gfx.screen); // clear backbuffer
gfx.cleared = 1; // defer clearing frontbuffer until offscreen
}

void GFX_setMode(int mode) {
Expand Down Expand Up @@ -542,10 +543,14 @@ void GFX_flip(SDL_Surface* screen) {
}
}


// swap backbuffer
gfx.page ^= 1;
gfx.screen->pixels = gfx.fb_info.vadd + gfx.page * PAGE_SIZE;

if (gfx.cleared) {
GFX_clear(gfx.screen);
gfx.cleared = 0;
}
}
void GFX_sync(void) {
if (gfx.vsync!=VSYNC_OFF) {
Expand Down

0 comments on commit 989079a

Please sign in to comment.