Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » What is the fastest way to update the contents of a bitmap from disk?

This thread is locked; no one can reply to it. rss feed Print
What is the fastest way to update the contents of a bitmap from disk?
roger levy
Member #2,513
July 2002

I have an idea to create a game with built-in development tools and for that I'd like it to be able to quickly reload several large bitmaps from disk without the overhead of the driver re-allocating memory for them. I'd like it to be significantly faster than it would be for a regular game to load bitmap files from disk, to create the smoothest workflow.

One idea to speed it up could be to store them in a format that needs no processing, such as 8-bit single channel, and use an indirect color shader. Not necessarily trying to limit myself to palette graphics though. And being able to easily use external graphics editors would be nice, so support for at least a couple common image file formats would be ideal.

What do you think? How to accomplish the fastest and most direct route to getting bitmap data into the graphics driver memory? What causes the most delay during the process of loading bitmap files and turning them into usable textures?

beoran
Member #12,636
March 2011

The speed bottleneck for loading images from disk is the latency of the disk itself, not that of the memory used. The fastest way then to display an image is to keep it loaded in memory, caching and limiting disk access, perhaps with a worker thread that loads from and saves to disk.

Chris Katko
Member #1,881
January 2002
avatar

- If you want "super fast", put tons of files into a simple archive format (zip without compression, or tar). Low compression might also be faster in some cases which is the basis for NTFS compression (ample extra CPU cycles, for a lower data usage over the bottleneck of the disk).

- Another reason is because filesystem access is actually pretty slow. Dealing with many files, each with their permission check syscalls, etc.

- Put files on an SSD. Throw cheap hardware at it over smart algorithms since algorithms keep going.

- Put files on a RAM disk. (I have 32 GB on my system... it cost less than $100.)

- Only reload files that actually change. You could try something crazy like "rsync" to a cache of the file in memory, and only chance the actual data that's different. But I have no idea if the tradeoffs would balance in your favor the way they do for network connections.

I don't know. I mean, is loading bitmaps "that" big of a bottleneck on the driver side? I can't imagine any way to speed up / go-around the fact you'll "eventually" need to load a bitmap into a driver-specific format. Only load the graphics you need first, and load the rest in the background. There's no way the user needs EVERY bitmap possible in the game all at once. Even if s/he needs to "see" them all at once side-by-side, it'd still be mipmapped/thumbnailed versions. Even a 4K screen can only display... 4K... at once. So get the user what they actually want first, and bring in the rest, prioritizing what the user "might" click/view next (the next sequential image in a list).

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Go to: