From: Emil Velikov <emil.veli...@collabora.com>

Signed-off-by: Emil Velikov <emil.veli...@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

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to