diff options
Diffstat (limited to 'src/host/Host.zig')
| -rw-r--r-- | src/host/Host.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/host/Host.zig b/src/host/Host.zig index 745d9a1..035a004 100644 --- a/src/host/Host.zig +++ b/src/host/Host.zig @@ -447,6 +447,7 @@ fn draw(self: *Host, now: u64, started: u64) !u64 { .audio => |a| self.audio.push(a.key, a.samples, a.clear), .quit => self.quit = true, .gpu => |pass| if (self.passes) |*g| self.runGpu(g, pass) catch |err| self.print("gpu pass: {t} ({s})", .{ err, c.SDL_GetError() }), + .post_process => |p| if (self.passes) |*g| self.runPostProcess(g, p.source, p.target, p.effect) catch |err| self.print("gpu postprocess: {t} ({s})", .{ err, c.SDL_GetError() }), .upload => |u| if (self.passes) |*g| g.write(u.buffer, u.offset, u.bytes) catch |err| self.print("gpu upload: {t} ({s})", .{ err, c.SDL_GetError() }), .compute => |d| if (self.passes) |*g| g.compute(d) catch |err| self.print("gpu compute: {t} ({s})", .{ err, c.SDL_GetError() }), .microphone => self.audio.listen(), @@ -981,6 +982,15 @@ fn apiEnv(ctx: *anyopaque, name: []const u8) ?[]const u8 { return hostOf(ctx).environ.get(name); } +fn runPostProcess(self: *Host, g: *Gpu, source: abi.Image, target: abi.Image, post: abi.gpu.PostProcess) !void { + const input = g.output(source) orelse return error.MissingImage; + const before = g.output(target); + const changed = if (before) |t| t.width != input.width or t.height != input.height else true; + if (changed) self.images.unwrap(target); + try g.runPostProcess(source, target, post); + if (g.output(target)) |t| try self.images.wrap(target, t.texture, t.width, t.height); +} + fn runGpu(self: *Host, g: *Gpu, pass: abi.gpu.Pass) !void { const before = g.output(pass.image); const changed = if (before) |t| t.width != pass.width or t.height != pass.height else true; |
