summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Justen <jordan.l.justen@intel.com>2021-02-08 12:23:38 -0800
committerJordan Justen <jordan.l.justen@intel.com>2021-03-08 12:47:06 -0800
commit230108b059c340f0bc5a3a1040029b45361b1c07 (patch)
tree830b09827e17584d6eb9f22abcc85aa9494efaca
parente9c2f3a404270c1a850cb58c103ecf385d5b0559 (diff)
anv: Add mem heap/type support for local-memanv-mem-heap-type
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 <jordan.l.justen@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
-rw-r--r--src/intel/vulkan/anv_device.c35
1 files changed, 34 insertions, 1 deletions
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,