It works!
This commit is contained in:
@@ -104,6 +104,9 @@ graphics_command_pool: vk.CommandPool,
|
||||
compute_command_pool: vk.CommandPool,
|
||||
transfer_command_pool: vk.CommandPool,
|
||||
|
||||
prng_ptr: *std.Random.Pcg,
|
||||
random: std.Random,
|
||||
|
||||
const debug = @import("builtin").mode == .Debug;
|
||||
|
||||
const vk_application_info: vk.ApplicationInfo = .{
|
||||
@@ -164,7 +167,7 @@ pub fn init(allocator: std.mem.Allocator, maybe_window: ?*glfw.Window) !Engine {
|
||||
|
||||
break :blk try base.createInstance(&.{
|
||||
.p_application_info = &vk_application_info,
|
||||
.enabled_layer_count = enabled_layers.len,
|
||||
.enabled_layer_count = 0, //enabled_layers.len,
|
||||
.pp_enabled_layer_names = enabled_layers.ptr,
|
||||
.enabled_extension_count = @intCast(enabled_extensions.items.len),
|
||||
.pp_enabled_extension_names = enabled_extensions.items.ptr,
|
||||
@@ -345,6 +348,15 @@ pub fn init(allocator: std.mem.Allocator, maybe_window: ?*glfw.Window) !Engine {
|
||||
const transfer_queue: Queue = .initAllocation(device, queue_allocations.transfer_queue);
|
||||
const presentation_queue: Queue = if (maybe_window != null) .initAllocation(device, queue_allocations.presentation_queue) else undefined;
|
||||
|
||||
// --- CREATE AND SEED RNG -------------------------------------------------
|
||||
|
||||
const prng_ptr = try allocator.create(std.Random.Pcg);
|
||||
errdefer allocator.destroy(prng_ptr);
|
||||
|
||||
const timestamp: u128 = @bitCast(std.time.nanoTimestamp());
|
||||
prng_ptr.* = .init(@truncate(timestamp));
|
||||
const random = prng_ptr.random();
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
return .{
|
||||
@@ -371,12 +383,17 @@ pub fn init(allocator: std.mem.Allocator, maybe_window: ?*glfw.Window) !Engine {
|
||||
.graphics_command_pool = graphics_command_pool,
|
||||
.compute_command_pool = compute_command_pool,
|
||||
.transfer_command_pool = transfer_command_pool,
|
||||
|
||||
.prng_ptr = prng_ptr,
|
||||
.random = random,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Engine) void {
|
||||
const allocator = self.vk_allocator.allocator;
|
||||
|
||||
allocator.destroy(self.prng_ptr);
|
||||
|
||||
self.device.destroyCommandPool(self.graphics_command_pool, &self.vk_allocator.interface);
|
||||
self.device.destroyCommandPool(self.compute_command_pool, &self.vk_allocator.interface);
|
||||
self.device.destroyCommandPool(self.transfer_command_pool, &self.vk_allocator.interface);
|
||||
|
||||
@@ -195,16 +195,12 @@ pub fn recreate(self: *Swapchain, engine: *Engine) !void {
|
||||
self.swapchain_images = new_swapchain_images;
|
||||
self.image_index = res.image_index;
|
||||
self.semaphore_image_acquired = semaphore_image_acquired;
|
||||
|
||||
std.log.debug("Swapchain recreated.", .{});
|
||||
}
|
||||
|
||||
pub fn present(self: *Swapchain, engine: *Engine, command_buffer: vk.CommandBuffer) !PresentResult {
|
||||
const device = engine.device;
|
||||
const mode = &engine.mode.surface;
|
||||
|
||||
std.log.debug("Presenting command buffer {X}.", .{@intFromEnum(command_buffer)});
|
||||
|
||||
// --- WAIT FOR CURRENT FRAME TO FINISH ------------------------------------
|
||||
|
||||
const current_swapchain_image = &self.swapchain_images[self.image_index];
|
||||
|
||||
Reference in New Issue
Block a user