PR tidy up
This commit is contained in:
parent
9cfabae931
commit
bfa3efbb51
|
@ -6,24 +6,6 @@ const slices = @import("./slices.zig");
|
||||||
|
|
||||||
const std = @import("std");
|
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 Byte = u8;
|
||||||
|
|
||||||
pub const Error = error {
|
pub const Error = error {
|
||||||
|
|
|
@ -53,7 +53,7 @@ pub const Table = struct {
|
||||||
errdefer resource_allocator.destroy(allocated_resource);
|
errdefer resource_allocator.destroy(allocated_resource);
|
||||||
|
|
||||||
std.debug.assert(try self.table.emplace(value_id, .{
|
std.debug.assert(try self.table.emplace(value_id, .{
|
||||||
.ptr = @ptrCast(allocated_resource),
|
.ptr = allocated_resource,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
allocated_resource.* = value;
|
allocated_resource.* = value;
|
||||||
|
|
|
@ -19,14 +19,14 @@ pub const Assets = struct {
|
||||||
|
|
||||||
pub const Format = struct {
|
pub const Format = struct {
|
||||||
extension: []const u8,
|
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 {
|
pub const Error = std.mem.Allocator.Error || coral.files.Error || error {
|
||||||
FormatUnsupported,
|
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 {
|
defer {
|
||||||
const max_cache_size = 536870912;
|
const max_cache_size = 536870912;
|
||||||
|
|
||||||
|
@ -40,13 +40,13 @@ pub const Assets = struct {
|
||||||
continue;
|
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;
|
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));
|
const width, const height = extents / @as(Point2D, @splat(2));
|
||||||
|
|
||||||
return self.context.open(.{
|
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 Point2D = @Vector(2, f32);
|
||||||
|
|
||||||
pub const Queue = struct {
|
pub const Queue = struct {
|
||||||
|
|
|
@ -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 open_commands = self.loop.opens.pending();
|
||||||
const index = self.loop.closed_indices.get() orelse open_commands.stack.len();
|
const index = self.loop.closed_indices.get() orelse open_commands.stack.len();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue