kopia lustrzana https://github.com/OpenRTX/OpenRTX
Ensure we do not render before the framebuffer copy completes
rodzic
82699f3d07
commit
992d6be6eb
|
@ -130,20 +130,23 @@ void display_renderRows(uint8_t startRow, uint8_t endRow)
|
|||
|
||||
if(sdl_ready)
|
||||
{
|
||||
// receive a texture pixel map
|
||||
void *fb;
|
||||
chan_recv(&fb_sync, &fb);
|
||||
#ifdef PIX_FMT_RGB565
|
||||
chan_send(&fb_sync, frameBuffer);
|
||||
memcpy(fb, frameBuffer, sizeof(PIXEL_SIZE) * SCREEN_HEIGHT * SCREEN_WIDTH);
|
||||
#else
|
||||
//TODO free
|
||||
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++)
|
||||
{
|
||||
pixels[x + y * SCREEN_WIDTH] = fetchPixelFromFb(x, y);
|
||||
}
|
||||
}
|
||||
chan_send(&fb_sync, (void *)pixels);
|
||||
for (unsigned int x = 0; x < SCREEN_WIDTH; x++)
|
||||
{
|
||||
for (unsigned int y = startRow; y < endRow; y++)
|
||||
{
|
||||
pixels[x + y * SCREEN_WIDTH] = fetchPixelFromFb(x, y);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// signal the SDL main loop to proceed with rendering
|
||||
void *done = {0};
|
||||
chan_send(&fb_sync, done);
|
||||
}
|
||||
|
||||
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;
|
||||
int pitch = 0;
|
||||
|
@ -287,9 +288,8 @@ void sdl_task()
|
|||
SDL_Log("SDL_lock failed: %s", SDL_GetError());
|
||||
}
|
||||
|
||||
void *fb;
|
||||
chan_recv(&fb_sync, &fb);
|
||||
memcpy(pixels, fb, sizeof(PIXEL_SIZE) * SCREEN_HEIGHT * SCREEN_WIDTH);
|
||||
chan_send(&fb_sync, pixels);
|
||||
chan_recv(&fb_sync, NULL);
|
||||
|
||||
SDL_UnlockTexture(displayTexture);
|
||||
SDL_RenderCopy(renderer, displayTexture, NULL, NULL);
|
||||
|
|
Ładowanie…
Reference in New Issue