diff options
author | Thaddeus Crews <repiteo@outlook.com> | 2024-11-18 09:23:35 -0600 |
---|---|---|
committer | Thaddeus Crews <repiteo@outlook.com> | 2024-11-18 09:23:35 -0600 |
commit | 1c1e833a432e8517625ef78ed636b9028835a562 (patch) | |
tree | 766205d905d5d9206b6a0d2cda30da1bc5e0f157 /modules | |
parent | 778f26e69ed4e9531754926ecc708dacef062a5e (diff) | |
parent | 985dc61386cab2f657acd8049052c182e2f32640 (diff) | |
download | redot-engine-1c1e833a432e8517625ef78ed636b9028835a562.tar.gz |
Merge pull request #99376 from clayjohn/basisu-defer-init
Defer initializing BasisU encoder until it is needed
Diffstat (limited to 'modules')
-rw-r--r-- | modules/basis_universal/image_compress_basisu.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/modules/basis_universal/image_compress_basisu.cpp b/modules/basis_universal/image_compress_basisu.cpp index 8ca5dba225..be28d89508 100644 --- a/modules/basis_universal/image_compress_basisu.cpp +++ b/modules/basis_universal/image_compress_basisu.cpp @@ -38,13 +38,12 @@ #include <transcoder/basisu_transcoder.h> #ifdef TOOLS_ENABLED #include <encoder/basisu_comp.h> -#endif -void basis_universal_init() { -#ifdef TOOLS_ENABLED - basisu::basisu_encoder_init(); +static Mutex init_mutex; +static bool initialized = false; #endif +void basis_universal_init() { basist::basisu_transcoder_init(); } @@ -80,6 +79,13 @@ inline void _basisu_pad_mipmap(const uint8_t *p_image_mip_data, Vector<uint8_t> } Vector<uint8_t> basis_universal_packer(const Ref<Image> &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> image = p_image->duplicate(); |