Refactor module initialization

* Changed to use the same stages as extensions.
* Makes the initialization more coherent, helping solve problems due to lack of stages.
* Makes it easier to port between module and extension.
* removed the DRIVER initialization level (no longer needed).
This commit is contained in:
reduz 2022-05-03 11:56:08 +02:00
parent 0a9d31a7eb
commit de0ca3b999
103 changed files with 897 additions and 454 deletions

View file

@ -190,7 +190,11 @@ static String _get_cache_key_function_glsl(const RenderingDevice::Capabilities *
return version;
}
void preregister_glslang_types() {
void initialize_glslang_module(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_CORE) {
return;
}
// Initialize in case it's not initialized. This is done once per thread
// and it's safe to call multiple times.
glslang::InitializeProcess();
@ -198,9 +202,10 @@ void preregister_glslang_types() {
RenderingDevice::shader_set_get_cache_key_function(_get_cache_key_function_glsl);
}
void register_glslang_types() {
}
void uninitialize_glslang_module(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_CORE) {
return;
}
void unregister_glslang_types() {
glslang::FinalizeProcess();
}

View file

@ -33,8 +33,9 @@
#define MODULE_GLSLANG_HAS_PREREGISTER
void preregister_glslang_types();
void register_glslang_types();
void unregister_glslang_types();
#include "modules/register_module_types.h"
void initialize_glslang_module(ModuleInitializationLevel p_level);
void uninitialize_glslang_module(ModuleInitializationLevel p_level);
#endif // GLSLANG_REGISTER_TYPES_H