#include "wsi_common_private.h"
#include "drm-uapi/drm_fourcc.h"
#include "util/macros.h"
+#include "util/os_file.h"
#include "util/xmlconfig.h"
#include "vk_util.h"
memset(chain, 0, sizeof(*chain));
+ vk_object_base_init(NULL, &chain->base, VK_OBJECT_TYPE_SWAPCHAIN_KHR);
+
chain->wsi = wsi;
chain->device = device;
chain->alloc = *pAllocator;
&chain->alloc);
}
vk_free(&chain->alloc, chain->cmd_pools);
+
+ vk_object_base_finish(&chain->base);
}
static uint32_t
if (p == 0) {
image->fds[p] = fd;
} else {
- image->fds[p] = dup(fd);
+ image->fds[p] = os_dupfd_cloexec(fd);
if (image->fds[p] == -1) {
for (uint32_t i = 0; i < p; i++)
close(image->fds[i]);
VkSwapchainKHR _swapchain,
const VkAllocationCallbacks *pAllocator)
{
- WSI_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
+ VK_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
if (!swapchain)
return;
uint32_t *pSwapchainImageCount,
VkImage *pSwapchainImages)
{
- WSI_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
+ VK_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
VK_OUTARRAY_MAKE(images, pSwapchainImages, pSwapchainImageCount);
for (uint32_t i = 0; i < swapchain->image_count; i++) {
const VkAcquireNextImageInfoKHR *pAcquireInfo,
uint32_t *pImageIndex)
{
- WSI_FROM_HANDLE(wsi_swapchain, swapchain, pAcquireInfo->swapchain);
+ VK_FROM_HANDLE(wsi_swapchain, swapchain, pAcquireInfo->swapchain);
VkResult result = swapchain->acquire_next_image(swapchain, pAcquireInfo,
pImageIndex);
if (result != VK_SUCCESS)
return result;
+ if (wsi->set_memory_ownership) {
+ VkDeviceMemory mem = swapchain->get_wsi_image(swapchain, *pImageIndex)->memory;
+ wsi->set_memory_ownership(swapchain->device, mem, true);
+ }
+
if (pAcquireInfo->semaphore != VK_NULL_HANDLE &&
wsi->signal_semaphore_for_memory != NULL) {
struct wsi_image *image =
vk_find_struct_const(pPresentInfo->pNext, PRESENT_REGIONS_KHR);
for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
- WSI_FROM_HANDLE(wsi_swapchain, swapchain, pPresentInfo->pSwapchains[i]);
+ VK_FROM_HANDLE(wsi_swapchain, swapchain, pPresentInfo->pSwapchains[i]);
uint32_t image_index = pPresentInfo->pImageIndices[i];
VkResult result;
if (result != VK_SUCCESS)
goto fail_present;
+ if (wsi->set_memory_ownership) {
+ VkDeviceMemory mem = swapchain->get_wsi_image(swapchain, image_index)->memory;
+ wsi->set_memory_ownership(swapchain->device, mem, false);
+ }
+
fail_present:
if (pPresentInfo->pResults != NULL)
pPresentInfo->pResults[i] = result;