extract generic au.Flights
This commit is contained in:
33
src/main.zig
33
src/main.zig
@@ -50,13 +50,6 @@ const vertices = [_]Vertex{
|
||||
|
||||
const indices = [_]Index{ 4, 5, 6, 6, 5, 7 };
|
||||
|
||||
const Flight = struct {
|
||||
acquire: vk.Semaphore = .null_handle,
|
||||
complete: vk.Semaphore = .null_handle,
|
||||
fence: vk.Fence = .null_handle,
|
||||
pool: vk.CommandPool = .null_handle,
|
||||
frame: Frame,
|
||||
};
|
||||
|
||||
const Frame = struct {
|
||||
pub fn init() !Frame {
|
||||
@@ -181,27 +174,11 @@ pub fn main() !void {
|
||||
var sc = try au.SwapChain.init(alloc);
|
||||
defer sc.deinit();
|
||||
|
||||
const flights = try alloc.alloc(Flight, 3); // FRAMES IN FLIGHT
|
||||
defer alloc.free(flights);
|
||||
var flights = try au.Flights(Frame).init(alloc, 3); // FRAMES IN FLIGHT
|
||||
defer flights.deinit();
|
||||
|
||||
for (flights) |*flight| {
|
||||
flight.acquire = try au.D.createSemaphore(&.{}, null);
|
||||
flight.complete = try au.D.createSemaphore(&.{}, null);
|
||||
flight.fence = try au.D.createFence(&.{ .flags = .{ .signaled_bit = true } }, null);
|
||||
flight.pool = try au.D.createCommandPool(&.{ .queue_family_index = au.device_config.family }, null);
|
||||
flight.frame = try Frame.init();
|
||||
}
|
||||
defer for (flights) |flight| {
|
||||
au.D.destroySemaphore(flight.acquire, null);
|
||||
au.D.destroySemaphore(flight.complete, null);
|
||||
au.D.destroyFence(flight.fence, null);
|
||||
au.D.destroyCommandPool(flight.pool, null);
|
||||
flight.frame.deinit();
|
||||
};
|
||||
|
||||
var flight_idx: usize = 0;
|
||||
while (!au.W.should_close()) : (flight_idx = (flight_idx + 1) % flights.len) {
|
||||
const flight = flights[flight_idx];
|
||||
while (!au.W.should_close()) {
|
||||
const flight = flights.next();
|
||||
|
||||
const events = if (au.W.focused())
|
||||
au.wait_events_timeout(0.1)
|
||||
@@ -243,7 +220,7 @@ pub fn main() !void {
|
||||
|
||||
try render_cmd.beginCommandBuffer(&.{ .flags = .{ .one_time_submit_bit = true } });
|
||||
|
||||
try flight.frame.record_render(
|
||||
try flight.ctx.record_render(
|
||||
render_cmd,
|
||||
image,
|
||||
view,
|
||||
|
Reference in New Issue
Block a user