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

Preloading Shaders doesn't help with performance

Discussion in 'General Graphics' started by roberto_sc, May 30, 2018.

  1. roberto_sc

    roberto_sc

    Joined:
    Dec 13, 2010
    Posts:
    144
    I'm having a huge cpu spike at a specific point in my game.
    I tried to set a shader variants file in Preloaded Shaders in Graphic settings, but it doesn't do anything.
    Shader variants file was created by playing the game as per documentation, it has included over 100 variants.

    What's going on?

    Screen Shot 2018-05-31 at 5.54.58 AM.png
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,845
    Hi!

    What platform does this happen on?
     
  3. roberto_sc

    roberto_sc

    Joined:
    Dec 13, 2010
    Posts:
    144
    Hi!
    This is on iOS.
    I'm deploying to an iPhone 6s. I'm using Unity 2017.2.0f3, macOS 10.12.
     
  4. martonekler

    martonekler

    Unity Technologies

    Joined:
    Feb 5, 2015
    Posts:
    31
    Hi!

    Are you deploying for Metal? When you see the spikes, what kind of render target and vertex format setup do you have?
     
  5. roberto_sc

    roberto_sc

    Joined:
    Dec 13, 2010
    Posts:
    144
    Hi.
    Deploying for Metal. Rendering to the... screen... ? (not to a RenderTexture). Sorry, I'm not a shader guy, I'm not sure what you mean by your questions :( Can you please elaborate, I can investigate further.

    By the way, the scene is a bit complex (multiple people creating content all the time in the project) so I even don't know what game objects are using those shaders when the spikes happen, is there an easy way to find out?
     
    Last edited: Jun 1, 2018
  6. roberto_sc

    roberto_sc

    Joined:
    Dec 13, 2010
    Posts:
    144
    Guys... did you give up on me? :(
     
  7. martonekler

    martonekler

    Unity Technologies

    Joined:
    Feb 5, 2015
    Posts:
    31
    Sorry for the delay!

    These spikes can happen if the render pipeline setup for a shader doesn't match the ones used during shader prewarming. This can be due to various reasons:
    - the render target pixel format. Could you check if your camera is rendering directly to backbuffer or to a RenderTexture? If the latter, what is its pixel format?
    - what is the vertex structure of the mesh you are rendering? it is default or some custom?

    I'm not aware of an easy way to spot which object is using those particular shaders.

    Did you doublecheck shader variants applied?

    Could you file a bugreport with a repro project?
     
    Neiist likes this.