platform.macos.renderer

A Metal 2D renderer for Chic UI geometry, drawing commands, and font atlases.

3 structs · 10 functions · Public API

Structs

ViewportUniforms

struct
ViewportUniforms : struct {
    width : f32 = 0.0
    height : f32 = 0.0
}

MetalRenderer2D

struct
MetalRenderer2D : struct {
    device : macos_core.ObjCId = null
    command_queue : macos_core.ObjCId = null
    pipeline : macos_core.ObjCId = null
    atlas_pipeline : macos_core.ObjCId = null
    vertex_buffer : macos_core.ObjCId = null
    atlas_texture : macos_core.ObjCId = null
    atlas_source : ^ui.FontAtlas = null
    atlas_width : i32 = 0
    atlas_height : i32 = 0
    atlas_revision : u64 = 0
    vertex_capacity : macos_core.NSUInteger = 0
    color_pixel_format : metal.MTLPixelFormat = metal.MTLPixelFormat.BGRA8Unorm
    clear_color : metal.MTLClearColor = metal.MTLClearColor { .red = 0.05, .green = 0.06, .blue = 0.08, .alpha = 1.0 }
}

RenderBatch

struct
RenderBatch : struct {
    vertices : ^ui.Vertex = null
    vertex_count : i64 = 0
    commands : ^ui.DrawCommand = null
    command_count : i64 = 0
    width : f32 = 0.0
    height : f32 = 0.0
    font_system : ^ui.FontSystem = null
}

Functions

init

func
init : func(renderer : ^MetalRenderer2D, device : ^metal.MTLDevice, color_pixel_format : metal.MTLPixelFormat) -> RendererStatus

deinit

func
deinit : func(self : ^MetalRenderer2D)

is_valid

func
is_valid : func(self : ^MetalRenderer2D) -> bool

create_pipeline

func
create_pipeline : func(self : ^MetalRenderer2D) -> RendererStatus

ensure_vertex_capacity

func
ensure_vertex_capacity : func(self : ^MetalRenderer2D, vertex_count : macos_core.NSUInteger) -> RendererStatus

upload_vertices

func
upload_vertices : func(self : ^MetalRenderer2D, batch : ^RenderBatch) -> RendererStatus

encode

func
encode : func(self : ^MetalRenderer2D, encoder : ^metal.MTLRenderCommandEncoder, batch : ^RenderBatch, target_width : f32, target_height : f32) -> RendererStatus

draw_batch

func
draw_batch : func(self : ^MetalRenderer2D, view : ^metalkit.MTKView, batch : ^RenderBatch) -> RendererStatus

draw

func
draw : func(self : ^MetalRenderer2D, view : ^metalkit.MTKView, vertices : ^ui.Vertex, vertex_count : i64, commands : ^ui.DrawCommand, command_count : i64, width : f32, height : f32) -> RendererStatus