-
Notifications
You must be signed in to change notification settings - Fork 187
cube: Resize surface after toplevel configure #1155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Author PancakeTAS not on autobuild list. Waiting for curator authorization before starting CI build. |
1 similar comment
|
Author PancakeTAS not on autobuild list. Waiting for curator authorization before starting CI build. |
|
This closes #1138, I should've put that into the description. |
|
CI Vulkan-Tools build queued with queue ID 534513. |
|
CI Vulkan-Tools build # 1815 running. |
|
CI Vulkan-Tools build # 1815 passed. |
On wayland, the swapchain size is always controlled by the client. Therefore there is nothing to invalidate nor is there any mechanism for the compositor to invalidate anything. This patch is wrong. The client should not do anything until it receives the xdg_surface.configure event as documented:
The client might in fact receive many xdg_toplevel.configure events before receiving a single xdg_surface.configure event. The client should ignore all but the last xdg_toplevel.configure event in this case. The existing code is not entirely correct because it might try to present before having received the first xdg_surface.configure event. This patch would fix that: diff --git a/cube/cube.c b/cube/cube.c
index b4db7500..8e37cc15 100644
--- a/cube/cube.c
+++ b/cube/cube.c
@@ -1372,6 +1372,12 @@ static void demo_prepare_swapchain(struct demo *demo) {
VkResult U_ASSERT_ONLY err;
VkSwapchainKHR oldSwapchain = demo->swapchain;
+#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
+ if (demo->wsi_platform == WSI_PLATFORM_WAYLAND && !demo->xdg_surface_has_been_configured) {
+ return;
+ }
+#endif
+
// Check the surface capabilities and formats
VkSurfaceCapabilitiesKHR surfCapabilities;
err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(demo->gpu, demo->surface, &surfCapabilities);
@@ -3054,10 +3060,8 @@ static void demo_run(struct demo *demo) {
static void handle_surface_configure(void *data, struct xdg_surface *xdg_surface, uint32_t serial) {
struct demo *demo = (struct demo *)data;
xdg_surface_ack_configure(xdg_surface, serial);
- if (demo->xdg_surface_has_been_configured) {
- demo_resize(demo);
- }
demo->xdg_surface_has_been_configured = 1;
+ demo_resize(demo);
}
static const struct xdg_surface_listener xdg_surface_listener = {handle_surface_configure};However, in practice it always gets lucky because the vulkan driver performs a number of roundtrips before creating the swapchain. |
|
The solution for this error from your logs is to double-buffer the width/height parameters sent in the xdg_toplevel.configure event until they are applied in the xdg_surface.configure event: |
996a0f8 to
f4e1799
Compare
|
Author PancakeTAS not on autobuild list. Waiting for curator authorization before starting CI build. |
1 similar comment
|
Author PancakeTAS not on autobuild list. Waiting for curator authorization before starting CI build. |
f4e1799 to
984c5ec
Compare
|
Author PancakeTAS not on autobuild list. Waiting for curator authorization before starting CI build. |
1 similar comment
|
Author PancakeTAS not on autobuild list. Waiting for curator authorization before starting CI build. |
|
I implemented the double buffering and moved the surface reconfigure to |
|
LGTM |
|
CI Vulkan-Tools build queued with queue ID 536288. |
|
CI Vulkan-Tools build # 1824 running. |
charles-lunarg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was able to run this and had no issue with resizing. Wayland code also makes more sense now, which is stellar.
|
CI Vulkan-Tools build # 1824 passed. |
It appears some compositors (tested on Hyprland) don't invalidate the swapchain after a window resize. This breaks rendering entirely due to mismatched sizes in the demo struct, versus the created framebuffer and isn't caught by anything else.