Fix shader crash when passing array to built-in function without index

This commit is contained in:
Yuri Roubinsky 2021-09-18 14:05:14 +03:00
parent 87de2e7c4a
commit f68d3f67b5

View file

@ -2384,6 +2384,10 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
failed_builtin = true;
bool fail = false;
for (int i = 0; i < argcount; i++) {
if (p_func->arguments[i + 1]->type == Node::TYPE_ARRAY && !static_cast<const ArrayNode *>(p_func->arguments[i + 1])->is_indexed()) {
fail = true;
break;
}
if (get_scalar_type(args[i]) == args[i] && p_func->arguments[i + 1]->type == Node::TYPE_CONSTANT && convert_constant(static_cast<ConstantNode *>(p_func->arguments[i + 1]), builtin_func_defs[idx].args[i])) {
//all good, but needs implicit conversion later
} else if (args[i] != builtin_func_defs[idx].args[i]) {
@ -2560,6 +2564,11 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
} else {
arg_name = get_datatype_name(args[i]);
}
if (args3[i] > 0) {
arg_name += "[";
arg_name += itos(args3[i]);
arg_name += "]";
}
err += arg_name;
}
err += ")";