reuse command buffers
This commit is contained in:
27
src/main.zig
27
src/main.zig
@@ -270,28 +270,20 @@ pub fn main() !void {
|
||||
const image = sc.getImage(acq.image_index);
|
||||
const view = sc.getView(acq.image_index);
|
||||
|
||||
var render_cmd = au.CommandBufferProxy.init(.null_handle, au.D.wrapper);
|
||||
try au.D.allocateCommandBuffers(
|
||||
&.{
|
||||
.command_pool = flight.pool,
|
||||
.level = .primary,
|
||||
.command_buffer_count = 1,
|
||||
},
|
||||
@ptrCast(&render_cmd.handle),
|
||||
);
|
||||
var cmd = au.CommandBufferProxy.init(flight.cmd, au.D.wrapper);
|
||||
|
||||
try render_cmd.beginCommandBuffer(&.{ .flags = .{ .one_time_submit_bit = true } });
|
||||
try cmd.beginCommandBuffer(&.{ .flags = .{ .one_time_submit_bit = true } });
|
||||
|
||||
try flight.ctx.record_render(
|
||||
render_cmd,
|
||||
cmd,
|
||||
image,
|
||||
view,
|
||||
vk.Rect2D{ .offset = .{ .x = 0, .y = 0 }, .extent = sc.cinfo.image_extent },
|
||||
);
|
||||
|
||||
try render_cmd.endCommandBuffer();
|
||||
try cmd.endCommandBuffer();
|
||||
|
||||
try au.Q.submit(
|
||||
au.Q.submit(
|
||||
1,
|
||||
&.{
|
||||
vk.SubmitInfo{
|
||||
@@ -299,13 +291,18 @@ pub fn main() !void {
|
||||
.p_wait_semaphores = @ptrCast(&flight.acquire),
|
||||
.p_wait_dst_stage_mask = @ptrCast(&vk.PipelineStageFlags{ .color_attachment_output_bit = true }),
|
||||
.command_buffer_count = 1,
|
||||
.p_command_buffers = @ptrCast(&render_cmd.handle),
|
||||
.p_command_buffers = @ptrCast(&cmd.handle),
|
||||
.signal_semaphore_count = 1,
|
||||
.p_signal_semaphores = @ptrCast(&flight.complete),
|
||||
},
|
||||
},
|
||||
flight.fence,
|
||||
);
|
||||
) catch {
|
||||
std.debug.print("Failed to submit.\nWaiting for idle...", .{});
|
||||
au.D.deviceWaitIdle() catch
|
||||
std.debug.print("deviceWaitIdle failed\n", .{});
|
||||
@panic("Submission failed");
|
||||
};
|
||||
|
||||
_ = try au.Q.presentKHR(&vk.PresentInfoKHR{
|
||||
.wait_semaphore_count = 1,
|
||||
|
Reference in New Issue
Block a user