Monitoring GPU usage through C++ or Obj-C?

Discussion in 'Mac Programming' started by blueshogun96, Dec 30, 2016.

  1. blueshogun96, Dec 30, 2016
    Last edited: Dec 30, 2016

    blueshogun96 macrumors regular

    blueshogun96

    Joined:
    Nov 24, 2012
    #1
    Okay, so one of the recent additions I added to my game engine was built in GPU monitoring for Windows. While not a critical feature, it is something I would like to add for macOS. The goal is to implement something similar to NVPerfHUD (for those who remember what that is) and show the dev how much of the GPU is currently being utilized. Essentially, I'm looking for similar functionality that GPU-Z has for Windows.

    I'm sure this is possible since XCode does seem to have some GPU monitoring instruments, therefore it has to hook into an API of some sort. For Windows and Linux, I can just use NVAPI for the NVIDIA cards, and D3DKMT for Intel (also Windows). There's another library for AMD which has similar APIs but I haven't looked into it as of yet. I don't know what to do for Mac.

    Any ideas? Thanks.

    Shogun

    EDIT: I found this link on stack overflow, but it only works for non-discreet GPUs it says: http://stackoverflow.com/questions/10110658/programmatically-get-gpu-percent-usage-in-os-x
     
  2. marksatt macrumors regular

    Joined:
    Jun 26, 2013
    Location:
    Epic UK
    #2
    I use the IORegistry stats in UE4 and they do exist for all GPU vendors. Which stats are available does depend on the OS version and GPU model but core utilisation should be available on all of them for recent (10.11+) versions of macOS.
     
  3. blueshogun96 thread starter macrumors regular

    blueshogun96

    Joined:
    Nov 24, 2012
    #3
    As much as I hate the thought of borrowing code from a commercial engine, I might have to make one exception.

    Part of the reason I wrote this engine is to get revenge on Epic (nothing personal, but still a long story that ended up costing me $75 to fix my then broken iPhone). The other reason was (at the time) to have a completely open source engine using open source components to make it portable to any platform desirable. And Ironically, someone already compared my engine to UE4.

    Thanks for the insight either way. Much appreciated.

    Shogun
     

Share This Page