Complete all Vulkan wrappers. Maybe worth it.
This commit is contained in:
@@ -14,7 +14,6 @@ const vk = @import("vulkan");
|
||||
const Engine = @import("Engine.zig");
|
||||
const QueueType = @import("QueueType.zig").QueueType;
|
||||
const Transient = @import("Transient.zig").Transient;
|
||||
const WaitSemaphore = @import("WaitSemaphore.zig");
|
||||
|
||||
proxy: vk.CommandBufferProxy,
|
||||
allocator: std.mem.Allocator,
|
||||
@@ -46,8 +45,8 @@ pub fn deinit(self: *CommandBuffer, engine: *Engine) void {
|
||||
self.* = undefined;
|
||||
}
|
||||
|
||||
pub fn submit(self: CommandBuffer, engine: *Engine, submit_info: SubmitInfo) !void {
|
||||
try submitCommandBuffer(engine, self.queue_type, self.proxy.handle, submit_info);
|
||||
pub fn submit(self: CommandBuffer, engine: *Engine, submit_info: Engine.SubmitInfo) !void {
|
||||
try engine.queueSubmit(self.queue_type, self.proxy.handle, submit_info);
|
||||
}
|
||||
|
||||
// --- VULKAN WRAPPERS ---------------------------------------------------------
|
||||
@@ -76,12 +75,6 @@ pub const RenderPassBeginInfo = struct {
|
||||
clear_values: []const vk.ClearValue = &.{},
|
||||
};
|
||||
|
||||
pub const SubmitInfo = struct {
|
||||
wait_semaphores: []const WaitSemaphore = &.{},
|
||||
signal_semaphores: []const vk.Semaphore = &.{},
|
||||
fence: vk.Fence = .null_handle,
|
||||
};
|
||||
|
||||
pub const VertexBufferBinding = struct {
|
||||
buffer: vk.Buffer,
|
||||
offset: usize,
|
||||
@@ -227,42 +220,3 @@ pub fn setScissor(self: CommandBuffer, first_scissor: u32, scissors: []const vk.
|
||||
pub fn setViewport(self: CommandBuffer, first_viewport: u32, viewports: []const vk.Viewport) void {
|
||||
self.proxy.setViewport(first_viewport, @intCast(viewports.len), viewports.ptr);
|
||||
}
|
||||
|
||||
// --- HELPER FUNCTIONS --------------------------------------------------------
|
||||
|
||||
fn submitCommandBuffer(
|
||||
engine: *Engine,
|
||||
queue_type: QueueType,
|
||||
command_buffer: vk.CommandBuffer,
|
||||
submit_info: SubmitInfo,
|
||||
) !void {
|
||||
const queue = switch (queue_type) {
|
||||
.graphics => engine.graphics_queue.handle,
|
||||
.compute => engine.compute_queue.handle,
|
||||
.transfer => engine.transfer_queue.handle,
|
||||
};
|
||||
|
||||
const command_buffers = [_]vk.CommandBuffer{command_buffer};
|
||||
|
||||
var wait_semaphores = std.MultiArrayList(WaitSemaphore){};
|
||||
defer wait_semaphores.deinit(engine.vk_allocator.allocator);
|
||||
try wait_semaphores.ensureTotalCapacity(engine.vk_allocator.allocator, submit_info.wait_semaphores.len);
|
||||
|
||||
for (submit_info.wait_semaphores) |wait_semaphore| {
|
||||
wait_semaphores.appendAssumeCapacity(wait_semaphore);
|
||||
}
|
||||
|
||||
const submits = [_]vk.SubmitInfo{
|
||||
.{
|
||||
.wait_semaphore_count = @intCast(wait_semaphores.len),
|
||||
.p_wait_semaphores = wait_semaphores.items(.semaphore).ptr,
|
||||
.p_wait_dst_stage_mask = wait_semaphores.items(.stage_flags).ptr,
|
||||
.command_buffer_count = command_buffers.len,
|
||||
.p_command_buffers = &command_buffers,
|
||||
.signal_semaphore_count = @intCast(submit_info.signal_semaphores.len),
|
||||
.p_signal_semaphores = submit_info.signal_semaphores.ptr,
|
||||
},
|
||||
};
|
||||
|
||||
try engine.device.queueSubmit(queue, submits.len, &submits, submit_info.fence);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user