Commit e9200b18 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winevulkan: Return VK_SUBOPTIMAL_KHR from vkAcquireNextImage(2)KHR after resize.

parent 010b497c
...@@ -208,6 +208,8 @@ USER_DRIVER_FUNCS = { ...@@ -208,6 +208,8 @@ USER_DRIVER_FUNCS = {
# functions for which the unix thunk is manually implemented # functions for which the unix thunk is manually implemented
MANUAL_UNIX_THUNKS = { MANUAL_UNIX_THUNKS = {
"vkAcquireNextImage2KHR",
"vkAcquireNextImageKHR",
"vkAllocateCommandBuffers", "vkAllocateCommandBuffers",
"vkAllocateMemory", "vkAllocateMemory",
"vkCreateBuffer", "vkCreateBuffer",
......
...@@ -1630,6 +1630,53 @@ static BOOL extents_equals(const VkExtent2D *extents, const RECT *rect) ...@@ -1630,6 +1630,53 @@ static BOOL extents_equals(const VkExtent2D *extents, const RECT *rect)
extents->height == rect->bottom - rect->top; extents->height == rect->bottom - rect->top;
} }
VkResult wine_vkAcquireNextImage2KHR(VkDevice device_handle, const VkAcquireNextImageInfoKHR *acquire_info,
uint32_t *image_index)
{
struct wine_swapchain *swapchain = wine_swapchain_from_handle(acquire_info->swapchain);
struct wine_device *device = wine_device_from_handle(device_handle);
VkAcquireNextImageInfoKHR acquire_info_host = *acquire_info;
struct wine_surface *surface = swapchain->surface;
RECT client_rect;
VkResult res;
acquire_info_host.swapchain = swapchain->host_swapchain;
res = device->funcs.p_vkAcquireNextImage2KHR(device->host_device, &acquire_info_host, image_index);
if (res == VK_SUCCESS && NtUserGetClientRect(surface->hwnd, &client_rect) &&
!extents_equals(&swapchain->extents, &client_rect))
{
WARN("Swapchain size %dx%d does not match client rect %s, returning VK_SUBOPTIMAL_KHR\n",
swapchain->extents.width, swapchain->extents.height, wine_dbgstr_rect(&client_rect));
return VK_SUBOPTIMAL_KHR;
}
return res;
}
VkResult wine_vkAcquireNextImageKHR(VkDevice device_handle, VkSwapchainKHR swapchain_handle, uint64_t timeout,
VkSemaphore semaphore, VkFence fence, uint32_t *image_index)
{
struct wine_swapchain *swapchain = wine_swapchain_from_handle(swapchain_handle);
struct wine_device *device = wine_device_from_handle(device_handle);
struct wine_surface *surface = swapchain->surface;
RECT client_rect;
VkResult res;
res = device->funcs.p_vkAcquireNextImageKHR(device->host_device, swapchain->host_swapchain, timeout,
semaphore, fence, image_index);
if (res == VK_SUCCESS && NtUserGetClientRect(surface->hwnd, &client_rect) &&
!extents_equals(&swapchain->extents, &client_rect))
{
WARN("Swapchain size %dx%d does not match client rect %s, returning VK_SUBOPTIMAL_KHR\n",
swapchain->extents.width, swapchain->extents.height, wine_dbgstr_rect(&client_rect));
return VK_SUBOPTIMAL_KHR;
}
return res;
}
VkResult wine_vkCreateSwapchainKHR(VkDevice device_handle, const VkSwapchainCreateInfoKHR *create_info, VkResult wine_vkCreateSwapchainKHR(VkDevice device_handle, const VkSwapchainCreateInfoKHR *create_info,
const VkAllocationCallbacks *allocator, VkSwapchainKHR *swapchain_handle) const VkAllocationCallbacks *allocator, VkSwapchainKHR *swapchain_handle)
{ {
......
...@@ -7112,28 +7112,13 @@ static uint64_t wine_vk_unwrap_handle(uint32_t type, uint64_t handle) ...@@ -7112,28 +7112,13 @@ static uint64_t wine_vk_unwrap_handle(uint32_t type, uint64_t handle)
} }
} }
#ifdef _WIN64 static inline void convert_VkAcquireNextImageInfoKHR_win32_to_unwrapped_host(const VkAcquireNextImageInfoKHR32 *in, VkAcquireNextImageInfoKHR *out)
static inline void convert_VkAcquireNextImageInfoKHR_win64_to_host(const VkAcquireNextImageInfoKHR *in, VkAcquireNextImageInfoKHR *out)
{
if (!in) return;
out->sType = in->sType;
out->pNext = in->pNext;
out->swapchain = wine_swapchain_from_handle(in->swapchain)->host_swapchain;
out->timeout = in->timeout;
out->semaphore = in->semaphore;
out->fence = in->fence;
out->deviceMask = in->deviceMask;
}
#endif /* _WIN64 */
static inline void convert_VkAcquireNextImageInfoKHR_win32_to_host(const VkAcquireNextImageInfoKHR32 *in, VkAcquireNextImageInfoKHR *out)
{ {
if (!in) return; if (!in) return;
out->sType = in->sType; out->sType = in->sType;
out->pNext = NULL; out->pNext = NULL;
out->swapchain = wine_swapchain_from_handle(in->swapchain)->host_swapchain; out->swapchain = in->swapchain;
out->timeout = in->timeout; out->timeout = in->timeout;
out->semaphore = in->semaphore; out->semaphore = in->semaphore;
out->fence = in->fence; out->fence = in->fence;
...@@ -30193,12 +30178,10 @@ static inline void convert_VkSemaphoreWaitInfo_win32_to_host(const VkSemaphoreWa ...@@ -30193,12 +30178,10 @@ static inline void convert_VkSemaphoreWaitInfo_win32_to_host(const VkSemaphoreWa
static NTSTATUS thunk64_vkAcquireNextImage2KHR(void *args) static NTSTATUS thunk64_vkAcquireNextImage2KHR(void *args)
{ {
struct vkAcquireNextImage2KHR_params *params = args; struct vkAcquireNextImage2KHR_params *params = args;
VkAcquireNextImageInfoKHR pAcquireInfo_host;
TRACE("%p, %p, %p\n", params->device, params->pAcquireInfo, params->pImageIndex); TRACE("%p, %p, %p\n", params->device, params->pAcquireInfo, params->pImageIndex);
convert_VkAcquireNextImageInfoKHR_win64_to_host(params->pAcquireInfo, &pAcquireInfo_host); params->result = wine_vkAcquireNextImage2KHR(params->device, params->pAcquireInfo, params->pImageIndex);
params->result = wine_device_from_handle(params->device)->funcs.p_vkAcquireNextImage2KHR(wine_device_from_handle(params->device)->host_device, &pAcquireInfo_host, params->pImageIndex);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
#endif /* _WIN64 */ #endif /* _WIN64 */
...@@ -30216,8 +30199,8 @@ static NTSTATUS thunk32_vkAcquireNextImage2KHR(void *args) ...@@ -30216,8 +30199,8 @@ static NTSTATUS thunk32_vkAcquireNextImage2KHR(void *args)
TRACE("%#x, %#x, %#x\n", params->device, params->pAcquireInfo, params->pImageIndex); TRACE("%#x, %#x, %#x\n", params->device, params->pAcquireInfo, params->pImageIndex);
convert_VkAcquireNextImageInfoKHR_win32_to_host((const VkAcquireNextImageInfoKHR32 *)UlongToPtr(params->pAcquireInfo), &pAcquireInfo_host); convert_VkAcquireNextImageInfoKHR_win32_to_unwrapped_host((const VkAcquireNextImageInfoKHR32 *)UlongToPtr(params->pAcquireInfo), &pAcquireInfo_host);
params->result = wine_device_from_handle((VkDevice)UlongToPtr(params->device))->funcs.p_vkAcquireNextImage2KHR(wine_device_from_handle((VkDevice)UlongToPtr(params->device))->host_device, &pAcquireInfo_host, (uint32_t *)UlongToPtr(params->pImageIndex)); params->result = wine_vkAcquireNextImage2KHR((VkDevice)UlongToPtr(params->device), &pAcquireInfo_host, (uint32_t *)UlongToPtr(params->pImageIndex));
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -30228,7 +30211,7 @@ static NTSTATUS thunk64_vkAcquireNextImageKHR(void *args) ...@@ -30228,7 +30211,7 @@ static NTSTATUS thunk64_vkAcquireNextImageKHR(void *args)
TRACE("%p, 0x%s, 0x%s, 0x%s, 0x%s, %p\n", params->device, wine_dbgstr_longlong(params->swapchain), wine_dbgstr_longlong(params->timeout), wine_dbgstr_longlong(params->semaphore), wine_dbgstr_longlong(params->fence), params->pImageIndex); TRACE("%p, 0x%s, 0x%s, 0x%s, 0x%s, %p\n", params->device, wine_dbgstr_longlong(params->swapchain), wine_dbgstr_longlong(params->timeout), wine_dbgstr_longlong(params->semaphore), wine_dbgstr_longlong(params->fence), params->pImageIndex);
params->result = wine_device_from_handle(params->device)->funcs.p_vkAcquireNextImageKHR(wine_device_from_handle(params->device)->host_device, wine_swapchain_from_handle(params->swapchain)->host_swapchain, params->timeout, params->semaphore, params->fence, params->pImageIndex); params->result = wine_vkAcquireNextImageKHR(params->device, params->swapchain, params->timeout, params->semaphore, params->fence, params->pImageIndex);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
#endif /* _WIN64 */ #endif /* _WIN64 */
...@@ -30248,7 +30231,7 @@ static NTSTATUS thunk32_vkAcquireNextImageKHR(void *args) ...@@ -30248,7 +30231,7 @@ static NTSTATUS thunk32_vkAcquireNextImageKHR(void *args)
TRACE("%#x, 0x%s, 0x%s, 0x%s, 0x%s, %#x\n", params->device, wine_dbgstr_longlong(params->swapchain), wine_dbgstr_longlong(params->timeout), wine_dbgstr_longlong(params->semaphore), wine_dbgstr_longlong(params->fence), params->pImageIndex); TRACE("%#x, 0x%s, 0x%s, 0x%s, 0x%s, %#x\n", params->device, wine_dbgstr_longlong(params->swapchain), wine_dbgstr_longlong(params->timeout), wine_dbgstr_longlong(params->semaphore), wine_dbgstr_longlong(params->fence), params->pImageIndex);
params->result = wine_device_from_handle((VkDevice)UlongToPtr(params->device))->funcs.p_vkAcquireNextImageKHR(wine_device_from_handle((VkDevice)UlongToPtr(params->device))->host_device, wine_swapchain_from_handle(params->swapchain)->host_swapchain, params->timeout, params->semaphore, params->fence, (uint32_t *)UlongToPtr(params->pImageIndex)); params->result = wine_vkAcquireNextImageKHR((VkDevice)UlongToPtr(params->device), params->swapchain, params->timeout, params->semaphore, params->fence, (uint32_t *)UlongToPtr(params->pImageIndex));
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#define WINE_VK_VERSION VK_API_VERSION_1_3 #define WINE_VK_VERSION VK_API_VERSION_1_3
/* Functions for which we have custom implementations outside of the thunks. */ /* Functions for which we have custom implementations outside of the thunks. */
VkResult wine_vkAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo, uint32_t *pImageIndex);
VkResult wine_vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex);
VkResult wine_vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers); VkResult wine_vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers);
VkResult wine_vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory); VkResult wine_vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory);
VkResult wine_vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer); VkResult wine_vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment