mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[client] egl: fix race on resolution change
A resolution switch could cause the renderer state to become invalid as the texture format may change while it's being rendered. This fixes this by adding a lock around the format change and render calls to the renderer.
This commit is contained in:
parent
82e10c1b7e
commit
7c1e8a85cd
@ -106,6 +106,8 @@ static int renderThread(void * unused)
|
||||
return 1;
|
||||
}
|
||||
|
||||
LG_LOCK_INIT(g_state.lgrLock);
|
||||
|
||||
g_state.lgr->on_show_fps(g_state.lgrData, g_state.showFPS);
|
||||
|
||||
/* signal to other threads that the renderer is ready */
|
||||
@ -132,8 +134,13 @@ static int renderThread(void * unused)
|
||||
atomic_compare_exchange_weak(&g_state.lgrResize, &resize, 0);
|
||||
}
|
||||
|
||||
LG_LOCK(g_state.lgrLock);
|
||||
if (!g_state.lgr->render(g_state.lgrData, g_params.winRotate))
|
||||
{
|
||||
LG_UNLOCK(g_state.lgrLock);
|
||||
break;
|
||||
}
|
||||
LG_UNLOCK(g_state.lgrLock);
|
||||
|
||||
if (g_state.showFPS)
|
||||
{
|
||||
@ -184,6 +191,8 @@ static int renderThread(void * unused)
|
||||
|
||||
g_state.lgr->deinitialize(g_state.lgrData);
|
||||
g_state.lgr = NULL;
|
||||
LG_LOCK_FREE(g_state.lgrLock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -492,12 +501,15 @@ int main_frameThread(void * unused)
|
||||
frame->stride, frame->pitch,
|
||||
frame->rotation);
|
||||
|
||||
LG_LOCK(g_state.lgrLock);
|
||||
if (!g_state.lgr->on_frame_format(g_state.lgrData, lgrFormat, useDMA))
|
||||
{
|
||||
DEBUG_ERROR("renderer failed to configure format");
|
||||
g_state.state = APP_STATE_SHUTDOWN;
|
||||
LG_UNLOCK(g_state.lgrLock);
|
||||
break;
|
||||
}
|
||||
LG_UNLOCK(g_state.lgrLock);
|
||||
|
||||
g_state.srcSize.x = lgrFormat.width;
|
||||
g_state.srcSize.y = lgrFormat.height;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "common/thread.h"
|
||||
#include "common/types.h"
|
||||
#include "common/ivshmem.h"
|
||||
#include "common/locking.h"
|
||||
|
||||
#include "spice/spice.h"
|
||||
#include <lgmp/client.h>
|
||||
@ -73,6 +74,7 @@ struct AppState
|
||||
const LG_Renderer * lgr;
|
||||
void * lgrData;
|
||||
atomic_int lgrResize;
|
||||
LG_Lock lgrLock;
|
||||
|
||||
bool cbAvailable;
|
||||
SpiceDataType cbType;
|
||||
|
Loading…
Reference in New Issue
Block a user