[Mesa-stable] [PATCH] glapi: Encapsulate nop table knowledge in new _mesa_new_nop_table function

Brian Paul brianp at vmware.com
Tue May 26 18:03:59 PDT 2015


On 05/26/2015 05:56 PM, Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> Encapsulate the knowledge about how to build the nop table in a new
> _mesa_new_nop_table function.  This makes it easier for dispatch_sanity
> to keep working now and in the future.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> Cc: Brian Paul <brianp at vmware.com>
> Cc: Emil Velikov <emil.l.velikov at gmail.com>
> Cc: 10.6 <mesa-stable at lists.freedesktop.org>
> ---
> I sent this just a few minutes after the previous version of the patch.
> I was hoping to to get the squashed version out before Brian pushed his
> patch, but I was too slow.
>
>   src/mesa/main/api_exec.h                |  3 +++
>   src/mesa/main/context.c                 | 16 ++++++++--------
>   src/mesa/main/tests/dispatch_sanity.cpp |  2 +-
>   3 files changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/main/api_exec.h b/src/mesa/main/api_exec.h
> index 12249fe..655cb32 100644
> --- a/src/mesa/main/api_exec.h
> +++ b/src/mesa/main/api_exec.h
> @@ -38,6 +38,9 @@ _mesa_initialize_exec_table(struct gl_context *ctx);
>   extern void
>   _mesa_initialize_dispatch_tables(struct gl_context *ctx);
>
> +extern struct _glapi_table *
> +_mesa_new_nop_table(unsigned numEntries);
> +
>   #ifdef __cplusplus
>   } // extern "C"
>   #endif
> diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
> index 02875ba..e4faf3d 100644
> --- a/src/mesa/main/context.c
> +++ b/src/mesa/main/context.c
> @@ -962,12 +962,12 @@ generic_nop(void)
>    * the __stdcall convention which requires the callee to clean up the
>    * call stack.  That's impossible with one generic no-op function.
>    */
> -#if !USE_GLAPI_NOP_FEATURES
> -static struct _glapi_table *
> -new_nop_table(unsigned numEntries)
> +struct _glapi_table *
> +_mesa_new_nop_table(unsigned numEntries)
>   {
>      struct _glapi_table *table;
>
> +#if !USE_GLAPI_NOP_FEATURES
>      table = malloc(numEntries * sizeof(_glapi_proc));
>      if (table) {
>         _glapi_proc *entry = (_glapi_proc *) table;
> @@ -976,9 +976,11 @@ new_nop_table(unsigned numEntries)
>            entry[i] = (_glapi_proc) generic_nop;
>         }
>      }
> +#else
> +   table = _glapi_new_nop_table(numEntries);
> +#endif
>      return table;
>   }
> -#endif
>
>
>   /**
> @@ -996,10 +998,7 @@ alloc_dispatch_table(void)
>       */
>      int numEntries = MAX2(_glapi_get_dispatch_table_size(), _gloffset_COUNT);
>
> -#if !USE_GLAPI_NOP_FEATURES
> -   struct _glapi_table *table = new_nop_table(numEntries);
> -#else
> -   struct _glapi_table *table = _glapi_new_nop_table(numEntries);
> +   struct _glapi_table *table = _mesa_new_nop_table(numEntries);
>
>   #if defined(_WIN32)
>      if (table) {
> @@ -1023,6 +1022,7 @@ alloc_dispatch_table(void)
>      }
>   #endif
>
> +#if USE_GLAPI_NOP_FEATURES
>      _glapi_set_nop_handler(nop_handler);
>   #endif
>
> diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
> index d38b68d..c6f3c39 100644
> --- a/src/mesa/main/tests/dispatch_sanity.cpp
> +++ b/src/mesa/main/tests/dispatch_sanity.cpp
> @@ -96,7 +96,7 @@ DispatchSanity_test::SetUp()
>      _mesa_init_driver_functions(&driver_functions);
>
>      const unsigned size = _glapi_get_dispatch_table_size();
> -   nop_table = (_glapi_proc *) _glapi_new_nop_table(size);
> +   nop_table = (_glapi_proc *) _mesa_new_nop_table(size);
>   }
>
>   void
>

Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the mesa-stable mailing list