carb::assets::HashAssetFn

Defined in carb/assets/AssetsTypes.h

using carb::assets::HashAssetFn = AssetHash (*)(carb::datasource::IDataSource *dataSource, carb::datasource::Connection *connection, const char *path, const uint8_t *data, size_t size, const LoadParameters *loadParameters, LoadContext *context)

Loader function (member of LoaderDesc) that hashes an asset’s data, this is used to combine collisions in the asset system.

This function is optional; if not provided, the path of the loaded file is hashed.

If two different files return the same hash, then the system will return a copy of the first asset load. An example of where this is useful is programmatically generated shaders. In this context this system ensures that only one unique shader is created from many sources that generate the same shader.

Param dataSource

The datasource the asset is being loaded from.

Param connection

The connection the asset is being loaded from.

Param path

The path of the file that is being loaded.

Param data

The data to be loaded.

Param size

The size of the data (in bytes) to be loaded.

Param loadParameters

The load parameters passed to IAssets::loadAsset().

Param context

A context generated by CreateContextFn, if one was provided.

Return

The hash of the asset.