@@ -1661,6 +1661,86 @@ def InstallAnimX(context, force, buildArgs):
16611661
16621662ANIMX = Dependency ("AnimX" , InstallAnimX , "include/animx.h" )
16631663
1664+ ############################################################
1665+ # Vulkan SDK components
1666+ VULKAN_SDK_VERSION = "1.3.296.0"
1667+
1668+ VULKAN_HEADERS_URL = f"https://github.com/KhronosGroup/Vulkan-Headers/archive/refs/tags/vulkan-sdk-{ VULKAN_SDK_VERSION } .zip"
1669+ def InstallVulkanHeaders (context , force , buildArgs ):
1670+ with CurrentWorkingDirectory (DownloadURL (VULKAN_HEADERS_URL , context , force , destFileName = f'Vulkan-Headers-{ VULKAN_SDK_VERSION } .zip' )):
1671+ extraArgs = buildArgs + [
1672+ '-DVULKAN_HEADERS_ENABLE_INSTALL=ON' ,
1673+ '-DVULKAN_HEADERS_ENABLE_MODULE=OFF' ,
1674+ '-DVULKAN_HEADERS_ENABLE_TESTS=OFF' ,
1675+ ]
1676+ RunCMake (context , force , extraArgs )
1677+
1678+ VULKAN_HEADERS = Dependency ("Vulkan-Headers" , InstallVulkanHeaders , "include/vulkan/vulkan.h" )
1679+
1680+ VULKAN_UTILITY_LIBRARIES_URL = f"https://github.com/KhronosGroup/Vulkan-Utility-Libraries/archive/refs/tags/vulkan-sdk-{ VULKAN_SDK_VERSION } .zip"
1681+ def InstallVulkanUtilityLibraries (context , force , buildArgs ):
1682+ with CurrentWorkingDirectory (DownloadURL (VULKAN_UTILITY_LIBRARIES_URL , context , force , destFileName = f'Vulkan-Utility-Libraries-{ VULKAN_SDK_VERSION } .zip' )):
1683+ extraArgs = buildArgs + [
1684+ '-DBUILD_TESTS=OFF' ,
1685+ ]
1686+ RunCMake (context , force , extraArgs )
1687+
1688+ VULKAN_UTILITY_LIBRARIES = Dependency ("Vulkan-Utility-Libraries" , InstallVulkanUtilityLibraries , "include/vulkan/vk_enum_string_helper.h" )
1689+
1690+ VULKAN_LOADER_URL = f"https://github.com/KhronosGroup/Vulkan-Loader/archive/refs/tags/vulkan-sdk-{ VULKAN_SDK_VERSION } .zip"
1691+ def InstallLoaderVulkan (context , force , buildArgs ):
1692+ with CurrentWorkingDirectory (DownloadURL (VULKAN_LOADER_URL , context , force , destFileName = f'Vulkan-Loader-{ VULKAN_SDK_VERSION } .zip' )):
1693+ extraArgs = buildArgs + [
1694+ f'-DVULKAN_HEADERS_INSTALL_DIR={ context .instDir } ' ,
1695+ '-DBUILD_TESTS=OFF' ,
1696+ '-UPDATE_DEPS=ON' ,
1697+ ]
1698+ RunCMake (context , force , extraArgs )
1699+
1700+ VULKAN_LOADER = Dependency ("Vulkan-Loader" , InstallLoaderVulkan , "lib/cmake/VulkanLoader/VulkanLoaderConfig.cmake" )
1701+
1702+ # The VulkanMemoryAllocator version should match the one used by VULKAN_SDK_VERSION
1703+ VULKAN_MEMORY_ALLOCATOR_VERSION = "3.2.1"
1704+ VULKAN_MEMORY_ALLOCATOR_URL = f"https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/archive/refs/tags/v{ VULKAN_MEMORY_ALLOCATOR_VERSION } .zip"
1705+ def InstallVulkanMemoryAllocator (context , force , buildArgs ):
1706+ with CurrentWorkingDirectory (DownloadURL (VULKAN_MEMORY_ALLOCATOR_URL , context , force , destFileName = f'VulkanMemoryAllocator-{ VULKAN_MEMORY_ALLOCATOR_VERSION } .zip' )):
1707+ extraArgs = buildArgs + [
1708+ '-DVMA_ENABLE_INSTALL=ON' ,
1709+ '-DVMA_BUILD_SAMPLES=OFF' ,
1710+ '-DVMA_BUILD_DOCUMENTATION=OFF' ,
1711+ ]
1712+ RunCMake (context , force , extraArgs )
1713+
1714+ VULKAN_MEMORY_ALLOCATOR = Dependency ("VulkanMemoryAllocator" , InstallVulkanMemoryAllocator , "include/vk_mem_alloc.h" )
1715+
1716+ # The shaderc version should match the one used by VULKAN_SDK_VERSION
1717+ SHADERC_VERSION = "2024.3"
1718+ SHADERC_URL = f"https://github.com/google/shaderc/archive/refs/tags/v{ SHADERC_VERSION } .zip"
1719+ def InstallShaderC (context , force , buildArgs ):
1720+ with CurrentWorkingDirectory (DownloadURL (SHADERC_URL , context , force , destFileName = f'shaderc-{ SHADERC_VERSION } .zip' )):
1721+ Run (f'"{ sys .executable } " utils/git-sync-deps' )
1722+ PatchFile ("third_party/CMakeLists.txt" , [
1723+ ('set( SKIP_GLSLANG_INSTALL ${SHADERC_SKIP_INSTALL} )\n ' ,
1724+ 'set( SKIP_GLSLANG_INSTALL ON )\n ' ),
1725+ ('set( SKIP_SPIRV_TOOLS_INSTALL ${SHADERC_SKIP_INSTALL} )\n ' ,
1726+ 'set( SKIP_SPIRV_TOOLS_INSTALL ON )\n ' ),
1727+ ('set( SKIP_GOOGLETEST_INSTALL ${SHADERC_SKIP_INSTALL} )\n ' ,
1728+ 'set( SKIP_GOOGLETEST_INSTALL ON} )\n ' ),
1729+ (' set(GLSLANG_ENABLE_INSTALL $<NOT:${SKIP_GLSLANG_INSTALL}>)\n ' ,
1730+ ' set(GLSLANG_ENABLE_INSTALL OFF)\n ' ),
1731+ ])
1732+ extraArgs = buildArgs + [
1733+ '-DSHADERC_SKIP_INSTALL=OFF' ,
1734+ '-DSHADERC_SKIP_TESTS=ON' ,
1735+ '-DSHADERC_SKIP_EXAMPLES=ON' ,
1736+ '-DSHADERC_SKIP_COPYRIGHT_CHECK=ON' ,
1737+ '-DSHADERC_ENABLE_SHARED_CRT=ON' ,
1738+ '-DSHADERC_ENABLE_WGSL_OUTPUT=OFF' ,
1739+ ]
1740+ RunCMake (context , force , extraArgs )
1741+
1742+ SHADERC = Dependency ("shaderc" , InstallShaderC , "include/shaderc/shaderc.h" )
1743+
16641744
16651745############################################################
16661746# USD
@@ -2177,6 +2257,14 @@ def InstallUSD(context, force, buildArgs):
21772257 default = False , help = "Enable Vulkan support" )
21782258subgroup .add_argument ("--no-vulkan" , dest = "enable_vulkan" , action = "store_false" ,
21792259 help = "Disable Vulkan support (default)" )
2260+ group .add_argument ("--use-vulkan-sdk" , dest = "use_vulkan_sdk" , type = str ,
2261+ nargs = '?' , default = None , const = '' ,
2262+ help = "Use the Vulkan SDK to build HgiVulkan, "
2263+ "otherwise the necessary components will be "
2264+ "installed automactically be the script. "
2265+ "The argument optionally takes a path to the "
2266+ "SDK root, otherwise the VULKAN_SDK environment "
2267+ "variable is required to be set." )
21802268
21812269group = parser .add_argument_group (title = "Imaging Plugin Options" )
21822270subgroup = group .add_mutually_exclusive_group ()
@@ -2404,6 +2492,7 @@ def __init__(self, args):
24042492 self .enableVulkan = (self .buildImaging
24052493 and args .enable_vulkan
24062494 and not embedded )
2495+ self .useVuklanSDK = args .use_vulkan_sdk
24072496
24082497 # - USD Imaging
24092498 self .buildUsdImaging = (args .build_imaging == USD_IMAGING and
@@ -2520,6 +2609,24 @@ def ForceBuildDependency(self, dep):
25202609if context .buildUsdview :
25212610 requiredDependencies += [PYOPENGL , PYSIDE ]
25222611
2612+ if context .enableVulkan :
2613+ if context .useVuklanSDK is None :
2614+ # We don't want to use the Vulkan SDK, we build our own components.
2615+ os .environ .pop ('VULKAN_SDK' , None )
2616+ requiredDependencies += [VULKAN_HEADERS , VULKAN_UTILITY_LIBRARIES ,
2617+ VULKAN_LOADER , VULKAN_MEMORY_ALLOCATOR ,
2618+ SHADERC ]
2619+ elif context .useVuklanSDK == '' :
2620+ # We use the Vulkan SDK from the environment
2621+ if not 'VULKAN_SDK' in os .environ :
2622+ PrintError ("Vulkan support cannot be enabled when VULKAN_SDK "
2623+ "environment variable is not set" )
2624+ sys .exit (1 )
2625+ context .useVuklanSDK = os .environ ['VULKAN_SDK' ]
2626+ else :
2627+ # We use the Vulkan SDK from the command line
2628+ os .environ ['VULKAN_SDK' ] = context .useVuklanSDK
2629+
25232630if context .buildAnimXTests :
25242631 requiredDependencies += [ANIMX ]
25252632
@@ -2546,12 +2653,6 @@ def ForceBuildDependency(self, dep):
25462653 PrintError ("Windows ARM64 builds require oneTBB. Enable via the --onetbb argument" )
25472654 sys .exit (1 )
25482655
2549- # Error out if user enables Vulkan support but env var VULKAN_SDK is not set.
2550- if context .enableVulkan and not 'VULKAN_SDK' in os .environ :
2551- PrintError ("Vulkan support cannot be enabled when VULKAN_SDK environment "
2552- "variable is not set" )
2553- sys .exit (1 )
2554-
25552656if context .targetWasm :
25562657 if "--no-onetbb" in sys .argv :
25572658 PrintError ("Wasm target requires oneTBB" )
@@ -2776,6 +2877,14 @@ def _JoinVersion(v):
27762877 Embree support: {buildEmbree}
27772878 PRMan support: {buildPrman}
27782879 Vulkan support: {enableVulkan}
2880+ """
2881+
2882+ if context .enableVulkan and context .useVuklanSDK :
2883+ summaryMsg += """\
2884+ Vulkan SDK: {useVuklanSDK}
2885+ """
2886+
2887+ summaryMsg += """\
27792888 UsdImaging {buildUsdImaging}
27802889 usdview: {buildUsdview}
27812890 MaterialX support {buildMaterialX}
@@ -2866,6 +2975,7 @@ def FormatBuildArguments(buildArgs):
28662975 buildExamples = ("On" if context .buildExamples else "Off" ),
28672976 buildTutorials = ("On" if context .buildTutorials else "Off" ),
28682977 enableVulkan = ("On" if context .enableVulkan else "Off" ),
2978+ useVuklanSDK = context .useVuklanSDK ,
28692979 buildTools = ("On" if context .buildTools else "Off" ),
28702980 buildUsdValidation = ("On" if context .buildUsdValidation else "Off" ),
28712981 buildAlembic = ("On" if context .buildAlembic else "Off" ),
0 commit comments