summaryrefslogtreecommitdiff
path: root/servers/rendering/shader_language.cpp
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2021-08-13 10:37:53 +0300
committerGitHub <noreply@github.com>2021-08-13 10:37:53 +0300
commiteadf9d92f97329d85f88dce1a6f8ea6866bf191b (patch)
treea0d57d154003c7fddd9100a2f001d9d00c3c9d8d /servers/rendering/shader_language.cpp
parentaf70288ee086493b3ab3df9c0e03c47ec07a19e8 (diff)
parentfa96c98bdf7a4ec3a97a6f99dea37a98c2c77f35 (diff)
Merge pull request #51609 from Chaosus/shader_fix_varying_error
Fix shader crash when using local var with the same name as varying
Diffstat (limited to 'servers/rendering/shader_language.cpp')
-rw-r--r--servers/rendering/shader_language.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index 47c6317962..20fcb1396d 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -4228,6 +4228,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
IdentifierType ident_type;
int array_size = 0;
StringName struct_name;
+ bool is_local = false;
if (p_block && p_block->block_tag != SubClassTag::TAG_GLOBAL) {
int idx = 0;
@@ -4284,6 +4285,8 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
} else {
last_type = ident_type;
}
+
+ is_local = ident_type == IDENTIFIER_LOCAL_VAR || ident_type == IDENTIFIER_FUNCTION_ARGUMENT;
}
Node *index_expression = nullptr;
@@ -4358,6 +4361,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
arrname->assign_expression = assign_expression;
arrname->is_const = is_const;
arrname->array_size = array_size;
+ arrname->is_local = is_local;
expr = arrname;
} else {
VariableNode *varname = alloc_node<VariableNode>();
@@ -4365,6 +4369,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
varname->datatype_cache = data_type;
varname->is_const = is_const;
varname->struct_name = struct_name;
+ varname->is_local = is_local;
expr = varname;
}
#ifdef DEBUG_ENABLED