diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-11-02 04:34:57 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-11-02 04:34:57 +0000 |
commit | 32aeb3c41fedbbd7b11aacfec48e8f699d16bff0 (patch) | |
tree | fc5893a490729ebf6b87b83eebf5d4ebfdfccf27 /lib/mesa/src/gallium/winsys/lima | |
parent | 286ec9d289bada8abb84753c461cfa3432866e98 (diff) |
Import Mesa 23.1.9
Diffstat (limited to 'lib/mesa/src/gallium/winsys/lima')
-rw-r--r-- | lib/mesa/src/gallium/winsys/lima/drm/lima_drm_public.h | 4 | ||||
-rw-r--r-- | lib/mesa/src/gallium/winsys/lima/drm/lima_drm_winsys.c | 75 |
2 files changed, 9 insertions, 70 deletions
diff --git a/lib/mesa/src/gallium/winsys/lima/drm/lima_drm_public.h b/lib/mesa/src/gallium/winsys/lima/drm/lima_drm_public.h index 06ca46499..96faec814 100644 --- a/lib/mesa/src/gallium/winsys/lima/drm/lima_drm_public.h +++ b/lib/mesa/src/gallium/winsys/lima/drm/lima_drm_public.h @@ -30,6 +30,8 @@ struct pipe_screen; struct renderonly; struct pipe_screen *lima_drm_screen_create(int drmFD); -struct pipe_screen *lima_drm_screen_create_renderonly(struct renderonly *ro); +struct pipe_screen *lima_drm_screen_create_renderonly(int fd, + struct renderonly *ro, + const struct pipe_screen_config *config); #endif /* __LIMA_DRM_PUBLIC_H__ */ diff --git a/lib/mesa/src/gallium/winsys/lima/drm/lima_drm_winsys.c b/lib/mesa/src/gallium/winsys/lima/drm/lima_drm_winsys.c index 9c8cd933e..589f15014 100644 --- a/lib/mesa/src/gallium/winsys/lima/drm/lima_drm_winsys.c +++ b/lib/mesa/src/gallium/winsys/lima/drm/lima_drm_winsys.c @@ -21,87 +21,24 @@ * IN THE SOFTWARE. */ -#include <unistd.h> -#include <fcntl.h> -#include <sys/stat.h> - -#include "c11/threads.h" #include "util/os_file.h" -#include "util/u_hash_table.h" -#include "util/u_pointer.h" +#include "util/u_screen.h" #include "renderonly/renderonly.h" #include "lima_drm_public.h" #include "lima/lima_screen.h" -static struct hash_table *fd_tab = NULL; -static mtx_t lima_screen_mutex = _MTX_INITIALIZER_NP; - -static void -lima_drm_screen_destroy(struct pipe_screen *pscreen) -{ - struct lima_screen *screen = lima_screen(pscreen); - boolean destroy; - int fd = screen->fd; - - mtx_lock(&lima_screen_mutex); - destroy = --screen->refcnt == 0; - if (destroy) { - _mesa_hash_table_remove_key(fd_tab, intptr_to_pointer(fd)); - - if (!fd_tab->entries) { - _mesa_hash_table_destroy(fd_tab, NULL); - fd_tab = NULL; - } - } - mtx_unlock(&lima_screen_mutex); - - if (destroy) { - pscreen->destroy = screen->winsys_priv; - pscreen->destroy(pscreen); - close(fd); - } -} - struct pipe_screen * lima_drm_screen_create(int fd) { - struct pipe_screen *pscreen = NULL; - - mtx_lock(&lima_screen_mutex); - if (!fd_tab) { - fd_tab = util_hash_table_create_fd_keys(); - if (!fd_tab) - goto unlock; - } - - pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd)); - if (pscreen) { - lima_screen(pscreen)->refcnt++; - } else { - int dup_fd = os_dupfd_cloexec(fd); - - pscreen = lima_screen_create(dup_fd, NULL); - if (pscreen) { - _mesa_hash_table_insert(fd_tab, intptr_to_pointer(dup_fd), pscreen); - - /* Bit of a hack, to avoid circular linkage dependency, - * ie. pipe driver having to call in to winsys, we - * override the pipe drivers screen->destroy(): - */ - lima_screen(pscreen)->winsys_priv = pscreen->destroy; - pscreen->destroy = lima_drm_screen_destroy; - } - } - -unlock: - mtx_unlock(&lima_screen_mutex); - return pscreen; + return u_pipe_screen_lookup_or_create(os_dupfd_cloexec(fd), NULL, + NULL, lima_screen_create); } struct pipe_screen * -lima_drm_screen_create_renderonly(struct renderonly *ro) +lima_drm_screen_create_renderonly(int fd, struct renderonly *ro, + const struct pipe_screen_config *config) { - return lima_screen_create(os_dupfd_cloexec(ro->gpu_fd), ro); + return lima_screen_create(os_dupfd_cloexec(fd), config, ro); } |