From 92eb70e1d6df05018dc87d3fafee2d153b750e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9a=20Machizaud?= Date: Thu, 7 Mar 2024 19:02:46 +0100 Subject: [PATCH] [embree3] Remove explicit ISA selection and expose more project options as features (#35929) If this PR updates an existing port, please uncomment and fill out this checklist: - [x] Changes comply with the [maintainer guide](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md) - [x] SHA512s are updated for each updated download - [x] The "supports" clause reflects platforms that may be fixed by this new version - [x] Any fixed [CI baseline](https://github.com/microsoft/vcpkg/blob/master/scripts/ci.baseline.txt) entries are removed from that file. - [x] Any patches that are no longer applied are deleted from the port's directory. - [x] The version database is fixed by rerunning `./vcpkg x-add-version --all` and committing the result. - [x] Only one version is added to each modified port's versions file. --- .../001-downgrade-find-package-tbb-2020.patch | 13 +++ ports/embree3/portfile.cmake | 88 +++++++++++++------ ports/embree3/vcpkg.json | 79 +++++++++++------ versions/baseline.json | 2 +- versions/e-/embree3.json | 5 ++ 5 files changed, 129 insertions(+), 58 deletions(-) create mode 100644 ports/embree3/001-downgrade-find-package-tbb-2020.patch diff --git a/ports/embree3/001-downgrade-find-package-tbb-2020.patch b/ports/embree3/001-downgrade-find-package-tbb-2020.patch new file mode 100644 index 0000000000..484008c5f1 --- /dev/null +++ b/ports/embree3/001-downgrade-find-package-tbb-2020.patch @@ -0,0 +1,13 @@ +diff --git a/common/tasking/CMakeLists.txt b/common/tasking/CMakeLists.txt +index 2aeb736..3b4d856 100644 +--- a/common/tasking/CMakeLists.txt ++++ b/common/tasking/CMakeLists.txt +@@ -20,7 +20,7 @@ ELSEIF (TASKING_TBB) + TARGET_LINK_LIBRARIES(tasking PUBLIC TBB::${EMBREE_TBB_COMPONENT}) + else() + # Try getting TBB via config first +- find_package(TBB 2021 COMPONENTS ${EMBREE_TBB_COMPONENT} CONFIG ${TBB_FIND_PACKAGE_OPTION}) ++ find_package(TBB COMPONENTS ${EMBREE_TBB_COMPONENT} CONFIG ${TBB_FIND_PACKAGE_OPTION}) + if (TBB_FOUND) + TARGET_LINK_LIBRARIES(tasking PUBLIC TBB::${EMBREE_TBB_COMPONENT}) + message("-- Found TBB: ${TBB_VERSION} at ${TBB_DIR} via TBBConfig.cmake") diff --git a/ports/embree3/portfile.cmake b/ports/embree3/portfile.cmake index 4d59f5ee02..b734bbb184 100755 --- a/ports/embree3/portfile.cmake +++ b/ports/embree3/portfile.cmake @@ -7,40 +7,67 @@ vcpkg_from_github( HEAD_REF master PATCHES no-runtime-install.patch + 001-downgrade-find-package-tbb-2020.patch ) string(COMPARE EQUAL ${VCPKG_LIBRARY_LINKAGE} static EMBREE_STATIC_LIB) string(COMPARE EQUAL ${VCPKG_CRT_LINKAGE} static EMBREE_STATIC_RUNTIME) -if (NOT VCPKG_TARGET_IS_OSX) - if ("avx512" IN_LIST FEATURES) - message(FATAL_ERROR "Microsoft Visual C++ Compiler does not support feature avx512 officially.") - endif() +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + backface-culling EMBREE_BACKFACE_CULLING + compact-polys EMBREE_COMPACT_POLYS + filter-function EMBREE_FILTER_FUNCTION + ray-mask EMBREE_RAY_MASK + ray-packets EMBREE_RAY_PACKETS - vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - avx EMBREE_ISA_AVX - avx2 EMBREE_ISA_AVX2 - avx512 EMBREE_ISA_AVX512 - sse2 EMBREE_ISA_SSE2 - sse42 EMBREE_ISA_SSE42 + geometry-triangle EMBREE_GEOMETRY_TRIANGLE + geometry-quad EMBREE_GEOMETRY_QUAD + geometry-curve EMBREE_GEOMETRY_CURVE + geometry-subdivision EMBREE_GEOMETRY_SUBDIVISION + geometry-user EMBREE_GEOMETRY_USER + geometry-instance EMBREE_GEOMETRY_INSTANCE + geometry-grid EMBREE_GEOMETRY_GRID + geometry-point EMBREE_GEOMETRY_POINT +) + +# Automatically select best ISA based on platform or VCPKG_CMAKE_CONFIGURE_OPTIONS. +vcpkg_list(SET EXTRA_OPTIONS) +if(VCPKG_TARGET_IS_EMSCRIPTEN) + # Disable incorrect ISA set for Emscripten and enable NEON which is supported and should provide decent performance. + # cf. [Using SIMD with WebAssembly](https://emscripten.org/docs/porting/simd.html#using-simd-with-webassembly) + vcpkg_list(APPEND EXTRA_OPTIONS + -DEMBREE_MAX_ISA:STRING=NONE + + -DEMBREE_ISA_AVX:BOOL=OFF + -DEMBREE_ISA_AVX2:BOOL=OFF + -DEMBREE_ISA_AVX512:BOOL=OFF + -DEMBREE_ISA_SSE2:BOOL=OFF + -DEMBREE_ISA_SSE42:BOOL=OFF + -DEMBREE_ISA_NEON:BOOL=ON ) -elseif (VCPKG_LIBRARY_LINKAGE STREQUAL static) - list(LENGTH FEATURES FEATURE_COUNT) - if (FEATURE_COUNT GREATER 2) - message(WARNING [[ -Using Embree as static library is not supported with AppleClang >= 9.0 when multiple ISAs are selected. -Please install embree3 with only one feature using command "./vcpkg install embree3[core,FEATURE_NAME]" -Only set feature avx automaticlly. - ]]) - set(FEATURE_OPTIONS - -DEMBREE_ISA_AVX=ON - -DEMBREE_ISA_AVX2=OFF - -DEMBREE_ISA_AVX512=OFF - -DEMBREE_ISA_SSE2=OFF - -DEMBREE_ISA_SSE42=OFF - ) - endif() +elseif(VCPKG_TARGET_IS_OSX AND (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")) + # The best ISA for Apple arm64 is unique and unambiguous. + vcpkg_list(APPEND EXTRA_OPTIONS + -DEMBREE_MAX_ISA:STRING=NONE + ) +elseif(VCPKG_TARGET_IS_OSX AND (VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") AND (VCPKG_LIBRARY_LINKAGE STREQUAL "static")) + # AppleClang >= 9.0 does not support selecting multiple ISAs. + # Let Embree select the best and unique one. + vcpkg_list(APPEND EXTRA_OPTIONS + -DEMBREE_MAX_ISA:STRING=DEFAULT + ) +else() + # Let Embree select the best ISA set for the targeted platform. + vcpkg_list(APPEND EXTRA_OPTIONS + -DEMBREE_MAX_ISA:STRING=NONE + ) +endif() + +if("tasking-tbb" IN_LIST FEATURES) + set(EMBREE_TASKING_SYSTEM "TBB") +else() + set(EMBREE_TASKING_SYSTEM "INTERNAL") endif() vcpkg_replace_string("${SOURCE_PATH}/common/cmake/installTBB.cmake" "IF (EMBREE_STATIC_LIB)" "IF (0)") @@ -48,12 +75,15 @@ vcpkg_replace_string("${SOURCE_PATH}/common/cmake/installTBB.cmake" "IF (EMBREE_ vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" DISABLE_PARALLEL_CONFIGURE - OPTIONS ${FEATURE_OPTIONS} + OPTIONS ${FEATURE_OPTIONS} ${EXTRA_OPTIONS} -DEMBREE_ISPC_SUPPORT=OFF -DEMBREE_TUTORIALS=OFF -DEMBREE_STATIC_RUNTIME=${EMBREE_STATIC_RUNTIME} -DEMBREE_STATIC_LIB=${EMBREE_STATIC_LIB} + -DEMBREE_TASKING_SYSTEM:STRING=${EMBREE_TASKING_SYSTEM} -DEMBREE_INSTALL_DEPENDENCIES=OFF + MAYBE_UNUSED_VARIABLES + EMBREE_STATIC_RUNTIME ) vcpkg_cmake_install() @@ -85,4 +115,4 @@ endif() file(RENAME "${CURRENT_PACKAGES_DIR}/share/doc" "${CURRENT_PACKAGES_DIR}/share/${PORT}/") file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") diff --git a/ports/embree3/vcpkg.json b/ports/embree3/vcpkg.json index 22b0e52b13..821601bc61 100644 --- a/ports/embree3/vcpkg.json +++ b/ports/embree3/vcpkg.json @@ -1,13 +1,12 @@ { "name": "embree3", "version": "3.13.5", - "port-version": 2, + "port-version": 3, "description": "High Performance Ray Tracing Kernels.", "homepage": "https://github.com/embree/embree", "license": "Apache-2.0", "supports": "!arm | osx", "dependencies": [ - "tbb", { "name": "vcpkg-cmake", "host": true @@ -18,39 +17,63 @@ } ], "default-features": [ - "default-features" + "filter-function", + "geometry-curve", + "geometry-grid", + "geometry-instance", + "geometry-point", + "geometry-quad", + "geometry-subdivision", + "geometry-triangle", + "geometry-user", + "ray-packets", + "tasking-tbb" ], "features": { - "avx": { - "description": "Enables AVX ISA." + "backface-culling": { + "description": "Enables backface culling." }, - "avx2": { - "description": "Enables AVX2 ISA." + "compact-polys": { + "description": "Enables double indexed poly layout." }, - "avx512": { - "description": "Enables AVX512 ISA." + "filter-function": { + "description": "Enables filter functions." }, - "default-features": { - "description": "Enables all default features.", + "geometry-curve": { + "description": "Enables support for curve geometries." + }, + "geometry-grid": { + "description": "Enables support for grid geometries." + }, + "geometry-instance": { + "description": "Enables support for instances." + }, + "geometry-point": { + "description": "Enables support for point geometries." + }, + "geometry-quad": { + "description": "Enables support for quad geometries." + }, + "geometry-subdivision": { + "description": "Enables support for subdiv geometries." + }, + "geometry-triangle": { + "description": "Enables support for triangle geometries." + }, + "geometry-user": { + "description": "Enables support for user geometries." + }, + "ray-mask": { + "description": "Enables ray mask support." + }, + "ray-packets": { + "description": "Enabled support for ray packets." + }, + "tasking-tbb": { + "description": "Use oneTBB as task system.", "dependencies": [ - { - "name": "embree3", - "default-features": false, - "features": [ - "avx", - "avx2", - "sse2", - "sse42" - ], - "platform": "x64 | x86" - } + "tbb" ] - }, - "sse2": { - "description": "Enables SSE2 ISA." - }, - "sse42": { - "description": "Enables SSE4.2 ISA." } } } diff --git a/versions/baseline.json b/versions/baseline.json index 46e31cd9e1..6af584f6db 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -2474,7 +2474,7 @@ }, "embree3": { "baseline": "3.13.5", - "port-version": 2 + "port-version": 3 }, "enet": { "baseline": "1.3.17", diff --git a/versions/e-/embree3.json b/versions/e-/embree3.json index 29c7d38278..be2464d5f2 100644 --- a/versions/e-/embree3.json +++ b/versions/e-/embree3.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "ff35cda43407d9fd76af567f3284e9eb988307fe", + "version": "3.13.5", + "port-version": 3 + }, { "git-tree": "23414ba5fbc71fc0db19bbc4133762e552a3bbec", "version": "3.13.5",