Skip to content

Engine → Assets

asset_types.h

Identity, states and constants shared by every asset header.

Enumerations

asset_load_priority

enum class asset_load_priority : u8 {
    LOW = 0,
    NORMAL,
    HIGH
};

Dispatch order of queued loads; FIFO within a level.

asset_state

enum class asset_state : u8 {
    UNLOADED = 0,
    QUEUED,
    LOADING,
    FINALISING,
    LOADED,
    RELOADING,
    FAILED
};

Lifecycle of a slot. LOADED and FAILED are terminal for dependency gating.

asset_type_flags

enum class asset_type_flags : u32 {
    NONE = 0,
    RELOAD_WITH_DEPENDENCIES = 1 << 0,   // hot reload reloads instances when a dependency changed
    EXCLUDE_FROM_PACK = 1 << 1,          // never cooked into content.cpak (script sources)
    PINNED_FALLBACK = 1 << 2             // the fallback is created at registration, not lazily
};

Per-type behaviour switches set at registration.

asset_type_id

enum class asset_type_id : u64 {
    INVALID = 0
};

Identity of an asset type: make_asset_type_id("conjure.renderer.texture"). Stored in blob headers and pack tables, so the value never depends on compiler or platform.

Type Aliases

asset_id

using asset_id = core::uuid;

Stable identity of an asset or sub-asset. asset_id{} (the null uuid) means "no asset".

Concepts

declared_asset_type

template <typename AssetType> concept declared_asset_type = requires { { asset_type_traits<AssetType>::NAME } -> std::convertible_to<std::string_view>; { asset_type_traits<AssetType>::id() } -> std::convertible_to<asset_type_id>; };

True when AssetType was declared with CONJURE_DECLARE_ASSET_TYPE.

Forward Declarations

asset_type_traits

template <typename AssetType> struct asset_type_traits;

Compile-time description of an asset type, specialised through CONJURE_DECLARE_ASSET_TYPE. Provides static constexpr std::string_view NAME and static constexpr asset_type_id id().

Constants

Name Type Value Description
ASSET_LOAD_PRIORITY_COUNT inline constexpr usize 3 Number of priority levels.
COOKED_BLOB_FORMAT_VERSION inline constexpr u32 1 Format versions written into blobs, packs and .meta files. Bumping one invalidates every artefact of that kind.
DEFAULT_MAX_JOBS_IN_FLIGHT inline constexpr u32 8 Default number of load jobs the manager keeps in flight.
DEFAULT_WATCH_INTERVAL_SECONDS inline constexpr f64 0.5 Default interval of the polling file watcher, in seconds.
detail::FNV1A64_OFFSET_BASIS inline constexpr u64 0xCBF29CE484222325ull
detail::FNV1A64_PRIME inline constexpr u64 0x00000100000001B3ull
MAX_ASSET_TYPES inline constexpr usize 256 Upper bound on registered asset types.
META_SCHEMA_VERSION inline constexpr u32 1
PACK_FORMAT_VERSION inline constexpr u32 1
RETIRE_FRAMES inline constexpr u64 2 Frames a retired payload stays alive after the publish that replaced it.

Macros

CONJURE_ENUM_FLAGS

CONJURE_ENUM_FLAGS(asset_type_flags)

Functions

Public

detail::fnv1a64

[[nodiscard]] constexpr u64 fnv1a64(std::string_view text) noexcept;

64-bit FNV-1a of the bytes of a string, usable in constant expressions.

is_terminal

[[nodiscard]] constexpr bool is_terminal(
    asset_state state) noexcept;

True for LOADED and FAILED: the states a dependent may finalise against.

make_asset_type_id

[[nodiscard]] constexpr asset_type_id make_asset_type_id(
    std::string_view name) noexcept;

Hashes a type name into its id. An empty name yields INVALID.

to_string

[[nodiscard]] CONJURE_API std::string_view to_string(
    asset_state state) noexcept;

Upper-case name of a state ("LOADING").