@@ -51,8 +51,11 @@ struct FFAdlData {
51
51
FF_LIBRARY_SYMBOL (ADL2_Adapter_ASICFamilyType_Get )
52
52
FF_LIBRARY_SYMBOL (ADL2_Overdrive_Caps )
53
53
FF_LIBRARY_SYMBOL (ADL2_OverdriveN_Capabilities_Get )
54
+ FF_LIBRARY_SYMBOL (ADL2_OverdriveN_SystemClocks_Get )
54
55
FF_LIBRARY_SYMBOL (ADL2_OverdriveN_PerformanceStatus_Get )
55
56
FF_LIBRARY_SYMBOL (ADL2_OverdriveN_Temperature_Get )
57
+ FF_LIBRARY_SYMBOL (ADL2_Overdrive8_Current_Setting_Get )
58
+ FF_LIBRARY_SYMBOL (ADL2_New_QueryPMLogData_Get )
56
59
FF_LIBRARY_SYMBOL (ADL2_Overdrive6_CurrentStatus_Get )
57
60
FF_LIBRARY_SYMBOL (ADL2_Overdrive6_Temperature_Get )
58
61
FF_LIBRARY_SYMBOL (ADL2_Overdrive6_StateInfo_Get )
@@ -90,7 +93,10 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
90
93
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Adapter_ASICFamilyType_Get )
91
94
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Overdrive_Caps )
92
95
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_OverdriveN_Capabilities_Get )
96
+ FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_OverdriveN_SystemClocks_Get )
93
97
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_OverdriveN_PerformanceStatus_Get )
98
+ FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Overdrive8_Current_Setting_Get )
99
+ FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_New_QueryPMLogData_Get )
94
100
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_OverdriveN_Temperature_Get )
95
101
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Overdrive6_CurrentStatus_Get )
96
102
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE (atiadl , adlData , ADL2_Overdrive6_Temperature_Get )
@@ -163,6 +169,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
163
169
164
170
if (status == ADL_OK )
165
171
{
172
+ FF_DEBUG ("Core info - NumCUs: %d, NumPEsPerCU: %d" , coreInfo .iNumCUs , coreInfo .iNumPEsPerCU );
166
173
* result .coreCount = (uint32_t ) coreInfo .iNumCUs * (uint32_t ) coreInfo .iNumPEsPerCU ;
167
174
FF_DEBUG ("Got core count: %u" , * result .coreCount );
168
175
}
@@ -179,8 +186,12 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
179
186
FF_DEBUG ("ADL2_Adapter_DedicatedVRAMUsage_Get returned %s (%d), usage: %d MB" ,
180
187
ffAdlStatusToString (status ), status , vramUsage );
181
188
182
- if (status == ADL_OK )
189
+ if (status == ADL_OK ) {
183
190
result .memory -> used = (uint64_t ) vramUsage * 1024 * 1024 ;
191
+ FF_DEBUG ("Dedicated VRAM usage: %llu bytes (%d MB)" , result .memory -> used , vramUsage );
192
+ } else {
193
+ FF_DEBUG ("Failed to get dedicated VRAM usage" );
194
+ }
184
195
185
196
if (result .sharedMemory )
186
197
{
@@ -189,8 +200,14 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
189
200
FF_DEBUG ("ADL2_Adapter_VRAMUsage_Get returned %s (%d), usage: %d MB" ,
190
201
ffAdlStatusToString (status ), status , vramUsage );
191
202
192
- if (status == ADL_OK )
193
- result .sharedMemory -> used = (uint64_t ) vramUsage * 1024 * 1024 - result .memory -> used ;
203
+ if (status == ADL_OK ) {
204
+ uint64_t totalUsage = (uint64_t ) vramUsage * 1024 * 1024 ;
205
+ result .sharedMemory -> used = totalUsage - result .memory -> used ;
206
+ FF_DEBUG ("Total VRAM usage: %llu bytes, Shared VRAM usage: %llu bytes (%llu MB)" ,
207
+ totalUsage , result .sharedMemory -> used , result .sharedMemory -> used / (1024 * 1024 ));
208
+ } else {
209
+ FF_DEBUG ("Failed to get total VRAM usage" );
210
+ }
194
211
}
195
212
}
196
213
@@ -202,6 +219,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
202
219
203
220
if (status == ADL_OK )
204
221
{
222
+ FF_DEBUG ("Memory info - Type: %s, Size: %lld MB" , memoryInfo .strMemoryType , memoryInfo .iMemorySize / 1024 / 1024 );
205
223
ffStrbufSetS (result .memoryType , memoryInfo .strMemoryType );
206
224
FF_DEBUG ("Got memory type: %s" , memoryInfo .strMemoryType );
207
225
}
@@ -223,7 +241,8 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
223
241
{
224
242
asicTypes &= valids ; // This design is strange
225
243
* result .type = asicTypes & ADL_ASIC_INTEGRATED ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE ;
226
- FF_DEBUG ("GPU type: %s" , * result .type == FF_GPU_TYPE_INTEGRATED ? "Integrated" : "Discrete" );
244
+ FF_DEBUG ("GPU type: %s (asicTypes: 0x%x, valids: 0x%x)" ,
245
+ * result .type == FF_GPU_TYPE_INTEGRATED ? "Integrated" : "Discrete" , asicTypes , valids );
227
246
}
228
247
else
229
248
{
@@ -240,7 +259,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
240
259
if (result .name )
241
260
{
242
261
ffStrbufSetS (result .name , device -> strAdapterName );
243
- FF_DEBUG ("Setting adapter name: %s" , device -> strAdapterName );
262
+ FF_DEBUG ("Setting adapter name: %s; UDID: %s, Present: %d, Exist: %d " , device -> strAdapterName , device -> strUDID , device -> iPresent , device -> iExist );
244
263
}
245
264
246
265
int odVersion = 0 ;
@@ -249,23 +268,54 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
249
268
int odSupported = 0 ;
250
269
int odEnabled = 0 ;
251
270
int status = adlData .ffADL2_Overdrive_Caps (adlData .apiHandle , device -> iAdapterIndex , & odSupported , & odEnabled , & odVersion );
252
- FF_DEBUG ("ADL2_Overdrive_Caps returned %s (%d); supported %d, enabled %d; version %d" , ffAdlStatusToString (status ), status , odSupported , odEnabled , odVersion );
271
+ FF_DEBUG ("ADL2_Overdrive_Caps returned %s (%d); supported %d, enabled %d; version %d" ,
272
+ ffAdlStatusToString (status ), status , odSupported , odEnabled , odVersion );
253
273
}
254
274
255
- if (odVersion >= 6 )
275
+ if (odVersion > 8 )
256
276
{
257
277
FF_DEBUG ("Using OverdriveN API (odVersion=%d)" , odVersion );
258
278
259
279
if (result .frequency )
260
280
{
281
+ // https://github.com/MaynardMiner/odvii/blob/master/OverdriveN.cpp#L176
261
282
ADLODNCapabilities odCapabilities ;
262
283
int status = adlData .ffADL2_OverdriveN_Capabilities_Get (adlData .apiHandle , device -> iAdapterIndex , & odCapabilities );
263
284
FF_DEBUG ("ADL2_OverdriveN_Capabilities_Get returned %s (%d)" , ffAdlStatusToString (status ), status );
264
285
265
286
if (status == ADL_OK )
266
287
{
267
- * result .frequency = (uint32_t ) odCapabilities .sEngineClockRange .iMax / 100 ; // assume in 10 KHz
268
- FF_DEBUG ("Got max engine clock: %u MHz" , * result .frequency );
288
+ if (odCapabilities .iMaximumNumberOfPerformanceLevels == 0 )
289
+ {
290
+ FF_DEBUG ("ADL2_OverdriveN_Capabilities_Get: no performance levels available" );
291
+ }
292
+ else
293
+ {
294
+ FF_DEBUG ("ODN Capabilities - MaxPerformanceLevels: %d, GPU Clock Range: [%d - %d]" ,
295
+ odCapabilities .iMaximumNumberOfPerformanceLevels ,
296
+ odCapabilities .sEngineClockRange .iMin , odCapabilities .sEngineClockRange .iMax );
297
+
298
+ size_t size = sizeof (ADLODNPerformanceLevels ) + sizeof (ADLODNPerformanceLevel ) * ((unsigned ) odCapabilities .iMaximumNumberOfPerformanceLevels - 1 );
299
+ FF_AUTO_FREE ADLODNPerformanceLevels * odPerfLevels = malloc (size );
300
+ * odPerfLevels = (ADLODNPerformanceLevels ) {
301
+ .iSize = (int ) size ,
302
+ .iNumberOfPerformanceLevels = odCapabilities .iMaximumNumberOfPerformanceLevels ,
303
+ };
304
+ int status = adlData .ffADL2_OverdriveN_SystemClocks_Get (adlData .apiHandle , device -> iAdapterIndex , odPerfLevels );
305
+ FF_DEBUG ("ADL2_OverdriveN_SystemClocks_Get returned %s (%d), levels: %d" ,
306
+ ffAdlStatusToString (status ), status , odPerfLevels -> iNumberOfPerformanceLevels );
307
+
308
+ * result .frequency = 0 ;
309
+ for (int i = 0 ; i < odPerfLevels -> iNumberOfPerformanceLevels ; i ++ )
310
+ {
311
+ uint32_t clock = (uint32_t ) odPerfLevels -> aLevels [i ].iClock ;
312
+ FF_DEBUG ("Performance level %d: engine clock = %u" , i , clock );
313
+ if (clock > * result .frequency )
314
+ * result .frequency = clock ;
315
+ }
316
+ * result .frequency /= 10 ; // assume in 10 kHz
317
+ FF_DEBUG ("Got max engine clock: %u MHz" , * result .frequency );
318
+ }
269
319
}
270
320
else
271
321
{
@@ -275,12 +325,17 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
275
325
276
326
if (result .coreUsage )
277
327
{
278
- ADLODNPerformanceStatus performanceStatus ;
328
+ ADLODNPerformanceStatus performanceStatus = {} ;
279
329
int status = adlData .ffADL2_OverdriveN_PerformanceStatus_Get (adlData .apiHandle , device -> iAdapterIndex , & performanceStatus );
280
330
FF_DEBUG ("ADL2_OverdriveN_PerformanceStatus_Get returned %s (%d)" , ffAdlStatusToString (status ), status );
281
331
282
332
if (status == ADL_OK )
283
333
{
334
+ FF_DEBUG ("Performance Status - Activity: %d%%, CoreClock: %dMHz, MemoryClock: %dMHz" ,
335
+ performanceStatus .iGPUActivityPercent ,
336
+ performanceStatus .iCoreClock / 100 ,
337
+ performanceStatus .iMemoryClock / 100 );
338
+
284
339
* result .coreUsage = performanceStatus .iGPUActivityPercent ;
285
340
FF_DEBUG ("Got GPU activity: %d%%" , performanceStatus .iGPUActivityPercent );
286
341
}
@@ -294,21 +349,96 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
294
349
{
295
350
int milliDegrees = 0 ;
296
351
int status = adlData .ffADL2_OverdriveN_Temperature_Get (adlData .apiHandle , device -> iAdapterIndex , 1 , & milliDegrees );
297
- FF_DEBUG ("ADL2_OverdriveN_Temperature_Get returned %s (%d), temperature: %d milliC " ,
298
- ffAdlStatusToString (status ), status , milliDegrees );
352
+ FF_DEBUG ("ADL2_OverdriveN_Temperature_Get returned %s (%d)" ,
353
+ ffAdlStatusToString (status ), status );
299
354
300
355
if (status == ADL_OK )
301
356
{
302
357
* result .temp = milliDegrees / 1000.0 ;
303
- FF_DEBUG ("Temperature: %.1f°C" , * result .temp );
358
+ FF_DEBUG ("Temperature: %.1f°C (raw: %d milliC) " , * result .temp , milliDegrees );
304
359
}
305
360
else
306
361
{
307
362
FF_DEBUG ("Failed to get temperature" );
308
363
}
309
364
}
310
365
}
311
- else
366
+ else if (odVersion == 8 )
367
+ {
368
+ FF_DEBUG ("Using Overdrive8 API (odVersion=%d)" , odVersion );
369
+
370
+ if (result .frequency )
371
+ {
372
+ ADLOD8CurrentSetting currentSetting ;
373
+ int status = adlData .ffADL2_Overdrive8_Current_Setting_Get (adlData .apiHandle , device -> iAdapterIndex , & currentSetting );
374
+ FF_DEBUG ("ADL2_Overdrive8_Current_Setting_Get returned %s (%d)" , ffAdlStatusToString (status ), status );
375
+ if (status == ADL_OK )
376
+ {
377
+ FF_DEBUG ("OD8 Settings count: %d" , currentSetting .count );
378
+
379
+ * result .frequency = (uint32_t ) currentSetting .Od8SettingTable [OD8_GFXCLK_FMAX ];
380
+ FF_DEBUG ("Got max engine clock (OD8 GFXCLK_FMAX): %u MHz" , * result .frequency );
381
+ }
382
+ else
383
+ {
384
+ FF_DEBUG ("Failed to get max frequency information" );
385
+ }
386
+ }
387
+
388
+ if (result .temp || result .coreUsage )
389
+ {
390
+ ADLPMLogDataOutput pmLogDataOutput ;
391
+ int status = adlData .ffADL2_New_QueryPMLogData_Get (adlData .apiHandle , device -> iAdapterIndex , & pmLogDataOutput );
392
+ FF_DEBUG ("ADL2_New_QueryPMLogData_Get returned %s (%d)" , ffAdlStatusToString (status ), status );
393
+ if (status == ADL_OK )
394
+ {
395
+ if (result .temp )
396
+ {
397
+ ADLSingleSensorData * edge = & pmLogDataOutput .sensors [ADL_PMLOG_TEMPERATURE_EDGE ];
398
+ FF_DEBUG ("Sensor %d: %s, supported: %d, value: %d" , ADL_PMLOG_TEMPERATURE_EDGE , "ADL_PMLOG_TEMPERATURE_EDGE" , edge -> supported , edge -> value );
399
+ if (edge -> supported )
400
+ {
401
+ * result .temp = edge -> value ;
402
+ FF_DEBUG ("Temperature: %.1f°C" , * result .temp );
403
+ }
404
+ else
405
+ {
406
+ FF_DEBUG ("Sensor %d not supported" , ADL_PMLOG_TEMPERATURE_EDGE );
407
+ ADLSingleSensorData * hotspot = & pmLogDataOutput .sensors [ADL_PMLOG_TEMPERATURE_EDGE ];
408
+ FF_DEBUG ("Sensor %d: %s, supported: %d, value: %d" , ADL_PMLOG_TEMPERATURE_EDGE , "ADL_PMLOG_TEMPERATURE_EDGE" , hotspot -> supported , hotspot -> value );
409
+ if (hotspot -> supported )
410
+ {
411
+ * result .temp = hotspot -> value ;
412
+ FF_DEBUG ("Temperature: %.1f°C" , * result .temp );
413
+ }
414
+ else
415
+ {
416
+ FF_DEBUG ("Sensor %d not supported" , PMLOG_TEMPERATURE_HOTSPOT );
417
+ }
418
+ }
419
+ }
420
+ if (result .coreUsage )
421
+ {
422
+ ADLSingleSensorData * activity = & pmLogDataOutput .sensors [ADL_PMLOG_INFO_ACTIVITY_GFX ];
423
+ FF_DEBUG ("Sensor %d: %s, supported: %d, value: %d" , ADL_PMLOG_INFO_ACTIVITY_GFX , "ADL_PMLOG_INFO_ACTIVITY_GFX" , activity -> supported , activity -> value );
424
+ if (activity -> supported )
425
+ {
426
+ * result .coreUsage = activity -> value ;
427
+ FF_DEBUG ("Core usage: %.1f%%" , * result .coreUsage );
428
+ }
429
+ else
430
+ {
431
+ FF_DEBUG ("Sensor %d not supported" , ADL_PMLOG_INFO_ACTIVITY_GFX );
432
+ }
433
+ }
434
+ }
435
+ else
436
+ {
437
+ FF_DEBUG ("Failed to get temperature / GPU activity" );
438
+ }
439
+ }
440
+ }
441
+ else if (odVersion == 6 )
312
442
{
313
443
FF_DEBUG ("Using Overdrive6 API (odVersion=%d)" , odVersion );
314
444
@@ -372,6 +502,11 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
372
502
}
373
503
}
374
504
}
375
- FF_DEBUG ("AMD GPU detection complete" );
505
+ else
506
+ {
507
+ FF_DEBUG ("Unknown Overdrive version: %d" , odVersion );
508
+ return "Unknown Overdrive version" ;
509
+ }
510
+ FF_DEBUG ("AMD GPU detection complete - returning success" );
376
511
return NULL ;
377
512
}
0 commit comments