Skip to content

Commit

Permalink
Prevent shader crash when doing invalid operation on boolean vector
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaosus committed Jun 30, 2024
1 parent 4ab8fb8 commit 4bf9f3e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions servers/rendering/shader_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1547,7 +1547,7 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op, DataType *r_ret_type
}

DataType na = p_op->arguments[0]->get_datatype();
valid = na > TYPE_BOOL && na < TYPE_MAT2;
valid = na > TYPE_BVEC4 && na < TYPE_MAT2;
ret_type = na;
} break;
case OP_ADD:
Expand All @@ -1567,7 +1567,7 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op, DataType *r_ret_type
}

if (na == nb) {
valid = (na > TYPE_BOOL && na <= TYPE_MAT4);
valid = (na > TYPE_BVEC4 && na <= TYPE_MAT4);
ret_type = na;
} else if (na == TYPE_INT && nb == TYPE_IVEC2) {
valid = true;
Expand Down Expand Up @@ -1776,7 +1776,7 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op, DataType *r_ret_type
DataType nb = p_op->arguments[1]->get_datatype();

if (na == nb) {
valid = (na > TYPE_BOOL && na <= TYPE_MAT4);
valid = (na > TYPE_BVEC4 && na <= TYPE_MAT4);
ret_type = na;
} else if (na == TYPE_IVEC2 && nb == TYPE_INT) {
valid = true;
Expand Down

0 comments on commit 4bf9f3e

Please sign in to comment.