render: replace wlr_renderer_get_drm_fd() with drm_dev_id

wlr_renderer_get_drm_fd() forces the renderer to open the DRM node
and keep the FD around for no good reason. Instead, use dev_t to
refer to a DRM device.

This also removes footguns related to FD ownership.
This commit is contained in:
Simon Ser 2023-10-04 12:40:34 +02:00
parent ebef710746
commit 986a2d9f66
13 changed files with 91 additions and 146 deletions

View file

@ -88,7 +88,10 @@ const struct wlr_drm_format_set *wlr_egl_get_dmabuf_render_formats(
*/
bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImageKHR image);
int wlr_egl_dup_drm_fd(struct wlr_egl *egl);
/**
* Get the DRM device ID used by EGL.
*/
bool wlr_egl_get_drm_dev_id(struct wlr_egl *egl, dev_t *devid);
/**
* Restore EGL context that was previously saved using wlr_egl_save_current().

View file

@ -41,8 +41,8 @@ struct wlr_gles2_tex_shader {
struct wlr_gles2_renderer {
struct wlr_renderer wlr_renderer;
dev_t drm_dev_id;
struct wlr_egl *egl;
int drm_fd;
struct wlr_drm_format_set shm_texture_formats;

View file

@ -38,8 +38,6 @@ struct wlr_vk_device {
VkPhysicalDevice phdev;
VkDevice dev;
int drm_fd;
bool implicit_sync_interop;
bool sampler_ycbcr_conversion;
@ -66,7 +64,7 @@ struct wlr_vk_device {
// Tries to find the VkPhysicalDevice for the given drm fd.
// Might find none and return VK_NULL_HANDLE.
VkPhysicalDevice vulkan_find_drm_phdev(struct wlr_vk_instance *ini, int drm_fd);
int vulkan_open_phdev_drm_fd(VkPhysicalDevice phdev);
bool vulkan_get_phdev_drm_dev_id(VkPhysicalDevice phdev, dev_t *dev_id);
// Creates a device for the given instance and physical device.
struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini,
@ -231,6 +229,7 @@ struct wlr_vk_renderer {
struct wlr_renderer wlr_renderer;
struct wlr_backend *backend;
struct wlr_vk_device *dev;
dev_t drm_dev_id;
VkCommandPool command_pool;