Implement Sk2f::Store2

Bug: skia:
Change-Id: Ifea5957458e5547ee428809d9599286e70f3f8f9
Reviewed-on: https://skia-review.googlesource.com/119860
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
Chris Dalton 2018-04-08 23:58:43 -06:00 committed by Skia Commit-Bot
parent e697500577
commit 42f02aa4e3
4 changed files with 34 additions and 0 deletions

View File

@ -97,6 +97,11 @@ struct SkNx {
Half::Store3(ptr, a.fLo, b.fLo, c.fLo);
Half::Store3(ptr + 3*N/2*sizeof(T), a.fHi, b.fHi, c.fHi);
}
AI static void Store2(void* vptr, const SkNx& a, const SkNx& b) {
auto ptr = (char*)vptr;
Half::Store2(ptr, a.fLo, b.fLo);
Half::Store2(ptr + 2*N/2*sizeof(T), a.fHi, b.fHi);
}
AI bool anyTrue() const { return fLo.anyTrue() || fHi.anyTrue(); }
AI bool allTrue() const { return fLo.allTrue() && fHi.allTrue(); }
@ -200,6 +205,11 @@ struct SkNx<1,T> {
b.store(ptr + 1*sizeof(T));
c.store(ptr + 2*sizeof(T));
}
AI static void Store2(void* vptr, const SkNx& a, const SkNx& b) {
auto ptr = (char*)vptr;
a.store(ptr + 0*sizeof(T));
b.store(ptr + 1*sizeof(T));
}
AI bool anyTrue() const { return fVal != 0; }
AI bool allTrue() const { return fVal != 0; }

View File

@ -34,6 +34,14 @@ public:
AI static SkNx Load(const void* ptr) { return vld1_f32((const float*)ptr); }
AI void store(void* ptr) const { vst1_f32((float*)ptr, fVec); }
AI static void Store2(void* dst, const SkNx& a, const SkNx& b) {
float32x2x2_t ab = {{
a.fVec,
b.fVec,
}};
vst2_f32((float*) dst, ab);
}
AI static void Store3(void* dst, const SkNx& a, const SkNx& b, const SkNx& c) {
float32x2x3_t abc = {{
a.fVec,

View File

@ -29,6 +29,11 @@ public:
AI void store(void* ptr) const { _mm_storel_pi((__m64*)ptr, fVec); }
AI static void Store2(void* dst, const SkNx& a, const SkNx& b) {
auto vals = _mm_unpacklo_ps(a.fVec, b.fVec);
_mm_storeu_ps((float*)dst, vals);
}
AI static void Store3(void* dst, const SkNx& a, const SkNx& b, const SkNx& c) {
auto lo = _mm_setr_ps(a[0], b[0], c[0], a[1]),
hi = _mm_setr_ps(b[1], c[1], 0, 0);

View File

@ -424,6 +424,17 @@ DEF_TEST(Sk4f_Load2, r) {
REPORTER_ASSERT(r, y[3] == 7);
}
DEF_TEST(Sk2f_Store2, r) {
Sk2f p0{0, 2};
Sk2f p1{1, 3};
float dst[4];
Sk2f::Store2(dst, p0, p1);
REPORTER_ASSERT(r, dst[0] == 0);
REPORTER_ASSERT(r, dst[1] == 1);
REPORTER_ASSERT(r, dst[2] == 2);
REPORTER_ASSERT(r, dst[3] == 3);
}
DEF_TEST(Sk2f_Store3, r) {
Sk2f p0{0, 3};
Sk2f p1{1, 4};