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

Author: Nanley Chery <[email protected]>
Date:   Fri Apr 21 14:55:26 2023 -0700

iris: Don't memset the clear color BO during aux init

The clear color BO is sometimes getting unnecessarily zeroed. For
example, if the resource will be fast-cleared, the app may pick a
non-zero color, causing the initial memset to be unneeded.  So, skip the
memset and mark the clear color as unknown if it has not been freshly
allocated. For now, we leave the memsets on imported dmabufs alone for
simplicity.

On non-small BAR ACM systems, this also allows internal resources using
compression to be created without executing an IOCTL for memory mapping.

Reviewed-by: José Roberto de Souza <[email protected]>
Reviewed-by: Sagar Ghuge <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26675>

---

 src/gallium/drivers/iris/iris_resource.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_resource.c 
b/src/gallium/drivers/iris/iris_resource.c
index 2d6738ce298..c8c280757bd 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -1011,21 +1011,6 @@ iris_resource_init_aux_buf(struct iris_screen *screen,
              0, res->aux.extra_aux.surf.size_B);
    }
 
-   unsigned clear_color_size = iris_get_aux_clear_color_state_size(screen, 
res);
-   if (clear_color_size > 0) {
-      if (iris_bo_mmap_mode(res->bo) != IRIS_MMAP_NONE) {
-         if (!map)
-            map = iris_bo_map(NULL, res->bo, MAP_WRITE | MAP_RAW);
-         if (!map)
-            return false;
-
-         /* Zero the indirect clear color to match ::fast_clear_color. */
-         memset((char *)map + res->aux.clear_color_offset, 0, 
clear_color_size);
-      } else {
-         res->aux.clear_color_unknown = true;
-      }
-   }
-
    if (map)
       iris_bo_unmap(res->bo);
 
@@ -1035,9 +1020,10 @@ iris_resource_init_aux_buf(struct iris_screen *screen,
       map_aux_addresses(screen, res, res->internal_format, 0);
    }
 
-   if (clear_color_size > 0) {
+   if (iris_get_aux_clear_color_state_size(screen, res) > 0) {
       res->aux.clear_color_bo = res->bo;
       iris_bo_reference(res->aux.clear_color_bo);
+      res->aux.clear_color_unknown = !res->aux.clear_color_bo->zeroed;
    }
 
    return true;

Reply via email to