It works!

This commit is contained in:
2025-11-26 15:47:02 +01:00
parent 9f2d1e4608
commit b9a804ead6
8 changed files with 150 additions and 88 deletions

View File

@@ -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);