From c101dd5fa62708b5c8175a9d8b0bfedd2b306961 Mon Sep 17 00:00:00 2001 From: David Sichma Date: Thu, 2 Aug 2018 21:04:33 +0200 Subject: [PATCH] Keeping track of discard Shader compilation now keeps track of the discard key word. Previously only variables were monitored. But discard, which needs special treatment in some cases, went unnoticed by the compiler as discard is not a variable but a flow control. This commit adds monitoring for discard. --- drivers/gles2/shader_compiler_gles2.cpp | 4 ++++ drivers/gles3/shader_compiler_gles3.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index 6c7f7677335..5ac2af6e5c7 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -704,6 +704,10 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener } code += ";\n"; } else if (cf_node->flow_op == SL::FLOW_OP_DISCARD) { + if (p_actions.usage_flag_pointers.has("DISCARD") && !used_flag_pointers.has("DISCARD")) { + *p_actions.usage_flag_pointers["DISCARD"] = true; + used_flag_pointers.insert("DISCARD"); + } code += "discard;"; } else if (cf_node->flow_op == SL::FLOW_OP_CONTINUE) { code += "continue;"; diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index 4ff8c72e13e..510188184bf 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -700,6 +700,11 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener } } else if (cfnode->flow_op == SL::FLOW_OP_DISCARD) { + if (p_actions.usage_flag_pointers.has("DISCARD") && !used_flag_pointers.has("DISCARD")) { + *p_actions.usage_flag_pointers["DISCARD"] = true; + used_flag_pointers.insert("DISCARD"); + } + code = "discard;"; } else if (cfnode->flow_op == SL::FLOW_OP_CONTINUE) {