diff --git a/ports/usd/001-fix_rename_find_package_to_find_dependency.patch b/ports/usd/001-fix_rename_find_package_to_find_dependency.patch new file mode 100644 index 0000000000..6af8bc6a4e --- /dev/null +++ b/ports/usd/001-fix_rename_find_package_to_find_dependency.patch @@ -0,0 +1,43 @@ +diff --git a/pxr/pxrConfig.cmake.in b/pxr/pxrConfig.cmake.in +index b26f1ea31..afe3dc448 100644 +--- a/pxr/pxrConfig.cmake.in ++++ b/pxr/pxrConfig.cmake.in +@@ -16,6 +16,8 @@ set(PXR_MINOR_VERSION "@PXR_MINOR_VERSION@") + set(PXR_PATCH_VERSION "@PXR_PATCH_VERSION@") + set(PXR_VERSION "@PXR_VERSION@") + ++include(CMakeFindDependencyMacro) ++ + # If Python support was enabled for this USD build, find the import + # targets by invoking the appropriate FindPython module. Use the same + # LIBRARY and INCLUDE_DIR settings from the original build if they +@@ -41,9 +43,9 @@ if(@PXR_ENABLE_PYTHON_SUPPORT@) + endif() + + if (NOT DEFINED Python3_VERSION) +- find_package(Python3 "@Python3_VERSION@" EXACT COMPONENTS Development REQUIRED) ++ find_dependency(Python3 "@Python3_VERSION@" EXACT COMPONENTS Development) + else() +- find_package(Python3 COMPONENTS Development REQUIRED) ++ find_dependency(Python3 COMPONENTS Development) + endif() + endif() + +@@ -57,7 +59,7 @@ if(@PXR_ENABLE_MATERIALX_SUPPORT@) + set(MaterialX_DIR [[@MaterialX_DIR@]]) + endif() + endif() +- find_package(MaterialX REQUIRED) ++ find_dependency(MaterialX) + endif() + + # Similar to MaterialX above, we are using Imath's cmake package config, so set +@@ -71,7 +73,7 @@ if(@Imath_FOUND@) + set(Imath_DIR [[@Imath_DIR@]]) + endif() + endif() +- find_package(Imath REQUIRED) ++ find_dependency(Imath) + endif() + + include("${PXR_CMAKE_DIR}/cmake/pxrTargets.cmake") diff --git a/ports/usd/002-vcpkg_find_tbb.patch b/ports/usd/002-vcpkg_find_tbb.patch new file mode 100644 index 0000000000..a3f83c04b4 --- /dev/null +++ b/ports/usd/002-vcpkg_find_tbb.patch @@ -0,0 +1,27 @@ +diff --git a/cmake/defaults/Packages.cmake b/cmake/defaults/Packages.cmake +index fe60570b3..ccaabe765 100644 +--- a/cmake/defaults/Packages.cmake ++++ b/cmake/defaults/Packages.cmake +@@ -137,7 +137,8 @@ endif() + + + # --TBB +-find_package(TBB REQUIRED COMPONENTS tbb) ++find_package(TBB CONFIG REQUIRED) ++set(TBB_tbb_LIBRARY TBB::tbb) + add_definitions(${TBB_DEFINITIONS}) + + # --math +diff --git a/pxr/pxrConfig.cmake.in b/pxr/pxrConfig.cmake.in +index afe3dc448..041cd8cba 100644 +--- a/pxr/pxrConfig.cmake.in ++++ b/pxr/pxrConfig.cmake.in +@@ -18,6 +18,8 @@ set(PXR_VERSION "@PXR_VERSION@") + + include(CMakeFindDependencyMacro) + ++find_dependency(TBB CONFIG) ++ + # If Python support was enabled for this USD build, find the import + # targets by invoking the appropriate FindPython module. Use the same + # LIBRARY and INCLUDE_DIR settings from the original build if they diff --git a/ports/usd/003-vcpkg_find_opensubdiv.patch b/ports/usd/003-vcpkg_find_opensubdiv.patch new file mode 100644 index 0000000000..ddd17c2fcf --- /dev/null +++ b/ports/usd/003-vcpkg_find_opensubdiv.patch @@ -0,0 +1,34 @@ +diff --git a/cmake/defaults/Packages.cmake b/cmake/defaults/Packages.cmake +index ccaabe765..d4eea2988 100644 +--- a/cmake/defaults/Packages.cmake ++++ b/cmake/defaults/Packages.cmake +@@ -260,8 +260,12 @@ if (PXR_BUILD_IMAGING) + endif() + endif() + # --Opensubdiv +- set(OPENSUBDIV_USE_GPU ${PXR_ENABLE_GL_SUPPORT}) +- find_package(OpenSubdiv 3 REQUIRED) ++ find_package(OpenSubdiv 3 CONFIG REQUIRED) ++ set(OPENSUBDIV_LIBRARIES OpenSubdiv::osdCPU_static) ++ set(OPENSUBDIV_OSDCPU_LIBRARY OpenSubdiv::osdCPU_static) # For compatibility ++ if(PXR_ENABLE_GL_SUPPORT) ++ list(APPEND OPENSUBDIV_LIBRARIES OpenSubdiv::osdGPU_static) ++ endif() + # --Ptex + if (PXR_ENABLE_PTEX_SUPPORT) + find_package(PTex REQUIRED) +diff --git a/pxr/pxrConfig.cmake.in b/pxr/pxrConfig.cmake.in +index 041cd8cba..692d045b9 100644 +--- a/pxr/pxrConfig.cmake.in ++++ b/pxr/pxrConfig.cmake.in +@@ -20,6 +20,10 @@ include(CMakeFindDependencyMacro) + + find_dependency(TBB CONFIG) + ++if(@PXR_BUILD_IMAGING@) ++ find_dependency(OpenSubdiv 3 CONFIG) ++endif() ++ + # If Python support was enabled for this USD build, find the import + # targets by invoking the appropriate FindPython module. Use the same + # LIBRARY and INCLUDE_DIR settings from the original build if they diff --git a/ports/usd/004-vcpkg_find_openimageio.patch b/ports/usd/004-vcpkg_find_openimageio.patch new file mode 100644 index 0000000000..96023df00a --- /dev/null +++ b/ports/usd/004-vcpkg_find_openimageio.patch @@ -0,0 +1,57 @@ +diff --git a/cmake/defaults/Packages.cmake b/cmake/defaults/Packages.cmake +index d4eea2988..106fd15e2 100644 +--- a/cmake/defaults/Packages.cmake ++++ b/cmake/defaults/Packages.cmake +@@ -196,7 +196,8 @@ if (PXR_BUILD_IMAGING) + # --OpenImageIO + if (PXR_BUILD_OPENIMAGEIO_PLUGIN) + set(REQUIRES_Imath TRUE) +- find_package(OpenImageIO REQUIRED) ++ find_package(OpenImageIO CONFIG REQUIRED) ++ set(OIIO_LIBRARIES OpenImageIO::OpenImageIO) + add_definitions(-DPXR_OIIO_PLUGIN_ENABLED) + if (OIIO_idiff_BINARY) + set(IMAGE_DIFF_TOOL ${OIIO_idiff_BINARY} CACHE STRING "Uses idiff for image diffing") +diff --git a/pxr/imaging/plugin/hioOiio/CMakeLists.txt b/pxr/imaging/plugin/hioOiio/CMakeLists.txt +index 0a055b711..de4b73a47 100644 +--- a/pxr/imaging/plugin/hioOiio/CMakeLists.txt ++++ b/pxr/imaging/plugin/hioOiio/CMakeLists.txt +@@ -7,6 +7,7 @@ if (NOT ${PXR_BUILD_GPU_SUPPORT}) + return() + endif() + ++if(0) # No need because OpenImageIO::OpenImageIO already declare its transitive dependencies correctly + # Use the import targets set by Imath's package config + if (Imath_FOUND) + set(__OIIO_IMATH_LIBS "Imath::Imath") +@@ -14,6 +15,7 @@ else() + set(__OIIO_IMATH_INCLUDE ${OPENEXR_INCLUDE_DIRS}) + set(__OIIO_IMATH_LIBS ${OPENEXR_LIBRARIES}) + endif() ++endif() + + pxr_plugin(hioOiio + LIBRARIES +diff --git a/pxr/pxrConfig.cmake.in b/pxr/pxrConfig.cmake.in +index 692d045b9..a934c336b 100644 +--- a/pxr/pxrConfig.cmake.in ++++ b/pxr/pxrConfig.cmake.in +@@ -22,6 +22,9 @@ find_dependency(TBB CONFIG) + + if(@PXR_BUILD_IMAGING@) + find_dependency(OpenSubdiv 3 CONFIG) ++ if(@PXR_BUILD_OPENIMAGEIO_PLUGIN@) ++ find_dependency(OpenImageIO CONFIG) ++ endif() + endif() + + # If Python support was enabled for this USD build, find the import +@@ -79,7 +82,7 @@ if(@Imath_FOUND@) + set(Imath_DIR [[@Imath_DIR@]]) + endif() + endif() +- find_dependency(Imath) ++ find_dependency(Imath CONFIG) + endif() + + include("${PXR_CMAKE_DIR}/cmake/pxrTargets.cmake") diff --git a/ports/usd/005-vcpkg_find_shaderc.patch b/ports/usd/005-vcpkg_find_shaderc.patch new file mode 100644 index 0000000000..610bdf84bd --- /dev/null +++ b/ports/usd/005-vcpkg_find_shaderc.patch @@ -0,0 +1,43 @@ +diff --git a/cmake/defaults/Packages.cmake b/cmake/defaults/Packages.cmake +index 3763c9997..79679ca13 100644 +--- a/cmake/defaults/Packages.cmake ++++ b/cmake/defaults/Packages.cmake +@@ -233,6 +233,7 @@ if (PXR_BUILD_IMAGING) + find_package(Vulkan REQUIRED) + list(APPEND VULKAN_LIBS Vulkan::Vulkan) + ++ if(0) + # Find the extra vulkan libraries we need + set(EXTRA_VULKAN_LIBS shaderc_combined) + if (WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug") +@@ -242,6 +243,7 @@ if (PXR_BUILD_IMAGING) + find_library("${EXTRA_LIBRARY}_PATH" NAMES "${EXTRA_LIBRARY}" PATHS $ENV{VULKAN_SDK}/lib) + list(APPEND VULKAN_LIBS "${${EXTRA_LIBRARY}_PATH}") + endforeach() ++ endif() + + # Find the OS specific libs we need + if (APPLE) +@@ -258,6 +260,8 @@ if (PXR_BUILD_IMAGING) + else() + message(FATAL_ERROR "VULKAN_SDK not valid") + endif() ++ find_package(unofficial-shaderc CONFIG REQUIRED) ++ list(APPEND VULKAN_LIBS unofficial::shaderc::shaderc) + endif() + # --Opensubdiv + find_package(OpenSubdiv 3 CONFIG REQUIRED) +diff --git a/pxr/pxrConfig.cmake.in b/pxr/pxrConfig.cmake.in +index a934c336b..62bb13a1b 100644 +--- a/pxr/pxrConfig.cmake.in ++++ b/pxr/pxrConfig.cmake.in +@@ -25,6 +25,9 @@ if(@PXR_BUILD_IMAGING@) + if(@PXR_BUILD_OPENIMAGEIO_PLUGIN@) + find_dependency(OpenImageIO CONFIG) + endif() ++ if(@PXR_ENABLE_VULKAN_SUPPORT@) ++ find_dependency(unofficial-shaderc CONFIG) ++ endif() + endif() + + # If Python support was enabled for this USD build, find the import diff --git a/ports/usd/006-vcpkg_find_spirv-reflect.patch b/ports/usd/006-vcpkg_find_spirv-reflect.patch new file mode 100644 index 0000000000..bde5f90aed --- /dev/null +++ b/ports/usd/006-vcpkg_find_spirv-reflect.patch @@ -0,0 +1,40 @@ +diff --git a/cmake/defaults/Packages.cmake b/cmake/defaults/Packages.cmake +index 79679ca13..d1a8169a2 100644 +--- a/cmake/defaults/Packages.cmake ++++ b/cmake/defaults/Packages.cmake +@@ -261,7 +261,9 @@ if (PXR_BUILD_IMAGING) + message(FATAL_ERROR "VULKAN_SDK not valid") + endif() + find_package(unofficial-shaderc CONFIG REQUIRED) ++ find_package(unofficial-spirv-reflect CONFIG REQUIRED) + list(APPEND VULKAN_LIBS unofficial::shaderc::shaderc) ++ list(APPEND VULKAN_LIBS unofficial::spirv-reflect) + endif() + # --Opensubdiv + find_package(OpenSubdiv 3 CONFIG REQUIRED) +diff --git a/pxr/imaging/hgiVulkan/CMakeLists.txt b/pxr/imaging/hgiVulkan/CMakeLists.txt +index 97e422894..d13837e45 100644 +--- a/pxr/imaging/hgiVulkan/CMakeLists.txt ++++ b/pxr/imaging/hgiVulkan/CMakeLists.txt +@@ -46,9 +46,6 @@ pxr_library(hgiVulkan + api.h + vulkan.h + +- PRIVATE_CLASSES +- spirv_reflect +- + RESOURCE_FILES + plugInfo.json + ) +diff --git a/pxr/pxrConfig.cmake.in b/pxr/pxrConfig.cmake.in +index 62bb13a1b..d5b0d2f77 100644 +--- a/pxr/pxrConfig.cmake.in ++++ b/pxr/pxrConfig.cmake.in +@@ -27,6 +27,7 @@ if(@PXR_BUILD_IMAGING@) + endif() + if(@PXR_ENABLE_VULKAN_SUPPORT@) + find_dependency(unofficial-shaderc CONFIG) ++ find_dependency(unofficial-spirv-reflect CONFIG) + endif() + endif() + diff --git a/ports/usd/007-vcpkg_find_vma.patch b/ports/usd/007-vcpkg_find_vma.patch new file mode 100644 index 0000000000..279e24d5f1 --- /dev/null +++ b/ports/usd/007-vcpkg_find_vma.patch @@ -0,0 +1,27 @@ +diff --git a/cmake/defaults/Packages.cmake b/cmake/defaults/Packages.cmake +index d1a8169a2..0fb6776a9 100644 +--- a/cmake/defaults/Packages.cmake ++++ b/cmake/defaults/Packages.cmake +@@ -262,8 +262,10 @@ if (PXR_BUILD_IMAGING) + endif() + find_package(unofficial-shaderc CONFIG REQUIRED) + find_package(unofficial-spirv-reflect CONFIG REQUIRED) ++ find_package(VulkanMemoryAllocator CONFIG REQUIRED) + list(APPEND VULKAN_LIBS unofficial::shaderc::shaderc) + list(APPEND VULKAN_LIBS unofficial::spirv-reflect) ++ list(APPEND VULKAN_LIBS GPUOpen::VulkanMemoryAllocator) + endif() + # --Opensubdiv + find_package(OpenSubdiv 3 CONFIG REQUIRED) +diff --git a/pxr/pxrConfig.cmake.in b/pxr/pxrConfig.cmake.in +index d5b0d2f77..c8039c310 100644 +--- a/pxr/pxrConfig.cmake.in ++++ b/pxr/pxrConfig.cmake.in +@@ -28,6 +28,7 @@ if(@PXR_BUILD_IMAGING@) + if(@PXR_ENABLE_VULKAN_SUPPORT@) + find_dependency(unofficial-shaderc CONFIG) + find_dependency(unofficial-spirv-reflect CONFIG) ++ find_dependency(VulkanMemoryAllocator CONFIG) + endif() + endif() + diff --git a/ports/usd/008-fix_cmake_package.patch b/ports/usd/008-fix_cmake_package.patch new file mode 100644 index 0000000000..b200106cde --- /dev/null +++ b/ports/usd/008-fix_cmake_package.patch @@ -0,0 +1,63 @@ +diff --git a/pxr/CMakeLists.txt b/pxr/CMakeLists.txt +index 00cafd3d9..c9faeabf0 100644 +--- a/pxr/CMakeLists.txt ++++ b/pxr/CMakeLists.txt +@@ -12,13 +12,31 @@ endif() + + pxr_core_epilogue() + +-export(PACKAGE pxr) ++include(GNUInstallDirs) ++include(CMakePackageConfigHelpers) + +-configure_file(pxrConfig.cmake.in +- "${PROJECT_BINARY_DIR}/pxrConfig.cmake" @ONLY) +-install(FILES ++configure_file( ++ "pxrConfig.cmake.in" + "${PROJECT_BINARY_DIR}/pxrConfig.cmake" +- DESTINATION "${CMAKE_INSTALL_PREFIX}" ++ @ONLY + ) + +-install(EXPORT pxrTargets DESTINATION "cmake") ++write_basic_package_version_file("${PROJECT_BINARY_DIR}/pxrConfigVersion.cmake" ++ VERSION "${PXR_MAJOR_VERSION}.${PXR_MINOR_VERSION}.${PXR_PATCH_VERSION}" ++ COMPATIBILITY AnyNewerVersion ++) ++ ++install( ++ FILES ++ "${PROJECT_BINARY_DIR}/pxrConfig.cmake" ++ "${PROJECT_BINARY_DIR}/pxrConfigVersion.cmake" ++ ++ DESTINATION ++ "${CMAKE_INSTALL_DATADIR}/pxr" ++) ++ ++install( ++ EXPORT pxrTargets ++ # NAMESPACE "pxr::" ++ DESTINATION "${CMAKE_INSTALL_DATADIR}/pxr" ++) +diff --git a/pxr/pxrConfig.cmake.in b/pxr/pxrConfig.cmake.in +index c8039c310..9e104abb7 100644 +--- a/pxr/pxrConfig.cmake.in ++++ b/pxr/pxrConfig.cmake.in +@@ -90,14 +90,14 @@ if(@Imath_FOUND@) + find_dependency(Imath CONFIG) + endif() + +-include("${PXR_CMAKE_DIR}/cmake/pxrTargets.cmake") ++include("${PXR_CMAKE_DIR}/pxrTargets.cmake") + if (TARGET usd_ms) + set(libs "usd_ms") + else() + set(libs "@PXR_ALL_LIBS@") + endif() + set(PXR_LIBRARIES "") +-set(PXR_INCLUDE_DIRS "${PXR_CMAKE_DIR}/include") ++set(PXR_INCLUDE_DIRS "${PXR_CMAKE_DIR}/../../include") + string(REPLACE " " ";" libs "${libs}") + foreach(lib ${libs}) + get_target_property(location ${lib} LOCATION) diff --git a/ports/usd/009-fix_cmake_hgi_interop.patch b/ports/usd/009-fix_cmake_hgi_interop.patch new file mode 100644 index 0000000000..058241d0ea --- /dev/null +++ b/ports/usd/009-fix_cmake_hgi_interop.patch @@ -0,0 +1,23 @@ +diff --git a/pxr/imaging/hgiInterop/CMakeLists.txt b/pxr/imaging/hgiInterop/CMakeLists.txt +index 64ebfcb9e..0087d89aa 100644 +--- a/pxr/imaging/hgiInterop/CMakeLists.txt ++++ b/pxr/imaging/hgiInterop/CMakeLists.txt +@@ -15,6 +15,7 @@ set(optionalPrivateHeaders "") + list(APPEND optionalLibraries garch) + + if (PXR_ENABLE_GL_SUPPORT) ++ list(APPEND optionalLibraries hgiGL) + list(APPEND optionalCppFiles opengl.cpp) + list(APPEND optionalPrivateHeaders opengl.h) + endif() +@@ -32,6 +33,10 @@ if (PXR_ENABLE_METAL_SUPPORT) + list(APPEND optionalPrivateHeaders metal.h) + endif() + ++if (NOT (PXR_ENABLE_GL_SUPPORT OR PXR_ENABLE_VULKAN_SUPPORT OR PXR_ENABLE_METAL_SUPPORT)) ++ message(FATAL_ERROR "No valid GPU backend set for hgiInterop") ++endif() ++ + pxr_library(hgiInterop + LIBRARIES + gf diff --git a/ports/usd/010-fix_missing_find_dependency_vulkan.patch b/ports/usd/010-fix_missing_find_dependency_vulkan.patch new file mode 100644 index 0000000000..d7d67b0cdf --- /dev/null +++ b/ports/usd/010-fix_missing_find_dependency_vulkan.patch @@ -0,0 +1,17 @@ +diff --git a/pxr/pxrConfig.cmake.in b/pxr/pxrConfig.cmake.in +index 9e104abb7..2aa4a3bd3 100644 +--- a/pxr/pxrConfig.cmake.in ++++ b/pxr/pxrConfig.cmake.in +@@ -26,6 +26,12 @@ if(@PXR_BUILD_IMAGING@) + find_dependency(OpenImageIO CONFIG) + endif() + if(@PXR_ENABLE_VULKAN_SUPPORT@) ++ if (NOT DEFINED Vulkan_DIR) ++ if (NOT [[@Vulkan_DIR@]] STREQUAL "") ++ set(Vulkan_DIR [[@Vulkan_DIR@]]) ++ endif() ++ endif() ++ find_dependency(Vulkan REQUIRED) + find_dependency(unofficial-shaderc CONFIG) + find_dependency(unofficial-spirv-reflect CONFIG) + find_dependency(VulkanMemoryAllocator CONFIG) diff --git a/ports/usd/011-fix_clang8_compiler_error.patch b/ports/usd/011-fix_clang8_compiler_error.patch new file mode 100644 index 0000000000..259ce8e63c --- /dev/null +++ b/ports/usd/011-fix_clang8_compiler_error.patch @@ -0,0 +1,22 @@ +diff --git a/pxr/usd/pcp/primIndex.h b/pxr/usd/pcp/primIndex.h +index 6b31c7da4..285d13fa7 100644 +--- a/pxr/usd/pcp/primIndex.h ++++ b/pxr/usd/pcp/primIndex.h +@@ -69,7 +69,7 @@ public: + PcpPrimIndex(const PcpPrimIndex& rhs); + + /// Move-construction +- PcpPrimIndex(PcpPrimIndex &&rhs) noexcept = default; ++ PcpPrimIndex(PcpPrimIndex &&rhs) = default; + + /// Assignment. + PcpPrimIndex &operator=(const PcpPrimIndex &rhs) { +@@ -78,7 +78,7 @@ public: + } + + // Move-assignment. +- PcpPrimIndex &operator=(PcpPrimIndex &&rhs) noexcept = default; ++ PcpPrimIndex &operator=(PcpPrimIndex &&rhs) = default; + + /// Swap the contents of this prim index with \p index. + PCP_API diff --git a/ports/usd/012-vcpkg_install_folder_conventions.patch b/ports/usd/012-vcpkg_install_folder_conventions.patch new file mode 100644 index 0000000000..cbe8d8bb2a --- /dev/null +++ b/ports/usd/012-vcpkg_install_folder_conventions.patch @@ -0,0 +1,82 @@ +diff --git a/cmake/macros/Private.cmake b/cmake/macros/Private.cmake +index 48fe107dd..79fdad022 100644 +--- a/cmake/macros/Private.cmake ++++ b/cmake/macros/Private.cmake +@@ -1185,8 +1185,10 @@ function(_pxr_library NAME) + # XXX --- Why this difference? + _get_install_dir("plugin/usd" pluginInstallPrefix) + endif() ++ elseif(WIN32 AND args_TYPE STREQUAL "SHARED") ++ _get_install_dir("${CMAKE_INSTALL_BINDIR}/usd" pluginInstallPrefix) + else() +- _get_install_dir("lib/usd" pluginInstallPrefix) ++ _get_install_dir("${CMAKE_INSTALL_LIBDIR}/usd" pluginInstallPrefix) + endif() + if(args_SUBDIR) + set(pluginInstallPrefix "${pluginInstallPrefix}/${args_SUBDIR}") +@@ -1266,17 +1268,25 @@ function(_pxr_library NAME) + # Where do we install library to? + _get_install_dir("include" headerInstallDir) + _get_install_dir("include/${PXR_PREFIX}/${NAME}" headerInstallPrefix) +- _get_install_dir("lib" libInstallPrefix) ++ if(WIN32 AND args_TYPE STREQUAL "SHARED") ++ _get_install_dir("${CMAKE_INSTALL_BINDIR}" libInstallPrefix) ++ _get_install_dir("${CMAKE_INSTALL_LIBDIR}" libInstallPrefixArchive) ++ else() ++ _get_install_dir("${CMAKE_INSTALL_LIBDIR}" libInstallPrefix) ++ _get_install_dir("${CMAKE_INSTALL_LIBDIR}" libInstallPrefixArchive) ++ endif() + if(isPlugin) + if(NOT isObject) + # A plugin embedded in the monolithic library is found in + # the usual library location, otherwise plugin libraries + # are in the plugin install location. + set(libInstallPrefix "${pluginInstallPrefix}") ++ set(libInstallPrefixArchive "${pluginInstallPrefix}") + endif() + endif() + if(args_SUBDIR) + set(libInstallPrefix "${libInstallPrefix}/${args_SUBDIR}") ++ set(libInstallPrefixArchive "${libInstallPrefixArchive}/${args_SUBDIR}") + endif() + # Return libInstallPrefix to caller. + if(args_LIB_INSTALL_PREFIX_RESULT) +@@ -1408,8 +1418,8 @@ function(_pxr_library NAME) + # The former is for helper libraries for a third party application and + # the latter for core USD libraries. + _pxr_init_rpath(rpath "${libInstallPrefix}") +- _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/${PXR_INSTALL_SUBDIR}/lib") +- _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") ++ _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/${PXR_INSTALL_SUBDIR}/${libInstallPrefix}") ++ _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/${libInstallPrefix}") + _pxr_install_rpath(rpath ${NAME}) + + # +@@ -1450,14 +1460,14 @@ function(_pxr_library NAME) + if(isPlugin) + install( + TARGETS ${NAME} +- LIBRARY DESTINATION ${libInstallPrefix} +- ARCHIVE DESTINATION ${libInstallPrefix} +- RUNTIME DESTINATION ${libInstallPrefix} ++ LIBRARY DESTINATION ${pluginInstallPrefix} ++ ARCHIVE DESTINATION ${pluginInstallPrefix} ++ RUNTIME DESTINATION ${pluginInstallPrefix} + ) + if(WIN32) + install( + FILES $ +- DESTINATION ${libInstallPrefix} ++ DESTINATION ${pluginInstallPrefix} + OPTIONAL + ) + endif() +@@ -1482,7 +1492,7 @@ function(_pxr_library NAME) + TARGETS ${NAME} + EXPORT pxrTargets + LIBRARY DESTINATION ${libInstallPrefix} +- ARCHIVE DESTINATION ${libInstallPrefix} ++ ARCHIVE DESTINATION ${libInstallPrefixArchive} + RUNTIME DESTINATION ${libInstallPrefix} + ) + endif() diff --git a/ports/usd/013-cmake_export_plugin_as_modules.patch b/ports/usd/013-cmake_export_plugin_as_modules.patch new file mode 100644 index 0000000000..d4820ba0f2 --- /dev/null +++ b/ports/usd/013-cmake_export_plugin_as_modules.patch @@ -0,0 +1,34 @@ +diff --git a/cmake/macros/Private.cmake b/cmake/macros/Private.cmake +index 79fdad022..799ce8801 100644 +--- a/cmake/macros/Private.cmake ++++ b/cmake/macros/Private.cmake +@@ -1238,11 +1238,16 @@ function(_pxr_library NAME) + + else() + # Building an explicitly shared library or plugin. +- add_library(${NAME} +- SHARED +- ${args_CPPFILES} +- ${args_PUBLIC_HEADERS} +- ${args_PRIVATE_HEADERS} ++ if(isPlugin) ++ add_library(${NAME} MODULE) ++ else() ++ add_library(${NAME} SHARED) ++ endif() ++ target_sources(${NAME} ++ PRIVATE ++ ${args_CPPFILES} ++ ${args_PUBLIC_HEADERS} ++ ${args_PRIVATE_HEADERS} + ) + if(PXR_PY_UNDEFINED_DYNAMIC_LOOKUP) + # When not explicitly linking to the python lib we need to allow +@@ -1460,6 +1465,7 @@ function(_pxr_library NAME) + if(isPlugin) + install( + TARGETS ${NAME} ++ EXPORT pxrTargets + LIBRARY DESTINATION ${pluginInstallPrefix} + ARCHIVE DESTINATION ${pluginInstallPrefix} + RUNTIME DESTINATION ${pluginInstallPrefix} diff --git a/ports/usd/014-MaterialX_v1.38-39.patch b/ports/usd/014-MaterialX_v1.38-39.patch new file mode 100644 index 0000000000..0f4797b0b1 --- /dev/null +++ b/ports/usd/014-MaterialX_v1.38-39.patch @@ -0,0 +1,397 @@ +diff --git a/pxr/imaging/hdSt/materialXFilter.cpp b/pxr/imaging/hdSt/materialXFilter.cpp +index 8897c5e72..975017525 100644 +--- a/pxr/imaging/hdSt/materialXFilter.cpp ++++ b/pxr/imaging/hdSt/materialXFilter.cpp +@@ -634,26 +634,48 @@ _GetGlTFSurfaceMaterialTag(HdMaterialNode2 const& terminal) + return materialToken.GetString(); + } + +-static const mx::TypeDesc* ++static const mx::TypeDesc + _GetMxTypeDescription(std::string const& typeName) + { ++#if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION==38 ++ // Add whatever is necessary for current codebase: ++ static const auto _typeLibrary = ++ std::map{ ++ {"float", mx::Type::FLOAT}, ++ {"color3", mx::Type::COLOR3}, ++ {"color4", mx::Type::COLOR4}, ++ {"vector2", mx::Type::VECTOR2}, ++ {"vector3", mx::Type::VECTOR3}, ++ {"vector4", mx::Type::VECTOR4}, ++ {"surfaceshader", mx::Type::SURFACESHADER} ++ }; ++ ++ const auto typeDescIt = _typeLibrary.find(typeName); ++ if (typeDescIt != _typeLibrary.end()) { ++ return *(typeDescIt->second); ++ } ++ ++ return *mx::Type::NONE; ++#else + // Add whatever is necessary for current codebase: +- static const auto _typeLibrary = +- std::map{ +- {"float", mx::Type::FLOAT}, +- {"color3", mx::Type::COLOR3}, +- {"color4", mx::Type::COLOR4}, +- {"vector2", mx::Type::VECTOR2}, +- {"vector3", mx::Type::VECTOR3}, +- {"vector4", mx::Type::VECTOR4}, +- {"surfaceshader", mx::Type::SURFACESHADER} ++ static const auto _typeLibrary = ++ std::map{ ++ {"float", mx::Type::FLOAT}, ++ {"color3", mx::Type::COLOR3}, ++ {"color4", mx::Type::COLOR4}, ++ {"vector2", mx::Type::VECTOR2}, ++ {"vector3", mx::Type::VECTOR3}, ++ {"vector4", mx::Type::VECTOR4}, ++ {"surfaceshader", mx::Type::SURFACESHADER} + }; + + const auto typeDescIt = _typeLibrary.find(typeName); + if (typeDescIt != _typeLibrary.end()) { + return typeDescIt->second; + } +- return nullptr; ++ ++ return mx::Type::NONE; ++#endif + } + + // This function adds a stripped down version of the surfaceshader node to the +@@ -678,32 +700,30 @@ _AddStrippedSurfaceNode( + if (!mxInputDef) { + continue; + } +- auto const* mxTypeDesc = _GetMxTypeDescription(mxInputDef->getType()); +- if (!mxTypeDesc) { ++ auto const mxTypeDesc = _GetMxTypeDescription(mxInputDef->getType()); ++ if (mxTypeIsNone(mxTypeDesc)) { + continue; + } + // If hdNode is connected to the surfaceshader node, recursively call + // this function to make sure that surfaceshader node is added to + // the mxDocument +- if (mxTypeDesc == mx::Type::SURFACESHADER) { ++ if (mxTypeIsSurfaceShader(mxTypeDesc)) { + auto const& hdConnectedPath = connIt.second.front().upstreamNode; + auto const& hdConnectedNode = hdNetwork.nodes.at(hdConnectedPath); + mx::NodePtr mxConnectedNode = + _AddStrippedSurfaceNode(mxDocument, hdConnectedPath.GetName(), + hdConnectedNode, hdNetwork); +- mx::InputPtr mxInput = +- mxNode->addInput(mxInput->getName(), mxInput->getType()); ++ mx::InputPtr mxInput = mxNode->addInputFromNodeDef(mxInputDef->getName()); + mxInput->setConnectedNode(mxConnectedNode); + } + // Add the connection as an input with each component set to 0.5 +- else if (mxTypeDesc->getBaseType() == mx::TypeDesc::BASETYPE_FLOAT && +- mxTypeDesc->getSemantic() != mx::TypeDesc::SEMANTIC_MATRIX) { ++ else if (mxTypeDesc.getBaseType() == mx::TypeDesc::BASETYPE_FLOAT && ++ mxTypeDesc.getSemantic() != mx::TypeDesc::SEMANTIC_MATRIX) { + std::string valueStr = "0.5"; +- for (size_t i = 1; i < mxTypeDesc->getSize(); ++i) { ++ for (size_t i = 1; i < mxTypeDesc.getSize(); ++i) { + valueStr += ", 0.5"; + } +- mx::InputPtr mxInput = +- mxNode->addInput(mxInputDef->getName(), mxInputDef->getType()); ++ mx::InputPtr mxInput = mxNode->addInputFromNodeDef(mxInputDef->getName()); + mxInput->setValueString(valueStr); + } + } +@@ -715,16 +735,15 @@ _AddStrippedSurfaceNode( + if (!mxInputDef) { + continue; + } +- auto const* mxTypeDesc = _GetMxTypeDescription(mxInputDef->getType()); +- if (!mxTypeDesc) { ++ auto const mxTypeDesc = _GetMxTypeDescription(mxInputDef->getType()); ++ if (mxTypeIsNone(mxTypeDesc)) { + continue; + } + +- if (mxTypeDesc->getBaseType() == mx::TypeDesc::BASETYPE_FLOAT && +- mxTypeDesc->getSemantic() != mx::TypeDesc::SEMANTIC_MATRIX) { ++ if (mxTypeDesc.getBaseType() == mx::TypeDesc::BASETYPE_FLOAT && ++ mxTypeDesc.getSemantic() != mx::TypeDesc::SEMANTIC_MATRIX) { + // Add the parameter as an input to the mxNode in the mx Document +- mx::InputPtr mxInput = +- mxNode->addInput(mxInputDef->getName(), mxInputDef->getType()); ++ mx::InputPtr mxInput = mxNode->addInputFromNodeDef(mxInputDef->getName()); + mxInput->setValueString(HdMtlxConvertToString(paramIt.second)); + } + } +@@ -787,9 +806,9 @@ _GetMaterialTag( + // Outputting anything that is not a surfaceshader will be + // considered opaque, unless outputting a color4 or vector4. + // XXX This is not fully per USD specs, but is supported by MaterialX. +- auto const* typeDesc = ++ auto const typeDesc = + _GetMxTypeDescription(activeOutputs.back()->getType()); +- if (typeDesc == mx::Type::COLOR4 || typeDesc == mx::Type::VECTOR4) { ++ if (typeDesc.isFloat4()) { + return HdStMaterialTagTokens->translucent.GetString(); + } + return HdStMaterialTagTokens->defaultMaterialTag.GetString(); +@@ -1100,7 +1119,7 @@ _AddMaterialXParams( + + // MaterialX parameter Information + const auto* variable = paramsBlock[i]; +- const auto varType = variable->getType(); ++ const auto varType = getMxTypeDesc(variable); + + // Create a corresponding HdSt_MaterialParam + HdSt_MaterialParam param; +@@ -1111,9 +1130,9 @@ _AddMaterialXParams( + const auto paramValueIt = + mxParamNameToValue.find(variable->getVariable()); + if (paramValueIt != mxParamNameToValue.end()) { +- if (varType->getBaseType() == mx::TypeDesc::BASETYPE_BOOLEAN || +- varType->getBaseType() == mx::TypeDesc::BASETYPE_FLOAT || +- varType->getBaseType() == mx::TypeDesc::BASETYPE_INTEGER) { ++ if (varType.getBaseType() == mx::TypeDesc::BASETYPE_BOOLEAN || ++ varType.getBaseType() == mx::TypeDesc::BASETYPE_FLOAT || ++ varType.getBaseType() == mx::TypeDesc::BASETYPE_INTEGER) { + param.fallbackValue = paramValueIt->second; + } + } +@@ -1124,52 +1143,52 @@ _AddMaterialXParams( + const auto varValue = variable->getValue(); + std::istringstream valueStream(varValue + ? varValue->getValueString() : std::string()); +- if (varType->getBaseType() == mx::TypeDesc::BASETYPE_BOOLEAN) { ++ if (varType.getBaseType() == mx::TypeDesc::BASETYPE_BOOLEAN) { + const bool val = valueStream.str() == "true"; + param.fallbackValue = VtValue(val); + } +- else if (varType->getBaseType() == mx::TypeDesc::BASETYPE_FLOAT) { +- if (varType->getSize() == 1) { ++ else if (varType.getBaseType() == mx::TypeDesc::BASETYPE_FLOAT) { ++ if (varType.getSize() == 1) { + float val; + valueStream >> val; + param.fallbackValue = VtValue(val); + } +- else if (varType->getSize() == 2) { ++ else if (varType.getSize() == 2) { + GfVec2f val; + valueStream >> val[0] >> separator >> val[1]; + param.fallbackValue = VtValue(val); + } +- else if (varType->getSize() == 3) { ++ else if (varType.getSize() == 3) { + GfVec3f val; + valueStream >> val[0] >> separator >> val[1] >> separator + >> val[2]; + param.fallbackValue = VtValue(val); + } +- else if (varType->getSize() == 4) { ++ else if (varType.getSize() == 4) { + GfVec4f val; + valueStream >> val[0] >> separator >> val[1] >> separator + >> val[2] >> separator >> val[3]; + param.fallbackValue = VtValue(val); + } + } +- else if (varType->getBaseType() == mx::TypeDesc::BASETYPE_INTEGER) { +- if (varType->getSize() == 1) { ++ else if (varType.getBaseType() == mx::TypeDesc::BASETYPE_INTEGER) { ++ if (varType.getSize() == 1) { + int val; + valueStream >> val; + param.fallbackValue = VtValue(val); + } +- else if (varType->getSize() == 2) { ++ else if (varType.getSize() == 2) { + GfVec2i val; + valueStream >> val[0] >> separator >> val[1]; + param.fallbackValue = VtValue(val); + } +- else if (varType->getSize() == 3) { ++ else if (varType.getSize() == 3) { + GfVec3i val; + valueStream >> val[0] >> separator >> val[1] >> separator + >> val[2]; + param.fallbackValue = VtValue(val); + } +- else if (varType->getSize() == 4) { ++ else if (varType.getSize() == 4) { + GfVec4i val; + valueStream >> val[0] >> separator >> val[1] >> separator + >> val[2] >> separator >> val[3]; +@@ -1183,7 +1202,7 @@ _AddMaterialXParams( + } + + // For filename inputs, manage the associated texture node +- if (varType->getSemantic() == mx::TypeDesc::SEMANTIC_FILENAME) { ++ if (varType.getSemantic() == mx::TypeDesc::SEMANTIC_FILENAME) { + // Get the anonymized MaterialX node name from the param name + // annonNodeName_paramName -> annonNodeName + std::string mxNodeName = variable->getVariable(); +diff --git a/pxr/imaging/hdSt/materialXShaderGen.cpp b/pxr/imaging/hdSt/materialXShaderGen.cpp +index 30674b521..78517b39d 100644 +--- a/pxr/imaging/hdSt/materialXShaderGen.cpp ++++ b/pxr/imaging/hdSt/materialXShaderGen.cpp +@@ -156,13 +156,17 @@ HdStMaterialXShaderGen::_EmitGlslfxHeader(mx::ShaderStage& mxStage) const + Base::emitString(R"( "attributes": {)" "\n", mxStage); + std::string line = ""; unsigned int i = 0; + for (mx::StringMap::const_reference primvarPair : _mxHdPrimvarMap) { +- const mx::TypeDesc *mxType = mx::TypeDesc::get(primvarPair.second); +- if (mxType == nullptr) { ++ const mx::TypeDesc mxType = getMxTypeDesc(primvarPair.second); ++ if (mxTypeIsNone(mxType)) { + TF_WARN("MaterialX geomprop '%s' has unknown type '%s'", + primvarPair.first.c_str(), primvarPair.second.c_str()); + } +- const std::string type = mxType +- ? Base::_syntax->getTypeName(mxType) : "vec2"; ++ ++#if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION==38 ++ const std::string type = (!mxTypeIsNone(mxType)) ? Base::_syntax->getTypeName(&mxType) : "vec2"; ++#else ++ const std::string type = (!mxTypeIsNone(mxType)) ? Base::_syntax->getTypeName(mxType) : "vec2"; ++#endif + + line += " \"" + primvarPair.first + "\": {\n"; + line += " \"type\": \"" + type + "\"\n"; +@@ -285,12 +289,15 @@ HdStMaterialXShaderGen::_EmitMxSurfaceShader( + if (outputConnection) { + + std::string finalOutput = outputConnection->getVariable(); ++#if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION==38 ++ // channels feature removed in MaterialX 1.39 + const std::string& channels = outputSocket->getChannels(); + if (!channels.empty()) { + finalOutput = Base::_syntax->getSwizzledVariable( + finalOutput, outputConnection->getType(), + channels, outputSocket->getType()); + } ++#endif + + if (mxGraph.hasClassification( + mx::ShaderNode::Classification::SURFACE)) { +@@ -311,7 +318,7 @@ HdStMaterialXShaderGen::_EmitMxSurfaceShader( + } + } + else { +- if (!outputSocket->getType()->isFloat4()) { ++ if (!getMxTypeDesc(outputSocket).isFloat4()) { + Base::toVec4(outputSocket->getType(), finalOutput); + } + emitLine(finalOutputReturn + +@@ -323,7 +330,7 @@ HdStMaterialXShaderGen::_EmitMxSurfaceShader( + ? Base::_syntax->getValue( + outputSocket->getType(), *outputSocket->getValue()) + : Base::_syntax->getDefaultValue(outputSocket->getType()); +- if (!outputSocket->getType()->isFloat4()) { ++ if (!getMxTypeDesc(outputSocket).isFloat4()) { + std::string finalOutput = outputSocket->getVariable() + "_tmp"; + emitLine(Base::_syntax->getTypeName(outputSocket->getType()) + + " " + finalOutput + " = " + outputValue, mxStage); +@@ -415,8 +422,8 @@ HdStMaterialXShaderGen::_EmitMxInitFunction( + mxStage.getUniformBlock(mx::HW::PUBLIC_UNIFORMS); + for (size_t i = 0; i < paramsBlock.size(); ++i) { + const mx::ShaderPort* variable = paramsBlock[i]; +- const mx::TypeDesc* variableType = variable->getType(); +- if (!_IsHardcodedPublicUniform(*variableType)) { ++ const mx::TypeDesc variableType = getMxTypeDesc(variable); ++ if (!_IsHardcodedPublicUniform(variableType)) { + emitLine(variable->getVariable() + " = HdGet_" + + variable->getVariable() + "()", mxStage); + } +@@ -622,16 +629,16 @@ HdStMaterialXShaderGen::emitVariableDeclarations( + { + Base::emitLineBegin(stage); + const mx::ShaderPort* variable = block[i]; +- const mx::TypeDesc* varType = variable->getType(); ++ const mx::TypeDesc varType = getMxTypeDesc(variable); + + // If bindlessTextures are not enabled the Mx Smpler names are mapped + // to the Hydra equivalents in HdStMaterialXShaderGen*::_EmitMxFunctions +- if (!_bindlessTexturesEnabled && varType == mx::Type::FILENAME) { ++ if (!_bindlessTexturesEnabled && mxTypeDescIsFilename(varType)) { + continue; + } + + // Only declare the variables that we need to initialize with Hd Data +- if ( (isPublicUniform && !_IsHardcodedPublicUniform(*varType)) ++ if ( (isPublicUniform && !_IsHardcodedPublicUniform(varType)) + || MxHdVariables.count(variable->getName()) ) { + Base::emitVariableDeclaration(variable, mx::EMPTY_STRING, + context, stage, false /* assignValue */); +@@ -1349,4 +1356,53 @@ HdStMaterialXShaderGenMsl::_EmitMxFunctions( + } + + ++bool mxTypeIsNone(mx::TypeDesc typeDesc) ++{ ++#if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION==38 ++ return typeDesc == *mx::Type::NONE; ++#else ++ return typeDesc == mx::Type::NONE; ++#endif ++} ++ ++bool mxTypeIsSurfaceShader(mx::TypeDesc typeDesc) ++{ ++#if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION==38 ++ return typeDesc == *mx::Type::SURFACESHADER; ++#else ++ return typeDesc == mx::Type::SURFACESHADER; ++#endif ++} ++ ++bool mxTypeDescIsFilename(const mx::TypeDesc typeDesc) ++{ ++#if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION==38 ++ return typeDesc == *mx::Type::FILENAME; ++#else ++ return typeDesc == mx::Type::FILENAME; ++#endif ++} ++ ++mx::TypeDesc getMxTypeDesc(const std::string& typeName) ++{ ++#if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION==38 ++ const mx::TypeDesc* mxType = mx::TypeDesc::get(typeName); ++ if (mxType) ++ return *mxType; ++ return *mx::Type::NONE; ++#else ++ return mx::TypeDesc::get(typeName); ++#endif ++} ++ ++const MaterialX::TypeDesc getMxTypeDesc(const mx::ShaderPort* port) ++{ ++#if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION==38 ++ return port->getType() ? *(port->getType()) : *mx::Type::NONE; ++#else ++ return port->getType(); ++#endif ++} ++ ++ + PXR_NAMESPACE_CLOSE_SCOPE +diff --git a/pxr/imaging/hdSt/materialXShaderGen.h b/pxr/imaging/hdSt/materialXShaderGen.h +index e61bd13a4..a7f93fdd0 100644 +--- a/pxr/imaging/hdSt/materialXShaderGen.h ++++ b/pxr/imaging/hdSt/materialXShaderGen.h +@@ -192,6 +192,13 @@ private: + MaterialX::ShaderStage& mxStage) const; + }; + ++// helper functions to aid building both MaterialX 1.38.X and 1.39.X ++// once MaterialX 1.38.X is no longer required these should likely be removed. ++bool mxTypeIsNone(MaterialX::TypeDesc typeDesc); ++bool mxTypeIsSurfaceShader(MaterialX::TypeDesc typeDesc); ++bool mxTypeDescIsFilename(const MaterialX::TypeDesc typeDesc); ++MaterialX::TypeDesc getMxTypeDesc(const std::string& typeName); ++const MaterialX::TypeDesc getMxTypeDesc(const MaterialX::ShaderPort* port); + + PXR_NAMESPACE_CLOSE_SCOPE + diff --git a/ports/usd/015-fix_missing_find_dependency_opengl.patch b/ports/usd/015-fix_missing_find_dependency_opengl.patch new file mode 100644 index 0000000000..1f1a94646b --- /dev/null +++ b/ports/usd/015-fix_missing_find_dependency_opengl.patch @@ -0,0 +1,14 @@ +diff --git a/pxr/pxrConfig.cmake.in b/pxr/pxrConfig.cmake.in +index 2aa4a3bd3..2f89d690c 100644 +--- a/pxr/pxrConfig.cmake.in ++++ b/pxr/pxrConfig.cmake.in +@@ -25,6 +25,9 @@ if(@PXR_BUILD_IMAGING@) + if(@PXR_BUILD_OPENIMAGEIO_PLUGIN@) + find_dependency(OpenImageIO CONFIG) + endif() ++ if(@PXR_ENABLE_GL_SUPPORT@) ++ find_dependency(OpenGL REQUIRED) ++ endif() + if(@PXR_ENABLE_VULKAN_SUPPORT@) + if (NOT DEFINED Vulkan_DIR) + if (NOT [[@Vulkan_DIR@]] STREQUAL "") diff --git a/ports/usd/016-TBB-2022.patch b/ports/usd/016-TBB-2022.patch new file mode 100644 index 0000000000..755018ca64 --- /dev/null +++ b/ports/usd/016-TBB-2022.patch @@ -0,0 +1,51 @@ +diff --git a/pxr/base/work/dispatcher.cpp b/pxr/base/work/dispatcher.cpp +index 8cc8dbb..74fba2d 100644 +--- a/pxr/base/work/dispatcher.cpp ++++ b/pxr/base/work/dispatcher.cpp +@@ -31,11 +31,18 @@ WorkDispatcher::WorkDispatcher() + } + + #if TBB_INTERFACE_VERSION_MAJOR >= 12 ++#if TBB_VERSION_MAJOR >= 2022 ++inline tbb::detail::d1::wait_context_vertex& ++WorkDispatcher::_TaskGroup::_GetInternalWaitContext() { ++ return m_wait_vertex; ++} ++#else + inline tbb::detail::d1::wait_context& + WorkDispatcher::_TaskGroup::_GetInternalWaitContext() { + return m_wait_ctx; + } + #endif ++#endif + + WorkDispatcher::~WorkDispatcher() noexcept + { +@@ -54,7 +61,11 @@ WorkDispatcher::Wait() + // The native task_group::wait() has a comment saying its call to the + // context reset method is not thread safe. So we do our own + // synchronization to ensure it is called once. ++#if TBB_VERSION_MAJOR >= 2022 ++ tbb::detail::d1::wait(_taskGroup._GetInternalWaitContext().get_context(), _context); ++#else + tbb::detail::d1::wait(_taskGroup._GetInternalWaitContext(), _context); ++#endif + #else + _rootTask->wait_for_all(); + #endif +diff --git a/pxr/base/work/dispatcher.h b/pxr/base/work/dispatcher.h +index b35bcd8..7d24165 100644 +--- a/pxr/base/work/dispatcher.h ++++ b/pxr/base/work/dispatcher.h +@@ -199,7 +199,11 @@ private: + class _TaskGroup : public tbb::task_group { + public: + _TaskGroup(tbb::task_group_context& ctx) : tbb::task_group(ctx) {} ++#if TBB_VERSION_MAJOR >= 2022 ++ inline tbb::detail::d1::wait_context_vertex& _GetInternalWaitContext(); ++ #else + inline tbb::detail::d1::wait_context& _GetInternalWaitContext(); ++ #endif + }; + + _TaskGroup _taskGroup; diff --git a/ports/usd/fix_build-location.patch b/ports/usd/fix_build-location.patch deleted file mode 100644 index 0dbb8714fe..0000000000 --- a/ports/usd/fix_build-location.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/macros/Private.cmake b/cmake/macros/Private.cmake -index 3825e2a19..0a79b49bd 100644 ---- a/cmake/macros/Private.cmake -+++ b/cmake/macros/Private.cmake -@@ -1238,7 +1238,7 @@ function(_pxr_library NAME) - MFB_PACKAGE_NAME=${PXR_PACKAGE} - MFB_ALT_PACKAGE_NAME=${PXR_PACKAGE} - MFB_PACKAGE_MODULE=${pythonModuleName} -- PXR_BUILD_LOCATION=usd -+ PXR_BUILD_LOCATION=../lib/usd - PXR_PLUGIN_BUILD_LOCATION=../plugin/usd - ${pxrInstallLocation} - ${apiPrivate} diff --git a/ports/usd/portfile.cmake b/ports/usd/portfile.cmake index a1ad27ce62..71f866fa80 100644 --- a/ports/usd/portfile.cmake +++ b/ports/usd/portfile.cmake @@ -1,14 +1,8 @@ -# Don't file if the bin folder exists. We need exe and custom files. -set(VCPKG_POLICY_EMPTY_PACKAGE enabled) +# USD plugins do not produce .lib +set(VCPKG_POLICY_DLLS_WITHOUT_LIBS enabled) -message(STATUS [=[ -The usd port does not work with the version of Threading Building Blocks (tbb) currently chosen by vcpkg's baselines, -and does not expect to be updated to work with current versions soon. See -https://github.com/PixarAnimationStudios/USD/issues/1600 - -If you must use this port in your project, pin a version of tbb of 2020_U3 or older via a manifest file. -See https://vcpkg.io/en/docs/examples/versioning.getting-started.html for instructions. -]=]) +# Proper support for a true static usd build is left as a future port improvement. +vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) string(REGEX REPLACE "^([0-9]+)[.]([0-9])\$" "\\1.0\\2" USD_VERSION "${VERSION}") @@ -16,50 +10,109 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO PixarAnimationStudios/OpenUSD REF "v${USD_VERSION}" - SHA512 e510f6421caba5e74c6efe5b56b17e9c9741ece0cfd5020148ca89b3ac32bd8781ab00dfc7a134163c85af3f4f01f2529a9baa5a9df9b0c80cbca003e6d199e2 - HEAD_REF master + SHA512 7d4404980579c4de3c155386184ca9d2eb96756ef6e090611bae7b4c21ad942c649f73a39b74ad84d0151ce6b9236c4b6c0c555e8e36fdd86304079e1c2e5cbe + HEAD_REF release PATCHES - fix_build-location.patch + 001-fix_rename_find_package_to_find_dependency.patch # See PixarAnimationStudios/OpenUSD#3205 + 002-vcpkg_find_tbb.patch # See PixarAnimationStudios/OpenUSD#3207 + 003-vcpkg_find_opensubdiv.patch + 004-vcpkg_find_openimageio.patch + 005-vcpkg_find_shaderc.patch + 006-vcpkg_find_spirv-reflect.patch + 007-vcpkg_find_vma.patch + 008-fix_cmake_package.patch + 009-fix_cmake_hgi_interop.patch + 010-fix_missing_find_dependency_vulkan.patch + 011-fix_clang8_compiler_error.patch + 012-vcpkg_install_folder_conventions.patch + 013-cmake_export_plugin_as_modules.patch + 014-MaterialX_v1.38-39.patch # PixarAnimationStudios/OpenUSD#3159 + 015-fix_missing_find_dependency_opengl.patch + 016-TBB-2022.patch # Accomodate oneapi-src/oneTBB#1345 changes ) -if(NOT VCPKG_TARGET_IS_WINDOWS) -file(REMOVE ${SOURCE_PATH}/cmake/modules/FindTBB.cmake) +# Changes accompanying 006-vcpkg_find_spirv-reflect.patch +vcpkg_replace_string("${SOURCE_PATH}/pxr/imaging/hgiVulkan/shaderCompiler.cpp" + [[#include "pxr/imaging/hgiVulkan/spirv_reflect.h"]] + [[#include ]] +) +file(REMOVE + "${SOURCE_PATH}/pxr/imaging/hgiVulkan/spirv_reflect.cpp" + "${SOURCE_PATH}/pxr/imaging/hgiVulkan/spirv_reflect.h" +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + materialx PXR_ENABLE_MATERIALX_SUPPORT + metal PXR_ENABLE_METAL_SUPPORT + openimageio PXR_BUILD_OPENIMAGEIO_PLUGIN + vulkan PXR_ENABLE_VULKAN_SUPPORT +) + +if (PXR_ENABLE_MATERIALX_SUPPORT) + list(APPEND FEATURE_OPTIONS "-DMaterialX_DIR=${CURRENT_INSTALLED_DIR}/share/materialx") +endif() + +# hgiInterop Metal and Vulkan backend requires garch which is only enabled if PXR_ENABLE_GL_SUPPORT is ON +if(PXR_ENABLE_VULKAN_SUPPORT OR PXR_ENABLE_METAL_SUPPORT) + list(APPEND FEATURE_OPTIONS "-DPXR_ENABLE_GL_SUPPORT:BOOL=ON") +else() + list(APPEND FEATURE_OPTIONS "-DPXR_ENABLE_GL_SUPPORT:BOOL=OFF") endif() vcpkg_cmake_configure( SOURCE_PATH ${SOURCE_PATH} - OPTIONS - -DPXR_BUILD_ALEMBIC_PLUGIN:BOOL=OFF - -DPXR_BUILD_EMBREE_PLUGIN:BOOL=OFF - -DPXR_BUILD_IMAGING:BOOL=OFF - -DPXR_BUILD_MONOLITHIC:BOOL=OFF - -DPXR_BUILD_TESTS:BOOL=OFF - -DPXR_BUILD_USD_IMAGING:BOOL=OFF - -DPXR_ENABLE_PYTHON_SUPPORT:BOOL=OFF + OPTIONS ${FEATURE_OPTIONS} + -DPXR_BUILD_DOCUMENTATION:BOOL=OFF -DPXR_BUILD_EXAMPLES:BOOL=OFF + -DPXR_BUILD_TESTS:BOOL=OFF -DPXR_BUILD_TUTORIALS:BOOL=OFF -DPXR_BUILD_USD_TOOLS:BOOL=OFF + + -DPXR_BUILD_ALEMBIC_PLUGIN:BOOL=OFF + -DPXR_BUILD_DRACO_PLUGIN:BOOL=OFF + -DPXR_BUILD_EMBREE_PLUGIN:BOOL=OFF + -DPXR_BUILD_PRMAN_PLUGIN:BOOL=OFF + + -DPXR_BUILD_IMAGING:BOOL=ON + -DPXR_BUILD_USD_IMAGING:BOOL=ON + + -DPXR_ENABLE_OPENVDB_SUPPORT:BOOL=OFF + -DPXR_ENABLE_PTEX_SUPPORT:BOOL=OFF + + -DPXR_PREFER_SAFETY_OVER_SPEED:BOOL=ON + + -DPXR_ENABLE_PRECOMPILED_HEADERS:BOOL=OFF + + -DPXR_ENABLE_PYTHON_SUPPORT:BOOL=OFF + -DPXR_USE_DEBUG_PYTHON:BOOL=OFF + MAYBE_UNUSED_VARIABLES + PXR_USE_PYTHON_3 + PYTHON_EXECUTABLE ) vcpkg_cmake_install() +vcpkg_copy_pdbs() -# The CMake files installation is not standard in USD and will install pxrConfig.cmake in the prefix root and -# pxrTargets.cmake in "cmake" so we are moving pxrConfig.cmake in the same folder and patch the path to pxrTargets.cmake -vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/pxrConfig.cmake "/cmake/pxrTargets.cmake" "/pxrTargets.cmake") +# Handle debug path for USD plugins +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + file(GLOB_RECURSE debug_targets + "${CURRENT_PACKAGES_DIR}/debug/share/pxr/*-debug.cmake" + ) + foreach(debug_target IN LISTS debug_targets) + file(READ "${debug_target}" contents) + string(REPLACE "\${_IMPORT_PREFIX}/usd" "\${_IMPORT_PREFIX}/debug/usd" contents "${contents}") + string(REPLACE "\${_IMPORT_PREFIX}/plugin" "\${_IMPORT_PREFIX}/debug/plugin" contents "${contents}") + file(WRITE "${debug_target}" "${contents}") + endforeach() +endif() -file( - RENAME - "${CURRENT_PACKAGES_DIR}/pxrConfig.cmake" - "${CURRENT_PACKAGES_DIR}/cmake/pxrConfig.cmake") +vcpkg_cmake_config_fixup(PACKAGE_NAME "pxr") -vcpkg_cmake_config_fixup(CONFIG_PATH cmake PACKAGE_NAME pxr) - -# Remove duplicates in debug folder -file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/pxrConfig.cmake) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) - -# Handle copyright -vcpkg_install_copyright(FILE_LIST ${SOURCE_PATH}/LICENSE.txt) +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" +) if(VCPKG_TARGET_IS_WINDOWS) # Move all dlls to bin @@ -72,8 +125,6 @@ if(VCPKG_TARGET_IS_WINDOWS) file(RENAME ${CURRENT_FROM} ${CURRENT_TO}) endforeach() - vcpkg_copy_pdbs() - function(file_replace_regex filename match_string replace_string) file(READ ${filename} _contents) string(REGEX REPLACE "${match_string}" "${replace_string}" _contents "${_contents}") @@ -91,3 +142,6 @@ if(VCPKG_TARGET_IS_WINDOWS) file_replace_regex(${PLUGINFO} [=["LibraryPath": "../../([a-zA-Z0-9_]+).dll"]=] [=["LibraryPath": "../../../bin/\1.dll"]=]) endforeach() endif() + +# Handle copyright +vcpkg_install_copyright(FILE_LIST ${SOURCE_PATH}/LICENSE.txt) diff --git a/ports/usd/vcpkg.json b/ports/usd/vcpkg.json index 439153976b..041c309b43 100644 --- a/ports/usd/vcpkg.json +++ b/ports/usd/vcpkg.json @@ -1,22 +1,12 @@ { "name": "usd", - "version": "24.5", + "version": "24.8", "description": "Universal Scene Description (USD) is an efficient, scalable system for authoring, reading, and streaming time-sampled scene description for interchange between graphics applications.", "homepage": "https://github.com/PixarAnimationStudios/USD", "license": null, "supports": "!x86 & !arm & !android", "dependencies": [ - "boost-assign", - "boost-crc", - "boost-date-time", - "boost-filesystem", - "boost-format", - "boost-multi-index", - "boost-program-options", - "boost-regex", - "boost-system", - "boost-variant", - "boost-vmd", + "opensubdiv", "tbb", { "name": "vcpkg-cmake", @@ -27,5 +17,46 @@ "host": true }, "zlib" - ] + ], + "features": { + "materialx": { + "description": "Enable MaterialX support", + "dependencies": [ + { + "name": "materialx", + "features": [ + "glsl-generator", + "render" + ] + } + ] + }, + "metal": { + "description": "Enable Metal based components", + "supports": "osx" + }, + "openimageio": { + "description": "Build OpenImageIO plugin", + "dependencies": [ + "openimageio" + ] + }, + "vulkan": { + "description": "Enable Vulkan based components", + "dependencies": [ + "opengl", + { + "name": "opensubdiv", + "default-features": false, + "features": [ + "opengl" + ] + }, + "shaderc", + "spirv-reflect", + "vulkan", + "vulkan-memory-allocator" + ] + } + } } diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 985a5beb97..bcfa262894 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -1109,16 +1109,8 @@ tvision:arm-neon-android=fail tvision:arm64-android=fail tvision:x64-android=fail unicorn:x64-windows-static-md=fail -# USD has set official policy that they will not update to be compatible with TBB in the near term (https://github.com/PixarAnimationStudios/USD/issues/1600) -usd:arm64-windows=skip -usd:arm64-uwp=skip -usd:x64-uwp=skip -usd:x64-windows=skip +# Proper support for a true static usd build is left as a future port improvement. It probably require fiddling with its monolithic mode. usd:x64-windows-static=skip -usd:x64-windows-static-md=skip -usd:x64-linux=skip -usd:x64-osx=skip -usd:x86-windows=skip # needs android-24 usrsctp:arm-neon-android=fail usrsctp:arm64-android=fail diff --git a/versions/baseline.json b/versions/baseline.json index 62c98bab65..a898a9549d 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -9241,7 +9241,7 @@ "port-version": 1 }, "usd": { - "baseline": "24.5", + "baseline": "24.8", "port-version": 0 }, "usearch": { diff --git a/versions/u-/usd.json b/versions/u-/usd.json index 952c8e5de2..257030cff1 100644 --- a/versions/u-/usd.json +++ b/versions/u-/usd.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "ead0e855944ba468f8f3e4cc4f1875ae14e2bbc1", + "version": "24.8", + "port-version": 0 + }, { "git-tree": "4c153b9f60e4a0f694dac0575011b99556c31084", "version": "24.5",