[Bf-blender-cvs] [937dde60602] functions: fix wrong element size due to alignment
Jacques Lucke
noreply at git.blender.org
Tue Jul 30 13:27:47 CEST 2019
Commit: 937dde6060280f0728765e41a26ce7c29fcc191b
Author: Jacques Lucke
Date: Tue Jul 30 10:59:34 2019 +0200
Branches: functions
https://developer.blender.org/rB937dde6060280f0728765e41a26ce7c29fcc191b
fix wrong element size due to alignment
===================================================================
M source/blender/functions/backends/tuple/tuple.cpp
M source/blender/functions/backends/tuple/tuple.hpp
===================================================================
diff --git a/source/blender/functions/backends/tuple/tuple.cpp b/source/blender/functions/backends/tuple/tuple.cpp
index 509684c8cc5..63f925042b8 100644
--- a/source/blender/functions/backends/tuple/tuple.cpp
+++ b/source/blender/functions/backends/tuple/tuple.cpp
@@ -8,16 +8,19 @@ TupleMeta::TupleMeta(ArrayRef<SharedType> types) : m_types(types)
m_size__data = 0;
for (const SharedType &type : types) {
CPPTypeInfo &info = type->extension<CPPTypeInfo>();
+ uint size = info.size();
uint alignment = info.alignment();
+
m_size__data = pad_up(m_size__data, alignment);
m_offsets.append(m_size__data);
m_type_info.append(&info);
- m_size__data += info.size();
+ m_sizes.append(size);
+ m_size__data += size;
+
if (!info.trivially_destructible()) {
m_all_trivially_destructible = false;
}
}
- m_offsets.append(m_size__data);
m_size__data_and_init = m_size__data + this->element_amount();
}
diff --git a/source/blender/functions/backends/tuple/tuple.hpp b/source/blender/functions/backends/tuple/tuple.hpp
index da4968ead5b..4e5fdd91e45 100644
--- a/source/blender/functions/backends/tuple/tuple.hpp
+++ b/source/blender/functions/backends/tuple/tuple.hpp
@@ -40,6 +40,7 @@ class TupleMeta : public RefCountedBase {
Vector<SharedType> m_types;
Vector<CPPTypeInfo *> m_type_info;
Vector<uint> m_offsets;
+ Vector<uint> m_sizes;
uint m_size__data;
uint m_size__data_and_init;
bool m_all_trivially_destructible;
@@ -110,7 +111,7 @@ class TupleMeta : public RefCountedBase {
*/
uint element_size(uint index) const
{
- return m_offsets[index + 1] - m_offsets[index];
+ return m_sizes[index];
}
/**
More information about the Bf-blender-cvs
mailing list