diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 2bace7d6cd3..10ba6046c98 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -2311,10 +2311,9 @@ VkResult anv_BindImageMemory2( continue; /* Add the plane to the aux map when applicable. */ - if (anv_bo_allows_aux_map(device, bo)) { - const struct anv_address main_addr = - anv_image_address(image, - &image->planes[p].primary_surface.memory_range); + const struct anv_address main_addr = anv_image_address( + image, &image->planes[p].primary_surface.memory_range); + if (anv_address_allows_aux_map(device, main_addr)) { const struct anv_address aux_addr = anv_image_address(image, &image->planes[p].compr_ctrl_memory_range); diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 4d243bbe6bc..f54aa54ecfe 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -5151,6 +5151,24 @@ anv_bo_allows_aux_map(const struct anv_device *device, return true; } +static inline bool +anv_address_allows_aux_map(const struct anv_device *device, + struct anv_address addr) +{ + 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 (((addr.bo ? addr.bo->offset : 0) + addr.offset) % + intel_aux_map_get_alignment(device->aux_map_ctx) != 0) + return false; + + return true; +} + void anv_cmd_buffer_mark_image_written(struct anv_cmd_buffer *cmd_buffer, const struct anv_image *image,