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

Image garbage collection and on-demand loading #188

Open
dhardy opened this issue Apr 20, 2021 · 1 comment
Open

Image garbage collection and on-demand loading #188

dhardy opened this issue Apr 20, 2021 · 1 comment
Labels
low priority Not a near-term goal / not easily achievable

Comments

@dhardy
Copy link
Collaborator

dhardy commented Apr 20, 2021

As of #187, multiple images in multiple atlases are supported and paths are deduplicated. Images are loaded immediately (even if never used), and are only freed if manually cleared (which might not happen; drop handlers can't do so automatically).

On-demand loading

Potentially we can improve this with on-demand loading as follows:

  • load_path creates an ID, reads the path only to find the image size, and creates a mapping from the ID to the path and size
  • when creating a render queue using a not-loaded image ID, use the cached size to allocate to an atlas, and queue loading the image in a background thread
  • in images::Pipeline::prepare block until the image is loaded

Caveat: we end up reading from all used images twice. This may be worse than simply loading them?

Variant: add a hint in load_path controlling whether immediate loading happens.

GC / auto freeing

Given the above, we could implement some garbage collector, e.g. by adding frame-number-of-last-use to each image, to automatically free unused images.

@dhardy dhardy added the low priority Not a near-term goal / not easily achievable label Jun 15, 2021
@dhardy
Copy link
Collaborator Author

dhardy commented Aug 2, 2021

See also #44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low priority Not a near-term goal / not easily achievable
Projects
None yet
Development

No branches or pull requests

1 participant