/* 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_IMPLICIT_CCS))
+ if (device->info->has_aux_map && (alloc_flags & ANV_BO_ALLOC_DEDICATED))
align = MAX2(intel_aux_map_get_alignment(device->aux_map_ctx), align);
/* Opportunistically align addresses to 2Mb when above 1Mb. We do this
{
assert(!(alloc_flags & (ANV_BO_ALLOC_MAPPED |
ANV_BO_ALLOC_SNOOPED |
+ ANV_BO_ALLOC_DEDICATED |
ANV_BO_ALLOC_FIXED_ADDRESS)));
assert(!(alloc_flags & ANV_BO_ALLOC_IMPLICIT_CCS) ||
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: {
*/
requirements->prefersDedicatedAllocation = true;
requirements->requiresDedicatedAllocation = true;
+ } else if (anv_image_uses_aux_map(device, image)) {
+ /* We request a dedicated allocation to guarantee that the BO will
+ * be aux-map compatible (see anv_bo_vma_alloc_or_close and
+ * anv_bo_allows_aux_map).
+ *
+ * TODO: This is an untested heuristic. It's not known if this
+ * guarantee is worth losing suballocation.
+ *
+ * If we don't have an aux-map compatible BO at the time we bind
+ * this image to device memory, we'll change the aux usage.
+ *
+ * It may be possible to handle an image using a modifier in the
+ * same way. However, we choose to keep things simple and require
+ * a dedicated allocation for that case.
+ */
+ requirements->prefersDedicatedAllocation = true;
+ requirements->requiresDedicatedAllocation =
+ isl_drm_modifier_has_aux(image->vk.drm_format_mod);
} else {
requirements->prefersDedicatedAllocation = false;
requirements->requiresDedicatedAllocation = false;
/** For descriptor pools */
ANV_BO_ALLOC_DESCRIPTOR_POOL = (1 << 13),
+
+ /** This BO will be dedicated to a buffer or an image */
+ ANV_BO_ALLOC_DEDICATED = (1 << 14),
};
struct anv_bo {
}
static inline bool
+anv_image_uses_aux_map(const struct anv_device *device,
+ const struct anv_image *image)
+{
+ for (uint32_t p = 0; p < image->n_planes; ++p) {
+ if (anv_image_plane_uses_aux_map(device, image, p))
+ return true;
+ }
+
+ return false;
+}
+
+static inline bool
anv_bo_allows_aux_map(const struct anv_device *device,
const struct anv_bo *bo)
{