Search code examples
objective-ciokit

What is the meaning of the keys in the GPU[@"PerformanceStatistics"]?


I get the GPU infos from IOKit in an iOS app on iPhone device, and I get the @"PerformanceStatistics" values of GPU info, I'm confused what's the key-values mean here:

{

    CommandBufferRenderCount = 1;
    "Device Utilization %" = 0;
    "Renderer Utilization %" = 0;
    SplitSceneCount = 0;
    TiledSceneBytes = 217088;
    "Tiler Utilization %" = 0;
    agpTextureCreationBytes = 0;
    agprefTextureCreationBytes = 16384;
    contextGLCount = 0;
    finishGLWaitTime = 0;
    freeToAllocGPUAddressWaitTime = 0;
    gartMapInBytesPerSample = 16384;
    gartMapOutBytesPerSample = 0;
    gartUsedBytes = 30801920;
    hardwareWaitTime = 0;
    iosurfaceTextureCreationBytes = 0;
    oolTextureCreationBytes = 0;
    recoveryCount = 0;
    stdTextureCreationBytes = 0;
    textureCount = 521;
}

Solution

  • I know this question is a bit old, but in case someone is asking the same thing, you can see what most of these mean by reading the official Apple's developer documentation on the subject here: https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/OpenGLDriverMonitorUserGuide/Glossary/Glossary.html

    As for the ones that are not listed, most of them are self explanatory and aptly named. Most modern iOS and macOS drivers calculate the usage of the GPU and hardware engines such as the video, renderer and tiling engines for you. These values can be queried from both Objective-C and C++ if they are needed beyond Xcode's performance tools.

    Considering the average person does not need this level of information, may I ask why you need this as opposed to using the performance profiling tools that come with XCode already?

    EDIT: Most people who search up the information above are often looking for ways to get the GPU usage of the overall system for macOS or iOS. If you or anyone else need to have customized code to get this information, see the links below:

    Programmatically get GPU percent usage in OS X https://gist.github.com/chockenberry/2afe4d0f1f9caddc81de

    The exact information from the GPU's driver that is exposed varies from one GPU to the next as well as the OS version. The first link demonstrates via C/C++ code how simple it is to get GPU usage and other statistics. The second link contains various examples of what different GPUs can generate. Of course, see the notes at the bottom of each link as these attribute names are subject to change.

    Lastly, if your GPU does not expose the GPU usage statistics directly, then the only possible way to calculate it would be to query the value of hardwareWaitTime (which is the time in nanoseconds for how long the GPU has been busy) and comparing that time with the GPUs clock speed (I have yet to know how to obtain such information programmatically): GPUusage = hardwareWaitTime/GPUClockSpeed in nanohertz.

    Hope this helps.