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

Asynchronous image loading to aid HDD bottlenecking #342

Closed
oomek opened this issue Apr 14, 2017 · 4 comments
Closed

Asynchronous image loading to aid HDD bottlenecking #342

oomek opened this issue Apr 14, 2017 · 4 comments

Comments

@oomek
Copy link
Collaborator

oomek commented Apr 14, 2017

Have you ever considered a possibility of using async method on loadFromFile() or asynchronously load an image to memory and then call loadFromMemory() function?

In the current state Attract Mode is choking on fast updating artworks. When they are loadded from HDD the animations are freezing until reading finishes. Using SSD helps, but not everyone can afford one with a decent capacity.

@cosmicdan
Copy link
Contributor

cosmicdan commented Apr 16, 2017

You seem to know what you're talking about - why not try it yourself and make a PR? ;)

I would try it, but I'm barely a code hacker when it comes to C(++). I wouldn't even know how to store the images in memory (creating some kind of ArrayList equivalent), let alone how to handle the buffer sizes (we obviously don't want to load EVERY image into memory, but rather the next/previous n amount), etc...

..unless by async you just mean loading images in a second thread (so it doesn't block the UI)?

@oomek
Copy link
Collaborator Author

oomek commented Apr 16, 2017

You do not to have all the images stored in memory. It's just a matter to handle the image loading asynchronously to the main thread. SFML is not multithreaded, but It can be done in 2 ways. You create a separate thread which loads an image to the buffer, or you call async to load it in a lambda expression. Once you've checked it's done loading in the main thread you can load the texture from memory the normal way and it will be without any delay. I've tried async few day ago, but since textures in AM are not static objects I've had some compiler errors. I'm not a guru in c++ either, but I can try the multithreaded method later. You do not need to worry about the memory buffers management as it is done automatically and as long as you load a whole png to memory, not just a raw bitmap you just pass the &buffer[0] and buffer.size() to the loadFromMemory() function and it decodes automatically.

@popoklo
Copy link

popoklo commented Jun 12, 2017

i think this is a very important thing for AM, I stopped directly working on theme because of massive HDD loading for rapid fileloading.

@mickelson
Copy link
Owner

Closing as a duplicate of #179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants