rsimd

Make SIMD instruction sets easier to use
git clone git://git.meso-star.fr/rsimd.git
Log | Files | Refs | README | LICENSE

commit 7dd8954d4229525bfbebefa1720ff04513517c73
parent d9088d1c00342b493c341935550144d0746c4d8c
Author: vaplv <vaplv@free.fr>
Date:   Sun, 10 Mar 2019 10:56:36 +0100

Update the soaXfY_lerp function

Do not clamp the interpolation parameter anymore.

Diffstat:
Msrc/soaXfY.h | 7++-----
Msrc/test_soa4f2.c | 4++--
Msrc/test_soa4f3.c | 4++--
Msrc/test_soa4f4.c | 4++--
Dsrc/test_soa4f_utils.h | 32--------------------------------
Asrc/test_soaXf_utils.h | 48++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 56 insertions(+), 43 deletions(-)

diff --git a/src/soaXfY.h b/src/soaXfY.h @@ -261,14 +261,11 @@ RSIMD_soaXfY__(lerp) const RSIMD_vXf_T__ t) { RSIMD_vXf_T__ tmp[RSIMD_SOA_DIMENSION__]; - RSIMD_vXf_T__ t_adjusted; int i; ASSERT(dst && from && to); - t_adjusted = RSIMD_vXf__(min) - (RSIMD_vXf__(max)(t, RSIMD_vXf__(zero)()), RSIMD_vXf__(set1)(1.f)); + FOR_EACH(i, 0, RSIMD_SOA_DIMENSION__) - tmp[i] = RSIMD_vXf__(madd) - (t_adjusted, RSIMD_vXf__(sub)(to[i], from[i]), from[i]); + tmp[i] = RSIMD_vXf__(lerp)(from[i], to[i], t); RSIMD_soaXfY__(set__)(dst, tmp); return dst; } diff --git a/src/test_soa4f2.c b/src/test_soa4f2.c @@ -14,7 +14,7 @@ * along with the RSIMD library. If not, see <http://www.gnu.org/licenses/>. */ #include "soa4f2.h" -#include "test_soa4f_utils.h" +#include "test_soaXf_utils.h" #define CHECK_F2(V, A, B, C, D, E, F, G, H) \ { \ @@ -67,7 +67,7 @@ main(int argc, char** argv) CHECK_F2(dst, 0.5f, 0.5f, 0.5f, 0.5f, 1.5f, 1.5f, 1.5f, 1.5f); soa4f2(a, v4f_set(-1.f, 2.f, 3.f,-4.f), v4f_set(5.f,-6.f,-7.f, 8.f)); soa4f2_minus(b, a); - CHK(soa4f2_lerp(dst, a, b, v4f_set(-0.5f, 1.f, 0.5f, 4.f)) == dst); + CHK(soa4f2_lerp(dst, a, b, v4f_set(0.f, 1.f, 0.5f, 1.f)) == dst); CHECK_F2(dst, -1.f, -2.f, 0.f, 4.f, 5.f, 6.f, 0.f, -8.f); f = soa4f2_sum(b); diff --git a/src/test_soa4f3.c b/src/test_soa4f3.c @@ -14,7 +14,7 @@ * along with the RSIMD library. If not, see <http://www.gnu.org/licenses/>. */ #include "soa4f3.h" -#include "test_soa4f_utils.h" +#include "test_soaXf_utils.h" #define CHECK_F3(V, A, B, C, D, E, F, G, H, I, J, K, L) \ { \ @@ -82,7 +82,7 @@ main(int argc, char** argv) v4f_set(5.f, -6.f, -7.f, 8.f), v4f_set(9.f, -10.f, 1.f, -2.f)) == a); CHK(soa4f3_minus(b, a) == b); - CHK(soa4f3_lerp(dst, a, b, v4f_set(-0.5f, 1.f, 0.5f, 4.f)) == dst); + CHK(soa4f3_lerp(dst, a, b, v4f_set(0.f, 1.f, 0.5f, 1.f)) == dst); CHECK_F3(dst, -1.f, -2.f, 0.f, 4.f, 5.f, 6.f, 0.f, -8.f, 9.f, 10.f, 0.f, 2.f); f = soa4f3_sum(b); diff --git a/src/test_soa4f4.c b/src/test_soa4f4.c @@ -14,7 +14,7 @@ * along with the RSIMD library. If not, see <http://www.gnu.org/licenses/>. */ #include "soa4f4.h" -#include "test_soa4f_utils.h" +#include "test_soaXf_utils.h" #define CHECK_F4(V, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) \ { \ @@ -121,7 +121,7 @@ main(int argc, char** argv) v4f_set(9.f, -10.f, 1.f, -2.f), v4f_set(5.f, -3.f, -7.f, 1.f)) == a); CHK(soa4f4_minus(b, a) == b); - CHK(soa4f4_lerp(dst, a, b, v4f_set(-0.5f, 1.f, 0.5f, 4.f)) == dst); + CHK(soa4f4_lerp(dst, a, b, v4f_set(0.f, 1.f, 0.5f, 1.f)) == dst); CHECK_F4(dst, -1.f, -2.f, 0.f, 4.f, 5.f, 6.f, 0.f, -8.f, diff --git a/src/test_soa4f_utils.h b/src/test_soa4f_utils.h @@ -1,32 +0,0 @@ -/* Copyright (C) 2014-2019 Vincent Forest (vaplv@free.fr) - * - * The RSIMD library is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The RSIMD library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with the RSIMD library. If not, see <http://www.gnu.org/licenses/>. */ - -#ifndef TEST_SOA4F_UTILS_H -#define TEST_SOA4F_UTILS_H - -#define V4TRUE ~0, ~0, ~0, ~0 -#define V4FALSE 0, 0, 0, 0 -#define CHECK_V4MASK__(Mask, A, B, C, D) \ - { \ - const v4f_T mask__ = (Mask); \ - CHK(v4f_mask_x(mask__) == (A)); \ - CHK(v4f_mask_y(mask__) == (B)); \ - CHK(v4f_mask_z(mask__) == (C)); \ - CHK(v4f_mask_w(mask__) == (D)); \ - } (void)0 -#define CHECK_V4MASK(Mask, Vec) CHECK_V4MASK__(Mask, Vec) - -#endif /* TEST_SOA4F_UTILS_H */ - diff --git a/src/test_soaXf_utils.h b/src/test_soaXf_utils.h @@ -0,0 +1,48 @@ +/* Copyright (C) 2014-2019 Vincent Forest (vaplv@free.fr) + * + * The RSIMD library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The RSIMD library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the RSIMD library. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef TEST_SOAXF_UTILS_H +#define TEST_SOAXF_UTILS_H + +#define V4TRUE ~0, ~0, ~0, ~0 +#define V4FALSE 0, 0, 0, 0 +#define CHECK_V4MASK__(Mask, A, B, C, D) \ + { \ + const v4f_T mask__ = (Mask); \ + CHK(v4f_mask_x(mask__) == (A)); \ + CHK(v4f_mask_y(mask__) == (B)); \ + CHK(v4f_mask_z(mask__) == (C)); \ + CHK(v4f_mask_w(mask__) == (D)); \ + } (void)0 +#define CHECK_V4MASK(Mask, Vec) CHECK_V4MASK__(Mask, Vec) + +#define V8TRUE ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0 +#define V8FALSE 0, 0, 0, 0, 0, 0, 0, 0 +#define CHECK_V8MASK__(Mask, A, B, C, D, E, F, G, H) \ + { \ + const v8f_T mask__ = (Mask); \ + CHK(v4f_mask_x(v8f_abcd(mask__)) == (A)); \ + CHK(v4f_mask_y(v8f_abcd(mask__)) == (B)); \ + CHK(v4f_mask_z(v8f_abcd(mask__)) == (C)); \ + CHK(v4f_mask_w(v8f_abcd(mask__)) == (D)); \ + CHK(v4f_mask_x(v8f_efgh(mask__)) == (E)); \ + CHK(v4f_mask_y(v8f_efgh(mask__)) == (F)); \ + CHK(v4f_mask_z(v8f_efgh(mask__)) == (G)); \ + CHK(v4f_mask_w(v8f_efgh(mask__)) == (H)); \ + } (void)0 +#define CHECK_V8MASK(Mask, Vec) CHECK_V8MASK__(Mask, Vec) + +#endif /* TEST_SOAXF_UTILS_H */ +