adding public queue functions and worker base
This commit is contained in:
@@ -19,7 +19,7 @@ dispatch_table: *const DispatchTable,
|
||||
vtable: *const VTable,
|
||||
|
||||
pub const VTable = struct {
|
||||
createQueue: *const fn (std.mem.Allocator, *const Self, u32, u32, vk.DeviceQueueCreateFlags) VkError!*Queue,
|
||||
createQueue: *const fn (std.mem.Allocator, *Self, u32, u32, vk.DeviceQueueCreateFlags) VkError!*Queue,
|
||||
destroyQueue: *const fn (*Queue, std.mem.Allocator) VkError!void,
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ const Fence = @import("Fence.zig");
|
||||
const Self = @This();
|
||||
pub const ObjectType: vk.ObjectType = .queue;
|
||||
|
||||
owner: *const Device,
|
||||
owner: *Device,
|
||||
family_index: u32,
|
||||
index: u32,
|
||||
flags: vk.DeviceQueueCreateFlags,
|
||||
@@ -16,12 +16,12 @@ flags: vk.DeviceQueueCreateFlags,
|
||||
dispatch_table: *const DispatchTable,
|
||||
|
||||
pub const DispatchTable = struct {
|
||||
bindSparse: *const fn (*Self, []*const vk.BindSparseInfo, ?*Fence) VkError!void,
|
||||
submit: *const fn (*Self, []*const vk.SubmitInfo, ?*Fence) VkError!void,
|
||||
bindSparse: *const fn (*Self, []const vk.BindSparseInfo, ?*Fence) VkError!void,
|
||||
submit: *const fn (*Self, []const vk.SubmitInfo, ?*Fence) VkError!void,
|
||||
waitIdle: *const fn (*Self) VkError!void,
|
||||
};
|
||||
|
||||
pub fn init(allocator: std.mem.Allocator, device: *const Device, index: u32, family_index: u32, flags: vk.DeviceQueueCreateFlags) VkError!Self {
|
||||
pub fn init(allocator: std.mem.Allocator, device: *Device, index: u32, family_index: u32, flags: vk.DeviceQueueCreateFlags) VkError!Self {
|
||||
std.log.scoped(.vkCreateDevice).info("Creating device queue with family index {d} and index {d}", .{ family_index, index });
|
||||
_ = allocator;
|
||||
return .{
|
||||
@@ -33,11 +33,11 @@ pub fn init(allocator: std.mem.Allocator, device: *const Device, index: u32, fam
|
||||
};
|
||||
}
|
||||
|
||||
pub inline fn bindSparse(self: *Self, info: []*const vk.BindSparseInfo, fence: ?*Fence) VkError!void {
|
||||
pub inline fn bindSparse(self: *Self, info: []const vk.BindSparseInfo, fence: ?*Fence) VkError!void {
|
||||
try self.dispatch_table.bindSparse(self, info, fence);
|
||||
}
|
||||
|
||||
pub inline fn submit(self: *Self, info: []*const vk.SubmitInfo, fence: ?*Fence) VkError!void {
|
||||
pub inline fn submit(self: *Self, info: []const vk.SubmitInfo, fence: ?*Fence) VkError!void {
|
||||
try self.dispatch_table.submit(self, info, fence);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,11 @@ const VulkanAllocator = @import("VulkanAllocator.zig");
|
||||
|
||||
const Instance = @import("Instance.zig");
|
||||
const Device = @import("Device.zig");
|
||||
const PhysicalDevice = @import("PhysicalDevice.zig");
|
||||
const Queue = @import("Queue.zig");
|
||||
|
||||
const DeviceMemory = @import("DeviceMemory.zig");
|
||||
const Fence = @import("Fence.zig");
|
||||
const PhysicalDevice = @import("PhysicalDevice.zig");
|
||||
|
||||
// This file contains all exported Vulkan entrypoints.
|
||||
|
||||
@@ -80,6 +82,9 @@ const device_pfn_map = std.StaticStringMap(vk.PfnVoidFunction).initComptime(.{
|
||||
functionMapEntryPoint("vkMapMemory"),
|
||||
functionMapEntryPoint("vkUnmapMemory"),
|
||||
functionMapEntryPoint("vkResetFences"),
|
||||
functionMapEntryPoint("vkQueueBindSparse"),
|
||||
functionMapEntryPoint("vkQueueSubmit"),
|
||||
functionMapEntryPoint("vkQueueWaitIdle"),
|
||||
functionMapEntryPoint("vkWaitForFences"),
|
||||
});
|
||||
|
||||
@@ -389,6 +394,26 @@ pub export fn strollResetFences(p_device: vk.Device, count: u32, p_fences: [*]co
|
||||
return .success;
|
||||
}
|
||||
|
||||
pub export fn strollQueueBindSparse(p_queue: vk.Queue, count: u32, info: [*]vk.BindSparseInfo, p_fence: vk.Fence) callconv(vk.vulkan_call_conv) vk.Result {
|
||||
const queue = Dispatchable(Queue).fromHandleObject(p_queue) catch |err| return toVkResult(err);
|
||||
const fence = if (p_fence != .null_handle) NonDispatchable(Fence).fromHandleObject(p_fence) catch |err| return toVkResult(err) else null;
|
||||
queue.bindSparse(info[0..count], fence) catch |err| return toVkResult(err);
|
||||
return .success;
|
||||
}
|
||||
|
||||
pub export fn strollQueueSubmit(p_queue: vk.Queue, count: u32, info: [*]const vk.SubmitInfo, p_fence: vk.Fence) callconv(vk.vulkan_call_conv) vk.Result {
|
||||
const queue = Dispatchable(Queue).fromHandleObject(p_queue) catch |err| return toVkResult(err);
|
||||
const fence = if (p_fence != .null_handle) NonDispatchable(Fence).fromHandleObject(p_fence) catch |err| return toVkResult(err) else null;
|
||||
queue.submit(info[0..count], fence) catch |err| return toVkResult(err);
|
||||
return .success;
|
||||
}
|
||||
|
||||
pub export fn strollQueueWaitIdle(p_queue: vk.Queue) callconv(vk.vulkan_call_conv) vk.Result {
|
||||
const queue = Dispatchable(Queue).fromHandleObject(p_queue) catch |err| return toVkResult(err);
|
||||
queue.waitIdle() catch |err| return toVkResult(err);
|
||||
return .success;
|
||||
}
|
||||
|
||||
pub export fn strollWaitForFences(p_device: vk.Device, count: u32, p_fences: [*]const vk.Fence, waitForAll: vk.Bool32, timeout: u64) callconv(vk.vulkan_call_conv) vk.Result {
|
||||
const device = Dispatchable(Device).fromHandleObject(p_device) catch |err| return toVkResult(err);
|
||||
const allocator = std.heap.c_allocator;
|
||||
|
||||
Reference in New Issue
Block a user