dust-engine / nrd-sys

Rust FFI for NVIDIA Realtime Denoiser
Apache License 2.0
2 stars 1 forks source link

nrd-sys

Rust bindings for the NVIDIA Real Time Denoisers SDK, targeting Vulkan applications.

NVIDIA Real-Time Denoisers (NRD) is a spatio-temporal API agnostic denoising library. The library has been designed to work with low rpp (ray per pixel) signals. NRD is a fast solution that slightly depends on input signals and environment conditions.

Supports both Windows and Linux. Pre-compiled binaries are automatically downloaded and linked.

The binaries are compiled from a custom NRD fork, which is necessary to make the SDK work better with Rust. The fork contains the following changes:

Usage

fn main() {
    let lib_desc = nrd_sys::Instance::library_desc();

    let id1 = nrd_sys::Identifier(0);
    let mut instance = nrd_sys::Instance::new(&[nrd_sys::DenoiserDesc {
        identifier: id1,
        denoiser: nrd_sys::Denoiser::ReblurDiffuse,
        render_width: 100,
        render_height: 100,
    }])
    .unwrap();
    let desc = instance.desc();

    instance
        .set_common_settings(&nrd_sys::CommonSettings::default())
        .unwrap();
    instance
        .set_denoiser_settings(id1, &nrd_sys::ReferenceSettings::default())
        .unwrap();

    let dispatches = instance.get_compute_dispatches(&[id1]).unwrap();

    // Now, make API calls based on `dispatches`
}

Note

The pre-compiled binaries included with this package only contains SPIR-V shader. If you need DXIL / DXBC shader for DirectX integration, feel free to make that a Cargo feature and create a PR.