diff --git a/src/detection/gpu/adl.h b/src/detection/gpu/adl.h index 45c2313ca..eac46852e 100644 --- a/src/detection/gpu/adl.h +++ b/src/detection/gpu/adl.h @@ -11,7 +11,7 @@ extern int ADL2_Main_Control_Create(ADL_MAIN_MALLOC_CALLBACK callback, int iEnum extern int ADL2_Main_Control_Destroy(ADL_CONTEXT_HANDLE context); // Retrieves adapter information for given adapter or all OS-known adapters. -// Return 1 on success +// Return ADL_OK on success, DESPITE THE OFFICIAL DOCUMENT SAYS IT RETURNS 1 FOR SUCCESS! extern int ADL2_Adapter_AdapterInfoX3_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* numAdapters, AdapterInfo** lppAdapterInfo); // Function to retrieve Graphic Core Info. @@ -34,6 +34,13 @@ extern int ADL2_Adapter_DedicatedVRAMUsage_Get(ADL_CONTEXT_HANDLE context, int i // Return ADL_OK on success extern int ADL2_Adapter_ASICFamilyType_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpAsicTypes, int* lpValids); + +// Function to retrieve current power management capabilities. +// Return ADL_OK on success +extern int ADL2_Overdrive_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* iSupported, int* iEnabled, int* iVersion); + +/////////// Overdrive 6 functions + // Function to retrieve current Overdrive and performance-related activity. // Return ADL_OK on success extern int ADL2_Overdrive6_CurrentStatus_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLOD6CurrentStatus* lpCurrentStatus); @@ -45,3 +52,5 @@ extern int ADL2_Overdrive6_Temperature_Get(ADL_CONTEXT_HANDLE context, int iAdap // Function to retrieve the current or default Overdrive clock ranges. // Return ADL_OK on success extern int ADL2_Overdrive6_StateInfo_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iStateType, ADLOD6StateInfo* lpStateInfo); + +/// Overdrive 8 functions diff --git a/src/detection/gpu/gpu_amd.c b/src/detection/gpu/gpu_amd.c index 4eff677c5..2c4261116 100644 --- a/src/detection/gpu/gpu_amd.c +++ b/src/detection/gpu/gpu_amd.c @@ -49,6 +49,7 @@ struct FFAdlData { FF_LIBRARY_SYMBOL(ADL2_Adapter_DedicatedVRAMUsage_Get) FF_LIBRARY_SYMBOL(ADL2_Adapter_VRAMUsage_Get) FF_LIBRARY_SYMBOL(ADL2_Adapter_ASICFamilyType_Get) + FF_LIBRARY_SYMBOL(ADL2_Overdrive_Caps) FF_LIBRARY_SYMBOL(ADL2_Overdrive6_CurrentStatus_Get) FF_LIBRARY_SYMBOL(ADL2_Overdrive6_Temperature_Get) FF_LIBRARY_SYMBOL(ADL2_Overdrive6_StateInfo_Get) @@ -119,9 +120,13 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu FF_AUTO_FREE AdapterInfo* devices = NULL; int numDevices = 0; int adapterResult = adlData.ffADL2_Adapter_AdapterInfoX3_Get(adlData.apiHandle, -1, &numDevices, &devices); - FF_DEBUG("ADL2_Adapter_AdapterInfoX3_Get returned %s (%d), found %d devices", ffAdlStatusToString(adapterResult), adapterResult, numDevices); + FF_DEBUG("ADL2_Adapter_AdapterInfoX3_Get returned %s (%d)", ffAdlStatusToString(adapterResult), adapterResult); - if (adapterResult != 1) // 1 means success for this function + if (adapterResult == ADL_OK) + { + FF_DEBUG("found %d adapters", numDevices); + } + else { FF_DEBUG("ffADL2_Adapter_AdapterInfoX3_Get() failed"); return "ffADL2_Adapter_AdapterInfoX3_Get() failed"; @@ -162,7 +167,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu if (status == ADL_OK) { - *result.coreCount = (uint32_t) coreInfo.iNumCUs; + *result.coreCount = (uint32_t) coreInfo.iNumCUs * (uint32_t) coreInfo.iNumPEsPerCU; FF_DEBUG("Got core count: %u", *result.coreCount); } else @@ -210,6 +215,40 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu } } + if (result.type) + { + int asicTypes = 0; + int valids = 0; + int status = adlData.ffADL2_Adapter_ASICFamilyType_Get(adlData.apiHandle, device->iAdapterIndex, &asicTypes, &valids); + FF_DEBUG("ADL2_Adapter_ASICFamilyType_Get returned %s (%d), asicTypes: 0x%x, valids: 0x%x", + ffAdlStatusToString(status), status, asicTypes, valids); + + if (status == ADL_OK) + { + asicTypes &= valids; // This design is strange + *result.type = asicTypes & ADL_ASIC_INTEGRATED ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE; + FF_DEBUG("GPU type: %s", *result.type == FF_GPU_TYPE_INTEGRATED ? "Integrated" : "Discrete"); + } + else + { + FF_DEBUG("Failed to get GPU type"); + } + } + + if (result.index) + { + *result.index = (uint32_t) device->iAdapterIndex; + FF_DEBUG("Setting adapter index: %u", *result.index); + } + + if (result.name) + { + ffStrbufSetS(result.name, device->strAdapterName); + FF_DEBUG("Setting adapter name: %s", device->strAdapterName); + } + + adlData.ffADL2_Overdrive_Caps(adlData.apiHandle, device->iAdapterIndex, NULL, NULL, NULL); + if (result.frequency) { ADLOD6StateInfo stateInfo; @@ -255,38 +294,6 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu } } - if (result.type) - { - int asicTypes = 0; - int valids = 0; - int status = adlData.ffADL2_Adapter_ASICFamilyType_Get(adlData.apiHandle, device->iAdapterIndex, &asicTypes, &valids); - FF_DEBUG("ADL2_Adapter_ASICFamilyType_Get returned %s (%d), asicTypes: 0x%x, valids: 0x%x", - ffAdlStatusToString(status), status, asicTypes, valids); - - if (status == ADL_OK) - { - asicTypes &= valids; // This design is strange - *result.type = asicTypes & ADL_ASIC_INTEGRATED ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE; - FF_DEBUG("GPU type: %s", *result.type == FF_GPU_TYPE_INTEGRATED ? "Integrated" : "Discrete"); - } - else - { - FF_DEBUG("Failed to get GPU type"); - } - } - - if (result.index) - { - *result.index = (uint32_t) device->iAdapterIndex; - FF_DEBUG("Setting adapter index: %u", *result.index); - } - - if (result.name) - { - ffStrbufSetS(result.name, device->strAdapterName); - FF_DEBUG("Setting adapter name: %s", device->strAdapterName); - } - if (result.temp) { int milliDegrees = 0;