Draft: Add asynchronous buffer updates
After a lot of thinking, this is the API I settled on for resolving tone-mapping LUTs at runtime. It makes usage very straightforward (just treat it as any other fire-and-forget command), implicitly synchronizes with the rest of the command stream, and transparently downgrades to a synchronous command on GPUs that don't support asynchronous CPU->GPU writes (e.g. OpenGL, as I sadly discovered).
This is only one piece of the puzzle - the ultimate goal here will be to do something like:
pl_buf tmp_lut_buffer = pl_buf_create(...);
pl_buf_copy(src = peak_detect_ssbo, dst = tmp_lut_buffer);
pl_buf_update({
.buf = tmp_lut_buffer,
.update = read_peak_and_replace_by_lut,
.priv = tone_mapping_lut_params,
.async = true,
});
pl_tex_upload(src = tmp_lut_buffer, dst = tone_mapping_lut);
pl_buf_destroy(&tmp_lut_buffer);
The actual buffer update will resolve asynchronously on the CPU at some future point in time, quite possibly even several frames from now, when the results of peak detection become available.
TODO:
-
add support for windows threads -
figure out if we can solve the command submission error on libavutil hwcontext_vulkan master -
find a scenario where it actually even has a noticeable performance increase -
solve the asan issues
Edited by Niklas Haas