PR tidy up
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kayomn 2024-06-23 03:31:51 +01:00
parent 9cfabae931
commit bfa3efbb51
4 changed files with 10 additions and 24 deletions

View File

@ -6,24 +6,6 @@ const slices = @import("./slices.zig");
const std = @import("std");
pub const Writable = struct {
data: []Byte,
pub fn writer(self: *Writable) Writer {
return Writer.bind(Writable, self, write);
}
fn write(self: *Writable, buffer: []const u8) !usize {
const range = @min(buffer.len, self.data.len);
@memcpy(self.data[0 .. range], buffer[0 .. range]);
self.data = self.data[range ..];
return buffer.len;
}
};
pub const Byte = u8;
pub const Error = error {

View File

@ -53,7 +53,7 @@ pub const Table = struct {
errdefer resource_allocator.destroy(allocated_resource);
std.debug.assert(try self.table.emplace(value_id, .{
.ptr = @ptrCast(allocated_resource),
.ptr = allocated_resource,
}));
allocated_resource.* = value;

View File

@ -19,14 +19,14 @@ pub const Assets = struct {
pub const Format = struct {
extension: []const u8,
file_desc: *const fn (*std.heap.ArenaAllocator, []const u8) Error!Desc,
file_desc: *const fn (*std.heap.ArenaAllocator, coral.files.Storage, []const u8) Error!Desc,
pub const Error = std.mem.Allocator.Error || coral.files.Error || error {
FormatUnsupported,
};
};
pub fn open_file(self: *Assets, path: []const u8) (std.mem.Allocator.Error || Format.Error)!Handle {
pub fn open_file(self: *Assets, storage: coral.files.Storage, path: []const u8) (OpenError || Format.Error)!Handle {
defer {
const max_cache_size = 536870912;
@ -40,13 +40,13 @@ pub const Assets = struct {
continue;
}
return self.context.open(try format.file_desc(&self.staging_arena, path));
return self.context.open(try format.file_desc(&self.staging_arena, storage, path));
}
return .none;
}
pub fn open_quad_mesh_2d(self: *Assets, extents: Point2D) std.mem.Allocator.Error!Handle {
pub fn open_quad_mesh_2d(self: *Assets, extents: Point2D) OpenError!Handle {
const width, const height = extents / @as(Point2D, @splat(2));
return self.context.open(.{
@ -137,6 +137,10 @@ pub const Input = union (enum) {
};
};
pub const OpenError = std.mem.Allocator.Error || error {
};
pub const Point2D = @Vector(2, f32);
pub const Queue = struct {

View File

@ -80,7 +80,7 @@ pub const Context = struct {
};
}
pub fn open(self: *Context, desc: gfx.Desc) std.mem.Allocator.Error!gfx.Handle {
pub fn open(self: *Context, desc: gfx.Desc) gfx.OpenError!gfx.Handle {
const open_commands = self.loop.opens.pending();
const index = self.loop.closed_indices.get() orelse open_commands.stack.len();