Skip to content

Commit 173ed0c

Browse files
authored
sysgpu: prevent smaller memory types from selected (#1445)
Only taking a look at the bitflags for linear_map_readable caused memory indexes with a smaller heap space to be selected. Signed-off-by: Shail Patel <shailpatel67@gmail.com>
1 parent 41e0762 commit 173ed0c

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/sysgpu/vulkan.zig

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3558,7 +3558,19 @@ const MemoryAllocator = struct {
35583558
const heap_size = mem_heaps[mem_type.heap_index].size;
35593559
const candidate = switch (mem_kind) {
35603560
.lazily_allocated => flags.lazily_allocated_bit,
3561-
.linear_write_mappable => flags.host_visible_bit and flags.host_coherent_bit and !flags.device_coherent_bit_amd,
3561+
.linear_write_mappable => blk: {
3562+
if (flags.host_visible_bit and flags.host_coherent_bit and !flags.device_coherent_bit_amd) {
3563+
if (best_type) |best| {
3564+
const best_heap_size = mem_heaps[mem_types[best].heap_index].size;
3565+
if (heap_size > best_heap_size) {
3566+
break :blk true;
3567+
}
3568+
break :blk false;
3569+
}
3570+
break :blk true;
3571+
}
3572+
break :blk false;
3573+
},
35623574
.linear_read_mappable => blk: {
35633575
if (flags.host_visible_bit and flags.host_coherent_bit and !flags.device_coherent_bit_amd) {
35643576
if (best_type) |best| {
@@ -3584,7 +3596,7 @@ const MemoryAllocator = struct {
35843596
if (mem_types[best].property_flags.device_local_bit) {
35853597
if (flags.device_local_bit and !flags.device_coherent_bit_amd) {
35863598
const best_heap_size = mem_heaps[mem_types[best].heap_index].size;
3587-
if (heap_size > best_heap_size or flags.host_visible_bit) {
3599+
if (heap_size > best_heap_size) {
35883600
break :blk true;
35893601
}
35903602
}

0 commit comments

Comments
 (0)