Class WindowsDxgi
java.lang.Object
oshi.jna.platform.windows.WindowsDxgi
Minimal JNA binding to
dxgi.dll for enumerating display adapters and reading
DXGI_ADAPTER_DESC.DedicatedVideoMemory.
DXGI is the authoritative Windows API for dedicated GPU memory. It is not subject to the 2 GiB cap that affects the
32-bit registry value HardwareInformation.MemorySize.
COM vtable layout used here:
IUnknown (vtable slots 0-2): QueryInterface, AddRef, Release
IDXGIObject (slots 3-6): SetPrivateData, SetPrivateDataInterface, GetPrivateData, GetParent
IDXGIFactory (slots 7-13): EnumAdapters, MakeWindowAssociation, GetWindowAssociation,
CreateSwapChain, CreateSoftwareAdapter, (IDXGIFactory1 adds 2 more)
IDXGIAdapter (slots 3-5 on adapter): EnumOutputs, GetDesc, CheckInterfaceSupport
This class should be considered non-API as it may be removed if/when its code is incorporated into the JNA project.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMaps to the WindowsDXGI_ADAPTER_DESCstructure. -
Method Summary
Modifier and TypeMethodDescriptionstatic DxgiAdapterInfofindMatch(List<DxgiAdapterInfo> adapters, int vendorId, int deviceId, String adapterName) Finds the best-matching DXGI adapter for a given vendor ID, device ID, and adapter name.static StringnormalizeName(String name) Normalizes an adapter name for fuzzy matching: lower-case, strips(R)/(TM), collapses whitespace.static List<DxgiAdapterInfo> Enumerates all DXGI display adapters and returns their identity and dedicated video memory.static longregistryValueToVram(Object value) Converts a registry value (REG_QWORD as Long, REG_DWORD as Integer, or REG_BINARY as byte[]) to a VRAM size in bytes.
-
Method Details
-
queryAdapters
Enumerates all DXGI display adapters and returns their identity and dedicated video memory.Fails gracefully: if
dxgi.dllis unavailable or any COM call fails, returns an empty list so callers can fall back to registry-based detection.- Returns:
- list of
DxgiAdapterInfo, one per adapter; empty if DXGI is unavailable
-
findMatch
public static DxgiAdapterInfo findMatch(List<DxgiAdapterInfo> adapters, int vendorId, int deviceId, String adapterName) Finds the best-matching DXGI adapter for a given vendor ID, device ID, and adapter name.Matching priority:
- Vendor ID + Device ID (exact, both non-zero)
- Normalized name match (case-insensitive, ignoring
(R),(TM), extra spaces)
If multiple adapters share the same vendor+device ID (e.g. multi-GPU), the first one is returned. If no confident match is found, returns
null.- Parameters:
adapters- list fromqueryAdapters()vendorId- PCI vendor ID parsed from the registry key (0 if unknown)deviceId- PCI device ID parsed from the registry key (0 if unknown)adapterName- adapter name from the registryDriverDescvalue- Returns:
- best-matching adapter, or
null
-
registryValueToVram
Converts a registry value (REG_QWORD as Long, REG_DWORD as Integer, or REG_BINARY as byte[]) to a VRAM size in bytes. REG_BINARY is interpreted as little-endian.Exposed as public for testing.
- Parameters:
value- the registry value object- Returns:
- the VRAM size in bytes, or 0 if the value type is unrecognised
-
normalizeName
-