@@ -403,8 +403,6 @@ static VkResult X11DRV_vkAcquireNextImageKHR(VkDevice device,
403403 VkSwapchainKHR swapchain , uint64_t timeout , VkSemaphore semaphore ,
404404 VkFence fence , uint32_t * image_index )
405405{
406- static int once ;
407- struct x11drv_escape_present_drawable escape ;
408406 struct wine_vk_surface * surface = NULL ;
409407 VkResult result ;
410408 VkFence orig_fence ;
@@ -439,12 +437,6 @@ static VkResult X11DRV_vkAcquireNextImageKHR(VkDevice device,
439437 if ((result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR ) && hdc && surface && surface -> offscreen )
440438 {
441439 if (wait_fence ) pvkWaitForFences (device , 1 , & fence , 0 , timeout );
442- escape .code = X11DRV_PRESENT_DRAWABLE ;
443- escape .drawable = surface -> window ;
444- escape .flush = TRUE;
445- ExtEscape (hdc , X11DRV_ESCAPE , sizeof (escape ), (char * )& escape , 0 , NULL );
446- if (surface -> present_mode == VK_PRESENT_MODE_MAILBOX_KHR )
447- if (once ++ ) FIXME ("Application requires child window rendering with mailbox present mode, expect possible tearing!\n" );
448440 }
449441
450442 if (fence != orig_fence ) pvkDestroyFence (device , fence , NULL );
@@ -868,6 +860,15 @@ static VkResult X11DRV_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *
868860{
869861 VkResult res ;
870862
863+ VkSwapchainKHR swapchain ;
864+
865+ static int once ;
866+ struct x11drv_escape_present_drawable escape ;
867+ struct wine_vk_surface * surface = NULL ;
868+ VkFence orig_fence ;
869+ BOOL wait_fence = FALSE;
870+ HDC hdc = 0 ;
871+
871872 TRACE ("%p, %p\n" , queue , present_info );
872873
873874 res = pvkQueuePresentKHR (queue , present_info );
@@ -893,6 +894,33 @@ static VkResult X11DRV_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *
893894 }
894895 }
895896
897+ if (res == VK_SUCCESS )
898+ {
899+ for (uint32_t i = 0 ; i < present_info -> swapchainCount ; i ++ )
900+ {
901+ swapchain = present_info -> pSwapchains [i ];
902+
903+ EnterCriticalSection (& context_section );
904+ if (!XFindContext (gdi_display , (XID )swapchain , vulkan_swapchain_context , (char * * )& surface ))
905+ {
906+ wine_vk_surface_grab (surface );
907+ hdc = surface -> hdc ;
908+ }
909+ LeaveCriticalSection (& context_section );
910+
911+ if (hdc && surface && surface -> offscreen )
912+ {
913+ escape .code = X11DRV_PRESENT_DRAWABLE ;
914+ escape .drawable = surface -> window ;
915+ escape .flush = TRUE;
916+
917+ ExtEscape (hdc , X11DRV_ESCAPE , sizeof (escape ), (char * )& escape , 0 , NULL );
918+ if (surface -> present_mode == VK_PRESENT_MODE_MAILBOX_KHR )
919+ if (once ++ ) FIXME ("Application requires child window rendering with mailbox present mode, expect possible tearing!\n" );
920+ }
921+ }
922+ }
923+
896924 return res ;
897925}
898926
0 commit comments