wayland direct scan-out on kmsro devices (imx-drm with etnaviv on i.MX6)
System information
- OS: custom build from yocto
- GPU: Vivante GC2000 rev 5108 (Etnaviv)
- Kernel version: 5.15.55
- Mesa version: 22.3.5
- Xserver version (if applicable): -
- Desktop manager and compositor: Compositor based on smithay
Issue
As discussed in #dri-devel I am trying to get direct scan-out of EGL clients under wayland to work on the i.MX6.
When running glmark2-es2-wayland
the buffers will first use a modifier unsuited for scan-out and are rejected as expected.
As soon as the compositor provides a scan-out tranche the client switches to linear. The linear buffers can be successfully imported through gbm but drmModeAddFB2
fails for the imported bo.
Relevant log entry from dmesg:
imx-drm display-subsystem: [drm:drm_gem_fb_init_with_funcs] Failed to lookup GEM object
I am not familiar with the inner workings but I tried to analyze what is going on and this is what I believe to have found out:
It seems that to get a scan-out able buffer from etnaviv the following condition in etna_resource_alloc
has to be true:
unlikely(templat->bind & PIPE_BIND_SCANOUT) && screen->ro
This will then use kmsro by calling renderonly_scanout_for_resource
to get a scan-out buffer which the driver imports
for rendering.
So how to make that to evaluate to true
:
- First
PIPE_BIND_SCANOUT
has to be set, this is done by passing__DRI_IMAGE_USE_SCANOUT
toloader_dri_create_image
inplatform_wayland.c
- kmsro has to be used to have a
screen->ro
, this is done bykmsro_drm_screen_create
inkmsro_drm_winsys.c
A requirement for actually receiving PIPE_BIND_SCANOUT
in etna_resource_alloc
is the use of wl_dmabuf
and a scan-out tranche in the wayland platform.
kmsro
will only be used when the compositor passes a device that will result in the loader creating kmsro. In case of the i.mx6 the imx-drm
device node.
But it seems that these two requirements are contradictory, if the main device passed to the wayland platform is not a render node the dmabuf feedback will be ignored as it falls back to wl_drm
. If a render node is passed the feedback is used and the scanout flag is set but kmsro will not be used.
Importing and scanning out buffers imported from gstreamer waylandsink
works as expected.
I found #5099 (closed), but that has been fixed by !12018 (merged).