Skip to content

Commit

Permalink
no device local if integrated
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNumbat committed Sep 30, 2024
1 parent 1896e03 commit 393ad1b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
16 changes: 12 additions & 4 deletions rvk/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,19 @@ Device::Device(Arc<Physical_Device, Alloc> P, VkSurfaceKHR surface, bool ray_tra
// Find heaps

{
if(auto idx = physical_device->largest_heap(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
idx.ok()) {
u32 device_heap_type = 0;
if(physical_device->properties().is_discrete()) {
device_heap_type = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
} else {
info("[rvk] GPU is integrated, using host coherent heap as device heap.");
device_heap_type =
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
}

if(auto idx = physical_device->largest_heap(device_heap_type); idx.ok()) {
device_memory_index = *idx;
} else {
die("[rvk] No device local heap found.");
die("[rvk] No device heap found.");
}

if(auto idx = physical_device->largest_heap(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Expand All @@ -565,7 +573,7 @@ Device::Device(Arc<Physical_Device, Alloc> P, VkSurfaceKHR surface, bool ray_tra
idx.ok()) {
host_memory_index = *idx;
} else {
die("[rvk] No host visible heap found.");
die("[rvk] No host cached heap found.");
}

info("[rvk] Found device and host heaps (%: %mb, %: %mb).", device_memory_index,
Expand Down
10 changes: 5 additions & 5 deletions rvk/rvk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ Vk::Vk(Config config) {
{
u64 heap_size = device->heap_size(Heap::host);
if(heap_size < Math::MB(64)) {
die("Host heap is too small: %mb / 64mb.", heap_size / Math::MB(1));
die("[rvk] Host heap is too small: %mb / 64mb.", heap_size / Math::MB(1));
}
if(config.host_heap > max_allocation) {
warn("Requested host heap is larger than the max allocation size, using max.");
warn("[rvk] Requested host heap is larger than the max allocation size, using max.");
config.host_heap = max_allocation;
}
if(config.host_heap > heap_size) {
warn("Requested host heap is larger than available, using entire heap.");
warn("[rvk] Requested host heap is larger than available, using entire heap.");
config.host_heap = heap_size;
}
host_memory = Arc<Device_Memory, Alloc>::make(physical_device, device.dup(), Heap::host,
Expand All @@ -197,10 +197,10 @@ Vk::Vk(Config config) {
{
u64 heap_size = device->heap_size(Heap::device);
if(heap_size < Math::MB(128)) {
die("Device heap is too small: %mb / 128mb.", heap_size / Math::MB(1));
die("[rvk] Device heap is too small: %mb / 128mb.", heap_size / Math::MB(1));
}
if(config.device_heap_margin > heap_size) {
warn("Requested device heap margin is larger than the heap, using 64mb margin.");
warn("[rvk] Requested device heap margin is larger than the heap, using 64mb margin.");
config.device_heap_margin = Math::MB(64);
}

Expand Down

0 comments on commit 393ad1b

Please sign in to comment.