diff options
author | clayjohn <claynjohn@gmail.com> | 2023-01-13 12:53:19 -0800 |
---|---|---|
committer | clayjohn <claynjohn@gmail.com> | 2023-01-13 12:53:19 -0800 |
commit | ccaebcd5e04aba9c7e3c9d819e4d10a40dd9679c (patch) | |
tree | f9e7d4b74275549c9b74de217d7c18e37ac22e6c | |
parent | 228db366bf7eee5cc1623f009d27e88ed80b5d7d (diff) |
Avoid crashing when custom GLSL shaders are imported when using the gl_compatibility renderer
-rw-r--r-- | editor/import/resource_importer_shader_file.cpp | 1 | ||||
-rw-r--r-- | servers/rendering/rendering_device_binds.cpp | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/editor/import/resource_importer_shader_file.cpp b/editor/import/resource_importer_shader_file.cpp index 7187e85df0..ba48fc9029 100644 --- a/editor/import/resource_importer_shader_file.cpp +++ b/editor/import/resource_importer_shader_file.cpp @@ -91,6 +91,7 @@ static String _include_function(const String &p_path, void *userpointer) { Error ResourceImporterShaderFile::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { /* STEP 1, Read shader code */ + ERR_FAIL_COND_V_EDMSG((OS::get_singleton()->get_current_rendering_method() == "gl_compatibility"), ERR_UNAVAILABLE, "Cannot import custom .glsl shaders when using the gl_compatibility rendering_method. Please switch to the forward_plus or mobile rendering methods to use custom shaders."); Error err; Ref<FileAccess> file = FileAccess::open(p_source_file, FileAccess::READ, &err); diff --git a/servers/rendering/rendering_device_binds.cpp b/servers/rendering/rendering_device_binds.cpp index 5967835d03..3678b70254 100644 --- a/servers/rendering/rendering_device_binds.cpp +++ b/servers/rendering/rendering_device_binds.cpp @@ -31,6 +31,8 @@ #include "rendering_device_binds.h" Error RDShaderFile::parse_versions_from_text(const String &p_text, const String p_defines, OpenIncludeFunction p_include_func, void *p_include_func_userdata) { + ERR_FAIL_NULL_V(RenderingDevice::get_singleton(), ERR_UNAVAILABLE); + Vector<String> lines = p_text.split("\n"); bool reading_versions = false; |