RadeonSI's Mesa Shader Cache Can Be A Big Help To Modern Linux Games

Written by Michael Larabel in Linux Gaming on 4 March 2017 at 06:40 PM EST. Page 1 of 4. 28 Comments.

With the rest of the RadeonSI shader cache support landing in Mesa, I have carried out some benchmarks to measure the impact of this on-disk GLSL shader cache not only for the performance of games but also the reduced load-times.

Thanks to the work by Timothy Arceri, who is now employed by Valve to work on the open-source AMD Linux driver stack, RadeonSI finally has a GLSL on-disk shader cache similar to what's been available for years within the proprietary AMD/NVIDIA graphics drivers. Landed recently was the ability to cache the TGSI Gallium3D IR, as a helpful caching step, while hitting Mesa Git just this week was the ability to cache the hardware-specific compiled shaders for quicker execution on the GPU. The TGSI shader cache works with both R600g and RadeonSI and can be easily adapted to other Gallium3D drivers while this latest RadeonSI shader cache code is driver-specific but still leverages the existing Mesa shader cache work that's been built in patches over the past few years.

If running Mesa 17.1 Git, the RadeonSI shader cache isn't yet enabled by default. But it may be enabled by default soon. In the meantime you can set MESA_GLSL_CACHE_ENABLE=1 as an environment variable prior to your GLSL-heavy workloads to benefit from this shader caching. The default cache location is ~/.cache/mesa/. (Note for those running Phoronix Test Suite benchmarks with Steam games and setting the env var, make sure you also launch Steam with the MESA_GLSL_CACHE_ENABLE. While the Phoronix Test Suite launches each game's benchmarking process on its own after mirroring how Steam sets up each game's environment, without setting the environment variable for the Steam process, the caching doesn't seem to work.) Tests for this article were done with a Radeon RX 480.

For this RadeonSI shader cache benchmarking I first ran tests on Mesa 17.1-dev Git from the Padoka PPA as of 3 March, which is built after the RadeonSI shader cache landed. I did these tests normally with the shader cache being disabled by default. After that I re-ran the tests via the Phoronix Test Suite with the shader cache enabled but without saving the results, in order to cache the shaders. Then I ran the tests a second time, saving the results, and keeping the RadeonSI shader cache enabled.

Mesa Shader Cache RadeonSI

Besides looking at the frame-rate advantage, I also compared the run-times of before/after the caching process. Thanks to the Phoronix Test Suite fully automating the benchmark runs in a repeatable manner, it's easy to time the before/after results. Plus with the Phoronix Test Suite executing each benchmark multiple times for accuracy, these load times should be very accurate. With the Phoronix Test Suite's modular architecture, I added a simple module to PTS7 where when the RUN_TIMES_ARE_A_BENCHMARK=1 environment variable is set, it will record the time each benchmark runs and plot that as its own graph. That way we can compare the affected run-time, in this case caused by the RadeonSI shader cache. It's that easy with the Phoronix Test Suite benchmarking! During this benchmarking, as usual, I kept Steam in offline mode to avoid any syncing delays with the Steam servers causing time differences.


Related Articles