wgl: Pass smapi explicitly to context creation
authorJesse Natalie <jenatali@microsoft.com>
Tue, 21 Sep 2021 15:39:23 +0000 (08:39 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 10 Aug 2022 21:00:43 +0000 (21:00 +0000)
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Sidney Just <justsid@x-plane.com>
Acked-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Tested-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12964>

src/egl/drivers/wgl/egl_wgl.c
src/egl/drivers/wgl/egl_wgl.h
src/gallium/frontends/wgl/stw_context.c
src/gallium/frontends/wgl/stw_context.h
src/gallium/frontends/wgl/stw_ext_context.c

index 9eb5e78..24a3f9b 100644 (file)
@@ -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,
index 7fd5408..8c572b6 100644 (file)
@@ -35,6 +35,7 @@ struct wgl_egl_display
 {
    int ref_count;
    struct pipe_screen *screen;
+   struct st_manager *smapi;
 };
 
 struct wgl_egl_config
index 678ddbd..7ca1029 100644 (file)
@@ -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;
 
index 170cd7d..5f4096f 100644 (file)
@@ -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);
index 44161f9..2156726 100644 (file)
@@ -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);