Skip to content

Commit

Permalink
Vulkan+Wayland fixes (#271)
Browse files Browse the repository at this point in the history
* Process wayland events with vulkan renderer.

* Handle vulkan offscreen swapchain size selection.
  • Loading branch information
dsvensson authored Sep 6, 2024
1 parent e62a712 commit 2efeab6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
9 changes: 8 additions & 1 deletion engine/gl/gl_vidwayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,14 @@ static void WL_SwapBuffers(void)
}
break;
#endif
case QR_VULKAN: //the vulkan stuff handles this itself. FIXME: are we still receiving inputs? no idea!
case QR_VULKAN:
if (pwl_display_dispatch_pending(w.display) < 0)
{
Con_Printf(CON_ERROR "wayland connection was lost. Restarting video\n");
Cbuf_InsertText("vid_restart", RESTRICT_LOCAL, true);
return;
}
break;
default:
break;
}
Expand Down
15 changes: 13 additions & 2 deletions engine/vk/vk_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,19 @@ static qboolean VK_CreateSwapChain(void)
swapinfo.minImageCount = surfcaps.maxImageCount;
if (swapinfo.minImageCount < surfcaps.minImageCount)
swapinfo.minImageCount = surfcaps.minImageCount;
swapinfo.imageExtent.width = surfcaps.currentExtent.width;
swapinfo.imageExtent.height = surfcaps.currentExtent.height;

// With offscreen rendering, the size is not known at first
if (surfcaps.currentExtent.width == UINT32_MAX && surfcaps.currentExtent.height == UINT32_MAX)
{
swapinfo.imageExtent.width = bound(surfcaps.minImageExtent.width, vid.pixelwidth, surfcaps.maxImageExtent.width);
swapinfo.imageExtent.height = bound(surfcaps.minImageExtent.height, vid.pixelheight, surfcaps.maxImageExtent.height);
}
else
{
swapinfo.imageExtent.width = surfcaps.currentExtent.width;
swapinfo.imageExtent.height = surfcaps.currentExtent.height;
}

swapinfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
swapinfo.preTransform = surfcaps.currentTransform;//VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
if (surfcaps.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR)
Expand Down

0 comments on commit 2efeab6

Please sign in to comment.