From 45e5c6b64119b3ddb82ff202b816be3eeecafef2 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Mon, 8 Feb 2021 12:23:38 -0800 Subject: [PATCH] anv: Add mem heap/type support for local-mem This will take effect in future patches when we are able to query the kernel to set device->vram.size to a non-zero size. Builds on Sagar's ("anv: Query memory region info") patch, and re-organizes things as recommended by Lionel (and Jason). Signed-off-by: Jordan Justen Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_device.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index e4ddd87b1a0..c8f61100a5d 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -363,7 +363,40 @@ anv_physical_device_init_heaps(struct anv_physical_device *device, int fd) anv_init_meminfo(device, fd); assert(device->sys.size != 0); - if (device->info.has_llc) { + if (device->vram.size > 0) { + /* We can create 2 different heaps when we have local memory support, + * first heap with local memory size and second with system memory size. + */ + device->memory.heap_count = 2; + device->memory.heaps[0] = (struct anv_memory_heap) { + .size = device->vram.size, + .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT, + .is_local_mem = true, + }; + device->memory.heaps[1] = (struct anv_memory_heap) { + .size = device->sys.size, + .flags = 0, + .is_local_mem = false, + }; + + device->memory.type_count = 3; + device->memory.types[0] = (struct anv_memory_type) { + .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, + .heapIndex = 0, + }; + device->memory.types[1] = (struct anv_memory_type) { + .propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | + VK_MEMORY_PROPERTY_HOST_CACHED_BIT, + .heapIndex = 1, + }; + device->memory.types[2] = (struct anv_memory_type) { + .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, + .heapIndex = 0, + }; + } else if (device->info.has_llc) { device->memory.heap_count = 1; device->memory.heaps[0] = (struct anv_memory_heap) { .size = device->sys.size,