[RFC] Weston GL shader compilation re-design
Harish Krupo
harish.krupo.kps at intel.com
Wed Jan 23 06:02:34 UTC 2019
Hi,
This is in continuation to the discussion in the mail chain here [1]. We
are currently working on enabling HDR rendering support in the
gl-renderer. HDR support requires color space conversion (709->2020 or
other way around) and Tone Mapping, for which, we need to execute the
following steps in the shader:
* Degamma (to linearize the buffer)
* Color space conversion (BT2020 -> BT709...)
* Tone mapping (SDR -> HDR, HDR -> SDR, HDR -> HDR conversion)
* Gamma: Apply gamma/transfer function for the display (PQ/HLG...)
We are currently targeting the DCI-P3, SRGB and 2084 color spaces. One
way to implement it would be to create multiple sets of shaders for each
degamma/gamma combination. Like the one done by Ville in his POC [2].
This solution was a POC, and isn't scalable when we need to support
multiple color spaces. I would like to propose 2 different solutions:
Proposal 1:
* Each of the shaders (gamma/degamma/main/tone mapping) would be
independent strings.
* When the view needs to be rendered, renderer will generate a set of
requirements like need degamma PQ curve, need tone mapping, need gamma
SRGB curve and so on.
* These requirements (NEED_GAMMA_PQ...) would be bit fields and will be
OR'd to create the total requirements.
* This total requirement would be used to stitch the required shaders to
compile a program. The total requirements integer will also be used as
a key to store that program in a hashmap for re-use.
Proposal 2:
We could go for multi pass rendering, where each of the steps (gamma,
csc, tone mappping, degamma) will be applied in different passes. Each
pass would bind an fbo and call draw elements with the corresponding
shader. This would not be as efficient but is another approach.
Please comment on the approaches and do suggest if there is a better
one.
Thank you
Regards
Harish Krupo
[1] https://lists.freedesktop.org/archives/wayland-devel/2019-January/039809.html
[2] https://github.com/vsyrjala/weston/blob/hdr_poc/libweston/gl-renderer.c#L257
More information about the wayland-devel
mailing list