How to detect if enable Hardware-Accelerated GPU Scheduling

Kevin Loong 1 Reputation point
2022-11-22T09:30:25.033+00:00

Hi All,

I want to use code to check whether Windows 11 has enable the Hardware-Accelerated GPU Scheduling.
I have tried to check the registry key HwSchMode, but found that it does not exist by default!
Is there any related interface API to detect it?

Thank you very much in advance for the answer!

Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | C++
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 90,686 Reputation points
    2022-11-22T15:33:52.23+00:00

    Maybe you can test with D3DKMTQueryAdapterInfo

    I did a test but I don't have this option on my OS (Windows 10 21H1, no real graphic card) =>

                {  
                    LPGUID Guid = (LPGUID)&GUID_DISPLAY_DEVICE_ARRIVAL;  
                    HDEVINFO hDI = SetupDiGetClassDevs(Guid, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);  
                    if (INVALID_HANDLE_VALUE != hDI)  
                    {  
                        SP_DEVINFO_DATA DeviceInfoData;  
                        DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);  
                        for (DWORD dwDeviceIndex = 0; SetupDiEnumDeviceInfo(hDI, dwDeviceIndex, &DeviceInfoData); dwDeviceIndex++)  
                        {  
                            SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;  
                            DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);  
                            for (DWORD dwMemberIndex = 0; SetupDiEnumDeviceInterfaces(hDI, &DeviceInfoData, Guid, dwMemberIndex, &DeviceInterfaceData); dwMemberIndex++)  
                            {  
                                DWORD dwDeviceInterfaceDetailDataSize = offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA, DevicePath) + MAX_PATH * sizeof(TCHAR);  
                                PSP_DEVICE_INTERFACE_DETAIL_DATA pDeviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)new BYTE[dwDeviceInterfaceDetailDataSize];  
                                pDeviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);  
                                if (SetupDiGetDeviceInterfaceDetail(hDI, &DeviceInterfaceData, pDeviceInterfaceDetailData, dwDeviceInterfaceDetailDataSize, NULL, NULL))  
                                {  
                                    CONFIGRET cRet;  
                                    WCHAR wsText[MAX_PATH] = L"";  
                                    DEVINST hDevInst = DeviceInfoData.DevInst;  
                                    DEVINST hParentDevInst;  
                                    TCHAR wsDeviceID[MAX_DEVICE_ID_LEN];  
                                    cRet = CM_Get_Device_ID(hDevInst, wsDeviceID, sizeof(wsDeviceID) / sizeof(TCHAR), 0);  
                                    if (cRet == CR_SUCCESS)  
                                    {  
                                        wsprintf(wsText, L"DeviceID : %s\r\n", wsDeviceID);  
                                        OutputDebugString(wsText);  
    
                                        wsprintf(wsText, L"\tDevice Path : %s\r\n", pDeviceInterfaceDetailData->DevicePath);  
                                        OutputDebugString(wsText);  
                                    }  
                                    cRet = CM_Get_Parent(&hParentDevInst, hDevInst, 0);  
                                    if (cRet == CR_SUCCESS)  
                                    {  
                                        TCHAR wsParentDeviceID[MAX_DEVICE_ID_LEN];  
                                        cRet = CM_Get_Device_ID(hParentDevInst, wsParentDeviceID, sizeof(wsParentDeviceID) / sizeof(TCHAR), 0);  
                                        if (cRet == CR_SUCCESS)  
                                        {  
                                            wsprintf(wsText, L"\tParent DeviceID : %s\r\n", wsParentDeviceID);  
                                            OutputDebugString(wsText);  
                                        }  
                                    }  
    
                                    // #include <D3dkmthk.h>  
                                    D3DKMT_OPENADAPTERFROMDEVICENAME oafdn;  
                                    ZeroMemory(&oafdn, sizeof(oafdn));  
                                    oafdn.pDeviceName = pDeviceInterfaceDetailData->DevicePath;  
                                    NTSTATUS Status;  
                                    Status = D3DKMTOpenAdapterFromDeviceName(&oafdn);  
                                    if (Status == 0)  
                                    {  
                                        D3DKMT_QUERYADAPTERINFO qai;  
                                        D3DKMT_WDDM_2_7_CAPS caps;  
                                        //D3DKMT_WDDM_1_2_CAPS caps;  
                                        ZeroMemory(&qai, sizeof(qai));  
                                        ZeroMemory(&caps, sizeof(caps));  
                                        qai.hAdapter = oafdn.hAdapter;  
                                        qai.Type = KMTQAITYPE_WDDM_2_7_CAPS;  
                                        //qai.Type = KMTQAITYPE_WDDM_1_2_CAPS;  
                                        qai.pPrivateDriverData = (void*)&caps;  
                                        qai.PrivateDriverDataSize = sizeof(caps);  
                                        // Status = 0xc000000d STATUS_INVALID_PARAMETER  
                                        Status = D3DKMTQueryAdapterInfo(&qai);  
                                        if (Status == 0)  
                                        {  
                                            wsprintf(wsText, L"\tHardware-accelerated GPU scheduling Support : %d\r\n", caps.HwSchSupported);  
                                            OutputDebugString(wsText);  
                                            wsprintf(wsText, L"\tHardware-accelerated GPU scheduling Enabled : %d\r\n", caps.HwSchEnabled);  
                                            OutputDebugString(wsText);  
                                        }  
    
                                        D3DKMT_CLOSEADAPTER ca;  
                                        ca.hAdapter = oafdn.hAdapter;  
                                        D3DKMTCloseAdapter(&ca);  
                                    }  
                                }  
                                delete[] pDeviceInterfaceDetailData;  
                            }  
                        }  
                        SetupDiDestroyDeviceInfoList(hDI);  
                    }                      
                }  
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.