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

CreateGPUProgram(Standard) is being invoked on iOS without any objects using that material

Discussion in 'General Graphics' started by acondevillamar, Jul 26, 2018.

  1. acondevillamar

    acondevillamar

    Joined:
    Jul 11, 2017
    Posts:
    2
    Hello,

    Has anyone run into the issue where an extra call to "CreateGPUProgam(Standard)" is generated upon loading a prefab from an asset bundle using "LoadAssetAsync" ? The execution time of CreateGPUProgam tends to vary between 30 ms and 80,000 ms. Calling Shader.WarmupAllShaders and using the ShaderVariantCollection class to manually warm-up the Standard shader did not work either. Removing all materials that were referencing Unity's Standard shader did not have any effect.

    I was able to find a temporary solution by forcing the CreateGPUProgram call by invoking the LoadAssetAsync on all of the asset bundles that were causing the the performance spike. This allowed me to at least execute the heavy load during our game's initialization to hide behind a loading screen, but it's still unacceptable as it's increasing our loading time.

    I'd also like to point that the CreateGPUProgram is triggered for the other shaders that are actually being used by the prefabs. However, those originate from Camera.Render() -> some other calls -> CreateGPUProgram. When the CreateGPUProgram(Standard) shows up in the profiler it always comes from Application.Integrate Assets In Background -> EarlyUpdate.Preload > CreateGPUProgram(Standard).

    All of the materials that are being loaded along with prefabs from the asset bundles are using a very specific shader. None of these are Unity's Standard shader. Is there any way to implicitly trigger Unity to load the Standard shader even though there aren't any materials referencing it? Any help would be greatly appreciated.

    Thanks,

    Alan
     
    MGGDev likes this.
  2. hardcodednumber

    hardcodednumber

    Joined:
    May 26, 2014
    Posts:
    88
    I just upgraded my project to 2018.2, and I'm still seeing this issue.
     
  3. geretti

    geretti

    Joined:
    Dec 20, 2016
    Posts:
    10
    This has been issue for me as well, can we get an official answer from Unity?
     
  4. martonekler

    martonekler

    Unity Technologies

    Joined:
    Feb 5, 2015
    Posts:
    31
    Hi Alan,

    could you please file a bugreport with a repro for this issue so we can investigate?

    Thanks,
    Marton
     
  5. acondevillamar

    acondevillamar

    Joined:
    Jul 11, 2017
    Posts:
    2
    We've found a solution to this issue. When an FBX file is imported, go to the Materials tab and check the box "Import Materials". Then select the "Use Embedded Materials" option and link the appropriate material under the "Remapped Materials" section. We no longer saw any calls to CreateGPUProgram after making these changes.

    By choosing to not import materials, the engine automatically creates a material that uses the Standard shader. When the prefab is loaded (asynchronously) from an asset bundle, the CreateGPU program call is generated with varying invocation times. The most expensive call was when it attempted to load the Standard shader, but we also saw that it would load any other shader dependencies that the FBX needed. Also, this issue only happened on iOS so it seems like this could still be an actual bug.
     
  6. MGGDev

    MGGDev

    Joined:
    Nov 6, 2018
    Posts:
    27
    Happens on Android too, and I don't even have 3D prefabs in the scene.
    I think it is related to TextMeshPro. Now that I mention it, loading times increased too much around the time I added TMPro to my game.
    Frame 233:
    shader.png
    Frame 234:
    shader2.png
     
  7. martonekler

    martonekler

    Unity Technologies

    Joined:
    Feb 5, 2015
    Posts:
    31
    Hi MGGDev,

    Please file a bugreport for this!

    Thanks
    Marton
     
  8. KB73

    KB73

    Joined:
    Feb 7, 2013
    Posts:
    234
    We're also able to repro this in the editor - it is a big problem.
    We've found the Frame debugger will not accurately capture all shader keywords used esp on device

    Sometimes via material inspectors, shader keywords ( as can be seen via the debug inspector ) such as _ZWRITE_ON are not listed..not sure if this is part of the issue?
    Any idea on a possible fix?

    The CreateGPU is triggered via the camera. All the warmup solns do not work.

    One thing to be mindful, once the shader is made it appears to be cached on device/editor so you need to touch the shader file each time to replicate the issue or it will look like it is 'fixed'
     
    Last edited: Mar 1, 2019