yuq / mesa-lima

Deprecated, new place: https://gitlab.freedesktop.org/lima
https://github.com/yuq/mesa-lima/wiki
165 stars 17 forks source link

lima: add resource_from_handle support #2

Closed enunes closed 6 years ago

enunes commented 6 years ago

Defines lima_resource_from_handle and adds resource_from_handle support. This is to be used to share a dmabuf with a kms display driver so that we can use lima to render to a buffer being output to a display.

This targets the Allwinner A20 support with the Display Engine (sun4i_drm) driver.

Signed-off-by: Erico Nunes nunes.erico@gmail.com

enunes commented 6 years ago

This was finally tested with this application: https://github.com/enunes/mesa-test-programs/blob/master/gbm-bo-test.c It is also necessary to have the linux-lima patches to enable prime support there.

enunes commented 6 years ago

Before I send in a modified version of this patch, can you give some more details on how the end solution should look like for lima? If I understand correctly, lima_bo_import() mostly overlaps with lima_screen_bo_from_handle(), so I should probably add some lima_bo_handle_type_fd support to lima_bo_import() and kill lima_screen_bo_from_handle() in the next revision. lima_resource_from_handle() probably stays mostly as it is but should end up calling lima_bo_import() instead now. Did I understand it correctly?

Also, should I care about the libdrm version of lima_bo_import?

yuq commented 6 years ago

Yes, exactly. You can also reference the amdgpu_bo_import() in libdrm.

The libdrm_lima is deprecated (all functions are moved into mesa), so no need to worry about the libdrm lima_bo_import. Now the upstream libdrm is OK for lima.

enunes commented 6 years ago

I just pushed a new revision based on the amdgpu_bo_import implementation. I left out the gem_flink related changes since I'm not sure how to test them right now, so I only ported/implemented the things related to dma_buf_fd. Retested this on the A20 with the display and it works as well as the previous revision.