void MemoryMonitor::GetMemoryInfo(MemInfo* pInfo) { NV_DISPLAY_DRIVER_MEMORY_INFO_V2 MemInfo = { 0 }; MemInfo.version = NV_DISPLAY_DRIVER_MEMORY_INFO_VER_2; NvAPI_Status Status = NvAPI_GPU_GetMemoryInfo(m_GpuHandle, &MemInfo); assert(Status == NVAPI_OK); pInfo->DedicatedVideoMemoryInMB = MemInfo.dedicatedVideoMemory / 1024; pInfo->AvailableDedicatedVideoMemoryInMB = MemInfo.availableDedicatedVideoMemory / 1024; pInfo->CurrentAvailableDedicatedVideoMemoryInMB = MemInfo.curAvailableDedicatedVideoMemory / 1024; GetProcessMemoryInfo(GetCurrentProcess(), pInfo, sizeof(PROCESS_MEMORY_COUNTERS)); //float base = (float)(log(CPUmemInfo.PagefileUsage) / log(1024)); //char suffixes[] = { 'b', 'k', 'M', 'G', 'T' }; }
VOID NvGpuUpdateValues(VOID) { NV_USAGES_INFO usagesInfo = { NV_USAGES_INFO_VER }; NV_DISPLAY_DRIVER_MEMORY_INFO memoryInfo = { NV_DISPLAY_DRIVER_MEMORY_INFO_VER }; NV_GPU_THERMAL_SETTINGS thermalSettings = { NV_GPU_THERMAL_SETTINGS_VER }; NV_GPU_CLOCK_FREQUENCIES clkFreqs = { NV_GPU_CLOCK_FREQUENCIES_VER }; NV_CLOCKS_INFO clocksInfo = { NV_CLOCKS_INFO_VER }; if (NvAPI_GPU_GetMemoryInfo(NvGpuDisplayHandleList->Items[0], &memoryInfo) == NVAPI_OK) { GpuMemoryLimit = memoryInfo.availableDedicatedVideoMemory; GpuCurrentMemSharedUsage = memoryInfo.sharedSystemMemory; GpuCurrentMemUsage = memoryInfo.availableDedicatedVideoMemory - memoryInfo.curAvailableDedicatedVideoMemory; } if (NvAPI_GPU_GetUsages(NvGpuPhysicalHandleList->Items[0], &usagesInfo) == NVAPI_OK) { GpuCurrentGpuUsage = (FLOAT)usagesInfo.usages[2] / 100; GpuCurrentCoreUsage = (FLOAT)usagesInfo.usages[6] / 100; GpuCurrentBusUsage = (FLOAT)usagesInfo.usages[14] / 100; } if (NvAPI_GPU_GetThermalSettings(NvGpuPhysicalHandleList->Items[0], NVAPI_THERMAL_TARGET_ALL, &thermalSettings) == NVAPI_OK) { GpuCurrentCoreTemp = thermalSettings.sensor[0].currentTemp; GpuCurrentBoardTemp = thermalSettings.sensor[1].currentTemp; } if (NvAPI_GPU_GetAllClockFrequencies(NvGpuPhysicalHandleList->Items[0], &clkFreqs) == NVAPI_OK) { //if (clkFreqs.domain[NVAPI_GPU_PUBLIC_CLOCK_GRAPHICS].bIsPresent) GpuCurrentCoreClock = clkFreqs.domain[NVAPI_GPU_PUBLIC_CLOCK_GRAPHICS].frequency / 1000; //if (clkFreqs.domain[NVAPI_GPU_PUBLIC_CLOCK_MEMORY].bIsPresent) GpuCurrentMemoryClock = clkFreqs.domain[NVAPI_GPU_PUBLIC_CLOCK_MEMORY].frequency / 1000; //if (clkFreqs.domain[NVAPI_GPU_PUBLIC_CLOCK_PROCESSOR].bIsPresent) GpuCurrentShaderClock = clkFreqs.domain[NVAPI_GPU_PUBLIC_CLOCK_PROCESSOR].frequency / 1000; } if (NvAPI_GPU_GetAllClocks(NvGpuPhysicalHandleList->Items[0], &clocksInfo) == NVAPI_OK) { if (GpuCurrentCoreClock == 0) GpuCurrentCoreClock = clocksInfo.clocks[0] / 1000; if (GpuCurrentMemoryClock == 0) GpuCurrentMemoryClock = clocksInfo.clocks[1] / 1000; if (GpuCurrentShaderClock == 0) GpuCurrentShaderClock = clocksInfo.clocks[2] / 1000; if (clocksInfo.clocks[30] != 0) { if (GpuCurrentCoreClock == 0) GpuCurrentCoreClock = (ULONG)(clocksInfo.clocks[30] * 0.0005f); if (GpuCurrentShaderClock == 0) GpuCurrentShaderClock = (ULONG)(clocksInfo.clocks[30] * 0.001f); } } }