mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-15 06:59:43 -05:00
render/timeline: add wlr_render_timeline_import_dmabuf
Same as wlr_render_timeline_import_sync_file, but takes a DMA-BUF as argument. Depends on [1]. [1]: https://lore.kernel.org/dri-devel/20210610210925.642582-5-jason@jlekstrand.net/
This commit is contained in:
parent
5a1f18666a
commit
7a661e4c38
2 changed files with 42 additions and 1 deletions
|
|
@ -56,5 +56,16 @@ int wlr_render_timeline_export_sync_file(struct wlr_render_timeline *timeline,
|
||||||
*/
|
*/
|
||||||
bool wlr_render_timeline_import_sync_file(struct wlr_render_timeline *timeline,
|
bool wlr_render_timeline_import_sync_file(struct wlr_render_timeline *timeline,
|
||||||
uint64_t dst_point, int sync_file_fd);
|
uint64_t dst_point, int sync_file_fd);
|
||||||
|
/**
|
||||||
|
* Import a timeline point from a DMA-BUF's implicit fence.
|
||||||
|
*
|
||||||
|
* The provided timeline point will be signalled when the DMA-BUF's producer
|
||||||
|
* has finished their write operations.
|
||||||
|
*
|
||||||
|
* This allows inter-operation with other APIs which don't support drm_syncobj
|
||||||
|
* nor sync_file yet.
|
||||||
|
*/
|
||||||
|
bool wlr_render_timeline_import_dmabuf(struct wlr_render_timeline *timeline,
|
||||||
|
uint64_t dst_point, int dmabuf_fd);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#include <xf86drm.h>
|
#include <linux/dma-buf.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <xf86drm.h>
|
||||||
#include <wlr/render/timeline.h>
|
#include <wlr/render/timeline.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
|
||||||
|
|
@ -84,3 +86,31 @@ out:
|
||||||
drmSyncobjDestroy(timeline->drm_fd, syncobj_handle);
|
drmSyncobjDestroy(timeline->drm_fd, syncobj_handle);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DMA_BUF_IOCTL_EXPORT_SYNC_FILE
|
||||||
|
|
||||||
|
struct dma_buf_export_sync_file {
|
||||||
|
__u32 flags;
|
||||||
|
__s32 fd;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define DMA_BUF_IOCTL_EXPORT_SYNC_FILE _IOWR(DMA_BUF_BASE, 2, struct dma_buf_export_sync_file)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool wlr_render_timeline_import_dmabuf(struct wlr_render_timeline *timeline,
|
||||||
|
uint64_t dst_point, int dmabuf_fd) {
|
||||||
|
struct dma_buf_export_sync_file ioctl_data = {
|
||||||
|
.flags = DMA_BUF_SYNC_READ,
|
||||||
|
};
|
||||||
|
if (drmIoctl(dmabuf_fd, DMA_BUF_IOCTL_EXPORT_SYNC_FILE,
|
||||||
|
&ioctl_data) != 0) {
|
||||||
|
wlr_log_errno(WLR_ERROR, "drmIoctl(EXPORT_SYNC_FILE) failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ok = wlr_render_timeline_import_sync_file(timeline,
|
||||||
|
ioctl_data.fd, dst_point);
|
||||||
|
close(ioctl_data.fd);
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue