Skip to content

Commit 393ad1b

Browse files
committed
no device local if integrated
1 parent 1896e03 commit 393ad1b

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

rvk/device.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,19 @@ Device::Device(Arc<Physical_Device, Alloc> P, VkSurfaceKHR surface, bool ray_tra
552552
// Find heaps
553553

554554
{
555-
if(auto idx = physical_device->largest_heap(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
556-
idx.ok()) {
555+
u32 device_heap_type = 0;
556+
if(physical_device->properties().is_discrete()) {
557+
device_heap_type = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
558+
} else {
559+
info("[rvk] GPU is integrated, using host coherent heap as device heap.");
560+
device_heap_type =
561+
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
562+
}
563+
564+
if(auto idx = physical_device->largest_heap(device_heap_type); idx.ok()) {
557565
device_memory_index = *idx;
558566
} else {
559-
die("[rvk] No device local heap found.");
567+
die("[rvk] No device heap found.");
560568
}
561569

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

571579
info("[rvk] Found device and host heaps (%: %mb, %: %mb).", device_memory_index,

rvk/rvk.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,14 @@ Vk::Vk(Config config) {
181181
{
182182
u64 heap_size = device->heap_size(Heap::host);
183183
if(heap_size < Math::MB(64)) {
184-
die("Host heap is too small: %mb / 64mb.", heap_size / Math::MB(1));
184+
die("[rvk] Host heap is too small: %mb / 64mb.", heap_size / Math::MB(1));
185185
}
186186
if(config.host_heap > max_allocation) {
187-
warn("Requested host heap is larger than the max allocation size, using max.");
187+
warn("[rvk] Requested host heap is larger than the max allocation size, using max.");
188188
config.host_heap = max_allocation;
189189
}
190190
if(config.host_heap > heap_size) {
191-
warn("Requested host heap is larger than available, using entire heap.");
191+
warn("[rvk] Requested host heap is larger than available, using entire heap.");
192192
config.host_heap = heap_size;
193193
}
194194
host_memory = Arc<Device_Memory, Alloc>::make(physical_device, device.dup(), Heap::host,
@@ -197,10 +197,10 @@ Vk::Vk(Config config) {
197197
{
198198
u64 heap_size = device->heap_size(Heap::device);
199199
if(heap_size < Math::MB(128)) {
200-
die("Device heap is too small: %mb / 128mb.", heap_size / Math::MB(1));
200+
die("[rvk] Device heap is too small: %mb / 128mb.", heap_size / Math::MB(1));
201201
}
202202
if(config.device_heap_margin > heap_size) {
203-
warn("Requested device heap margin is larger than the heap, using 64mb margin.");
203+
warn("[rvk] Requested device heap margin is larger than the heap, using 64mb margin.");
204204
config.device_heap_margin = Math::MB(64);
205205
}
206206

0 commit comments

Comments
 (0)