dri_util: Don't assume __DRIcontext->driverPrivate is a gl_context
authorKristian Høgsberg <krh@bitplanet.net>
Sun, 8 Dec 2013 06:02:11 +0000 (22:02 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 13 Dec 2013 16:19:50 +0000 (08:19 -0800)
The driverPrivate pointer is opaque to the driver and we can't assume
it's a struct gl_context in dri_util.c.  Instead provide a helper function
to set the struct gl_context flags from the incoming DRI context flags.

v2 (idr): Modify the other classic drivers to also use
driContextSetFlags.  I ran all the piglit GLX_ARB_create_context tests
with i965 and classic swrast without regressions.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> [v1]
Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Ilia Mirkin <imirkin@alum.mit.edu> [v1 on Gallium nouveau]
Cc: "10.0" <mesa-stable@lists.freedesktop.org>
14 files changed:
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/common/dri_util.h
src/mesa/drivers/dri/i915/i830_context.c
src/mesa/drivers/dri/i915/i830_context.h
src/mesa/drivers/dri/i915/i915_context.c
src/mesa/drivers/dri/i915/i915_context.h
src/mesa/drivers/dri/i915/intel_context.c
src/mesa/drivers/dri/i915/intel_context.h
src/mesa/drivers/dri/i915/intel_screen.c
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/nouveau/nouveau_context.c
src/mesa/drivers/dri/r200/r200_context.c
src/mesa/drivers/dri/radeon/radeon_context.c
src/mesa/drivers/dri/swrast/swrast.c

index fd2eca715c37b1051c36dc10a35ac60a73196eaf..d648211123aaf499c21cd10b85e3b65c9fc19fad 100644 (file)
@@ -438,16 +438,19 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
         return NULL;
     }
 
-    struct gl_context *ctx = context->driverPrivate;
+    *error = __DRI_CTX_ERROR_SUCCESS;
+    return context;
+}
+
+void
+driContextSetFlags(struct gl_context *ctx, uint32_t flags)
+{
     if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
         ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
     if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) {
         ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT;
         ctx->Debug.DebugOutput = GL_TRUE;
     }
-
-    *error = __DRI_CTX_ERROR_SUCCESS;
-    return context;
 }
 
 static __DRIcontext *
index 4cfa75dd3e467a5da39fc866503816928a18c4f4..a79a4ed7aeabb12d4cf8a262743f11fa712ea5b3 100644 (file)
@@ -292,6 +292,9 @@ dri2InvalidateDrawable(__DRIdrawable *drawable);
 extern void
 driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv);
 
+extern void
+driContextSetFlags(struct gl_context *ctx, uint32_t flags);
+
 extern const __DRIimageDriverExtension driImageDriverExtension;
 
 #endif /* _DRI_UTIL_H_ */
index b7553d87fdc782859e150941822297f04e6660bf..87d1a496ecc0ce0f23cc30f3d5bc750ae0d7fef6 100644 (file)
@@ -56,6 +56,7 @@ i830CreateContext(int api,
                   __DRIcontext * driContextPriv,
                   unsigned major_version,
                   unsigned minor_version,
+                  uint32_t flags,
                   unsigned *error,
                   void *sharedContextPrivate)
 {
@@ -73,7 +74,7 @@ i830CreateContext(int api,
    i830InitDriverFunctions(&functions);
 
    if (!intelInitContext(intel, __DRI_API_OPENGL,
-                         major_version, minor_version,
+                         major_version, minor_version, flags,
                          mesaVis, driContextPriv,
                          sharedContextPrivate, &functions,
                          error)) {
index ab6222b56f049c6c29b3872b2378c7a62a84983b..4088480e644ae6edd6c9e30d89e6b1b77c079a83 100644 (file)
@@ -183,6 +183,7 @@ i830CreateContext(int api,
                   __DRIcontext * driContextPriv,
                   unsigned major_version,
                   unsigned minor_version,
+                  uint32_t flags,
                   unsigned *error,
                   void *sharedContextPrivate);
 
index 5907e32b75648b33de6d9d7a64660d1210fe2730..23890439ca599818cb97331202ba987410ad66b3 100644 (file)
@@ -151,6 +151,7 @@ i915CreateContext(int api,
                   __DRIcontext * driContextPriv,
                   unsigned major_version,
                   unsigned minor_version,
+                  uint32_t flags,
                   unsigned *error,
                   void *sharedContextPrivate)
 {
@@ -168,7 +169,7 @@ i915CreateContext(int api,
 
    i915InitDriverFunctions(&functions);
 
-   if (!intelInitContext(intel, api, major_version, minor_version,
+   if (!intelInitContext(intel, api, major_version, minor_version, flags,
                          mesaVis, driContextPriv,
                          sharedContextPrivate, &functions,
                          error)) {
index f5c15960dd0b664a45ab09e8398f99c7de945ed2..7789ac28ee41f88c1489ccd426e279fc54498057 100644 (file)
@@ -324,6 +324,7 @@ extern bool i915CreateContext(int api,
                              __DRIcontext * driContextPriv,
                               unsigned major_version,
                               unsigned minor_version,
+                              uint32_t flags,
                               unsigned *error,
                              void *sharedContextPrivate);
 
index 36188934fca33d471517dad93d3f753bd2477102..ac5d4ff240bffb79da5489947b6ae455e54e6113 100644 (file)
@@ -409,6 +409,7 @@ intelInitContext(struct intel_context *intel,
                  int api,
                  unsigned major_version,
                  unsigned minor_version,
+                 uint32_t flags,
                  const struct gl_config * mesaVis,
                  __DRIcontext * driContextPriv,
                  void *sharedContextPrivate,
index e488ed1a67773f559f0224e3a7831b8295367656..c3dad9c291f4b0815437bd8ce6d6ce8410e5ae66 100644 (file)
@@ -401,6 +401,7 @@ extern bool intelInitContext(struct intel_context *intel,
                              int api,
                              unsigned major_version,
                              unsigned minor_version,
+                             uint32_t flags,
                              const struct gl_config * mesaVis,
                              __DRIcontext * driContextPriv,
                              void *sharedContextPrivate,
index 7f1fc6b89e2ca597b49208268f7cbf4f1b3d28a6..d607f477d8433355c324bc9b8fc50ba0223bcde3 100644 (file)
@@ -931,6 +931,7 @@ i830CreateContext(int api,
                  __DRIcontext *driContextPriv,
                  unsigned major_version,
                  unsigned minor_version,
+                  uint32_t flags,
                  unsigned *error,
                  void *sharedContextPrivate);
 
@@ -940,6 +941,7 @@ i915CreateContext(int api,
                  __DRIcontext *driContextPriv,
                   unsigned major_version,
                   unsigned minor_version,
+                  uint32_t flags,
                   unsigned *error,
                  void *sharedContextPrivate);
 
@@ -971,13 +973,13 @@ intelCreateContext(gl_api api,
 
    if (IS_9XX(intelScreen->deviceID)) {
       success = i915CreateContext(api, mesaVis, driContextPriv,
-                                  major_version, minor_version, error,
-                                  sharedContextPrivate);
+                                  major_version, minor_version, flags,
+                                  error, sharedContextPrivate);
    } else {
       intelScreen->no_vbo = true;
       success = i830CreateContext(api, mesaVis, driContextPriv,
-                                  major_version, minor_version, error,
-                                  sharedContextPrivate);
+                                  major_version, minor_version, flags,
+                                  error, sharedContextPrivate);
    }
 
    if (success)
index a1676fe39fd0c90ead800f5e67905f1b5fd08502..688091fa49e28a0af95198d470bd07655997fd1e 100644 (file)
@@ -631,6 +631,8 @@ brwCreateContext(gl_api api,
       return false;
    }
 
+   driContextSetFlags(ctx, flags);
+
    /* Initialize the software rasterizer and helper modules.
     *
     * As of GL 3.1 core, the gen4+ driver doesn't need the swrast context for
index d44864ca9a95d21965def3682e2c32baa4accf93..18c6e776f2bf0bccb9d248a65977b8991566300f 100644 (file)
@@ -78,6 +78,8 @@ nouveau_context_create(gl_api api,
                return GL_FALSE;
        }
 
+       driContextSetFlags(ctx, flags);
+
        nctx = to_nouveau_context(ctx);
        nctx->dri_context = dri_ctx;
        dri_ctx->driverPrivate = ctx;
index d4e9ca8cacae1513192e35f62471e1375eccc9c1..dadbd7778c6b5517b48a20f8b9a7429d666cfe77 100644 (file)
@@ -279,6 +279,8 @@ GLboolean r200CreateContext( gl_api api,
      return GL_FALSE;
    }
 
+   driContextSetFlags(ctx, flags);
+
    rmesa->radeon.swtcl.RenderIndex = ~0;
    rmesa->radeon.hw.all_dirty = 1;
 
index 76bfe55c0ebf58da3ed5f90ae8c8d5eac13b5082..c8b997bcf052d04cf1c57360e56dc874bf546fe1 100644 (file)
@@ -242,6 +242,8 @@ r100CreateContext( gl_api api,
      return GL_FALSE;
    }
 
+   driContextSetFlags(ctx, flags);
+
    rmesa->radeon.swtcl.RenderIndex = ~0;
    rmesa->radeon.hw.all_dirty = GL_TRUE;
 
index 7eed5a418cb02cc7d5453752d7fd7b65c13842e9..cfa9316a2da70e7751992af9f31edeab4a7b92c1 100644 (file)
@@ -705,6 +705,8 @@ dri_create_context(gl_api api,
        goto context_fail;
     }
 
+    driContextSetFlags(ctx, flags);
+
     /* do bounds checking to prevent segfaults and server crashes! */
     mesaCtx->Const.CheckArrayBounds = GL_TRUE;