Another quick update on my work threading zip loading and decompression of (at the moment) jpg files for loading into textures.
I finally got the rewrite working last night, though not without an occasional crash bug still present (did a bit of work cleaning that up morning).
Now it works like :
-
When a request comes in, check the zip file cache, if nothing there, create a new cached zip file object and call FIOSystem::LoadData to load the whole (compressed) file into mem, as well as set up the timer to check completion.
-
When the LoadData call finishes, go through the list of pending page requests, and create a new reader Worker to handle decompressing and filling a mipmap buffer (all Workers read from the single compressed zip buffer - threading ftw). Right now it’s set so only 5 workers can run at once.
-
When a thread finishes, copy the mipmap buffer into the Texture2D’s mip, free it up, remove the worker etc., and set the Texture2D into the cache.
Then in Blueprint I use a function to check the cache for a given zip file. When it’s available and Set Page is called to set it onto the material, it works
I need to debug getting rid of workers, as well as make it so that a loading material is used when Set Page is called but the desired page isn’t ready.
Best of all, the loading is 100% buttery smooth, no hitching or hangs in the main game thread - no mean feat when loading in images which are 2000x3000 resolution (roughly).
Eventually I’d like to make the file loading a bit more generic, and package up as a plugin on the Marketplace, so that other developers will be able to easily use .zipped files in their packaged games (works in editor, of course).
I can think of a lot of uses for being able to load in files inside a zip into in-game assets (I’ll probably not be supporting models, since there are issues with FBX import, at least not for the moment), namely being able to let users make their own mods