[Mesa-dev] [PATCH 11/15] mesa: cleanup the remaining API references in one_time_init()

Ian Romanick idr at freedesktop.org
Tue Jun 7 18:19:18 UTC 2016


On 06/07/2016 09:33 AM, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
> 
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
>  src/mesa/main/context.c | 45 +++++++++++++++++++++------------------------
>  1 file changed, 21 insertions(+), 24 deletions(-)
> 
> diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
> index 894c38a..f8961fc 100644
> --- a/src/mesa/main/context.c
> +++ b/src/mesa/main/context.c
> @@ -370,44 +370,41 @@ one_time_fini(void)
>  static void
>  one_time_init( struct gl_context *ctx )
>  {
> -   static GLbitfield api_init_mask = 0x0;
> +   static bool initialized = false;
> +   unsigned i;
>  
> -   mtx_lock(&OneTimeLock);
> +   if (initialized)
> +       return;
>  
> -   /* truly one-time init */
> -   if (!api_init_mask) {
> -      GLuint i;
> +   mtx_lock(&OneTimeLock);
>  
> -      STATIC_ASSERT(sizeof(GLbyte) == 1);
> -      STATIC_ASSERT(sizeof(GLubyte) == 1);
> -      STATIC_ASSERT(sizeof(GLshort) == 2);
> -      STATIC_ASSERT(sizeof(GLushort) == 2);
> -      STATIC_ASSERT(sizeof(GLint) == 4);
> -      STATIC_ASSERT(sizeof(GLuint) == 4);
> +   STATIC_ASSERT(sizeof(GLbyte) == 1);
> +   STATIC_ASSERT(sizeof(GLubyte) == 1);
> +   STATIC_ASSERT(sizeof(GLshort) == 2);
> +   STATIC_ASSERT(sizeof(GLushort) == 2);
> +   STATIC_ASSERT(sizeof(GLint) == 4);
> +   STATIC_ASSERT(sizeof(GLuint) == 4);
>  
> -      _mesa_locale_init();
> +   _mesa_locale_init();
>  
> -      _mesa_one_time_init_extension_overrides();
> +   _mesa_one_time_init_extension_overrides();
>  
> -      _mesa_get_cpu_features();
> +   _mesa_get_cpu_features();
>  
> -      for (i = 0; i < 256; i++) {
> -         _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F;
> -      }
> +   for (i = 0; i < 256; i++)
> +      _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F;
>  
> -      atexit(one_time_fini);
> +   atexit(one_time_fini);
>  
>  #if defined(DEBUG) && defined(__DATE__) && defined(__TIME__)
> -      if (MESA_VERBOSE != 0) {
> -	 _mesa_debug(ctx, "Mesa %s DEBUG build %s %s\n",
> -		     PACKAGE_VERSION, __DATE__, __TIME__);
> -      }
> +   if (MESA_VERBOSE != 0)
> +      _mesa_debug(ctx, "Mesa " PACKAGE_VERSION " DEBUG build %s %s\n",
> +                  __DATE__, __TIME__);

I don't think we should make this change.  I seem to recall doing it
like this because static analysis tools complain... something about
PACKAGE_VERSION could have formatting.  I don't fully recall.  Either
way, it's orthogonal to the rest of the patch.

>  #endif
> -   }
>  
>     _mesa_init_remap_table();
>  
> -   api_init_mask |= 1 << ctx->API;
> +   initialized = true;
>  
>     mtx_unlock(&OneTimeLock);
>  }
> 



More information about the mesa-dev mailing list