c/client: Mark consumed FDs as invalid

This commit is contained in:
Jakob Bornecrantz 2020-05-30 16:56:33 +01:00
parent 9ec0b559d4
commit 5b0085f1c1
3 changed files with 13 additions and 2 deletions

View file

@ -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`.

View file

@ -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,

View file

@ -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;
}