7

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.

Community
  • 1
  • 1
Dan
  • 221
  • 1
  • 4
  • 12
  • 1
    Look at ***[this link](http://stackoverflow.com/a/1866429/645128)***. and the surrounding conversations. It looks like it will give you what you are looking for – ryyker Apr 13 '15 at 17:53
  • I'm not looking for graphics memory usage, but usage of graphics processor (load). – Dan Apr 13 '15 at 18:05
  • Okay, here is a ***[link to performance tools](https://msdn.microsoft.com/en-us/library/windows/desktop/jj585574%28v=vs.85%29.aspx)*** that may help. (read down a bit to see examples) – ryyker Apr 13 '15 at 18:26
  • 1
    Again I'm not really sure that you understood my question. I'm not looking a way to optimise my program GPU wise. What I'm looking is a way to get the GPU usage while some other program uses it. – Dan Apr 13 '15 at 19:08
  • In this original post, there is not a single question posed by you, only a series of statements. Use the content of your responses to my comments to improve your post by editing some clarification to exactly what it is you need. State what problem you are trying to solve. If I made these wrong assumptions based on what I read, other may as well. Sorry I was not able to help. – ryyker Apr 13 '15 at 19:24

1 Answers1

4

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.

Anton Krouglov
  • 3,077
  • 2
  • 29
  • 50