Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Unified Diff: src/core/SkHalf.h

Issue 1891513002: skcpu: sse4.1 floor, f16c f16<->f32 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: invert #ifs Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkXfermodeF16.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkHalf.h
diff --git a/src/core/SkHalf.h b/src/core/SkHalf.h
index 5f5575ae1aeaede7f1fd6bde72c8df549f8557bf..82d4fb414c851b1cf1979c79b6bb424c5c966e2b 100644
--- a/src/core/SkHalf.h
+++ b/src/core/SkHalf.h
@@ -8,6 +8,7 @@
#ifndef SkHalf_DEFINED
#define SkHalf_DEFINED
+#include "SkCpu.h"
#include "SkNx.h"
#include "SkTypes.h"
@@ -122,3 +123,32 @@ static inline uint64_t SkFloatToHalf_01(const Sk4f& fs) {
}
#endif
+
+static inline Sk4f SkHalfToFloat_01(const uint64_t* hs) {
+#if !defined(SKNX_NO_SIMD) && SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
+ if (SkCpu::Supports(SkCpu::F16C)) {
+ __m128 fs;
+ #if defined(__GNUC__) || defined(__clang__)
+ asm("vcvtph2ps %[hs], %[fs]" : [fs]"=x"(fs) : [hs]"m"(*hs));
+ #else
+ fs = _mm_cvtph_ps(_mm_loadl_epi64((const __m128i*)hs));
+ #endif
+ return fs;
+ }
+#endif
+ return SkHalfToFloat_01(*hs);
+}
+
+static inline void SkFloatToHalf_01(const Sk4f& fs, uint64_t* hs) {
+#if !defined(SKNX_NO_SIMD) && SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
+ if (SkCpu::Supports(SkCpu::F16C)) {
+ #if defined(__GNUC__) || defined(__clang__)
+ asm("vcvtps2ph $0, %[fs], %[hs]" : [hs]"=m"(*hs) : [fs]"x"(fs.fVec));
+ #else
+ _mm_storel_epi64((__m128i*)hs, _mm_cvtps_ph(fs.fVec, 0));
+ #endif
+ return;
+ }
+#endif
+ *hs = SkFloatToHalf_01(fs);
+}
« no previous file with comments | « no previous file | src/core/SkXfermodeF16.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698