this repo has no description

changed render context

+7 -8
+2 -2
src/rayray.zig
··· 60 60 const finished_threads = try self.allocator.alloc(bool, num_threads); 61 61 62 62 for (0..num_threads) |row| { 63 - const ctx = renderer.Context{ .cam = &self.camera, .world = &self.world, .done = &threads[row].done }; 64 - const t = try std.Thread.spawn(.{}, renderer.renderThread, .{ ctx, row, row_height }); 63 + const ctx = renderer.Context{ .cam = &self.camera, .world = &self.world }; 64 + const t = try std.Thread.spawn(.{}, renderer.renderThread, .{ ctx, &threads[row].done, row, row_height }); 65 65 threads[row].thread = t; 66 66 } 67 67
+5 -6
src/renderer.zig
··· 17 17 pub const Context = struct { 18 18 cam: *Camera, 19 19 world: *hittable.HittableList, 20 - done: *std.atomic.Value(bool), 21 20 }; 22 21 23 22 pub fn rayColor(r: *Ray, world: *hittable.HittableList) zm.Vec { ··· 30 29 return zm.f32x4s(1.0 - a) * zm.f32x4s(1.0) + zm.f32x4s(a) * zm.f32x4(0.5, 0.7, 1.0, 1.0); 31 30 } 32 31 33 - pub fn render(ctx: Context, height: IntervalUsize, width: IntervalUsize) void { 32 + pub fn run(ctx: Context, height: IntervalUsize, width: IntervalUsize) void { 34 33 var height_iter = height.iter(); 35 34 height_iter.upper_boundry = .inclusive; 36 35 ··· 51 50 ctx.cam.setPixel(i, j, col) catch break; 52 51 } 53 52 } 54 - 55 - ctx.done.store(true, .Release); 56 53 } 57 54 58 - pub fn renderThread(ctx: Context, row: usize, row_height: usize) void { 55 + pub fn renderThread(ctx: Context, done: *std.atomic.Value(bool), row: usize, row_height: usize) void { 59 56 spall.init_thread(); 60 57 defer spall.deinit_thread(); 61 58 ··· 67 64 const s = spall.trace(@src(), "Render Thread {}", .{row}); 68 65 defer s.end(); 69 66 70 - render(ctx, height, width); 67 + run(ctx, height, width); 68 + 69 + done.store(true, .Release); 71 70 } 72 71 73 72 fn vecToRgba(v: zm.Vec) color.Rgba32 {