From d63d1c9e7fa646a3836d1363101309cfaf95a0bd Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 7 Aug 2022 17:13:38 +0200 Subject: [PATCH] Load icon during rendering backend setup. Creating a new window along with setting up an OpenGL context is universally a lengthy operation. Decode the icon image on a separate thread. --- profiler/src/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index e9662eb0..218f5a25 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -213,10 +213,13 @@ int main( int argc, char** argv ) } ); } ); - iconPx = stbi_load_from_memory( (const stbi_uc*)Icon_data, Icon_size, &iconX, &iconY, nullptr, 4 ); + auto iconThread = std::thread( [] { + iconPx = stbi_load_from_memory( (const stbi_uc*)Icon_data, Icon_size, &iconX, &iconY, nullptr, 4 ); + } ); ImGuiTracyContext imguiContext; Backend backend( title, DrawContents, &mainThreadTasks ); + iconThread.join(); backend.SetIcon( iconPx, iconX, iconY ); bptr = &backend;