The shader cache is managed by the GPU driver. Based on my testing on Windows with a Nvidia GPU, the shader cache is shared between different Blender versions. This means that when you update to a new Blender version, you still have a semi-useful shader cache. I say semi-useful because some of the shaders may have changed due to code changes and need to be compiled again because their current form is not in the cache.
Due to development primarily focused on EEVEE-Next, itâs much more likely that a shader would of changed in EEVEE-Next and not EEVEE, and so you can reuse more/all shaders from the cache in EEVEE, but not in EEVEE-Next. Which would make EEVEE shader âcompile timesâ shorter than they should be compared to EEVEE-Next that would still have significant parts re-compiled.
If you want to do this test properly, you will need to clear your GPU shader cache for Blender, test one render engine (EEVEE), probably close Blender, clear the GPU shader cache, and test the next one (EEVEE-Next). And I have done my own testing with this technique:
Testing
I ran a shader compile time test (with shader cache clears between runs) on a semi-complex scene I have and here are the compile times:
EEVEE: 65 seconds
EEVEE-Next: 106 seconds
The performance ratio is a lot different from your results. So I investigated further:
In these render engines, there are two âtypesâ of shaders important for the thing Iâm going to talk about. General shaders and Material shaders.
- General shaders are shaders that are going to be there in every scene and is entirely controlled by the developers at Blender. The shaders do not change between scenes. These should only need to be compiled once per Blender version (ignoring various factors that may end up removing these shaders from the shader cache).
- Material shaders are the shaders that are generated from the materials that we make in the shader editor. These change between scenes, and you will need to compile most material shaders you make.
Letâs figure out which type of shader is taking longer to compile in EEVEE-Next. The easy way is to open a simple scene with render settings that match my complex scene, but share very few to no material shaders. Wait for the shaders to compile and that will give us the âtime to compile General shadersâ. Then open up the complex scene and wait for the shaders to compile. This will give us the âtime to compile Material shadersâ.
And the results:
- EEVEE General Shaders: 2 second
- EEVEE-Next General Shaders: 27 seconds
- EEVEE Material Shaders: 65 seconds
- EEVEE-Next Material Shaders: 67 seconds
Note: Test data is imprecise due to single test runs and using a human controlled stop watch to measure the time.
Well, thatâs some useful results. Material shader compile times are pretty close (as would be expected). Itâs those âGeneral Shadersâ that make the most difference. And as mentioned earlier, you should only need to compile those General Shaders once per Blender version (once again ignoring the different ways it can get removed from the shader cache). So although it takes a lot longer to compile these âGeneral Shadersâ in EEVEE-Next, itâs only a one time cost meaning itâs not a major issue outside of the first run of EEVEE-Next from a clean/invalid shader cache.
This also explains the performance number differences between our two tests. Because only some parts of EEVEE-Nextâs shader compilation take longer than EEVEE. Which results in non-linear âcompile time scalingâ depending on the ratio of types of shaders used in a scene.
If I recall correctly, when compiling shaders for Unreal Engine, multiple threads are used for shader compilation. Assuming Blender and Unreal Engine were requesting the compilation of the exact same shaders, then with the shader compilation scheduling system used in Unreal Engine, you would process all the shaders roughly 6x as fast as Blender on your computer. (The 6x number is just an estimate. I assumed no hyper-threading and perfect multi-core scaling).
On the topic of what was mentioned above, based on my observations with Blender on a Windows machine with a NVIDIA GPU, shader compilation seems to be single threaded. This means compiling many shaders takes longer than it theoretically could take if Blender scheduled multiple shaders to be compiled concurrently (similar to Unreal Engine and some games with shader compilation stages).