tu: Fix heap size
It make no sense to advertise a bigger heap than what we can fit into the GPU virtual address space. Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25130>
This commit is contained in:
@@ -1479,7 +1479,7 @@ tu_GetPhysicalDeviceQueueFamilyProperties2(
|
||||
}
|
||||
|
||||
uint64_t
|
||||
tu_get_system_heap_size()
|
||||
tu_get_system_heap_size(struct tu_physical_device *physical_device)
|
||||
{
|
||||
struct sysinfo info;
|
||||
sysinfo(&info);
|
||||
@@ -1495,6 +1495,9 @@ tu_get_system_heap_size()
|
||||
else
|
||||
available_ram = total_ram * 3 / 4;
|
||||
|
||||
if (physical_device->va_size)
|
||||
available_ram = MIN2(available_ram, physical_device->va_size);
|
||||
|
||||
return available_ram;
|
||||
}
|
||||
|
||||
@@ -1508,6 +1511,9 @@ tu_get_budget_memory(struct tu_physical_device *physical_device)
|
||||
os_get_available_system_memory(&sys_available);
|
||||
assert(has_available_memory);
|
||||
|
||||
if (physical_device->va_size)
|
||||
sys_available = MIN2(sys_available, physical_device->va_size);
|
||||
|
||||
/*
|
||||
* Let's not incite the app to starve the system: report at most 90% of
|
||||
* available system memory.
|
||||
|
||||
@@ -457,7 +457,7 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(tu_sampler, base, VkSampler,
|
||||
VK_OBJECT_TYPE_SAMPLER)
|
||||
|
||||
uint64_t
|
||||
tu_get_system_heap_size(void);
|
||||
tu_get_system_heap_size(struct tu_physical_device *physical_device);
|
||||
|
||||
VkResult
|
||||
tu_physical_device_init(struct tu_physical_device *device,
|
||||
|
||||
@@ -1113,7 +1113,7 @@ tu_knl_drm_msm_load(struct tu_instance *instance,
|
||||
device->sync_types[1] = &device->timeline_type.sync;
|
||||
device->sync_types[2] = NULL;
|
||||
|
||||
device->heap.size = tu_get_system_heap_size();
|
||||
device->heap.size = tu_get_system_heap_size(device);
|
||||
device->heap.used = 0u;
|
||||
device->heap.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT;
|
||||
|
||||
|
||||
@@ -1591,7 +1591,7 @@ tu_knl_drm_virtio_load(struct tu_instance *instance,
|
||||
device->sync_types[1] = &device->timeline_type.sync;
|
||||
device->sync_types[2] = NULL;
|
||||
|
||||
device->heap.size = tu_get_system_heap_size();
|
||||
device->heap.size = tu_get_system_heap_size(device);
|
||||
device->heap.used = 0u;
|
||||
device->heap.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT;
|
||||
|
||||
|
||||
@@ -1271,7 +1271,7 @@ tu_knl_kgsl_load(struct tu_instance *instance, int fd)
|
||||
device->sync_types[1] = &device->timeline_type.sync;
|
||||
device->sync_types[2] = NULL;
|
||||
|
||||
device->heap.size = tu_get_system_heap_size();
|
||||
device->heap.size = tu_get_system_heap_size(device);
|
||||
device->heap.used = 0u;
|
||||
device->heap.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user