Skip to content

Engine → RHI → device.h

device

Syntax

class CONJURE_API device

Constructors

AccessSignatureDescription
publicexplicit device( create_tag);

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~device();

Variables

AccessNameTypeDefaultDescription
privatemImplstd::unique_ptr<impl>{}

Functions

Public

backend

[[nodiscard]] graphics_backend backend() const noexcept;

The backend this device runs on.

capabilities

[[nodiscard]] const device_capabilities &capabilities() const noexcept;

Adapter name, limits and queue availability of the created device.

create

[[nodiscard]] static core::result<std::unique_ptr<device>> create(
    const device_desc &desc);

Creates the NVRHI device for the requested backend. Fails with core::error_code::UNSUPPORTED when the backend is not compiled in, rhi_error::INVALID_DESC when the description is inconsistent (backend out of range, GPU validation without the debug layer, nullMsaaSampleCounts failing is_valid_msaa_sample_counts, a null device with nullMaxTextureDimension2d 0), and rhi_error::DEVICE_CREATION_FAILED when the API refuses (its message is quoted).

desc

[[nodiscard]] const device_desc &desc() const noexcept;

The description the device was created from.

inject_null_fault

void inject_null_fault(
    null_fault fault,
    u32 matchingCallsToSkip = 0);

Arms one failure on the null backend (null_fault): the first matchingCallsToSkip calls that match it succeed, the next one reports it and disarms. Arming replaces any failure still armed; NONE disarms without a failure. No effect on D3D12 and Vulkan.

is_lost

[[nodiscard]] bool is_lost() const noexcept;

True once the API reported device removal or NVRHI raised a Fatal message. Every later present fails with rhi_error::DEVICE_LOST; the owner must recreate everything.

native_device

[[nodiscard]] nvrhi::IDevice *native_device() const noexcept;

Non-owning NVRHI device for in-engine modules. Never exposed to game code.

null_stats

[[nodiscard]] std::optional<null_device_stats> null_stats() const;

Snapshot of what the null backend recorded; nullopt on D3D12 and Vulkan.

reset_null_stats

void reset_null_stats();

Resets the null backend's counters; no effect on other backends.

run_garbage_collection

void run_garbage_collection();

Releases the resources of command lists that finished executing. Call once per frame.

simulate_device_loss

void simulate_device_loss();

Behaves as if the API reported device removal: routes a Fatal message through the message callback so is_lost() becomes true. Exists for the engine's device-loss tests on every backend.

wait_idle

void wait_idle();

Blocks until the GPU is idle. A failed wait marks the device lost.