diff --git a/.github/scripts/swiftusd_ci_common/openusd_building.py b/.github/scripts/swiftusd_ci_common/openusd_building.py index 9a4857f9c9..67b30c7272 100644 --- a/.github/scripts/swiftusd_ci_common/openusd_building.py +++ b/.github/scripts/swiftusd_ci_common/openusd_building.py @@ -39,19 +39,19 @@ def get_openusd_build_flags(target): "--ignore-homebrew", "--build-target", "native", openusd_build_dir("macOS"), file_prefix_map] if target == "iOS": - return ["--imageio", "--alembic", "--no-python", "--ignore-homebrew", + return ["--embree", "--imageio", "--alembic", "--no-python", "--ignore-homebrew", "--build-target", "iOS", "--no-build-apple-framework", openusd_build_dir("iOS"), file_prefix_map] if target == "iOSSimulator": - return ["--imageio", "--alembic", "--no-python", "--ignore-homebrew", + return ["--embree", "--imageio", "--alembic", "--no-python", "--ignore-homebrew", "--build-target", "iOSSimulator", "--no-build-apple-framework", openusd_build_dir("iOSSimulator"), file_prefix_map] if target == "visionOS": - return ["--imageio", "--alembic", "--no-python", "--ignore-homebrew", + return ["--embree", "--imageio", "--alembic", "--no-python", "--ignore-homebrew", "--build-target", "visionOS", "--no-build-apple-framework", openusd_build_dir("visionOS"), file_prefix_map] if target == "visionOSSimulator": - return ["--imageio", "--alembic", "--no-python", "--ignore-homebrew", + return ["--embree", "--imageio", "--alembic", "--no-python", "--ignore-homebrew", "--build-target", "visionOSSimulator", "--no-build-apple-framework", openusd_build_dir("visionOSSimulator"), file_prefix_map] raise ValueError(f"Unknown target {target}") diff --git a/SwiftUsd.docc/AboutThisRepo/ChangeLog.md b/SwiftUsd.docc/AboutThisRepo/ChangeLog.md index c724c156ba..0d14c46495 100644 --- a/SwiftUsd.docc/AboutThisRepo/ChangeLog.md +++ b/SwiftUsd.docc/AboutThisRepo/ChangeLog.md @@ -14,6 +14,7 @@ Changes to SwiftUsd ### TBD Released TBD, based on OpenUSD TBD - Add zero-copy `VtArray` reads via `withUnsafeBufferPointer(_:)` and single-copy construction from an `UnsafeBufferPointer` +- Add Embree to the default Swift Package for iOS, visionOS, and simulators ### 8.0.0 Released 2026-07-22, based on OpenUSD v26.08 diff --git a/SwiftUsd.docc/TechnicalDetails/BuildingLocally.md b/SwiftUsd.docc/TechnicalDetails/BuildingLocally.md index b658975b3e..6e684ef61c 100644 --- a/SwiftUsd.docc/TechnicalDetails/BuildingLocally.md +++ b/SwiftUsd.docc/TechnicalDetails/BuildingLocally.md @@ -40,6 +40,7 @@ python3 build_scripts/build_usd.py \ cd ~/SwiftUsd/openusd-source python3 build_scripts/build_usd.py \ + --embree \ --imageio \ --alembic \ --no-python \ @@ -51,6 +52,7 @@ python3 build_scripts/build_usd.py \ cd ~/SwiftUsd/openusd-source python3 build_scripts/build_usd.py \ + --embree \ --imageio \ --alembic \ --no-python \ @@ -62,6 +64,7 @@ python3 build_scripts/build_usd.py \ cd ~/SwiftUsd/openusd-source python3 build_scripts/build_usd.py \ + --embree \ --imageio \ --alembic \ --no-python \ @@ -73,6 +76,7 @@ python3 build_scripts/build_usd.py \ cd ~/SwiftUsd/openusd-source python3 build_scripts/build_usd.py \ + --embree \ --imageio \ --alembic \ --no-python \ diff --git a/SwiftUsd.docc/TechnicalDetails/ChangesToOpenUSD.md b/SwiftUsd.docc/TechnicalDetails/ChangesToOpenUSD.md index b414554719..5af950691e 100644 --- a/SwiftUsd.docc/TechnicalDetails/ChangesToOpenUSD.md +++ b/SwiftUsd.docc/TechnicalDetails/ChangesToOpenUSD.md @@ -14,6 +14,9 @@ These changes fix bugs or add features to Usd that aren't part of vanilla OpenUS - Add support for usdValidation libraries when building for iOS, visionOS, or simulators: - Modified: `build_scripts/build_usd.py` +- Cherry pick [https://github.com/PixarAnimationStudios/OpenUSD/pull/4166](https://github.com/PixarAnimationStudios/OpenUSD/pull/4166) to add support for Embree on iOS, visionOS, and simulators: + - Modified: `build_scripts/build_usd.py` + #### Swift-specific changes to OpenUSD before building These changes work around Swift-specific issues in vanilla OpenUSD, add Swift-specific features, and work around issues in the Swift compiler. - Header modularization fixes: diff --git a/openusd-patch.patch b/openusd-patch.patch index 66b95ab38f..a48f5fd2dd 100644 --- a/openusd-patch.patch +++ b/openusd-patch.patch @@ -1,7 +1,27 @@ diff -Nura --exclude .git --exclude *.orig --exclude .DS_Store --exclude *.pyc /Users/maddyadams/OpenUSD/build_scripts/build_usd.py ./build_scripts/build_usd.py ---- /Users/maddyadams/OpenUSD/build_scripts/build_usd.py 2026-07-20 09:43:19 -+++ ./build_scripts/build_usd.py 2026-07-20 10:06:34 -@@ -2524,7 +2524,6 @@ +--- /Users/maddyadams/OpenUSD/build_scripts/build_usd.py 2026-07-24 12:11:44 ++++ ./build_scripts/build_usd.py 2026-07-27 10:36:40 +@@ -1756,6 +1756,19 @@ + "target_compile_options(embree PRIVATE -Wno-unused-but-set-variable)\n")], + multiLineMatches=True, + ) ++ # Add iOS, visionOS support ++ PatchFile("CMakeLists.txt", ++ [('IF (APPLE AND CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" AND CMAKE_OSX_ARCHITECTURES STREQUAL "") OR ("arm64" IN_LIST CMAKE_OSX_ARCHITECTURES))', ++ 'IF (APPLE AND ((CMAKE_SYSTEM_NAME STREQUAL "Darwin") OR (CMAKE_SYSTEM_NAME STREQUAL "iOS") OR (CMAKE_SYSTEM_NAME STREQUAL "visionOS")) AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" AND CMAKE_OSX_ARCHITECTURES STREQUAL "") OR ("arm64" IN_LIST CMAKE_OSX_ARCHITECTURES))' ++ )]) ++ PatchFile("common/cmake/clang.cmake", ++ [(' SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7") # makes sure code runs on older MacOSX versions\n', ++ ' IF (CMAKE_SYSTEM_NAME STREQUAL "Darwin")\n' ++ ' SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7") # makes sure code runs on older MacOSX versions\n' ++ ' ENDIF()\n' ++ )], ++ multiLineMatches=True) ++ + if context.targetUniversal: + extraArgs += [ + '-DEMBREE_MAX_ISA=NEON', +@@ -2524,7 +2537,6 @@ not embedded and not self.targetWasm) self.buildUsdValidation = (args.build_usd_validation and diff --git a/scripts/make-swift-package/Sources/UsdFeatureFlags.swift b/scripts/make-swift-package/Sources/UsdFeatureFlags.swift index 64004d8ed4..4c8f023f9e 100644 --- a/scripts/make-swift-package/Sources/UsdFeatureFlags.swift +++ b/scripts/make-swift-package/Sources/UsdFeatureFlags.swift @@ -51,7 +51,6 @@ extension FileSystemInfo { /// or nil if the module name is available on embedded platforms static func shortNameForFeatureUnavailableOnEmbeddedPlatforms(moduleName: String) -> String? { switch moduleName { - case "SwiftUsd_PXR_ENABLE_EMBREE_SUPPORT": "Embree" case "SwiftUsd_PXR_ENABLE_OPENIMAGEIO_SUPPORT": "OpenImageIO" case "SwiftUsd_PXR_ENABLE_OPENVDB_SUPPORT": "OpenVDB" default: nil @@ -62,7 +61,6 @@ extension FileSystemInfo { /// These flags use OR instead, because they're only available on certain platforms static func prefersOrForMergingFeatureFlag(_ flag: String) -> Bool { switch flag { - case "PXR_BUILD_EMBREE_PLUGIN": true case "PXR_BUILD_OPENIMAGEIO_PLUGIN": true case "PXR_ENABLE_OPENVDB_SUPPORT": true default: false