aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/renderer.c
AgeCommit message (Collapse)Author
2023-02-21render/swapchain: make publicSimon Ser
We've had this struct for a while. It'd be useful for compositors if they want to manage the swap chains themselves instead of being forced to use wlr_output's. Some compositors might also want to use a swapchain without an output.
2022-12-07backend/drm: store pending FB in stateSimon Ser
Instead of having a pending_fb field on the struct wlr_drm_plane, move it to struct wlr_drm_connector_state. That way, there's no risk having a stale pending FB around: the state doesn't survive across tests and commits. The cursor is a special case because it's disconnected from the atomic state: the wlr_backend_impl.set_cursor hook sets the cursor for the next commit. Move the field to wlr_drm_connector.cursor_pending_fb.
2022-10-18backend/drm: log failures in drm_surface_blit()Simon Ser
Can make issues like [1] easier to debug. [1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3451
2022-05-26backend/drm: fix crash in init_drm_surfaceSimon Ser
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3434
2022-05-25backend/drm: remove wlr_drm_surface.{width,height}Simon Ser
This information is stored in wlr_swapchain, no need to duplicate it.
2021-12-14backend/drm: use drmCloseBufferHandleSimon Ser
This has been added in [1] and allows us to close buffer handles without manually calling drmIoctl. [1]: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/192
2021-11-29backend/drm: poison buffers which cannot be scanned outSimon Ser
Rather than repeatedly trying to import DMA-BUFs which cannot be scanned out, mark the failed ones with a special "poison" marker. Inspired from [1]. [1]: https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/731
2021-11-26backend/drm: fail on explicit modifier in drmModeAddFB2Simon Ser
drmModeAddFB2 doesn't support explicit modifiers. Only accept INVALID which indicates an implicit modifier and LINEAR which may indicate that GBM_BO_USE_LINEAR has been used.
2021-11-26Require INVALID for implicit format modifiersSimon Ser
See [1] for the motivation. [1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/75
2021-11-17Remove support for DMA-BUF flagsSimon Ser
They are never used in practice, which makes all of our flag handling effectively dead code. Also, APIs such as KMS don't provide a good way to deal with the flags. Let's just fail the DMA-BUF import when clients provide flags.
2021-10-29backend/drm: get rid of BO handle tableSimon Ser
The BO handle table exists to avoid double-closing a BO handle, which aren't reference-counted by the kernel. But if we can guarantee that there is only ever a single ref for each BO handle, then we don't need the BO handle table anymore. This is possible if we create the handle right before the ADDFB2 IOCTL, and close the handle right after. The handles are very short-lived and we don't need to track their lifetime. Because of multi-planar FBs, we need to be a bit careful: some FB planes might share the same handle. But with a small check, it's easy to avoid double-closing the same handle (which wouldn't be a big deal anyways). There's one gotcha though: drmModeSetCursor2 takes a BO handle as input. Saving the handles until drmModeSetCursor2 time would require us to track BO handle lifetimes, so we wouldn't be able to get rid of the BO handle table. As a workaround, use drmModeGetFB to turn the FB ID back to a BO handle, call drmModeSetCursor2 and then immediately close the BO handle. The overhead should be minimal since these IOCTLs are pretty cheap. Closes: https://github.com/swaywm/wlroots/issues/3164
2021-10-01Revert "backend/drm: fail on explicit modifier in drmModeAddFB2"Simon Ser
This reverts commit d6be1d68b7d0542efa4dc2d19d57531484fe330a.
2021-10-01backend/drm: fail on explicit modifier in drmModeAddFB2Simon Ser
drmModeAddFB2 doesn't support explicit modifiers. Only accept INVALID which indicates an implicit modifier and LINEAR which may indicate that GBM_BO_USE_LINEAR has been used.
2021-08-25backend/drm: introduce wlr_drm_bo_handle_tableSimon Ser
Using GBM to import DRM dumb buffers tends to not work well. By using GBM we're calling some driver-specific functions in Mesa. These functions check whether Mesa can work with the buffer. Sometimes Mesa has requirements which differ from DRM dumb buffers and the GBM import will fail (e.g. on amdgpu). Instead, drop GBM and use drmPrimeFDToHandle directly. But there's a twist: BO handles are not ref'counted by the kernel and need to be ref'counted in user-space [1]. libdrm usually performs this bookkeeping and is used under-the-hood by Mesa. We can't re-use libdrm for this task without using driver-specific APIs. So let's just re-implement the ref'counting logic in wlroots. The wlroots implementation is inspired from amdgpu's in libdrm [2]. Closes: https://github.com/swaywm/wlroots/issues/2916 [1]: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/110 [2]: https://gitlab.freedesktop.org/mesa/drm/-/blob/1a4c0ec9aea13211997f982715fe5ffcf19dd067/amdgpu/handle_table.c
2021-08-25Move allocator stuff into new directorySimon Ser
Add render/allocator/ and include/render/allocator/ to hold everything allocator-related.
2021-08-17backend/drm: use addon for wlr_drm_fbSimon Ser
2021-07-28backend/drm: stop initializing renderer for parent backendSimon Ser
Unless we're dealing with a multi-GPU setup and the backend being initialized is secondary, we don't need a renderer nor an allocator. Stop initializing these.
2021-07-28backend/drm: drop drm_surface_{make,unset}_currentSimon Ser
2021-07-28backend/drm: remove primary swapchainSimon Ser
We can't nuke it completely, we still need it for multi-GPU.
2021-07-22render/wlr_texture: put wlr_texture_from_buffer into the public APISimon Zeni
2021-07-08backend/drm: stop using drm_surface_make_current in drm_surface_blitSimon Ser
drm_surface_make_current and drm_surface_unset_current set implicit state and are an unnecessary mid-layer. Prefer to use directly wlr_renderer_begin_with_buffer, which automatically unsets the back buffer on wlr_renderer_end. I'd like to get rid of drm_surface_make_current once we stop using it for the primary swapchain.
2021-06-09render: drop wlr_ prefix from wlr_renderer_bind_bufferSimon Ser
Make it clear this function is a private wlroots API and will stay that way.
2021-06-02output: take a wlr_buffer in set_cursorSimon Ser
Instead of passing a wlr_texture to the backend, directly pass a wlr_buffer. Use get_cursor_size and get_cursor_formats to create a wlr_buffer that can be used as a cursor. We don't want to pass a wlr_texture because we want to remove as many rendering bits from the backend as possible.
2021-06-02backend/drm: introduce drm_plane_pick_render_formatSimon Ser
This is a new helper function to pick a render format suitable for a plane. The next commit will use it to initialize the cursor multi-GPU surface.
2021-06-02backend/drm: remove format arg from drm_plane_init_surfaceSimon Ser
This was always set to ARGB8888.
2021-05-17backend/drm: use wlr_texture_from_bufferSimon Ser
2021-04-29backend/drm: fix allocator DRM FD on multi-GPU setupsSimon Ser
On multi-GPU setups, there is a primary DRM backend and secondary DRM backends. wlr_backend_get_drm_fd will always return the parent DRM FD even on secondary backends, so that users always use the primary device for rendering. However, for our internal rendering we want to use the secondary device. Use allocator_autocreate_with_drm_fd to make sure the allocator will create buffers on the secondary device. We do something similar to ensure our internal rendering will happen on the secondary device with renderer_autocreate_with_drm_fd. Fixes: cc1b66364cc9 ("backend: use wlr_allocator_autocreate")
2021-04-29render: remove wlr_ prefix from wlr_renderer_autocreate_with_drm_fdSimon Ser
This function is only required because the DRM backend still needs to perform multi-GPU magic under-the-hood. Remove the wlr_ prefix to make it clear it's not a candidate for being made public.
2021-04-29backend/drm: reword wlr_renderer failure messageSimon Ser
Remove the assumption about EGL.
2021-04-28backend: use wlr_allocator_autocreateSimon Zeni
2021-04-28render/gbm_allocator: make wlr_gbm_allocator_create return a wlr_allocatorSimon Zeni
2021-04-15render: rename get_dmabuf_render_formats into get_render_formatsSimon Zeni
2021-04-06backend/drm: reject DMA-BUFs with flagsSimon Ser
We cannot scan-out DMA-BUFs with any flag right now.
2021-04-06backend/drm: improve logs in drm_fb_createSimon Ser
Downgrade errors to DEBUG level, because drm_fb_create is used in test_buffer, so errors aren't always fatal. Add ERROR logs at call sites where a failure is fatal, to make it clear something wrong happened.
2021-03-25backend/drm: use pixel format table in rendererSimon Zeni
2021-03-16Fix buffer blit matricesSimon Ser
There was a missing wlr_matrix_scale call, so we ended up with black frames. Closes: https://github.com/swaywm/wlroots/issues/2780
2021-03-10output: improve transform matrix calculationSimon Zeni
Compute only the transform matrix in the output. The projection matrix will be calculated inside the gles2 renderer when we start rendering. The goal is to help the pixman rendering process.
2021-02-18backend: add error messages in attach_render implsSimon Ser
2021-01-24backend/drm: don't blit in drm_fb_importSimon Ser
Instead blit in drm_plane_lock_surface. This makes drm_fb_import simpler and better fits its name.
2021-01-24backend/drm: simplify drm_fb_lock_surfaceSimon Ser
Make it take a plane instead, and rename to drm_plane_lock_surface.
2021-01-16backend/drm: use local DRM FD for wlr_rendSimon Ser
The new wlr_renderer_autocreate API is great for compositors, however it causes some issues with DRM multi-GPU support. A DRM child backend wants the compositor to use the parent GPU, so it exposes the parent's DRM FD in get_drm_fd. However, in order to be able to perform multi-GPU buffer copies, the child DRM backend still needs to create a local renderer. Use the new private wlr_renderer_autocreate_with_drm_fd function to avoid creating a renderer for the parent GPU. Fixes: e128e6c08dc0 ("render: drop egl parameters from wlr_renderer_autocreate")
2021-01-16render/gles2: make EGL context current in bind_bufferSimon Ser
Instead of requiring callers to manually make the EGL context current before binding a buffer and unsetting it after unbinding a buffer, do it inside wlr_renderer_bind_buffer. This hides renderer-specific implementation details inside the wlr_renderer interface. Non-GLES2 renderers may not use EGL. This removes all EGL dependencies from the backends. References: https://github.com/swaywm/wlroots/issues/2618 References: https://github.com/swaywm/wlroots/pull/2615#issuecomment-756687006
2021-01-16render: remove egl include from wlr_rendererSimon Zeni
2021-01-16render: drop egl parameters from wlr_renderer_autocreateSimon Zeni
2021-01-12render/egl: remove surface and buffer age args from make_currentSimon Ser
These aren't used anymore.
2021-01-10backend/drm: re-use FBsSimon Ser
Instead of importing buffers to GBM and KMS at each frame, cache them and re-use them while the wlr_buffer is alive. This is the same as [1] and [2] but for the DRM backend. [1]: https://github.com/swaywm/wlroots/pull/2538 [2]: https://github.com/swaywm/wlroots/pull/2539
2021-01-10backend/drm: only keep track of local bufferSimon Ser
Stop keeping track of buffers on the parent GPU when multi-GPU is used. This removes support for export_dmabuf on secondary GPUs, but renderer v6 will bring this back by managing the swapchains in wlr_output instead of the backends.
2021-01-10backend/drm: add wlr_drm_buf.local_wlr_bufSimon Ser
2021-01-10backend/drm: introduce drm_fb_createSimon Ser
2021-01-10backend/drm: make wlr_drm_plane.{pending,queued,current}_fb pointersSimon Ser
This will be useful once we start re-using wlr_drm_fb.