Search Unity

Profiling Shader.CreateGPUProgram

Discussion in 'Editor & General Support' started by teaMate_, Jun 1, 2014.

  1. teaMate_

    teaMate_

    Joined:
    Apr 15, 2014
    Posts:
    7
    Hi,

    can someone give me a clue on what Shader.CreateGPUProgram does?
    The name seems self-explanatory but i actually don't get it, and why are multiple calls issued?
     
  2. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    I wish to know about this also?
     
  3. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    It's the submission of a shader to the graphics card, which includes the graphics card driver compiling it into a card-specific format.

    You may want to look into ShaderVariantCollection.
     
    SolidAlloy and siddharth3322 like this.
  4. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,362
    I think the way to optimize CreateGPUTime is:
    1. go in Graphics, press Clear
    2. run a few levels of the game in the editor
    3. Graphics variant count went up
    4. Save to assets then drop that Variant asset in the preloaded shaders array
    correct?
     
    TerminalJack, lrb and StenCG like this.
  5. Hyperg

    Hyperg

    Joined:
    Jul 6, 2015
    Posts:
    19
    I've been trying to optimize our async level loading times and one of the profiling issues I've recently encountered is the Shader.Parse call (which leads to the shader gpu programs stall).

    Our setup uses asset bundles to load assets and scenes which seems to invalidate the regular shader preload technique (because the materials in the bundles refer the bundled shaders, not the ones baked into the ShaderVariantCollection added to the player graphics preload slot). So i've replaced that with a "manual" warmup that is done by our loader scene, so basically it warms up the same shadervariantcollection asset, but which is now baked into the bundles. Note that the shader collection is a complete level gather of shaders (according to the Unity built-in tracking system).

    The problem is that I'm still getting those shader parsing spikes which makes me wonder how is that possible with the shader variants being already warmed up?
     
  6. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    If for this problem, ShaderVariantCollection is a solution then can you guide me further into this?
    How to use ShaderVariantCollection within the game or setup?
     
  7. Ryan_McMahon

    Ryan_McMahon

    Joined:
    Oct 11, 2015
    Posts:
    5
    Any ideas why it would be taking up 97% of our project startup time?
    ShaderCompileTime.png
     
  8. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,362
    unity version ?
    2020.3 and above has regressed massively with up to 70% slowdown, if that's the case log a bug and report in this thread as well as the 21.2 alpha to prioritize fix
     
  9. Ryan_McMahon

    Ryan_McMahon

    Joined:
    Oct 11, 2015
    Posts:
    5
    This is in 2020.3.2 (you guessed it). We upgraded from 2019.3.0. Our team is reverting back to 2019 but I'll be sure to link the bug report in multiple places if I file one. The only thing blocking me from reporting a bug is the thought of stripping down our project. Do you think that's necessary?
     
  10. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,362
    not in cases like these - they need real life projects
     
  11. mzage31

    mzage31

    Joined:
    May 7, 2017
    Posts:
    3
    @Ryan_McMahon The same happened to me on android when using new Texture2DArray();