From bae150305d602bb08ed12acc71979f1cd341ff78 Mon Sep 17 00:00:00 2001 From: Peterino2 Date: Thu, 8 Jan 2026 17:19:52 -0800 Subject: [PATCH] enabling shader gen --- build/program.zig | 9 +++++++++ buildgen/generateEmbeddedShaders.zig | 2 +- engine/core/build.zig | 3 +++ engine/main2.zig | 4 ++-- engine/modulelaunch.zig | 2 +- lib/packer/src/packerfs.zig | 2 ++ 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/build/program.zig b/build/program.zig index e5ffa3a..5d07fca 100644 --- a/build/program.zig +++ b/build/program.zig @@ -157,6 +157,11 @@ pub const Program = struct { return lib; } + pub fn generateStaticShaders(self: *@This()) *std.Build.Module { + const loadStatics = self.buildSystem.generateInstallStaticResources(self.name, "content/_shaders") catch unreachable; + return loadStatics; + } + // spec is linked in both the base trampoline pub fn compileInstall(self: *@This()) *std.Build.Step.Compile { const bEngine = self.buildSystem.bEngine; @@ -185,6 +190,10 @@ pub const Program = struct { exe.root_module.addImport("platform", platform); } + if (self.opts.static_build) { + exe.root_module.addImport().addImport("staticShaderLoader", self.generateStaticShaders()); + } + const gameModule = self.makeGameModule(); const gameApi = self.makeGameApi(); gameModule.root_module.addImport("backlog", gameApi); diff --git a/buildgen/generateEmbeddedShaders.zig b/buildgen/generateEmbeddedShaders.zig index 4bac12a..dcb3ca8 100644 --- a/buildgen/generateEmbeddedShaders.zig +++ b/buildgen/generateEmbeddedShaders.zig @@ -73,10 +73,10 @@ pub fn main() !void { var ast = try std.zig.Ast.parse(allocator, @as([:0]const u8, @ptrCast(writer.items[0 .. writer.items.len - 1])), .zig); - // std.debug.print("output=\n{s}", .{content.items[0 .. content.items.len - 1]}); defer ast.deinit(allocator); const out = try ast.renderAlloc(allocator); + std.debug.print("output=\n{s}", .{out}); // Write the content to the file try file.writeAll(out); } diff --git a/engine/core/build.zig b/engine/core/build.zig index b9d564a..361ef64 100644 --- a/engine/core/build.zig +++ b/engine/core/build.zig @@ -28,8 +28,10 @@ pub fn build(b: *std.Build) void { .root_module = b.createModule(.{ .target = target, .optimize = optimize, + .link_libc = true, .root_source_file = b.path("tests/tests.zig"), }), + .use_llvm = true, }); const sampleGameExtern = b.addLibrary(.{ @@ -40,6 +42,7 @@ pub fn build(b: *std.Build) void { .target = target, }), .linkage = .dynamic, + .use_llvm = true, .name = "external", }); sampleGameExtern.root_module.addImport("core", mod); diff --git a/engine/main2.zig b/engine/main2.zig index 390b89b..8f839b6 100644 --- a/engine/main2.zig +++ b/engine/main2.zig @@ -83,8 +83,8 @@ pub fn startEngine(spec: *core.SpecVariantMap) bool { if (comptime core.BuildOption("static_build")) { core.engine_log("static build, using embedded shaders", .{}); - // const loader = @import("staticShaderLoader"); - // loader.installStaticResources() catch return false; + const loader = @import("staticShaderLoader"); + loader.installStaticResources() catch return false; } core.start_module(spec, args, allocator) catch return false; diff --git a/engine/modulelaunch.zig b/engine/modulelaunch.zig index fd442ed..6409a8e 100644 --- a/engine/modulelaunch.zig +++ b/engine/modulelaunch.zig @@ -38,7 +38,7 @@ pub export fn startup_module(p_allocator: *anyopaque, p_a: ?*anyopaque) bool { defer z1.End(); core.engine_logs("starting module >>>> " ++ feature ++ " <<<<"); core.tracy.Message(Struct.Module.name); - Struct.start_module(spec, args, allocator) catch return false; + Struct.start_module(spec, args, allocator) catch @panic("start_module failed"); if (core.MemoryTracker.MTGet()) |_| { core.MemoryTracker.MTPrintStatsDelta(); diff --git a/lib/packer/src/packerfs.zig b/lib/packer/src/packerfs.zig index e7589fe..96b57e3 100644 --- a/lib/packer/src/packerfs.zig +++ b/lib/packer/src/packerfs.zig @@ -342,6 +342,8 @@ pub const PackerFS = struct { } pub fn installFileBytesMount(self: *@This(), path: []const u8, fileBytes: []align(8) u8, embedded: bool) !?PackerBytesMapping { + std.debug.print("mounting file path {s}\n", .{path}); + const pakMountIndex = self.pakMountings.items.len; try self.pakMountings.append(self.allocator, .{ .filePath = try self.stringAlloc().dupe(u8, path),