adding base Buffer, refactoring of unnecessary device layer functions
This commit is contained in:
@@ -9,6 +9,7 @@ const VkError = @import("error_set.zig").VkError;
|
||||
const PhysicalDevice = @import("PhysicalDevice.zig");
|
||||
const Queue = @import("Queue.zig");
|
||||
|
||||
const Buffer = @import("Buffer.zig");
|
||||
const CommandBuffer = @import("CommandBuffer.zig");
|
||||
const CommandPool = @import("CommandPool.zig");
|
||||
const DeviceMemory = @import("DeviceMemory.zig");
|
||||
@@ -30,18 +31,11 @@ pub const VTable = struct {
|
||||
};
|
||||
|
||||
pub const DispatchTable = struct {
|
||||
allocateCommandBuffers: *const fn (*Self, *const vk.CommandBufferAllocateInfo) VkError![]*Dispatchable(CommandBuffer),
|
||||
allocateMemory: *const fn (*Self, std.mem.Allocator, *const vk.MemoryAllocateInfo) VkError!*DeviceMemory,
|
||||
createBuffer: *const fn (*Self, std.mem.Allocator, *const vk.BufferCreateInfo) VkError!*Buffer,
|
||||
createCommandPool: *const fn (*Self, std.mem.Allocator, *const vk.CommandPoolCreateInfo) VkError!*CommandPool,
|
||||
createFence: *const fn (*Self, std.mem.Allocator, *const vk.FenceCreateInfo) VkError!*Fence,
|
||||
destroy: *const fn (*Self, std.mem.Allocator) VkError!void,
|
||||
destroyCommandPool: *const fn (*Self, std.mem.Allocator, *CommandPool) VkError!void,
|
||||
destroyFence: *const fn (*Self, std.mem.Allocator, *Fence) VkError!void,
|
||||
freeCommandBuffers: *const fn (*Self, *CommandPool, []*Dispatchable(CommandBuffer)) VkError!void,
|
||||
freeMemory: *const fn (*Self, std.mem.Allocator, *DeviceMemory) VkError!void,
|
||||
getFenceStatus: *const fn (*Self, *Fence) VkError!void,
|
||||
resetFences: *const fn (*Self, []*Fence) VkError!void,
|
||||
waitForFences: *const fn (*Self, []*Fence, bool, u64) VkError!void,
|
||||
};
|
||||
|
||||
pub fn init(allocator: std.mem.Allocator, physical_device: *const PhysicalDevice, info: *const vk.DeviceCreateInfo) VkError!Self {
|
||||
@@ -90,60 +84,18 @@ pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) VkError!void {
|
||||
try self.dispatch_table.destroy(self, allocator);
|
||||
}
|
||||
|
||||
// Fence functions ===================================================================================================================================
|
||||
pub inline fn createBuffer(self: *Self, allocator: std.mem.Allocator, info: *const vk.BufferCreateInfo) VkError!*Buffer {
|
||||
return self.dispatch_table.createBuffer(self, allocator, info);
|
||||
}
|
||||
|
||||
pub inline fn createFence(self: *Self, allocator: std.mem.Allocator, info: *const vk.FenceCreateInfo) VkError!*Fence {
|
||||
return self.dispatch_table.createFence(self, allocator, info);
|
||||
}
|
||||
|
||||
pub inline fn destroyFence(self: *Self, allocator: std.mem.Allocator, fence: *Fence) VkError!void {
|
||||
try self.dispatch_table.destroyFence(self, allocator, fence);
|
||||
}
|
||||
|
||||
pub inline fn getFenceStatus(self: *Self, fence: *Fence) VkError!void {
|
||||
try self.dispatch_table.getFenceStatus(self, fence);
|
||||
}
|
||||
|
||||
pub inline fn resetFences(self: *Self, fences: []*Fence) VkError!void {
|
||||
try self.dispatch_table.resetFences(self, fences);
|
||||
}
|
||||
|
||||
pub inline fn waitForFences(self: *Self, fences: []*Fence, waitForAll: bool, timeout: u64) VkError!void {
|
||||
try self.dispatch_table.waitForFences(self, fences, waitForAll, timeout);
|
||||
}
|
||||
|
||||
// Command Pool functions ============================================================================================================================
|
||||
|
||||
pub inline fn allocateCommandBuffers(self: *Self, info: *const vk.CommandBufferAllocateInfo) VkError![]*Dispatchable(CommandBuffer) {
|
||||
return self.dispatch_table.allocateCommandBuffers(self, info);
|
||||
}
|
||||
|
||||
pub inline fn createCommandPool(self: *Self, allocator: std.mem.Allocator, info: *const vk.CommandPoolCreateInfo) VkError!*CommandPool {
|
||||
return self.dispatch_table.createCommandPool(self, allocator, info);
|
||||
}
|
||||
|
||||
pub inline fn destroyCommandPool(self: *Self, allocator: std.mem.Allocator, pool: *CommandPool) VkError!void {
|
||||
try self.dispatch_table.destroyCommandPool(self, allocator, pool);
|
||||
}
|
||||
|
||||
pub inline fn freeCommandBuffers(self: *Self, pool: *CommandPool, cmds: []*Dispatchable(CommandBuffer)) VkError!void {
|
||||
try self.dispatch_table.freeCommandBuffers(self, pool, cmds);
|
||||
}
|
||||
|
||||
// Memory functions ==================================================================================================================================
|
||||
|
||||
pub inline fn allocateMemory(self: *Self, allocator: std.mem.Allocator, info: *const vk.MemoryAllocateInfo) VkError!*DeviceMemory {
|
||||
return self.dispatch_table.allocateMemory(self, allocator, info);
|
||||
}
|
||||
|
||||
pub inline fn freeMemory(self: *Self, allocator: std.mem.Allocator, device_memory: *DeviceMemory) VkError!void {
|
||||
try self.dispatch_table.freeMemory(self, allocator, device_memory);
|
||||
}
|
||||
|
||||
pub inline fn mapMemory(_: *Self, device_memory: *DeviceMemory, offset: vk.DeviceSize, size: vk.DeviceSize) VkError!?*anyopaque {
|
||||
return device_memory.map(offset, size);
|
||||
}
|
||||
|
||||
pub inline fn unmapMemory(_: *Self, device_memory: *DeviceMemory) void {
|
||||
return device_memory.unmap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user