[Mesa-dev] [PATCH 3/8] dri: Change __DriverApiRec::CreateContext to take a struct for attribs

Neil Roberts neil at linux.intel.com
Wed Oct 1 12:00:46 PDT 2014


Previously the CreateContext method of __DriverApiRec took a set of arguments
to describe the attribute values from the window system API's
CreateContextAttribs function. As more attributes get added this could quickly
get unworkable and every new attribute needs a modification for every driver.

To fix that this patch passes the attribute values in a struct instead. The
struct has a bitmask to specify which members are used. However the first
three members (two for the GL version and one for the flags) are always set.
If the bit is not set in the attribute mask then it can be assumed the
attribute has the default value. That way the drivers can quickly check if any
attributes were set that they don't understand. When we add any new attributes
we can just extend the struct and add a new flag and the existing drivers will
automatically report an error when the attribute is used.

Currently the only attribute using this mechanism is the reset strategy but
the plan is to also use it for the flush control attribute in a later patch.
---
 src/gallium/state_trackers/dri/dri_context.c   | 18 +++++-----
 src/gallium/state_trackers/dri/dri_context.h   |  5 +--
 src/mesa/drivers/dri/common/dri_util.c         | 47 ++++++++++++++++----------
 src/mesa/drivers/dri/common/dri_util.h         | 32 +++++++++++++++---
 src/mesa/drivers/dri/i915/intel_screen.c       | 17 +++++-----
 src/mesa/drivers/dri/i965/brw_context.c        | 22 +++++++-----
 src/mesa/drivers/dri/i965/brw_context.h        |  5 +--
 src/mesa/drivers/dri/nouveau/nouveau_context.c | 14 ++++----
 src/mesa/drivers/dri/nouveau/nouveau_context.h |  5 ++-
 src/mesa/drivers/dri/r200/r200_context.c       | 11 +++---
 src/mesa/drivers/dri/r200/r200_context.h       |  6 ++--
 src/mesa/drivers/dri/radeon/radeon_context.c   | 11 +++---
 src/mesa/drivers/dri/radeon/radeon_context.h   |  6 ++--
 src/mesa/drivers/dri/swrast/swrast.c           | 16 +++++----
 14 files changed, 120 insertions(+), 95 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c
index fe3240a..4f75df0 100644
--- a/src/gallium/state_trackers/dri/dri_context.c
+++ b/src/gallium/state_trackers/dri/dri_context.c
@@ -42,10 +42,7 @@
 GLboolean
 dri_create_context(gl_api api, const struct gl_config * visual,
 		   __DRIcontext * cPriv,
-		   unsigned major_version,
-		   unsigned minor_version,
-		   uint32_t flags,
-                   bool notify_reset,
+                   const struct __DriverContextConfig *ctx_config,
 		   unsigned *error,
 		   void *sharedContextPrivate)
 {
@@ -69,13 +66,13 @@ dri_create_context(gl_api api, const struct gl_config * visual,
    case API_OPENGL_CORE:
       attribs.profile = api == API_OPENGL_COMPAT ? ST_PROFILE_DEFAULT
                                                  : ST_PROFILE_OPENGL_CORE;
-      attribs.major = major_version;
-      attribs.minor = minor_version;
+      attribs.major = ctx_config->major_version;
+      attribs.minor = ctx_config->minor_version;
 
-      if ((flags & __DRI_CTX_FLAG_DEBUG) != 0)
+      if ((ctx_config->flags & __DRI_CTX_FLAG_DEBUG) != 0)
 	 attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
 
-      if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
+      if ((ctx_config->flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
 	 attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
       break;
    default:
@@ -83,12 +80,13 @@ dri_create_context(gl_api api, const struct gl_config * visual,
       goto fail;
    }
 
-   if (flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE)) {
+   if (ctx_config->flags & ~(__DRI_CTX_FLAG_DEBUG |
+                             __DRI_CTX_FLAG_FORWARD_COMPATIBLE)) {
       *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
       goto fail;
    }
 
-   if (notify_reset) {
+   if (ctx_config->attribute_mask != 0) {
       *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
       goto fail;
    }
diff --git a/src/gallium/state_trackers/dri/dri_context.h b/src/gallium/state_trackers/dri/dri_context.h
index 56dfa2c..d0cfd07 100644
--- a/src/gallium/state_trackers/dri/dri_context.h
+++ b/src/gallium/state_trackers/dri/dri_context.h
@@ -86,10 +86,7 @@ boolean
 dri_create_context(gl_api api,
 		   const struct gl_config * visual,
 		   __DRIcontext * driContextPriv,
-		   unsigned major_version,
-		   unsigned minor_version,
-		   uint32_t flags,
-		   bool notify_reset,
+                   const struct __DriverContextConfig *ctx_config,
 		   unsigned *error,
 		   void *sharedContextPrivate);
 
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index 6c78928..3125c65 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -306,10 +306,12 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
     const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
     void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
     gl_api mesa_api;
-    unsigned major_version = 1;
-    unsigned minor_version = 0;
-    uint32_t flags = 0;
-    bool notify_reset = false;
+    struct __DriverContextConfig ctx_config;
+
+    ctx_config.major_version = 1;
+    ctx_config.minor_version = 0;
+    ctx_config.flags = 0;
+    ctx_config.attribute_mask = 0;
 
     assert((num_attribs == 0) || (attribs != NULL));
 
@@ -340,17 +342,23 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
     for (unsigned i = 0; i < num_attribs; i++) {
 	switch (attribs[i * 2]) {
 	case __DRI_CTX_ATTRIB_MAJOR_VERSION:
-	    major_version = attribs[i * 2 + 1];
+            ctx_config.major_version = attribs[i * 2 + 1];
 	    break;
 	case __DRI_CTX_ATTRIB_MINOR_VERSION:
-	    minor_version = attribs[i * 2 + 1];
+	    ctx_config.minor_version = attribs[i * 2 + 1];
 	    break;
 	case __DRI_CTX_ATTRIB_FLAGS:
-	    flags = attribs[i * 2 + 1];
+	    ctx_config.flags = attribs[i * 2 + 1];
 	    break;
         case __DRI_CTX_ATTRIB_RESET_STRATEGY:
-            notify_reset = (attribs[i * 2 + 1]
-                            != __DRI_CTX_RESET_NO_NOTIFICATION);
+            if (attribs[i * 2 + 1] != __DRI_CTX_RESET_NO_NOTIFICATION) {
+                ctx_config.attribute_mask |=
+                    __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY;
+                ctx_config.reset_strategy = attribs[i * 2 + 1];
+            } else {
+                ctx_config.attribute_mask &=
+                    ~__DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY;
+            }
             break;
 	default:
 	    /* We can't create a context that satisfies the requirements of an
@@ -366,12 +374,14 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
      * compatibility profile.  This means that we treat a API_OPENGL_COMPAT 3.1 as
      * API_OPENGL_CORE and reject API_OPENGL_COMPAT 3.2+.
      */
-    if (mesa_api == API_OPENGL_COMPAT && major_version == 3 && minor_version == 1)
+    if (mesa_api == API_OPENGL_COMPAT &&
+        ctx_config.major_version == 3 && ctx_config.minor_version == 1)
        mesa_api = API_OPENGL_CORE;
 
     if (mesa_api == API_OPENGL_COMPAT
-        && ((major_version > 3)
-            || (major_version == 3 && minor_version >= 2))) {
+        && ((ctx_config.major_version > 3)
+            || (ctx_config.major_version == 3 &&
+                ctx_config.minor_version >= 2))) {
        *error = __DRI_CTX_ERROR_BAD_API;
        return NULL;
     }
@@ -388,7 +398,7 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
      */
     if (mesa_api != API_OPENGL_COMPAT
         && mesa_api != API_OPENGL_CORE
-        && flags != 0) {
+        && ctx_config.flags != 0) {
 	*error = __DRI_CTX_ERROR_BAD_FLAG;
 	return NULL;
     }
@@ -404,20 +414,22 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
      *
      * In Mesa, a debug context is the same as a regular context.
      */
-    if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) {
+    if ((ctx_config.flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) {
        mesa_api = API_OPENGL_CORE;
     }
 
     const uint32_t allowed_flags = (__DRI_CTX_FLAG_DEBUG
                                     | __DRI_CTX_FLAG_FORWARD_COMPATIBLE
                                     | __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS);
-    if (flags & ~allowed_flags) {
+    if (ctx_config.flags & ~allowed_flags) {
 	*error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
 	return NULL;
     }
 
     if (!validate_context_version(screen, mesa_api,
-                                  major_version, minor_version, error))
+                                  ctx_config.major_version,
+                                  ctx_config.minor_version,
+                                  error))
        return NULL;
 
     context = calloc(1, sizeof *context);
@@ -433,8 +445,7 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
     context->driReadablePriv = NULL;
 
     if (!screen->driver->CreateContext(mesa_api, modes, context,
-                                       major_version, minor_version,
-                                       flags, notify_reset, error, shareCtx)) {
+                                       &ctx_config, error, shareCtx)) {
         free(context);
         return NULL;
     }
diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h
index 1138bf1..0369987 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -67,6 +67,33 @@ extern const __DRIswrastExtension driSWRastExtension;
 extern const __DRIdri2Extension driDRI2Extension;
 extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
 extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
+
+/**
+ * Description of the attributes used to create a config.
+ *
+ * This is passed as the context_config parameter to CreateContext. The idea
+ * with this struct is that it can be extended without having to modify all of
+ * the drivers. The first three members (major/minor_version and flags) are
+ * always valid, but the remaining members are only valid if the corresponding
+ * flag is set for the attribute. If the flag is not set then the default
+ * value should be assumed. That way the driver can quickly check if any
+ * attributes were set that it doesn't understand and report an error.
+ */
+struct __DriverContextConfig {
+    /* These members are always valid */
+    unsigned major_version;
+    unsigned minor_version;
+    uint32_t flags;
+
+    /* Flags describing which of the remaining members are valid */
+    uint32_t attribute_mask;
+
+    /* Only valid if __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY is set */
+    int reset_strategy;
+};
+
+#define __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY (1 << 0)
+
 /**
  * Driver callback functions.
  *
@@ -85,10 +112,7 @@ struct __DriverAPIRec {
     GLboolean (*CreateContext)(gl_api api,
                                const struct gl_config *glVis,
                                __DRIcontext *driContextPriv,
-			       unsigned major_version,
-			       unsigned minor_version,
-			       uint32_t flags,
-                               bool notify_reset,
+                               const struct __DriverContextConfig *ctx_config,
 			       unsigned *error,
                                void *sharedContextPrivate);
 
diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c
index 00d8580..6806a53 100644
--- a/src/mesa/drivers/dri/i915/intel_screen.c
+++ b/src/mesa/drivers/dri/i915/intel_screen.c
@@ -947,10 +947,7 @@ static GLboolean
 intelCreateContext(gl_api api,
 		   const struct gl_config * mesaVis,
                    __DRIcontext * driContextPriv,
-		   unsigned major_version,
-		   unsigned minor_version,
-		   uint32_t flags,
-                   bool notify_reset,
+                   const struct __DriverContextConfig *ctx_config,
 		   unsigned *error,
                    void *sharedContextPrivate)
 {
@@ -959,24 +956,28 @@ intelCreateContext(gl_api api,
    __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    struct intel_screen *intelScreen = sPriv->driverPrivate;
 
-   if (flags & ~__DRI_CTX_FLAG_DEBUG) {
+   if (ctx_config->flags & ~__DRI_CTX_FLAG_DEBUG) {
       *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
       return false;
    }
 
-   if (notify_reset) {
+   if (ctx_config->attribute_mask) {
       *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
       return false;
    }
 
    if (IS_9XX(intelScreen->deviceID)) {
       success = i915CreateContext(api, mesaVis, driContextPriv,
-                                  major_version, minor_version, flags,
+                                  ctx_config->major_version,
+                                  ctx_config->minor_version,
+                                  ctx_config->flags,
                                   error, sharedContextPrivate);
    } else {
       intelScreen->no_vbo = true;
       success = i830CreateContext(api, mesaVis, driContextPriv,
-                                  major_version, minor_version, flags,
+                                  ctx_config->major_version,
+                                  ctx_config->minor_version,
+                                  ctx_config->flags,
                                   error, sharedContextPrivate);
    }
 
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index ca389f8..d78ae56 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -631,10 +631,7 @@ GLboolean
 brwCreateContext(gl_api api,
 	         const struct gl_config *mesaVis,
 		 __DRIcontext *driContextPriv,
-                 unsigned major_version,
-                 unsigned minor_version,
-                 uint32_t flags,
-                 bool notify_reset,
+                 const struct __DriverContextConfig *ctx_config,
                  unsigned *dri_ctx_error,
 	         void *sharedContextPrivate)
 {
@@ -653,11 +650,20 @@ brwCreateContext(gl_api api,
    if (screen->has_context_reset_notification)
       allowed_flags |= __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS;
 
-   if (flags & ~allowed_flags) {
+   if (ctx_config->flags & ~allowed_flags) {
       *dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
       return false;
    }
 
+   if (ctx_config->attribute_mask & ~__DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY) {
+      *dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+      return false;
+   }
+
+   bool notify_reset =
+      ((ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY) &&
+       ctx_config->reset_strategy != __DRI_CTX_RESET_NO_NOTIFICATION);
+
    struct brw_context *brw = rzalloc(NULL, struct brw_context);
    if (!brw) {
       fprintf(stderr, "%s: failed to alloc context\n", __FUNCTION__);
@@ -720,7 +726,7 @@ brwCreateContext(gl_api api,
       return false;
    }
 
-   driContextSetFlags(ctx, flags);
+   driContextSetFlags(ctx, ctx_config->flags);
 
    /* Initialize the software rasterizer and helper modules.
     *
@@ -818,12 +824,12 @@ brwCreateContext(gl_api api,
 
    brw_draw_init( brw );
 
-   if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) {
+   if ((ctx_config->flags & __DRI_CTX_FLAG_DEBUG) != 0) {
       /* Turn on some extra GL_ARB_debug_output generation. */
       brw->perf_debug = true;
    }
 
-   if ((flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS) != 0)
+   if ((ctx_config->flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS) != 0)
       ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB;
 
    if (INTEL_DEBUG & DEBUG_SHADER_TIME)
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 317724f..cdb30ea 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1444,10 +1444,7 @@ void intel_resolve_for_dri2_flush(struct brw_context *brw,
 GLboolean brwCreateContext(gl_api api,
 		      const struct gl_config *mesaVis,
 		      __DRIcontext *driContextPriv,
-                      unsigned major_version,
-                      unsigned minor_version,
-                      uint32_t flags,
-                      bool notify_reset,
+                      const struct __DriverContextConfig *ctx_config,
                       unsigned *error,
 		      void *sharedContextPrivate);
 
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c
index 5be5ec5..18ec5fa 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c
@@ -50,10 +50,7 @@
 GLboolean
 nouveau_context_create(gl_api api,
 		       const struct gl_config *visual, __DRIcontext *dri_ctx,
-		       unsigned major_version,
-		       unsigned minor_version,
-		       uint32_t flags,
-		       bool notify_reset,
+		       const struct __DriverContextConfig *ctx_config,
 		       unsigned *error,
 		       void *share_ctx)
 {
@@ -62,12 +59,12 @@ nouveau_context_create(gl_api api,
 	struct nouveau_context *nctx;
 	struct gl_context *ctx;
 
-	if (flags & ~__DRI_CTX_FLAG_DEBUG) {
+	if (ctx_config->flags & ~__DRI_CTX_FLAG_DEBUG) {
 		*error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
 		return false;
 	}
 
-	if (notify_reset) {
+	if (ctx_config->attribute_mask) {
 		*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
 		return false;
 	}
@@ -78,14 +75,15 @@ nouveau_context_create(gl_api api,
 		return GL_FALSE;
 	}
 
-	driContextSetFlags(ctx, flags);
+	driContextSetFlags(ctx, ctx_config->flags);
 
 	nctx = to_nouveau_context(ctx);
 	nctx->dri_context = dri_ctx;
 	dri_ctx->driverPrivate = ctx;
 
 	_mesa_compute_version(ctx);
-	if (ctx->Version < major_version * 10 + minor_version) {
+	if (ctx->Version < (ctx_config->major_version * 10 +
+			    ctx_config->minor_version)) {
 	   nouveau_context_destroy(dri_ctx);
 	   *error = __DRI_CTX_ERROR_BAD_VERSION;
 	   return GL_FALSE;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h
index 8ea431b..923fb4e 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h
@@ -110,9 +110,8 @@ struct nouveau_context {
 GLboolean
 nouveau_context_create(gl_api api,
 		       const struct gl_config *visual, __DRIcontext *dri_ctx,
-		       unsigned major_version, unsigned minor_version,
-		       uint32_t flags, bool notify_reset, unsigned *error,
-		       void *share_ctx);
+		       const struct __DriverContextConfig *ctx_config,
+		       unsigned *error, void *share_ctx);
 
 GLboolean
 nouveau_context_init(struct gl_context *ctx, gl_api api,
diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
index 931f437..4ca2df4 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -175,10 +175,7 @@ static void r200_init_vtbl(radeonContextPtr radeon)
 GLboolean r200CreateContext( gl_api api,
 			     const struct gl_config *glVisual,
 			     __DRIcontext *driContextPriv,
-			     unsigned major_version,
-			     unsigned minor_version,
-			     uint32_t flags,
-                             bool notify_reset,
+			     const struct __DriverContextConfig *ctx_config,
 			     unsigned *error,
 			     void *sharedContextPrivate)
 {
@@ -190,12 +187,12 @@ GLboolean r200CreateContext( gl_api api,
    int i;
    int tcl_mode;
 
-   if (flags & ~__DRI_CTX_FLAG_DEBUG) {
+   if (ctx_config->flags & ~__DRI_CTX_FLAG_DEBUG) {
       *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
       return false;
    }
 
-   if (notify_reset) {
+   if (ctx_config->attribute_mask) {
       *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
       return false;
    }
@@ -261,7 +258,7 @@ GLboolean r200CreateContext( gl_api api,
 
    ctx = &rmesa->radeon.glCtx;
 
-   driContextSetFlags(ctx, flags);
+   driContextSetFlags(ctx, ctx_config->flags);
 
    /* Initialize the software rasterizer and helper modules.
     */
diff --git a/src/mesa/drivers/dri/r200/r200_context.h b/src/mesa/drivers/dri/r200/r200_context.h
index eb498f7..fb3c84e 100644
--- a/src/mesa/drivers/dri/r200/r200_context.h
+++ b/src/mesa/drivers/dri/r200/r200_context.h
@@ -635,10 +635,8 @@ extern void r200DestroyContext( __DRIcontext *driContextPriv );
 extern GLboolean r200CreateContext( gl_api api,
 				    const struct gl_config *glVisual,
 				    __DRIcontext *driContextPriv,
-				    unsigned major_version,
-				    unsigned minor_version,
-				    uint32_t flags,
-                                    bool notify_reset,
+				    const struct __DriverContextConfig *
+				       ctx_config,
 				    unsigned *error,
 				    void *sharedContextPrivate);
 extern GLboolean r200MakeCurrent( __DRIcontext *driContextPriv,
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index b376c0c..60e43d5 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -140,10 +140,7 @@ GLboolean
 r100CreateContext( gl_api api,
 		   const struct gl_config *glVisual,
 		   __DRIcontext *driContextPriv,
-		   unsigned major_version,
-		   unsigned minor_version,
-		   uint32_t flags,
-                   bool notify_reset,
+		   const struct __DriverContextConfig *ctx_config,
 		   unsigned *error,
 		   void *sharedContextPrivate)
 {
@@ -155,12 +152,12 @@ r100CreateContext( gl_api api,
    int i;
    int tcl_mode, fthrottle_mode;
 
-   if (flags & ~__DRI_CTX_FLAG_DEBUG) {
+   if (ctx_config->flags & ~__DRI_CTX_FLAG_DEBUG) {
       *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
       return false;
    }
 
-   if (notify_reset) {
+   if (ctx_config->attribute_mask) {
       *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
       return false;
    }
@@ -222,7 +219,7 @@ r100CreateContext( gl_api api,
 
    ctx = &rmesa->radeon.glCtx;
 
-   driContextSetFlags(ctx, flags);
+   driContextSetFlags(ctx, ctx_config->flags);
 
    /* Initialize the software rasterizer and helper modules.
     */
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.h b/src/mesa/drivers/dri/radeon/radeon_context.h
index 4032532..d093fb4 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.h
+++ b/src/mesa/drivers/dri/radeon/radeon_context.h
@@ -454,10 +454,8 @@ R100_CONTEXT(struct gl_context *ctx)
 extern GLboolean r100CreateContext( gl_api api,
 				    const struct gl_config *glVisual,
 				    __DRIcontext *driContextPriv,
-				    unsigned major_version,
-				    unsigned minor_version,
-				    uint32_t flags,
-                                    bool notify_reset,
+				    const struct __DriverContextConfig *
+				       ctx_config,
 				    unsigned *error,
 				    void *sharedContextPrivate);
 
diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
index e8a2c12..7ed5a39 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -726,10 +726,7 @@ static GLboolean
 dri_create_context(gl_api api,
 		   const struct gl_config * visual,
 		   __DRIcontext * cPriv,
-		   unsigned major_version,
-		   unsigned minor_version,
-		   uint32_t flags,
-		   bool notify_reset,
+		   const struct __DriverContextConfig *ctx_config,
 		   unsigned *error,
 		   void *sharedContextPrivate)
 {
@@ -742,8 +739,15 @@ dri_create_context(gl_api api,
     TRACE;
 
     /* Flag filtering is handled in dri2CreateContextAttribs.
+     * FIXME: Is it really?
      */
-    (void) flags;
+    (void) ctx_config->flags;
+
+    /* The swrast driver doesn't understand any of the attributes */
+    if (ctx_config->attribute_mask != 0) {
+	*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+	return false;
+    }
 
     ctx = CALLOC_STRUCT(dri_context);
     if (ctx == NULL) {
@@ -770,7 +774,7 @@ dri_create_context(gl_api api,
 	goto context_fail;
     }
 
-    driContextSetFlags(mesaCtx, flags);
+    driContextSetFlags(mesaCtx, ctx_config->flags);
 
     /* create module contexts */
     _swrast_CreateContext( mesaCtx );
-- 
1.9.3



More information about the mesa-dev mailing list