Skip to content

Commit

Permalink
Merge pull request #81300 from bitsawer/fix_empty_shader_handling
Browse files Browse the repository at this point in the history
Fix empty shader resource loading
  • Loading branch information
YuriSizov committed Sep 5, 2023
2 parents cfdc016 + 15eec24 commit 3604b46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions scene/resources/shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,10 @@ Ref<Resource> ResourceFormatLoaderShader::load(const String &p_path, const Strin
ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot load shader: " + p_path);

String str;
error = str.parse_utf8((const char *)buffer.ptr(), buffer.size());
ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot parse shader: " + p_path);
if (buffer.size() > 0) {
error = str.parse_utf8((const char *)buffer.ptr(), buffer.size());
ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot parse shader: " + p_path);
}

Ref<Shader> shader;
shader.instantiate();
Expand Down
6 changes: 4 additions & 2 deletions scene/resources/shader_include.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ Ref<Resource> ResourceFormatLoaderShaderInclude::load(const String &p_path, cons
ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot load shader include: " + p_path);

String str;
error = str.parse_utf8((const char *)buffer.ptr(), buffer.size());
ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot parse shader include: " + p_path);
if (buffer.size() > 0) {
error = str.parse_utf8((const char *)buffer.ptr(), buffer.size());
ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot parse shader include: " + p_path);
}

Ref<ShaderInclude> shader_inc;
shader_inc.instantiate();
Expand Down

0 comments on commit 3604b46

Please sign in to comment.