Module: Mesa
Branch: staging/23.3
Commit: d0993405a4078ef86d05753c9ac4e03c9cff2fa3
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d0993405a4078ef86d05753c9ac4e03c9cff2fa3

Author: Lionel Landwerlin <lionel.g.landwer...@intel.com>
Date:   Wed Nov 22 16:26:38 2023 +0200

anv: use main image address to determine ccs compatibility

The BO address is not really a good criteria since we can bind an
image at an offset inside a BO.

Signed-off-by: Lionel Landwerlin <lionel.g.landwer...@intel.com>
Fixes: ee6e2bc4a3 ("anv: Place images into the aux-map when safe to do so")
Tested-by: Dmitry Osipenko <dmitry.osipe...@collabora.com>
Reviewed-by: José Roberto de Souza <jose.so...@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26335>
(cherry picked from commit b09db9d823638ccccb0898736024e69f25c321a0)

---

 .pick_status.json              |  2 +-
 src/intel/vulkan/anv_image.c   |  7 +++----
 src/intel/vulkan/anv_private.h | 18 ++++++++++++++++++
 3 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 885ef187740..c5bbb4b782d 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1754,7 +1754,7 @@
         "description": "anv: use main image address to determine ccs 
compatibility",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "ee6e2bc4a31345e50b3c674cdae233a5de5179d1",
         "notes": null
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index bed29ebe20b..43447ecfff6 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -2302,10 +2302,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 ae9dbcb549d..5f0947cb330 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -4942,6 +4942,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,

Reply via email to