Handles the asynchronous loading of an Image texture.
Mipmapped textures are streamed if the driver supports the ResidentMips feature : the mip levels up to BASE_SIZE
are always loaded synchronously, the more detailed ones are loaded on demand with loadMips or loadSync.
Other textures having the AsyncLoading flag use a 1x1 black placeholder while the file is read asynchronously.
Static variables
staticCOMPLETION_TIME_BUDGET:Float = 0.002
Main thread time in seconds spent per frame applying completed reads (allocation and upload), at least one is applied.
staticENABLED:Bool = true
Set to false to disable mip levels streaming : textures are loaded at full resolution. Streamed textures then load their missing mip levels asynchronously, and are streamed again once it is set back to true.
staticHIDDEN_FRAMES:Int = 60
Frames without being visible (see Texture.markVisible) before a texture can lose mip levels.
staticMAX_LOADING_BYTES:Int = 256 << 20
The maximum size of the buffers used to read data asynchronously : other requests are queued until it's available. A request bigger than this size is read without waiting. The released buffers are kept for reuse within this size.
staticMAX_SIZE_RAISE_MARGIN:Float = 64 << 20
Extra free memory in bytes required to raise maxVisibleSize, on top of what the raise and the loads in progress need.
staticMAX_UNLOADS_PER_FRAME:Int = 4
Maximum number of mip levels released per frame when over budget, so that the reduction is spread over time.
staticMEMORY_BUDGET:Float = -1
Budget in bytes for the resident mip levels of all streamed textures, -1 for no limit.
staticMIN_GPU_FREE:Float = 256 << 20
GPU memory in bytes to keep free when the driver reports its memory usage (see Driver.getMemoryUsage), -1 to ignore it.
staticREDUCE_VISIBLE:Bool = false
Set to true to let visible textures lose mip levels (see maxVisibleSize) when releasing hidden ones is not enough to meet the budget.
staticdebugBudget:Float = -1
A virtual budget in bytes, combined with MEMORY_BUDGET (the smaller wins), to force streaming operations while profiling (see h3d.impl.TextureStreamProfiler). -1 when unused.
staticread onlyexcessBytes:Float = 0
Bytes over budget after the last updateStreaming, 0 or less when within budget.
staticread onlymaxVisibleSize:Int = 0
When visible textures alone exceed the budget and REDUCE_VISIBLE is set, the largest size (in pixels) they can load, 0 for no limit. It is halved from the largest visible texture size (a 4K texture becomes 2K) until the budget is met, and doubled back when it fits.
staticread onlyresidentBytes:Float = 0
Bytes of all streamed textures resident mip levels, computed by the last updateStreaming.
Static methods
Constructor
Variables
read onlytargetMip:Int = 0
The most detailed mip level requested, it will be reloaded if the texture is reallocated.
Methods
loadMips(mip:Int, ?onDone:() ‑> Void, priority:Float = 0.):Void
Load asynchronously the mip levels up to mip (0 for full resolution).
onDone is called when the texture is loaded (immediately if it is already loaded).
If the texture is not allocated, the mip levels will be loaded with it.
loadSync(maxSize:Int = 0):Void
Load synchronously the texture, up to the given size for streamed mip levels (0 for full resolution).
unloadMips(mip:Int):Void
Release the mip levels that are more detailed than mip.
The mip levels up to BASE_SIZE are always kept.
