Mesa (main): wgl: Make overridden entrypoints local to stw_ext_context

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Sep 8 14:45:16 UTC 2021


Module: Mesa
Branch: main
Commit: e2bb111e02f9949b3c044cb9de024d87b96e5aac
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e2bb111e02f9949b3c044cb9de024d87b96e5aac

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Fri Sep  3 15:41:48 2021 -0700

wgl: Make overridden entrypoints local to stw_ext_context

Reviewed By: Bill Kristiansen <billkris at microsoft.com>

Reviewed-by: Charmaine Lee >charmainel at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12677>

---

 src/gallium/frontends/wgl/stw_ext_context.c | 18 ++++++++++++++++--
 src/gallium/frontends/wgl/stw_ext_context.h |  4 ++--
 src/gallium/targets/libgl-gdi/stw_wgl.c     | 21 ++-------------------
 3 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/src/gallium/frontends/wgl/stw_ext_context.c b/src/gallium/frontends/wgl/stw_ext_context.c
index fee498bf800..26dcd46e2cd 100644
--- a/src/gallium/frontends/wgl/stw_ext_context.c
+++ b/src/gallium/frontends/wgl/stw_ext_context.c
@@ -38,8 +38,22 @@
 #include "util/u_debug.h"
 
 
-wglCreateContext_t wglCreateContext_func = 0;
-wglDeleteContext_t wglDeleteContext_func = 0;
+static wglCreateContext_t wglCreateContext_func = 0;
+static wglDeleteContext_t wglDeleteContext_func = 0;
+
+/* When this library is used as a opengl32.dll drop-in replacement, ensure we
+ * use the wglCreate/Destroy entrypoints above, and not the true opengl32.dll,
+ * which could happen if this library's name is not opengl32.dll exactly.
+ *
+ * For example, Qt 5.4 bundles this as opengl32sw.dll:
+ * https://blog.qt.io/blog/2014/11/27/qt-weekly-21-dynamic-opengl-implementation-loading-in-qt-5-4/
+ */
+void
+stw_override_opengl32_entry_points(wglCreateContext_t create, wglDeleteContext_t delete)
+{
+   wglCreateContext_func = create;
+   wglDeleteContext_func = delete;
+}
 
 
 /**
diff --git a/src/gallium/frontends/wgl/stw_ext_context.h b/src/gallium/frontends/wgl/stw_ext_context.h
index d0337490436..3ef31913f52 100644
--- a/src/gallium/frontends/wgl/stw_ext_context.h
+++ b/src/gallium/frontends/wgl/stw_ext_context.h
@@ -32,7 +32,7 @@
 typedef HGLRC (WINAPI *wglCreateContext_t)(HDC hdc);
 typedef BOOL (WINAPI *wglDeleteContext_t)(HGLRC hglrc);
 
-extern wglCreateContext_t wglCreateContext_func;
-extern wglDeleteContext_t wglDeleteContext_func;
+extern void
+stw_override_opengl32_entry_points(wglCreateContext_t create, wglDeleteContext_t delete);
 
 #endif /* STW_EXT_CONTEXT_H */
diff --git a/src/gallium/targets/libgl-gdi/stw_wgl.c b/src/gallium/targets/libgl-gdi/stw_wgl.c
index 5f4cb7293fc..3b56fb59af4 100644
--- a/src/gallium/targets/libgl-gdi/stw_wgl.c
+++ b/src/gallium/targets/libgl-gdi/stw_wgl.c
@@ -48,10 +48,6 @@
 #include "stw_wgl.h"
 #include "stw_ext_context.h"
 
-
-static void
-overrideOpenGL32EntryPoints(void);
-
 WINGDIAPI BOOL APIENTRY
 wglCopyContext(
    HGLRC hglrcSrc,
@@ -67,7 +63,7 @@ WINGDIAPI HGLRC APIENTRY
 wglCreateContext(
    HDC hdc )
 {
-   overrideOpenGL32EntryPoints();
+   stw_override_opengl32_entry_points(&wglCreateContext, &wglDeleteContext);
    return (HGLRC)(UINT_PTR)DrvCreateContext(hdc);
 }
 
@@ -76,7 +72,7 @@ wglCreateLayerContext(
    HDC hdc,
    int iLayerPlane )
 {
-   overrideOpenGL32EntryPoints();
+   stw_override_opengl32_entry_points(&wglCreateContext, &wglDeleteContext);
    return (HGLRC)(UINT_PTR)DrvCreateLayerContext( hdc, iLayerPlane );
 }
 
@@ -377,16 +373,3 @@ wglRealizeLayerPalette(
 }
 
 
-/* When this library is used as a opengl32.dll drop-in replacement, ensure we
- * use the wglCreate/Destroy entrypoints above, and not the true opengl32.dll,
- * which could happen if this library's name is not opengl32.dll exactly.
- *
- * For example, Qt 5.4 bundles this as opengl32sw.dll:
- * https://blog.qt.io/blog/2014/11/27/qt-weekly-21-dynamic-opengl-implementation-loading-in-qt-5-4/
- */
-static void
-overrideOpenGL32EntryPoints(void)
-{
-   wglCreateContext_func = &wglCreateContext;
-   wglDeleteContext_func = &wglDeleteContext;
-}



More information about the mesa-commit mailing list