From 133c73da8560f689f8d560b30b1557a353b44995 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 13 Mar 2024 12:22:23 +1000 Subject: [PATCH] nvk: enable a mappable bar heap when rebar is disabled. Now that we've resolved the kernel side issues, this should be fine to expose on non-rebar systems. Part-of: --- src/nouveau/vulkan/nvk_physical_device.c | 15 ++++++++++++--- src/nouveau/vulkan/nvk_physical_device.h | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/nouveau/vulkan/nvk_physical_device.c b/src/nouveau/vulkan/nvk_physical_device.c index fc18c0b31cd..651cbd9336b 100644 --- a/src/nouveau/vulkan/nvk_physical_device.c +++ b/src/nouveau/vulkan/nvk_physical_device.c @@ -1170,11 +1170,21 @@ nvk_create_drm_physical_device(struct vk_instance *_instance, if (pdev->info.vram_size_B > 0) { uint32_t vram_heap_idx = pdev->mem_heap_count++; + uint32_t bar_heap_idx = vram_heap_idx; pdev->mem_heaps[vram_heap_idx] = (struct nvk_memory_heap) { .size = pdev->info.vram_size_B, .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT, }; + if (pdev->info.bar_size_B > 0 && + pdev->info.bar_size_B < pdev->info.vram_size_B) { + bar_heap_idx = pdev->mem_heap_count++; + pdev->mem_heaps[bar_heap_idx] = (struct nvk_memory_heap) { + .size = pdev->info.bar_size_B, + .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT, + }; + } + /* Only set available if we have the ioctl. */ if (nouveau_ws_device_vram_used(ws_dev) > 0) pdev->mem_heaps[vram_heap_idx].available = nvk_get_vram_heap_available; @@ -1184,13 +1194,12 @@ nvk_create_drm_physical_device(struct vk_instance *_instance, .heapIndex = vram_heap_idx, }; - if (pdev->info.cls_eng3d >= MAXWELL_A && - pdev->info.bar_size_B >= pdev->info.vram_size_B) { + if (pdev->info.cls_eng3d >= MAXWELL_A) { pdev->mem_types[pdev->mem_type_count++] = (VkMemoryType) { .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, - .heapIndex = vram_heap_idx, + .heapIndex = bar_heap_idx, }; } } diff --git a/src/nouveau/vulkan/nvk_physical_device.h b/src/nouveau/vulkan/nvk_physical_device.h index ac963111798..a329f6f35b4 100644 --- a/src/nouveau/vulkan/nvk_physical_device.h +++ b/src/nouveau/vulkan/nvk_physical_device.h @@ -49,7 +49,7 @@ struct nvk_physical_device { uint8_t device_uuid[VK_UUID_SIZE]; // TODO: add mapable VRAM heap if possible - struct nvk_memory_heap mem_heaps[2]; + struct nvk_memory_heap mem_heaps[3]; VkMemoryType mem_types[3]; uint8_t mem_heap_count; uint8_t mem_type_count;