zink: store drm fd to screen
Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12857>
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include "util/u_debug.h"
|
||||
#include "util/format/u_format.h"
|
||||
#include "util/hash_table.h"
|
||||
#include "util/os_file.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_screen.h"
|
||||
@@ -51,6 +52,12 @@
|
||||
|
||||
#include "frontend/sw_winsys.h"
|
||||
|
||||
#if DETECT_OS_WINDOWS
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// Source of MVK_VERSION
|
||||
#include "MoltenVK/vk_mvk_moltenvk.h"
|
||||
@@ -1087,6 +1094,9 @@ zink_destroy_screen(struct pipe_screen *pscreen)
|
||||
vkDestroyInstance(screen->instance, NULL);
|
||||
util_idalloc_mt_fini(&screen->buffer_ids);
|
||||
|
||||
if (screen->drm_fd != -1)
|
||||
close(screen->drm_fd);
|
||||
|
||||
slab_destroy_parent(&screen->transfer_pool);
|
||||
ralloc_free(screen);
|
||||
}
|
||||
@@ -1961,8 +1971,10 @@ struct pipe_screen *
|
||||
zink_create_screen(struct sw_winsys *winsys)
|
||||
{
|
||||
struct zink_screen *ret = zink_internal_create_screen(NULL);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
ret->winsys = winsys;
|
||||
ret->drm_fd = -1;
|
||||
}
|
||||
|
||||
return &ret->base;
|
||||
}
|
||||
@@ -1972,6 +1984,8 @@ zink_drm_create_screen(int fd, const struct pipe_screen_config *config)
|
||||
{
|
||||
struct zink_screen *ret = zink_internal_create_screen(config);
|
||||
|
||||
if (ret)
|
||||
ret->drm_fd = os_dupfd_cloexec(fd);
|
||||
if (ret && !ret->info.have_KHR_external_memory_fd) {
|
||||
debug_printf("ZINK: KHR_external_memory_fd required!\n");
|
||||
zink_destroy_screen(&ret->base);
|
||||
|
||||
@@ -86,6 +86,7 @@ struct zink_screen {
|
||||
|
||||
bool device_lost;
|
||||
struct sw_winsys *winsys;
|
||||
int drm_fd;
|
||||
|
||||
struct hash_table framebuffer_cache;
|
||||
simple_mtx_t framebuffer_mtx;
|
||||
|
||||
Reference in New Issue
Block a user