NVIDIAGameWorks / nvrhi

MIT License
846 stars 97 forks source link

NVRHI

Build Status

Introduction

NVRHI (NVIDIA Rendering Hardware Interface) is a library that implements a common abstraction layer over multiple graphics APIs (GAPIs): Direct3D 11, Direct3D 12, and Vulkan 1.2. It works on Windows (x64 only) and Linux (x64 and ARM64).

Key features:

NVRHI is used in several NVIDIA GameWorks SDKs:

Notable third-party projects using NVRHI:

Various early versions of NVRHI have been used in various projects created at NVIDIA, including:

Requirements

Building NVRHI

NVRHI can be configured to be used a set of static libraries in CMake-based projects, or as a single dynamic library.

To include NVRHI into a CMake project as static libraries:

  1. Add this repository as a submodule.
  2. Add a add_subdirectory(nvrhi) directive to the parent CMakeLists.txt.
  3. Add dependencies to the necessary targets:
    • nvrhi for the interface headers, common utilities, and validation;
    • nvrhi_d3d11 for DX11 (enabled when NVRHI_WITH_DX11 is ON);
    • nvrhi_d3d12 for DX12 (enabled when NVRHI_WITH_DX12 is ON); and
    • nvrhi_vk for Vulkan (enabled when NVRHI_WITH_VULKAN is ON).

To build NVRHI as a shared library (DLL or .so):

  1. Clone this repository recursively (including submodules).
  2. Generate the project with CMake:
    • Set the NVRHI_BUILD_SHARED variable to ON.
    • Make sure to set the target platform to a 64-bit one. 32-bit builds are not supported.
  3. Build and install as normal.

Using NVRHI in Applications

See the programming guide and the tutorial.

NVAPI Support

NVRHI includes optional support for certain DX11 and DX12 extensions available through the NVAPI library. The library is not distributed with NVRHI but is available separately here.

To enable NVAPI support, extract the NVAPI SDK into the nvapi subfolder of your main project and set the NVRHI_WITH_NVAPI CMake variable to ON.

The following extensions are supported:

RTXMU Integration

NVRHI includes an optional integration of the RTXMU library. The library is included as a git submodule, and can be enabled with the NVRHI_WITH_RTXMU CMake variable.

When RTXMU integration is enabled, all bottom-level ray tracing acceleration structures (BLAS'es) are managed by that library. All built BLAS'es that have the AllowCompaction flag set are automatically compacted when ICommandList::compactBottomLevelAccelStructs method is called. No other configuration is necessary.

License

NVRHI is licensed under the MIT License.