Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkVxTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2019 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9#include "src/base/SkRandom.h"
10#include "src/base/SkUtils.h"
11#include "src/base/SkVx.h"
12#include "tests/Test.h"
13
14#include <numeric>
15
16namespace skvx {
17
18DEF_TEST(SkVx, r) {
19 static_assert(sizeof(float2) == 8, "");
20 static_assert(sizeof(float4) == 16, "");
21 static_assert(sizeof(float8) == 32, "");
22
23 static_assert(sizeof(byte2) == 2, "");
24 static_assert(sizeof(byte4) == 4, "");
25 static_assert(sizeof(byte8) == 8, "");
26
27 {
28 int4 mask = float4{1,2,3,4} < float4{1,2,4,8};
29 REPORTER_ASSERT(r, mask[0] == int32_t( 0));
30 REPORTER_ASSERT(r, mask[1] == int32_t( 0));
31 REPORTER_ASSERT(r, mask[2] == int32_t(-1));
32 REPORTER_ASSERT(r, mask[3] == int32_t(-1));
33
34 REPORTER_ASSERT(r, any(mask));
35 REPORTER_ASSERT(r, !all(mask));
36 }
37
38 {
39 long4 mask = double4{1,2,3,4} < double4{1,2,4,8};
40 REPORTER_ASSERT(r, mask[0] == int64_t( 0));
41 REPORTER_ASSERT(r, mask[1] == int64_t( 0));
42 REPORTER_ASSERT(r, mask[2] == int64_t(-1));
43 REPORTER_ASSERT(r, mask[3] == int64_t(-1));
44
45 REPORTER_ASSERT(r, any(mask));
46 REPORTER_ASSERT(r, !all(mask));
47 }
48
49 {
50 // Tests that any/all work with non-zero values, not just full bit lanes.
51 REPORTER_ASSERT(r, all(int4{1,2,3,4}));
52 REPORTER_ASSERT(r, !all(int4{1,2,3}));
53 REPORTER_ASSERT(r, any(int4{1,2}));
54 REPORTER_ASSERT(r, !any(int4{}));
55 }
56
57 REPORTER_ASSERT(r, min(float4{1,2,3,4}) == 1);
58 REPORTER_ASSERT(r, max(float4{1,2,3,4}) == 4);
59
60 REPORTER_ASSERT(r, all(int4{1,2,3,4} == int4{1,2,3,4}));
61 REPORTER_ASSERT(r, all(int4{1,2,3} == int4{1,2,3,0}));
62 REPORTER_ASSERT(r, all(int4{1,2} == int4{1,2,0,0}));
63 REPORTER_ASSERT(r, all(int4{1} == int4{1,0,0,0}));
64 REPORTER_ASSERT(r, all(int4(1) == int4{1,1,1,1}));
65 REPORTER_ASSERT(r, all(int4{} == int4{0,0,0,0}));
66 REPORTER_ASSERT(r, all(int4() == int4{0,0,0,0}));
67
68 REPORTER_ASSERT(r, all(int4{1,2,2,1} == min(int4{1,2,3,4}, int4{4,3,2,1})));
69 REPORTER_ASSERT(r, all(int4{4,3,3,4} == max(int4{1,2,3,4}, int4{4,3,2,1})));
70
71 REPORTER_ASSERT(r, all(if_then_else(float4{1,2,3,2} <= float4{2,2,2,2}, float4(42), float4(47))
72 == float4{42,42,47,42}));
73
74 REPORTER_ASSERT(r, all(floor(float4{-1.5f,1.5f,1.0f,-1.0f}) == float4{-2.0f,1.0f,1.0f,-1.0f}));
75 REPORTER_ASSERT(r, all( ceil(float4{-1.5f,1.5f,1.0f,-1.0f}) == float4{-1.0f,2.0f,1.0f,-1.0f}));
76 REPORTER_ASSERT(r, all(trunc(float4{-1.5f,1.5f,1.0f,-1.0f}) == float4{-1.0f,1.0f,1.0f,-1.0f}));
77 REPORTER_ASSERT(r, all(round(float4{-1.5f,1.5f,1.0f,-1.0f}) == float4{-2.0f,2.0f,1.0f,-1.0f}));
78
79
80 REPORTER_ASSERT(r, all(abs(float4{-2,-1,0,1}) == float4{2,1,0,1}));
81
82 // TODO(mtklein): these tests could be made less loose.
83 REPORTER_ASSERT(r, all( sqrt(float4{2,3,4,5}) < float4{2,2,3,3}));
84 REPORTER_ASSERT(r, all( sqrt(float2{2,3}) < float2{2,2}));
85
86 REPORTER_ASSERT(r, all(cast<int>(float4{-1.5f,0.5f,1.0f,1.5f}) == int4{-1,0,1,1}));
87
88 float buf[] = {1,2,3,4,5,6};
89 REPORTER_ASSERT(r, all(float4::Load(buf) == float4{1,2,3,4}));
90 float4{2,3,4,5}.store(buf);
91 REPORTER_ASSERT(r, buf[0] == 2
92 && buf[1] == 3
93 && buf[2] == 4
94 && buf[3] == 5
95 && buf[4] == 5
96 && buf[5] == 6);
97 REPORTER_ASSERT(r, all(float4::Load(buf+0) == float4{2,3,4,5}));
98 REPORTER_ASSERT(r, all(float4::Load(buf+2) == float4{4,5,5,6}));
99
100 REPORTER_ASSERT(r, all(shuffle<2,1,0,3> (float4{1,2,3,4}) == float4{3,2,1,4}));
101 REPORTER_ASSERT(r, all(shuffle<2,1> (float4{1,2,3,4}) == float2{3,2}));
102 REPORTER_ASSERT(r, all(shuffle<3,3,3,3> (float4{1,2,3,4}) == float4{4,4,4,4}));
103 REPORTER_ASSERT(r, all(shuffle<2,1,2,1,2,1,2,1>(float4{1,2,3,4})
104 == float8{3,2,3,2,3,2,3,2}));
105
106 // Test that mixed types can be used where they make sense. Mostly about ergonomics.
107 REPORTER_ASSERT(r, all(float4{1,2,3,4} < 5));
108 REPORTER_ASSERT(r, all( byte4{1,2,3,4} < 5));
109 REPORTER_ASSERT(r, all( int4{1,2,3,4} < 5.0f));
110 float4 five = 5;
111 REPORTER_ASSERT(r, all(five == 5.0f));
112 REPORTER_ASSERT(r, all(five == 5));
113
114 REPORTER_ASSERT(r, all(max(2, min(float4{1,2,3,4}, 3)) == float4{2,2,3,3}));
115
116 for (int x = 0; x < 256; x++)
117 for (int y = 0; y < 256; y++) {
118 uint8_t want = (uint8_t)( 255*(x/255.0 * y/255.0) + 0.5 );
119
120 {
121 uint8_t got = div255(Vec<8, uint16_t>(x) * Vec<8, uint16_t>(y) )[0];
122 REPORTER_ASSERT(r, got == want);
123 }
124
125 {
126 uint8_t got = approx_scale(Vec<8,uint8_t>(x), Vec<8,uint8_t>(y))[0];
127
128 REPORTER_ASSERT(r, got == want-1 ||
129 got == want ||
130 got == want+1);
131 if (x == 0 || y == 0 || x == 255 || y == 255) {
132 REPORTER_ASSERT(r, got == want);
133 }
134 }
135 }
136
137 for (int x = 0; x < 256; x++)
138 for (int y = 0; y < 256; y++) {
139 uint16_t xy = x*y;
140
141 // Make sure to cover implementation cases N=8, N<8, and N>8.
142 REPORTER_ASSERT(r, all(mull(byte2 (x), byte2 (y)) == xy));
143 REPORTER_ASSERT(r, all(mull(byte4 (x), byte4 (y)) == xy));
144 REPORTER_ASSERT(r, all(mull(byte8 (x), byte8 (y)) == xy));
145 REPORTER_ASSERT(r, all(mull(byte16(x), byte16(y)) == xy));
146 }
147
148 {
149 // Intentionally not testing -0, as we don't care if it's 0x0000 or 0x8000.
150 float8 fs = {+0.0f,+0.5f,+1.0f,+2.0f,
151 -4.0f,-0.5f,-1.0f,-2.0f};
152 Vec<8,uint16_t> hs = {0x0000,0x3800,0x3c00,0x4000,
153 0xc400,0xb800,0xbc00,0xc000};
154 REPORTER_ASSERT(r, all( to_half(fs) == hs));
155 REPORTER_ASSERT(r, all(from_half(hs) == fs));
156 }
157}
158
159DEF_TEST(SkVx_xy, r) {
160 float2 f = float2(1,2);
161 REPORTER_ASSERT(r, all(f == float2{1,2}));
162 REPORTER_ASSERT(r, f.x() == 1);
163 REPORTER_ASSERT(r, f.y() == 2);
164 f.y() = 9;
165 REPORTER_ASSERT(r, all(f == float2{1,9}));
166 f.x() = 0;
167 REPORTER_ASSERT(r, all(f == float2(0,9)));
168 f[0] = 8;
169 REPORTER_ASSERT(r, f.x() == 8);
170 f[1] = 6;
171 REPORTER_ASSERT(r, f.y() == 6);
172 REPORTER_ASSERT(r, all(f == float2(8,6)));
173 f = f.yx();
174 REPORTER_ASSERT(r, all(f == float2(6,8)));
175 REPORTER_ASSERT(r, sk_bit_cast<SkPoint>(f) == SkPoint::Make(6,8));
176 SkPoint p;
177 f.store(&p);
178 REPORTER_ASSERT(r, p == SkPoint::Make(6,8));
179 f.yx().store(&p);
180 REPORTER_ASSERT(r, p == SkPoint::Make(8,6));
181 REPORTER_ASSERT(r, all(f.xyxy() == float4(6,8,6,8)));
182 REPORTER_ASSERT(r, all(f.xyxy() == float4(f,f)));
183 REPORTER_ASSERT(r, all(join(f,f) == f.xyxy()));
184 REPORTER_ASSERT(r, all(join(f.yx(),f) == float4(f.y(),f.x(),f)));
185 REPORTER_ASSERT(r, all(join(f.yx(),f) == float4(f.yx(),f.x(),f.y())));
186 REPORTER_ASSERT(r, all(join(f,f.yx()) == float4(f.x(),f.y(),f.yx())));
187 REPORTER_ASSERT(r, all(join(f.yx(),f.yx()) == float4(f.yx(),f.yx())));
188}
189
190DEF_TEST(SkVx_xyzw, r) {
191 float4 f = float4{1,2,3,4};
192 REPORTER_ASSERT(r, all(f == float4(1,2,3,4)));
193 REPORTER_ASSERT(r, all(f == float4(1,2,float2(3,4))));
194 REPORTER_ASSERT(r, all(f == float4(float2(1,2),3,4)));
195 REPORTER_ASSERT(r, all(f == float4(float2(1,2),float2(3,4))));
196 f.xy() = float2(9,8);
197 REPORTER_ASSERT(r, all(f == float4(9,8,3,4)));
198 f.zw().x() = 7;
199 f.zw().y() = 6;
200 REPORTER_ASSERT(r, all(f == float4(9,8,7,6)));
201 f.x() = 5;
202 f.y() = 4;
203 f.z() = 3;
204 f.w() = 2;
205 REPORTER_ASSERT(r, all(f == float4(5,4,3,2)));
206 f[0] = 0;
207 REPORTER_ASSERT(r, f.x() == 0);
208 f[1] = 1;
209 REPORTER_ASSERT(r, f.y() == 1);
210 f[2] = 2;
211 REPORTER_ASSERT(r, f.z() == 2);
212 f[3] = 3;
213 REPORTER_ASSERT(r, f.w() == 3);
214 REPORTER_ASSERT(r, all(f.xy() == float2(0,1)));
215 REPORTER_ASSERT(r, all(f.zw() == float2{2,3}));
216 REPORTER_ASSERT(r, all(f == float4(0,1,2,3)));
217 REPORTER_ASSERT(r, all(f.yxwz().lo == shuffle<1,0>(f)));
218 REPORTER_ASSERT(r, all(f.yxwz().hi == shuffle<3,2>(f)));
219 REPORTER_ASSERT(r, all(f.zwxy().lo.lo == f.z()));
220 REPORTER_ASSERT(r, all(f.zwxy().lo.hi == f.w()));
221 REPORTER_ASSERT(r, all(f.zwxy().hi.lo == f.x()));
222 REPORTER_ASSERT(r, all(f.zwxy().hi.hi == f.y()));
223 REPORTER_ASSERT(r, f.yxwz().lo.lo.val == f.y());
224 REPORTER_ASSERT(r, f.yxwz().lo.hi.val == f.x());
225 REPORTER_ASSERT(r, f.yxwz().hi.lo.val == f.w());
226 REPORTER_ASSERT(r, f.yxwz().hi.hi.val == f.z());
227
229 shuffle<3,2>(float4(0,1,2,3)),
230 float4(4,5,6,7).xy()) == float2(4,2)));
232 shuffle<3,2>(float4(0,1,2,3)),
233 float4(4,5,6,7).xy()) == float2(4,2)));
235 float4(0,1,2,3).zwxy(),
236 float4(4,5,6,7)) == float4(4,3,6,1)));
237 REPORTER_ASSERT(r, all(if_then_else(int2(0,~0).xyxy(),
238 float4(0,1,2,3).zwxy(),
239 float4(4,5,6,7)) == float4(4,3,6,1)));
240
241 REPORTER_ASSERT(r, all(pin(float4(0,1,2,3).yxwz(),
242 float2(1).xyxy(),
243 float2(2).xyxy()) == float4(1,1,2,2)));
244}
245
246DEF_TEST(SkVx_cross_dot, r) {
247 REPORTER_ASSERT(r, cross(int2{0,1}, int2{0,1}) == 0);
248 REPORTER_ASSERT(r, cross(int2{1,0}, int2{1,0}) == 0);
249 REPORTER_ASSERT(r, cross(int2{1,1}, int2{1,1}) == 0);
250 REPORTER_ASSERT(r, cross(int2{1,1}, int2{1,-1}) == -2);
251 REPORTER_ASSERT(r, cross(int2{1,1}, int2{-1,1}) == 2);
252
253 REPORTER_ASSERT(r, dot(int2{0,1}, int2{1,0}) == 0);
254 REPORTER_ASSERT(r, dot(int2{1,0}, int2{0,1}) == 0);
255 REPORTER_ASSERT(r, dot(int2{1,1}, int2{1,-1}) == 0);
256 REPORTER_ASSERT(r, dot(int2{1,1}, int2{1,1}) == 2);
257 REPORTER_ASSERT(r, dot(int2{1,1}, int2{-1,-1}) == -2);
258
259 SkRandom rand;
260 for (int i = 0; i < 100; ++i) {
261 float a=rand.nextRangeF(-1,1), b=rand.nextRangeF(-1,1), c=rand.nextRangeF(-1,1),
262 d=rand.nextRangeF(-1,1);
263 constexpr static float kTolerance = 1.f / (1 << 20);
267 dot(float2{a,b}, float2{c,d}), SkPoint::DotProduct({a,b}, {c,d}), kTolerance));
268 }
269
270 auto assertDoublesEqual = [&](double left, double right) {
272 };
273 assertDoublesEqual(cross(double2{1.2, 3.4}, double2{3.4, -1.2}), -13.000000);
274 assertDoublesEqual(cross(double2{12.34, 5.6}, double2{7.8, -9.0}), -154.740000);
275 assertDoublesEqual(cross(double2{12.34, 5.6}, double2{7.8, 9.012345678}), 67.532346);
276}
277
278template<int N, typename T> void check_strided_loads(skiatest::Reporter* r) {
279 using Vec = Vec<N,T>;
280 T values[N*4];
281 std::iota(values, values + N*4, 0);
282 Vec a, b, c, d;
283 strided_load2(values, a, b);
284 for (int i = 0; i < N; ++i) {
285 REPORTER_ASSERT(r, a[i] == values[i*2]);
286 REPORTER_ASSERT(r, b[i] == values[i*2 + 1]);
287 }
288 strided_load4(values, a, b, c, d);
289 for (int i = 0; i < N; ++i) {
290 REPORTER_ASSERT(r, a[i] == values[i*4]);
291 REPORTER_ASSERT(r, b[i] == values[i*4 + 1]);
292 REPORTER_ASSERT(r, c[i] == values[i*4 + 2]);
293 REPORTER_ASSERT(r, d[i] == values[i*4 + 3]);
294 }
295}
296
297template<typename T> void check_strided_loads(skiatest::Reporter* r) {
298 check_strided_loads<1,T>(r);
299 check_strided_loads<2,T>(r);
300 check_strided_loads<4,T>(r);
301 check_strided_loads<8,T>(r);
302 check_strided_loads<16,T>(r);
303 check_strided_loads<32,T>(r);
304}
305
306DEF_TEST(SkVx_strided_loads, r) {
307 check_strided_loads<uint32_t>(r);
308 check_strided_loads<uint16_t>(r);
309 check_strided_loads<uint8_t>(r);
310 check_strided_loads<int32_t>(r);
311 check_strided_loads<int16_t>(r);
312 check_strided_loads<int8_t>(r);
313 check_strided_loads<float>(r);
314}
315
316DEF_TEST(SkVx_ScaledDividerU32, r) {
317 static constexpr uint32_t kMax = std::numeric_limits<uint32_t>::max();
318
319 auto errorBounds = [&](uint32_t actual, uint32_t expected) {
320 uint32_t lowerLimit = expected == 0 ? 0 : expected - 1,
321 upperLimit = expected == kMax ? kMax : expected + 1;
322 return lowerLimit <= actual && actual <= upperLimit;
323 };
324
325 auto test = [&](uint32_t denom) {
326 // half == 1 so, the max to check is kMax-1
327 ScaledDividerU32 d(denom);
328 uint32_t maxCheck = static_cast<uint32_t>(
329 std::floor((double)(kMax - d.half()) / denom + 0.5));
330 REPORTER_ASSERT(r, errorBounds(d.divide((kMax))[0], maxCheck));
331 for (uint32_t i = 0; i < kMax - d.half(); i += 65535) {
332 uint32_t expected = static_cast<uint32_t>(std::floor((double)i / denom + 0.5));
333 auto actual = d.divide(i + d.half());
334 if (!errorBounds(actual[0], expected)) {
335 SkDebugf("i: %u expected: %u actual: %u\n", i, expected, actual[0]);
336 }
337 // Make sure all the lanes are the same.
338 for (int e = 1; e < 4; e++) {
339 SkASSERT(actual[0] == actual[e]);
340 }
341 }
342 };
343
344 test(2);
345 test(3);
346 test(5);
347 test(7);
348 test(27);
349 test(65'535);
350 test(15'485'863);
351 test(512'927'377);
352}
353
354DEF_TEST(SkVx_saturated_add, r) {
355 for (int a = 0; a < (1<<8); a++) {
356 for (int b = 0; b < (1<<8); b++) {
357 int exact = a+b;
358 if (exact > 255) { exact = 255; }
359 if (exact < 0) { exact = 0; }
360
362 }
363 }
364}
365
366DEF_TEST(SkVx_length, r) {
367 auto assertFloatsEqual = [&](float left, float right) {
369 };
370 auto assertDoublesEqual = [&](double left, double right) {
372 };
373
374 assertFloatsEqual(length(float2{0, 1}), 1.000000f);
375 assertFloatsEqual(length(float2{2, 0}), 2.000000f);
376 assertFloatsEqual(length(float2{3, 4}), 5.000000f);
377 assertFloatsEqual(length(float2{1, 1}), 1.414214f);
378 assertFloatsEqual(length(float2{2.5f, 2.5f}), 3.535534f);
379 assertFloatsEqual(length(float4{1, 2, 3, 4}), 5.477226f);
380
381 assertDoublesEqual(length(double2{2.5, 2.5}), 3.535534);
382 assertDoublesEqual(length(double4{1.5, 2.5, 3.5, 4.5}), 6.403124);
383}
384
385DEF_TEST(SkVx_normalize, r) {
386 auto assertFloatsEqual = [&](float left, float right) {
388 };
389 auto assertDoublesEqual = [&](double left, double right) {
391 };
392
393 skvx::float2 twoFloats = normalize(skvx::float2{1.2f, 3.4f});
394 assertFloatsEqual(twoFloats[0], 0.332820f);
395 assertFloatsEqual(twoFloats[1], 0.942990f);
396
397 skvx::double2 twoDoubles = normalize(skvx::double2{2.3, -4.5});
398 assertDoublesEqual(twoDoubles[0], 0.455111);
399 assertDoublesEqual(twoDoubles[1], -0.890435);
400
401 skvx::double4 fourDoubles = normalize(skvx::double4{1.2, 3.4, 5.6, 7.8});
402 assertDoublesEqual(fourDoubles[0], 0.116997);
403 assertDoublesEqual(fourDoubles[1], 0.331490);
404 assertDoublesEqual(fourDoubles[2], 0.545984);
405 assertDoublesEqual(fourDoubles[3], 0.760478);
406}
407
408DEF_TEST(SkVx_normalize_infinity_and_nan, r) {
409 skvx::float2 zeroLenVec = normalize(skvx::float2{0, 0});
410 REPORTER_ASSERT(r, std::isnan(zeroLenVec[0]), "%f is not nan", zeroLenVec[0]);
411 REPORTER_ASSERT(r, std::isnan(zeroLenVec[1]), "%f is not nan", zeroLenVec[1]);
412 REPORTER_ASSERT(r, !isfinite(zeroLenVec));
413
414 skvx::float2 tooBigVec = normalize(skvx::float2{std::numeric_limits<float>::max(),
415 std::numeric_limits<float>::max()});
416 REPORTER_ASSERT(r, tooBigVec[0] == 0, "%f != 0", tooBigVec[0]);
417 REPORTER_ASSERT(r, tooBigVec[1] == 0, "%f != 0", tooBigVec[1]);
418
419 skvx::double2 tooBigVecD = normalize(skvx::double2{std::numeric_limits<double>::max(),
420 std::numeric_limits<double>::max()});
421 REPORTER_ASSERT(r, tooBigVecD[0] == 0, "%f != 0", tooBigVecD[0]);
422 REPORTER_ASSERT(r, tooBigVecD[1] == 0, "%f != 0", tooBigVecD[1]);
423}
424
425DEF_TEST(SkVx_isfinite, r) {
427 REPORTER_ASSERT(r, isfinite(skvx::double4{1.2, 3.4, 5.6, 7.8}));
428 REPORTER_ASSERT(r, isfinite(skvx::float8{8, 7, 6, 5, 4, 3, 2, 1}));
429
431 REPORTER_ASSERT(r, !isfinite(skvx::float2{INFINITY, 10}));
432 REPORTER_ASSERT(r, !isfinite(skvx::float2{NAN, INFINITY}));
433
434 for (int i = 0; i < 4; i++) {
435 auto v = skvx::double4{4, 3, 2, 1};
436 v[i] = INFINITY;
437 REPORTER_ASSERT(r, !isfinite(v), "index %d INFINITY", i);
438 v[i] = NAN;
439 REPORTER_ASSERT(r, !isfinite(v), "index %d NAN", i);
440 }
441
442 for (int i = 0; i < 8; i++) {
443 auto v = skvx::float8{8, 7, 6, 5, 4, 3, 2, 1};
444 v[i] = INFINITY;
445 REPORTER_ASSERT(r, !isfinite(v), "index %d INFINITY", i);
446 v[i] = NAN;
447 REPORTER_ASSERT(r, !isfinite(v), "index %d NAN", i);
448 }
449}
450
451} // namespace skvx
#define test(name)
static constexpr float kTolerance
#define SkASSERT(cond)
Definition SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition SkScalar.h:107
#define DEF_TEST(name, reporter)
Definition Test.h:312
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
#define N
Definition beziers.cpp:19
float nextRangeF(float min, float max)
Definition SkRandom.h:64
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19
static bool b
struct MyStruct a[10]
size_t length
double y
double x
Definition SkVx.h:73
SINT bool isfinite(const Vec< N, T > &v)
Definition SkVx.h:1003
SIN Vec< N, float > trunc(const Vec< N, float > &x)
Definition SkVx.h:704
SINT T dot(const Vec< N, T > &a, const Vec< N, T > &b)
Definition SkVx.h:964
SIT Vec< 1, T > if_then_else(const Vec< 1, M< T > > &cond, const Vec< 1, T > &t, const Vec< 1, T > &e)
Definition SkVx.h:479
Vec< 8, float > float8
Definition SkVx.h:1147
Vec< 16, uint8_t > byte16
Definition SkVx.h:1156
SINT Vec< N, T > naive_if_then_else(const Vec< N, M< T > > &cond, const Vec< N, T > &t, const Vec< N, T > &e)
Definition SkVx.h:474
SIN Vec< N, float > round(const Vec< N, float > &x)
Definition SkVx.h:705
SIT void strided_load4(const T *v, Vec< 1, T > &a, Vec< 1, T > &b, Vec< 1, T > &c, Vec< 1, T > &d)
Definition SkVx.h:1013
SIN Vec< N, float > abs(const Vec< N, float > &x)
Definition SkVx.h:707
SIT void strided_load2(const T *v, Vec< 1, T > &a, Vec< 1, T > &b)
Definition SkVx.h:1112
Vec< 4, float > float4
Definition SkVx.h:1146
Vec< 2, int32_t > int2
Definition SkVx.h:1158
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition SkVx.h:706
SIN Vec< N, float > normalize(const Vec< N, float > &v)
Definition SkVx.h:995
SINT Vec< 2 *N, T > join(const Vec< N, T > &lo, const Vec< N, T > &hi)
Definition SkVx.h:242
SIN Vec< N, uint16_t > mull(const Vec< N, uint8_t > &x, const Vec< N, uint8_t > &y)
Definition SkVx.h:906
Vec< 4, int32_t > int4
Definition SkVx.h:1159
SIN Vec< N, float > from_half(const Vec< N, uint16_t > &x)
Definition SkVx.h:790
SIN Vec< N, uint8_t > div255(const Vec< N, uint16_t > &x)
Definition SkVx.h:818
Vec< 2, uint8_t > byte2
Definition SkVx.h:1153
SIN Vec< N, uint16_t > to_half(const Vec< N, float > &x)
Definition SkVx.h:750
SIT bool all(const Vec< 1, T > &x)
Definition SkVx.h:582
SINT std::enable_if_t< std::is_unsigned_v< T >, Vec< N, T > > saturated_add(const Vec< N, T > &x, const Vec< N, T > &y)
Definition SkVx.h:833
Vec< 2, float > float2
Definition SkVx.h:1145
SIT T max(const Vec< 1, T > &x)
Definition SkVx.h:641
Vec< 4, uint8_t > byte4
Definition SkVx.h:1154
SIT T min(const Vec< 1, T > &x)
Definition SkVx.h:640
Vec< 8, uint8_t > byte8
Definition SkVx.h:1155
void check_strided_loads(skiatest::Reporter *r)
Definition SkVxTest.cpp:278
SIN Vec< N, float > floor(const Vec< N, float > &x)
Definition SkVx.h:703
SIT bool any(const Vec< 1, T > &x)
Definition SkVx.h:530
SIN Vec< N, float > ceil(const Vec< N, float > &x)
Definition SkVx.h:702
SIN Vec< N, uint8_t > approx_scale(const Vec< N, uint8_t > &x, const Vec< N, uint8_t > &y)
Definition SkVx.h:824
SIT T cross(const Vec< 2, T > &a, const Vec< 2, T > &b)
Definition SkVx.h:982
SINT Vec< N, T > pin(const Vec< N, T > &x, const Vec< N, T > &lo, const Vec< N, T > &hi)
Definition SkVx.h:655
#define T
static float CrossProduct(const SkVector &a, const SkVector &b)
static float DotProduct(const SkVector &a, const SkVector &b)
static constexpr SkPoint Make(float x, float y)
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)
Definition SkVx.h:109
SKVX_ALWAYS_INLINE void store(void *ptr) const
Definition SkVx.h:112