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

Emil Velikov emil.l.velikov at gmail.com
Tue Jun 7 16:33:44 UTC 2016


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__);
 #endif
-   }
 
    _mesa_init_remap_table();
 
-   api_init_mask |= 1 << ctx->API;
+   initialized = true;
 
    mtx_unlock(&OneTimeLock);
 }
-- 
2.8.2



More information about the mesa-dev mailing list