sucessfully compiling minimal

This commit is contained in:
peterino2 2025-10-19 00:04:09 -07:00
parent 1be853d166
commit 7a6308454a
20 changed files with 149 additions and 236 deletions

View File

@ -10,7 +10,6 @@ run tools/scripts/first-time-setup.py
ffmpeg -i INPUT.mp4 -c:v libtheora -q:v 7 -c:a libvorbis -q:a 4 OUTPUT.ogv
/// --------------------------------------------------------
void* malloc(size_t size); // gives you a pointer to a memory buffer of size
void free(void* ptr); // releases a pointer to memory

102
build.zig
View File

@ -2,9 +2,8 @@
b: *std.Build,
nw_builder: *std.Build,
target: std.Build.ResolvedTarget,
optimize: std.builtin.Mode,
optimize: std.builtin.OptimizeMode,
nw_mod: *std.Build.Module,
spirvReflect: SpirvReflect.SpirvGenerator2,
gltf2ozz: ozz.GltfToOzz,
options: *std.Build.Step.Options,
cookShaders: bool,
@ -42,7 +41,6 @@ const std = @import("std");
const Build = std.Build;
const LazyPath = Build.LazyPath;
const SpirvReflect = @import("SpirvReflect");
const ozz = @import("ozz");
pub const InitOptions = struct {
@ -75,7 +73,6 @@ pub fn init(b: *std.Build, opts: InitOptions) BuildSystem {
.optimize = opts.optimize,
.nw_mod = nwdep.module("Backlog"),
.backlogRoot = opts.backlogRoot,
.spirvReflect = SpirvReflect.SpirvGenerator2.init(nwdep.builder, .{}),
.options = createGameOptions(b, buildOpts),
.gltf2ozz = ozz.GltfToOzz.init(nwdep.builder, .{}),
.cookShaders = b.option(bool, "cookShaders", "generates shaders and updates .json files before running the build. (needs to be done whenever shaders are updated, this just runs tools/scripts/cook-shaders.py)") orelse false,
@ -88,7 +85,7 @@ pub fn init(b: *std.Build, opts: InitOptions) BuildSystem {
.shaderEmbedGen = nwdep.artifact("backlog-shaderEmbedGen"),
};
const exeList = [2]*std.Build.Step.Compile{ self.gltf2ozz.exe, self.spirvReflect.reflect };
const exeList = [1]*std.Build.Step.Compile{self.gltf2ozz.exe};
const install_tools = b.step("tools", "installs tools needed to generate outputs for the engine");
for (exeList) |exe| {
const toolsInstall = b.addInstallArtifact(exe, .{
@ -108,16 +105,6 @@ pub fn init(b: *std.Build, opts: InitOptions) BuildSystem {
run_exe.dependOn(&runArtifact.step);
}
{
const runArtifact = b.addRunArtifact(self.spirvReflect.reflect);
if (b.args) |args| {
runArtifact.addArgs(args);
}
const run_exe = b.step("spv-reflect", "runs the gltf animation converter.");
run_exe.dependOn(&runArtifact.step);
}
self.addDependencyInstalls(self.b, .ReleaseFast);
return self;
@ -135,9 +122,11 @@ pub fn addProgram(self: *BuildSystem, opts: AddProgramOptions) *std.Build.Module
const exe = self.nw_builder.addExecutable(.{
.name = opts.name,
.target = self.target,
.optimize = self.optimize,
.root_source_file = self.nw_builder.path("engine/main.zig"),
.root_module = b.createModule(.{
.target = self.target,
.optimize = self.optimize,
.root_source_file = self.nw_builder.path("engine/main.zig"),
}),
});
b.installArtifact(exe);
@ -329,28 +318,24 @@ pub const DynamicModule = struct {
const b = self.buildSystem.b;
const static = self.buildSystem.staticBuild;
const lib = if (static)
b.addStaticLibrary(.{
const lib = b.addLibrary(.{
.name = self.name,
.linkage = if (static) .static else .dynamic,
.root_module = b.createModule(.{
.root_source_file = self.opts.root_source_file,
.link_libc = true,
.optimize = self.buildSystem.optimize,
.target = self.buildSystem.target,
.name = self.name,
})
else
b.addSharedLibrary(.{
.root_source_file = self.opts.root_source_file,
.link_libc = true,
.optimize = self.buildSystem.optimize,
.target = self.buildSystem.target,
.name = self.name,
});
}),
});
var modlist = std.ArrayList([]const u8).init(self.buildSystem.b.allocator);
const allocator = self.buildSystem.b.allocator;
var modlist = std.ArrayList([]const u8){};
for (self.gameModules.items) |mod| {
if (mod.enabled) {
modlist.append(mod.name) catch @panic("out of memory");
modlist.append(allocator, mod.name) catch @panic("out of memory");
}
}
@ -423,11 +408,13 @@ pub const Program = struct {
pub fn compileInstall(self: *@This()) *std.Build.Module {
const exe = self.buildSystem.addProgram(self.opts);
var modlist = std.ArrayList([]const u8).init(self.buildSystem.b.allocator);
const allocator = self.buildSystem.b.allocator;
var modlist = std.ArrayList([]const u8){};
for (self.gameModules.items) |mod| {
if (mod.enabled) {
modlist.append(mod.name) catch @panic("out of memory");
modlist.append(allocator, mod.name) catch @panic("out of memory");
}
}
@ -477,46 +464,49 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
const spirvDep = b.dependency("SpirvReflect", .{
.target = target,
.optimize = optimize,
.static_build = static_build,
});
_ = spirvDep;
const fwdGeneratorExe = b.addExecutable(.{
.name = "backlog-generate-fwd",
.target = b.graph.host,
.optimize = .Debug,
.root_source_file = b.path("build/generateFwd.zig"),
.root_module = b.createModule(.{
.target = b.graph.host,
.optimize = .Debug,
.root_source_file = b.path("build/generateFwd.zig"),
}),
});
const generateExe = b.addExecutable(.{
.name = "backlog-apigen",
.target = b.graph.host,
.optimize = .Debug,
.root_source_file = b.path("build/generateApi.zig"),
.root_module = b.createModule(.{
.target = b.graph.host,
.optimize = .Debug,
.root_source_file = b.path("build/generateApi.zig"),
}),
});
const generateShaders = b.addExecutable(.{
.name = "backlog-shaderEmbedGen",
.target = b.graph.host,
.optimize = .Debug,
.root_source_file = b.path("build/generateEmbeddedShaders.zig"),
.root_module = b.createModule(.{
.target = b.graph.host,
.optimize = .Debug,
.root_source_file = b.path("build/generateEmbeddedShaders.zig"),
}),
});
const generateRcExe = b.addExecutable(.{
.name = "backlog-generate-rc",
.target = b.graph.host,
.optimize = .Debug,
.root_source_file = b.path("build/generateRc.zig"),
.root_module = b.createModule(.{
.target = b.graph.host,
.optimize = .Debug,
.root_source_file = b.path("build/generateRc.zig"),
}),
});
const generateLoadDynamicsExe = b.addExecutable(.{
.name = "backlog-generate-loadDynamics",
.target = b.graph.host,
.optimize = .Debug,
.root_source_file = b.path("build/generateLoadDynamics.zig"),
.root_module = b.createModule(.{
.target = b.graph.host,
.optimize = .Debug,
.root_source_file = b.path("build/generateLoadDynamics.zig"),
}),
});
b.installArtifact(generateLoadDynamicsExe);

View File

@ -13,7 +13,6 @@
.ui = .{ .path = "engine/ui" },
.sys = .{ .path = "engine/sys" },
.rend = .{.path = "engine/rend" },
.SpirvReflect = .{ .path = "lib/spirv-reflect-zig" },
.ozz = .{ .path = "lib/ozz" },
.spng = .{ .path = "lib/spng" },

View File

@ -13,21 +13,20 @@ pub fn main() !void {
// Generate a startup module function that invokes
// startup module for each zig function
// and generates an api
var content = std.ArrayList(u8).init(allocator);
var writer = content.writer();
var writer = std.ArrayList(u8){};
const moduleList = args[2..];
for (moduleList) |mod| {
try writer.print("pub const {s} = @import(\"{s}\").module;\n", .{ mod, mod });
try writer.print(allocator, "pub const {s} = @import(\"{s}\").module;\n", .{ mod, mod });
}
try writer.print("pub const moduleList:[]const []const u8 = &.{{\n", .{});
try writer.print(allocator, "pub const moduleList:[]const []const u8 = &.{{\n", .{});
for (moduleList) |mod| {
try writer.print("\"{s}\",\n", .{mod});
try writer.print(allocator, "\"{s}\",\n", .{mod});
}
try writer.print("}};\n", .{});
try writer.print(allocator, "}};\n", .{});
try writer.print(
try writer.print(allocator,
\\var shutdownList: std.ArrayListUnmanaged(*const fn (std.mem.Allocator) void) = .{{}};
\\var shutdownModuleNames: std.ArrayListUnmanaged([]const u8) = .{{}};
\\
@ -45,9 +44,9 @@ pub fn main() !void {
\\ return a;
\\ }}
, .{});
try writer.print("pub fn start_modules_(spec: *core.SpecVariantMap, maybeArgs: ?NwArgs, allocator: std.mem.Allocator) !void {{", .{});
try writer.print(allocator, "pub fn start_modules_(spec: *core.SpecVariantMap, maybeArgs: ?NwArgs, allocator: std.mem.Allocator) !void {{", .{});
try writer.print(
try writer.print(allocator,
\\
\\ var z = core.tracy.ZoneN(@src(), "Starting all Modules");
\\ defer z.End();
@ -87,7 +86,7 @@ pub fn main() !void {
\\
, .{});
_ = try writer.write(
_ = try writer.appendSlice(allocator,
\\ pub fn startEngine(vtable: *core.EngineObjectVTable, spec: *core.SpecVariantMap) bool {
\\ const args = getArgs() catch return false;
\\
@ -160,24 +159,24 @@ pub fn main() !void {
);
for (moduleList) |mod| {
try writer.print(".{s} = true,\n", .{mod});
try writer.print(allocator, ".{s} = true,\n", .{mod});
}
try writer.print("}}, std.heap.c_allocator); }}\n", .{});
try writer.print(allocator, "}}, std.heap.c_allocator); }}\n", .{});
try writer.print("const std = @import(\"std\");\n\n", .{});
try writer.print(allocator, "const std = @import(\"std\");\n\n", .{});
// Write to specified output file
// Open or create the file for writing (overwrites if it exists)
const file = try std.fs.cwd().createFile(out_path, .{});
defer file.close();
try content.append(0);
try writer.append(allocator, 0);
var ast = try std.zig.Ast.parse(allocator, @as([:0]const u8, @ptrCast(content.items[0 .. content.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);
const out = try ast.render(allocator);
const out = try ast.renderAlloc(allocator);
// Write the content to the file
try file.writeAll(out);

View File

@ -1,5 +1,11 @@
const std = @import("std");
// this file creates auto generated static resource installers for
// embedded shaders.
//
// when building with -Dstatic_build shaders are instead not loaded from the file system
// but instead embedded into the binary
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
@ -13,8 +19,7 @@ pub fn main() !void {
// Generate a startup module function that invokes
// startup module for each zig function
// and generates an api
var content = std.ArrayList(u8).init(allocator);
var writer = content.writer();
var writer = std.ArrayList(u8){};
// const content_path = args[2];
// std.debug.print("content path: {s}\n", .{content_path});
@ -24,14 +29,14 @@ pub fn main() !void {
var dir = try std.fs.cwd().openDir("content/_shaders", .{ .iterate = true });
defer dir.close();
_ = try writer.write(
_ = try writer.appendSlice(allocator,
\\ pub const core = @import("core").module;
\\
\\ pub fn installStaticResources() !void {
\\
);
var shaderFileEmbeds = std.ArrayList([]const u8).init(allocator);
var shaderFileEmbeds = std.ArrayList([]const u8){};
var walker = dir.iterate();
while (try walker.next()) |shaderType| {
@ -44,32 +49,33 @@ pub fn main() !void {
const shaderPath = try std.fmt.allocPrint(allocator, "_shaders/{s}/{s}", .{ shaderType.name, shaderName.name });
// std.debug.print("mounted path: {s} => {s}\n", .{ shaderPath, shaderName.name });
try writer.print(
allocator,
"{{ const embedded align(8) = @embedFile(\"{s}\").*;\n_ = try core.fs().installFileBytesMount(\"{s}\", @constCast(&embedded), true);}}\n",
.{ shaderName.name, shaderPath },
);
try shaderFileEmbeds.append(shaderName.name);
try shaderFileEmbeds.append(allocator, shaderName.name);
}
}
}
_ = try writer.write(
_ = try writer.appendSlice(allocator,
\\ }
);
try writer.print("const std = @import(\"std\");", .{});
try writer.print(allocator, "const std = @import(\"std\");", .{});
// Write to specified output file
// Open or create the file for writing (overwrites if it exists)
const file = try std.fs.cwd().createFile(out_path, .{});
defer file.close();
try content.append(0);
try writer.append(allocator, 0);
var ast = try std.zig.Ast.parse(allocator, @as([:0]const u8, @ptrCast(content.items[0 .. content.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);
const out = try ast.render(allocator);
const out = try ast.renderAlloc(allocator);
// Write the content to the file
try file.writeAll(out);

View File

@ -16,15 +16,14 @@ pub fn main() !void {
// Generate a startup module function that invokes
// startup module for each zig function
// and generates an api
var content = std.ArrayList(u8).init(allocator);
var writer = content.writer();
var writer = std.ArrayList(u8){};
// const content_path = args[2];
// std.debug.print("content path: {s}\n", .{content_path});
// check the content directory and search for all _spv files
_ = try writer.write(
_ = try writer.appendSlice(allocator,
\\ pub const core = @import("core").module;
\\
\\ pub fn loadDynamicModules() !void {
@ -33,47 +32,47 @@ pub fn main() !void {
if (!static) {
for (modlist) |mod| {
try writer.print("try core.loadModule(\"{s}\", true);\n", .{mod});
try writer.print(allocator, "try core.loadModule(\"{s}\", true);\n", .{mod});
}
}
if (static) {
_ = try writer.write(
_ = try writer.appendSlice(allocator,
\\ const args = core.externModule.getModuleLoaderArgs(true);
);
if (modlist.len == 0) {
_ = try writer.write(
_ = try writer.appendSlice(allocator,
\\ _ = args;
);
}
for (modlist) |mod| {
try writer.print("try {s}.start_module(args);\n", .{mod});
try writer.print(allocator, "try {s}.start_module(args);\n", .{mod});
}
}
_ = try writer.write("}\n");
_ = try writer.appendSlice(allocator, "}\n");
if (static) {
for (modlist) |mod| {
try writer.print("const {s} = @import(\"{s}\");\n", .{ mod, mod });
try writer.print(allocator, "const {s} = @import(\"{s}\");\n", .{ mod, mod });
}
}
try writer.print("const std = @import(\"std\");", .{});
try writer.print(allocator, "const std = @import(\"std\");", .{});
// Write to specified output file
// Open or create the file for writing (overwrites if it exists)
const file = try std.fs.cwd().createFile(out_path, .{});
defer file.close();
try content.append(0);
try writer.append(allocator, 0);
var ast = try std.zig.Ast.parse(allocator, @as([:0]const u8, @ptrCast(content.items[0 .. content.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);
const out = try ast.render(allocator);
const out = try ast.renderAlloc(allocator);
// Write the content to the file
try file.writeAll(out);

View File

@ -1,5 +1,8 @@
const std = @import("std");
// this generates RC scripts for windows, specifically for
// setting the icon of the output binary
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
@ -13,20 +16,19 @@ pub fn main() !void {
// Generate a startup module function that invokes
// startup module for each zig function
// and generates an api
var content = std.ArrayList(u8).init(allocator);
var writer = content.writer();
var writer = std.ArrayList(u8){};
const iconPath = args[2];
try writer.print("#include <windows.h>\r\n", .{});
try writer.print("IDI_ICON1 ICON \"../../../content/", .{}); //{s}\"", .{iconPath});
try writer.print(allocator, "#include <windows.h>\r\n", .{});
try writer.print(allocator, "IDI_ICON1 ICON \"../../../content/", .{}); //{s}\"", .{iconPath});
for (iconPath) |c| {
if (c == '\\') {
try writer.writeByte('/');
try writer.append(allocator, '/');
} else {
try writer.writeByte(c);
try writer.append(allocator, c);
}
}
try writer.writeByte('"');
try writer.append(allocator, '"');
// Write to specified output file
// Open or create the file for writing (overwrites if it exists)
@ -34,5 +36,5 @@ pub fn main() !void {
defer file.close();
// Write the content to the file
try file.writeAll(content.items);
try file.writeAll(writer.items);
}

View File

@ -82,6 +82,7 @@ pub const SparseMultiSetAdvanced = p2.SparseMultiSetAdvanced;
pub const SetHandle = p2.SetHandle;
pub const EcsContainerInterface = p2.EcsContainerInterface;
pub const IndexPoolHandle = p2.IndexPoolHandle;
pub const PagedVector = p2.PagedVector;
pub const IndexPool = p2.IndexPool;
@ -128,6 +129,7 @@ pub const Vector2f = math.Vector2f;
pub const Rotation = math.Rotation;
pub const launchArgs = @import("args.zig");
pub const ParseArgs = launchArgs.ParseArgs;
pub const panickers = @import("panickers.zig");
pub const scene = @import("scene.zig");
@ -143,6 +145,7 @@ pub const MemoryTracker = @import("MemoryTracker.zig");
pub const DefaultSavePath = "Saved";
pub const logging = @import("logging.zig");
pub const logDisplay = logging.logDisplay;
pub const LoggerSys = logging.LoggerSys;
const c = @This();
@ -199,6 +202,10 @@ pub const ModuleLoader = externModule.ModuleLoader;
pub const ModuleLoaderArgs = externModule.ModuleLoaderArgs;
pub const ecs = @import("ecs.zig");
pub const defineComponentList = ecs.defineComponentList;
pub const undefineComponentList = ecs.undefineComponentList;
pub const Entity = ecs.Entity;
pub const createEntity = ecs.createEntity;

View File

@ -6,7 +6,7 @@ const core = @import("core.zig");
const jobs = @import("jobs.zig");
const math = @import("math.zig");
const tracy = @import("tracy");
const tracy = @import("tracy").t;
const p2 = @import("p2");
const nfd = @import("nfd");

View File

@ -147,8 +147,7 @@ pub const FileLog = struct {
}
pub fn write(self: *@This(), comptime fmt: []const u8, args: anytype) !void {
var writer = self.buffer.writer();
try writer.print(fmt, args);
try self.buffer.print(self.allocator, fmt, args);
}
pub fn writeGraphvizHeader(self: *@This()) !void {
@ -199,6 +198,7 @@ pub const LoggerSys = struct {
logFilePath: []const u8,
logFile: std.fs.File,
consoleFile: std.fs.File,
writerBuffer: []u8,
lock: std.Thread.Mutex = .{},
flushing: std.atomic.Value(bool) = std.atomic.Value(bool).init(false),
@ -250,7 +250,8 @@ pub const LoggerSys = struct {
if (builtin.is_test) {
std.debug.print("{s}", .{self.flushBuffer.items});
} else {
try self.consoleFile.writer().writeAll(self.writeOutBuffer.items);
var writer = self.consoleFile.writer(self.writerBuffer);
try writer.interface.writeAll(self.writeOutBuffer.items);
}
self.writeOutBuffer.clearRetainingCapacity();
self.lock.unlock();
@ -262,8 +263,8 @@ pub const LoggerSys = struct {
if (builtin.is_test) {
std.debug.print("{s}", .{self.flushBuffer.items});
} else {
const writer = self.consoleFile.writer();
try writer.writeAll(self.flushBuffer.items);
var writer = self.consoleFile.writer(self.writerBuffer);
try writer.interface.writeAll(self.flushBuffer.items);
try self.consoleFile.writeAll("");
}
self.flushBuffer.clearRetainingCapacity();
@ -314,6 +315,7 @@ pub const LoggerSys = struct {
.writeOutBuffer = std.ArrayList(u8).initCapacity(allocator, LogBufferSize) catch unreachable,
.flushBuffer = std.ArrayList(u8).initCapacity(allocator, LogBufferSize) catch unreachable,
.logFilePath = ofile,
.writerBuffer = allocator.alloc(u8, LogBufferSize) catch unreachable,
.logFile = cwd.createFile(ofile, .{}) catch unreachable,
.consoleFile = std.fs.File.stdout(),
};

View File

@ -5,7 +5,7 @@ const windows = std.os.windows;
const core = @import("core.zig");
const lua = @import("lua");
fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(windows.WINAPI) c_long {
fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(.winapi) c_long {
switch (info.ExceptionRecord.ExceptionCode) {
windows.EXCEPTION_DATATYPE_MISALIGNMENT => handleSegfaultWindowsExtra(info, 0, "Unaligned Memory Access"),
windows.EXCEPTION_ACCESS_VIOLATION => handleSegfaultWindowsExtra(info, 1, null),
@ -39,7 +39,7 @@ fn handleSegfaultWindowsExtra(
) noreturn {
const exception_address = @intFromPtr(info.ExceptionRecord.ExceptionAddress);
core.engine_logs("PANIC!!");
core.forceFlush();
core.logging.forceFlush();
if (!@hasDecl(windows, "CONTEXT")) {
switch (msg) {
@ -63,15 +63,18 @@ fn handleSegfaultWindowsExtra(
}
fn dumpSegfaultInfoWindows(info: *windows.EXCEPTION_POINTERS, msg: u8, label: ?[]const u8) void {
const stderr = std.io.getStdErr().writer();
var segfaultBuffer: [4096]u8 = undefined;
var stderr = std.fs.File.stderr().writer(&segfaultBuffer);
_ = switch (msg) {
0 => stderr.print("{s}\n", .{label.?}),
1 => stderr.print("Segmentation fault at address 0x{x}\n", .{info.ExceptionRecord.ExceptionInformation[1]}),
2 => stderr.print("Illegal instruction at address 0x{x}\n", .{info.ContextRecord.getRegs().ip}),
0 => stderr.interface.print("{s}\n", .{label.?}),
1 => stderr.interface.print("Segmentation fault at address 0x{x}\n", .{info.ExceptionRecord.ExceptionInformation[1]}),
2 => stderr.interface.print("Illegal instruction at address 0x{x}\n", .{info.ContextRecord.getRegs().ip}),
else => unreachable,
} catch std.posix.abort();
std.debug.dumpStackTraceFromBase(info.ContextRecord);
std.debug.dumpStackTraceFromBase(info.ContextRecord, &stderr.interface);
}
pub fn dumpStackPointerAddr(prefix: []const u8) void {

View File

@ -27,9 +27,11 @@ pub fn build(b: *std.Build) void {
// ========== tests ==========
const tests = b.addTest(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("tests/tests.zig"),
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("tests/tests.zig"),
}),
});
const test_step = b.step("test", "run unit tests for imgui");

View File

@ -11,4 +11,5 @@
.paths = .{
"",
},
.fingerprint = 0xb0f2441596ddf171,
}

View File

@ -23,9 +23,11 @@ pub fn build(b: *std.Build) void {
const test_step = b.step("test", "run unit tests for physics");
const tests = b.addTest(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("tests/tests.zig"),
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("tests/tests.zig"),
}),
});
tests.root_module.addImport("physics", mod);

View File

@ -349,10 +349,10 @@ pub const AnimationSystem = struct {
@panic("too many bones in skeleton, not supported");
}
var bindModels = std.ArrayList(ozz.Float4x4).init(self.backingAllocator);
defer bindModels.deinit();
var bindModels = std.ArrayList(ozz.Float4x4){}; // .init(self.backingAllocator);
defer bindModels.deinit(self.backingAllocator);
try bindModels.resize(new.sk.numJoints());
try bindModels.resize(self.backingAllocator, new.sk.numJoints());
var ltmJob: ozz.LocalToModelJob = .{
.skeleton = new.sk,

8
lib/ozz/build.zig vendored
View File

@ -38,8 +38,10 @@ pub const GltfToOzz = struct {
fn initFromBuilder(b: *Build, ozz_build: *Build, opts: BuildOptions) GltfToOzz {
const exe = ozz_build.addExecutable(.{
.name = "gltf2ozz",
.target = ozz_build.graph.host,
.optimize = .ReleaseSafe,
.root_module = b.createModule(.{
.target = ozz_build.graph.host,
.optimize = .ReleaseSafe,
}),
});
exe.linkLibCpp();
@ -59,6 +61,7 @@ pub const GltfToOzz = struct {
exe.addIncludePath(ozz_build.path("ozz-animation/extern/jsoncpp/dist/json"));
exe.addCSourceFiles(.{
.root = ozz_build.path("."),
.files = &.{
src_dir ++ "animation/offline/gltf/gltf2ozz.cc",
src_dir ++ "animation/offline/tools/import2ozz.cc",
@ -94,6 +97,7 @@ pub const GltfToOzz = struct {
exe.linkLibCpp();
exe.root_module.addCSourceFiles(.{
.root = ozz_build.path("."),
.files = &.{
src_dir ++ "options/options.cc",
src_dir ++ "geometry/runtime/skinning_job.cc",

View File

@ -1,4 +1,4 @@
const tracy = @import("tracy");
const tracy = @import("tracy").t;
const std = @import("std");

View File

@ -48,6 +48,9 @@ pub fn build(b: *std.Build) void {
) orelse true,
};
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
_ = static_build;
const user_extensions = b.option(
[]const std.Build.LazyPath,
"user_extensions",

View File

@ -1,105 +0,0 @@
[ENGINE ]: defining componentScene
[ENGINE ]: Component container created scene.Scene @1f698af1300
[ENGINE ]: creating lua metatable Scene
[ENGINE ]: module started >>>> core <<<<
[ENGINE ]: allocated size: 4034825 (3.848 MiB)
[ENGINE ]: peak allocated size size: 4034953 (3.848 MiB) (72 peak allocations)
[ENGINE ]: module started >>>> assets <<<<
[ENGINE ]: platform settings windowing.PlatformParams{ .extent = math.Vector2Type(c_int,"Vector2c"[0..8]){ .x = 1600, .y = 900 }, .resizeable = true, .windowName = { 66, 97, 99, 107, 108, 111, 103, 32, 69, 110, 103, 105, 110, 101 }, .icon = { 116, 101, 120, 116, 117, 114, 101, 115, 47, 105, 99, 111, 110, 46, 112, 110, 103 }, .hasVideo = true }
[ENGINE ]: module started >>>> platform <<<<
[ENGINE ]: sgpu device created, using shader format: .spv
[ENGINE ]: using renderer... scientist
[ENGINE ]: creating shader meshes.vert => _shaders/spv/meshes.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 1, .num_uniform_buffers = 1 }
[ENGINE ]: creating shader lit_mesh.frag => _shaders/spv/lit_mesh.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 4, .num_storage_textures = 0, .num_storage_buffers = 1, .num_uniform_buffers = 1 }
[GRAPHICS ]: swapchain format: gpu.GPUTextureFormat.textureformatB8g8r8a8Unorm
[ENGINE ]: creating shader postProc.vert => _shaders/spv/postProc.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 }
[ENGINE ]: creating shader postProc.frag => _shaders/spv/postProc.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 3, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 }
[GRAPHICS ]: hdr texture format format: gpu.GPUTextureFormat.textureformatR16g16b16a16Float
[GRAPHICS ]: mesh pool created 4000k vertices, 16000k indices
[ENGINE ]: asset loader for asset type (Mesh) registered
[ENGINE ]: Texture List Added
[ENGINE ]: asset loader for asset type (Texture) registered
[ENGINE ]: creating blocky sampler
[ENGINE ]: loading asset t_default (Texture) [embedded:texture_sample.png]
[ENGINE ]: loading texture t_default
[ENGINE ]: creating mipmap level 9
[ENGINE ]: loading asset m_default_cube (Mesh) [embedded:primitive_box.obj]
[ENGINE ]: loading mesh asset embedded:primitive_box.obj [obj]
[GRAPHICS ]: [embedded:primitive_box.obj] vertex count vertices=24 indices=36
[ENGINE ]: [DebugDrawSystem] starting up...
[ENGINE ]: loading asset m_debug_box (Mesh) [embedded:debug_box.obj]
[ENGINE ]: loading mesh asset embedded:debug_box.obj [obj]
[GRAPHICS ]: [embedded:debug_box.obj] vertex count vertices=24 indices=36
[ENGINE ]: loading asset m_debug_line (Mesh) [embedded:debug_line.obj]
[ENGINE ]: loading mesh asset embedded:debug_line.obj [obj]
[GRAPHICS ]: [embedded:debug_line.obj] vertex count vertices=2 indices=3
[ENGINE ]: loading asset m_debug_sphere (Mesh) [embedded:debug_sphere.obj]
[ENGINE ]: loading mesh asset embedded:debug_sphere.obj [obj]
[GRAPHICS ]: [embedded:debug_sphere.obj] vertex count vertices=240 indices=336
[ENGINE ]: [DebugDrawSystem] registering to renderer...
[ENGINE ]: creating shader debug.vert => _shaders/spv/debug.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 1, .num_uniform_buffers = 1 }
[ENGINE ]: creating shader debug.frag => _shaders/spv/debug.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 }
[ENGINE ]: creating shader meshes.vert => _shaders/spv/meshes.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 1, .num_uniform_buffers = 1 }
[ENGINE ]: creating shader depthOnly.frag => _shaders/spv/depthOnly.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 }
[ENGINE ]: loading asset m_skybox (Mesh) [embedded:skybox_mesh.obj]
[ENGINE ]: loading mesh asset embedded:skybox_mesh.obj [obj]
[GRAPHICS ]: [embedded:skybox_mesh.obj] vertex count vertices=24 indices=36
[ENGINE ]: creating shader skybox.vert => _shaders/spv/skybox.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 1 }
[ENGINE ]: creating shader skybox.frag => _shaders/spv/skybox.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 1, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 1 }
[ENGINE ]: loading asset m_plane (Mesh) [embedded:plane.obj]
[ENGINE ]: loading mesh asset embedded:plane.obj [obj]
[GRAPHICS ]: [embedded:plane.obj] vertex count vertices=4 indices=6
[ENGINE ]: loading asset m_screenPlane (Mesh) [embedded:screenPlane.obj]
[ENGINE ]: loading mesh asset embedded:screenPlane.obj [obj]
[GRAPHICS ]: [embedded:screenPlane.obj] vertex count vertices=4 indices=6
[ENGINE ]: creating ssao pipeline
[ENGINE ]: creating shader postProc.vert => _shaders/spv/postProc.vert.spv gpu.GPUShaderStage.shaderstageVertex args: shaderTypes.ShaderLoadArgs{ .num_samplers = 0, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 0 }
[ENGINE ]: creating shader ssao.frag => _shaders/spv/ssao.frag.spv gpu.GPUShaderStage.shaderstageFragment args: shaderTypes.ShaderLoadArgs{ .num_samplers = 3, .num_storage_textures = 0, .num_storage_buffers = 0, .num_uniform_buffers = 1 }
[ENGINE ]: defining component_MeshComponent
[ENGINE ]: Component container created meshes.MeshComponent @1f698af4080
[ENGINE ]: creating lua metatable Mesh
[ENGINE ]: defining component_CameraComponent
[ENGINE ]: Component container created camera.CameraComponent @1f698ac1c00
[ENGINE ]: creating lua metatable Camera
[ENGINE ]: module started >>>> rend <<<<
[GRAPHICS ]: imgui startup
[ENGINE ]: module started >>>> imgui <<<<
[ENGINE ]: creating Game context
[ENGINE ]: calling gEngine.run
[ENGINE ]: engine loop started
[ENGINE ]: program ready
[ENGINE ]: uploading mesh => m_default_cube
[GRAPHICS ]: uploading 24 vertices and 36 indices
[ENGINE ]: install mesh by name 16
[ENGINE ]: uploading mesh => m_debug_box
[GRAPHICS ]: uploading 24 vertices and 36 indices
[ENGINE ]: install mesh by name 20
[ENGINE ]: uploading mesh => m_debug_line
[GRAPHICS ]: uploading 2 vertices and 3 indices
[ENGINE ]: install mesh by name 21
[ENGINE ]: uploading mesh => m_debug_sphere
[GRAPHICS ]: uploading 240 vertices and 336 indices
[ENGINE ]: install mesh by name 22
[ENGINE ]: uploading mesh => m_skybox
[GRAPHICS ]: uploading 24 vertices and 36 indices
[ENGINE ]: install mesh by name 30
[ENGINE ]: uploading mesh => m_plane
[GRAPHICS ]: uploading 4 vertices and 6 indices
[ENGINE ]: install mesh by name 37
[ENGINE ]: uploading mesh => m_screenPlane
[GRAPHICS ]: uploading 4 vertices and 6 indices
[ENGINE ]: install mesh by name 38
[ENGINE ]: Processing exit signals
[ENGINE ]: checking everything is ready to exit
[ENGINE ]: checking everything is ready to exit engineObject.InterfaceRef2(engineObject.EngineObjectVTable){ .ptr = anyopaque@1f698af1600, .vtable = engineObject.EngineObjectVTable{ .typeName = { 119, 105, 110, 100, 111, 119, 105, 110, 103, 46, 80, 108, 97, 116, 102, 111, 114, 109, 73, 110, 115, 116, 97, 110, 99, 101 }, .typeSize = 112, .typeAlign = 8, .singletonName = { 112, 108, 97, 116, 102, 111, 114, 109, 46, 73, 110, 115, 116, 97, 110, 99, 101 }, .init_func = fn (mem.Allocator) error{OutOfMemory,UnknownStatePanic,BadInit,UnknownError}!*anyopaque@7ff75e930a40, .tick_func = null, .engineDraw_func = null, .preTick_func = null, .deinit_func = fn (*anyopaque) void@7ff75e930ca0, .postInit_func = null, .processEvents = null, .exitSignal_func = fn (*anyopaque) error{OutOfMemory,UnknownStatePanic,BadInit,UnknownError}!void@7ff75e930b80, .readyToExit_func = fn (*anyopaque) bool@7ff75e930c00, .prepare_func = null, .fieldListHash = null, .fieldList = null, .slackSize = null } }
[ENGINE ]: exiting
[ENGINE ]: module shutting down >>>> imgui <<<<
[ENGINE ]: module shutting down >>>> rend <<<<
[ENGINE ]: undefining component meshes.MeshComponent
[ENGINE ]: undefining component camera.CameraComponent
[ENGINE ]: module shutting down >>>> platform <<<<
[ENGINE ]: module shutting down >>>> assets <<<<
[ENGINE ]: module shutting down >>>> core <<<<
[ENGINE ]: allocated size: 3065691 (2.924 MiB)
[ENGINE ]: peak allocated size size: 4989728 (4.759 MiB) (143 peak allocations)
[ENGINE ]: undefining component scene.Scene

View File

@ -11,7 +11,7 @@ pub fn init(allocator: std.mem.Allocator) !*@This() {
}
pub fn prepare(self: *@This()) !void {
try self.fuckNazis();
_ = self;
core.engine_log("program ready", .{});
}