Skip to content

Commit

Permalink
fixed potential build issues for windows (winarm, generic, arm32bit, …
Browse files Browse the repository at this point in the history
…minor fix for avx512)
  • Loading branch information
t-boiko committed Oct 24, 2024
1 parent 1e89710 commit 99e368b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
27 changes: 11 additions & 16 deletions vk_video_decoder/libs/NvVideoParser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,34 @@ include_directories(BEFORE ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT})

add_library(${VULKAN_VIDEO_PARSER_LIB} SHARED ${LIBNVPARSER})

if (CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
if ((CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") OR (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm64") OR (CMAKE_SYSTEM_PROCESSOR MATCHES "^ARM64"))
if(WIN32)
set(GENERIC_CPU_FEATURE "/arch:armv8.0+nosimd")
set(NEON_CPU_FEATURE "/arch:armv8.0")
set(SVE_CPU_FEATURE "/arch:armv8.0+sve")
# set(SVE_CPU_FEATURE "/arch:armv8.0+sve") # clang-cl limitation (SVE intrinsics are not supported by MSVC at the moment)
elseif(UNIX)
set(GENERIC_CPU_FEATURE "-march=armv8-a+nosimd")
set(NEON_CPU_FEATURE "-march=armv8-a")
set(SVE_CPU_FEATURE "-march=armv8-a+sve")
endif()
add_library(next_start_code_c OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/src/NextStartCodeC.cpp include)
set_target_properties(next_start_code_c PROPERTIES COMPILE_FLAGS ${GENERIC_CPU_FEATURE} )
target_include_directories(next_start_code_c PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
add_library(next_start_code_neon OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/src/NextStartCodeNEON.cpp include)
set_target_properties(next_start_code_neon PROPERTIES COMPILE_FLAGS ${NEON_CPU_FEATURE} )
target_include_directories(next_start_code_neon PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
if(WIN32) # clang-cl limitation (SVE intrinsics are not supported by MSVC at the moment)
target_link_libraries(${VULKAN_VIDEO_PARSER_LIB} next_start_code_c next_start_code_neon)
elseif(UNIX)
add_library(next_start_code_sve OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/src/NextStartCodeSVE.cpp include)
set_target_properties(next_start_code_sve PROPERTIES COMPILE_FLAGS ${SVE_CPU_FEATURE} )
target_include_directories(next_start_code_sve PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(${VULKAN_VIDEO_PARSER_LIB} next_start_code_c next_start_code_neon next_start_code_sve)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch32")
endif()
elseif ((CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") OR (CMAKE_SYSTEM_PROCESSOR MATCHES "^ARM"))
if(WIN32)
set(GENERIC_CPU_FEATURE "/arch:ARMv7VE")
set(NEON_CPU_FEATURE "/arch:VFPv4")
elseif(UNIX)
set(GENERIC_CPU_FEATURE "-march=armv7-a+nosimd")
set(NEON_CPU_FEATURE "-march=armv7-a+simd")
endif()
add_library(next_start_code_c OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/src/NextStartCodeC.cpp include)
set_target_properties(next_start_code_c PROPERTIES COMPILE_FLAGS ${GENERIC_CPU_FEATURE} )
target_include_directories(next_start_code_c PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
add_library(next_start_code_neon OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/src/NextStartCodeNEON.cpp include)
set_target_properties(next_start_code_neon PROPERTIES COMPILE_FLAGS ${NEON_CPU_FEATURE} )
Expand All @@ -88,18 +86,13 @@ else()
if(WIN32)
set(SSSE3_CPU_FEATURE "/arch:SSE2")
set(AVX2_CPU_FEATURE "/arch:AVX2")
set(AVX512_CPU_FEATURE "/arch:AVX512")
# set(AVX512_CPU_FEATURE "/arch:AVX512")
elseif(UNIX)
set(GENERIC_CPU_FEATURE "-mtune=generic -mno-sse -mno-sse2 -mno-ssse3 -mno-sse4 -mno-sse4.2 -mno-avx \
-mno-avx2 -mno-avx512f -mno-avx512vl -mno-avx512bw -mno-bmi2")
set(SSSE3_CPU_FEATURE "-mssse3")
set(AVX2_CPU_FEATURE "-mavx2")
set(AVX512_CPU_FEATURE "-mavx512f -mavx512bw")
endif()
add_library(next_start_code_c OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/src/NextStartCodeC.cpp include)
if(NOT WIN32)
set_target_properties(next_start_code_c PROPERTIES COMPILE_FLAGS ${GENERIC_CPU_FEATURE} )
endif()
target_include_directories(next_start_code_c PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
add_library(next_start_code_ssse3 OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/src/NextStartCodeSSSE3.cpp include)
set_target_properties(next_start_code_ssse3 PROPERTIES COMPILE_FLAGS ${SSSE3_CPU_FEATURE} )
Expand All @@ -108,7 +101,9 @@ else()
set_target_properties(next_start_code_avx2 PROPERTIES COMPILE_FLAGS ${AVX2_CPU_FEATURE} )
target_include_directories(next_start_code_avx2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
add_library(next_start_code_avx512 OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/src/NextStartCodeAVX512.cpp include)
set_target_properties(next_start_code_avx512 PROPERTIES COMPILE_FLAGS ${AVX512_CPU_FEATURE} )
if(NOT WIN32)
set_target_properties(next_start_code_avx512 PROPERTIES COMPILE_FLAGS ${AVX512_CPU_FEATURE} )
endif()
target_include_directories(next_start_code_avx512 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(${VULKAN_VIDEO_PARSER_LIB} next_start_code_c next_start_code_ssse3 next_start_code_avx2 next_start_code_avx512)
endif()
Expand Down
4 changes: 3 additions & 1 deletion vk_video_decoder/libs/NvVideoParser/src/cpudetect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ class InstructionSet
static bool AVX(void) { return CPU_Rep.f_1_ECX_[28]; }
static bool AVX2(void) { return CPU_Rep.f_7_EBX_[5]; }
static bool AVX512F(void) { return CPU_Rep.f_7_EBX_[16]; }
static bool AVX512DQ(void) { return CPU_Rep.f_7_EBX_[17]; }
static bool AVX512CD(void) { return CPU_Rep.f_7_EBX_[28]; }
static bool AVX512BW(void) { return CPU_Rep.f_7_EBX_[30]; }
static bool AVX512VL(void) { return CPU_Rep.f_7_EBX_[31]; } // VL isn't required
static bool AVX512VL(void) { return CPU_Rep.f_7_EBX_[31]; } // all the 5 bits should be checked if "/arch:AVX512" option is passed

private:
static const InstructionSet_Internal CPU_Rep;
Expand Down

0 comments on commit 99e368b

Please sign in to comment.