Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How to retrieve specific GPU usage time from Profiler in code?

Discussion in 'Editor & General Support' started by Superark, May 29, 2023.

  1. Superark


    Mar 2, 2018
    How can I obtain the consumption time of a specific row under GPU usage in Unity 2021.3, for example, the time taken by ParticleSystem.Draw as illustrated in the image below.

    Attached Files:

  2. MartinTilo


    Unity Technologies

    Aug 16, 2017
    Hi there,
    The GPU profiler, when using the Graphic APIs and configurations with which it works, shows GPU costs associated with commands issued from the CPU as attributed into a CPU like hierarchy of calls that lead to the calls issuing the command.

    That is to say, not all of the entries you see have actual GPU Markers associated with them using the same name. That is only true for the commands that are issued. Some of the samples shown are essentially from higher order CPU markers around the code that issued the commands and the hierarchy of the CPU samples bubbles the GPU cost up the hierarchy.

    That said, some of these totally do have GPU marker equivalents that can be queried from code using ProfilerRecorders together with the ProfilerRecorderOptions.GpuRecorder to record these. And you can use ProfilerRecorderHandle.GetAvailable to get the full list of supported metrics and filter it to GPU markers via ProfilerRecorderHandle.GetDescription(handle).Flags.HasFlag(MarkerFlag.SampleGPU)