vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::AssetCook Namespace Reference

Cooked binary asset format (derived cache). More...

Functions

uint64_t cacheKey (uint64_t recipeHash, AssetType type)
 The complete cache key for one cooked artifact.
bool writeMesh (const std::filesystem::path &path, const MeshAsset &mesh)
 Write one cooked file of each kind.
bool isCookedCurrent (AssetType type, const std::filesystem::path &path)
 Whether the cooked file at path can still serve type.
bool readMesh (const std::filesystem::path &path, MeshAsset &out)
 Read one cooked file of each kind.

Variables

constexpr uint16_t COOKER_VERSION = 12
 Bump when anything the cooker writes changes: a kind's byte layout, an importer flag, a mip policy, a vertex welding rule.
constexpr uint32_t MAX_SKELETON_BONES = 1024
 Bone count past which a rig is refused as corrupt rather than read.
constexpr uint32_t MAX_AUDIO_CHANNELS = 8
 Channel count past which a sound is refused as corrupt rather than read.
constexpr uint32_t MAX_AUDIO_SAMPLE_RATE = 384000
 Sample rate past which a clip is refused as corrupt rather than read.

Detailed Description

Cooked binary asset format (derived cache).

Host-endian; an endian sentinel rejects a file written on a differently-endianed machine. Cooked files are regenerable and keyed to their recipe by name (see cacheKey). Readers validate every count against the file length before allocating. Materials load straight from JSON and are not cooked; meshes, textures, skeletons, animation clips and sounds are.

Function Documentation

◆ cacheKey()

uint64_t Vkm::Engine::AssetCook::cacheKey ( uint64_t recipeHash,
AssetType type )

The complete cache key for one cooked artifact.

Covers what it was baked from, its kind and the cooker. It goes in the artifact's name, so a change to any of them makes the old file one nobody looks for rather than a stale one.

Parameters
recipeHashRecorded hash of the recipe, its source art and dependencies (AssetRecord::recipeHash).
typeAsset kind, mixed in with COOKER_VERSION.
Returns
The key the artifact is filed under.

◆ writeMesh()

bool Vkm::Engine::AssetCook::writeMesh ( const std::filesystem::path & path,
const MeshAsset & mesh )
nodiscard

Write one cooked file of each kind.

Creates the parent directories and writes beside the target, renaming onto it once the write is whole.

Parameters
pathWhere the file goes, already named for its key.
Returns
False on any IO error.

◆ isCookedCurrent()

bool Vkm::Engine::AssetCook::isCookedCurrent ( AssetType type,
const std::filesystem::path & path )
nodiscard

Whether the cooked file at path can still serve type.

Reads the header and measures the file, nothing more. Not current: absent, not a cooked asset, another kind, or a length other than the header's. Recipe and cooker version are in the name, so not checked. A material is never current: it has no binary. Logs nothing; a stale cache is the caller's to report.

Parameters
typeAsset type the file is expected to hold.
pathCooked file to probe, already named for its key.
Returns
True when this build can read that file.

◆ readMesh()

bool Vkm::Engine::AssetCook::readMesh ( const std::filesystem::path & path,
MeshAsset & out )
nodiscard

Read one cooked file of each kind.

Parameters
pathThe cooked file.
outFilled on success.
Returns
False, logging the reason, on any magic, endian, kind, version, size or integrity mismatch.

Variable Documentation

◆ COOKER_VERSION

uint16_t Vkm::Engine::AssetCook::COOKER_VERSION = 12
constexpr

Bump when anything the cooker writes changes: a kind's byte layout, an importer flag, a mip policy, a vertex welding rule.

Part of every cache key, so a bump re-bakes everything. Also written into each header, where a reader refuses a mismatch - the case of a file copied under a name not baked for it. Only testTheCookersOutputIsPinnedToItsVersion notices a forgotten bump that changes no layout.

◆ MAX_SKELETON_BONES

uint32_t Vkm::Engine::AssetCook::MAX_SKELETON_BONES = 1024
constexpr

Bone count past which a rig is refused as corrupt rather than read.

A rejection threshold, not a capability: a full character rig lands near three hundred bones.

◆ MAX_AUDIO_CHANNELS

uint32_t Vkm::Engine::AssetCook::MAX_AUDIO_CHANNELS = 8
constexpr

Channel count past which a sound is refused as corrupt rather than read.

A rejection threshold, not a capability: 7.1 is the outer edge of authored source material.

◆ MAX_AUDIO_SAMPLE_RATE

uint32_t Vkm::Engine::AssetCook::MAX_AUDIO_SAMPLE_RATE = 384000
constexpr

Sample rate past which a clip is refused as corrupt rather than read.

Twice the highest consumer hardware rate. The rate gives the clip's duration, so a wild one makes the length wrong everywhere it is read.