iris: give each screen of a bufmgr a unique ID

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>
This commit is contained in:
Paulo Zanoni 2021-08-11 15:17:33 -07:00 committed by Marge Bot
parent b2c811ccdc
commit d1c27d214b
4 changed files with 16 additions and 0 deletions

View 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.
*

View 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 */

View 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);

View 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 *