mesa/main: factor out one-time-init into a helper
This will make the next commit a bit cleaner. Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5879>
This commit is contained in:

committed by
Marge Bot

parent
38e3cbb639
commit
0a4aa612ba
@@ -340,14 +340,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,23 +352,12 @@ one_time_fini(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls all the various one-time-init functions in Mesa.
|
||||
*
|
||||
* While holding a global mutex lock, calls several initialization functions,
|
||||
* and sets the glapi callbacks if the \c MESA_DEBUG environment variable is
|
||||
* defined.
|
||||
*
|
||||
* \sa _math_init().
|
||||
* Calls all the various one-time-init functions in Mesa
|
||||
*/
|
||||
void
|
||||
_mesa_initialize(void)
|
||||
|
||||
static void
|
||||
one_time_init(void)
|
||||
{
|
||||
static bool initialized;
|
||||
|
||||
mtx_lock(&OneTimeLock);
|
||||
|
||||
/* truly one-time init */
|
||||
if (!initialized) {
|
||||
GLuint i;
|
||||
|
||||
STATIC_ASSERT(sizeof(GLbyte) == 1);
|
||||
@@ -412,6 +393,34 @@ _mesa_initialize(void)
|
||||
_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,
|
||||
* and sets the glapi callbacks if the \c MESA_DEBUG environment variable is
|
||||
* defined.
|
||||
*
|
||||
* \sa _math_init().
|
||||
*/
|
||||
void
|
||||
_mesa_initialize(void)
|
||||
{
|
||||
static bool initialized;
|
||||
|
||||
mtx_lock(&OneTimeLock);
|
||||
|
||||
/* truly one-time init */
|
||||
if (!initialized)
|
||||
one_time_init();
|
||||
|
||||
initialized = true;
|
||||
|
||||
mtx_unlock(&OneTimeLock);
|
||||
|
Reference in New Issue
Block a user