From 49f659e24c5ace2568555a0a37772bc56a0be393 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 04:36:56 -0300 Subject: gui: the renderer's resources, pictures, overlay and atlas upload are sketchbook's (src/gpu/Cells.zig), moved as they were, the fourth step of the GPU move, its first half: the atlas's texture, sampler and upload buffer, the pictures' sampler, the four pipelines, the overlay's buffers and their release (runNative: Cells.init and deinit, on Present's device, before the device goes), the cells' and the pictures' instance buffers, the pictures' textures by key (releaseNativeImage, clearNativeImages, uploadNativeTexture's upload and uploadTextureRows: Cells.image, which takes the RGBA, its size and stride and the dirty rows, still the whole picture or only the rows that changed into the texture held), the pictures' instance upload (Cells.mapImages and uploadImages around gui.zig's emitPreparedImage) and their draws (drawNativeImagesGpu: Cells.drawImages, each picture's clip, imageScissor's, kept beside its texture as the frame's instances are written), the addon pipeline (made on first use as before: Cells.makeAddonPipeline), uploadAtlas (over the Atlas's dirty rows), uploadOverlayGpu, pushLayerOpacity and drawOverlayGpu leave gui.zig; the seven SPIR-V embeds go with the pipelines (build.zig gives the `.spv` imports to the Cells module, sketchbook's GLSL through glslc or its prebuilt copies, as before); the Gui holds a pointer to runNative's Cells (`cells`) and no longer the device; an addon's texture is still handed over borrowed and premultiplied; renderFrame's command buffer, cell upload and render pass stay for the second half; frame corpus unchanged (77 frames) --- build.zig | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'build.zig') diff --git a/build.zig b/build.zig index 6d2ddeaf..25f1d8b9 100644 --- a/build.zig +++ b/build.zig @@ -928,16 +928,25 @@ pub fn build(b: *std.Build) void { if (b.lazyDependency("sketchbook", .{ .@"gpu-only" = true })) |sb| { const gpu = b.createModule(.{ .root_source_file = sb.path("src/gpu/Executor.zig"), .imports = &.{ .{ .name = "abi", .module = sb.module("abi") }, .{ .name = "c", .module = gui_c_mod } } }); gm.addImport("sketch_gpu", gpu); - // pardes's renderer, moved to sketchbook (src/gpu/), compiled - // against pardes's SDL; its tests run with unit-test. - const cells_mod = b.createModule(.{ .root_source_file = sb.path("src/gpu/Cells.zig"), .imports = &.{.{ .name = "c", .module = gui_c_mod }} }); - gm.addImport("gpu_cells", cells_mod); - gm.addImport("gpu_present", b.createModule(.{ .root_source_file = sb.path("src/gpu/Present.zig"), .imports = &.{ .{ .name = "c", .module = gui_c_mod }, .{ .name = "gpu_cells", .module = cells_mod } } })); - if (cells_test == null) cells_test = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = sb.path("src/gpu/Cells.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "c", .module = gui_c_mod }} }), .filters = test_filters }); // The glyph atlas (src/font/Atlas.zig) over the font shim // (vendor/font.{c,h}), compiled below against pardes's // FreeType and HarfBuzz. - gm.addImport("font_atlas", b.createModule(.{ .root_source_file = sb.path("src/font/Atlas.zig"), .imports = &.{.{ .name = "c", .module = gui_c_mod }} })); + const atlas_mod = b.createModule(.{ .root_source_file = sb.path("src/font/Atlas.zig"), .imports = &.{.{ .name = "c", .module = gui_c_mod }} }); + gm.addImport("font_atlas", atlas_mod); + // pardes's renderer, moved to sketchbook (src/gpu/), compiled + // against pardes's SDL; its tests run with unit-test. Its + // SPIR-V is sketchbook's GLSL through glslc, or the prebuilt + // copies with -Dprebuilt-shaders. + const cells_mod = b.createModule(.{ .root_source_file = sb.path("src/gpu/Cells.zig"), .imports = &.{ .{ .name = "c", .module = gui_c_mod }, .{ .name = "font_atlas", .module = atlas_mod } } }); + for (gui_shaders) |name| cells_mod.addAnonymousImport(b.fmt("{s}.spv", .{name}), .{ + .root_source_file = if (prebuilt_shaders) + sb.path(b.fmt("src/gpu/shaders/prebuilt/{s}.spv", .{name})) + else + compileGlsl(b, sb.path(b.fmt("src/gpu/shaders/{s}.glsl", .{name})), name), + }); + gm.addImport("gpu_cells", cells_mod); + gm.addImport("gpu_present", b.createModule(.{ .root_source_file = sb.path("src/gpu/Present.zig"), .imports = &.{ .{ .name = "c", .module = gui_c_mod }, .{ .name = "gpu_cells", .module = cells_mod } } })); + if (cells_test == null) cells_test = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = sb.path("src/gpu/Cells.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "c", .module = gui_c_mod }, .{ .name = "font_atlas", .module = atlas_mod } } }), .filters = test_filters }); gui_c.addIncludePath(sb.path("vendor")); gm.addImport("gpu_scene", sb.module("gpu_scene")); } @@ -1015,12 +1024,6 @@ pub fn build(b: *std.Build) void { gm.addAnonymousImport("AdwaitaMono-Regular.ttf", .{ .root_source_file = b.path("assets/AdwaitaMono-Regular.ttf"), }); - if (b.lazyDependency("sketchbook", .{ .@"gpu-only" = true })) |sb| for (gui_shaders) |name| gm.addAnonymousImport(b.fmt("{s}.spv", .{name}), .{ - .root_source_file = if (prebuilt_shaders) - sb.path(b.fmt("src/gpu/shaders/prebuilt/{s}.spv", .{name})) - else - compileGlsl(b, sb.path(b.fmt("src/gpu/shaders/{s}.glsl", .{name})), name), - }); }; if (target.result.os.tag == .macos) if (sdl_include) |include| { const adapter_test = b.addSystemCommand(&.{ "xcrun", "clang", "-fobjc-arc", "-O1", "-framework", "Cocoa", "-I" }); -- cgit v1.3