简体   繁体   中英

C (Windows) - GPU usage (load %)

According to many sources on the Internet its possible to get GPU usage (load) using D3DKMTQueryStatistics.

How to query GPU Usage in DirectX?

I've succeded to get memory information using code from here with slight modifications: http://processhacker.sourceforge.net/forums/viewtopic.php?t=325#p1338

However I didn't find a member of D3DKMT_QUERYSTATISTICS structure that should carry information regarding GPU usage.

Look at the EtpUpdateNodeInformation function in gpumon.c . It queries for process statistic per GPU node. There can be several processing nodes per graphics card:

queryStatistics.Type = D3DKMT_QUERYSTATISTICS_PROCESS_NODE
...
totalRunningTime += queryStatistics.QueryResult.ProcessNodeInformation.RunningTime.QuadPart
...
PhUpdateDelta(&Block->GpuRunningTimeDelta, totalRunningTime);
...
block->GpuNodeUsage = (FLOAT)(block->GpuRunningTimeDelta.Delta / (elapsedTime * EtGpuNodeBitMapBitsSet));

It gathers process running time and divides by actual time span.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM