1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Fix uniform array alignment to fix a bug

This commit is contained in:
Yuri Roubinsky
2021-11-25 23:34:58 +03:00
parent 1e99eea064
commit 43d999e346
2 changed files with 14 additions and 2 deletions

View File

@@ -661,6 +661,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
uniform_sizes.write[uniform.order] = _get_datatype_size(ShaderLanguage::TYPE_UINT);
uniform_alignments.write[uniform.order] = _get_datatype_alignment(ShaderLanguage::TYPE_UINT);
} else {
// The following code enforces a 16-byte alignment of uniform arrays.
if (uniform.array_size > 0) {
int size = _get_datatype_size(uniform.type) * uniform.array_size;
int m = (16 * uniform.array_size);
@@ -668,10 +669,11 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
size += m - (size % m);
}
uniform_sizes.write[uniform.order] = size;
uniform_alignments.write[uniform.order] = 16;
} else {
uniform_sizes.write[uniform.order] = _get_datatype_size(uniform.type);
uniform_alignments.write[uniform.order] = _get_datatype_alignment(uniform.type);
}
uniform_alignments.write[uniform.order] = _get_datatype_alignment(uniform.type);
}
}