[Mesa-dev] [PATCH v2 7/7] mesa: don't enable legacy GL functions when using API_OPENGL_CORE

Ian Romanick idr at freedesktop.org
Fri Jul 27 08:15:28 PDT 2012


On 07/27/2012 08:06 AM, Brian Paul wrote:
> On 07/27/2012 12:43 AM, Jordan Justen wrote:
>> Signed-off-by: Jordan Justen<jordan.l.justen at intel.com>
>> ---
>>   src/mesa/main/api_exec.c |  227
>> ++++++++++++++++++++++++++++------------------
>>   src/mesa/main/api_exec.h |    3 +-
>>   src/mesa/main/context.c  |    2 +-
>>   src/mesa/main/vtxfmt.c   |  167 ++++++++++++++++++----------------
>>   4 files changed, 232 insertions(+), 167 deletions(-)
>>
>> diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c
>> index 19e7f98..81be46d 100644
>> --- a/src/mesa/main/api_exec.c
>> +++ b/src/mesa/main/api_exec.c
>> @@ -120,7 +120,7 @@
>>    * \param exec dispatch table.
>>    */
>>   struct _glapi_table *
>> -_mesa_create_exec_table(void)
>> +_mesa_create_exec_table(struct gl_context *ctx)
>>   {
>>      struct _glapi_table *exec;
>>
>> @@ -133,7 +133,10 @@ _mesa_create_exec_table(void)
>>   #endif
>>
>>      /* load the dispatch slots we understand */
>> -   SET_AlphaFunc(exec, _mesa_AlphaFunc);
>> +   if (ctx->API != API_OPENGL_CORE) {
>> +      SET_AlphaFunc(exec, _mesa_AlphaFunc);
>> +   }
>> +
>>      SET_BlendFunc(exec, _mesa_BlendFunc);
>>      SET_Clear(exec, _mesa_Clear);
>>      SET_ClearColor(exec, _mesa_ClearColor);
>> @@ -149,42 +152,62 @@ _mesa_create_exec_table(void)
>>      SET_Finish(exec, _mesa_Finish);
>>      SET_Flush(exec, _mesa_Flush);
>>      SET_FrontFace(exec, _mesa_FrontFace);
>> -   SET_Frustum(exec, _mesa_Frustum);
>> +   if (ctx->API != API_OPENGL_CORE) {
>> +      SET_Frustum(exec, _mesa_Frustum);
>> +   }
>
> So, if you're not plugging functions into these dispatch pointers, the
> default is the "no op" function in the dispatcher module which print a
> warning message about calling an invalid function.
>
> But the GL 3.2 spec says "Functions which have been removed will
> generate an INVALID_OPERATION error if called in the core profile or in
> a forward-compatible context."
>
> So I think we actually need to plug in a "invalid operation" stub
> function instead.  Something like this:

Already done.  See

commit 01168df4d999f84105928d69fdd3eeed6baeeab4
Author: Jordan Justen <jordan.l.justen at intel.com>
Date:   Mon Jul 16 15:41:26 2012 -0700

     mesa context: generate an error for uninstalled context functions

     For 'non-legacy' contexts we will want to generate an error
     if an uninstalled function is called.

     The effect of this change will be that we can avoid installing
     legacy functions, and they will then generate an error as
     needed for deprecated functions in GL >= 3.1.

     Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
     Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
     Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

>
> void GLAPIENTRY
> _mesa_invalid_function(void)
> {
>     GET_CURRENT_CONTEXT(ctx);
>     _mesa_error(ctx, GL_INVALID_OPERATION,
>                 "Calling legacy function from core profile");
> }
>
> [...]
>
>     if (ctx->API == API_OPENGL_CORE) {
>        SET_Frustum(exec, _mesa_invalid_function);
>     }
>     else {
>        SET_Frustum(exec, _mesa_Frustum);
>     }
>
>
> But it might be simplest to have a function that simply plugs the
> _mesa_invalid_function into all the relevant dispatch slots when a core
> profile context is created.  It would be called both for the "exec" the
> "dlist" dispatch tables.  Then we could leave the api_exec.c code mostly
> as-is.
>
> -Brian
> _______________________________________________
> 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