Table of Contents

Class DXGIAdapterEnumerator

Namespace
VisioForge.Core.Windows
Assembly
VisioForge.Core.dll

Enumerates DXGI graphics adapters on Windows and maps LUIDs to CUDA device ordinals. Returns an empty list and null translations on non-Windows platforms.

public static class DXGIAdapterEnumerator

Inheritance

Inherited Members

Methods

Enumerate()

Enumerates hardware and software graphics adapters visible to DXGI. Results are cached for the lifetime of the process; call VisioForge.Core.Windows.DXGIAdapterEnumerator.Invalidate to refresh after a device hotplug.

public static IReadOnlyList<EncoderAdapterInfo> Enumerate()

Returns

IReadOnlyList<EncoderAdapterInfo>

Invalidate()

Drops the cached adapter list so the next VisioForge.Core.Windows.DXGIAdapterEnumerator.Enumerate call re-queries DXGI. Use sparingly; DXGI enumeration allocates native handles.

public static void Invalidate()

LuidToCudaDeviceId(long)

Translates a DXGI adapter LUID to a CUDA device ordinal suitable for the cuda-device-id property of an NVENC element that exposes it writable - nvautogpuh264enc / nvautogpuh265enc / nvautogpuav1enc here, not the plain nvh264enc / nvh265enc / nvav1enc, where the property is read-only. Returns null if the LUID does not map to a non-software NVIDIA adapter on this host.

public static uint? LuidToCudaDeviceId(long luid)

Parameters

luid long

Returns

uint?

Remarks

Best-effort heuristic. This method does NOT query CUDA or NVML — it simply walks the DXGI adapter list and returns the enumeration index of the matching NVIDIA adapter. On single-NVIDIA-GPU systems this typically matches the CUDA device ordinal, but on multi-NVIDIA-GPU rigs the DXGI enumeration order is not guaranteed to match CUDA's ordinal order (CUDA can reorder devices based on compute capability, CUDA_VISIBLE_DEVICES, driver version, and other factors).

A guess is not precise enough to pin a session, so VisioForge.Core.Types.X.VideoEncoders.NVENCBaseEncoderSettings.AdapterLuid uses VisioForge.Core.Windows.DXGIAdapterEnumerator.LuidToCudaDeviceIdExact(System.Int64) instead, which asks CUDA itself (issue #5162).

LuidToCudaDeviceIdExact(long)

Resolves a DXGI adapter LUID to the CUDA device ordinal by asking the CUDA driver (nvcuda.dll): every CUDA device is read with cuDeviceGetLuid and its 8-byte LUID compared with the one DXGI reports. Exact on a machine with several NVIDIA GPUs, unlike VisioForge.Core.Windows.DXGIAdapterEnumerator.LuidToCudaDeviceId(System.Int64), whose DXGI order is only a proxy for the CUDA ordinal.

public static uint? LuidToCudaDeviceIdExact(long luid)

Parameters

luid long

Returns

uint?

The CUDA device ordinal, or null when nvcuda.dll is unavailable, CUDA cannot initialize, or no CUDA device reports this LUID.