From 34b522bd3f7fc7b701fd9f69d2eb6298d75adf1d Mon Sep 17 00:00:00 2001 From: MatthewBeshay <92357869+MatthewBeshay@users.noreply.github.com> Date: Wed, 8 Apr 2026 11:50:09 +1000 Subject: [PATCH] [nvrhi] add new port --- ports/nvrhi/fix-vcpkg-deps.patch | 69 ++++++++++++++++++++++++++++++++ ports/nvrhi/portfile.cmake | 31 ++++++++++++++ ports/nvrhi/usage | 12 ++++++ ports/nvrhi/vcpkg.json | 23 +++++++++++ versions/baseline.json | 4 ++ versions/n-/nvrhi.json | 9 +++++ 6 files changed, 148 insertions(+) create mode 100644 ports/nvrhi/fix-vcpkg-deps.patch create mode 100644 ports/nvrhi/portfile.cmake create mode 100644 ports/nvrhi/usage create mode 100644 ports/nvrhi/vcpkg.json create mode 100644 versions/n-/nvrhi.json diff --git a/ports/nvrhi/fix-vcpkg-deps.patch b/ports/nvrhi/fix-vcpkg-deps.patch new file mode 100644 index 00000000000000..525ced44cc43c5 --- /dev/null +++ b/ports/nvrhi/fix-vcpkg-deps.patch @@ -0,0 +1,69 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5d1797e..7cfb05b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -61,10 +61,18 @@ endif() + + set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + ++if (NVRHI_WITH_VULKAN AND NOT TARGET Vulkan-Headers AND NOT TARGET Vulkan::Headers) ++ find_package(VulkanHeaders CONFIG QUIET) ++endif() ++ + if (NVRHI_WITH_VULKAN AND NOT TARGET Vulkan-Headers AND NOT TARGET Vulkan::Headers) + add_subdirectory(thirdparty/Vulkan-Headers) + endif() + ++if(NVRHI_WITH_DX12 AND NOT TARGET DirectX-Headers AND NOT TARGET Microsoft::DirectX-Headers) ++ find_package(directx-headers CONFIG QUIET) ++endif() ++ + if(NVRHI_WITH_DX12 AND NOT TARGET DirectX-Headers AND NOT TARGET Microsoft::DirectX-Headers) + add_subdirectory(thirdparty/DirectX-Headers) + endif() +@@ -209,7 +217,9 @@ if (NVRHI_BUILD_SHARED) + if(NVRHI_WITH_VULKAN) + target_compile_definitions(nvrhi PRIVATE VULKAN_HPP_STORAGE_SHARED VULKAN_HPP_STORAGE_SHARED_EXPORT) + endif() +- set_property(TARGET nvrhi PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") ++ if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) ++ set_property(TARGET nvrhi PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") ++ endif() + endif() + + if (NVRHI_WITH_VALIDATION) +@@ -220,7 +230,7 @@ endif() + + target_include_directories(nvrhi PUBLIC + $ +- $/include>) ++ $) + + set_target_properties(nvrhi PROPERTIES FOLDER "NVRHI") + +@@ -388,4 +398,4 @@ if (NVRHI_INSTALL) + EXPORT_LINK_INTERFACE_LIBRARIES + DESTINATION "${nvrhi_CONFIG_PATH}") + endif() +-endif() +\ No newline at end of file ++endif() +diff --git a/src/nvrhiConfig.cmake.in b/src/nvrhiConfig.cmake.in +index f9ff79d..6de08c5 100644 +--- a/src/nvrhiConfig.cmake.in ++++ b/src/nvrhiConfig.cmake.in +@@ -19,4 +19,14 @@ + # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + # DEALINGS IN THE SOFTWARE. + ++include(CMakeFindDependencyMacro) ++ ++if(@NVRHI_WITH_VULKAN@) ++ find_dependency(VulkanHeaders CONFIG) ++endif() ++ ++if(@NVRHI_WITH_DX12@) ++ find_dependency(directx-headers CONFIG) ++endif() ++ + include("${CMAKE_CURRENT_LIST_DIR}/nvrhiTargets.cmake") diff --git a/ports/nvrhi/portfile.cmake b/ports/nvrhi/portfile.cmake new file mode 100644 index 00000000000000..7759c44b901b5d --- /dev/null +++ b/ports/nvrhi/portfile.cmake @@ -0,0 +1,31 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO NVIDIA-RTX/NVRHI + REF 54100464714de88a5a5059d25808f5ccb914ad7d + SHA512 56d5de1cc0840e29d8df976a5fe7b13d676c110ba24c09ff5e0caaa73f4aa56cc78d2ec2c31b1cb8da9f5b099c8b8598410792f8343a77ba928da28ba8146b1f + HEAD_REF main + PATCHES + fix-vcpkg-deps.patch +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DNVRHI_INSTALL=ON + -DNVRHI_INSTALL_EXPORTS=ON + -DNVRHI_WITH_NVAPI=OFF + -DNVRHI_WITH_AFTERMATH=OFF + -DNVRHI_WITH_RTXMU=OFF +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/nvrhi") +vcpkg_copy_pdbs() + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" +) + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/ports/nvrhi/usage b/ports/nvrhi/usage new file mode 100644 index 00000000000000..1de1ca8d8baad4 --- /dev/null +++ b/ports/nvrhi/usage @@ -0,0 +1,12 @@ +The package exports CMake targets from `find_package(nvrhi CONFIG REQUIRED)`. + +Static builds install one interface/common target plus backend libraries: + + target_link_libraries(main PRIVATE nvrhi nvrhi_d3d11 nvrhi_d3d12 nvrhi_vk) + +Link only the backend targets you actually use on the current platform. On Linux, +only `nvrhi` and `nvrhi_vk` are relevant. + +Shared builds install a single `nvrhi` target with the enabled backends compiled in: + + target_link_libraries(main PRIVATE nvrhi) diff --git a/ports/nvrhi/vcpkg.json b/ports/nvrhi/vcpkg.json new file mode 100644 index 00000000000000..f2c41f159e0219 --- /dev/null +++ b/ports/nvrhi/vcpkg.json @@ -0,0 +1,23 @@ +{ + "name": "nvrhi", + "version-date": "2026-02-26", + "description": "NVIDIA Rendering Hardware Interface abstraction layer for D3D11, D3D12, and Vulkan", + "homepage": "https://github.com/NVIDIA-RTX/NVRHI", + "license": "MIT", + "supports": "(windows & x64 & !uwp & !xbox) | (linux & (x64 | arm64))", + "dependencies": [ + { + "name": "directx-headers", + "platform": "windows" + }, + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + }, + "vulkan-headers" + ] +} diff --git a/versions/baseline.json b/versions/baseline.json index 0f5afb1c386617..a5bf84c207c364 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -7096,6 +7096,10 @@ "baseline": "4.3.5", "port-version": 0 }, + "nvrhi": { + "baseline": "2026-02-26", + "port-version": 0 + }, "nvtt": { "baseline": "2.1.2", "port-version": 9 diff --git a/versions/n-/nvrhi.json b/versions/n-/nvrhi.json new file mode 100644 index 00000000000000..391bc61c938544 --- /dev/null +++ b/versions/n-/nvrhi.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "b355711be2fb5c423ab2381046b5f929477c8d7b", + "version-date": "2026-02-26", + "port-version": 0 + } + ] +}