[Mesa-dev] V7 On disk shader cache GLSL/i965

Timothy Arceri timothy.arceri at collabora.com
Tue Nov 29 03:57:59 UTC 2016

This series applies on top of these to clean-up series [1] and [2] please
reviews those patches first.

[1] https://patchwork.freedesktop.org/series/15613/
[2] https://patchwork.freedesktop.org/series/15775/

- support for SSO added.
- rebased/reworked on top of my work to rework the gl structs, many previous
 hack and work arounds removed. Fallback support is now much cleaner and
 less hacky.
- Added fallback support for programs that use FragData bindings.
- Fixed off by 1 bug with attribute binding fallback as the
 string_to_uint_map hash table offsets everything by 1 which we didn't allow
- Lots of other clean-ups and improvements.

- rewrote a bunch of the i965 shader cache functions to reduce
- fixed some i965 bugs that only happen when falling back to a full
 recompile when a cache object is deemed invalid (created with different
 mesa version).
- added env var to more easily debug bugs as described in previous dot
- Store all pointers as uint64_t.

- added support for caching shaders with transform feedback
 enabled by the in shader xfb qualifiers now ARB_enhanced_layouts
 is enabled.
- rebased on last 3 months of Mesa changes

- lots of reworking patches to remove code churn should be much nicer now
- fixed fallback when shader has been detached
- fixed a couple of bugs with UBOs
- no more printfs, debug info is behind an environment var
- various cleanups, tweaks and fixes
- add support for geometry and tessellation stages
- cache clip planes
- reserve parameter storage before restoring list
- stop losing  buffer blocks on cache fallback
- lots of little fixes I cant remember

- rebased on master
- add support for encoding doubles
- renamed skip_cache params to is_cache_fallback, and fix related bug
 when  disabling shader cache for xfb.

This series is based on the great work done by Carl, Kristian and

This series enables on disk shader cache for all stage except compute
programs also for now programs using transform feedback (when enabled via the
 API) skip using the cache, these will be added as follow ups.

The last two patches are not needed but it seems safer to just store
separate shaders for different platform to avoid any future bugs which
we are unlikely to do regression testing for since there is no real
advantage in sharing the cached shaders.


Enabling shader cache with the Shadow of Mordor benchmark make things noticeably
smoother and helps consitently keep the min FPS at 15 on my Skylake,
were as without it can be anywhere between 4-15.

The elemental demo which Dave pointed out as also doing a bunch of
compiles during the demo is also smoother especially on the second run
but its really slow on my Skylake regardless. Maybe someone with a
highend Skylake would like to give it a try.

You can find the series in the shader-cache38 branch of:


MESA_GLSL_CACHE_ENABLE=1 - enables the cache.
MESA_GLSL=cache_info - enables some debug messages

More information about the mesa-dev mailing list