mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 13:11:19 +01:00
This adds AsyncPipelineStateManager to the render code, which handles the background processing of draw shader creation (not, at the moment, other shader types...there's no reason those couldn't be added as well, but this seemed the biggest target).
If a given shader has not been compiled yet, we will fall back on an ubershader version with all features enabled
the ubershader version will be compiled synchronously if it does not exist yet
For the D3Ds, this is done with a background thread that compiles the shaders.
GL, however, does not seem to play nice with background threading shader creation. But what it does have is the KHR_parallel_shader_compile extension, which basically lets the driver create threads in the background and thread the shader compilation.
The shader manager, in this case, needs to poll the completion state every time the shader is requested and potentially push the compilation along to the next stage (i.e. once linkProgram has completed, then we can do the rest of our setup)
If KHR_parallel_shader_compile is not supported (for instance, with WebGL on Firefox) then shader compilation will just happen synchronously (I could not find a clear way to thread the GL shader creation, but I would happily add it as a fallback if there is a way)
This change also updates our GLAD loader to version 2.0.8 (from 0.1.36!), which had some API changes.
Co-authored-by: JoshJRive <joshua@rive.app>