anv: Allocate BO in appropriate region

Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5599>
This commit is contained in:
Sagar Ghuge 2020-04-02 20:16:08 -07:00 committed by Marge Bot
parent 3f8eca7f82
commit 6352371ff6
3 changed files with 32 additions and 1 deletions

View File

@ -1649,7 +1649,29 @@ anv_device_alloc_bo(struct anv_device *device,
ccs_size = align_u64(DIV_ROUND_UP(size, INTEL_AUX_MAP_GFX12_CCS_SCALE), 4096);
}
uint32_t gem_handle = anv_gem_create(device, size + ccs_size);
uint32_t gem_handle;
/* If we have vram size, we have multiple memory regions and should choose
* one of them.
*/
if (device->physical->vram.size > 0) {
struct drm_i915_gem_memory_class_instance regions[2];
uint32_t nregions = 0;
if (alloc_flags & ANV_BO_ALLOC_LOCAL_MEM) {
/* For vram allocation, still use system memory as a fallback. */
regions[nregions++] = device->physical->vram.region;
regions[nregions++] = device->physical->sys.region;
} else {
regions[nregions++] = device->physical->sys.region;
}
gem_handle = anv_gem_create_regions(device, size + ccs_size,
nregions, regions);
} else {
gem_handle = anv_gem_create(device, size + ccs_size);
}
if (gem_handle == 0)
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);

View File

@ -4021,6 +4021,12 @@ VkResult anv_AllocateMemory(
goto success;
}
/* Set ALLOC_LOCAL_MEM flag if heap has device local bit set and requested
* memory property flag has DEVICE_LOCAL_BIT set.
*/
if (mem_type->propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
alloc_flags |= ANV_BO_ALLOC_LOCAL_MEM;
/* Regular allocate (not importing memory). */
result = anv_device_alloc_bo(device, "user", pAllocateInfo->allocationSize,

View File

@ -1404,6 +1404,9 @@ enum anv_bo_alloc_flags {
/** This buffer has implicit CCS data attached to it */
ANV_BO_ALLOC_IMPLICIT_CCS = (1 << 9),
/** This buffer is allocated from local memory */
ANV_BO_ALLOC_LOCAL_MEM = (1 << 10),
};
VkResult anv_device_alloc_bo(struct anv_device *device,