Log inGet started
Package

refs.module

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

renderer.refs

How renderer.* names a live resource. A runtime resource is filed under a v4 guid, minted from OS entropy or given by the caller; and each call that names a resource takes whatever the caller already holds (the key or guid, the handle create returned, the CPU handle load returned, or an AssetRef) and coerces it to the key the renderer's stores index it by.

  • makeGuid() mints a guid; validateGuid(guid, what) answers guid when it is a v4 guid and raises at the caller's line when it is not.
  • materialKey(value, what), meshKey(value, what) and textureKey(value, what) answer the registry key or guid a value names, and raise a rejection that lists the accepted forms.
  • refField(t, name), declaredCategory(value) and shapeName(value) read a ref-like table the way the coercions do.
  • primaryBytes(ref) answers an asset's primary content bytes, waiting for them under a coroutine when they are still on their way; textureRefOf(value, what) answers the ref a texture asset's content is read through.
local Refs = require("modules.api.engine.renderer.refs")
local guid = Refs.makeGuid()
assert(Refs.validateGuid(guid, "example") == guid)
assert(Refs.meshKey({ kind = "MeshHandle", category = "mesh", guid = guid }, "example") == guid)