Ensure we do not render before the framebuffer copy completes
This commit is contained in:
parent
82699f3d07
commit
992d6be6eb
|
|
@ -130,20 +130,23 @@ void display_renderRows(uint8_t startRow, uint8_t endRow)
|
||||||
|
|
||||||
if(sdl_ready)
|
if(sdl_ready)
|
||||||
{
|
{
|
||||||
|
// receive a texture pixel map
|
||||||
|
void *fb;
|
||||||
|
chan_recv(&fb_sync, &fb);
|
||||||
#ifdef PIX_FMT_RGB565
|
#ifdef PIX_FMT_RGB565
|
||||||
chan_send(&fb_sync, frameBuffer);
|
memcpy(fb, frameBuffer, sizeof(PIXEL_SIZE) * SCREEN_HEIGHT * SCREEN_WIDTH);
|
||||||
#else
|
#else
|
||||||
//TODO free
|
for (unsigned int x = 0; x < SCREEN_WIDTH; x++)
|
||||||
PIXEL_SIZE *pixels = malloc(sizeof(uint16_t) * SCREEN_HEIGHT * SCREEN_WIDTH);
|
{
|
||||||
for (unsigned int x = 0; x < SCREEN_WIDTH; x++)
|
for (unsigned int y = startRow; y < endRow; y++)
|
||||||
{
|
{
|
||||||
for (unsigned int y = startRow; y < endRow; y++)
|
pixels[x + y * SCREEN_WIDTH] = fetchPixelFromFb(x, y);
|
||||||
{
|
}
|
||||||
pixels[x + y * SCREEN_WIDTH] = fetchPixelFromFb(x, y);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
chan_send(&fb_sync, (void *)pixels);
|
|
||||||
#endif
|
#endif
|
||||||
|
// signal the SDL main loop to proceed with rendering
|
||||||
|
void *done = {0};
|
||||||
|
chan_send(&fb_sync, done);
|
||||||
}
|
}
|
||||||
|
|
||||||
inProgress = false;
|
inProgress = false;
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,8 @@ void sdl_task()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan_can_recv(&fb_sync))
|
// we update the window only if there is a something ready to render
|
||||||
|
if (chan_can_send(&fb_sync))
|
||||||
{
|
{
|
||||||
PIXEL_SIZE *pixels;
|
PIXEL_SIZE *pixels;
|
||||||
int pitch = 0;
|
int pitch = 0;
|
||||||
|
|
@ -287,9 +288,8 @@ void sdl_task()
|
||||||
SDL_Log("SDL_lock failed: %s", SDL_GetError());
|
SDL_Log("SDL_lock failed: %s", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
void *fb;
|
chan_send(&fb_sync, pixels);
|
||||||
chan_recv(&fb_sync, &fb);
|
chan_recv(&fb_sync, NULL);
|
||||||
memcpy(pixels, fb, sizeof(PIXEL_SIZE) * SCREEN_HEIGHT * SCREEN_WIDTH);
|
|
||||||
|
|
||||||
SDL_UnlockTexture(displayTexture);
|
SDL_UnlockTexture(displayTexture);
|
||||||
SDL_RenderCopy(renderer, displayTexture, NULL, NULL);
|
SDL_RenderCopy(renderer, displayTexture, NULL, NULL);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue