Skip to content
modkitv0.2

pipeline.h

#include <modkit/pipeline.h>12 functions · 2 structs · 1 typedefs · 1 macros

Immutable pipeline objects (PSO).

A pipeline bakes a shader program, an (optional) vertex layout, and the full render state (blend/depth/cull/primitive/write masks + stencil) into one immutable handle. This is the modern, footgun-free way to describe "how to draw": create the pipeline once, then submit draws through it with mk_pass_draw() no per-submit global state to rebind after MK_DISCARD_ALL. Mental model (sokol / WebGPU / Metal): apply pipeline -> apply bindings -> draw Example: Uses generational handles for use-after-free detection (id 0 = invalid).

Functions

mk_pipeline_blend_rgbafunction

uint32_t mk_pipeline_blend_rgba(mk_pipeline_t p)

Get the baked blend factor constant.

ParameterTypeDescription
pmk_pipeline_tValue for p.

Returns The resulting value.

mk_pipeline_createfunction

mk_pipeline_t mk_pipeline_create(const mk_pipeline_desc *desc)

Create an immutable pipeline.

ParameterTypeDescription
descconst mk_pipeline_desc *Pipeline descriptor (shader required; zero-init = sane defaults).

Returns Pipeline handle, or MK_PIPELINE_INVALID on failure.

mk_pipeline_destroyfunction

void mk_pipeline_destroy(mk_pipeline_t pipeline)

Destroy a pipeline.

Does NOT destroy the shader it references (the caller owns the shader's lifetime).

ParameterTypeDescription
pipelinemk_pipeline_tValue for pipeline.

mk_pipeline_is_validfunction

bool mk_pipeline_is_valid(mk_pipeline_t pipeline)

Check if a pipeline is publicly valid and not pending destruction.

ParameterTypeDescription
pipelinemk_pipeline_tValue for pipeline.

Returns True when the condition holds.

mk_pipeline_pinfunction

bool mk_pipeline_pin(mk_pipeline_t pipeline)

Perform the pipeline pin operation.

ParameterTypeDescription
pipelinemk_pipeline_tValue for pipeline.

Returns True when the operation succeeds.

mk_pipeline_shaderfunction

mk_shader_t mk_pipeline_shader(mk_pipeline_t p)

Get the shader baked into the pipeline (MK_SHADER_INVALID if handle stale).

ParameterTypeDescription
pmk_pipeline_tValue for p.

Returns The resulting handle or value.

mk_pipeline_statefunction

uint64_t mk_pipeline_state(mk_pipeline_t p)

Get the baked render state word (0 if handle stale).

ParameterTypeDescription
pmk_pipeline_tValue for p.

Returns The resulting value.

mk_pipeline_stencil_backfunction

uint32_t mk_pipeline_stencil_back(mk_pipeline_t p)

Get the baked stencil back state.

ParameterTypeDescription
pmk_pipeline_tValue for p.

Returns The resulting value.

mk_pipeline_stencil_frontfunction

uint32_t mk_pipeline_stencil_front(mk_pipeline_t p)

Get the baked stencil front state.

ParameterTypeDescription
pmk_pipeline_tValue for p.

Returns The resulting value.

mk_pipeline_system_initfunction

void mk_pipeline_system_init(void)

Initialize the pipeline system.

mk_pipeline_system_shutdownfunction

void mk_pipeline_system_shutdown(void)

Perform the pipeline system shutdown operation.

mk_pipeline_unpinfunction

void mk_pipeline_unpin(mk_pipeline_t pipeline)

Perform the pipeline unpin operation.

ParameterTypeDescription
pipelinemk_pipeline_tValue for pipeline.

Structs

mk_pipeline_descstruct

Immutable pipeline descriptor.

All fields have sane defaults when zero: state == 0 -> MK_STATE_DEFAULT is substituted at create time layout NULL -> no layout is stored (the bound vbuf carries its own) stencil 0/0 -> stencil disabled blend_rgba 0 -> blend factor constant of 0 (only used by *_FACTOR blends)

FieldTypeDescription
nameconst char *Debug name (optional, NULL ok).
shadermk_shader_tREQUIRED: vs+fs program.
layoutconst mk_layout_t *Optional expected vertex layout (copied).
stateuint64_tThe state.
blend_rgbauint32_tBlend factor constant (for *_FACTOR blends).
stencil_frontuint32_tThe stencil front.
stencil_backuint32_tThe stencil back.

mk_pipeline_tstruct

Data for pipeline.

FieldTypeDescription
iduint32_tThe ID.

Typedefs

mk_pipeline_desctypedef

typedef struct mk_pipeline_desc mk_pipeline_desc

Immutable pipeline descriptor.

All fields have sane defaults when zero: state == 0 -> MK_STATE_DEFAULT is substituted at create time layout NULL -> no layout is stored (the bound vbuf carries its own) stencil 0/0 -> stencil disabled blend_rgba 0 -> blend factor constant of 0 (only used by *_FACTOR blends)

Macros

MK_PIPELINE_INVALIDdefine

MK_PIPELINE_INVALID

Invalid sentinel for pipeline.