Last updated: 2026-06-12

Shader Dispatch

Runtime Assets

All API Sections

Runtime asset discovery for installed and source-tree ZINC layouts.

Release archives place shader assets next to the executable under `share/zinc/shaders`, while development builds often run from the repository with assets under `zig-out` or `src/shaders`. This module centralizes that lookup and keeps backend code from hardcoding source-checkout paths.

3 exports 0 methods src/runtime_assets.zig

3 exports shown

enum

ShaderKind

#
pub const ShaderKind = enum

Which compiled shader family to locate.

src/runtime_assets.zig:10

function

resolveShaderDir

#
pub fn resolveShaderDir(allocator: std.mem.Allocator, kind: ShaderKind) ![]u8

Resolve the directory holding compiled shaders of `kind`, honoring `ZINC_SHADER_DIR`.

Checks the `ZINC_SHADER_DIR` environment override first, then falls back to the executable-relative install layout and the in-tree development paths. or `error.ShaderDirNotFound` when no known layout exists.

Parameters

allocator
Allocator for the returned path; the caller owns the result.
kind
Shader family to locate (SPIR-V or Metal).

Returns

Newly allocated path to the shader directory.

Notes

Returns `error.ShaderDirOverrideNotFound` when the override is set but absent,

src/runtime_assets.zig:37

function

resolveShaderDirFrom

#
pub fn resolveShaderDirFrom( allocator: std.mem.Allocator, base_dir: std.fs.Dir, exe_dir_override: ?[]const u8, kind: ShaderKind, ) ![]u8

Resolve the shader directory against explicit base/exe dirs — the testable core of `resolveShaderDir`.

Tries the executable-relative install layout first, then the working-directory candidates for the requested shader family.

Parameters

allocator
Allocator for the returned path; the caller owns the result.
base_dir
Directory the cwd-relative candidates are resolved against.
exe_dir_override
Optional executable directory; when null the real exe path is queried.
kind
Shader family to locate (SPIR-V or Metal).

Returns

Newly allocated path to the shader directory.

Notes

Returns `error.ShaderDirNotFound` when no known layout exists.

src/runtime_assets.zig:55