From 782fd5fab613703a4eabf9c7f563ad981d22b00e Mon Sep 17 00:00:00 2001 From: clayjohn Date: Sun, 26 Apr 2020 23:28:24 -0700 Subject: [PATCH] Avoid duplicating shader defines in GLES2 --- drivers/gles2/shader_compiler_gles2.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index 6c07a8918d5..350b9451450 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -488,12 +488,15 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener if (p_default_actions.usage_defines.has(var_node->name) && !used_name_defines.has(var_node->name)) { String define = p_default_actions.usage_defines[var_node->name]; + String node_name = define.substr(1, define.length()); if (define.begins_with("@")) { - define = p_default_actions.usage_defines[define.substr(1, define.length())]; + define = p_default_actions.usage_defines[node_name]; } - r_gen_code.custom_defines.push_back(define.utf8()); + if (!used_name_defines.has(node_name)) { + r_gen_code.custom_defines.push_back(define.utf8()); + } used_name_defines.insert(var_node->name); } @@ -550,12 +553,15 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener if (p_default_actions.usage_defines.has(arr_node->name) && !used_name_defines.has(arr_node->name)) { String define = p_default_actions.usage_defines[arr_node->name]; + String node_name = define.substr(1, define.length()); if (define.begins_with("@")) { - define = p_default_actions.usage_defines[define.substr(1, define.length())]; + define = p_default_actions.usage_defines[node_name]; } - r_gen_code.custom_defines.push_back(define.utf8()); + if (!used_name_defines.has(node_name)) { + r_gen_code.custom_defines.push_back(define.utf8()); + } used_name_defines.insert(arr_node->name); } @@ -726,12 +732,15 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener if (p_default_actions.usage_defines.has(var_node->name) && !used_name_defines.has(var_node->name)) { String define = p_default_actions.usage_defines[var_node->name]; + String node_name = define.substr(1, define.length()); if (define.begins_with("@")) { - define = p_default_actions.usage_defines[define.substr(1, define.length())]; + define = p_default_actions.usage_defines[node_name]; } - r_gen_code.custom_defines.push_back(define.utf8()); + if (!used_name_defines.has(node_name)) { + r_gen_code.custom_defines.push_back(define.utf8()); + } used_name_defines.insert(var_node->name); }