mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-02-27 01:40:49 -05:00
render/vulkan: introduce buffer_export_sync_file()
Same as buffer_import_sync_file(), but for the export side.
This commit is contained in:
parent
43b37e34d6
commit
ff4ce12179
1 changed files with 11 additions and 8 deletions
|
|
@ -968,13 +968,11 @@ static struct wlr_vk_render_buffer *get_render_buffer(
|
|||
return buffer;
|
||||
}
|
||||
|
||||
bool vulkan_sync_foreign_texture(struct wlr_vk_texture *texture,
|
||||
int sync_file_fds[static WLR_DMABUF_MAX_PLANES]) {
|
||||
struct wlr_vk_renderer *renderer = texture->renderer;
|
||||
|
||||
static bool buffer_export_sync_file(struct wlr_vk_renderer *renderer, struct wlr_buffer *buffer,
|
||||
uint32_t flags, int sync_file_fds[static WLR_DMABUF_MAX_PLANES]) {
|
||||
struct wlr_dmabuf_attributes dmabuf = {0};
|
||||
if (!wlr_buffer_get_dmabuf(texture->buffer, &dmabuf)) {
|
||||
wlr_log(WLR_ERROR, "Failed to get texture DMA-BUF");
|
||||
if (!wlr_buffer_get_dmabuf(buffer, &dmabuf)) {
|
||||
wlr_log(WLR_ERROR, "wlr_buffer_get_dmabuf() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -984,7 +982,7 @@ bool vulkan_sync_foreign_texture(struct wlr_vk_texture *texture,
|
|||
for (int i = 0; i < dmabuf.n_planes; i++) {
|
||||
struct pollfd pollfd = {
|
||||
.fd = dmabuf.fd[i],
|
||||
.events = POLLIN,
|
||||
.events = (flags & DMA_BUF_SYNC_WRITE) ? POLLOUT : POLLIN,
|
||||
};
|
||||
int timeout_ms = 1000;
|
||||
int ret = poll(&pollfd, 1, timeout_ms);
|
||||
|
|
@ -1001,7 +999,7 @@ bool vulkan_sync_foreign_texture(struct wlr_vk_texture *texture,
|
|||
}
|
||||
|
||||
for (int i = 0; i < dmabuf.n_planes; i++) {
|
||||
int sync_file_fd = dmabuf_export_sync_file(dmabuf.fd[i], DMA_BUF_SYNC_READ);
|
||||
int sync_file_fd = dmabuf_export_sync_file(dmabuf.fd[i], flags);
|
||||
if (sync_file_fd < 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to extract DMA-BUF fence");
|
||||
return false;
|
||||
|
|
@ -1013,6 +1011,11 @@ bool vulkan_sync_foreign_texture(struct wlr_vk_texture *texture,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool vulkan_sync_foreign_texture(struct wlr_vk_texture *texture,
|
||||
int sync_file_fds[static WLR_DMABUF_MAX_PLANES]) {
|
||||
return buffer_export_sync_file(texture->renderer, texture->buffer, DMA_BUF_SYNC_READ, sync_file_fds);
|
||||
}
|
||||
|
||||
static bool buffer_import_sync_file(struct wlr_buffer *buffer, uint32_t flags, int sync_file_fd) {
|
||||
struct wlr_dmabuf_attributes dmabuf = {0};
|
||||
if (!wlr_buffer_get_dmabuf(buffer, &dmabuf)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue