summaryrefslogtreecommitdiff
path: root/examples/live/src/probe.zig
diff options
context:
space:
mode:
Diffstat (limited to 'examples/live/src/probe.zig')
-rw-r--r--examples/live/src/probe.zig12
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/live/src/probe.zig b/examples/live/src/probe.zig
index 5f6e8ee..1e2970c 100644
--- a/examples/live/src/probe.zig
+++ b/examples/live/src/probe.zig
@@ -17,6 +17,7 @@ pub const height = 360;
pub const Session = struct {
images: [3]sk.Image = .{ .none, .none, .none },
block: sk.Buffer = .none,
+ tapes: sk.Buffer = .none,
time: f32 = 0,
};
@@ -80,7 +81,7 @@ const pipeline: gpu.Pipeline = .{
.attributes = &.{},
.blend = .none,
};
-const kernel: gpu.Kernel = .{ .code = shaders.synth_comp, .readwrite_buffers = 1, .uniform_buffers = 1 };
+const kernel: gpu.Kernel = .{ .code = shaders.synth_comp, .readonly_buffers = 1, .readwrite_buffers = 1, .uniform_buffers = 1 };
pub fn draw(ss: *Session, f: *sk.Frame) void {
f.clear(0x000000);
@@ -88,6 +89,7 @@ pub fn draw(ss: *Session, f: *sk.Frame) void {
if (ss.block == .none) {
for (&ss.images, sizes) |*image, size| image.* = f.host.newImage(size[0], size[1]);
ss.block = f.host.newBuffer(1024 * @sizeOf(f32));
+ ss.tapes = f.host.newBuffer(2 * Lang.max_tape * 16);
}
ss.time += @floatCast(@as(f64, @floatFromInt(f.in.dt)) / std.time.ns_per_s);
for (pictures) |p| {
@@ -107,15 +109,15 @@ pub fn draw(ss: *Session, f: *sk.Frame) void {
});
}
for (blocks) |k| {
- var both: [2 * Lang.max_tape][4]u32 = undefined;
- both[0..Lang.max_tape].* = tape(k.len);
- both[Lang.max_tape..].* = tape(k.len);
+ const both = f.scratch.create([2][Lang.max_tape][4]u32) catch return;
+ both.* = .{ tape(k.len), tape(k.len) };
+ f.upload(ss.tapes, 0, std.mem.asBytes(both));
f.compute(.{
.label = k.label,
.kernel = kernel,
+ .readonly = &.{ss.tapes},
.readwrite = &.{ss.block},
.uniforms = gpu.uniform(f.scratch, Lang.Synth{
- .tape = both,
.len = k.len,
.old_len = k.len,
.count = k.count,