diff --git a/modules/basis_universal/image_compress_basisu.cpp b/modules/basis_universal/image_compress_basisu.cpp index 8ca5dba2254..be28d895082 100644 --- a/modules/basis_universal/image_compress_basisu.cpp +++ b/modules/basis_universal/image_compress_basisu.cpp @@ -38,13 +38,12 @@ #include #ifdef TOOLS_ENABLED #include + +static Mutex init_mutex; +static bool initialized = false; #endif void basis_universal_init() { -#ifdef TOOLS_ENABLED - basisu::basisu_encoder_init(); -#endif - basist::basisu_transcoder_init(); } @@ -80,6 +79,13 @@ inline void _basisu_pad_mipmap(const uint8_t *p_image_mip_data, Vector } Vector basis_universal_packer(const Ref &p_image, Image::UsedChannels p_channels) { + init_mutex.lock(); + if (!initialized) { + basisu::basisu_encoder_init(); + initialized = true; + } + init_mutex.unlock(); + uint64_t start_time = OS::get_singleton()->get_ticks_msec(); Ref image = p_image->duplicate();