aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/renderer.c
AgeCommit message (Collapse)Author
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.
2021-01-07remove unnecessary egl includesSimon Zeni
2021-01-07backend: remove wlr_egl from all backendsSimon Zeni
2021-01-06render: remove EGL config and visual from wlr_renderer_autocreateSimon Ser
This isn't used anymore by any backend. Some examples still provide an EGL config to wlr_egl_init, so we can't drop it yet there.
2020-12-30Remove wlr_create_renderer_func_tSimon Ser
This callback allowed compositors to customize the EGL config used by the renderer. However with renderer v6 EGL configs aren't used anymore. Instead, buffers are allocated via GBM and GL FBOs are rendered to. So customizing the EGL config is a no-op.
2020-12-30backend/drm: remove special linear case for cursor planeSimon Ser
We now properly mark the cursor plane's formats as linear-only, and we now have a version of wlr_drm_format_intersect that handles the case of linear-only formats and implicit modifiers. We can remove the special drm_plane_init_surface flag we had for cursor planes. This also allows us to use a non-linear layout for cursor planes on drivers that support it. Tested on amdgpu GFX9.
2020-12-30backend/drm: extract linear format creation into functionSimon Ser
Simplifies error handling.
2020-12-22backend/drm: error on size mismatch in drm_surface_blitSimon Ser
2020-12-22backend/drm: remove drm_fb_acquireSimon Ser
Instead, import the buffer into GBM and KMS in drm_fb_import. Also move the multi-GPU copy there if necessary.
2020-12-22backend/drm: make drm_fb_acquire return a FB IDSimon Ser
2020-12-22backend/drm: drop export_drm_boSimon Ser
Not used anymore.
2020-12-22backend/drm: don't save texture in gbm_bo user dataSimon Ser
The GBM BO is destroyed when released anyways.
2020-12-18backend/drm: use wlr_drm_format_{create,add}Simon Ser
Instead of manually allocating and initializing the structs, use the new wlr_drm_format helpers.
2020-12-15backend/drm: dup FD before wlr_gbm_allocator_createSimon Ser
The GBM allocator takes ownership of the DRM FD.