Search Unity

Extreme GPU spikes from ParticleSystem

Discussion in 'General Graphics' started by mrtenda, Aug 13, 2019.

  1. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    28
    We are experiencing extreme GPU spikes in Unity 2019.2.0f1 on the first time a ParticleSystem is played (as shown in the screenshots below), and have been unable to figure out the cause. We don't really know where to go from here, so any help would be greatly appreciated.

    The spike seems to reliably happen on the FIRST time a ParticleSystem with these materials is played (and not subsequent times), so we thought that perhaps the shader used by the ParticleSystem wasn't being preloaded. With that in mind, we tried the following things, but unfortunately saw no change in behaviour:
    • Adding the shader (Legacy Shaders/Particles/Additive) to the preloaded ShaderVariantCollection
    • Adding the shader to the "Always Included Shaders" list
    • Calling Shader.WarmupAllShaders() after loading the scene
    I have also stepped through the game with the Frame Debugger and saw no significant change in GPU calls occur when the ParticleSystem plays. The spike isn't exclusive to the editor either; it also happens in a standalone build, causing the game to stutter.

    Would greatly appreciate some guidance here. Thanks!

    Spike in profiler:
    gpu1.png

    GPU usage hierarchy during the spike:
    (note that is it not always DrawInstanced that is the culprit - it randomly sometimes is DrawStatic)
    gpu2.png

    CPU usage hierarchy during the spike:
    cpu.png

    ParticleSystem materials:
    particles.png
     
    Last edited: Aug 13, 2019
  2. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    28
    Anyone have any ideas? Hard to find information on this kind of performance issue.
     
  3. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    261
    Hi,
    Not really my area of expertise and I'm not sure how much this applies to the current particle systems but, back in 5.6, I'd prewarm not just my materials/shaders, but also all particle effects, behind the loading screen to avoid these spikes. Looks like that might still be necessary.
     
    richardkettlewell and mrtenda like this.
  4. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    28
    MartinTilo and richardkettlewell like this.