NRI is a modular, extensible, low-level abstract rendering interface that was designed to support all low-level features of D3D12 and Vulkan GAPIs. At the same time, it aims to simplify usage and reduce the amount of code needed (especially compared with VK).
Goals:
- Generalization and unification of D3D12 (spec) and VK (spec)
- Explicitness (providing access to low-level features of modern GAPIs)
- Quality-of-life and high-level extensions (e.g., streaming and upscaling)
- Low overhead
- Cross-platform and platform independence (AMD/INTEL friendly)
- D3D11 support (spec) (as much as possible)
Non-goals:
- Exposing entities not existing in GAPIs
- High-level (D3D11-like) abstraction
- Hidden management of any kind (except for some high-level extensions where it's desired)
- Automatic barriers (better handled in a higher-level abstraction)
Supported GAPIs:
- Vulkan
- D3D12
- D3D11
- Metal (through MoltenVK)
- None / dummy (everything is supported but does nothing)
There is NVRHI, which offers a D3D11-like abstraction layer, implying some overhead. There is vkd3d-proton, which was designed for D3D12 emulation using Vulkan. There is nvpro-samples, which explores all "dark corners" of Vulkan usage, but does not offer any cross-API support. There are some other good, unmentioned projects, but NRI was designed to offer a reasonably simple, low-overhead, and high-performance render interface suitable for game development, professional rendering and hobby projects. Additionally, NRI can serve as a middleware for integrations. For instance, the NRD integration layer is based on NRI, unifying multiple GAPI support within a single codebase.
- C++ and C compatible interfaces
- generalized common denominator for D3D12, VK and D3D11
- low overhead
- no memory allocations at runtime
- descriptor indexing support
- ray tracing support
- mesh shaders support
- D3D12 Ultimate features support, including enhanced barriers
- VK printf support
- validation layers (GAPI- and NRI- provided)
- user provided memory allocator support
- default D3D11 behavior is changed to match D3D12/VK using NVAPI or AMD AGS libraries, where applicable
- supporting as much as possible VK-enabled platforms: Windows, Linux, MacOS, Android
- debug names and annotations for CPU and GPU timelines (GAPI, NVTX and PIX, if "WinPixEventRuntime.dll" is nearby)
- can be used as a shared or static library
Available interfaces:
NRI.h
- core functionalityNRIDeviceCreation.h
- device creation and related functionalityNRIHelper.h
- a collection of various helpers to ease use of the core interfaceNRIImgui.h
- a light-weight ImGui renderer (no ImGui dependency)NRILowLatency.h
- low latency support (aka NVIDIA REFLEX)NRIMeshShader.h
- mesh shadersNRIRayTracing.h
- ray tracingNRIResourceAllocator.h
- convenient creation of resources using AMD Virtual Memory Allocator, which get returned already bound to memoryNRIStreamer.h
- a convenient way to stream data into resourcesNRISwapChain.h
- swap chain and related functionalityNRIUpscaler.h
- a configurable collection of common upscalers (NIS, FSR, DLSS-SR, DLSS-RR)
Repository organization:
- there is only
main
branch used for development - stable versions are in
Releases
section
Required Vulkan extensions:
- for Vulkan 1.2:
- VK_KHR_synchronization2
- VK_KHR_dynamic_rendering
- VK_KHR_copy_commands2
- VK_EXT_extended_dynamic_state
- for APPLE:
- VK_KHR_portability_enumeration (instance extension)
- VK_KHR_get_physical_device_properties2 (instance extension)
- VK_KHR_portability_subset
Supported Vulkan extensions:
- Instance:
- VK_KHR_get_surface_capabilities2
- VK_KHR_surface
- VK_KHR_win32_surface (VK_KHR_xlib_surface, VK_KHR_wayland_surface, VK_EXT_metal_surface)
- VK_EXT_swapchain_colorspace
- VK_EXT_debug_utils
- Device:
- VK_KHR_swapchain
- VK_KHR_present_id
- VK_KHR_present_wait
- VK_KHR_swapchain_mutable_format
- VK_KHR_maintenance4 (for Vulkan 1.2)
- VK_KHR_maintenance5
- VK_KHR_maintenance6
- VK_KHR_maintenance7
- VK_KHR_maintenance8
- VK_KHR_maintenance9
- VK_KHR_fragment_shading_rate
- VK_KHR_push_descriptor
- VK_KHR_pipeline_library
- VK_KHR_ray_tracing_pipeline
- VK_KHR_acceleration_structure (depends on VK_KHR_deferred_host_operations)
- VK_KHR_ray_query
- VK_KHR_ray_tracing_position_fetch
- VK_KHR_ray_tracing_maintenance1
- VK_KHR_line_rasterization
- VK_KHR_fragment_shader_barycentric
- VK_KHR_shader_clock
- VK_KHR_compute_shader_derivatives
- VK_EXT_swapchain_maintenance1
- VK_EXT_present_mode_fifo_latest_ready
- VK_EXT_opacity_micromap
- VK_EXT_sample_locations
- VK_EXT_conservative_rasterization
- VK_EXT_mesh_shader
- VK_EXT_shader_atomic_float
- VK_EXT_shader_atomic_float2
- VK_EXT_memory_budget
- VK_EXT_memory_priority
- VK_EXT_image_sliced_view_of_3d
- VK_EXT_custom_border_color
- VK_EXT_image_robustness (for Vulkan 1.2)
- VK_EXT_robustness2
- VK_EXT_pipeline_robustness
- VK_EXT_fragment_shader_interlock
- VK_NV_low_latency2
- VK_NVX_binary_import
- VK_NVX_image_view_handle
- Install Cmake 3.30+
- Build (variant 1) - using Git and CMake explicitly
- Clone project and init submodules
- Generate and build the project using CMake
- To build the binary with static MSVC runtime, add
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>"
parameter when deploying the project
- Build (variant 2) - by running scripts:
- Run
1-Deploy
- Run
2-Build
- Run
Notes:
- Xlib and Wayland can be both enabled
- Minimal supported client is Windows 8.1+. Windows 7 support requires minimal effort and can be added by request
NRI_AGILITY_SDK_DIR
- Directory where Agility SDK will be copied relative to the directory with binariesNRI_AGILITY_SDK_VERSION_MAJOR
- Agility SDK major versionNRI_AGILITY_SDK_VERSION_MINOR
- Agility SDK minor versionNRI_SHADERS_PATH
- Shader output path overrideNRI_STATIC_LIBRARY
- Build static libraryNRI_ENABLE_NVTX_SUPPORT
- Annotations for NVIDIA Nsight SystemsNRI_ENABLE_DEBUG_NAMES_AND_ANNOTATIONS
- Enable debug names, host and device annotationsNRI_ENABLE_NONE_SUPPORT
- Enable NONE backendNRI_ENABLE_VK_SUPPORT
- Enable Vulkan backendNRI_ENABLE_VALIDATION_SUPPORT
- Enable Validation backend (otherwiseenableNRIValidation
is ignored)NRI_ENABLE_NIS_SDK
- Enable NVIDIA Image Sharpening SDKNRI_ENABLE_IMGUI_EXTENSION
- EnableNRIImgui
extensionNRI_ENABLE_D3D11_SUPPORT
- Enable D3D11 backendNRI_ENABLE_D3D12_SUPPORT
- Enable D3D12 backendNRI_ENABLE_D3D_EXTENSIONS
- Enable vendor specific extension libraries for D3D (NVAPI and AMD AGS)NRI_ENABLE_AGILITY_SDK_SUPPORT
- Enable Agility SDK support to unlock access to latest D3D12 featuresNRI_ENABLE_XLIB_SUPPORT
- Enable X11 supportNRI_ENABLE_WAYLAND_SUPPORT
- Enable Wayland supportNRI_ENABLE_NGX_SDK
- Enable NVIDIA NGX (DLSS) SDKNRI_ENABLE_FFX_SDK
- Enable AMD FidelityFX SDKNRI_ENABLE_XESS_SDK
- Enable INTEL XeSS SDK
Overview and Download sections can be found here.
D3D12 backend uses Agility SDK to get access to most recent D3D12 features. It's highly recommended to use it.
Steps (already enabled by default):
- modify
NRI_AGILITY_SDK_VERSION_MAJOR
andNRI_AGILITY_SDK_VERSION_MINOR
to the desired value - enable or disable
NRI_ENABLE_AGILITY_SDK_SUPPORT
- re-deploy project
- include auto-generated
NRIAgilitySDK.h
header in the code of your executable using NRI
- main sample demonstrating path tracing best practices
- DeviceInfo - queries and prints out information about device groups in the system
- Clear - minimal example of rendering using framebuffer clears only
- CTest - very simple example of C interface usage
- Triangle - simple textured triangle rendering (also multiview demonstration in FLEXIBLE mode)
- SceneViewer - loading & rendering of meshes with materials (also tests programmable sample locations, shading rate and pipeline statistics)
- BindlessSceneViewer - bindless GPU-driven rendering test
- Readback - getting data from the GPU back to the CPU
- AsyncCompute - demonstrates parallel execution of graphic and compute workloads
- MultiThreading - shows advantages of multi-threaded command buffer recording
- Multiview - multiview demonstration in LAYER_BASED mode (VK and D3D12 compatible)
- MultiGPU - multi GPU example
- RayTracingTriangle - simple triangle rendering through ray tracing
- RayTracingBoxes - a more advanced ray tracing example with many BLASes in TLAS
- Wrapper - shows how to wrap native D3D11/D3D12/VK objects into NRI entities
- Resize - demonstrates window resize
C++ | C |
---|---|
nri::Interface |
NriInterface |
nri::Enum::MEMBER |
NriEnum_MEMBER |
nri::CONST |
NRI_CONST |
nri::nriFunction |
nriFunction |
nri::Function |
nriFunction |
Reference & |
Pointer * |
NRI | D3D11 | D3D12 | VK |
---|---|---|---|
Device |
ID3D11Device |
ID3D12Device |
VkDevice |
CommandBuffer |
ID3D11DeviceContext (deferred) |
ID3D12CommandList |
VkCommandBuffer |
CommandQueue |
ID3D11DeviceContext (immediate) |
ID3D12CommandQueue |
VkQueue |
Fence |
ID3D11Fence |
ID3D12Fence |
VkSemaphore (timeline) |
CommandAllocator |
N/A | ID3D12CommandAllocator |
VkCommandPool |
Buffer |
ID3D11Buffer |
ID3D12Resource |
VkBuffer |
Texture |
ID3D11Texture |
ID3D12Resource |
VkImage |
Memory |
N/A | ID3D12Heap |
VkDeviceMemory |
Descriptor |
ID3D11*View or ID3D11SamplerState |
D3D12_CPU_DESCRIPTOR_HANDLE |
Vk*View or VkSampler |
DescriptorSet |
N/A | N/A | VkDescriptorSet |
DescriptorPool |
N/A | ID3D12DescriptorHeap |
VkDescriptorPool |
PipelineLayout |
N/A | ID3D12RootSignature |
VkPipelineLayout |
Pipeline |
ID3D11*Shader and ID3D11*State |
ID3D12StateObject |
VkPipeline |
AccelerationStructure |
N/A | ID3D12Resource |
VkAccelerationStructure |
NRI is licensed under the MIT License.