summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2020-02-12 20:12:05 +0300
committerGitHub <noreply@github.com>2020-02-12 20:12:05 +0300
commit4aa31a2851e3dd5b67193194f899850239b2669d (patch)
tree91408c1c1c1d6b0be39dc02a4fddc2cf1188b941 /drivers
parent0f90ddbcf4489f46132ef48c1611d5c14ff2b776 (diff)
parent6b99bda1e8407433a51fb69a32154690ec996d9b (diff)
Merge pull request #36141 from Chaosus/shader_struct_member_arrays
Added support for arrays as shader struct members
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles2/shader_compiler_gles2.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp
index 08047935bd..620fcdbdca 100644
--- a/drivers/gles2/shader_compiler_gles2.cpp
+++ b/drivers/gles2/shader_compiler_gles2.cpp
@@ -332,6 +332,11 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
}
struct_code += " ";
struct_code += m->name;
+ if (m->array_size > 0) {
+ struct_code += "[";
+ struct_code += itos(m->array_size);
+ struct_code += "]";
+ }
struct_code += ";\n";
}
struct_code += "}";
@@ -558,6 +563,26 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
}
}
} break;
+ case SL::Node::TYPE_ARRAY_CONSTRUCT: {
+ SL::ArrayConstructNode *arr_con_node = (SL::ArrayConstructNode *)p_node;
+ int sz = arr_con_node->initializer.size();
+ if (acnode->datatype == SL::TYPE_STRUCT) {
+ code += _mkid(arr_con_node->struct_name);
+ } else {
+ code += _typestr(arr_con_node->datatype);
+ }
+ code += "[";
+ code += itos(arr_con_node->initializer.size());
+ code += "]";
+ code += "(";
+ for (int i = 0; i < sz; i++) {
+ code += _dump_node_code(arr_con_node->initializer[i], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
+ if (i != sz - 1) {
+ code += ", ";
+ }
+ }
+ code += ")";
+ } break;
case SL::Node::TYPE_ARRAY_DECLARATION: {
SL::ArrayDeclarationNode *arr_dec_node = (SL::ArrayDeclarationNode *)p_node;
@@ -898,6 +923,11 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
code += _dump_node_code(member_node->owner, p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
code += ".";
code += member_node->name;
+ if (member_node->index_expression != NULL) {
+ code += "[";
+ code += _dump_node_code(member_node->index_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
+ code += "]";
+ }
} break;
}