aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2020-07-10 13:05:32 +0200
committerMarge Bot <[email protected]>2020-07-14 10:56:03 +0000
commit0a4aa612ba27d6b9e550f7c4a009f30fcfa0c93e (patch)
treee54070ee548c1bf74619a8891c957736011d98f6 /src/mesa
parent38e3cbb639174db71eea9edc2628e4e0b1696fbc (diff)
mesa/main: factor out one-time-init into a helper
This will make the next commit a bit cleaner. Reviewed-by: Kristian H. Kristensen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5879>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/context.c95
1 files changed, 52 insertions, 43 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 2b8becb806d..b8b11b0c450 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -341,14 +341,6 @@ _mesa_destroy_visual( struct gl_config *vis )
/**
- * One-time initialization mutex lock.
- *
- * \sa Used by one_time_init().
- */
-mtx_t OneTimeLock = _MTX_INITIALIZER_NP;
-
-
-/**
* Calls all the various one-time-fini functions in Mesa
*/
@@ -360,6 +352,56 @@ one_time_fini(void)
}
/**
+ * Calls all the various one-time-init functions in Mesa
+ */
+
+static void
+one_time_init(void)
+{
+ GLuint i;
+
+ 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_one_time_init_extension_overrides();
+
+ _mesa_get_cpu_features();
+
+ for (i = 0; i < 256; i++) {
+ _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F;
+ }
+
+ atexit(one_time_fini);
+
+#if defined(DEBUG)
+ if (MESA_VERBOSE != 0) {
+ _mesa_debug(NULL, "Mesa " PACKAGE_VERSION " DEBUG build" MESA_GIT_SHA1 "\n");
+ }
+#endif
+
+ /* Take a glsl type reference for the duration of libGL's life to avoid
+ * unecessary creation/destruction of glsl types.
+ */
+ glsl_type_singleton_init_or_ref();
+
+ _mesa_init_remap_table();
+}
+
+/**
+ * One-time initialization mutex lock.
+ *
+ * \sa Used by _mesa_initialize().
+ */
+mtx_t OneTimeLock = _MTX_INITIALIZER_NP;
+
+
+/**
* Calls all the various one-time-init functions in Mesa.
*
* While holding a global mutex lock, calls several initialization functions,
@@ -376,41 +418,8 @@ _mesa_initialize(void)
mtx_lock(&OneTimeLock);
/* truly one-time init */
- if (!initialized) {
- GLuint i;
-
- 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_one_time_init_extension_overrides();
-
- _mesa_get_cpu_features();
-
- for (i = 0; i < 256; i++) {
- _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F;
- }
-
- atexit(one_time_fini);
-
-#if defined(DEBUG)
- if (MESA_VERBOSE != 0) {
- _mesa_debug(NULL, "Mesa " PACKAGE_VERSION " DEBUG build" MESA_GIT_SHA1 "\n");
- }
-#endif
-
- /* Take a glsl type reference for the duration of libGL's life to avoid
- * unecessary creation/destruction of glsl types.
- */
- glsl_type_singleton_init_or_ref();
-
- _mesa_init_remap_table();
- }
+ if (!initialized)
+ one_time_init();
initialized = true;