diff --git a/src/Material.zig b/src/Material.zig new file mode 100644 index 0000000..f65275f --- /dev/null +++ b/src/Material.zig @@ -0,0 +1,12 @@ +const std = @import("std"); +const vk = @import("vulkan"); + +const Context = @import("Context.zig"); + +const Self = @This(); + +allocator: std.mem.Allocator, + +ctx: Context, + +pub fn new(allocator: std.mem.Allocator, ctx: Context) Self {} diff --git a/src/ResourceManager.zig b/src/ResourceManager.zig new file mode 100644 index 0000000..4aff513 --- /dev/null +++ b/src/ResourceManager.zig @@ -0,0 +1,54 @@ +const std = @import("std"); +const vk = @import("vulkan"); + +const Context = @import("Context.zig"); +const Mesh = @import("Mesh.zig"); +const Material = @import("Material.zig"); + +const Self = @This(); + +allocator: std.mem.Allocator, + +ctx: Context, + +sampler_descriptor_pool: vk.DescriptorPool, +sampler_descriptor_set_layout: vk.DescriptorSetLayout, + +mesh_cache: std.AutoArrayHashMap([]const u8, Mesh), +material_cache: std.AutoArrayHashMap([]const u8, Material), + +pub fn new(allocator: std.mem.Allocator, ctx: Context) Self { + var self: Self = undefined; + + self.allocator = allocator; + self.ctx = ctx; + + self.mesh_cache = std.AutoArrayHashMap([]const u8, Mesh).init(allocator); + self.material_cache = std.AutoArrayHashMap([]const u8, Material).init(allocator); + + return self; +} + +pub fn deinit(self: *Self) void { + // TODO Release resources properly + self.mesh_cache.deinit(); + self.material_cache.deinit(); +} + +pub fn getMesh(self: *Self, file_name: []const u8) !Mesh { + if (self.mesh_cache.get(file_name)) |mesh| { + return mesh; + } + + // TODO Create mesh + + return undefined; +} + +fn allocateDescriptorSet(self: *Self) !void { + // TODO +} + +fn createDescriptorSetLayout(self: *Self) !void { + // TODO +}