renderer-mvp/asset-pipeline #53

Merged
kayomn merged 6 commits from renderer-mvp/asset-pipeline into main 2024-06-23 04:37:40 +02:00
4 changed files with 10 additions and 24 deletions
Showing only changes of commit bfa3efbb51 - Show all commits

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;
kayomn marked this conversation as resolved
Review

Unused addition.

Unused addition.
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,
kayomn marked this conversation as resolved Outdated

Bad idea to forcibly convert non-trivial downcasts like **opaque actually

Bad idea to forcibly convert non-trivial downcasts like `**opaque` actually
}));
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 {
kayomn marked this conversation as resolved Outdated

Wants to accept the desired storage source as an argument for loading resources from non-bundled locations like user storage or caller-defined storage implementations.

Wants to accept the desired storage source as an argument for loading resources from non-bundled locations like user storage or caller-defined storage implementations.
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();