Refactor alignment code. Change deprecated function in test.

This commit is contained in:
Christoffer Lerno
2024-09-12 08:30:01 +02:00
parent 9f4da339c3
commit 1b6ec34c61
2 changed files with 4 additions and 4 deletions

View File

@@ -668,11 +668,11 @@ AlignSize type_abi_alignment(Type *type)
if (!len) len = 1;
ByteSize width = type_size(type->array.base) * len;
AlignSize alignment = (AlignSize)(int32_t)width;
if (alignment & (alignment - 1))
if (max_alignment_vector && alignment > max_alignment_vector) return max_alignment_vector;
if (!is_power_of_two(alignment))
{
alignment = (AlignSize)next_highest_power_of_2((uint32_t)alignment);
}
if (max_alignment_vector && alignment > max_alignment_vector) alignment = max_alignment_vector;
return alignment;
}
case TYPE_VOID:

View File

@@ -50,8 +50,8 @@ fn void test_mat4()
-0.988936, -2.970838, -20.765262, 1.000000
};
Matrix4 look_at = vector::matrix4_look_at({4.0, 5.0, 20.0}, {1.0, 3.0, 0.0}, {0.0, 1.0, 0.0});
Matrix4f look_at_f = vector::matrix4f_look_at({4.0, 5.0, 20.0}, {1.0, 3.0, 0.0}, {0.0, 1.0, 0.0});
Matrix4 look_at = matrix::look_at(<double>)({4.0, 5.0, 20.0}, {1.0, 3.0, 0.0}, {0.0, 1.0, 0.0});
Matrix4f look_at_f = matrix::look_at(<float>)({4.0, 5.0, 20.0}, {1.0, 3.0, 0.0}, {0.0, 1.0, 0.0});
assert(math::round_to_decimals((double[<16>])look_at.m, 4) == math::round_to_decimals((double[<16>])result.m, 4));
assert(math::round_to_decimals((float[<16>])look_at_f.m, 4) == math::round_to_decimals((float[<16>])result_f.m, 4));