enabling shader gen

This commit is contained in:
Peterino2 2026-01-08 17:19:52 -08:00
parent 6300ef0e35
commit bae150305d
6 changed files with 18 additions and 4 deletions

View File

@ -157,6 +157,11 @@ pub const Program = struct {
return lib; 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 // spec is linked in both the base trampoline
pub fn compileInstall(self: *@This()) *std.Build.Step.Compile { pub fn compileInstall(self: *@This()) *std.Build.Step.Compile {
const bEngine = self.buildSystem.bEngine; const bEngine = self.buildSystem.bEngine;
@ -185,6 +190,10 @@ pub const Program = struct {
exe.root_module.addImport("platform", platform); exe.root_module.addImport("platform", platform);
} }
if (self.opts.static_build) {
exe.root_module.addImport().addImport("staticShaderLoader", self.generateStaticShaders());
}
const gameModule = self.makeGameModule(); const gameModule = self.makeGameModule();
const gameApi = self.makeGameApi(); const gameApi = self.makeGameApi();
gameModule.root_module.addImport("backlog", gameApi); gameModule.root_module.addImport("backlog", gameApi);

View File

@ -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); 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); defer ast.deinit(allocator);
const out = try ast.renderAlloc(allocator); const out = try ast.renderAlloc(allocator);
std.debug.print("output=\n{s}", .{out});
// Write the content to the file // Write the content to the file
try file.writeAll(out); try file.writeAll(out);
} }

View File

@ -28,8 +28,10 @@ pub fn build(b: *std.Build) void {
.root_module = b.createModule(.{ .root_module = b.createModule(.{
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
.link_libc = true,
.root_source_file = b.path("tests/tests.zig"), .root_source_file = b.path("tests/tests.zig"),
}), }),
.use_llvm = true,
}); });
const sampleGameExtern = b.addLibrary(.{ const sampleGameExtern = b.addLibrary(.{
@ -40,6 +42,7 @@ pub fn build(b: *std.Build) void {
.target = target, .target = target,
}), }),
.linkage = .dynamic, .linkage = .dynamic,
.use_llvm = true,
.name = "external", .name = "external",
}); });
sampleGameExtern.root_module.addImport("core", mod); sampleGameExtern.root_module.addImport("core", mod);

View File

@ -83,8 +83,8 @@ pub fn startEngine(spec: *core.SpecVariantMap) bool {
if (comptime core.BuildOption("static_build")) { if (comptime core.BuildOption("static_build")) {
core.engine_log("static build, using embedded shaders", .{}); core.engine_log("static build, using embedded shaders", .{});
// const loader = @import("staticShaderLoader"); const loader = @import("staticShaderLoader");
// loader.installStaticResources() catch return false; loader.installStaticResources() catch return false;
} }
core.start_module(spec, args, allocator) catch return false; core.start_module(spec, args, allocator) catch return false;

View File

@ -38,7 +38,7 @@ pub export fn startup_module(p_allocator: *anyopaque, p_a: ?*anyopaque) bool {
defer z1.End(); defer z1.End();
core.engine_logs("starting module >>>> " ++ feature ++ " <<<<"); core.engine_logs("starting module >>>> " ++ feature ++ " <<<<");
core.tracy.Message(Struct.Module.name); 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()) |_| { if (core.MemoryTracker.MTGet()) |_| {
core.MemoryTracker.MTPrintStatsDelta(); core.MemoryTracker.MTPrintStatsDelta();

View File

@ -342,6 +342,8 @@ pub const PackerFS = struct {
} }
pub fn installFileBytesMount(self: *@This(), path: []const u8, fileBytes: []align(8) u8, embedded: bool) !?PackerBytesMapping { 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; const pakMountIndex = self.pakMountings.items.len;
try self.pakMountings.append(self.allocator, .{ try self.pakMountings.append(self.allocator, .{
.filePath = try self.stringAlloc().dupe(u8, path), .filePath = try self.stringAlloc().dupe(u8, path),