Module: Mesa
Branch: main
Commit: 8d0e70f628b745ad81124e0c3fe5e46ea84f6b46
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d0e70f628b745ad81124e0c3fe5e46ea84f6b46

Author: José Roberto de Souza <[email protected]>
Date:   Fri Dec 15 07:55:27 2023 -0800

anv: Replace anv_bo.vram_only by anv_bo.alloc_flags check

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10291
Signed-off-by: José Roberto de Souza <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26711>

---

 src/intel/vulkan/anv_allocator.c        |  2 --
 src/intel/vulkan/anv_image.c            |  2 +-
 src/intel/vulkan/anv_private.h          | 12 +++++++++---
 src/intel/vulkan/i915/anv_batch_chain.c |  4 ++--
 4 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
index 0c09b0c4c48..3222d75ab30 100644
--- a/src/intel/vulkan/anv_allocator.c
+++ b/src/intel/vulkan/anv_allocator.c
@@ -1531,8 +1531,6 @@ anv_device_alloc_bo(struct anv_device *device,
       .actual_size = actual_size,
       .flags = bo_flags,
       .alloc_flags = alloc_flags,
-      .vram_only = nregions == 1 &&
-                   regions[0] == device->physical->vram_non_mappable.region,
    };
 
    if (alloc_flags & ANV_BO_ALLOC_MAPPED) {
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 7287dffc2ba..aa48332301a 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -2369,7 +2369,7 @@ VkResult anv_BindImageMemory2(
             continue;
 
          /* Do nothing if flat CCS requirements are satisfied. */
-         if (device->info->has_flat_ccs && bo->vram_only)
+         if (device->info->has_flat_ccs && anv_bo_is_vram_only(bo))
             continue;
 
          /* Add the plane to the aux map when applicable. */
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 76f103df525..94798bdbac0 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -497,9 +497,6 @@ struct anv_bo {
 
    /** True if this BO wraps a host pointer */
    bool from_host_ptr:1;
-
-   /** True if this BO can only live in VRAM */
-   bool vram_only:1;
 };
 
 static inline bool
@@ -508,6 +505,15 @@ anv_bo_is_external(const struct anv_bo *bo)
    return bo->alloc_flags & ANV_BO_ALLOC_EXTERNAL;
 }
 
+static inline bool
+anv_bo_is_vram_only(const struct anv_bo *bo)
+{
+   return !(bo->alloc_flags & (ANV_BO_ALLOC_NO_LOCAL_MEM |
+                               ANV_BO_ALLOC_MAPPED |
+                               ANV_BO_ALLOC_LOCAL_MEM_CPU_VISIBLE |
+                               ANV_BO_ALLOC_IMPORTED));
+}
+
 static inline struct anv_bo *
 anv_bo_ref(struct anv_bo *bo)
 {
diff --git a/src/intel/vulkan/i915/anv_batch_chain.c 
b/src/intel/vulkan/i915/anv_batch_chain.c
index 3cfff100e20..51c99799e0a 100644
--- a/src/intel/vulkan/i915/anv_batch_chain.c
+++ b/src/intel/vulkan/i915/anv_batch_chain.c
@@ -664,7 +664,7 @@ anv_i915_debug_submit(const struct anv_execbuf *execbuf)
    for (uint32_t i = 0; i < execbuf->bo_count; i++) {
       const struct anv_bo *bo = execbuf->bos[i];
       total_size_kb += bo->size / 1024;
-      if (bo->vram_only)
+      if (anv_bo_is_vram_only(bo))
          total_vram_only_size_kb += bo->size / 1024;
    }
 
@@ -679,7 +679,7 @@ anv_i915_debug_submit(const struct anv_execbuf *execbuf)
               "KB handle=%05u capture=%u vram_only=%u name=%s\n",
               bo->offset, bo->offset + bo->size - 1, bo->size / 1024,
               bo->gem_handle, (bo->flags & EXEC_OBJECT_CAPTURE) != 0,
-              bo->vram_only, bo->name);
+              anv_bo_is_vram_only(bo), bo->name);
    }
 }
 

Reply via email to