diff --git a/lib/p2/build.zig.zon b/lib/p2/build.zig.zon index 1f5e361..4a8bb12 100644 --- a/lib/p2/build.zig.zon +++ b/lib/p2/build.zig.zon @@ -1,8 +1,9 @@ .{ - .name = "p2", + .name = .p2, .version = "0.0.0", .dependencies = .{}, .paths = .{ "", }, + .fingerprint = 0xa6313a892725ee21, } diff --git a/lib/p2/src/structures/bump-arena.zig b/lib/p2/src/structures/bump-arena.zig index a5ecf4f..077a01b 100644 --- a/lib/p2/src/structures/bump-arena.zig +++ b/lib/p2/src/structures/bump-arena.zig @@ -19,6 +19,7 @@ pub const BumpArena = struct { .alloc = alloc, .free = free, .resize = resize, + .remap = std.mem.Allocator.noRemap, }; pub fn init(backing: std.mem.Allocator) !@This() { @@ -37,15 +38,15 @@ pub const BumpArena = struct { self.large.deinit(); } - fn respectAlignment(offset: usize, alignment: u8) usize { + fn respectAlignment(offset: usize, alignment: std.mem.Alignment) usize { if (offset == 0) { return 0; } - const a: usize = @intCast(@as(usize, @intCast(1)) << @as(u6, @truncate(alignment))); + const a: usize = @intCast(@as(usize, @intCast(1)) << @as(u6, @truncate(@intFromEnum(alignment)))); return ((offset / a) + 1) * @as(usize, @intCast(a)); } - pub fn alloc(ctx: *anyopaque, len: usize, ptr_align: u8, ret_addr: usize) ?[*]u8 { + pub fn alloc(ctx: *anyopaque, len: usize, ptr_align: std.mem.Alignment, ret_addr: usize) ?[*]u8 { const self: *@This() = @ptrCast(@alignCast(ctx)); self.mutex.lock(); @@ -77,7 +78,7 @@ pub const BumpArena = struct { return self.large.allocator(); } - pub fn free(ctx: *anyopaque, buf: []u8, buf_align: u8, ret_addr: usize) void { + pub fn free(ctx: *anyopaque, buf: []u8, buf_align: std.mem.Alignment, ret_addr: usize) void { // it's a bump allocator, it does nothing on free. _ = ctx; _ = buf; @@ -86,7 +87,7 @@ pub const BumpArena = struct { } // do not support resize in place. - pub fn resize(ctx: *anyopaque, buf: []u8, buf_align: u8, new_len: usize, ret_addr: usize) bool { + pub fn resize(ctx: *anyopaque, buf: []u8, buf_align: std.mem.Alignment, new_len: usize, ret_addr: usize) bool { _ = ctx; _ = buf; _ = buf_align; diff --git a/lib/p2/src/structures/interface.zig b/lib/p2/src/structures/interface.zig index dd0986c..bd0005e 100644 --- a/lib/p2/src/structures/interface.zig +++ b/lib/p2/src/structures/interface.zig @@ -37,7 +37,7 @@ test "simple" { } }; - inline for (@typeInfo(Wrap).Struct.decls) |d| { + inline for (@typeInfo(Wrap).@"struct".decls) |d| { if (!@hasDecl(T, d.name)) { @compileError(@typeName(T) ++ " is missing implementation of func " ++ d.name); } @@ -65,7 +65,7 @@ test "simple" { } }; - inline for (@typeInfo(Wrap).Struct.decls) |d| { + inline for (@typeInfo(Wrap).@"struct".decls) |d| { if (!@hasDecl(T, d.name)) { @compileError(@typeName(T) ++ " is missing implementation of func " ++ d.name); } diff --git a/lib/p2/src/structures/sparse-set.zig b/lib/p2/src/structures/sparse-set.zig index bf43579..9ecd5b6 100644 --- a/lib/p2/src/structures/sparse-set.zig +++ b/lib/p2/src/structures/sparse-set.zig @@ -227,7 +227,7 @@ pub fn SparseMultiSetAdvanced(comptime T: type, comptime SparseSize: u32) type { return true; } - var prng = std.rand.DefaultPrng.init(0x1234); + var prng = std.Random.DefaultPrng.init(0x1234); var rand = prng.random(); pub fn newRandomIndex() IndexType { @@ -402,7 +402,7 @@ pub fn SparseSetAdvanced(comptime T: type, comptime SparseSize: u32) type { } } - var prng = std.rand.DefaultPrng.init(0x1234); + var prng = std.Random.DefaultPrng.init(0x1234); var rand = prng.random(); fn newRandomIndex() IndexType { diff --git a/lib/p2/src/utils/shell.zig b/lib/p2/src/utils/shell.zig index 70bc950..00d3ddf 100644 --- a/lib/p2/src/utils/shell.zig +++ b/lib/p2/src/utils/shell.zig @@ -58,7 +58,7 @@ pub const ShellProcess = struct { } } else { if (terminalStack.items[terminalStack.items.len - 1] == c) { - try currentCmd.append(terminalStack.pop()); + try currentCmd.append(terminalStack.pop().?); } else { try currentCmd.append(c); } diff --git a/lib/sdl3/build.zig b/lib/sdl3/build.zig index d1918fb..4684ca1 100644 --- a/lib/sdl3/build.zig +++ b/lib/sdl3/build.zig @@ -33,4 +33,6 @@ pub fn build(b: *std.Build) void { const runArtifact = b.addRunArtifact(tests); test_step.dependOn(&runArtifact.step); + + b.installArtifact(tests); } diff --git a/lib/sdl3/src/generators/gpu.py b/lib/sdl3/src/generators/gpu.py index 8b1df8e..76ea0eb 100644 --- a/lib/sdl3/src/generators/gpu.py +++ b/lib/sdl3/src/generators/gpu.py @@ -6,6 +6,13 @@ import math import subprocess +# yeah I ain't gonna sugar coat it, +# parsing C files is really awful. +# goal with these files is to use em to generate usable APIs only for the stuff that's going to be widely exposed througout +# the engine. + +# which.. in this case... the only there is- is the gpu API. + def convertCase(x): s = '' underbar = False @@ -33,11 +40,17 @@ SDL_files = [ typeMap = { - 'Uint32': 'u32', 'float': 'f32', 'Sint32': 'i32', 'bool': 'bool', 'Uint8': 'u8', 'SDL_PropertiesID': 'PropertiesID','char': 'u8', + 'Uint32': 'u32', + 'float': 'f32', + 'Sint32': 'i32', + 'bool': 'bool', + 'Uint8': 'u8', + 'SDL_PropertiesID': 'PropertiesID', + 'char': 'u8', 'void': 'void', 'int': 'c_int', 'size_t': 'usize', - 'SDL_Window': 'Window', + 'SDL_Window': 'Window' } typeMap_r = {} diff --git a/lib/sdl3/src/samples/hello-triangle.zig b/lib/sdl3/src/samples/hello-triangle.zig index d75d999..6f2d6f6 100644 --- a/lib/sdl3/src/samples/hello-triangle.zig +++ b/lib/sdl3/src/samples/hello-triangle.zig @@ -43,6 +43,7 @@ pub fn startContext(self: *@This()) !void { return error.UnableToClaimGpu; const formats = self.device.getGPUShaderFormats(); + std.debug.print("SDL Context Loaded: {}\n", .{formats}); if (formats.shaderformatSpirv) { self.shaderpath = "./content/_cooked/spv"; // shaderformatSpirv @@ -121,10 +122,10 @@ pub fn loadShader( } pub fn loop(self: *@This()) !void { - const dt = @as(f64, @floatFromInt(self.timer.lap())) / 1000 / 1000 / 1000; std.debug.print("loop started\n", .{}); try self.startContext(); while (self.running) { + const dt = @as(f64, @floatFromInt(self.timer.lap())) / 1000 / 1000 / 1000; self.update(dt); } } @@ -140,7 +141,9 @@ fn update(self: *@This(), dt: f64) void { self.draw(dt); } + std.debug.print("frameTime: {d}ms ({d}fps)\n", .{ dt * 1000, 1 / dt }); } + pub fn draw(self: *@This(), dt: f64) void { _ = dt; const cmd = self.device.acquireGPUCommandBuffer();