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

Author: Jesse Natalie <[email protected]>
Date:   Tue Sep 21 08:39:23 2021 -0700

wgl: Pass smapi explicitly to context creation

Acked-by: Daniel Stone <[email protected]>
Acked-by: Mike Blumenkrantz <[email protected]>
Acked-by: Sidney Just <[email protected]>
Acked-by: Jason Ekstrand <[email protected]>
Tested-by: Yonggang Luo <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12964>

---

 src/egl/drivers/wgl/egl_wgl.c               | 5 ++++-
 src/egl/drivers/wgl/egl_wgl.h               | 1 +
 src/gallium/frontends/wgl/stw_context.c     | 8 ++++++--
 src/gallium/frontends/wgl/stw_context.h     | 2 ++
 src/gallium/frontends/wgl/stw_ext_context.c | 4 ++++
 5 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/egl/drivers/wgl/egl_wgl.c b/src/egl/drivers/wgl/egl_wgl.c
index 9eb5e781a2d..24a3f9be831 100644
--- a/src/egl/drivers/wgl/egl_wgl.c
+++ b/src/egl/drivers/wgl/egl_wgl.c
@@ -218,7 +218,9 @@ wgl_initialize_impl(_EGLDisplay *disp, HDC hdc)
       goto cleanup;
    }
 
-   wgl_dpy->screen = stw_get_device()->screen;
+   struct stw_device *stw_dev = stw_get_device();
+   wgl_dpy->screen = stw_dev->screen;
+   wgl_dpy->smapi = stw_dev->smapi;
 
    disp->ClientAPIs = 0;
    if (_eglIsApiValid(EGL_OPENGL_API))
@@ -443,6 +445,7 @@ wgl_create_context(_EGLDisplay *disp, _EGLConfig *conf,
    if (wgl_ctx->base.ResetNotificationStrategy != EGL_NO_RESET_NOTIFICATION)
       resetStrategy = WGL_LOSE_CONTEXT_ON_RESET_ARB;
    wgl_ctx->ctx = stw_create_context_attribs(disp->PlatformDisplay, 0, shared,
+      wgl_dpy->smapi,
       wgl_ctx->base.ClientMajorVersion,
       wgl_ctx->base.ClientMinorVersion,
       flags,
diff --git a/src/egl/drivers/wgl/egl_wgl.h b/src/egl/drivers/wgl/egl_wgl.h
index 7fd5408d1b3..8c572b61353 100644
--- a/src/egl/drivers/wgl/egl_wgl.h
+++ b/src/egl/drivers/wgl/egl_wgl.h
@@ -35,6 +35,7 @@ struct wgl_egl_display
 {
    int ref_count;
    struct pipe_screen *screen;
+   struct st_manager *smapi;
 };
 
 struct wgl_egl_config
diff --git a/src/gallium/frontends/wgl/stw_context.c 
b/src/gallium/frontends/wgl/stw_context.c
index 678ddbd2c34..7ca1029f6c5 100644
--- a/src/gallium/frontends/wgl/stw_context.c
+++ b/src/gallium/frontends/wgl/stw_context.c
@@ -126,7 +126,10 @@ DrvCreateContext(HDC hdc)
 DHGLRC APIENTRY
 DrvCreateLayerContext(HDC hdc, INT iLayerPlane)
 {
-   struct stw_context *ctx = stw_create_context_attribs(hdc, iLayerPlane, 0, 
1, 0, 0,
+   if (!stw_dev)
+      return 0;
+
+   struct stw_context *ctx = stw_create_context_attribs(hdc, iLayerPlane, 
NULL, stw_dev->smapi, 1, 0, 0,
                                                         
WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
                                                         0, 
WGL_NO_RESET_NOTIFICATION_ARB);
    if (!ctx)
@@ -165,6 +168,7 @@ get_matching_pixel_format(HDC hdc)
  */
 struct stw_context *
 stw_create_context_attribs(HDC hdc, INT iLayerPlane, struct stw_context 
*shareCtx,
+                           struct st_manager *smapi,
                            int majorVersion, int minorVersion,
                            int contextFlags, int profileMask,
                            int iPixelFormat, int resetStrategy)
@@ -279,7 +283,7 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, struct 
stw_context *shareCt
    attribs.options = stw_dev->st_options;
 
    ctx->st = stw_dev->stapi->create_context(stw_dev->stapi,
-         stw_dev->smapi, &attribs, &ctx_err, shareCtx ? shareCtx->st : NULL);
+         smapi, &attribs, &ctx_err, shareCtx ? shareCtx->st : NULL);
    if (ctx->st == NULL)
       goto no_st_ctx;
 
diff --git a/src/gallium/frontends/wgl/stw_context.h 
b/src/gallium/frontends/wgl/stw_context.h
index 170cd7def19..5f4096f362c 100644
--- a/src/gallium/frontends/wgl/stw_context.h
+++ b/src/gallium/frontends/wgl/stw_context.h
@@ -35,6 +35,7 @@
 struct hud_context;
 struct stw_framebuffer;
 struct st_context_iface;
+struct st_manager;
 
 struct stw_context
 {
@@ -53,6 +54,7 @@ struct stw_context
 
 struct stw_context *stw_create_context_attribs(HDC hdc, INT iLayerPlane,
                                                struct stw_context *shareCtx,
+                                               struct st_manager *smapi,
                                                int majorVersion, int 
minorVersion,
                                                int contextFlags, int 
profileMask,
                                                int iPixelFormat, int 
resetStrategy);
diff --git a/src/gallium/frontends/wgl/stw_ext_context.c 
b/src/gallium/frontends/wgl/stw_ext_context.c
index 44161f948a6..2156726f339 100644
--- a/src/gallium/frontends/wgl/stw_ext_context.c
+++ b/src/gallium/frontends/wgl/stw_ext_context.c
@@ -83,6 +83,9 @@ wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, 
const int *attribList)
                                 WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB |
                                 WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB);
 
+   if (!stw_dev)
+      return NULL;
+
    /* parse attrib_list */
    if (attribList) {
       for (i = 0; !done && attribList[i]; i++) {
@@ -211,6 +214,7 @@ wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, 
const int *attribList)
       struct stw_context *share_stw = stw_lookup_context(share_dhglrc);
 
       struct stw_context *stw_ctx = stw_create_context_attribs(hDC, 
layerPlane, share_stw,
+                                                               stw_dev->smapi,
                                                                majorVersion, 
minorVersion,
                                                                contextFlags, 
profileMask, 0,
                                                                resetStrategy);

Reply via email to