name22

ATI ADL SDK

Apr 24th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 4.21 KB | None | 0 0
  1. #include <Memory.au3>
  2.  
  3. ; - "Inspired" by this script http://www.autoit.de/index.php?page=Thread&postID=250736#post250736 (written by Andy)
  4. ; - Author: name22 (www.autoit.de)
  5.  
  6. #Region Structure Definitions
  7. Global Const $tagAdapterInfo =  "int iSize;" & _
  8.                                 "int iAdapterIndex;" & _
  9.                                 "char strUDID[256];" & _
  10.                                 "int iBusNumber;" & _
  11.                                 "int iDeviceNumber;" & _
  12.                                 "int iFunctionNumber;" & _
  13.                                 "int iVendorID;" & _
  14.                                 "char strAdapterName[256];" & _
  15.                                 "char strDisplayName[256];" & _
  16.                                 "int iPresent;" & _
  17.                                 "int iExist;" & _
  18.                                 "char strDriverPath[256];" & _
  19.                                 "char strDriverPathExt[256];" & _
  20.                                 "char strPNPString[256];" & _
  21.                                 "int iOSDisplayIndex"
  22.  
  23. Global Const $tagADLPMActivity =    "int iSize;" & _
  24.                                     "int iEngineClock;" & _
  25.                                     "int iMemoryClock;" & _
  26.                                     "int iVddc;" & _
  27.                                     "int iActivityPercent;" & _
  28.                                     "int iCurrentPerformanceLevel;" & _
  29.                                     "int iCurrentBusSpeed;" & _
  30.                                     "int iCurrentBusLanes;" & _
  31.                                     "int iMaximumBusLanes;" & _
  32.                                     "int iReserved"
  33. #EndRegion
  34.  
  35. Global $sDLL_ADL, $hCallback_Alloc, $pCallback_Alloc, $iNumberAdapters, $aAdapterInfo, $tBuffer, $tActivity
  36.  
  37. OnAutoItExitRegister("_Shutdown")
  38.  
  39. $hDLL_ADL = DllOpen("atiadlxx.dll")
  40. If $hDLL_ADL = -1 Then $hDLL_ADL = DllOpen("atiadlxy.dll")
  41.  
  42. $hCallback_Alloc = DllCallbackRegister("_Main_Memory_Alloc", "int_ptr", "int")
  43. $pCallback_Alloc = DllCallbackGetPtr($hCallback_Alloc)
  44.  
  45. _ADL_Main_Control_Create($pCallback_Alloc)
  46. $iNumberAdapters = _ADL_Adapter_NumberOfAdapters_Get()
  47.  
  48. If $iNumberAdapters > 0 Then
  49.     $aAdapterInfo = _ADL_Adapter_AdapterInfo_Get($iNumberAdapters)
  50.     For $i = 0 To UBound($aAdapterInfo) - 1
  51.         $tActivity = _ADL_Overdrive5_CurrentActivity_Get($aAdapterInfo[$i].iAdapterIndex)
  52.         ConsoleWrite("GPU " & $i + 1 & ". " & $aAdapterInfo[$i].strAdapterName & ": Activity [%] =" & @TAB & $tActivity.iActivityPercent & @CRLF)
  53.     Next
  54. EndIf
  55.  
  56. Func _Main_Memory_Alloc($iSize)
  57.     ConsoleWrite("!Global_Mem_Alloc:" & @TAB & $iSize & @CRLF)
  58.     Return _MemGlobalAlloc($iSize)
  59. EndFunc
  60.  
  61. Func _Main_Memory_Free($pMem)
  62.     ConsoleWrite("!Global_Mem_Free:" & @TAB & $pMem & @CRLF)
  63.     Return _MemGlobalFree($pMem)
  64. EndFunc
  65.  
  66. Func _Shutdown()
  67.     _ADL_Main_Control_Destroy()
  68.     DllCallbackFree($hCallback_Alloc)
  69.     DllClose($hDLL_ADL)
  70. EndFunc
  71.  
  72. #Region ADL-DLL Functions
  73. Func _ADL_Main_Control_Create($pMemAlloc, $iEnumConnectedAdapters = 0)
  74.     $aRet = DllCall($hDLL_ADL, "int:cdecl", "ADL_Main_Control_Create", "ptr", $pCallback_Alloc, "int", $iEnumConnectedAdapters)
  75.     If Not @error Then
  76.         Return $aRet[0]
  77.     Else
  78.         Return SetError(@error, 0, 0)
  79.     EndIf
  80. EndFunc
  81.  
  82. Func _ADL_Main_Control_Destroy()
  83.     $aRet = DllCall($hDLL_ADL, "int:cdecl", "ADL_Main_Control_Destroy")
  84.     If Not @error Then
  85.         Return $aRet[0]
  86.     Else
  87.         Return SetError(@error, 0, 0)
  88.     EndIf
  89. EndFunc
  90.  
  91. Func _ADL_Adapter_NumberOfAdapters_Get()
  92.     Local $iNumberAdapters
  93.     $aRet = DllCall($hDLL_ADL, "int:cdecl", "ADL_Adapter_NumberOfAdapters_Get", "int*", $iNumberAdapters)
  94.     If Not @error Then
  95.         Return $aRet[1]
  96.     Else
  97.         Return SetError(@error, 0, 0)
  98.     EndIf
  99. EndFunc
  100.  
  101. Func _ADL_Adapter_AdapterInfo_Get($iNumberAdapters)
  102.     Local $iStructSize = DllStructGetSize(DllStructCreate($tagAdapterInfo))
  103.     $tBuffer = DllStructCreate("byte[" & $iStructSize * $iNumberAdapters & "]")
  104.     Local $pBuffer = DllStructGetPtr($tBuffer)
  105.     Local $aAdapterInfo[$iNumberAdapters]
  106.     For $i = 0 To $iNumberAdapters - 1
  107.         $aAdapterInfo[$i] = DllStructCreate($tagAdapterInfo, $pBuffer + $i * $iStructSize)
  108.     Next
  109.     $aRet = DllCall($hDLL_ADL, "int:cdecl", "ADL_Adapter_AdapterInfo_Get", "ptr", $pBuffer, "int", DllStructGetSize($tBuffer))
  110.     If Not @error Then
  111.         Return $aAdapterInfo
  112.     Else
  113.         Return SetError(@error, 0, 0)
  114.     EndIf
  115. EndFunc
  116.  
  117. Func _ADL_Overdrive5_CurrentActivity_Get($iAdapterIndex)
  118.     Local $tADLPMActivity = DllStructCreate($tagADLPMActivity), $pADLPMActivity = DllStructGetPtr($tADLPMActivity)
  119.     $tADLPMActivity.iSize = DllStructGetSize($tADLPMActivity)
  120.     $aRet = DllCall($hDLL_ADL, "int:cdecl", "ADL_Overdrive5_CurrentActivity_Get", "int", $iAdapterIndex, "ptr", $pADLPMActivity)
  121.     If Not @error Then
  122.         Return $tADLPMActivity
  123.     Else
  124.         Return SetError(@error, 0, 0)
  125.     EndIf
  126. EndFunc
  127. #EndRegion
Add Comment
Please, Sign In to add comment