From: Rob Clark Date: Tue, 30 May 2023 17:20:53 +0000 (-0700) Subject: freedreno: Add aux-context support X-Git-Tag: upstream/23.3.3~7864 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=75193262fd62376947f2f997609c595efae5ceed;p=platform%2Fupstream%2Fmesa.git freedreno: Add aux-context support A global aux-context can be created on-demand for cases where we need to (for example) blit a resource when we only have a screen ptr. Signed-off-by: Rob Clark Part-of: --- diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 918f390..22042a8 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -146,6 +146,9 @@ fd_screen_destroy(struct pipe_screen *pscreen) { struct fd_screen *screen = fd_screen(pscreen); + if (screen->aux_ctx) + screen->aux_ctx->destroy(screen->aux_ctx); + if (screen->tess_bo) fd_bo_del(screen->tess_bo); @@ -1230,9 +1233,34 @@ fd_screen_create(int fd, slab_create_parent(&screen->transfer_pool, sizeof(struct fd_transfer), 16); + simple_mtx_init(&screen->aux_ctx_lock, mtx_plain); + return pscreen; fail: fd_screen_destroy(pscreen); return NULL; } + +struct fd_context * +fd_screen_aux_context_get(struct pipe_screen *pscreen) +{ + struct fd_screen *screen = fd_screen(pscreen); + + simple_mtx_lock(&screen->aux_ctx_lock); + + if (!screen->aux_ctx) { + screen->aux_ctx = pscreen->context_create(pscreen, NULL, 0); + } + + return fd_context(screen->aux_ctx); +} + +void +fd_screen_aux_context_put(struct pipe_screen *pscreen) +{ + struct fd_screen *screen = fd_screen(pscreen); + + screen->aux_ctx->flush(screen->aux_ctx, NULL, 0); + simple_mtx_unlock(&screen->aux_ctx_lock); +} diff --git a/src/gallium/drivers/freedreno/freedreno_screen.h b/src/gallium/drivers/freedreno/freedreno_screen.h index 466e203..c8a814e 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.h +++ b/src/gallium/drivers/freedreno/freedreno_screen.h @@ -170,6 +170,9 @@ struct fd_screen { */ const enum pc_di_primtype *primtypes; uint32_t primtypes_mask; + + simple_mtx_t aux_ctx_lock; + struct pipe_context *aux_ctx; }; static inline struct fd_screen * @@ -178,6 +181,10 @@ fd_screen(struct pipe_screen *pscreen) return (struct fd_screen *)pscreen; } +struct fd_context; +struct fd_context * fd_screen_aux_context_get(struct pipe_screen *pscreen); +void fd_screen_aux_context_put(struct pipe_screen *pscreen); + static inline void fd_screen_lock(struct fd_screen *screen) {