Lines Matching full:vec
11 // skvx::Vec<N,T> are SIMD vectors of N T's, a v1.5 successor to SkNx<N,T>.
18 // with across translation units. skvx::Vec<N,T> always has N*sizeof(T) size
80 struct alignas(N*sizeof(T)) Vec;
83 SI Vec<sizeof...(Ix),T> shuffle(const Vec<N,T>&);
85 // All Vec have the same simple memory layout, the same as `T vec[N]`.
87 struct alignas(N*sizeof(T)) Vec { struct
91 // Methods belong here in the class declaration of Vec only if:
94 // Other operations on Vec should be defined outside the type.
96 SKVX_ALWAYS_INLINE Vec() = default;
97 SKVX_ALWAYS_INLINE Vec(T s) : lo(s), hi(s) {} in Vec() argument
99 // NOTE: Vec{x} produces x000..., whereas Vec(x) produces xxxx.... since this constructor fills
101 SKVX_ALWAYS_INLINE Vec(std::initializer_list<T> xs) { in Vec() function
106 this->lo = Vec<N/2,T>::Load(vals + 0); in Vec()
107 this->hi = Vec<N/2,T>::Load(vals + N/2); in Vec()
113 SKVX_ALWAYS_INLINE static Vec Load(const void* ptr) { in Load() argument
114 return sk_unaligned_load<Vec>(ptr); in Load()
118 memcpy(ptr, this, sizeof(Vec)); in store() argument
121 Vec<N/2,T> lo, hi; argument
127 struct alignas(4*sizeof(T)) Vec<4,T> {
130 SKVX_ALWAYS_INLINE Vec() = default;
131 SKVX_ALWAYS_INLINE Vec(T s) : lo(s), hi(s) {}
132 SKVX_ALWAYS_INLINE Vec(T x, T y, T z, T w) : lo(x,y), hi(z,w) {}
133 SKVX_ALWAYS_INLINE Vec(Vec<2,T> xy, T z, T w) : lo(xy), hi(z,w) {}
134 SKVX_ALWAYS_INLINE Vec(T x, T y, Vec<2,T> zw) : lo(x,y), hi(zw) {}
135 SKVX_ALWAYS_INLINE Vec(Vec<2,T> xy, Vec<2,T> zw) : lo(xy), hi(zw) {}
137 SKVX_ALWAYS_INLINE Vec(std::initializer_list<T> xs) {
142 this->lo = Vec<2,T>::Load(vals + 0);
143 this->hi = Vec<2,T>::Load(vals + 2);
149 SKVX_ALWAYS_INLINE static Vec Load(const void* ptr) {
150 return sk_unaligned_load<Vec>(ptr);
153 memcpy(ptr, this, sizeof(Vec));
156 SKVX_ALWAYS_INLINE Vec<2,T>& xy() { return lo; }
157 SKVX_ALWAYS_INLINE Vec<2,T>& zw() { return hi; }
163 SKVX_ALWAYS_INLINE Vec<2,T> xy() const { return lo; }
164 SKVX_ALWAYS_INLINE Vec<2,T> zw() const { return hi; }
171 SKVX_ALWAYS_INLINE Vec<4,T> yxwz() const { return shuffle<1,0,3,2>(*this); }
172 SKVX_ALWAYS_INLINE Vec<4,T> zwxy() const { return shuffle<2,3,0,1>(*this); }
174 Vec<2,T> lo, hi;
178 struct alignas(2*sizeof(T)) Vec<2,T> {
181 SKVX_ALWAYS_INLINE Vec() = default;
182 SKVX_ALWAYS_INLINE Vec(T s) : lo(s), hi(s) {}
183 SKVX_ALWAYS_INLINE Vec(T x, T y) : lo(x), hi(y) {}
185 SKVX_ALWAYS_INLINE Vec(std::initializer_list<T> xs) {
190 this->lo = Vec<1,T>::Load(vals + 0);
191 this->hi = Vec<1,T>::Load(vals + 1);
197 SKVX_ALWAYS_INLINE static Vec Load(const void* ptr) {
198 return sk_unaligned_load<Vec>(ptr);
201 memcpy(ptr, this, sizeof(Vec));
211 SKVX_ALWAYS_INLINE Vec<2,T> yx() const { return shuffle<1,0>(*this); }
212 SKVX_ALWAYS_INLINE Vec<4,T> xyxy() const { return Vec<4,T>(*this, *this); }
214 Vec<1,T> lo, hi;
218 struct Vec<1,T> {
221 SKVX_ALWAYS_INLINE Vec() = default;
222 SKVX_ALWAYS_INLINE Vec(T s) : val(s) {}
224 SKVX_ALWAYS_INLINE Vec(std::initializer_list<T> xs) : val(xs.size() ? *xs.begin() : 0) {
231 SKVX_ALWAYS_INLINE static Vec Load(const void* ptr) {
232 return sk_unaligned_load<Vec>(ptr);
235 memcpy(ptr, this, sizeof(Vec));
245 // Join two Vec<N,T> into one Vec<2N,T>.
246 SINT Vec<2*N,T> join(const Vec<N,T>& lo, const Vec<N,T>& hi) {
247 Vec<2*N,T> v;
253 // We have three strategies for implementing Vec operations:
257 // We can slot in platform-specific implementations as overloads for particular Vec<N,T>,
262 // VExt<N,T> types have the same size as Vec<N,T> and support most operations directly.
278 SI Vec<4,float> to_vec(VExt<4,float> v) { return sk_bit_cast<Vec<4,float>>(v); }
281 SINT VExt<N,T> to_vext(const Vec<N,T>& v) { return sk_bit_cast<VExt<N,T>>(v); }
282 SINT Vec <N,T> to_vec(const VExt<N,T>& v) { return sk_bit_cast<Vec <N,T>>(v); }
284 SINT Vec<N,T> operator+(const Vec<N,T>& x, const Vec<N,T>& y) {
287 SINT Vec<N,T> operator-(const Vec<N,T>& x, const Vec<N,T>& y) {
290 SINT Vec<N,T> operator*(const Vec<N,T>& x, const Vec<N,T>& y) {
293 SINT Vec<N,T> operator/(const Vec<N,T>& x, const Vec<N,T>& y) {
297 SINT Vec<N,T> operator^(const Vec<N,T>& x, const Vec<N,T>& y) {
300 SINT Vec<N,T> operator&(const Vec<N,T>& x, const Vec<N,T>& y) {
303 SINT Vec<N,T> operator|(const Vec<N,T>& x, const Vec<N,T>& y) {
307 SINT Vec<N,T> operator!(const Vec<N,T>& x) { return to_vec<N,T>(!to_vext(x)); }
308 SINT Vec<N,T> operator-(const Vec<N,T>& x) { return to_vec<N,T>(-to_vext(x)); }
309 SINT Vec<N,T> operator~(const Vec<N,T>& x) { return to_vec<N,T>(~to_vext(x)); }
311 SINT Vec<N,T> operator<<(const Vec<N,T>& x, int k) { return to_vec<N,T>(to_vext(x) << k); }
312 SINT Vec<N,T> operator>>(const Vec<N,T>& x, int k) { return to_vec<N,T>(to_vext(x) >> k); }
314 SINT Vec<N,M<T>> operator==(const Vec<N,T>& x, const Vec<N,T>& y) {
315 return sk_bit_cast<Vec<N,M<T>>>(to_vext(x) == to_vext(y));
317 SINT Vec<N,M<T>> operator!=(const Vec<N,T>& x, const Vec<N,T>& y) {
318 return sk_bit_cast<Vec<N,M<T>>>(to_vext(x) != to_vext(y));
320 SINT Vec<N,M<T>> operator<=(const Vec<N,T>& x, const Vec<N,T>& y) {
321 return sk_bit_cast<Vec<N,M<T>>>(to_vext(x) <= to_vext(y));
323 SINT Vec<N,M<T>> operator>=(const Vec<N,T>& x, const Vec<N,T>& y) {
324 return sk_bit_cast<Vec<N,M<T>>>(to_vext(x) >= to_vext(y));
326 SINT Vec<N,M<T>> operator< (const Vec<N,T>& x, const Vec<N,T>& y) {
327 return sk_bit_cast<Vec<N,M<T>>>(to_vext(x) < to_vext(y));
329 SINT Vec<N,M<T>> operator> (const Vec<N,T>& x, const Vec<N,T>& y) {
330 return sk_bit_cast<Vec<N,M<T>>>(to_vext(x) > to_vext(y));
339 SIT Vec<1,T> operator+(const Vec<1,T>& x, const Vec<1,T>& y) { return x.val + y.val; }
340 SIT Vec<1,T> operator-(const Vec<1,T>& x, const Vec<1,T>& y) { return x.val - y.val; }
341 SIT Vec<1,T> operator*(const Vec<1,T>& x, const Vec<1,T>& y) { return x.val * y.val; }
342 SIT Vec<1,T> operator/(const Vec<1,T>& x, const Vec<1,T>& y) { return x.val / y.val; }
344 SIT Vec<1,T> operator^(const Vec<1,T>& x, const Vec<1,T>& y) { return x.val ^ y.val; }
345 SIT Vec<1,T> operator&(const Vec<1,T>& x, const Vec<1,T>& y) { return x.val & y.val; }
346 SIT Vec<1,T> operator|(const Vec<1,T>& x, const Vec<1,T>& y) { return x.val | y.val; }
348 SIT Vec<1,T> operator!(const Vec<1,T>& x) { return !x.val; }
349 SIT Vec<1,T> operator-(const Vec<1,T>& x) { return -x.val; }
350 SIT Vec<1,T> operator~(const Vec<1,T>& x) { return ~x.val; }
352 SIT Vec<1,T> operator<<(const Vec<1,T>& x, int k) { return x.val << k; }
353 SIT Vec<1,T> operator>>(const Vec<1,T>& x, int k) { return x.val >> k; }
355 SIT Vec<1,M<T>> operator==(const Vec<1,T>& x, const Vec<1,T>& y) {
358 SIT Vec<1,M<T>> operator!=(const Vec<1,T>& x, const Vec<1,T>& y) {
361 SIT Vec<1,M<T>> operator<=(const Vec<1,T>& x, const Vec<1,T>& y) {
364 SIT Vec<1,M<T>> operator>=(const Vec<1,T>& x, const Vec<1,T>& y) {
367 SIT Vec<1,M<T>> operator< (const Vec<1,T>& x, const Vec<1,T>& y) {
370 SIT Vec<1,M<T>> operator> (const Vec<1,T>& x, const Vec<1,T>& y) {
375 SINT Vec<N,T> operator+(const Vec<N,T>& x, const Vec<N,T>& y) {
378 SINT Vec<N,T> operator-(const Vec<N,T>& x, const Vec<N,T>& y) {
381 SINT Vec<N,T> operator*(const Vec<N,T>& x, const Vec<N,T>& y) {
384 SINT Vec<N,T> operator/(const Vec<N,T>& x, const Vec<N,T>& y) {
388 SINT Vec<N,T> operator^(const Vec<N,T>& x, const Vec<N,T>& y) {
391 SINT Vec<N,T> operator&(const Vec<N,T>& x, const Vec<N,T>& y) {
394 SINT Vec<N,T> operator|(const Vec<N,T>& x, const Vec<N,T>& y) {
398 SINT Vec<N,T> operator!(const Vec<N,T>& x) { return join(!x.lo, !x.hi); }
399 SINT Vec<N,T> operator-(const Vec<N,T>& x) { return join(-x.lo, -x.hi); }
400 SINT Vec<N,T> operator~(const Vec<N,T>& x) { return join(~x.lo, ~x.hi); }
402 SINT Vec<N,T> operator<<(const Vec<N,T>& x, int k) { return join(x.lo << k, x.hi << k); }
403 SINT Vec<N,T> operator>>(const Vec<N,T>& x, int k) { return join(x.lo >> k, x.hi >> k); }
405 SINT Vec<N,M<T>> operator==(const Vec<N,T>& x, const Vec<N,T>& y) {
408 SINT Vec<N,M<T>> operator!=(const Vec<N,T>& x, const Vec<N,T>& y) {
411 SINT Vec<N,M<T>> operator<=(const Vec<N,T>& x, const Vec<N,T>& y) {
414 SINT Vec<N,M<T>> operator>=(const Vec<N,T>& x, const Vec<N,T>& y) {
417 SINT Vec<N,M<T>> operator< (const Vec<N,T>& x, const Vec<N,T>& y) {
420 SINT Vec<N,M<T>> operator> (const Vec<N,T>& x, const Vec<N,T>& y) {
426 SINTU Vec<N,T> operator+ (U x, const Vec<N,T>& y) { return Vec<N,T>(x) + y; }
427 SINTU Vec<N,T> operator- (U x, const Vec<N,T>& y) { return Vec<N,T>(x) - y; }
428 SINTU Vec<N,T> operator* (U x, const Vec<N,T>& y) { return Vec<N,T>(x) * y; }
429 SINTU Vec<N,T> operator/ (U x, const Vec<N,T>& y) { return Vec<N,T>(x) / y; }
430 SINTU Vec<N,T> operator^ (U x, const Vec<N,T>& y) { return Vec<N,T>(x) ^ y; }
431 SINTU Vec<N,T> operator& (U x, const Vec<N,T>& y) { return Vec<N,T>(x) & y; }
432 SINTU Vec<N,T> operator| (U x, const Vec<N,T>& y) { return Vec<N,T>(x) | y; }
433 SINTU Vec<N,M<T>> operator==(U x, const Vec<N,T>& y) { return Vec<N,T>(x) == y; }
434 SINTU Vec<N,M<T>> operator!=(U x, const Vec<N,T>& y) { return Vec<N,T>(x) != y; }
435 SINTU Vec<N,M<T>> operator<=(U x, const Vec<N,T>& y) { return Vec<N,T>(x) <= y; }
436 SINTU Vec<N,M<T>> operator>=(U x, const Vec<N,T>& y) { return Vec<N,T>(x) >= y; }
437 SINTU Vec<N,M<T>> operator< (U x, const Vec<N,T>& y) { return Vec<N,T>(x) < y; }
438 SINTU Vec<N,M<T>> operator> (U x, const Vec<N,T>& y) { return Vec<N,T>(x) > y; }
440 SINTU Vec<N,T> operator+ (const Vec<N,T>& x, U y) { return x + Vec<N,T>(y); }
441 SINTU Vec<N,T> operator- (const Vec<N,T>& x, U y) { return x - Vec<N,T>(y); }
442 SINTU Vec<N,T> operator* (const Vec<N,T>& x, U y) { return x * Vec<N,T>(y); }
443 SINTU Vec<N,T> operator/ (const Vec<N,T>& x, U y) { return x / Vec<N,T>(y); }
444 SINTU Vec<N,T> operator^ (const Vec<N,T>& x, U y) { return x ^ Vec<N,T>(y); }
445 SINTU Vec<N,T> operator& (const Vec<N,T>& x, U y) { return x & Vec<N,T>(y); }
446 SINTU Vec<N,T> operator| (const Vec<N,T>& x, U y) { return x | Vec<N,T>(y); }
447 SINTU Vec<N,M<T>> operator==(const Vec<N,T>& x, U y) { return x == Vec<N,T>(y); }
448 SINTU Vec<N,M<T>> operator!=(const Vec<N,T>& x, U y) { return x != Vec<N,T>(y); }
449 SINTU Vec<N,M<T>> operator<=(const Vec<N,T>& x, U y) { return x <= Vec<N,T>(y); }
450 SINTU Vec<N,M<T>> operator>=(const Vec<N,T>& x, U y) { return x >= Vec<N,T>(y); }
451 SINTU Vec<N,M<T>> operator< (const Vec<N,T>& x, U y) { return x < Vec<N,T>(y); }
452 SINTU Vec<N,M<T>> operator> (const Vec<N,T>& x, U y) { return x > Vec<N,T>(y); }
454 SINT Vec<N,T>& operator+=(Vec<N,T>& x, const Vec<N,T>& y) { return (x = x + y); }
455 SINT Vec<N,T>& operator-=(Vec<N,T>& x, const Vec<N,T>& y) { return (x = x - y); }
456 SINT Vec<N,T>& operator*=(Vec<N,T>& x, const Vec<N,T>& y) { return (x = x * y); }
457 SINT Vec<N,T>& operator/=(Vec<N,T>& x, const Vec<N,T>& y) { return (x = x / y); }
458 SINT Vec<N,T>& operator^=(Vec<N,T>& x, const Vec<N,T>& y) { return (x = x ^ y); }
459 SINT Vec<N,T>& operator&=(Vec<N,T>& x, const Vec<N,T>& y) { return (x = x & y); }
460 SINT Vec<N,T>& operator|=(Vec<N,T>& x, const Vec<N,T>& y) { return (x = x | y); }
462 SINTU Vec<N,T>& operator+=(Vec<N,T>& x, U y) { return (x = x + Vec<N,T>(y)); }
463 SINTU Vec<N,T>& operator-=(Vec<N,T>& x, U y) { return (x = x - Vec<N,T>(y)); }
464 SINTU Vec<N,T>& operator*=(Vec<N,T>& x, U y) { return (x = x * Vec<N,T>(y)); }
465 SINTU Vec<N,T>& operator/=(Vec<N,T>& x, U y) { return (x = x / Vec<N,T>(y)); }
466 SINTU Vec<N,T>& operator^=(Vec<N,T>& x, U y) { return (x = x ^ Vec<N,T>(y)); }
467 SINTU Vec<N,T>& operator&=(Vec<N,T>& x, U y) { return (x = x & Vec<N,T>(y)); }
468 SINTU Vec<N,T>& operator|=(Vec<N,T>& x, U y) { return (x = x | Vec<N,T>(y)); }
470 SINT Vec<N,T>& operator<<=(Vec<N,T>& x, int bits) { return (x = x << bits); }
471 SINT Vec<N,T>& operator>>=(Vec<N,T>& x, int bits) { return (x = x >> bits); }
478 SINT Vec<N,T> naive_if_then_else(const Vec<N,M<T>>& cond, const Vec<N,T>& t, const Vec<N,T>& e) {
479 return sk_bit_cast<Vec<N,T>>(( cond & sk_bit_cast<Vec<N, M<T>>>(t)) |
480 (~cond & sk_bit_cast<Vec<N, M<T>>>(e)) );
483 SIT Vec<1,T> if_then_else(const Vec<1,M<T>>& cond, const Vec<1,T>& t, const Vec<1,T>& e) {
485 return sk_bit_cast<Vec<1,T>>(( cond & sk_bit_cast<Vec<1, M<T>>>(t)) |
486 (~cond & sk_bit_cast<Vec<1, M<T>>>(e)) );
488 SINT Vec<N,T> if_then_else(const Vec<N,M<T>>& cond, const Vec<N,T>& t, const Vec<N,T>& e) {
492 return sk_bit_cast<Vec<N,T>>(_mm256_blendv_epi8(sk_bit_cast<__m256i>(e),
499 return sk_bit_cast<Vec<N,T>>(_mm_blendv_epi8(sk_bit_cast<__m128i>(e),
506 return sk_bit_cast<Vec<N,T>>(vbslq_u8(sk_bit_cast<uint8x16_t>(cond),
513 return sk_bit_cast<Vec<N,T>>(__lasx_xvbitsel_v(sk_bit_cast<__m256i>(e),
520 return sk_bit_cast<Vec<N,T>>(__lsx_vbitsel_v(sk_bit_cast<__m128i>(e),
534 SIT bool any(const Vec<1,T>& x) { return x.val != 0; }
535 SINT bool any(const Vec<N,T>& x) {
551 // directly from a comparison op (which sets all bits to 1 when true), but skvx::Vec<>
586 SIT bool all(const Vec<1,T>& x) { return x.val != 0; }
587 SINT bool all(const Vec<N,T>& x) {
629 // cast() Vec<N,S> to Vec<N,D>, as if applying a C-cast to each lane.
632 SI Vec<1,D> cast(const Vec<1,S>& src) { return (D)src.val; }
635 SI Vec<N,D> cast(const Vec<N,S>& src) {
644 SIT T min(const Vec<1,T>& x) { return x.val; }
645 SIT T max(const Vec<1,T>& x) { return x.val; }
646 SINT T min(const Vec<N,T>& x) { return std::min(min(x.lo), min(x.hi)); }
647 SINT T max(const Vec<N,T>& x) { return std::max(max(x.lo), max(x.hi)); }
649 SINT Vec<N,T> min(const Vec<N,T>& x, const Vec<N,T>& y) { return naive_if_then_else(y < x, y, x); }
650 SINT Vec<N,T> max(const Vec<N,T>& x, const Vec<N,T>& y) { return naive_if_then_else(x < y, y, x); }
652 SINTU Vec<N,T> min(const Vec<N,T>& x, U y) { return min(x, Vec<N,T>(y)); }
653 SINTU Vec<N,T> max(const Vec<N,T>& x, U y) { return max(x, Vec<N,T>(y)); }
654 SINTU Vec<N,T> min(U x, const Vec<N,T>& y) { return min(Vec<N,T>(x), y); }
655 SINTU Vec<N,T> max(U x, const Vec<N,T>& y) { return max(Vec<N,T>(x), y); }
659 SINT Vec<N,T> pin(const Vec<N,T>& x, const Vec<N,T>& lo, const Vec<N,T>& hi) {
664 // skvx::Vec<4,float> rgba = {R,G,B,A};
669 // The only real restriction is that the output also be a legal N=power-of-two sknx::Vec.
671 SI Vec<sizeof...(Ix),T> shuffle(const Vec<N,T>& x) {
685 Fn&& fn, const Args&... args) -> skvx::Vec<sizeof...(I), decltype(fn(args[0]...))> {
701 auto map(Fn&& fn, const Vec<N,T>& first, const Rest&... rest) {
706 SIN Vec<N,float> ceil(const Vec<N,float>& x) { return map( ceilf, x); }
707 SIN Vec<N,float> floor(const Vec<N,float>& x) { return map(floorf, x); }
708 SIN Vec<N,float> trunc(const Vec<N,float>& x) { return map(truncf, x); }
709 SIN Vec<N,float> round(const Vec<N,float>& x) { return map(roundf, x); }
710 SIN Vec<N,float> sqrt(const Vec<N,float>& x) { return map( sqrtf, x); }
711 SIN Vec<N,float> abs(const Vec<N,float>& x) { return map( fabsf, x); }
712 SIN Vec<N,float> fma(const Vec<N,float>& x,
713 const Vec<N,float>& y,
714 const Vec<N,float>& z) {
720 SI Vec<1,int> lrint(const Vec<1,float>& x) {
723 SIN Vec<N,int> lrint(const Vec<N,float>& x) {
726 return sk_bit_cast<Vec<N,int>>(_mm256_cvtps_epi32(sk_bit_cast<__m256>(x)));
731 return sk_bit_cast<Vec<N,int>>(_mm_cvtps_epi32(sk_bit_cast<__m128>(x)));
736 return sk_bit_cast<Vec<N,int>>(__lasx_xvftint_w_s(sk_bit_cast<__m256>(x)));
741 return sk_bit_cast<Vec<N,int>>(__lsx_vftint_w_s(sk_bit_cast<__m128>(x)));
748 SIN Vec<N,float> fract(const Vec<N,float>& x) { return x - floor(x); }
754 SIN Vec<N,uint16_t> to_half(const Vec<N,float>& x) {
767 return sk_bit_cast<Vec<N,uint16_t>>(vcvt_f16_f32(sk_bit_cast<float32x4_t>(x)));
772 #define I(x) sk_bit_cast<Vec<N,int32_t>>(x)
773 #define F(x) sk_bit_cast<Vec<N,float>>(x)
774 Vec<N,int32_t> sem = I(x),
794 SIN Vec<N,float> from_half(const Vec<N,uint16_t>& x) {
802 return sk_bit_cast<Vec<N,float>>(vcvt_f32_f16(sk_bit_cast<float16x4_t>(x)));
806 Vec<N,int32_t> wide = cast<int32_t>(x),
812 sub = sk_bit_cast<Vec<N,int32_t>>((cast<float>(em) * (1.f/(1<<24)))),
818 return sk_bit_cast<Vec<N,float>>((s<<16) | finite | inf_or_nan);
822 SIN Vec<N,uint8_t> div255(const Vec<N,uint16_t>& x) {
828 SIN Vec<N,uint8_t> approx_scale(const Vec<N,uint8_t>& x, const Vec<N,uint8_t>& y) {
837 SINT std::enable_if_t<std::is_unsigned_v<T>, Vec<N,T>> saturated_add(const Vec<N,T>& x,
838 const Vec<N,T>& y) {
845 return sk_bit_cast<Vec<N,T>>(_mm_adds_epu8(sk_bit_cast<__m128i>(x),
848 return sk_bit_cast<Vec<N,T>>(__lsx_vsadd_bu(sk_bit_cast<__m128i>(x),
851 return sk_bit_cast<Vec<N,T>>(vqaddq_u8(sk_bit_cast<uint8x16_t>(x),
862 return if_then_else(sum < x, Vec<N,T>(std::numeric_limits<T>::max()), sum);
891 Vec<4, uint32_t> divide(const Vec<4, uint32_t>& numerator) const {
911 SIN Vec<N,uint16_t> mull(const Vec<N,uint8_t>& x,
912 const Vec<N,uint8_t>& y) {
927 SIN Vec<N,uint32_t> mull(const Vec<N,uint16_t>& x,
928 const Vec<N,uint16_t>& y) {
943 SIN Vec<N,uint16_t> mulhi(const Vec<N,uint16_t>& x,
944 const Vec<N,uint16_t>& y) {
948 return sk_bit_cast<Vec<8,uint16_t>>(_mm_mulhi_epu16(sk_bit_cast<__m128i>(x),
957 return sk_bit_cast<Vec<8,uint16_t>>(__lsx_vmuh_hu(sk_bit_cast<__m128i>(x),
969 SINT T dot(const Vec<N, T>& a, const Vec<N, T>& b) {
987 SIT T cross(const Vec<2, T>& a, const Vec<2, T>& b) {
992 SIN float length(const Vec<N, float>& v) {
996 SIN double length(const Vec<N, double>& v) {
1000 SIN Vec<N, float> normalize(const Vec<N, float>& v) {
1004 SIN Vec<N, double> normalize(const Vec<N, double>& v) {
1008 SINT bool isfinite(const Vec<N, T>& v) {
1011 return SkIsFinite(dot(v, Vec<N, T>(0)));
1019 Vec<1,T>& a,
1020 Vec<1,T>& b,
1021 Vec<1,T>& c,
1022 Vec<1,T>& d) {
1029 Vec<N,T>& a,
1030 Vec<N,T>& b,
1031 Vec<N,T>& c,
1032 Vec<N,T>& d) {
1039 Vec<N,T>& a, \
1040 Vec<N,T>& b, \
1041 Vec<N,T>& c, \
1042 Vec<N,T>& d) { \
1044 a = sk_bit_cast<Vec<N,T>>(mat.val[0]); \
1045 b = sk_bit_cast<Vec<N,T>>(mat.val[1]); \
1046 c = sk_bit_cast<Vec<N,T>>(mat.val[2]); \
1047 d = sk_bit_cast<Vec<N,T>>(mat.val[3]); \
1068 Vec<4,float>& a,
1069 Vec<4,float>& b,
1070 Vec<4,float>& c,
1071 Vec<4,float>& d) {
1077 a = sk_bit_cast<Vec<4,float>>(a_);
1078 b = sk_bit_cast<Vec<4,float>>(b_);
1079 c = sk_bit_cast<Vec<4,float>>(c_);
1080 d = sk_bit_cast<Vec<4,float>>(d_);
1097 Vec<4,int>& a,
1098 Vec<4,int>& b,
1099 Vec<4,int>& c,
1100 Vec<4,int>& d) {
1106 a = sk_bit_cast<Vec<4,int>>(a_);
1107 b = sk_bit_cast<Vec<4,int>>(b_);
1108 c = sk_bit_cast<Vec<4,int>>(c_);
1109 d = sk_bit_cast<Vec<4,int>>(d_);
1117 SIT void strided_load2(const T* v, Vec<1,T>& a, Vec<1,T>& b) {
1121 SINT void strided_load2(const T* v, Vec<N,T>& a, Vec<N,T>& b) {
1127 SI void strided_load2(const T* v, Vec<N,T>& a, Vec<N,T>& b) { \
1129 a = sk_bit_cast<Vec<N,T>>(mat.val[0]); \
1130 b = sk_bit_cast<Vec<N,T>>(mat.val[1]); \
1150 using float2 = Vec< 2, float>;
1151 using float4 = Vec< 4, float>;
1152 using float8 = Vec< 8, float>;
1154 using double2 = Vec< 2, double>;
1155 using double4 = Vec< 4, double>;
1156 using double8 = Vec< 8, double>;
1158 using byte2 = Vec< 2, uint8_t>;
1159 using byte4 = Vec< 4, uint8_t>;
1160 using byte8 = Vec< 8, uint8_t>;
1161 using byte16 = Vec<16, uint8_t>;
1163 using int2 = Vec< 2, int32_t>;
1164 using int4 = Vec< 4, int32_t>;
1165 using int8 = Vec< 8, int32_t>;
1167 using ushort2 = Vec< 2, uint16_t>;
1168 using ushort4 = Vec< 4, uint16_t>;
1169 using ushort8 = Vec< 8, uint16_t>;
1171 using uint2 = Vec< 2, uint32_t>;
1172 using uint4 = Vec< 4, uint32_t>;
1173 using uint8 = Vec< 8, uint32_t>;
1175 using long2 = Vec< 2, int64_t>;
1176 using long4 = Vec< 4, int64_t>;
1177 using long8 = Vec< 8, int64_t>;
1180 using half2 = Vec< 2, uint16_t>;
1181 using half4 = Vec< 4, uint16_t>;
1182 using half8 = Vec< 8, uint16_t>;