Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on shader constant initialization on MinGW compiler #93469

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions servers/rendering/shader_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1445,8 +1445,12 @@ bool ShaderLanguage::_find_identifier(const BlockNode *p_block, bool p_allow_rea
*r_struct_name = shader->constants[p_identifier].struct_name;
}
if (r_constant_value) {
if (shader->constants[p_identifier].initializer && shader->constants[p_identifier].initializer->values.size() == 1) {
*r_constant_value = shader->constants[p_identifier].initializer->values[0];
if (shader->constants[p_identifier].initializer && shader->constants[p_identifier].initializer->type == Node::NODE_TYPE_CONSTANT) {
ConstantNode *cnode = static_cast<ConstantNode *>(shader->constants[p_identifier].initializer);

if (cnode->values.size() == 1) {
*r_constant_value = cnode->values[0];
}
}
}
if (r_type) {
Expand Down Expand Up @@ -9443,7 +9447,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
}
}

constant.initializer = static_cast<ConstantNode *>(expr);
constant.initializer = expr;

if (!_compare_datatypes(type, struct_name, 0, expr->get_datatype(), expr->get_datatype_name(), expr->get_array_size())) {
return ERR_PARSE_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion servers/rendering/shader_language.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ class ShaderLanguage {
DataType type;
StringName struct_name;
DataPrecision precision;
ConstantNode *initializer = nullptr;
Node *initializer = nullptr;
int array_size;
};

Expand Down
Loading