From a5ff640aeb5127e38eb1ca74b070020d64d05d7f Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Wed, 6 May 2026 15:54:59 +0200 Subject: [PATCH] investigating memory issues --- src/soft/SoftDeviceMemory.zig | 4 ++++ src/soft/lib.zig | 1 + 2 files changed, 5 insertions(+) diff --git a/src/soft/SoftDeviceMemory.zig b/src/soft/SoftDeviceMemory.zig index a4d5ab2..9b36fbd 100644 --- a/src/soft/SoftDeviceMemory.zig +++ b/src/soft/SoftDeviceMemory.zig @@ -2,6 +2,7 @@ const std = @import("std"); const vk = @import("vulkan"); const SoftDevice = @import("SoftDevice.zig"); const base = @import("base"); +const lib = @import("lib.zig"); const VkError = base.VkError; @@ -12,6 +13,9 @@ interface: Interface, data: []u8, pub fn create(device: *SoftDevice, allocator: std.mem.Allocator, size: vk.DeviceSize, memory_type_index: u32) VkError!*Self { + if (size > lib.MAX_MEMORY_ALLOCATION_SIZE) + return VkError.OutOfDeviceMemory; + const self = allocator.create(Self) catch return VkError.OutOfHostMemory; errdefer allocator.destroy(self); diff --git a/src/soft/lib.zig b/src/soft/lib.zig index b512cfb..6609f3b 100644 --- a/src/soft/lib.zig +++ b/src/soft/lib.zig @@ -67,6 +67,7 @@ pub const MAX_IMAGE_LEVELS_CUBE = 15; pub const MAX_IMAGE_ARRAY_LAYERS = 2048; pub const PHYSICAL_DEVICE_HEAP_SIZE = 0x80000000; // 2 GiB +pub const MAX_MEMORY_ALLOCATION_SIZE = 0x80000000; // 2 GiB pub const MAX_ALLOCATION_COUNT = 4096; pub const std_options = base.std_options;