diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2021-11-07 22:46:12 +0300 |
---|---|---|
committer | Yuri Roubinsky <chaosus89@gmail.com> | 2021-11-07 23:30:09 +0300 |
commit | bbfa5f29c79fe3ee57dc82b5e14a707efa4f0c3f (patch) | |
tree | 3d87781220b783c7349f1bad7a4f1fefd6c5f15a /servers/rendering/shader_language.cpp | |
parent | c89061e982a27ba6e5dc6ea54ae812976de2d2db (diff) |
Pushes array of uniforms to first place in the buffer to prevent bug
Diffstat (limited to 'servers/rendering/shader_language.cpp')
-rw-r--r-- | servers/rendering/shader_language.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 04cc844483..d803d5fcf8 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -7439,7 +7439,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct int texture_uniforms = 0; int texture_binding = 0; - int uniforms = 0; int instance_index = 0; ShaderNode::Uniform::Scope uniform_scope = ShaderNode::Uniform::SCOPE_LOCAL; @@ -7790,9 +7789,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct return ERR_PARSE_ERROR; } uniform2.texture_order = -1; - if (uniform_scope != ShaderNode::Uniform::SCOPE_INSTANCE) { - uniform2.order = uniforms++; - } } if (uniform2.array_size > 0) { @@ -8771,6 +8767,20 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct tk = _get_token(); } + int uniforms = 0; + + // Need to push arrays to first place in a uniform buffer in order to correct work. + for (Map<StringName, ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) { + if (E->get().texture_order == -1 && E->get().scope != ShaderNode::Uniform::SCOPE_INSTANCE && E->get().array_size > 0) { + E->get().order = uniforms++; + } + } + for (Map<StringName, ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) { + if (E->get().texture_order == -1 && E->get().scope != ShaderNode::Uniform::SCOPE_INSTANCE && E->get().array_size == 0) { + E->get().order = uniforms++; + } + } + int error_line; String error_message; if (!_check_varying_usages(&error_line, &error_message)) { |