aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/opts
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-03-20 12:42:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-20 17:23:09 +0000
commitd92a739d72ae70fc8122dc077b0f751d4b1dd023 (patch)
treee54ae06a74e10e32a3d23bee092213e6c6c4efb0 /src/opts
parent140ab3659e0c5193c778c5e2752387cd0fbe370c (diff)
detect nonfinite cubic points
Bug: oss-fuzz:7031 Cq-Include-Trybots: skia.primary:Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-SKNX_NO_SIMD Change-Id: I657c0652dc863256f445a84c084ccc37d287f534 Reviewed-on: https://skia-review.googlesource.com/115222 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/opts')
-rw-r--r--src/opts/SkNx_sse.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/opts/SkNx_sse.h b/src/opts/SkNx_sse.h
index 3b530f0e78..b4ae0cbe2b 100644
--- a/src/opts/SkNx_sse.h
+++ b/src/opts/SkNx_sse.h
@@ -268,6 +268,53 @@ public:
};
template <>
+class SkNx<2, uint32_t> {
+public:
+ AI SkNx(const __m128i& vec) : fVec(vec) {}
+
+ AI SkNx() {}
+ AI SkNx(uint32_t val) : fVec(_mm_set1_epi32(val)) {}
+ AI static SkNx Load(const void* ptr) { return _mm_loadl_epi64((const __m128i*)ptr); }
+ AI SkNx(uint32_t a, uint32_t b) : fVec(_mm_setr_epi32(a,b,0,0)) {}
+
+ AI void store(void* ptr) const { _mm_storel_epi64((__m128i*)ptr, fVec); }
+
+ AI SkNx operator + (const SkNx& o) const { return _mm_add_epi32(fVec, o.fVec); }
+ AI SkNx operator - (const SkNx& o) const { return _mm_sub_epi32(fVec, o.fVec); }
+ AI SkNx operator * (const SkNx& o) const { return mullo32(fVec, o.fVec); }
+
+ AI SkNx operator & (const SkNx& o) const { return _mm_and_si128(fVec, o.fVec); }
+ AI SkNx operator | (const SkNx& o) const { return _mm_or_si128(fVec, o.fVec); }
+ AI SkNx operator ^ (const SkNx& o) const { return _mm_xor_si128(fVec, o.fVec); }
+
+ AI SkNx operator << (int bits) const { return _mm_slli_epi32(fVec, bits); }
+ AI SkNx operator >> (int bits) const { return _mm_srli_epi32(fVec, bits); }
+
+ AI SkNx operator == (const SkNx& o) const { return _mm_cmpeq_epi32 (fVec, o.fVec); }
+ AI SkNx operator != (const SkNx& o) const { return (*this == o) ^ 0xffffffff; }
+ // operator < and > take a little extra fiddling to make work for unsigned ints.
+
+ AI uint32_t operator[](int k) const {
+ SkASSERT(0 <= k && k < 2);
+ union { __m128i v; uint32_t us[4]; } pun = {fVec};
+ return pun.us[k&1];
+ }
+
+ AI SkNx thenElse(const SkNx& t, const SkNx& e) const {
+#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE41
+ return _mm_blendv_epi8(e.fVec, t.fVec, fVec);
+#else
+ return _mm_or_si128(_mm_and_si128 (fVec, t.fVec),
+ _mm_andnot_si128(fVec, e.fVec));
+#endif
+ }
+
+ AI bool allTrue() const { return 0xff == (_mm_movemask_epi8(fVec) & 0xff); }
+
+ __m128i fVec;
+};
+
+template <>
class SkNx<4, uint32_t> {
public:
AI SkNx(const __m128i& vec) : fVec(vec) {}
@@ -291,6 +338,8 @@ public:
AI SkNx operator >> (int bits) const { return _mm_srli_epi32(fVec, bits); }
AI SkNx operator == (const SkNx& o) const { return _mm_cmpeq_epi32 (fVec, o.fVec); }
+ AI SkNx operator != (const SkNx& o) const { return (*this == o) ^ 0xffffffff; }
+
// operator < and > take a little extra fiddling to make work for unsigned ints.
AI uint32_t operator[](int k) const {