1 #ifdef CPU_SIMD
2 
3 force_inline
LoadRGBA(const RGBA * s)4 i16x8 LoadRGBA(const RGBA *s)
5 {
6 	return Unpack8L(i32x4(*(dword *)s));
7 }
8 
9 force_inline
LoadRGBA2(const RGBA * s0,const RGBA * s1)10 i16x8 LoadRGBA2(const RGBA *s0, const RGBA *s1)
11 {
12 	return Unpack8L(i32x4(0, 0, *(dword *)s1, *(dword *)s0));
13 }
14 
15 force_inline
LoadRGBA2(const RGBA & c)16 i16x8 LoadRGBA2(const RGBA& c)
17 {
18 	return LoadRGBA2(&c, &c);
19 }
20 
21 force_inline
LoadRGBA2(const RGBA * s)22 i16x8 LoadRGBA2(const RGBA *s)
23 {
24 	i16x8 h;
25 	h.Load64(s);
26 	return Unpack8L(h);
27 }
28 
29 force_inline
LoadRGBAL(i16x8 x)30 i16x8 LoadRGBAL(i16x8 x)
31 {
32 	return Unpack8L(x);
33 }
34 
35 force_inline
LoadRGBAH(i16x8 x)36 i16x8 LoadRGBAH(i16x8 x)
37 {
38 	return Unpack8H(x);
39 }
40 
41 force_inline
LoadRGBA4(const RGBA * s,i16x8 & l,i16x8 & h)42 void LoadRGBA4(const RGBA *s, i16x8& l, i16x8& h)
43 {
44 	i16x8 t4(s);
45 	l = LoadRGBAL(t4);
46 	h = LoadRGBAH(t4);
47 }
48 
49 force_inline
PackRGBA(i16x8 l,i16x8 h)50 i8x16 PackRGBA(i16x8 l, i16x8 h)
51 {
52 	return Pack16(l, h);
53 }
54 
55 force_inline
StoreRGBA(RGBA * rgba,i16x8 x)56 void StoreRGBA(RGBA *rgba, i16x8 x)
57 {
58 	PackRGBA(x, 0).Store32(rgba);
59 }
60 
61 force_inline
StoreRGBA2(RGBA * rgba,i16x8 x)62 void StoreRGBA2(RGBA *rgba, i16x8 x)
63 {
64 	PackRGBA(x, 0).Store64(rgba);
65 }
66 
67 force_inline
StoreRGBA4(RGBA * rgba,i16x8 l,i16x8 h)68 void StoreRGBA4(RGBA *rgba, i16x8 l, i16x8 h)
69 {
70 	PackRGBA(l, h).Store(rgba);
71 }
72 
73 force_inline
LoadRGBAF(const RGBA * s)74 f32x4 LoadRGBAF(const RGBA *s)
75 {
76 	return ToFloat(Unpack16L(Unpack8L(i16x8().Load32(s))));
77 }
78 
79 force_inline
StoreRGBAF(RGBA * t,f32x4 s)80 void StoreRGBAF(RGBA *t, f32x4 s)
81 {
82 	Pack16(Pack32(Truncate(s))).Store32(t);
83 }
84 
85 force_inline
ClampRGBAF(f32x4 p)86 f32x4 ClampRGBAF(f32x4 p)
87 {
88 #ifdef PLATFORM_MACOS
89 	f32x4 alpha = Broadcast0(p);
90 #else
91 	f32x4 alpha = Broadcast3(p);
92 #endif
93 	alpha = min(alpha, f32all(255.0));
94 	return min(p, alpha);
95 }
96 
97 #endif
98