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.

Bug Shaders seem to cache miss and recompile too often

Discussion in 'Universal Render Pipeline' started by strich, Feb 22, 2022.

  1. strich


    Aug 14, 2012
    I'm currently investigating and trying to improve our build pipeline. By far the largest time sink in the build process is URP shaders. We have about 350 unique URP shaders in our project. After doing some investigating and fixes to our shader template I have been able to get our shaders to build on average about 150 variants each. On a fresh clean build this takes about 1.5 hours. This is acceptable for a fresh build I think.

    However, I am really struggling with subsequent builds. Our project uses Asset Bundles for all content and right now Unity fails to recognise that it has already built and presumably cached unchanged shaders (and asset bundles for that matter), but most of the time it does not.

    Subsequent builds still seem to cause Unity to perform a shader stripping preprocessing step on each build. This takes about 10 minutes per build after an initial clean build.

    It is not clear to me why it does this, and I don't know if this is a problem with URP performing the stripping preprocessing action or if something is wrong with Asset Bundles system not checking if it needs to rebuild them. I have raised a forum post over there just in case.

    I currently can't dive much deeper as I've no data to draw upon. It would be great to get some insight from a Unity dev about the interplay between Asset Bundle builds and the URP shader stripping preprocessor - Is it wasting time?