Browse Source

Discarding now works in shaders

"discard" has been added to the list of recognised keywords.

A flag specifing when discarding is allowed is now set correctly.
Daniel Doran 8 years ago
parent
commit
d0c42da961
1 changed files with 5 additions and 0 deletions
  1. 5 0
      servers/visual/shader_language.cpp

+ 5 - 0
servers/visual/shader_language.cpp

@@ -267,6 +267,7 @@ const ShaderLanguage::KeyWord ShaderLanguage::keyword_list[] = {
 	{ TK_CF_BREAK, "break" },
 	{ TK_CF_BREAK, "break" },
 	{ TK_CF_CONTINUE, "continue" },
 	{ TK_CF_CONTINUE, "continue" },
 	{ TK_CF_RETURN, "return" },
 	{ TK_CF_RETURN, "return" },
+	{ TK_CF_DISCARD, "discard" },
 	{ TK_UNIFORM, "uniform" },
 	{ TK_UNIFORM, "uniform" },
 	{ TK_VARYING, "varying" },
 	{ TK_VARYING, "varying" },
 	{ TK_ARG_IN, "in" },
 	{ TK_ARG_IN, "in" },
@@ -3804,6 +3805,10 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
 				func_node->return_type = type;
 				func_node->return_type = type;
 				func_node->return_precision = precision;
 				func_node->return_precision = precision;
 
 
+				if (p_functions.has(name)) {
+					func_node->can_discard = p_functions[name].can_discard;
+				}
+
 				func_node->body = alloc_node<BlockNode>();
 				func_node->body = alloc_node<BlockNode>();
 				func_node->body->parent_function = func_node;
 				func_node->body->parent_function = func_node;