fast sk4f <-> sk4i SSE methods
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1707673002 CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Review URL: https://codereview.chromium.org/1707673002
This commit is contained in:
parent
d96e7e503f
commit
0cf795fd11
@ -294,6 +294,13 @@ public:
|
|||||||
__m128i fVec;
|
__m128i fVec;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<> /*static*/ inline Sk4f SkNx_cast<float, int>(const Sk4i& src) {
|
||||||
|
return _mm_cvtepi32_ps(src.fVec);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <> /*static*/ inline Sk4i SkNx_cast<int, float>(const Sk4f& src) {
|
||||||
|
return _mm_cvttps_epi32(src.fVec);
|
||||||
|
}
|
||||||
|
|
||||||
template<> /*static*/ inline Sk4h SkNx_cast<uint16_t, float>(const Sk4f& src) {
|
template<> /*static*/ inline Sk4h SkNx_cast<uint16_t, float>(const Sk4f& src) {
|
||||||
auto _32 = _mm_cvttps_epi32(src.fVec);
|
auto _32 = _mm_cvttps_epi32(src.fVec);
|
||||||
|
@ -237,6 +237,22 @@ DEF_TEST(SkNx_shuffle, r) {
|
|||||||
REPORTER_ASSERT(r, f4[3] == 20);
|
REPORTER_ASSERT(r, f4[3] == 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEF_TEST(SkNx_int_float, r) {
|
||||||
|
Sk4f f(-2.3f, 1.0f, 0.45f, 0.6f);
|
||||||
|
|
||||||
|
Sk4i i = SkNx_cast<int>(f);
|
||||||
|
REPORTER_ASSERT(r, i[0] == -2);
|
||||||
|
REPORTER_ASSERT(r, i[1] == 1);
|
||||||
|
REPORTER_ASSERT(r, i[2] == 0);
|
||||||
|
REPORTER_ASSERT(r, i[3] == 0);
|
||||||
|
|
||||||
|
f = SkNx_cast<float>(i);
|
||||||
|
REPORTER_ASSERT(r, f[0] == -2.0f);
|
||||||
|
REPORTER_ASSERT(r, f[1] == 1.0f);
|
||||||
|
REPORTER_ASSERT(r, f[2] == 0.0f);
|
||||||
|
REPORTER_ASSERT(r, f[3] == 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
#include "SkRandom.h"
|
#include "SkRandom.h"
|
||||||
|
|
||||||
DEF_TEST(SkNx_u16_float, r) {
|
DEF_TEST(SkNx_u16_float, r) {
|
||||||
|
Loading…
Reference in New Issue
Block a user