[Mesa-dev] [PATCH] dri_util: Don't assume __DRIcontext->driverPrivate is a gl_context
Kristian Høgsberg
krh at bitplanet.net
Sat Dec 7 22:02:11 PST 2013
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.
Signed-off-by: Kristian Høgsberg <krh at bitplanet.net>
Cc: "10.0" <mesa-stable at lists.freedesktop.org>
---
src/mesa/drivers/dri/common/dri_util.c | 11 +++++++----
src/mesa/drivers/dri/common/dri_util.h | 3 +++
src/mesa/drivers/dri/i965/brw_context.c | 2 ++
3 files changed, 12 insertions(+), 4 deletions(-)
I'd suggest something like this... I haven't verified that it actually fixes
the problem, I just wanted to illustrate what the fix would look like and
ended up writing the full patch after all.
Kristian
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index 0bce77e..9134a94 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -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 *
diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h
index 79a8564..35f674e 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -289,6 +289,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_ */
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 6de6759..46ae086 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -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
--
1.8.3.1
More information about the mesa-dev
mailing list