anv: Refactor memory type setup
This makes us walk over the heaps one at a time and add the types for LLC and !LLC to each heap. Reviewed-by: Nanley Chery <nanley.g.chery@intel.com> Cc: "17.1" <mesa-stable@lists.freedesktop.org>
This commit is contained in:
@@ -112,18 +112,28 @@ anv_physical_device_init_heaps(struct anv_physical_device *device, int fd)
|
|||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
device->memory.heap_count = 1;
|
||||||
|
device->memory.heaps[0] = (struct anv_memory_heap) {
|
||||||
|
.size = heap_size,
|
||||||
|
.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
|
||||||
|
.supports_48bit_addresses = device->supports_48bit_addresses,
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t type_count = 0;
|
||||||
|
for (uint32_t heap = 0; heap < device->memory.heap_count; heap++) {
|
||||||
|
uint32_t valid_buffer_usage = ~0;
|
||||||
|
|
||||||
if (device->info.has_llc) {
|
if (device->info.has_llc) {
|
||||||
/* Big core GPUs share LLC with the CPU and thus one memory type can be
|
/* Big core GPUs share LLC with the CPU and thus one memory type can be
|
||||||
* both cached and coherent at the same time.
|
* both cached and coherent at the same time.
|
||||||
*/
|
*/
|
||||||
device->memory.type_count = 1;
|
device->memory.types[type_count++] = (struct anv_memory_type) {
|
||||||
device->memory.types[0] = (struct anv_memory_type) {
|
|
||||||
.propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
|
.propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
||||||
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
|
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
|
||||||
VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
|
VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
|
||||||
.heapIndex = 0,
|
.heapIndex = heap,
|
||||||
.valid_buffer_usage = ~0,
|
.valid_buffer_usage = valid_buffer_usage,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
/* The spec requires that we expose a host-visible, coherent memory
|
/* The spec requires that we expose a host-visible, coherent memory
|
||||||
@@ -131,29 +141,23 @@ anv_physical_device_init_heaps(struct anv_physical_device *device, int fd)
|
|||||||
* to give the application a choice between cached, but not coherent and
|
* to give the application a choice between cached, but not coherent and
|
||||||
* coherent but uncached (WC though).
|
* coherent but uncached (WC though).
|
||||||
*/
|
*/
|
||||||
device->memory.type_count = 2;
|
device->memory.types[type_count++] = (struct anv_memory_type) {
|
||||||
device->memory.types[0] = (struct anv_memory_type) {
|
|
||||||
.propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
|
.propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
||||||
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||||
.heapIndex = 0,
|
.heapIndex = heap,
|
||||||
.valid_buffer_usage = ~0,
|
.valid_buffer_usage = valid_buffer_usage,
|
||||||
};
|
};
|
||||||
device->memory.types[1] = (struct anv_memory_type) {
|
device->memory.types[type_count++] = (struct anv_memory_type) {
|
||||||
.propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
|
.propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
||||||
VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
|
VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
|
||||||
.heapIndex = 0,
|
.heapIndex = heap,
|
||||||
.valid_buffer_usage = ~0,
|
.valid_buffer_usage = valid_buffer_usage,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
device->memory.heap_count = 1;
|
device->memory.type_count = type_count;
|
||||||
device->memory.heaps[0] = (struct anv_memory_heap) {
|
|
||||||
.size = heap_size,
|
|
||||||
.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
|
|
||||||
.supports_48bit_addresses = device->supports_48bit_addresses,
|
|
||||||
};
|
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user