updating p2 to 0.14
This commit is contained in:
parent
3b65cdb8f5
commit
b500809d6f
|
|
@ -1,8 +1,9 @@
|
||||||
.{
|
.{
|
||||||
.name = "p2",
|
.name = .p2,
|
||||||
.version = "0.0.0",
|
.version = "0.0.0",
|
||||||
.dependencies = .{},
|
.dependencies = .{},
|
||||||
.paths = .{
|
.paths = .{
|
||||||
"",
|
"",
|
||||||
},
|
},
|
||||||
|
.fingerprint = 0xa6313a892725ee21,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ pub const BumpArena = struct {
|
||||||
.alloc = alloc,
|
.alloc = alloc,
|
||||||
.free = free,
|
.free = free,
|
||||||
.resize = resize,
|
.resize = resize,
|
||||||
|
.remap = std.mem.Allocator.noRemap,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn init(backing: std.mem.Allocator) !@This() {
|
pub fn init(backing: std.mem.Allocator) !@This() {
|
||||||
|
|
@ -37,15 +38,15 @@ pub const BumpArena = struct {
|
||||||
self.large.deinit();
|
self.large.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn respectAlignment(offset: usize, alignment: u8) usize {
|
fn respectAlignment(offset: usize, alignment: std.mem.Alignment) usize {
|
||||||
if (offset == 0) {
|
if (offset == 0) {
|
||||||
return 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));
|
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));
|
const self: *@This() = @ptrCast(@alignCast(ctx));
|
||||||
|
|
||||||
self.mutex.lock();
|
self.mutex.lock();
|
||||||
|
|
@ -77,7 +78,7 @@ pub const BumpArena = struct {
|
||||||
return self.large.allocator();
|
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.
|
// it's a bump allocator, it does nothing on free.
|
||||||
_ = ctx;
|
_ = ctx;
|
||||||
_ = buf;
|
_ = buf;
|
||||||
|
|
@ -86,7 +87,7 @@ pub const BumpArena = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not support resize in place.
|
// 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;
|
_ = ctx;
|
||||||
_ = buf;
|
_ = buf;
|
||||||
_ = buf_align;
|
_ = buf_align;
|
||||||
|
|
|
||||||
|
|
@ -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)) {
|
if (!@hasDecl(T, d.name)) {
|
||||||
@compileError(@typeName(T) ++ " is missing implementation of func " ++ 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)) {
|
if (!@hasDecl(T, d.name)) {
|
||||||
@compileError(@typeName(T) ++ " is missing implementation of func " ++ d.name);
|
@compileError(@typeName(T) ++ " is missing implementation of func " ++ d.name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ pub fn SparseMultiSetAdvanced(comptime T: type, comptime SparseSize: u32) type {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var prng = std.rand.DefaultPrng.init(0x1234);
|
var prng = std.Random.DefaultPrng.init(0x1234);
|
||||||
var rand = prng.random();
|
var rand = prng.random();
|
||||||
|
|
||||||
pub fn newRandomIndex() IndexType {
|
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();
|
var rand = prng.random();
|
||||||
|
|
||||||
fn newRandomIndex() IndexType {
|
fn newRandomIndex() IndexType {
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ pub const ShellProcess = struct {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (terminalStack.items[terminalStack.items.len - 1] == c) {
|
if (terminalStack.items[terminalStack.items.len - 1] == c) {
|
||||||
try currentCmd.append(terminalStack.pop());
|
try currentCmd.append(terminalStack.pop().?);
|
||||||
} else {
|
} else {
|
||||||
try currentCmd.append(c);
|
try currentCmd.append(c);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,4 +33,6 @@ pub fn build(b: *std.Build) void {
|
||||||
|
|
||||||
const runArtifact = b.addRunArtifact(tests);
|
const runArtifact = b.addRunArtifact(tests);
|
||||||
test_step.dependOn(&runArtifact.step);
|
test_step.dependOn(&runArtifact.step);
|
||||||
|
|
||||||
|
b.installArtifact(tests);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,13 @@ import math
|
||||||
|
|
||||||
import subprocess
|
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):
|
def convertCase(x):
|
||||||
s = ''
|
s = ''
|
||||||
underbar = False
|
underbar = False
|
||||||
|
|
@ -33,11 +40,17 @@ SDL_files = [
|
||||||
|
|
||||||
|
|
||||||
typeMap = {
|
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',
|
'void': 'void',
|
||||||
'int': 'c_int',
|
'int': 'c_int',
|
||||||
'size_t': 'usize',
|
'size_t': 'usize',
|
||||||
'SDL_Window': 'Window',
|
'SDL_Window': 'Window'
|
||||||
}
|
}
|
||||||
|
|
||||||
typeMap_r = {}
|
typeMap_r = {}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ pub fn startContext(self: *@This()) !void {
|
||||||
return error.UnableToClaimGpu;
|
return error.UnableToClaimGpu;
|
||||||
|
|
||||||
const formats = self.device.getGPUShaderFormats();
|
const formats = self.device.getGPUShaderFormats();
|
||||||
|
|
||||||
std.debug.print("SDL Context Loaded: {}\n", .{formats});
|
std.debug.print("SDL Context Loaded: {}\n", .{formats});
|
||||||
if (formats.shaderformatSpirv) {
|
if (formats.shaderformatSpirv) {
|
||||||
self.shaderpath = "./content/_cooked/spv"; // shaderformatSpirv
|
self.shaderpath = "./content/_cooked/spv"; // shaderformatSpirv
|
||||||
|
|
@ -121,10 +122,10 @@ pub fn loadShader(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn loop(self: *@This()) !void {
|
pub fn loop(self: *@This()) !void {
|
||||||
const dt = @as(f64, @floatFromInt(self.timer.lap())) / 1000 / 1000 / 1000;
|
|
||||||
std.debug.print("loop started\n", .{});
|
std.debug.print("loop started\n", .{});
|
||||||
try self.startContext();
|
try self.startContext();
|
||||||
while (self.running) {
|
while (self.running) {
|
||||||
|
const dt = @as(f64, @floatFromInt(self.timer.lap())) / 1000 / 1000 / 1000;
|
||||||
self.update(dt);
|
self.update(dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +141,9 @@ fn update(self: *@This(), dt: f64) void {
|
||||||
|
|
||||||
self.draw(dt);
|
self.draw(dt);
|
||||||
}
|
}
|
||||||
|
std.debug.print("frameTime: {d}ms ({d}fps)\n", .{ dt * 1000, 1 / dt });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw(self: *@This(), dt: f64) void {
|
pub fn draw(self: *@This(), dt: f64) void {
|
||||||
_ = dt;
|
_ = dt;
|
||||||
const cmd = self.device.acquireGPUCommandBuffer();
|
const cmd = self.device.acquireGPUCommandBuffer();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue