mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-10 01:18:18 +02:00
v3dv: expose the full simulator memory to applications
On real hardware compute_heap_size() reserves a fraction of total_ram for
the rest of the system and compute_memory_budget() reports at most 90% of
the available memory, both because that RAM is shared between the GPU and
the CPU. In simulator mode the memory is instead a dedicated GPU pool
allocated by the simulator, so these reservations just hid memory: although
we allocate 1 GiB for the simulator, only 512 MiB was exposed as the heap
and as the budget.
Expose the full simulator allocation as both the heap size and the budget.
The simulator never allocates more than the 4 GiB the GPU MMU can address,
which we assert.
Before:
memoryHeaps[0]:
size = 536870912 (0x20000000) (512.00 MiB)
budget = 536870912 (0x20000000) (512.00 MiB)
After:
memoryHeaps[0]:
size = 1073741824 (0x40000000) (1024.00 MiB)
budget = 1073725536 (0x3fffc060) (1023.98 MiB)
Assisted-by: Claude Opus 4.8
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41898>
This commit is contained in:
parent
27a8ca79b1
commit
03dee27f48
1 changed files with 18 additions and 13 deletions
|
|
@ -768,20 +768,23 @@ v3dv_DestroyInstance(VkInstance _instance,
|
|||
static uint64_t
|
||||
compute_heap_size(struct v3dv_instance *instance)
|
||||
{
|
||||
const uint64_t MAX_HEAP_SIZE = 4ull * 1024ull * 1024ull * 1024ull;
|
||||
/* The GPU has a 32-bit MMU and cannot address more than 4GB. */
|
||||
ASSERTED const uint64_t MAX_HEAP_SIZE = 4ull * 1024ull * 1024ull * 1024ull;
|
||||
uint64_t memory;
|
||||
|
||||
#if !USE_V3D_SIMULATOR
|
||||
memory = os_get_gpu_heap_size(instance->heap_memory_percent,
|
||||
&instance->heap_memory_percent);
|
||||
#else
|
||||
uint64_t total_ram = (uint64_t) v3d_simulator_get_mem_size();
|
||||
memory = os_gpu_heap_size_calculate(total_ram,
|
||||
instance->heap_memory_percent,
|
||||
&instance->heap_memory_percent);
|
||||
#endif
|
||||
|
||||
return MIN2(MAX_HEAP_SIZE, memory);
|
||||
#else
|
||||
/* Memory allocated by the simulator is fully dedicated for the GPU so we
|
||||
* expose all of it instead of reserving a fraction for the rest of the
|
||||
* system as we do for real, shared RAM. The simulator never allocates more
|
||||
* than the GPU can address.
|
||||
*/
|
||||
memory = (uint64_t) v3d_simulator_get_mem_size();
|
||||
assert(MAX_HEAP_SIZE >= memory);
|
||||
return memory;
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
|
|
@ -790,17 +793,19 @@ compute_memory_budget(struct v3dv_physical_device *device)
|
|||
uint64_t heap_size = device->memory.memoryHeaps[0].size;
|
||||
uint64_t heap_used = p_atomic_read(&device->heap_used);
|
||||
|
||||
#if !USE_V3D_SIMULATOR
|
||||
/* Let's not incite the app to starve the system: report at most 90% of
|
||||
* available system memory.
|
||||
*/
|
||||
const float percentage = 0.9f;
|
||||
|
||||
#if !USE_V3D_SIMULATOR
|
||||
return vk_physical_device_heap_budget_from_system(
|
||||
&device->vk, percentage, heap_size, heap_used);
|
||||
#else
|
||||
return vk_physical_device_heap_budget(v3d_simulator_get_mem_free(),
|
||||
percentage, heap_size, heap_used);
|
||||
/* The simulator memory is fully dedicated to the GPU, so the whole free
|
||||
* pool is available to applications.
|
||||
*/
|
||||
uint64_t heap_available = (uint64_t) v3d_simulator_get_mem_free();
|
||||
return MIN2(heap_size, heap_used + heap_available);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue