iris: give each screen of a bufmgr a unique ID
authorPaulo Zanoni <paulo.r.zanoni@intel.com>
Wed, 11 Aug 2021 22:17:33 +0000 (15:17 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 1 Sep 2021 21:48:13 +0000 (21:48 +0000)
We want to implement explicit BO dependency tracking and for that
we'll use arrays of dependencies (syncobjs) indexed by screen->id.
This is way more efficient than storing and checking screen pointers
everywhere.

v2: Properly use atomic operations in a non-racy way (Alyssa, Ken).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12363>

src/gallium/drivers/iris/iris_bufmgr.c
src/gallium/drivers/iris/iris_bufmgr.h
src/gallium/drivers/iris/iris_screen.c
src/gallium/drivers/iris/iris_screen.h

index a8e2ab7..52a7125 100644 (file)
@@ -206,6 +206,8 @@ struct iris_bufmgr {
    uint64_t vma_min_align;
    struct iris_memregion vram, sys;
 
+   int next_screen_id;
+
    bool has_llc:1;
    bool has_local_mem:1;
    bool has_mmap_offset:1;
@@ -1866,6 +1868,13 @@ iris_bufmgr_unref(struct iris_bufmgr *bufmgr)
    simple_mtx_unlock(&global_bufmgr_list_mutex);
 }
 
+/** Returns a new unique id, to be used by screens. */
+int
+iris_bufmgr_create_screen_id(struct iris_bufmgr *bufmgr)
+{
+   return p_atomic_inc_return(&bufmgr->next_screen_id) - 1;
+}
+
 /**
  * Gets an already existing GEM buffer manager or create a new one.
  *
index 700636f..226168d 100644 (file)
@@ -449,4 +449,6 @@ iris_bo_bump_seqno(struct iris_bo *bo, uint64_t seqno,
 
 enum iris_memory_zone iris_memzone_for_address(uint64_t address);
 
+int iris_bufmgr_create_screen_id(struct iris_bufmgr *bufmgr);
+
 #endif /* IRIS_BUFMGR_H */
index bd6ed55..55db58c 100644 (file)
@@ -830,6 +830,8 @@ iris_screen_create(int fd, const struct pipe_screen_config *config)
    screen->fd = iris_bufmgr_get_fd(screen->bufmgr);
    screen->winsys_fd = fd;
 
+   screen->id = iris_bufmgr_create_screen_id(screen->bufmgr);
+
    screen->workaround_bo =
       iris_bo_alloc(screen->bufmgr, "workaround", 4096, 1,
                     IRIS_MEMZONE_OTHER, 0);
index 82fd1d3..3a4e56a 100644 (file)
@@ -223,6 +223,9 @@ struct iris_screen {
    struct disk_cache *disk_cache;
 
    struct intel_measure_device measure;
+
+   /** Every screen on a bufmgr has an unique ID assigned by the bufmgr. */
+   int id;
 };
 
 struct pipe_screen *