Merge branch 'renderer-drm-devid' into 'master'

render: replace wlr_renderer_get_drm_fd() with drm_dev_id

See merge request wlroots/wlroots!4368
This commit is contained in:
Simon Ser 2024-08-04 06:57:04 +00:00
commit 779f37e846
15 changed files with 177 additions and 225 deletions

View file

@ -53,11 +53,11 @@ struct wlr_egl_context {
};
/**
* Initializes an EGL context for the given DRM FD.
* Initializes an EGL context for the given DRM device ID.
*
* Will attempt to load all possibly required API functions.
*/
struct wlr_egl *wlr_egl_create_with_drm_fd(int drm_fd);
struct wlr_egl *wlr_egl_create_with_drm_dev_id(dev_t dev_id);
/**
* Frees all related EGL resources, makes the context not-current and
@ -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;
@ -63,10 +61,10 @@ struct wlr_vk_device {
struct wlr_drm_format_set shm_texture_formats;
};
// Tries to find the VkPhysicalDevice for the given drm fd.
// Tries to find the VkPhysicalDevice for the given DRM device ID.
// 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);
VkPhysicalDevice vulkan_find_drm_phdev(struct wlr_vk_instance *ini, dev_t dev_id);
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,
@ -262,6 +260,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;

View file

@ -10,7 +10,6 @@
#define WLR_RENDER_GLES2_H
#include <GLES2/gl2.h>
#include <wlr/render/wlr_renderer.h>
struct wlr_egl;
@ -28,7 +27,7 @@ struct wlr_egl;
* render pass can't be used before the nested render pass is submitted.
*/
struct wlr_renderer *wlr_gles2_renderer_create_with_drm_fd(int drm_fd);
struct wlr_renderer *wlr_gles2_renderer_create_with_drm_dev_id(dev_t dev_id);
struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl);
struct wlr_egl *wlr_gles2_renderer_get_egl(struct wlr_renderer *renderer);

View file

@ -25,7 +25,6 @@ struct wlr_renderer_impl {
const struct wlr_drm_format_set *(*get_render_formats)(
struct wlr_renderer *renderer);
void (*destroy)(struct wlr_renderer *renderer);
int (*get_drm_fd)(struct wlr_renderer *renderer);
struct wlr_texture *(*texture_from_buffer)(struct wlr_renderer *renderer,
struct wlr_buffer *buffer);
struct wlr_render_pass *(*begin_buffer_pass)(struct wlr_renderer *renderer,

View file

@ -18,7 +18,7 @@ struct wlr_vk_image_attribs {
VkFormat format;
};
struct wlr_renderer *wlr_vk_renderer_create_with_drm_fd(int drm_fd);
struct wlr_renderer *wlr_vk_renderer_create_with_drm_dev_id(dev_t dev_id);
VkInstance wlr_vk_renderer_get_instance(struct wlr_renderer *renderer);
VkPhysicalDevice wlr_vk_renderer_get_physical_device(struct wlr_renderer *renderer);

View file

@ -29,6 +29,8 @@ struct wlr_renderer {
// Capabilities required for the buffer used as a render target (bitmask of
// enum wlr_buffer_cap)
uint32_t render_buffer_caps;
// DRM device used for rendering, if any
const dev_t *drm_dev_id;
struct {
struct wl_signal destroy;
@ -85,13 +87,6 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
bool wlr_renderer_init_wl_shm(struct wlr_renderer *r,
struct wl_display *wl_display);
/**
* Obtains the FD of the DRM device used for rendering, or -1 if unavailable.
*
* The caller doesn't have ownership of the FD, it must not close it.
*/
int wlr_renderer_get_drm_fd(struct wlr_renderer *r);
/**
* Destroys the renderer.
*