From ca1ee7d2c4eb18726d440bc82589339f48f5cc3e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 1 Feb 2026 13:18:31 -0800 Subject: [PATCH] renderer: don't draw overlay if it isn't needed This avoids loud log messages when no overlay is present. --- src/renderer/generic.zig | 70 +--------------------------------------- 1 file changed, 1 insertion(+), 69 deletions(-) diff --git a/src/renderer/generic.zig b/src/renderer/generic.zig index 3c77e4cdf..c8acebd0f 100644 --- a/src/renderer/generic.zig +++ b/src/renderer/generic.zig @@ -1644,7 +1644,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type { // Debug overlay. We do this before any custom shader state // because our debug overlay is aligned with the grid. - self.images.draw( + if (self.overlay != null) self.images.draw( &self.api, self.shaders.pipelines.image, &pass, @@ -1704,74 +1704,6 @@ pub fn Renderer(comptime GraphicsAPI: type) type { self.swap_chain.releaseFrame(); } - fn drawImagePlacements( - self: *Self, - pass: *RenderPass, - placements: []const imagepkg.Placement, - ) !void { - if (placements.len == 0) return; - - for (placements) |p| { - - // Look up the image - const image = self.images.get(p.image_id) orelse { - log.warn("image not found for placement image_id={}", .{p.image_id}); - continue; - }; - - // Get the texture - const texture = switch (image.image) { - .ready, - .unload_ready, - => |t| t, - else => { - log.warn("image not ready for placement image_id={}", .{p.image_id}); - continue; - }, - }; - - // Create our vertex buffer, which is always exactly one item. - // future(mitchellh): we can group rendering multiple instances of a single image - var buf = try Buffer(shaderpkg.Image).initFill( - self.api.imageBufferOptions(), - &.{.{ - .grid_pos = .{ - @as(f32, @floatFromInt(p.x)), - @as(f32, @floatFromInt(p.y)), - }, - - .cell_offset = .{ - @as(f32, @floatFromInt(p.cell_offset_x)), - @as(f32, @floatFromInt(p.cell_offset_y)), - }, - - .source_rect = .{ - @as(f32, @floatFromInt(p.source_x)), - @as(f32, @floatFromInt(p.source_y)), - @as(f32, @floatFromInt(p.source_width)), - @as(f32, @floatFromInt(p.source_height)), - }, - - .dest_size = .{ - @as(f32, @floatFromInt(p.width)), - @as(f32, @floatFromInt(p.height)), - }, - }}, - ); - defer buf.deinit(); - - pass.step(.{ - .pipeline = self.shaders.pipelines.image, - .buffers = &.{buf.buffer}, - .textures = &.{texture}, - .draw = .{ - .type = .triangle_strip, - .vertex_count = 4, - }, - }); - } - } - /// Call this any time the background image path changes. /// /// Caller must hold the draw mutex.