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.

Parameters
  • dataSource – The datasource the asset is being loaded from.

  • connection – The connection the asset is being loaded from.

  • path – The path of the file that is being loaded.

  • data – The data to be loaded.

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

  • loadParameters – The load parameters passed to IAssets::loadAsset().

  • context – A context generated by CreateContextFn, if one was provided.

Returns

The hash of the asset.