1 | // [Blend2D] |
2 | // 2D Vector Graphics Powered by a JIT Compiler. |
3 | // |
4 | // [License] |
5 | // Zlib - See LICENSE.md file in the package. |
6 | |
7 | #ifndef BLEND2D_BLSIMD_P_H |
8 | #define BLEND2D_BLSIMD_P_H |
9 | |
10 | #include "./blapi-internal_p.h" |
11 | |
12 | // ============================================================================ |
13 | // [SIMD - Architecture] |
14 | // ============================================================================ |
15 | |
16 | #if BL_TARGET_ARCH_X86 |
17 | #include "./blsimd_x86_p.h" |
18 | #endif |
19 | |
20 | #ifndef BL_TARGET_SIMD_I |
21 | #define BL_TARGET_SIMD_I 0 |
22 | #endif |
23 | |
24 | #ifndef BL_TARGET_SIMD_F |
25 | #define BL_TARGET_SIMD_F 0 |
26 | #endif |
27 | |
28 | #ifndef BL_TARGET_SIMD_D |
29 | #define BL_TARGET_SIMD_D 0 |
30 | #endif |
31 | |
32 | // ============================================================================ |
33 | // [SIMD - Loop Helpers] |
34 | // ============================================================================ |
35 | |
36 | //! \cond INTERNAL |
37 | //! \addtogroup blend2d_internal |
38 | //! \{ |
39 | |
40 | //! Define a blit that processes 4 (32-bit) pixels at a time in main loop. |
41 | #define BL_SIMD_LOOP_32x4_INIT() \ |
42 | size_t miniLoopCnt; \ |
43 | size_t mainLoopCnt; |
44 | |
45 | #define BL_SIMD_LOOP_32x4_MINI_BEGIN(LOOP, DST, COUNT) \ |
46 | miniLoopCnt = blMin(size_t((uintptr_t(0) - ((uintptr_t)(DST) / 4)) & 0x3), \ |
47 | size_t(COUNT)); \ |
48 | mainLoopCnt = size_t(COUNT) - miniLoopCnt; \ |
49 | if (!miniLoopCnt) goto On##LOOP##_MiniSkip; \ |
50 | \ |
51 | On##LOOP##_MiniBegin: \ |
52 | do { |
53 | |
54 | #define BL_SIMD_LOOP_32x4_MINI_END(LOOP) \ |
55 | } while (--miniLoopCnt); \ |
56 | \ |
57 | On##LOOP##_MiniSkip: \ |
58 | miniLoopCnt = mainLoopCnt & 3; \ |
59 | mainLoopCnt /= 4; \ |
60 | if (!mainLoopCnt) goto On##LOOP##_MainSkip; |
61 | |
62 | #define BL_SIMD_LOOP_32x4_MAIN_BEGIN(LOOP) \ |
63 | do { |
64 | |
65 | #define BL_SIMD_LOOP_32x4_MAIN_END(LOOP) \ |
66 | } while (--mainLoopCnt); \ |
67 | \ |
68 | On##LOOP##_MainSkip: \ |
69 | if (miniLoopCnt) goto On##LOOP##_MiniBegin; \ |
70 | \ |
71 | On##LOOP##_End: \ |
72 | (void)0; |
73 | |
74 | //! \} |
75 | //! \endcond |
76 | |
77 | #endif // BLEND2D_BLSIMD_P_H |
78 | |