[Mesa-dev] [PATCH] dri_util: Don't assume __DRIcontext->driverPrivate is a gl_context

Ian Romanick idr at freedesktop.org
Mon Dec 9 12:41:46 PST 2013


On 12/09/2013 10:53 AM, Ian Romanick wrote:
> On 12/07/2013 10:02 PM, Kristian Høgsberg wrote:
>> 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>
> 
> Comparing with 95bd8a33, this seems like the obviously correct patch.

Actually... the reason Eric originally made this refactor was so that
all classic drivers would handle __DRI_CTX_FLAG_DEBUG.  It looks like
all of those drivers no need to call driContextSetFlags from the right
place.  Yeah?

> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
> 
>> ---
>>  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
>>
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 



More information about the mesa-dev mailing list