Class DxgiUtil

java.lang.Object
oshi.driver.common.windows.gpu.DxgiUtil

@ThreadSafe public final class DxgiUtil extends Object
Shared utility methods for DXGI adapter matching and related parsing. Contains no native code.
  • Method Details

    • 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:

      1. Vendor ID + Device ID (exact, both non-zero)
      2. Normalized name match (case-insensitive, ignoring (R), (TM), extra spaces)
      Parameters:
      adapters - list of adapters
      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 registry DriverDesc value
      Returns:
      best-matching adapter, or null
    • registryValueToVram

      public static long registryValueToVram(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. REG_BINARY is interpreted as little-endian.
      Parameters:
      value - the registry value object
      Returns:
      the VRAM size in bytes, or 0 if the value type is unrecognised
    • normalizeName

      public static String normalizeName(String name)
      Normalizes an adapter name for fuzzy matching: lower-case, strips (R)/(TM), collapses whitespace.
      Parameters:
      name - the raw adapter name, may be null
      Returns:
      normalized name, never null
    • buildLuidPrefix

      public static String buildLuidPrefix(DxgiAdapterInfo adapter)
      Builds the PDH LUID instance prefix for the given DXGI adapter. The prefix has the form luid_0xHHHHHHHH_0xLLLLLLLL_phys_0.
      Parameters:
      adapter - the DXGI adapter info containing the LUID
      Returns:
      PDH LUID instance prefix string, or empty string if the LUID is zero
    • parsePciBusNumber

      public static int parsePciBusNumber(String locationInfo)
      Parses the PCI bus number from a Windows registry LocationInformation string of the form "PCI bus N, device N, function N".
      Parameters:
      locationInfo - the LocationInformation registry value
      Returns:
      PCI bus number, or -1 if not parseable
    • parsePciDevice

      public static int parsePciDevice(String locationInfo)
      Parses the PCI device number from a Windows registry LocationInformation string.
      Parameters:
      locationInfo - the LocationInformation registry value
      Returns:
      PCI device number, or -1 if not parseable
    • parsePciFunction

      public static int parsePciFunction(String locationInfo)
      Parses the PCI function number from a Windows registry LocationInformation string.
      Parameters:
      locationInfo - the LocationInformation registry value
      Returns:
      PCI function number, or -1 if not parseable
    • buildPciBusId

      public static String buildPciBusId(String locationInfo)
      Builds a PCI bus ID string in "0000:BB:DD.F" format from a Windows registry LocationInformation string.
      Parameters:
      locationInfo - the LocationInformation registry value
      Returns:
      PCI bus ID string, or empty string if not parseable