mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-03-18 05:34:29 -04: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;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool vulkan_sync_foreign_texture(struct wlr_vk_texture *texture,
|
static bool buffer_export_sync_file(struct wlr_vk_renderer *renderer, struct wlr_buffer *buffer,
|
||||||
int sync_file_fds[static WLR_DMABUF_MAX_PLANES]) {
|
uint32_t flags, int sync_file_fds[static WLR_DMABUF_MAX_PLANES]) {
|
||||||
struct wlr_vk_renderer *renderer = texture->renderer;
|
|
||||||
|
|
||||||
struct wlr_dmabuf_attributes dmabuf = {0};
|
struct wlr_dmabuf_attributes dmabuf = {0};
|
||||||
if (!wlr_buffer_get_dmabuf(texture->buffer, &dmabuf)) {
|
if (!wlr_buffer_get_dmabuf(buffer, &dmabuf)) {
|
||||||
wlr_log(WLR_ERROR, "Failed to get texture DMA-BUF");
|
wlr_log(WLR_ERROR, "wlr_buffer_get_dmabuf() failed");
|
||||||
return false;
|
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++) {
|
for (int i = 0; i < dmabuf.n_planes; i++) {
|
||||||
struct pollfd pollfd = {
|
struct pollfd pollfd = {
|
||||||
.fd = dmabuf.fd[i],
|
.fd = dmabuf.fd[i],
|
||||||
.events = POLLIN,
|
.events = (flags & DMA_BUF_SYNC_WRITE) ? POLLOUT : POLLIN,
|
||||||
};
|
};
|
||||||
int timeout_ms = 1000;
|
int timeout_ms = 1000;
|
||||||
int ret = poll(&pollfd, 1, timeout_ms);
|
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++) {
|
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) {
|
if (sync_file_fd < 0) {
|
||||||
wlr_log(WLR_ERROR, "Failed to extract DMA-BUF fence");
|
wlr_log(WLR_ERROR, "Failed to extract DMA-BUF fence");
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1013,6 +1011,11 @@ bool vulkan_sync_foreign_texture(struct wlr_vk_texture *texture,
|
||||||
return true;
|
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) {
|
static bool buffer_import_sync_file(struct wlr_buffer *buffer, uint32_t flags, int sync_file_fd) {
|
||||||
struct wlr_dmabuf_attributes dmabuf = {0};
|
struct wlr_dmabuf_attributes dmabuf = {0};
|
||||||
if (!wlr_buffer_get_dmabuf(buffer, &dmabuf)) {
|
if (!wlr_buffer_get_dmabuf(buffer, &dmabuf)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue