Search Unity

Can someone help me understand the profiler?

Discussion in 'Editor & General Support' started by Wizard-Games, Sep 1, 2018.

  1. Wizard-Games

    Wizard-Games

    Joined:
    Jun 4, 2013
    Posts:
    34
    Hi, can someone help me understand this? The issue is with GfxPresentFrame and Gfx.WaitForPresent.To me it looks as if Gfx.PresentFrame is taking quite a long time for no reason which is then causing the WaitForPresent to take half of the next frame. I am using 5.6.6 and I have a GTX 970 running windows 10. Any help would be apreciated. Thanks ahead of time. GFX.PRESENT.PNG
     
  2. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    Roughly speaking Gfx.PresentFrame is the engine submitting draw commands to the GPU. So that's an entirely CPU-side operation. That depends on the complexity of your scene (e.g. number of MeshRenderers, complexity of the state that needs to be set up, etc).

    Gfx.WaitForPresent is the CPU waiting for the GPU to finish processing those commands. So broadly speaking WaitForPresent could be considered a proxy for the work that the fragment shaders are doing (also the vertex shaders but typically the time spent doing fragment shader operations will dwarf the time spent doing vertex shader operations). The GPU will actually start executing commands when they're kicked off, and during that timeframe other game systems will be ticking and updating, so by the time WaitForPresent comes around, some parts of the GPU frame will have already been drawn. So it's not exact.

    This post on the Oculus forums has a great explanation in more detail.

    If you want to get more detailed information about what the GPU is doing you should use the appropriate platform tools to debug. To debug a Windows target the Intel Graphics Performance Analyzer is pretty good. On macOS you can use Instruments. The mobile platforms have their own tools.

    Having said all that, it doesn't look like you're running into any performance issues (I assume you don't have vsync turned on there).

    Sam
     
  3. Wizard-Games

    Wizard-Games

    Joined:
    Jun 4, 2013
    Posts:
    34
    Hey Sam, thanks for the relpy. The scene was just a 2k^2 terrain with some trees and grass on it when that test was done. I removed all the meshes from the scene because I was trying to figure out how I could get some better performance. Vsync is turned off. I had hoped that I was just doing something wrong, because GfxPresentFrame was running so far into the next frame.

    Here is a video of the scene being played, though the above profile does not have all the geometry in the scene, only the terrain, trees and grass. Thanks again for your help.
     
  4. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    Ah ok. Another thing I forgot to mention - you could try using the frame debugger, that will show you all the draw calls that are being submitted to the GPU. That will give you an idea of a lot of the CPU overhead.

    Sam