Details
-
Task
-
Resolution: Done
-
P1: Critical
-
None
-
None
-
Embedded with GLES 3.0+, primarily DRIVE CX. Desktop and mobile secondary.
-
85f868e73e4cf9dffe27b737f8dc3f5bb626ed04, f0e60aefa48e2299c14918983ffa1016fb4677ba, e8801e7c09414753a8e01a6be303c7922bbe023f
Description
Investigate pre-compiled shader programs (as in glProgramBinary in GLES 3.0 and up) in Qt.
Possible approaches:
- Use glGetProgramBinary to read back driver-specific linked programs. Could have a runtime disk cache in Qt (Quick), as already demonstrated on scenegraph-playground. This way the sources must still be shipped, and compilation happens on the first startup. ( + when driver / version string does not match anymore) Subsequent startups then just do a glProgramBinary and get the benefits.
- Some vendors provide host tools, like NVIDIA's glslc (proprietary, for embedded), which compile, link, and output glProgramBinary-suitable binaries.
- Other approaches don't really work (we cannot roll our own tool etc. due to (a) cross-compilation (b) the shader binaries being driver - and even driver version - specific.)
Cons:
- Batching uses shader rewriting therefore offline pre-compilation of shaders used by Qt Quick materials is not feasible.
- The OpenGL ShaderEffect's reflection is based on parsing shader sources. Offline pre-compiled shaders would require switching to GL program queries which are quite awful and pose various problems, like requiring a context.
Based on the above a runtime disk cache is the feasible solution, however:
- NVIDIA does shader caching on disk anyway, including on embedded.
- AMD too. WIP for Mesa? See https://www.phoronix.com/scan.php?page=news_item&px=Intel-Mesa-Shader-Cache-New
Might be wasted effort. Should benchmark first.