@@ -1555,10 +1555,11 @@ bool ShaderLanguage::_find_identifier(const BlockNode *p_block, bool p_allow_rea
15551555 return false ;
15561556}
15571557
1558- bool ShaderLanguage::_validate_operator (const BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_op, DataType *r_ret_type, int *r_ret_size) {
1558+ bool ShaderLanguage::_validate_operator (const BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_op, DataType *r_ret_type, int *r_ret_size, StringName *r_ret_struct_name ) {
15591559 bool valid = false ;
15601560 DataType ret_type = TYPE_VOID;
15611561 int ret_size = 0 ;
1562+ String ret_struct_name;
15621563
15631564 switch (p_op->op ) {
15641565 case OP_EQUAL:
@@ -2003,7 +2004,23 @@ bool ShaderLanguage::_validate_operator(const BlockNode *p_block, const Function
20032004 DataType nb = p_op->arguments [1 ]->get_datatype ();
20042005 DataType nc = p_op->arguments [2 ]->get_datatype ();
20052006
2006- valid = na == TYPE_BOOL && (nb == nc) && !is_sampler_type (nb);
2007+ bool is_same = false ;
2008+ if (nb == nc) {
2009+ is_same = true ;
2010+
2011+ if (nb == TYPE_STRUCT) {
2012+ String tb = p_op->arguments [1 ]->get_datatype_name ();
2013+ String tc = p_op->arguments [2 ]->get_datatype_name ();
2014+
2015+ if (tb != tc) {
2016+ break ;
2017+ }
2018+
2019+ ret_struct_name = tb;
2020+ }
2021+ }
2022+
2023+ valid = na == TYPE_BOOL && is_same && !is_sampler_type (nb);
20072024 ret_type = nb;
20082025 ret_size = sa;
20092026 } break ;
@@ -2018,6 +2035,9 @@ bool ShaderLanguage::_validate_operator(const BlockNode *p_block, const Function
20182035 if (r_ret_size) {
20192036 *r_ret_size = ret_size;
20202037 }
2038+ if (r_ret_struct_name) {
2039+ *r_ret_struct_name = ret_struct_name;
2040+ }
20212041
20222042 if (valid && (!p_block || p_block->use_op_eval )) {
20232043 // Need to be placed here and not in the `_reduce_expression` because otherwise expressions like `1 + 2 / 2` will not work correctly.
@@ -7699,7 +7719,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
76997719
77007720 expression.write [next_op - 1 ].is_op = false ;
77017721 expression.write [next_op - 1 ].node = op;
7702- if (!_validate_operator (p_block, p_function_info, op, &op->return_cache , &op->return_array_size )) {
7722+ if (!_validate_operator (p_block, p_function_info, op, &op->return_cache , &op->return_array_size , &op-> struct_name )) {
77037723 if (error_set) {
77047724 return nullptr ;
77057725 }
@@ -7709,7 +7729,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
77097729 if (i > 0 ) {
77107730 at += " , " ;
77117731 }
7712- at += get_datatype_name (op->arguments [i]->get_datatype ());
7732+ DataType dt = op->arguments [i]->get_datatype ();
7733+ if (dt == TYPE_STRUCT) {
7734+ at += op->arguments [i]->get_datatype_name ();
7735+ } else {
7736+ at += get_datatype_name (dt);
7737+ }
77137738 if (!op->arguments [i]->is_indexed () && op->arguments [i]->get_array_size () > 0 ) {
77147739 at += " [" ;
77157740 at += itos (op->arguments [i]->get_array_size ());
0 commit comments