mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-14 04:57:54 +00:00
overlay: move init/free to the context of the render thread
This is done to allow overlays to make use of the renderer during init/free.
This commit is contained in:
parent
c737b12a3b
commit
8aa36144dc
6 changed files with 29 additions and 18 deletions
|
@ -280,7 +280,6 @@ static void egl_deinitialize(LG_Renderer * renderer)
|
|||
if (this->imgui)
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
|
||||
app_unregisterGraph(this->importGraph);
|
||||
ringbuffer_free(&this->importTimings);
|
||||
|
||||
egl_desktopFree(&this->desktop);
|
||||
|
|
|
@ -980,6 +980,9 @@ void app_overlayConfigRegisterTab(const char * title,
|
|||
|
||||
void app_invalidateOverlay(bool renderTwice)
|
||||
{
|
||||
if (g_state.state == APP_STATE_SHUTDOWN)
|
||||
return;
|
||||
|
||||
if (renderTwice)
|
||||
g_state.renderImGuiTwice = true;
|
||||
app_invalidateWindow(false);
|
||||
|
|
|
@ -201,6 +201,8 @@ static int renderThread(void * unused)
|
|||
|
||||
LG_LOCK_INIT(g_state.lgrLock);
|
||||
|
||||
app_initOverlays();
|
||||
|
||||
/* signal to other threads that the renderer is ready */
|
||||
lgSignalEvent(e_startup);
|
||||
|
||||
|
@ -322,6 +324,13 @@ static int renderThread(void * unused)
|
|||
|
||||
g_state.state = APP_STATE_SHUTDOWN;
|
||||
|
||||
if (g_state.overlays)
|
||||
{
|
||||
app_freeOverlays();
|
||||
ll_free(g_state.overlays);
|
||||
g_state.overlays = NULL;
|
||||
}
|
||||
|
||||
lgTimerDestroy(tickTimer);
|
||||
lgTimerDestroy(fpsTimer);
|
||||
|
||||
|
@ -1125,8 +1134,6 @@ static int lg_run(void)
|
|||
ImFontGlyphRangesBuilder_BuildRanges(rangeBuilder, &g_state.fontRange);
|
||||
ImFontGlyphRangesBuilder_destroy(rangeBuilder);
|
||||
|
||||
app_initOverlays();
|
||||
|
||||
// initialize metrics ringbuffers
|
||||
g_state.renderTimings = ringbuffer_new(256, sizeof(float));
|
||||
g_state.uploadTimings = ringbuffer_new(256, sizeof(float));
|
||||
|
@ -1666,13 +1673,6 @@ static void lg_shutdown(void)
|
|||
if (g_state.dsInitialized)
|
||||
g_state.ds->free();
|
||||
|
||||
if (g_state.overlays)
|
||||
{
|
||||
app_freeOverlays();
|
||||
ll_free(g_state.overlays);
|
||||
g_state.overlays = NULL;
|
||||
}
|
||||
|
||||
ivshmemClose(&g_state.shm);
|
||||
|
||||
renderQueue_free();
|
||||
|
|
|
@ -46,16 +46,14 @@ OverlayConfig;
|
|||
|
||||
static OverlayConfig cfg = { 0 };
|
||||
|
||||
static bool config_init(void ** udata, const void * params)
|
||||
static void config_earlyInit(void)
|
||||
{
|
||||
cfg.callbacks = ll_new();
|
||||
cfg.tabCallbacks = ll_new();
|
||||
if (!cfg.callbacks)
|
||||
{
|
||||
DEBUG_ERROR("failed to allocate ram");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool config_init(void ** udata, const void * params)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -239,6 +237,7 @@ static int config_render(void * udata, bool interactive, struct Rect * windowRec
|
|||
struct LG_OverlayOps LGOverlayConfig =
|
||||
{
|
||||
.name = "Config",
|
||||
.earlyInit = config_earlyInit,
|
||||
.init = config_init,
|
||||
.free = config_free,
|
||||
.render = config_render
|
||||
|
|
|
@ -70,9 +70,13 @@ static void showTimingKeybind(int sc, void * opaque)
|
|||
app_invalidateWindow(false);
|
||||
}
|
||||
|
||||
static bool graphs_init(void ** udata, const void * params)
|
||||
static void graphs_earlyInit(void)
|
||||
{
|
||||
gs.graphs = ll_new();
|
||||
}
|
||||
|
||||
static bool graphs_init(void ** udata, const void * params)
|
||||
{
|
||||
app_overlayConfigRegister("Performance Metrics", configCallback, NULL);
|
||||
app_registerKeybind(KEY_T, showTimingKeybind, NULL,
|
||||
"Show frame timing information");
|
||||
|
@ -207,6 +211,7 @@ static int graphs_render(void * udata, bool interactive,
|
|||
struct LG_OverlayOps LGOverlayGraphs =
|
||||
{
|
||||
.name = "Graphs",
|
||||
.earlyInit = graphs_earlyInit,
|
||||
.init = graphs_init,
|
||||
.free = graphs_free,
|
||||
.render = graphs_render
|
||||
|
|
|
@ -46,9 +46,13 @@ struct MsgState
|
|||
|
||||
struct MsgState l_msg = { 0 };
|
||||
|
||||
static bool msg_init(void ** udata, const void * params)
|
||||
static void msg_earlyInit(void)
|
||||
{
|
||||
l_msg.messages = ll_new();
|
||||
}
|
||||
|
||||
static bool msg_init(void ** udata, const void * params)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -168,6 +172,7 @@ static int msg_render(void * udata, bool interactive, struct Rect * windowRects,
|
|||
struct LG_OverlayOps LGOverlayMsg =
|
||||
{
|
||||
.name = "msg",
|
||||
.earlyInit = msg_earlyInit,
|
||||
.init = msg_init,
|
||||
.free = msg_free,
|
||||
.needs_overlay = msg_needsOverlay,
|
||||
|
|
Loading…
Reference in a new issue