Skip to content
modkitv0.2

pass.h

#include <modkit/pass.h>56 functions · 12 structs · 7 enums · 19 typedefs · 5 macros

Sokol-style pass-based rendering API.

A pass is a transient rendering scope that owns a bgfx view, encoder, clear state, and render target. The user never sees view IDs, encoders, or bgfx_touch those are handled internally. Two ways to draw:Simple API (mk_clear, mk_cube, mk_rect2d) zero boilerplate, uses implicit passes internally.Pass API (mk_begin_pass/mk_end_pass) explicit multi-pass control without touching bgfx views or encoders. Example (simple 2D): Example (3D with camera): Example (render to texture, then display): Example (NanoVG via escape hatches):

Functions

mk_batch_stats_getfunction

void mk_batch_stats_get(mk_batch_stats *out_stats)

Get state from the batch stats.

ParameterTypeDescription
out_statsmk_batch_stats *Receives the stats.

mk_begin_passfunction

bool mk_begin_pass(const mk_pass_desc *desc)

Begin a rendering pass.

Allocates a bgfx view, configures clear/rect/transform, begins an encoder. Only one pass may be active at a time. Nested passes are not supported.

ParameterTypeDescription
descconst mk_pass_desc *Pass descriptor (clear, camera, target, sort).

Returns True when the operation succeeds.

mk_dispatchfunction

void mk_dispatch(const mk_dispatch_desc *desc)

Dispatch a compute program into the active pass (explicit mk_begin_pass, or the implicit simple-API pass).

Resolves the pass's encoder + view automatically.

ParameterTypeDescription
descconst mk_dispatch_desc *Configuration descriptor.

mk_dispatch_exfunction

void mk_dispatch_ex(mk_encoder_t enc, mk_view_id_t view, const mk_dispatch_desc *desc)

Dispatch a compute program into a specific encoder + view (multi-threaded path).

ParameterTypeDescription
encmk_encoder_tValue for enc.
viewmk_view_id_tValue for view.
descconst mk_dispatch_desc *Configuration descriptor.

mk_draw_rejection_stats_getfunction

void mk_draw_rejection_stats_get(mk_draw_rejection_stats *out_stats)

Read compact rejection counts accumulated since the current frame began.

ParameterTypeDescription
out_statsmk_draw_rejection_stats *Receives the stats.

mk_end_passfunction

void mk_end_pass(void)

End the current pass.

Flushes any active draw2d/draw3d contexts, ends the encoder, and frees the allocated view.

mk_in_passfunction

bool mk_in_pass(void)

Check whether a pass is currently active.

Returns true if mk_begin_pass was called without a matching mk_end_pass.

mk_pass_2dfunction

mk_pass_desc mk_pass_2d(uint32_t clear_color)

Explicit painter-ordered 2D pass.

ParameterTypeDescription
clear_coloruint32_tValue for clear color.

Returns The resulting value.

mk_pass_3dfunction

mk_pass_desc mk_pass_3d(uint32_t clear_color, const float *view_mtx, const float *proj_mtx)

3D pass: clears color + depth, sets view/projection matrices.

ParameterTypeDescription
clear_coloruint32_tRGBA clear color.
view_mtxconst float *4x4 view matrix.
proj_mtxconst float *4x4 projection matrix.

Returns The resulting value.

mk_pass_apply_view_orderfunction

void mk_pass_apply_view_order(void)

Apply view order for the pass.

mk_pass_canvasfunction

struct mk_canvas * mk_pass_canvas(void)

Get a draw2d context bound to the current pass.

Lazy-created on first call. Automatically flushed on mk_end_pass(). If a draw3d context is active, it is flushed first (context switch).

Returns Draw2d context. Only valid until mk_end_pass().

mk_pass_clearfunction

mk_pass_desc mk_pass_clear(uint32_t clear_color)

2D pass: clears color + depth, no camera transform.

ParameterTypeDescription
clear_coloruint32_tRGBA clear color.

Returns The resulting value.

mk_pass_defer_view_freefunction

void mk_pass_defer_view_free(mk_view_id_t view)

Queue a view ID to be freed at the next mk_pass_frame_begin().

Use this when a subsystem allocates its own views via mk_view_alloc() and needs to release them. Immediate mk_view_free() can wipe bgfx view state before bgfx_frame() executes submitted draws — deferring matches the internal behavior used by mk_end_pass() for the pass's own view.

ParameterTypeDescription
viewmk_view_id_tView ID to defer-free. No-op for MK_VIEW_INVALID.

mk_pass_drawfunction

mk_result mk_pass_draw(const mk_draw_desc *desc)

Submit one draw into the active pass (explicit mk_begin_pass, or the implicit simple-API pass).

Resolves the pass's encoder + view automatically.

ParameterTypeDescription
descconst mk_draw_desc *Configuration descriptor.

Returns MK_SUCCESS or an error result.

mk_pass_draw_exfunction

mk_result mk_pass_draw_ex(mk_encoder_t enc, mk_view_id_t view, const mk_draw_desc *desc)

Submit one draw into a specific encoder + view.

This is the multi-threaded entry point: a worker that owns a mk_render_ctx_t passes its per-thread encoder and the pass's view. Touches no global pass state.

ParameterTypeDescription
encmk_encoder_tValue for enc.
viewmk_view_id_tValue for view.
descconst mk_draw_desc *Configuration descriptor.

Returns MK_SUCCESS or an error result.

mk_pass_draw_ex_reportfunction

mk_result mk_pass_draw_ex_report(mk_encoder_t enc, mk_view_id_t view, const mk_draw_desc *desc, mk_resolved_draw_report *out_report)

Draw ex report for the pass.

ParameterTypeDescription
encmk_encoder_tValue for enc.
viewmk_view_id_tValue for view.
descconst mk_draw_desc *Configuration descriptor.
out_reportmk_resolved_draw_report *Receives the report.

Returns MK_SUCCESS or an error result.

mk_pass_draw_reportfunction

mk_result mk_pass_draw_report(const mk_draw_desc *desc, mk_resolved_draw_report *out_report)

Draw report for the pass.

ParameterTypeDescription
descconst mk_draw_desc *Configuration descriptor.
out_reportmk_resolved_draw_report *Receives the report.

Returns MK_SUCCESS or an error result.

mk_pass_draw3dfunction

struct mk_draw3d_ctx * mk_pass_draw3d(void)

Get a draw3d context bound to the current pass.

Lazy-created on first call. Automatically flushed on mk_end_pass(). If a draw2d context is active, it is flushed first (context switch).

Returns Draw3d context. Only valid until mk_end_pass().

mk_pass_encoderfunction

mk_encoder_t mk_pass_encoder(void)

Get the current pass's encoder.

Use this for subsystems that require an explicit encoder, such as NanoVG (mk_nvg_set_encoder), text rendering (mk_text_begin), or raw mk_encoder_* submissions.

Returns The encoder for the current pass. Only valid until mk_end_pass().

mk_pass_frame_beginfunction

void mk_pass_frame_begin(void)

Reset per-frame state.

Called by mk_frame_begin().

mk_pass_frame_endfunction

bool mk_pass_frame_end(void)

Flush any dangling pass.

Returns True when the operation succeeds.

mk_pass_implicit_camera_defaultfunction

void mk_pass_implicit_camera_default(const float view[16], const float proj[16])

Store the draw3d default-camera matrices WITHOUT marking the camera as user-overridden.

Called by draw3d's ensure path each frame. Internal.

ParameterTypeDescription
viewconst floatValue for view.
projconst floatValue for proj.

mk_pass_implicit_camera_overriddenfunction

bool mk_pass_implicit_camera_overridden(void)

True once mk_set_camera/mk_set_camera_raw overrode the default camera.

Returns True when the operation succeeds.

mk_pass_implicit_camera_projfunction

const float * mk_pass_implicit_camera_proj(void)

Stored implicit camera projection matrix (16 floats, never NULL).

Returns A borrowed pointer, or NULL when unavailable.

mk_pass_implicit_camera_reset_overridefunction

void mk_pass_implicit_camera_reset_override(void)

Clear the mk_set_camera override so the draw3d default camera (mk_cam_*) drives the implicit pass again.

Called by the mk_cam_* setters. Internal.

mk_pass_implicit_camera_viewfunction

const float * mk_pass_implicit_camera_view(void)

Stored implicit camera view matrix (16 floats, never NULL).

Returns A borrowed pointer, or NULL when unavailable.

mk_pass_implicit_encoderfunction

mk_encoder_t mk_pass_implicit_encoder(void)

Get the encoder for the current implicit pass.

Returns Encoder, or NULL if no implicit pass is active.

mk_pass_implicit_ensure_2dfunction

void mk_pass_implicit_ensure_2d(void)

Ensure an implicit 2D pass is active for the simple API.

Opens a 2D overlay pass. If a 3D implicit pass is active, it is flushed first (the 2D pass does NOT clear, compositing on top).

mk_pass_implicit_ensure_3dfunction

void mk_pass_implicit_ensure_3d(void)

Ensure an implicit 3D pass is active for the simple API.

Opens a 3D pass with the sticky clear color and the stored implicit camera (mk_set_camera / mk_set_camera_raw / the draw3d default camera). If a 2D implicit pass is active, it is flushed first.

mk_pass_implicit_flushfunction

void mk_pass_implicit_flush(void)

Flush (end) the current implicit pass if any.

Called by mk_draw3d_flush() and mk_canvas_flush().

mk_pass_implicit_frame_endfunction

void mk_pass_implicit_frame_end(void)

Frame-end fallback: if NO pass ran this frame (e.g.

an mk_clear()-only or empty frame), opens + closes an implicit pass so the backbuffer is still cleared with the sticky clear color. Called by mk_frame_end() after mk_pass_frame_end().

mk_pass_implicit_set_clearfunction

void mk_pass_implicit_set_clear(uint32_t color)

Set the clear color for the implicit simple API pass (sticky across frames).

ParameterTypeDescription
coloruint32_tValue for color.

mk_pass_implicit_typefunction

mk_implicit_pass_type_t mk_pass_implicit_type(void)

Get the current implicit pass type.

Returns The resulting handle or value.

mk_pass_implicit_viewfunction

mk_view_id_t mk_pass_implicit_view(void)

Get the view for the current implicit pass.

Returns View ID, or MK_VIEW_INVALID if no implicit pass is active.

mk_pass_material_rolefunction

mk_material_pass_role mk_pass_material_role(void)

Perform the pass material role operation.

Returns The resulting value.

mk_pass_material_role_for_viewfunction

mk_material_pass_role mk_pass_material_role_for_view(mk_view_t view)

Perform the pass material role for view operation.

ParameterTypeDescription
viewmk_view_tValue for view.

Returns The resulting value.

mk_pass_offscreenfunction

mk_pass_desc mk_pass_offscreen(mk_render_target_t target, uint32_t clear_color)

Offscreen 2D pass: renders to a render target.

ParameterTypeDescription
targetmk_render_target_tRender target.
clear_coloruint32_tRGBA clear color.

Returns The resulting value.

mk_pass_offscreen_2dfunction

mk_pass_desc mk_pass_offscreen_2d(mk_render_target_t target, uint32_t clear_color)

Explicit painter-ordered offscreen 2D pass.

ParameterTypeDescription
targetmk_render_target_tValue for target.
clear_coloruint32_tValue for clear color.

Returns The resulting value.

mk_pass_offscreen_3dfunction

mk_pass_desc mk_pass_offscreen_3d(mk_render_target_t target, uint32_t clear_color, const float *view_mtx, const float *proj_mtx)

Offscreen 3D pass: renders to a render target with camera.

ParameterTypeDescription
targetmk_render_target_tRender target.
clear_coloruint32_tRGBA clear color.
view_mtxconst float *4x4 view matrix.
proj_mtxconst float *4x4 projection matrix.

Returns The resulting value.

mk_pass_phase_modefunction

mk_pass_phase_mode_t mk_pass_phase_mode(void)

Perform the pass phase mode operation.

Returns The resulting handle or value.

mk_pass_prepare_phasefunction

mk_view_t mk_pass_prepare_phase(mk_draw_phase_t phase)

API-thread-only phase preparation.

ParameterTypeDescription
phasemk_draw_phase_tValue for phase.

Returns The resulting handle or value.

mk_pass_provider_disable_mask_for_viewfunction

mk_shader_provider_mask_t mk_pass_provider_disable_mask_for_view(mk_view_t view)

Disable the mask for view for the pass provider.

ParameterTypeDescription
viewmk_view_tValue for view.

Returns The resulting handle or value.

mk_pass_provider_state_for_viewfunction

void mk_pass_provider_state_for_view(mk_view_t view, float out_camera[4], float out_output[4])

Perform the pass provider state for view operation.

ParameterTypeDescription
viewmk_view_tValue for view.
out_camerafloatReceives the camera.
out_outputfloatReceives the output.

mk_pass_register_view_orderfunction

void mk_pass_register_view_order(mk_view_t view)

Register view order for the pass.

ParameterTypeDescription
viewmk_view_tValue for view.

mk_pass_resolve_draw_viewfunction

mk_view_t mk_pass_resolve_draw_view(mk_draw_phase_t phase, uint64_t resolved_state, mk_material_t material)

Draw view for the pass resolve.

ParameterTypeDescription
phasemk_draw_phase_tValue for phase.
resolved_stateuint64_tValue for resolved state.
materialmk_material_tValue for material.

Returns The resulting handle or value.

mk_pass_sort_depth_worldfunction

uint32_t mk_pass_sort_depth_world(float x, float y, float z)

Perform the pass sort depth world operation.

ParameterTypeDescription
xfloatValue for x.
yfloatValue for y.
zfloatValue for z.

Returns The resulting value.

mk_pass_spritefunction

struct mk_sprite_ctx * mk_pass_sprite(void)

Begin sprite-batch rendering bound to the current pass — the pass-native entry point for the sprite/atlas system (no manual encoder/view juggling).

Mirrors mk_pass_canvas(): flushes any other active draw context, then begins a pooled sprite batch on the pass's encoder + view with a screen-space orthographic projection. Draw with mk_sprite_draw*(); the batch is flushed automatically on mk_end_pass() (or when you switch to another draw context). Returns MK_SPRITE_CTX_INVALID if no pass is active or sprites are disabled.

Returns A borrowed pointer, or NULL when unavailable.

mk_begin_pass(&mk_pass_clear(0x202020ff));
mk_sprite_ctx_t s = mk_pass_sprite();
mk_sprite_draw(s, my_sprite, 100, 100);
mk_end_pass();

mk_pass_submit_modefunction

mk_submit_mode_t mk_pass_submit_mode(void)

Current pass policy; used by the high-level model package.

Returns The resulting handle or value.

mk_pass_system_initfunction

void mk_pass_system_init(void)

Initialize the pass system.

Called by mk_init().

mk_pass_system_shutdownfunction

void mk_pass_system_shutdown(void)

Shutdown the pass system.

Called by mk_shutdown().

mk_pass_targetfunction

mk_render_target_t mk_pass_target(void)

Get the current pass's render target (NULL = backbuffer).

Subsystems that need to allocate auxiliary views (e.g. model.c's transmission framebuffer-capture path) read this to configure those views with the same render target as the caller's pass.

Returns The render target for the current pass, or MK_RENDER_TARGET_INVALID if rendering to the backbuffer or no pass is active.

mk_pass_textfunction

void mk_pass_text(void)

Begin text rendering bound to the current pass — the pass-native default text path (no custom shader, no encoder/view juggling).

Mirrors mk_pass_canvas(): flushes any active draw2d/draw3d batch, then begins the built-in text subsystem on the pass's encoder + view with a screen-space (pixel) orthographic projection. After calling this you draw with the normal mk_text_draw()/mk_text_draw_styled() functions; the batch is flushed automatically on mk_end_pass() (or when you switch to another draw context). For custom-shaded text, skip this and use mk_text_build() + mk_pass_draw() with your own pipeline instead.

mk_begin_pass(&mk_pass_clear(0x202020ff));
mk_pass_text();
mk_text_draw(font, 20, 20, "Hello", 0, 0xFFFFFFFF, MK_TEXT_ALIGN_LEFT | MK_TEXT_ALIGN_TOP);
mk_end_pass();

mk_pass_viewfunction

mk_view_id_t mk_pass_view(void)

Get the current pass's view ID.

Use this for subsystems that require an explicit view ID, such as NanoVG (mk_nvg_set_view), or for debugging.

Returns The view ID for the current pass. Only valid until mk_end_pass().

mk_set_camerafunction

void mk_set_camera(const struct mk_camera *camera)

Set the camera used by the implicit (simple-API) pass.

Affects mk_pass_draw/mk_dispatch/mk_cube/etc. when called WITHOUT an explicit mk_begin_pass. The camera persists across frames; call once or per-frame. Does NOT affect explicit passes those take their camera from mk_pass_desc.view_mtx/proj_mtx.

ParameterTypeDescription
cameraconst struct mk_camera *Camera whose view/projection matrices are applied.

mk_set_camera_rawfunction

void mk_set_camera_raw(const float *view_mtx, const float *proj_mtx)

Set the implicit-pass camera from raw matrices.

ParameterTypeDescription
view_mtxconst float *4x4 view matrix (NULL = identity).
proj_mtxconst float *4x4 projection matrix (NULL = identity).

mk_sort_depth_from_distancefunction

uint32_t mk_sort_depth_from_distance(float view_distance)

Encode a non-negative view-forward distance into a monotonic bgfx sort key.

ParameterTypeDescription
view_distancefloatValue for view distance.

Returns The resulting value.

Structs

mk_batch_statsstruct

Data for batch stats.

FieldTypeDescription
packetsuint32_tThe packets.
instanced_drawsuint32_tThe instanced draws.
instancesuint32_tThe instances.
fallback_drawsuint32_tThe fallback draws.

mk_dispatch_descstruct

Compute dispatch descriptor.

Zero-init = sane defaults: num_x/y/z 0 => 1 (a single workgroup on that axis) discard 0 => MK_DISCARD_ALL

FieldTypeDescription
shadermk_shader_tCompute program (mk_shader_load_compute*).
num_xuint32_tX workgroup count; zero selects one.
num_yuint32_tY workgroup count; zero selects one.
num_zuint32_tZ workgroup count; zero selects one.
imagesmk_image_bindingThe images.
image_countuint8_tThe image count.
buffersmk_storage_bindingThe buffers.
buffer_countuint8_tThe buffer count.
indirect_buffersmk_indirect_bindingThe indirect buffers.
indirect_buffer_countuint8_tThe indirect buffer count.
uniformsmk_uniform_bindingThe uniforms.
uniform_countuint8_tThe uniform count.
use_indirectboolThe use indirect.
indirect_buffermk_indirect_buf_tThe indirect buffer.
indirect_startuint32_tThe indirect start.
indirect_countuint32_t0 selects one command.
discarduint8_t0 => MK_DISCARD_ALL

mk_draw_descstruct

Draw descriptor.

Zero-init = sane defaults: pipeline invalid + shader set => inline shortcut (state 0 => MK_STATE_DEFAULT) ibuf invalid => non-indexed draw transform NULL => identity (no set_transform) discard 0 => MK_DISCARD_ALL Geometry precedence per stream: transient > dynamic > static. Instance data precedence: transient instance buffer > dynamic vertex buffer static vertex buffer > count-only instancing.

FieldTypeDescription
pipelinemk_pipeline_tThe pipeline.
shadermk_shader_tThe shader.
stateuint64_tinline shortcut state; 0 => MK_STATE_DEFAULT
blend_rgbauint32_tinline shortcut blend factor
materialmk_material_tThe material.
geometrymk_geometry_tThe geometry.
instanced_pipelinemk_pipeline_tThe instanced pipeline.
pipeline_retained_resourceboolInternal pipeline ownership marker; callers leave false.
shader_retained_resourceboolInternal shader ownership marker; callers leave false.
instanced_pipeline_retained_resourceboolInternal instanced-pipeline ownership marker; callers leave false.
flagsuint32_tThe flags.
provider_maskmk_shader_provider_mask_tThe provider mask.
provider_disable_maskmk_shader_provider_mask_tThe provider disable mask.
stencil_frontuint32_tThe stencil front.
stencil_backuint32_tThe stencil back.
stencil_overrideboolThe stencil override.
vbufmk_vbuf_tThe vbuf.
ibufmk_ibuf_toptional; invalid => non-indexed
vbuf_retained_resourceboolInternal vertex-buffer ownership marker; callers leave false.
ibuf_retained_resourceboolInternal index-buffer ownership marker; callers leave false.
dvbufmk_dvbuf_toptional dynamic vbuf
dibufmk_dibuf_toptional dynamic ibuf
tvbufconst mk_tvbuf_t *optional transient vbuf (wins if set)
tibufconst mk_tibuf_t *optional transient ibuf (wins if set)
streamuint8_tvertex stream index (default 0)
vbuf_startuint32_tFirst vertex; zero with vbuf_num zero selects the whole buffer.
vbuf_numuint32_tVertex count; zero with vbuf_start zero selects the whole buffer.
ibuf_firstuint32_tFirst index; zero with ibuf_num zero selects the whole buffer.
ibuf_numuint32_tIndex count; zero with ibuf_first zero selects the whole buffer.
vertex_countuint32_tbufferless draw: when >0 AND no vbuf/dvbuf/tvbuf is set, draw this many vertices with no vertex buffer (gl_VertexID; fullscreen triangle/quad).
transformconst float *The transform.
instance_bufferconst mk_instance_buf_t *optional transient instance data
instance_vbufmk_vbuf_toptional static instance data
instance_vbuf_retained_resourceboolInternal instance-buffer ownership marker; callers leave false.
instance_dvbufmk_dvbuf_toptional dynamic instance data
instance_startuint32_tfirst instance record
instance_strideuint16_tbytes per instance, documentation only
instance_countuint32_tThe instance count.
use_indirectboolThe use indirect.
indirect_buffermk_indirect_buf_tThe indirect buffer.
indirect_startuint32_tThe indirect start.
indirect_countuint32_t0 selects one command.
texturesmk_tex_bindingThe textures.
texture_countuint8_tThe texture count.
uniformsmk_uniform_bindingThe uniforms.
uniform_countuint8_tThe uniform count.
binding_overflowboolinternal resolver marker; callers leave false
phasemk_draw_phase_tThe phase.
depthuint32_tThe depth.
has_depthboolpermits an explicit depth of zero
discarduint8_t0 => MK_DISCARD_ALL

mk_draw_rejection_statsstruct

Data for draw rejection stats.

FieldTypeDescription
totaluint32_tThe total.
invalid_argumentuint32_tThe invalid argument.
invalid_stateuint32_tThe invalid state.
unsupporteduint32_tThe unsupported.
binding_capacityuint32_tThe binding capacity.
binding_conflictuint32_tThe binding conflict.
binding_typeuint32_tThe binding type.
otheruint32_tThe other.

mk_image_bindingstruct

A storage-image binding for a compute dispatch.

FieldTypeDescription
stageuint8_tImage stage 0..15.
texturemk_texture_tStorage image (mk_texture_create_storage).
mipuint8_tMip level (default 0).
accessmk_access_tREAD / WRITE / READWRITE.
formatmk_texture_format_tAccess format.

mk_indirect_bindingstruct

Data for indirect binding.

FieldTypeDescription
stageuint8_tThe stage.
buffermk_indirect_buf_tThe buffer.
accessmk_access_tThe access.

mk_pass_descstruct

Pass descriptor.

All fields have sensible defaults when zero-initialized. Zero-init gives: no clear, no camera, backbuffer target, default sort. Use the convenience constructors (mk_pass_clear, mk_pass_3d, etc.) for common configurations.

FieldTypeDescription
nameconst char *Debug name (optional, NULL ok).
clear_coloruint32_tRGBA clear color.
clear_depthfloatDepth clear value (0 = use default 1.0).
clear_stenciluint8_tStencil clear value.
clear_flagsuint16_tMK_CLEAR_COLOR | MK_CLEAR_DEPTH etc.
clear_colorsconst uint32_t *The clear colors.
clear_color_countuint8_tThe clear color count.
targetmk_render_target_tThe target.
viewport_xuint16_tThe viewport x.
viewport_yuint16_tThe viewport y.
viewport_widthuint16_tThe viewport width.
viewport_heightuint16_tThe viewport height.
sortmk_pass_sort_tThe sort.
view_mtxconst float *4x4 view matrix (NULL = identity)
proj_mtxconst float *4x4 projection matrix (NULL = identity)
camera_positionconst float *World-space xyz; NULL derives from view.
outputmk_pass_output_descImmutable view/output provider state.
provider_disable_maskmk_shader_provider_mask_tThe provider disable mask.
phase_modemk_pass_phase_mode_tThe phase mode.
submit_modemk_submit_mode_tThe submit mode.
material_passmk_material_pass_roleThe material pass.

mk_pass_output_descstruct

Data for pass output desc.

FieldTypeDescription
modemk_pass_output_mode_tDisplay encoding or raw-linear output.
exposurefloatLinear multiplier; <= 0 selects 1.0.
tonemap_operatormk_tonemap_opOperator used by display-output shaders.

mk_resolved_draw_reportstruct

Data for resolved draw report.

FieldTypeDescription
resultmk_resultThe result.
effective_providersmk_shader_provider_mask_tThe effective providers.
sampler_countuint8_tThe sampler count.
selected_pbr_variant_iduint32_tThe selected PBR variant ID.
pbr_extension_maskuint32_tThe PBR extension mask.
pbr_familyuint32_tThe PBR family.
pbr_downgrade_maskuint32_tThe PBR downgrade mask.

mk_storage_bindingstruct

A storage-buffer binding for a compute dispatch.

dvbuf wins if both set.

FieldTypeDescription
stageuint8_tBuffer stage 0..15.
dvbufmk_dvbuf_tDynamic vertex buffer (MK_DYNBUF_COMPUTE_*), preferred.
vbufmk_vbuf_tStatic vertex buffer (compute-access).
accessmk_access_tREAD / WRITE / READWRITE.

mk_tex_bindingstruct

A single texture binding for a draw.

FieldTypeDescription
stageuint8_tTexture stage 0..15.
samplermk_uniform_tSampler uniform (MK_UNIFORM_SAMPLER).
texturemk_texture_tTexture to bind.
sampler_flagsuint32_tSampler override when has_sampler_override is true.
has_sampler_overrideboolThe has sampler override.
retained_resourceboolInternal ownership marker; callers leave false.
sampler_retained_resourceboolInternal sampler ownership marker; callers leave false.

mk_uniform_bindingstruct

A single uniform binding for a draw.

value is read during the call only.

FieldTypeDescription
uniformmk_uniform_tUniform handle (VEC4 / MAT3 / MAT4).
valueconst float *Pointer to caller data.
countuint16_tNumber of vec4s/mats; 0 => 1.
retained_resourceboolInternal ownership marker; callers leave false.

Enums

mk_draw_flag_tenum

Values for draw flag.

ValueDescription
MK_DRAW_NO_BATCHSelects draw no batch.

mk_draw_phase_tenum

Values for draw phase.

ValueDescription
MK_DRAW_PHASE_AUTOSelects auto.
MK_DRAW_PHASE_OPAQUESelects opaque.
MK_DRAW_PHASE_TRANSPARENTSelects transparent.

mk_implicit_pass_typeenum

Values for implicit pass type.

ValueDescription
MK_IMPLICIT_PASS_NONENo implicit pass open.
MK_IMPLICIT_PASS_3D3D scene pass (from ensure_ctx)
MK_IMPLICIT_PASS_2D2D overlay pass (from ensure_2d)

mk_pass_output_mode_tenum

Values for pass output mode.

ValueDescription
MK_PASS_OUTPUT_DISPLAYSelects display.
MK_PASS_OUTPUT_RAW_LINEARSelects raw linear.

mk_pass_phase_mode_tenum

Values for pass phase mode.

ValueDescription
MK_PASS_PHASE_SINGLESelects single.
MK_PASS_PHASE_AUTOMATIC_3DSelects automatic 3D.

mk_pass_sortenum

Pass sorting mode.

ValueDescription
MK_PASS_SORT_DEFAULTDefault sorting.
MK_PASS_SORT_SEQUENTIALRender in submission order.
MK_PASS_SORT_DEPTH_ASCFront-to-back (opaque optimization).
MK_PASS_SORT_DEPTH_DESCBack-to-front (transparency).

mk_submit_mode_tenum

Values for submit mode.

ValueDescription
MK_SUBMIT_IMMEDIATESelects immediate.
MK_SUBMIT_AUTO_BATCHSelects auto batch.

Typedefs

mk_batch_statstypedef

typedef struct mk_batch_stats mk_batch_stats

Data for batch stats.

mk_dispatch_desctypedef

typedef struct mk_dispatch_desc mk_dispatch_desc

Compute dispatch descriptor.

Zero-init = sane defaults: num_x/y/z 0 => 1 (a single workgroup on that axis) discard 0 => MK_DISCARD_ALL

mk_draw_desctypedef

typedef struct mk_draw_desc mk_draw_desc

Draw descriptor.

Zero-init = sane defaults: pipeline invalid + shader set => inline shortcut (state 0 => MK_STATE_DEFAULT) ibuf invalid => non-indexed draw transform NULL => identity (no set_transform) discard 0 => MK_DISCARD_ALL Geometry precedence per stream: transient > dynamic > static. Instance data precedence: transient instance buffer > dynamic vertex buffer static vertex buffer > count-only instancing.

mk_draw_flag_ttypedef

typedef enum mk_draw_flag_t mk_draw_flag_t

Values for draw flag.

mk_draw_phase_ttypedef

typedef enum mk_draw_phase_t mk_draw_phase_t

Values for draw phase.

mk_draw_rejection_statstypedef

typedef struct mk_draw_rejection_stats mk_draw_rejection_stats

Data for draw rejection stats.

mk_image_bindingtypedef

typedef struct mk_image_binding mk_image_binding

A storage-image binding for a compute dispatch.

mk_implicit_pass_type_ttypedef

typedef enum mk_implicit_pass_type mk_implicit_pass_type_t

Values for implicit pass type.

mk_indirect_bindingtypedef

typedef struct mk_indirect_binding mk_indirect_binding

Data for indirect binding.

mk_pass_desctypedef

typedef struct mk_pass_desc mk_pass_desc

Pass descriptor.

All fields have sensible defaults when zero-initialized. Zero-init gives: no clear, no camera, backbuffer target, default sort. Use the convenience constructors (mk_pass_clear, mk_pass_3d, etc.) for common configurations.

mk_pass_output_desctypedef

typedef struct mk_pass_output_desc mk_pass_output_desc

Data for pass output desc.

mk_pass_output_mode_ttypedef

typedef enum mk_pass_output_mode_t mk_pass_output_mode_t

Values for pass output mode.

mk_pass_phase_mode_ttypedef

typedef enum mk_pass_phase_mode_t mk_pass_phase_mode_t

Values for pass phase mode.

mk_pass_sort_ttypedef

typedef enum mk_pass_sort mk_pass_sort_t

Pass sorting mode.

mk_resolved_draw_reporttypedef

typedef struct mk_resolved_draw_report mk_resolved_draw_report

Data for resolved draw report.

mk_storage_bindingtypedef

typedef struct mk_storage_binding mk_storage_binding

A storage-buffer binding for a compute dispatch.

dvbuf wins if both set.

mk_submit_mode_ttypedef

typedef enum mk_submit_mode_t mk_submit_mode_t

Values for submit mode.

mk_tex_bindingtypedef

typedef struct mk_tex_binding mk_tex_binding

A single texture binding for a draw.

mk_uniform_bindingtypedef

typedef struct mk_uniform_binding mk_uniform_binding

A single uniform binding for a draw.

value is read during the call only.

Macros

MK_DISPATCH_MAX_BUFFERSdefine

MK_DISPATCH_MAX_BUFFERS

Maximum supported dispatch buffers.

MK_DISPATCH_MAX_IMAGESdefine

MK_DISPATCH_MAX_IMAGES

Maximum supported dispatch images.

MK_DISPATCH_MAX_INDIRECT_BUFFERSdefine

MK_DISPATCH_MAX_INDIRECT_BUFFERS

Maximum supported dispatch indirect buffers.

MK_DRAW_MAX_TEXTURESdefine

MK_DRAW_MAX_TEXTURES

Maximum supported draw textures.

MK_DRAW_MAX_UNIFORMSdefine

MK_DRAW_MAX_UNIFORMS

Maximum supported draw uniforms.