Umbra::AssetJob class

A request to either load or unload a texture/mesh/material.

Any assets associated with an AssetJob have already been downloaded or read from disk, but may remain in compressed or in an otherwise not immediately usable form. As such, any assets should ideally be fetched to application controlled memory outside any render thread before being used in any performance-sensitive thread.

Public types

enum JobType { StreamIn, StreamOut }
What should be done.
enum AssetType { Material, Texture, Mesh }
Type of asset to load/unload.
enum JobResult { Failure, OutOfMemory, Aborted, Success }
Result of streaming job. StreamOut jobs are expected to always succeed.

Public functions

auto getJobType() const -> JobType pure virtual
Distinguishes between load and unload tasks.
auto getAssetType() const -> AssetType pure virtual
Type of asset to process.
auto getMaterialData() -> const MaterialData* pure virtual
Get MaterialData if getAssetType is Material.
auto getMeshLoader() -> MeshLoader* pure virtual
Get MeshLoader if getAssetType is Mesh.
auto getTextureData() -> const TextureData* pure virtual
Get TextureData if getAssetType is Texture.
auto getUserPointer() -> UserPointer pure virtual
Gets the user pointer if getJobType() == StreamOut.
void finish(JobResult status, UserPointer userPointer) pure virtual
Inform Runtime of AssetJob completion.
auto abortRequested() const -> bool pure virtual
Query if this job should be aborted.

Enum details

enum Umbra::AssetJob::JobType

What should be done.

Enumerators
StreamIn

Asset should be loaded.

StreamOut

Asset should be unloaded.

enum Umbra::AssetJob::AssetType

Type of asset to load/unload.

Enumerators
Material

Job expects loading a MaterialData.

Texture

Job expects loading a TextureData.

Mesh

Job expects loading a MeshData.

enum Umbra::AssetJob::JobResult

Result of streaming job. StreamOut jobs are expected to always succeed.

Enumerators
Failure

Operation failed.

OutOfMemory

We're out of memory to stream in assets.

Aborted

Abort was requested.

Success

Operation succeeded.

Function details

AssetType Umbra::AssetJob::getAssetType() const pure virtual

Type of asset to process.

Depending on the type of asset, either getMaterialData, getMeshData or getTextureData can be called to get the actual data.

void Umbra::AssetJob::finish(JobResult status, UserPointer userPointer) pure virtual

Inform Runtime of AssetJob completion.

Parameters
status Success/failure of AssetJob. A job can be failed safely for transient reasons, failed jobs will be retried in a later frame if the asset remains relevant. Umbra does not directly limit memory use if OutOfMemory is used. Instead, the quality requested from any View should be reduced to limit asset memory use.
userPointer User-defined identifier for the asset resulting from this job. Umbra will use this later to refer to the asset. userPointer is ignored for StreamOut jobs.

Any AssetJob may be active for an arbitrary time. Calling finish informs Umbra that the asset is now usable. After this call the given UserPointer may appear when using the API.

While many AssetJobs can be active at any one time, finish should be called as soon as possible to let Umbra use assets or start jobs loading dependent assets.