summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2022-01-14 10:10:42 +0300
committerYuri Roubinsky <chaosus89@gmail.com>2022-01-14 10:37:39 +0300
commit0845b25497c00757e94b7c8f035fa1182282a0fd (patch)
treedc7932419afeaf80b2d3c4609512f01b0f1b6064 /servers
parente4453096d3bb0acbccb3d97e516c24ea2f713b36 (diff)
Fix shader crashing when declaring matrix or array varyings
Diffstat (limited to 'servers')
-rw-r--r--servers/rendering/shader_compiler.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/servers/rendering/shader_compiler.cpp b/servers/rendering/shader_compiler.cpp
index 114e7e66cb..b0629de2f0 100644
--- a/servers/rendering/shader_compiler.cpp
+++ b/servers/rendering/shader_compiler.cpp
@@ -692,17 +692,36 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
vcode += _prestr(varying.precision, ShaderLanguage::is_float_type(varying.type));
vcode += _typestr(varying.type);
vcode += " " + _mkid(varying_name);
+ uint32_t inc = 1U;
+
if (varying.array_size > 0) {
+ inc = (uint32_t)varying.array_size;
+
vcode += "[";
vcode += itos(varying.array_size);
vcode += "]";
}
+
+ switch (varying.type) {
+ case SL::TYPE_MAT2:
+ inc *= 2U;
+ break;
+ case SL::TYPE_MAT3:
+ inc *= 3U;
+ break;
+ case SL::TYPE_MAT4:
+ inc *= 4U;
+ break;
+ default:
+ break;
+ }
+
vcode += ";\n";
r_gen_code.stage_globals[STAGE_VERTEX] += "layout(location=" + itos(index) + ") " + interp_mode + "out " + vcode;
r_gen_code.stage_globals[STAGE_FRAGMENT] += "layout(location=" + itos(index) + ") " + interp_mode + "in " + vcode;
- index++;
+ index += inc;
}
if (var_frag_to_light.size() > 0) {