mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 16:08:04 +02:00
anv/device: Only allocate whole pages in AllocateMemory
The kernel is going to give us whole pages anyway, so allocating part of a page doesn't help. And this ensures that we can always work with whole pages.
This commit is contained in:
parent
f076d5330d
commit
6b0b57225c
2 changed files with 11 additions and 2 deletions
|
|
@ -1020,7 +1020,10 @@ VkResult anv_AllocateMemory(
|
|||
if (mem == NULL)
|
||||
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
result = anv_bo_init_new(&mem->bo, device, pAllocateInfo->allocationSize);
|
||||
/* The kernel is going to give us whole pages anyway */
|
||||
uint64_t alloc_size = align_u64(pAllocateInfo->allocationSize, 4096);
|
||||
|
||||
result = anv_bo_init_new(&mem->bo, device, alloc_size);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
|
|
@ -1088,7 +1091,7 @@ VkResult anv_MapMemory(
|
|||
uint64_t map_size = (offset + size) - map_offset;
|
||||
|
||||
/* Let's map whole pages */
|
||||
map_size = (map_size + 4095) & ~4095ull;
|
||||
map_size = align_u64(map_size, 4096);
|
||||
|
||||
mem->map = anv_gem_mmap(device, mem->bo.gem_handle,
|
||||
map_offset, map_size, gem_flags);
|
||||
|
|
|
|||
|
|
@ -86,6 +86,12 @@ align_u32(uint32_t v, uint32_t a)
|
|||
return (v + a - 1) & ~(a - 1);
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
align_u64(uint64_t v, uint64_t a)
|
||||
{
|
||||
return (v + a - 1) & ~(a - 1);
|
||||
}
|
||||
|
||||
static inline int32_t
|
||||
align_i32(int32_t v, int32_t a)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue