diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index 396c1da39..c4b4e4dd9 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -23,6 +23,8 @@ option(WITH_PROFILER "Compile profiler." OFF) option(WITH_GPROF "Compile with GProf profiler." OFF) option(WITH_SSE2 "Enable SSE2 optimization." OFF) +cmake_dependent_option(WITH_AVX2 "Compile AVX2 optimizations" ON "WITH_SSE2" OFF) + option(WITH_NEON "Enable NEON optimization." OFF) option(WITH_JPEG "Use JPEG decoding." OFF) diff --git a/include/config/config.h.in b/include/config/config.h.in index a0a73f32d..5da29b8e8 100644 --- a/include/config/config.h.in +++ b/include/config/config.h.in @@ -22,6 +22,7 @@ #cmakedefine WITH_PROFILER #cmakedefine WITH_GPROF #cmakedefine WITH_SSE2 +#cmakedefine WITH_AVX2 #cmakedefine WITH_NEON #cmakedefine WITH_CUPS #cmakedefine WITH_JPEG diff --git a/libfreerdp/primitives/CMakeLists.txt b/libfreerdp/primitives/CMakeLists.txt index f85974858..38a8dcc15 100644 --- a/libfreerdp/primitives/CMakeLists.txt +++ b/libfreerdp/primitives/CMakeLists.txt @@ -87,9 +87,14 @@ set(PRIMITIVES_OPT_SRCS ${PRIMITIVES_SSSE3_SRCS} ${PRIMITIVES_SSE4_1_SRCS} ${PRIMITIVES_SSE4_2_SRCS} - ${PRIMITIVES_AVX2_SRCS} ${PRIMITIVES_OPENCL_SRCS}) +if (WITH_AVX2) + list(APPEND PRIMITIVES_OPT_SRCS + ${PRIMITIVES_AVX2_SRCS} + ) +endif() + set(PRIMITIVES_SRCS ${PRIMITIVES_SRCS} ${PRIMITIVES_OPT_SRCS}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) @@ -117,7 +122,7 @@ if(WITH_SSE2) if (PRIMITIVES_SSE4_2_SRCS) set_source_files_properties(${PRIMITIVES_SSE4_2_SRCS} PROPERTIES COMPILE_FLAGS "-msse4.2" ) endif() - if (PRIMITIVES_AVX2_SRCS) + if (PRIMITIVES_AVX2_SRCS AND WITH_AVX2) set_source_files_properties(${PRIMITIVES_AVX2_SRCS} PROPERTIES COMPILE_FLAGS "-mavx2" ) endif() endif() diff --git a/libfreerdp/primitives/prim_copy.c b/libfreerdp/primitives/prim_copy.c index 4c33615e2..99b40b5b8 100644 --- a/libfreerdp/primitives/prim_copy.c +++ b/libfreerdp/primitives/prim_copy.c @@ -382,5 +382,7 @@ void primitives_init_copy(primitives_t* WINPR_RESTRICT prims) void primitives_init_copy_opt(primitives_t* prims) { primitives_init_copy_sse41(prims); +#if defined(WITH_AVX2) primitives_init_copy_avx2(prims); +#endif } diff --git a/libfreerdp/primitives/prim_copy.h b/libfreerdp/primitives/prim_copy.h index ace7f925f..8275adc9d 100644 --- a/libfreerdp/primitives/prim_copy.h +++ b/libfreerdp/primitives/prim_copy.h @@ -39,6 +39,9 @@ pstatus_t generic_image_copy_no_overlap_memcpy( UINT32 flags); void primitives_init_copy_sse41(primitives_t* prims); + +#if defined(WITH_AVX2) void primitives_init_copy_avx2(primitives_t* prims); +#endif #endif