diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-16 18:04:21 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-16 18:04:21 -0300 |
| commit | e77b01d4b5504cea08a3f88cf8502897d868a1d3 (patch) | |
| tree | c8e643d234dd26d920cbc563bfa7f740febf1fc7 /src/abi.zig | |
| parent | d3074636fff0fbcd5fd9b71c0c3b1c1f5c0c1285 (diff) | |
| download | sketchbook-e77b01d4b5504cea08a3f88cf8502897d868a1d3.tar.gz sketchbook-e77b01d4b5504cea08a3f88cf8502897d868a1d3.zip | |
Add glTF scene rendering, resource setup and 9P controls
Diffstat (limited to 'src/abi.zig')
| -rw-r--r-- | src/abi.zig | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/abi.zig b/src/abi.zig index 77a737d..2eed3a7 100644 --- a/src/abi.zig +++ b/src/abi.zig @@ -464,6 +464,8 @@ pub const gpu = struct { primitive: enum { triangle_list, triangle_strip, line_list, line_strip } = .triangle_list, blend: Blend = .premultiplied, write_color: bool = true, + depth_test: ?Compare = null, + depth_write: bool = false, /// Stencil test and update, per triangle facing. Needs a pass with /// a stencil buffer. stencil: ?struct { front: StencilFace, back: StencilFace } = null, @@ -527,6 +529,8 @@ pub const gpu = struct { primitive: @FieldType(Pipeline, "primitive") = .triangle_list, blend: Blend = .premultiplied, write_color: bool = true, + depth_test: ?Compare = null, + depth_write: bool = false, stencil: @FieldType(Pipeline, "stencil") = null, }) Pipeline { return .{ @@ -537,6 +541,8 @@ pub const gpu = struct { .primitive = p.primitive, .blend = p.blend, .write_color = p.write_color, + .depth_test = p.depth_test, + .depth_write = p.depth_write, .stencil = p.stencil, }; } @@ -564,11 +570,20 @@ pub const gpu = struct { /// 1, 2, 4 or 8. More than one renders multisampled and resolves. samples: u8 = 1, stencil: bool = false, + /// Clears depth to 1 each pass; pipelines choose comparison and writes. + depth: bool = false, /// Premultiplied; null keeps the image's previous contents. clear: ?[4]f32 = .{ 0, 0, 0, 0 }, pipelines: []const Pipeline, draws: []const Draw, }; + + /// A fullscreen triangle sampling one completed pass at fragment binding 0. + pub const PostProcess = struct { + vertex: Shader, + fragment: Shader, + fragment_uniforms: []const u8 = &.{}, + }; }; /// Host services. Handles and loaded data outlive reloads. @@ -593,6 +608,8 @@ pub const Host = struct { /// A GPU buffer of `size` bytes, zeroed; `.none` without a GPU. newBuffer: *const fn (*anyopaque, u32) Buffer, freeBuffer: *const fn (*anyopaque, Buffer) void, + /// Submits a copy now; source bytes may be released on return. + writeBuffer: *const fn (*anyopaque, Buffer, u32, []const u8) anyerror!void, /// Zero while unknown. imageSize: *const fn (*anyopaque, Image) [2]u32, /// What `Command.text` gives the bytes at a scale: the width they @@ -642,6 +659,10 @@ pub const Host = struct { pub fn freeBuffer(h: Host, buffer: Buffer) void { h.vtable.freeBuffer(h.ctx, buffer); } + /// Upload immediately, including during session setup. + pub fn writeBuffer(h: Host, buffer: Buffer, offset: u32, bytes: []const u8) !void { + try h.vtable.writeBuffer(h.ctx, buffer, offset, bytes); + } pub fn imageSize(h: Host, image: Image) [2]u32 { return h.vtable.imageSize(h.ctx, image); } @@ -766,6 +787,8 @@ pub const Sketch = struct { defaults: *const fn (Memory, [*]u8) callconv(.c) void, /// Setup for brand new state, after its defaults. init: *const fn (*const Context, [*]u8) callconv(.c) void, + /// Resource setup once per fresh Session; receives no State pointer. + setup: *const fn (*const Context) callconv(.c) bool, /// Deterministic: new state from state and input, nothing else. update: *const fn (*const Context, [*]u8) callconv(.c) void, /// Presentation: reads state, may change session and store, appends @@ -778,6 +801,7 @@ pub const Sketch = struct { .info = "sketch_info", .defaults = "sketch_defaults", .init = "sketch_init", + .setup = "sketch_setup", .update = "sketch_update", .draw = "sketch_draw", .command = "sketch_command", |
