Chia-I Wu recently sent out a set of 21 patches for Mesa that add a thread pool to Mesa's GLSL compiler and a new DRI option for defering glCompileShader calls to this pool. These changes are to reduce start-up time of applications that can handle defered compilation of GLSL shaders. When going through this thread pool, the shader compilation process is much faster across multiple threads while returning asynchronously with the compile shader call.
Intel's Ian Romanick has begun reviewing the patches. Pierre-Loup A. Griffais followed-up to explain the benefits at length. Pierre-Loup says that the shader compilation time on OpenGL is a real problem for both developers and users while in the Direct3D world threaded shader compiles and lazy shader reflection have been around for a long time.
When testing the patches, Dota 2 is running with a 20 second reduction in loading times across the board for an Intel-powered Gigabyte Brix Pro system. Valve is already merging these patches into their SteamOS Mesa branch and will be shipping it as part of their next driver release cycle for SteamOS.
Aside from needing a patched version of Mesa, the DRIRC option also needs to be set for this deferred and threaded OpenGL shader compilation process, but Pierre-Loup also mentioned they are already working on updated builds of Counter-Strike: Global Offensive and Dota 2 for Linux to automatically take advantage of the feature. Valve is also encouraging other game developers to begin taking advantage of this feature. This statement is also very interesting since Valve hasn't publicly released Counter-Strike: Global Offensive to Linux gamers, but we know it's already been ported and Linux driver developers have been working to optimize CS:GO -- hopefully with a better open-source experience, CS:GO could be publicly released for Linux/SteamOS gamers.
Some more context on the intent: we're having this work done because shader compilation time on OpenGL is a real issue that both end-users and developers run into on a daily basis. Threaded compiles and lazy shader reflection have been part of the D3D ecosystem for a long while. Here's a sample that contains several data points to put this into perspective:
I'm happy to say that when applying this patch series to my Mesa branch and changing ToGL in DOTA2 to perform lazy shader reflection, I'm seeing a 20s reduction in loading times across the board on a Brix Pro machine, from starting the client to getting in-game.
This is a very promising start and I will be merging this patch series to the SteamOS Mesa branch, and ship it as part of our next driver release cycle.
We will also be releasing updated builds of CS:GO and DOTA2 for Linux to take advantage of that feature; we encourage developers shipping on Linux to use that same pattern when compiling their shaders as well as enabling this new feature in their environment, as it's too good to pass on.
Thanks a lot,