[nvrhi] New port. (#51041)

This commit is contained in:
MatthewBeshay 2026-04-10 11:21:52 +10:00 committed by GitHub
parent 4497409a47
commit 5d00b6f2b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 148 additions and 0 deletions

View File

@ -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$<$<CONFIG:Debug>:Debug>")
+ if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
+ set_property(TARGET nvrhi PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+ endif()
endif()
if (NVRHI_WITH_VALIDATION)
@@ -220,7 +230,7 @@ endif()
target_include_directories(nvrhi PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
- $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>)
+ $<INSTALL_INTERFACE: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")

View File

@ -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}")

12
ports/nvrhi/usage Normal file
View File

@ -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)

23
ports/nvrhi/vcpkg.json Normal file
View File

@ -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"
]
}

View File

@ -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

9
versions/n-/nvrhi.json Normal file
View File

@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "b355711be2fb5c423ab2381046b5f929477c8d7b",
"version-date": "2026-02-26",
"port-version": 0
}
]
}