vo_gpu_next: only re-upload OSD textures when they change - #18352
Open
rlauuzo wants to merge 2 commits into
Open
vo_gpu_next: only re-upload OSD textures when they change#18352rlauuzo wants to merge 2 commits into
rlauuzo wants to merge 2 commits into
Conversation
`update_overlays()` uploads every `sub_bitmaps` item to its texture on every call, and `draw_frame()` calls it unconditionally, so an OSD that is not changing is re-uploaded at the display refresh rate rather than at the rate it actually changes. `vo_gpu` already avoids this: `gen_osd_cb()` compares `sub_bitmaps.change_id` against a cached copy and skips `upload_osd()` when they match. `osd_render()` computes that `change_id` for both VOs, so `vo_gpu_next` has the information and simply does not read it. This caches the id next to the texture and skips `pl_tex_upload()` when it matches. It also restricts `pl_tex_recreate()` to the cases where the size or format really has to change. That is not tidying: a reallocated texture has undefined contents, so the cached id would stop describing it. Restricting the call also removes any dependence on `pl_tex_recreate()` preserving contents when it is a no-op.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
update_overlays() uploaded every sub_bitmaps item into its texture on every call, and draw_frame() calls it unconditionally, so a static OSD was re-uploaded at display refresh rate rather than at the rate it actually changes.
vo_gpu already avoids this: gen_osd_cb() compares sub_bitmaps.change_id against a cached copy and skips upload_osd() when they match. osd_render() computes that change_id for both VOs, so vo_gpu_next had the information and simply did not read it. Cache the id next to the texture and skip pl_tex_upload() when it matches.
A change_id of 0 means the texture contents are unknown (osd.h guarantees 0 is never a real id), and it is written at every point where that becomes true: when an entry takes a recycled texture from the sub_tex pool, and on reallocation, before pl_tex_recreate() runs, so a failed recreate cannot leave a stale id behind. The upload check itself is then a single comparison.
pl_tex_recreate() is now only called when the size or format actually has to change: libplacebo documents that the call invalidates the texture's contents even when it does not reallocate, so calling it every frame would defeat the cache by contract. The old code could call it unconditionally because it always uploaded straight afterwards.
AI Disclosure: The patch was written with AI assistance. I understand what it does and why. The change is submitted under the same licence as
video/out/vo_gpu_next.c(LGPLv2.1+).