Add shader hooking mechanism
Much like mpv, we need some sort of “hooking” mechanism to allow users to insert their own processing (shaders etc.) into the rendering pipeline. This is needed in particular to retain compatibility with the mpv user shader system, but is surely also interesting for others.
Some design goals/notes:
- Instead of bothering with difficult text parsing like mpv, just communicate everything as C structs and raw textures
- We could either use a callback-oriented architecture (user provides a function which gets called with some useful arguments, user can do what they want) or a static struct/metadata architecture. The former would most likely make the most sense, in order to allow users to leverage our whole shader system - in which case we need to figure out what state to expose and how to do so safely
- Obviously, users will need some ability to wrap custom shaders into our
pl_shader
abstraction. Most likely, we will allow users to provide their own verbatim functions which then get called (as appropriate for the signature type) by some function likepl_shader_custom_glsl
- Maybe we will need to open up
sh_lut
,sh_bind
etc. somehow to users? Possible, but requires tying off some loose ends. More likely, we'll allow users to just straight up name and specify their own descriptors and variables. The chance of a collision is basically nonexistant with our naming scheme. - (Optional) We could possibly reorganize the control flow of the renderer into CPS style or something and actually allow users to decide to cut off the rendering at that point rather than just inserting hooks. Basically, say a user only wants the
LINEAR
stage, but doesn't care about the rest. But I think this is rather unlikely, since complexity of the renderer logic is a heavy cost to pay for an obscure feature that can be implemented by users with the libplacebo shader system anyway.