mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 13:20:14 +01:00
anv: add missing alignment for AUX-TT mapping
Buffers that are not dedicated can also be used for CCS mapped images,
so they need to be aligned to the AUX-TT requirements.
GTK+ is running into such case where it creates an image with a CCS
modifier. When requesting the alignment through
vkGetImageMemoryRequirements() the 64KB/1MB alignment is returned, but
the binding fails with an assert because the VkDeviceMemory has not
been aligned to the AUX-TT requirement and we cannot disable CCS since
the modifier requires it.
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 4cdd3178fb ("anv: Meet CCS alignment reqs with dedicated allocs")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10433
Reviewed-by: Jianxun Zhang <jianxun.zhang@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27258>
This commit is contained in:
parent
337fbab9ce
commit
e519e06f4b
3 changed files with 18 additions and 13 deletions
|
|
@ -1399,7 +1399,7 @@ anv_bo_vma_alloc_or_close(struct anv_device *device,
|
||||||
/* If we're using the AUX map, make sure we follow the required
|
/* If we're using the AUX map, make sure we follow the required
|
||||||
* alignment.
|
* alignment.
|
||||||
*/
|
*/
|
||||||
if (device->info->has_aux_map && (alloc_flags & ANV_BO_ALLOC_DEDICATED))
|
if (alloc_flags & ANV_BO_ALLOC_AUX_TT_ALIGNED)
|
||||||
align = MAX2(intel_aux_map_get_alignment(device->aux_map_ctx), align);
|
align = MAX2(intel_aux_map_get_alignment(device->aux_map_ctx), align);
|
||||||
|
|
||||||
/* Opportunistically align addresses to 2Mb when above 1Mb. We do this
|
/* Opportunistically align addresses to 2Mb when above 1Mb. We do this
|
||||||
|
|
@ -1614,7 +1614,6 @@ anv_device_import_bo_from_host_ptr(struct anv_device *device,
|
||||||
assert(!(alloc_flags & (ANV_BO_ALLOC_MAPPED |
|
assert(!(alloc_flags & (ANV_BO_ALLOC_MAPPED |
|
||||||
ANV_BO_ALLOC_HOST_CACHED |
|
ANV_BO_ALLOC_HOST_CACHED |
|
||||||
ANV_BO_ALLOC_HOST_COHERENT |
|
ANV_BO_ALLOC_HOST_COHERENT |
|
||||||
ANV_BO_ALLOC_DEDICATED |
|
|
||||||
ANV_BO_ALLOC_PROTECTED |
|
ANV_BO_ALLOC_PROTECTED |
|
||||||
ANV_BO_ALLOC_FIXED_ADDRESS)));
|
ANV_BO_ALLOC_FIXED_ADDRESS)));
|
||||||
assert(alloc_flags & ANV_BO_ALLOC_EXTERNAL);
|
assert(alloc_flags & ANV_BO_ALLOC_EXTERNAL);
|
||||||
|
|
|
||||||
|
|
@ -4022,7 +4022,6 @@ VkResult anv_AllocateMemory(
|
||||||
|
|
||||||
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO:
|
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO:
|
||||||
dedicated_info = (void *)ext;
|
dedicated_info = (void *)ext;
|
||||||
alloc_flags |= ANV_BO_ALLOC_DEDICATED;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO: {
|
case VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO: {
|
||||||
|
|
@ -4070,6 +4069,20 @@ VkResult anv_AllocateMemory(
|
||||||
if (mem->vk.alloc_flags & VK_MEMORY_PROPERTY_PROTECTED_BIT)
|
if (mem->vk.alloc_flags & VK_MEMORY_PROPERTY_PROTECTED_BIT)
|
||||||
alloc_flags |= ANV_BO_ALLOC_PROTECTED;
|
alloc_flags |= ANV_BO_ALLOC_PROTECTED;
|
||||||
|
|
||||||
|
/* For now, always allocated AUX-TT aligned memory, regardless of dedicated
|
||||||
|
* allocations. An application can for example, suballocate a large
|
||||||
|
* VkDeviceMemory and try to bind an image created with a CCS modifier. In
|
||||||
|
* that case we cannot disable CCS if the alignment doesn´t meet the AUX-TT
|
||||||
|
* requirements, so we need to ensure both the VkDeviceMemory and the
|
||||||
|
* alignment reported through vkGetImageMemoryRequirements() meet the
|
||||||
|
* AUX-TT requirement.
|
||||||
|
*
|
||||||
|
* TODO: when we enable EXT_descriptor_buffer, we'll be able to drop the
|
||||||
|
* AUX-TT alignment for that type of allocation.
|
||||||
|
*/
|
||||||
|
if (device->info->has_aux_map)
|
||||||
|
alloc_flags |= ANV_BO_ALLOC_AUX_TT_ALIGNED;
|
||||||
|
|
||||||
/* Anything imported or exported is EXTERNAL. Apply implicit sync to be
|
/* Anything imported or exported is EXTERNAL. Apply implicit sync to be
|
||||||
* compatible with clients relying on implicit fencing. This matches the
|
* compatible with clients relying on implicit fencing. This matches the
|
||||||
* behavior in iris i915_batch_submit. An example client is VA-API.
|
* behavior in iris i915_batch_submit. An example client is VA-API.
|
||||||
|
|
|
||||||
|
|
@ -407,8 +407,8 @@ enum anv_bo_alloc_flags {
|
||||||
/** Has an address which is visible to the client */
|
/** Has an address which is visible to the client */
|
||||||
ANV_BO_ALLOC_CLIENT_VISIBLE_ADDRESS = (1 << 8),
|
ANV_BO_ALLOC_CLIENT_VISIBLE_ADDRESS = (1 << 8),
|
||||||
|
|
||||||
/** This BO will be dedicated to a buffer or an image */
|
/** Align the BO's virtual address to match AUX-TT requirements */
|
||||||
ANV_BO_ALLOC_DEDICATED = (1 << 9),
|
ANV_BO_ALLOC_AUX_TT_ALIGNED = (1 << 9),
|
||||||
|
|
||||||
/** This buffer is allocated from local memory and should be cpu visible */
|
/** This buffer is allocated from local memory and should be cpu visible */
|
||||||
ANV_BO_ALLOC_LOCAL_MEM_CPU_VISIBLE = (1 << 10),
|
ANV_BO_ALLOC_LOCAL_MEM_CPU_VISIBLE = (1 << 10),
|
||||||
|
|
@ -5089,14 +5089,7 @@ anv_bo_allows_aux_map(const struct anv_device *device,
|
||||||
if (device->aux_map_ctx == NULL)
|
if (device->aux_map_ctx == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Technically, we really only care about what offset the image is bound
|
return (bo->alloc_flags & ANV_BO_ALLOC_AUX_TT_ALIGNED) != 0;
|
||||||
* into on the BO, but we don't have that information here. As a heuristic,
|
|
||||||
* rely on the BO offset instead.
|
|
||||||
*/
|
|
||||||
if (bo->offset % intel_aux_map_get_alignment(device->aux_map_ctx) != 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue