Skip to content

panfrost: Plumb in the shader disk cache (+ shader precompiles + clean up + bonus bug fixes)

Alyssa Rosenzweig requested to merge alyssa/mesa:panfrost/disk-cache into main

The goal of this series is to implement a disk cache. The disk cache itself is mostly handled by common code in Mesa, there's just a bit of driver plumbing needed. The plumbing for pan_disk_cache.c began as a copypaste of iris but has mostly diverged since then. That last commit is pretty simple, but depends on the rest of the series to:

  • Clean up our shader variants infrastructure. The simplicity of the disk cache is riding on this clean up, I wanted to be able to look at a panfrost_compiled_shader and know that I'm serializing everything it needs.
  • Precompile shaders at CSO create time. Frankly I should've done this years ago. With the shader variants clean up this became nice and simple indeed.
  • Varying linking bug fix. Apparently some dEQP tests compile shaders but don't use them. We were passing these trivially by not compiling anything (because no precompiles). With precompiles the tests actually run and a few crashed due to varying linking issues. I'd been putting off rewriting the varying linker to use lowered I/O instead of nir_variables, here was my opportunity to do it.
  • Stop relying on nir_variables. With the linker rewritten they're not needed for anything of note, lowered I/O is easier to use, and this means we can strip variables if we want. A near-future extension to this MR would be to strip variables in our finalize_nir to reduce the on-disk GLSL->NIR shader cache size, so this deals with those blocks.
  • Bonus Midgard bug fix for separate shaders, to confirm correctness of the above (especially the new varying linker, which is complicated mainly by separable shaders).

While the code here works, there are some outstanding todo's:

  • Driver (PAN_MESA_DEBUG) and compiler (MIDGARD_MESA_DEBUG, BIFROST_MESA_DEBUG) environment variables are ignored in the cache logic. This is pretty simple to fix.
  • Implement finalize_nir to help the GLSL->NIR cache here.
  • Some extra copying that should probably be optimized out.
  • So far this caches shaders at the Gallium CSO level. Internal shaders from src/panfrost/lib bypass the disk cache. It's unclear how much win we get from disk-caching blit shaders, but we definitely want to consider caching the indirect dispatch/draw shaders on Mali-G52 because they're massive.
  • Finish the Midgard bug fix, there's a HACK in here. Possible hardware bug to workaround, needs investigation. Should not block the rest of this series, of course.
Edited by Alyssa Rosenzweig

Merge request reports