From 927a19d4f518109023f2274d62d8bc753ec8c593 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Sun, 11 Aug 2024 02:37:22 +0300 Subject: [PATCH] Fix async shader compiler on Windows --- third_party/duckstation/duckstation_scoped_guard.h | 8 ++++++++ third_party/duckstation/gl/context_wgl.cpp | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/third_party/duckstation/duckstation_scoped_guard.h b/third_party/duckstation/duckstation_scoped_guard.h index 89f35d92..c9e57ddd 100644 --- a/third_party/duckstation/duckstation_scoped_guard.h +++ b/third_party/duckstation/duckstation_scoped_guard.h @@ -19,6 +19,14 @@ public: /// Prevents the function from being invoked when we go out of scope. ALWAYS_INLINE void Cancel() { m_func.reset(); } + /// Runs the destructor function now instead of when we go out of scope. + ALWAYS_INLINE void Run() { + if (!m_func.has_value()) return; + + m_func.value()(); + m_func.reset(); + } + /// Explicitly fires the function. ALWAYS_INLINE void Invoke() { diff --git a/third_party/duckstation/gl/context_wgl.cpp b/third_party/duckstation/gl/context_wgl.cpp index b2e0d2e5..3837656b 100644 --- a/third_party/duckstation/gl/context_wgl.cpp +++ b/third_party/duckstation/gl/context_wgl.cpp @@ -19,6 +19,17 @@ static void* GetProcAddressCallback(const char* name) } namespace GL { +static bool ReloadWGL(HDC dc) +{ + if (!gladLoadWGL(dc)) + { + Log_ErrorPrint("Loading GLAD WGL functions failed"); + return false; + } + + return true; +} + ContextWGL::ContextWGL(const WindowInfo& wi) : Context(wi) {} ContextWGL::~ContextWGL()