@@ -750,15 +750,33 @@ void SwapChainProcessor::RunCore()
750750 ERR (" IddCxSwapChainSetDevice failed, screen = %d, err = %s\n " , m_screen_num, err);
751751 return ;
752752 }
753- if (IDD_IS_FUNCTION_AVAILABLE (IddCxSetRealtimeGPUPriority))
754- {
755- IDARG_IN_SETREALTIMEGPUPRIORITY SetPriority = {};
756- SetPriority.pDevice = DxgiDevice.Get ();
757- hr = IddCxSetRealtimeGPUPriority (m_hSwapChain, &SetPriority);
758- if (FAILED (hr)) {
759- ERR (" IddCxSetRealtimeGPUPriority failed\n " );
753+ DWORD gpuDeviceId = GetGpuDeviceId ();
754+ if (gpuDeviceId != 0 )
755+ DBGPRINT (" GPU PCI Device ID: 0x%04X\n " , gpuDeviceId);
756+ else
757+ DBGPRINT (" No GPU PCI Device ID found.\n " );
758+
759+ switch (gpuDeviceId) {
760+ case DEV_ID_7D40:
761+ case DEV_ID_7D45:
762+ case DEV_ID_7D55:
763+ case DEV_ID_7D60:
764+ case DEV_ID_7D67:
765+ case DEV_ID_7DD5:
766+ DBGPRINT (" IddCxSetRealtimeGPUPriority skipped" );
767+ break ;
768+ default :
769+ DBGPRINT (" IddCxSetRealtimeGPUPriority engaged" );
770+ if (IDD_IS_FUNCTION_AVAILABLE (IddCxSetRealtimeGPUPriority)) {
771+ IDARG_IN_SETREALTIMEGPUPRIORITY SetPriority = {};
772+ SetPriority.pDevice = DxgiDevice.Get ();
773+ hr = IddCxSetRealtimeGPUPriority (m_hSwapChain, &SetPriority);
774+ if (FAILED (hr)) {
775+ ERR (" IddCxSetRealtimeGPUPriority failed\n " );
776+ }
777+ }
778+ break ;
760779 }
761- }
762780
763781 // reset the resolution flag whenever there is a resolution change
764782 m_resolution_changed = TRUE ;
@@ -1995,4 +2013,54 @@ bool IsWindows11OrLater()
19952013 return true ;
19962014}
19972015
2016+ DWORD GetGpuDeviceId ()
2017+ {
2018+ HDEVINFO deviceInfoSet = SetupDiGetClassDevs (&GUID_DEVCLASS_DISPLAY, nullptr , nullptr , DIGCF_PRESENT);
2019+ if (deviceInfoSet == INVALID_HANDLE_VALUE) {
2020+ ERR (" SetupDiGetClassDevs failed.\n " );
2021+ return 0 ;
2022+ }
2023+
2024+ DWORD deviceIdFromPci = 0 ;
2025+ SP_DEVINFO_DATA deviceInfoData = {};
2026+ deviceInfoData.cbSize = sizeof (SP_DEVINFO_DATA);
2027+
2028+ std::regex deviceIdRegex (DEVICE_ID_REGEX_PATTERN);
2029+ std::smatch match;
2030+
2031+ for (DWORD i = 0 ; i < MAX_ENUM_ATTEMPTS; ++i) {
2032+ if (!SetupDiEnumDeviceInfo (deviceInfoSet, i, &deviceInfoData))
2033+ break ;
2034+
2035+ TCHAR deviceInstanceId[MAX_DEVICE_ID_LEN];
2036+ if (CM_Get_Device_ID (deviceInfoData.DevInst , deviceInstanceId, MAX_DEVICE_ID_LEN, 0 ) == CR_SUCCESS) {
2037+ std::wstring instanceId (deviceInstanceId);
2038+
2039+ // Convert wide string to UTF-8
2040+ int size_needed = WideCharToMultiByte (CP_UTF8, 0 , instanceId.c_str (), -1 , nullptr , 0 , nullptr , nullptr );
2041+ std::string instanceIdStr (size_needed, 0 );
2042+ WideCharToMultiByte (CP_UTF8, 0 , instanceId.c_str (), -1 , &instanceIdStr[0 ], size_needed, nullptr , nullptr );
2043+
2044+
2045+ if (std::regex_search (instanceIdStr, match, deviceIdRegex)) {
2046+ try {
2047+ deviceIdFromPci = std::stoul (match[1 ].str (), nullptr , 16 );
2048+ // Validate range (for safety, PCI Device IDs are 16-bit)
2049+ if (deviceIdFromPci > 0xFFFF ) {
2050+ ERR (" Invalid Device ID extracted: 0x%08X\n " , deviceIdFromPci);
2051+ deviceIdFromPci = 0 ;
2052+ }
2053+ break ;
2054+ }
2055+ catch (const std::exception&) {
2056+ ERR (" Error parsing Device ID from string: %s\n " , match[1 ].str ().c_str ());
2057+ }
2058+ }
2059+ }
2060+ }
2061+
2062+ SetupDiDestroyDeviceInfoList (deviceInfoSet);
2063+
2064+ return deviceIdFromPci;
2065+ }
19982066#pragma endregion
0 commit comments