diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index bb63487cdad..587c8a8804f 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -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 * 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); /* 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 | ANV_BO_ALLOC_HOST_CACHED | ANV_BO_ALLOC_HOST_COHERENT | - ANV_BO_ALLOC_DEDICATED | ANV_BO_ALLOC_PROTECTED | ANV_BO_ALLOC_FIXED_ADDRESS))); assert(alloc_flags & ANV_BO_ALLOC_EXTERNAL); diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 0348f59bda6..ef566302032 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -4022,7 +4022,6 @@ VkResult anv_AllocateMemory( case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO: dedicated_info = (void *)ext; - alloc_flags |= ANV_BO_ALLOC_DEDICATED; break; 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) 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 * compatible with clients relying on implicit fencing. This matches the * behavior in iris i915_batch_submit. An example client is VA-API. diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 5e99c01ce3e..353b13c3cd3 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -407,8 +407,8 @@ enum anv_bo_alloc_flags { /** Has an address which is visible to the client */ ANV_BO_ALLOC_CLIENT_VISIBLE_ADDRESS = (1 << 8), - /** This BO will be dedicated to a buffer or an image */ - ANV_BO_ALLOC_DEDICATED = (1 << 9), + /** Align the BO's virtual address to match AUX-TT requirements */ + ANV_BO_ALLOC_AUX_TT_ALIGNED = (1 << 9), /** This buffer is allocated from local memory and should be cpu visible */ 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) return false; - /* Technically, we really only care about what offset the image is bound - * 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; + return (bo->alloc_flags & ANV_BO_ALLOC_AUX_TT_ALIGNED) != 0; } static inline bool