wgl: Pass share context as pointer instead of DHGLRC
authorJesse Natalie <jenatali@microsoft.com>
Thu, 2 Sep 2021 15:51:34 +0000 (08:51 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 15 Sep 2021 20:17:31 +0000 (20:17 +0000)
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Reviewed By: Bill Kristiansen <billkris@microsoft.com>

Acked-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12727>

src/gallium/frontends/wgl/stw_context.c
src/gallium/frontends/wgl/stw_context.h
src/gallium/frontends/wgl/stw_device.h
src/gallium/frontends/wgl/stw_ext_context.c

index d3a1cea..4ab618b 100644 (file)
@@ -163,7 +163,7 @@ get_matching_pixel_format(HDC hdc)
  * wglCreateContextAttribsARB() to actually create a rendering context.
  */
 struct stw_context *
-stw_create_context_attribs(HDC hdc, INT iLayerPlane, DHGLRC hShareContext,
+stw_create_context_attribs(HDC hdc, INT iLayerPlane, struct stw_context *shareCtx,
                            int majorVersion, int minorVersion,
                            int contextFlags, int profileMask)
 {
@@ -172,7 +172,6 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, DHGLRC hShareContext,
    const struct stw_pixelformat_info *pfi;
    struct st_context_attribs attribs;
    struct stw_context *ctx = NULL;
-   struct stw_context *shareCtx = NULL;
    enum st_context_error ctx_err = 0;
 
    if (!stw_dev)
@@ -203,12 +202,8 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, DHGLRC hShareContext,
 
    pfi = stw_pixelformat_get_info( iPixelFormat );
 
-   if (hShareContext != 0) {
-      stw_lock_contexts(stw_dev);
-      shareCtx = stw_lookup_context_locked( hShareContext );
+   if (shareCtx != NULL)
       shareCtx->shared = TRUE;
-      stw_unlock_contexts(stw_dev);
-   }
 
    ctx = CALLOC_STRUCT( stw_context );
    if (ctx == NULL)
index 664e57d..76ea75a 100644 (file)
@@ -49,7 +49,7 @@ struct stw_context
 };
 
 struct stw_context *stw_create_context_attribs(HDC hdc, INT iLayerPlane,
-                                               DHGLRC hShareContext,
+                                               struct stw_context *shareCtx,
                                                int majorVersion, int minorVersion,
                                                int contextFlags, int profileMask);
 
index a939269..441c9fa 100644 (file)
@@ -121,6 +121,16 @@ stw_unlock_contexts(struct stw_device *stw_dev)
    LeaveCriticalSection(&stw_dev->ctx_mutex);
 }
 
+static inline struct stw_context *
+stw_lookup_context( DHGLRC dhglrc )
+{
+   struct stw_context *ret;
+   stw_lock_contexts(stw_dev);
+   ret = stw_lookup_context_locked(dhglrc);
+   stw_unlock_contexts(stw_dev);
+   return ret;
+}
+
 
 static inline void
 stw_lock_framebuffers(struct stw_device *stw_dev)
index c3ab043..52a8921 100644 (file)
@@ -197,7 +197,9 @@ wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int *attribList)
          share_dhglrc = (DHGLRC)(INT_PTR)hShareContext;
       }
 
-      struct stw_context *stw_ctx = stw_create_context_attribs(hDC, layerPlane, share_dhglrc,
+      struct stw_context *share_stw = stw_lookup_context(share_dhglrc);
+
+      struct stw_context *stw_ctx = stw_create_context_attribs(hDC, layerPlane, share_stw,
                                                                majorVersion, minorVersion,
                                                                contextFlags, profileMask);