[Bf-blender-cvs] [34b24fb6025] master: BLI: use proper alignment for new matrix types
Jacques Lucke
noreply at git.blender.org
Fri Jan 6 17:59:34 CET 2023
Commit: 34b24fb6025011a28fcce4fc85e9132f7bf1cf57
Author: Jacques Lucke
Date: Fri Jan 6 17:59:07 2023 +0100
Branches: master
https://developer.blender.org/rB34b24fb6025011a28fcce4fc85e9132f7bf1cf57
BLI: use proper alignment for new matrix types
===================================================================
M source/blender/blenlib/BLI_math_matrix_types.hh
===================================================================
diff --git a/source/blender/blenlib/BLI_math_matrix_types.hh b/source/blender/blenlib/BLI_math_matrix_types.hh
index 6d6e738fc4b..f2cc66ebc1b 100644
--- a/source/blender/blenlib/BLI_math_matrix_types.hh
+++ b/source/blender/blenlib/BLI_math_matrix_types.hh
@@ -70,7 +70,7 @@ template<
int NumRow,
/* Alignment in bytes. Do not align matrices whose size is not a multiple of 4 component.
* This is in order to avoid padding when using arrays of matrices. */
- int Alignment = (((NumCol * NumRow) % 4) ? 4 : 0) * sizeof(T)>
+ int Alignment = (((NumCol * NumRow) % 4 == 0) ? 4 : 1) * alignof(T)>
struct alignas(Alignment) MatBase : public vec_struct_base<vec_base<T, NumRow>, NumCol> {
using base_type = T;
@@ -923,8 +923,8 @@ using float4x4 = MatBase<float, 4, 4>;
/* These types are reserved to wrap C matrices without copy. Note the un-alignment. */
/* TODO: It would be preferable to align all C matrices inside DNA structs. */
-using float4x4_view = MatView<float, 4, 4, 4, 4, 0, 0, /* Alignment */ 0>;
-using float4x4_mutableview = MutableMatView<float, 4, 4, 4, 4, 0, 0, /* Alignment */ 0>;
+using float4x4_view = MatView<float, 4, 4, 4, 4, 0, 0, alignof(float)>;
+using float4x4_mutableview = MutableMatView<float, 4, 4, 4, 4, 0, 0, alignof(float)>;
using double2x2 = MatBase<double, 2, 2>;
using double2x3 = MatBase<double, 2, 3>;
More information about the Bf-blender-cvs
mailing list