Skip to main content

nvidia_nrd/
stub.rs

1#[cfg(feature = "vk-graph")]
2use vk_graph::driver::device::Device;
3
4use {
5    crate::{Frame, Resources},
6    ash::vk,
7};
8
9pub struct Nrd;
10
11impl Nrd {
12    /// Creates a runtime retaining the graph device until this runtime is dropped.
13    ///
14    /// # Errors
15    /// Always returns an error because the native backend is unavailable.
16    ///
17    /// # Safety
18    ///
19    /// The queue family, enabled extensions, and synchronization must satisfy
20    /// [`Self::from_raw`]. Device ownership does not establish these requirements.
21    #[cfg(feature = "vk-graph")]
22    pub unsafe fn new(_: &Device, _: u32) -> anyhow::Result<Self> {
23        anyhow::bail!("nrd is unavailable on this target")
24    }
25
26    /// Creates a runtime borrowing raw Vulkan handles without taking ownership.
27    ///
28    /// # Errors
29    /// Always returns an error because the native backend is unavailable.
30    ///
31    /// # Safety
32    ///
33    /// The device must belong to the physical device and instance. All handles must remain
34    /// valid until [`Self::shutdown`] returns. `queue_family_index` must identify a graphics
35    /// and compute capable family with queue 0 created on the device; command buffers passed
36    /// to [`Self::evaluate`] must belong to that family. The caller must externally synchronize
37    /// queue access and NRD work. `api_version` must be standard Vulkan 1.3 or later,
38    /// enabled for the instance and supported by the device. Enable the extensions and
39    /// device features documented in [`Self::required_device_extensions`].
40    /// Complete all NRD GPU work before resolution changes or shutdown, and call
41    /// shutdown before destroying the device or instance. Dropping alone leaks the native context.
42    pub unsafe fn from_raw(
43        _: vk::Instance,
44        _: vk::PhysicalDevice,
45        _: vk::Device,
46        _: u32,
47        _: u32,
48    ) -> anyhow::Result<Self> {
49        anyhow::bail!("nrd is unavailable on this target")
50    }
51
52    /// Records RELAX SH work into an active command buffer.
53    ///
54    /// Inputs must declare `SHADER_READ_ONLY_OPTIMAL`, and outputs `GENERAL`.
55    ///
56    /// # Errors
57    /// Always returns an error because the native backend is unavailable; no slot
58    /// is consumed. With a native backend, pre-FFI errors do not consume slots,
59    /// but failures after `NewFrame` can. Errors do not reliably indicate native
60    /// advancement; follow [`crate::QUEUED_EVALUATIONS`] even when calls fail.
61    ///
62    /// # Safety
63    ///
64    /// All images must belong to this instance's device and remain alive until execution completes.
65    /// Transition them to their declared layouts and synchronize prior writes for compute shader
66    /// sampled reads (inputs) or storage reads/writes (outputs) before NRD executes.
67    /// NRD restores the declared layouts after its dispatches.
68    /// Before each call, retire all older work according to
69    /// [`crate::QUEUED_EVALUATIONS`], counting every call including errors, not
70    /// `frame.frame_index`. Do not infer native slot indices from this count.
71    /// The caller must synchronize shutdown and resolution changes with
72    /// all previously submitted NRD work.
73    /// The command buffer must be recording on the device and queue family supplied at creation.
74    pub unsafe fn evaluate(
75        &mut self,
76        _: vk::CommandBuffer,
77        _: &Frame,
78        _: &Resources,
79    ) -> anyhow::Result<()> {
80        anyhow::bail!("nrd is unavailable on this target")
81    }
82
83    /// Destroys the native context after all submitted work has completed.
84    ///
85    /// # Safety
86    ///
87    /// The Vulkan device must be idle with respect to every NRD dispatch.
88    pub unsafe fn shutdown(&mut self) {}
89}