From 5b0085f1c132881d224f50f04400c8971c9f6c3f Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 30 May 2020 16:56:33 +0100 Subject: [PATCH] c/client: Mark consumed FDs as invalid --- doc/changes/compositor/mr.359.3.md | 3 +++ src/xrt/compositor/client/comp_gl_client.c | 6 +++++- src/xrt/compositor/client/comp_vk_client.c | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 doc/changes/compositor/mr.359.3.md diff --git a/doc/changes/compositor/mr.359.3.md b/doc/changes/compositor/mr.359.3.md new file mode 100644 index 000000000..576427dad --- /dev/null +++ b/doc/changes/compositor/mr.359.3.md @@ -0,0 +1,3 @@ +client: When we give a image fd to the either OpenGL or Vulkan it is consumed +and can not be rused. So make sure that it is set to an invalid fd value on the +`xrt_image_fd` on the owning `xrt_swapchain_fd`. diff --git a/src/xrt/compositor/client/comp_gl_client.c b/src/xrt/compositor/client/comp_gl_client.c index 892116543..0c328d2d8 100644 --- a/src/xrt/compositor/client/comp_gl_client.c +++ b/src/xrt/compositor/client/comp_gl_client.c @@ -1,4 +1,4 @@ -// Copyright 2019, Collabora, Ltd. +// Copyright 2019-2020, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -296,6 +296,10 @@ client_gl_swapchain_create(struct xrt_compositor *xc, glImportMemoryFdEXT( sc->base.memory[i], sc->xscfd->images[i].size, GL_HANDLE_TYPE_OPAQUE_FD_EXT, sc->xscfd->images[i].fd); + + // We have consumed this fd now, make sure it's not freed again. + sc->xscfd->images[i].fd = -1; + if (array_size == 1) { glTextureStorageMem2DEXT(sc->base.images[i], mip_count, (GLuint)format, width, height, diff --git a/src/xrt/compositor/client/comp_vk_client.c b/src/xrt/compositor/client/comp_vk_client.c index e7f8ab2ac..bfd25e801 100644 --- a/src/xrt/compositor/client/comp_vk_client.c +++ b/src/xrt/compositor/client/comp_vk_client.c @@ -1,4 +1,4 @@ -// Copyright 2019, Collabora, Ltd. +// Copyright 2019-2020, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -271,6 +271,10 @@ client_vk_swapchain_create(struct xrt_compositor *xc, &c->vk, bits, format, width, height, array_size, mip_count, &sc->xscfd->images[i], &sc->base.images[i], &sc->base.mems[i]); + + // We have consumed this fd now, make sure it's not freed again. + sc->xscfd->images[i].fd = -1; + if (ret != VK_SUCCESS) { return NULL; }