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>tags/mesa-10.1-rc1
| @@ -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 * | |||
| @@ -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_ */ | |||
| @@ -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)) { | |||
| @@ -183,6 +183,7 @@ i830CreateContext(int api, | |||
| __DRIcontext * driContextPriv, | |||
| unsigned major_version, | |||
| unsigned minor_version, | |||
| uint32_t flags, | |||
| unsigned *error, | |||
| void *sharedContextPrivate); | |||
| @@ -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)) { | |||
| @@ -324,6 +324,7 @@ extern bool i915CreateContext(int api, | |||
| __DRIcontext * driContextPriv, | |||
| unsigned major_version, | |||
| unsigned minor_version, | |||
| uint32_t flags, | |||
| unsigned *error, | |||
| void *sharedContextPrivate); | |||
| @@ -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, | |||
| @@ -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, | |||
| @@ -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) | |||
| @@ -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 | |||
| @@ -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; | |||
| @@ -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; | |||
| @@ -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; | |||
| @@ -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; | |||