Add intel vram sensors (#2077)

* Add Intel Arc VRAM sensors support

- Implement BDF-based device matching for Intel discrete GPUs
- Add VRAM sensors (total, used, free, load percentage)
- Use D3D device enumeration with fallback logic
- Enable Windows-specific VRAM monitoring for Intel Arc GPUs
- Fix device identification to distinguish between multiple identical GPUs

Resolves issue where both Intel Arc GPUs showed identical VRAM values.
Now each GPU displays unique, accurate memory usage statistics.

* Add defensive validation to GetBdfFromDeviceIdentifier

- Add null/empty check for deviceIdentifier parameter
- Return false explicitly when LastIndexOf('#') returns -1
- Add DEVPROPTYPE.DEVPROP_TYPE_UINT32 validation after property queries
- Use sizeof(uint) instead of hardcoded 4 for buffer sizes
- Apply PCI spec bit masks (5-bit device, 3-bit function)
- Add bus range validation (0-255)

* Revert to Windows DEVPKEY_Device_Address spec masks

Use 0xFFFF masks as per Windows documentation instead of PCI spec
bit widths. The Windows API uses full 16-bit fields for device and
function numbers.

* Update IntelDiscreteGpu.cs

* Update NativeMethods.txt

---------

Co-authored-by: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com>
This commit is contained in:
David Renelt
2025-11-28 21:54:04 +01:00
committed by GitHub
co-authored by PhyxionNL
parent 6bb1c627e1
commit a792c26891
2 changed files with 105 additions and 6 deletions
@@ -17,6 +17,8 @@ SetupDiDestroyDeviceInfoList
SetupDiGetDeviceInterfaceDetail
SetupDiEnumDeviceInterfaces
SetupDiGetClassDevs
SP_DEVICE_INTERFACE_DATA
SP_DEVICE_INTERFACE_DETAIL_DATA_W
GUID_DEVICE_BATTERY
WIN32_ERROR
HRESULT_FROM_WIN32
@@ -42,3 +44,8 @@ LoadLibrary
FreeLibrary
GetProcAddress
BATTERY_UNKNOWN_*
CM_Locate_DevNode
CM_Get_DevNode_Property
CM_LOCATE_DEVNODE_FLAGS
DEVPKEY_Device_BusNumber
DEVPKEY_Device_Address