-
-
Save wyrover/02e0f7aba447a271fe9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; =============================================================================================================================== | |
; Title .........: GPU_MEMORY_INFO | |
; AHK Version ...: 1.1.15.01 x64 Unicode | |
; Win Version ...: Windows 7 Professional x64 SP1 | |
; Description ...: GPU_MEMORY_INFO | |
; NVIDIA Graphics Memory Size and Usage in OpenGL | |
; Version .......: v1.00 | |
; Modified ......: 2014.06.27-2150 | |
; Author(s) .....: jNIzM | |
; =============================================================================================================================== | |
;@Ahk2Exe-SetName GPU_MEMORY_INFO | |
;@Ahk2Exe-SetDescription GPU_MEMORY_INFO | |
;@Ahk2Exe-SetVersion v1.00 | |
;@Ahk2Exe-SetCopyright Copyright (c) 2013-2014`, jNizM | |
;@Ahk2Exe-SetOrigFilename GPU_MEMORY_INFO.ahk | |
; =============================================================================================================================== | |
; GLOBAL SETTINGS =============================================================================================================== | |
#NoEnv | |
SetBatchLines, -1 | |
OnExit, EOS | |
; http://developer.download.nvidia.com/opengl/specs/GL_NVX_gpu_memory_info.txt | |
global GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX := 0x9048 | |
global GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX := 0x9049 | |
; SCRIPT ======================================================================================================================== | |
glInit() | |
mem_total := glGetInt(GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX) | |
mem_current := glGetInt(GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX) | |
mem_usage := mem_total - mem_current | |
MsgBox % "OpenGL memory:`nTotal:`t" mem_total " MB`nUsage:`t" mem_usage " MB" | |
; FUNCTIONS ===================================================================================================================== | |
glInit() | |
{ | |
hOpenGL32 := DllCall("Kernel32.dll\LoadLibrary", "Str", "opengl32.dll") | |
Gui, +LastFound +Resize | |
hDC := DllCall("User32.dll\GetDC", "UInt", WinExist()) | |
VarSetCapacity(pfd, 40, 0) | |
NumPut(40, pfd, 0, "UShort") | |
NumPut( 1, pfd, 2, "UShort") | |
NumPut(37, pfd, 4, "UInt") | |
NumPut(24, pfd, 9, "UChar") | |
NumPut(16, pfd, 23, "UChar") | |
DllCall("Gdi32.dll\SetPixelFormat", "UInt", hDC, "UInt", DllCall("Gdi32.dll\ChoosePixelFormat", "UInt", hDC, "UInt", &pfd), "UInt", &pfd) | |
hRC := DllCall("opengl32.dll\wglCreateContext", "UInt", hDC) | |
DllCall("opengl32.dll\wglMakeCurrent", "UInt", hDC, "UInt", hRC) | |
} | |
glGetInt(enum) | |
{ | |
VarSetCapacity(param, 4, 0) | |
DllCall("opengl32.dll\glGetIntegerv", "UInt", enum, "Ptr", ¶m) | |
return Round(NumGet(param, 0, "Int") / 1024, 0) | |
} | |
; EXIT ========================================================================================================================== | |
EOS: | |
DllCall("opengl32.dll\wglMakeCurrent", "uInt", 0, "uInt", 0) | |
DllCall("opengl32.dll\wglDeleteContext", "uInt", hRC) | |
DllCall("User32.dll\ReleaseDC", "uInt", hDC) | |
DllCall("Kernel32.dll\FreeLibrary", "UInt", hOpenGL32) | |
ExitApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment