Skip to content

AsyncLoading

Narta Xaymar Dirks edited this page Oct 28, 2026 · 7 revisions
BlitzLLVM

AsyncLoading 〔BlitzLLVM〕

AsyncLoading:Void enabled:Int32
Parameter Mode Type Default Description
enabled In Int32 required True to load on other threads, False to wait for every picture and model.

Description

〔BlitzLLVM〕 This command does not exist in the original Blitz products. BlitzLLVM adds it.

Turns loading of pictures and models on other threads on or off. It is off at first, and the environment variable BLITZLLVM_ASYNC_LOAD=1 turns it on for a program without changing it. With it on, LoadTexture and LoadImage read the file at once and return a handle, and the decoding of the picture goes on while the program does other things. Finished pictures are put on the graphics card a little at a time while frames are shown with Flip, so a loading screen that flips does not stall at the end. Whatever else needs a picture waits for it: drawing, TextureWidth, ImageWidth, ReadPixel and every other command that uses it. TextureReady and ImageReady tell whether it is done without waiting.

LoadMesh and LoadAnimMesh also read the file at once, and parse it on another thread, together with the vertices and normals of its surfaces. They return an entity that is empty until something asks for it: any command that uses the entity (including moving it) builds the model first, and waits if the parsing is not done. A program that loads many models first and uses them later gets them parsed side by side. EntityReady tells whether the model is built and its textures are loaded, and Flip builds finished models a little at a time. The textures of a model are loaded as above. A program that loads many pictures and does other setup in between gets faster, and one that uses each picture right after loading it gains only what decoding several at once brings.

LoadTexture and LoadImage still give 0 for a file that is missing or is no picture. A file that is a picture or model by its header but cannot be decoded (a cut off download, for example) cannot give 0 any more: the program stops with an error the first time it uses it, instead of at the load (a model that cannot be read stops the program with a message that names the command). Models in DirectX .x format and files that are no model are loaded as before. Cube maps and sheets of frames are loaded as before. Changing the setting does not change pictures that are loading already.

A program compiled with -d (a debug build) ignores this command and BLITZLLVM_ASYNC_LOAD, and always loads on the spot: a file that cannot be loaded or decoded then stops the program at the command that loaded it, and not at the first use. Release builds do what is described above.

This is a BlitzLLVM extension: the originals load every picture and model before the command returns.

Differences

  • With asynchronous loading on, a picture or model with a valid header that cannot be decoded raises its error when it is first used and not as a 0 from the load.

Related Commands

AsyncSaving 〔BlitzLLVM〕, AutoMidHandle

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally