Added check if field name in the shader is equal to builtin
This commit is contained in:
parent
f480d1c3b7
commit
76eb486413
2 changed files with 42 additions and 0 deletions
|
@ -4754,6 +4754,11 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||||
return ERR_PARSE_ERROR;
|
return ERR_PARSE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (has_builtin(p_functions, name)) {
|
||||||
|
_set_error("Redefinition of '" + String(name) + "'");
|
||||||
|
return ERR_PARSE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (uniform) {
|
if (uniform) {
|
||||||
|
|
||||||
ShaderNode::Uniform uniform2;
|
ShaderNode::Uniform uniform2;
|
||||||
|
@ -5002,6 +5007,11 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||||
return ERR_PARSE_ERROR;
|
return ERR_PARSE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (has_builtin(p_functions, name)) {
|
||||||
|
_set_error("Redefinition of '" + String(name) + "'");
|
||||||
|
return ERR_PARSE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
tk = _get_token();
|
tk = _get_token();
|
||||||
if (tk.type != TK_PARENTHESIS_OPEN) {
|
if (tk.type != TK_PARENTHESIS_OPEN) {
|
||||||
if (type == TYPE_VOID) {
|
if (type == TYPE_VOID) {
|
||||||
|
@ -5060,6 +5070,11 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||||
return ERR_PARSE_ERROR;
|
return ERR_PARSE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (has_builtin(p_functions, name)) {
|
||||||
|
_set_error("Redefinition of '" + String(name) + "'");
|
||||||
|
return ERR_PARSE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
tk = _get_token();
|
tk = _get_token();
|
||||||
|
|
||||||
} else if (tk.type == TK_SEMICOLON) {
|
} else if (tk.type == TK_SEMICOLON) {
|
||||||
|
@ -5161,6 +5176,12 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||||
return ERR_PARSE_ERROR;
|
return ERR_PARSE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (has_builtin(p_functions, pname)) {
|
||||||
|
_set_error("Redefinition of '" + String(pname) + "'");
|
||||||
|
return ERR_PARSE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
FunctionNode::Argument arg;
|
FunctionNode::Argument arg;
|
||||||
arg.type = ptype;
|
arg.type = ptype;
|
||||||
arg.name = pname;
|
arg.name = pname;
|
||||||
|
@ -5227,6 +5248,26 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ShaderLanguage::has_builtin(const Map<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name) {
|
||||||
|
|
||||||
|
if (p_functions.has("vertex")) {
|
||||||
|
if (p_functions["vertex"].built_ins.has(p_name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (p_functions.has("fragment")) {
|
||||||
|
if (p_functions["fragment"].built_ins.has(p_name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (p_functions.has("light")) {
|
||||||
|
if (p_functions["light"].built_ins.has(p_name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Error ShaderLanguage::_find_last_flow_op_in_op(ControlFlowNode *p_flow, FlowOperation p_op) {
|
Error ShaderLanguage::_find_last_flow_op_in_op(ControlFlowNode *p_flow, FlowOperation p_op) {
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
|
@ -645,6 +645,7 @@ public:
|
||||||
Map<StringName, BuiltInInfo> built_ins;
|
Map<StringName, BuiltInInfo> built_ins;
|
||||||
bool can_discard;
|
bool can_discard;
|
||||||
};
|
};
|
||||||
|
static bool has_builtin(const Map<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct KeyWord {
|
struct KeyWord {
|
||||||
|
|
Loading…
Reference in a new issue