17 #include <freerdp/config.h>
20 #include <freerdp/types.h>
21 #include <freerdp/primitives.h>
22 #include <winpr/sysinfo.h>
24 #include "prim_internal.h"
28 #if defined(SSE2_ENABLED)
29 #include <emmintrin.h>
33 static pstatus_t sse2_set_8u(BYTE val, BYTE* WINPR_RESTRICT pDst, UINT32 len)
41 return generic->set_8u(val, pDst, len);
47 while ((ULONG_PTR)dptr & 0x0f)
52 return PRIMITIVES_SUCCESS;
55 xmm0 = _mm_set1_epi8(
byte);
63 _mm_store_si128((__m128i*)dptr, xmm0);
65 _mm_store_si128((__m128i*)dptr, xmm0);
67 _mm_store_si128((__m128i*)dptr, xmm0);
69 _mm_store_si128((__m128i*)dptr, xmm0);
71 _mm_store_si128((__m128i*)dptr, xmm0);
73 _mm_store_si128((__m128i*)dptr, xmm0);
75 _mm_store_si128((__m128i*)dptr, xmm0);
77 _mm_store_si128((__m128i*)dptr, xmm0);
79 _mm_store_si128((__m128i*)dptr, xmm0);
81 _mm_store_si128((__m128i*)dptr, xmm0);
83 _mm_store_si128((__m128i*)dptr, xmm0);
85 _mm_store_si128((__m128i*)dptr, xmm0);
87 _mm_store_si128((__m128i*)dptr, xmm0);
89 _mm_store_si128((__m128i*)dptr, xmm0);
91 _mm_store_si128((__m128i*)dptr, xmm0);
93 _mm_store_si128((__m128i*)dptr, xmm0);
104 _mm_store_si128((__m128i*)dptr, xmm0);
112 return PRIMITIVES_SUCCESS;
116 static pstatus_t sse2_set_32u(UINT32 val, UINT32* WINPR_RESTRICT pDst, UINT32 len)
129 return PRIMITIVES_SUCCESS;
133 if (((ULONG_PTR)dptr & 0x03) != 0)
135 return prim->set_32u(val, pDst, len);
139 while ((ULONG_PTR)dptr & 0x0f)
144 return PRIMITIVES_SUCCESS;
147 xmm0 = _mm_set1_epi32(val);
155 _mm_store_si128((__m128i*)dptr, xmm0);
157 _mm_store_si128((__m128i*)dptr, xmm0);
159 _mm_store_si128((__m128i*)dptr, xmm0);
161 _mm_store_si128((__m128i*)dptr, xmm0);
163 _mm_store_si128((__m128i*)dptr, xmm0);
165 _mm_store_si128((__m128i*)dptr, xmm0);
167 _mm_store_si128((__m128i*)dptr, xmm0);
169 _mm_store_si128((__m128i*)dptr, xmm0);
171 _mm_store_si128((__m128i*)dptr, xmm0);
173 _mm_store_si128((__m128i*)dptr, xmm0);
175 _mm_store_si128((__m128i*)dptr, xmm0);
177 _mm_store_si128((__m128i*)dptr, xmm0);
179 _mm_store_si128((__m128i*)dptr, xmm0);
181 _mm_store_si128((__m128i*)dptr, xmm0);
183 _mm_store_si128((__m128i*)dptr, xmm0);
185 _mm_store_si128((__m128i*)dptr, xmm0);
196 _mm_store_si128((__m128i*)dptr, xmm0);
204 return PRIMITIVES_SUCCESS;
208 static pstatus_t sse2_set_32s(INT32 val, INT32* WINPR_RESTRICT pDst, UINT32 len)
210 UINT32 uval = *((UINT32*)&val);
211 return sse2_set_32u(uval, (UINT32*)pDst, len);
216 void primitives_init_set_sse2(
primitives_t* WINPR_RESTRICT prims)
218 #if defined(SSE2_ENABLED)
219 generic = primitives_get_generic();
220 primitives_init_set(prims);
223 if (IsProcessorFeaturePresent(PF_SSE2_INSTRUCTIONS_AVAILABLE))
225 WLog_VRB(PRIM_TAG,
"SSE2 optimizations");
226 prims->set_8u = sse2_set_8u;
227 prims->set_32s = sse2_set_32s;
228 prims->set_32u = sse2_set_32u;
232 WLog_VRB(PRIM_TAG,
"undefined WITH_SSE2");