Mesa (main): wgl: Implement WGL_ARB_create_context_robustness

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 28 20:01:20 UTC 2022


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

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Fri Feb 11 07:55:14 2022 -0800

wgl: Implement WGL_ARB_create_context_robustness

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
Reviewed-by: Bill Kristiansen <billkris at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15002>

---

 docs/relnotes/new_features.txt                       |  1 +
 src/egl/drivers/wgl/egl_wgl.c                        |  6 +++++-
 src/gallium/frontends/wgl/stw_context.c              |  8 ++++++--
 src/gallium/frontends/wgl/stw_context.h              |  2 +-
 src/gallium/frontends/wgl/stw_ext_context.c          | 16 ++++++++++++++--
 src/gallium/frontends/wgl/stw_ext_extensionsstring.c |  1 +
 6 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt
index e69de29bb2d..b8d89951bf0 100644
--- a/docs/relnotes/new_features.txt
+++ b/docs/relnotes/new_features.txt
@@ -0,0 +1 @@
+WGL_ARB_create_context_robustness
diff --git a/src/egl/drivers/wgl/egl_wgl.c b/src/egl/drivers/wgl/egl_wgl.c
index d0483e1641a..b98445133c4 100644
--- a/src/egl/drivers/wgl/egl_wgl.c
+++ b/src/egl/drivers/wgl/egl_wgl.c
@@ -445,12 +445,16 @@ wgl_create_context(_EGLDisplay *disp, _EGLConfig *conf,
       flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
    if (wgl_ctx->base.Flags & EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR)
       flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
+   unsigned resetStrategy = WGL_NO_RESET_NOTIFICATION_ARB;
+   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_ctx->base.ClientMajorVersion,
       wgl_ctx->base.ClientMinorVersion,
       flags,
       profile_mask,
-      stw_config->iPixelFormat);
+      stw_config->iPixelFormat,
+      resetStrategy);
 
    if (!wgl_ctx->ctx)
       goto cleanup;
diff --git a/src/gallium/frontends/wgl/stw_context.c b/src/gallium/frontends/wgl/stw_context.c
index 7c789f18b60..5fa0ca31fc9 100644
--- a/src/gallium/frontends/wgl/stw_context.c
+++ b/src/gallium/frontends/wgl/stw_context.c
@@ -128,7 +128,7 @@ DrvCreateLayerContext(HDC hdc, INT iLayerPlane)
 {
    struct stw_context *ctx = stw_create_context_attribs(hdc, iLayerPlane, 0, 1, 0, 0,
                                                         WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
-                                                        0);
+                                                        0, WGL_NO_RESET_NOTIFICATION_ARB);
    if (!ctx)
       return 0;
 
@@ -167,7 +167,7 @@ struct stw_context *
 stw_create_context_attribs(HDC hdc, INT iLayerPlane, struct stw_context *shareCtx,
                            int majorVersion, int minorVersion,
                            int contextFlags, int profileMask,
-                           int iPixelFormat)
+                           int iPixelFormat, int resetStrategy)
 {
    const struct stw_pixelformat_info *pfi;
    struct st_context_attribs attribs;
@@ -226,6 +226,10 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, struct stw_context *shareCt
       attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
    if (contextFlags & WGL_CONTEXT_DEBUG_BIT_ARB)
       attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
+   if (contextFlags & WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB)
+      attribs.flags |= ST_CONTEXT_FLAG_ROBUST_ACCESS;
+   if (resetStrategy != WGL_NO_RESET_NOTIFICATION_ARB)
+      attribs.flags |= ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED;
 
    switch (profileMask) {
    case WGL_CONTEXT_CORE_PROFILE_BIT_ARB:
diff --git a/src/gallium/frontends/wgl/stw_context.h b/src/gallium/frontends/wgl/stw_context.h
index d61efe881a4..caf3efa4ffa 100644
--- a/src/gallium/frontends/wgl/stw_context.h
+++ b/src/gallium/frontends/wgl/stw_context.h
@@ -53,7 +53,7 @@ struct stw_context *stw_create_context_attribs(HDC hdc, INT iLayerPlane,
                                                struct stw_context *shareCtx,
                                                int majorVersion, int minorVersion,
                                                int contextFlags, int profileMask,
-                                               int iPixelFormat);
+                                               int iPixelFormat, int resetStrategy);
 
 DHGLRC stw_create_context_handle(struct stw_context *context, DHGLRC handle);
 
diff --git a/src/gallium/frontends/wgl/stw_ext_context.c b/src/gallium/frontends/wgl/stw_ext_context.c
index 99665685357..44161f948a6 100644
--- a/src/gallium/frontends/wgl/stw_ext_context.c
+++ b/src/gallium/frontends/wgl/stw_ext_context.c
@@ -76,10 +76,12 @@ wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int *attribList)
    int majorVersion = 1, minorVersion = 0, layerPlane = 0;
    int contextFlags = 0x0;
    int profileMask = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
+   int resetStrategy = WGL_NO_RESET_NOTIFICATION_ARB;
    int i;
    BOOL done = FALSE;
    const int contextFlagsAll = (WGL_CONTEXT_DEBUG_BIT_ARB |
-                                WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB);
+                                WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB |
+                                WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB);
 
    /* parse attrib_list */
    if (attribList) {
@@ -100,6 +102,9 @@ wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int *attribList)
          case WGL_CONTEXT_PROFILE_MASK_ARB:
             profileMask = attribList[++i];
             break;
+         case WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB:
+            resetStrategy = attribList[++i];
+            break;
          case 0:
             /* end of list */
             done = TRUE;
@@ -150,6 +155,12 @@ wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int *attribList)
       return 0;
    }
 
+   if (resetStrategy != WGL_NO_RESET_NOTIFICATION_ARB &&
+       resetStrategy != WGL_LOSE_CONTEXT_ON_RESET_ARB) {
+      SetLastError(ERROR_INVALID_PARAMETER);
+      return NULL;
+   }
+
    /* Get pointer to OPENGL32.DLL's wglCreate/DeleteContext() functions */
    if (!wglCreateContext_func || !wglDeleteContext_func) {
       /* Get the OPENGL32.DLL library */
@@ -201,7 +212,8 @@ wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int *attribList)
 
       struct stw_context *stw_ctx = stw_create_context_attribs(hDC, layerPlane, share_stw,
                                                                majorVersion, minorVersion,
-                                                               contextFlags, profileMask, 0);
+                                                               contextFlags, profileMask, 0,
+                                                               resetStrategy);
 
       if (!stw_ctx) {
          wglDeleteContext_func(context);
diff --git a/src/gallium/frontends/wgl/stw_ext_extensionsstring.c b/src/gallium/frontends/wgl/stw_ext_extensionsstring.c
index 904ac151490..f0d29752e22 100644
--- a/src/gallium/frontends/wgl/stw_ext_extensionsstring.c
+++ b/src/gallium/frontends/wgl/stw_ext_extensionsstring.c
@@ -37,6 +37,7 @@
 static const char *stw_extension_string = 
    "WGL_ARB_create_context "
    "WGL_ARB_create_context_profile "
+   "WGL_ARB_create_context_robustness "
    "WGL_ARB_extensions_string "
    "WGL_ARB_make_current_read "
    "WGL_ARB_multisample "



More information about the mesa-commit mailing list