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.
This commit is contained in:
David Sichma 2018-08-02 21:04:33 +02:00
parent 6c569c90b6
commit c101dd5fa6
2 changed files with 9 additions and 0 deletions

View file

@ -704,6 +704,10 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
} }
code += ";\n"; code += ";\n";
} else if (cf_node->flow_op == SL::FLOW_OP_DISCARD) { } 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;"; code += "discard;";
} else if (cf_node->flow_op == SL::FLOW_OP_CONTINUE) { } else if (cf_node->flow_op == SL::FLOW_OP_CONTINUE) {
code += "continue;"; code += "continue;";

View file

@ -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) { } 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;"; code = "discard;";
} else if (cfnode->flow_op == SL::FLOW_OP_CONTINUE) { } else if (cfnode->flow_op == SL::FLOW_OP_CONTINUE) {