mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-21 14:20:29 +01:00
vulkan/wsi: Close file descriptors in wsi_destroy_image
Most of the time, this is a non-issue because the WSI back-end closes them as part of handing them to the window-system and sets fds[*] to -1. The one exception here was Wayland which was closing them but leaving fds[*] pointing to bogus file descriptors. Having wsi_destroy_image close them makes clean-up easier and more reliable. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Simon Ser <contact@emersion.fr> Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16333>
This commit is contained in:
parent
ae6d32c938
commit
c72ff19a9e
5 changed files with 10 additions and 9 deletions
|
|
@ -512,6 +512,11 @@ wsi_destroy_image(const struct wsi_swapchain *chain,
|
||||||
{
|
{
|
||||||
const struct wsi_device *wsi = chain->wsi;
|
const struct wsi_device *wsi = chain->wsi;
|
||||||
|
|
||||||
|
for (int p = 0; p < image->num_planes; p++) {
|
||||||
|
if (image->fds[p] >= 0)
|
||||||
|
close(image->fds[p]);
|
||||||
|
}
|
||||||
|
|
||||||
if (image->buffer.blit_cmd_buffers) {
|
if (image->buffer.blit_cmd_buffers) {
|
||||||
for (uint32_t i = 0; i < wsi->queue_family_count; i++) {
|
for (uint32_t i = 0; i < wsi->queue_family_count; i++) {
|
||||||
wsi->FreeCommandBuffers(chain->device, chain->cmd_pools[i],
|
wsi->FreeCommandBuffers(chain->device, chain->cmd_pools[i],
|
||||||
|
|
|
||||||
|
|
@ -1136,10 +1136,6 @@ fail_handle:
|
||||||
for (unsigned int i = 0; i < image->base.num_planes; i++) {
|
for (unsigned int i = 0; i < image->base.num_planes; i++) {
|
||||||
if (image->buffer[i])
|
if (image->buffer[i])
|
||||||
wsi_display_destroy_buffer(wsi, image->buffer[i]);
|
wsi_display_destroy_buffer(wsi, image->buffer[i]);
|
||||||
if (image->base.fds[i] != -1) {
|
|
||||||
close(image->base.fds[i]);
|
|
||||||
image->base.fds[i] = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wsi_destroy_image(&chain->base, &image->base);
|
wsi_destroy_image(&chain->base, &image->base);
|
||||||
|
|
|
||||||
|
|
@ -393,12 +393,8 @@ wsi_create_native_image_mem(const struct wsi_swapchain *chain,
|
||||||
image->fds[p] = fd;
|
image->fds[p] = fd;
|
||||||
} else {
|
} else {
|
||||||
image->fds[p] = os_dupfd_cloexec(fd);
|
image->fds[p] = os_dupfd_cloexec(fd);
|
||||||
if (image->fds[p] == -1) {
|
if (image->fds[p] == -1)
|
||||||
for (uint32_t i = 0; i < p; i++)
|
|
||||||
close(image->fds[i]);
|
|
||||||
|
|
||||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,9 @@ VkResult
|
||||||
wsi_create_image(const struct wsi_swapchain *chain,
|
wsi_create_image(const struct wsi_swapchain *chain,
|
||||||
const struct wsi_image_info *info,
|
const struct wsi_image_info *info,
|
||||||
struct wsi_image *image);
|
struct wsi_image *image);
|
||||||
|
void
|
||||||
|
wsi_image_init(struct wsi_image *image);
|
||||||
|
|
||||||
void
|
void
|
||||||
wsi_destroy_image(const struct wsi_swapchain *chain,
|
wsi_destroy_image(const struct wsi_swapchain *chain,
|
||||||
struct wsi_image *image);
|
struct wsi_image *image);
|
||||||
|
|
|
||||||
|
|
@ -1167,6 +1167,7 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain,
|
||||||
image->base.drm_modifier >> 32,
|
image->base.drm_modifier >> 32,
|
||||||
image->base.drm_modifier & 0xffffffff);
|
image->base.drm_modifier & 0xffffffff);
|
||||||
close(image->base.fds[i]);
|
close(image->base.fds[i]);
|
||||||
|
image->base.fds[i] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
image->buffer =
|
image->buffer =
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue