WIP: Resource manager
This commit is contained in:
parent
0134da7d95
commit
34135fa83e
2 changed files with 66 additions and 0 deletions
12
src/Material.zig
Normal file
12
src/Material.zig
Normal file
|
@ -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 {}
|
54
src/ResourceManager.zig
Normal file
54
src/ResourceManager.zig
Normal file
|
@ -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
|
||||
}
|
Loading…
Reference in a new issue