Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API for buffer age #90

Closed
ids1024 opened this issue Apr 7, 2023 · 1 comment
Closed

Add API for buffer age #90

ids1024 opened this issue Apr 7, 2023 · 1 comment

Comments

@ids1024
Copy link
Member

ids1024 commented Apr 7, 2023

Compare https://registry.khronos.org/EGL/extensions/EXT/EGL_EXT_buffer_age.txt:

        For example, with a double buffered surface and an
        implementation that swaps via buffer exchanges, the age would
        usually be 2. With a triple buffered surface the age would
        usually be 3. An age of 1 means the previous swap was
        implemented as a copy. An age of 0 means the buffer has only
        just been initialized and the contents are undefined. Single
        buffered surfaces have no frame boundaries and therefore
        always have an age of 0.

We can have a method on softbuffer::Surface, something like fn age(&self) -> Option<NonZeroU8>. An application rendering with softbuffer could use this to avoid redrawing everything every frame when not much has changed, regardless of whether a backend uses double-buffering, etc.

Currently buffer_mut is documented saying "The initial contents of the buffer may be zeroed, or may contain a previous frame." So this would provide a way to know which previous frame.

@ids1024
Copy link
Member Author

ids1024 commented Apr 10, 2023

The way this interacts with buffer resizing is interesting. Depending on the backend, it may be able to grow or shrink a buffer while using the same memory. If height increased, it may only be necessary to draw the extra height. If width changed, everything needs to be shifted over.

It could return an age of None here like a fresh buffer, but we'll have to be clear that this doesn't guarantee a zeroed buffer then (not that it matters, generally, since an application typically won't rely on the default value of the buffer).

ids1024 added a commit that referenced this issue Apr 26, 2023
ids1024 added a commit that referenced this issue Apr 26, 2023
@ids1024 ids1024 closed this as completed in 29b3f4a Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant