Resizing swap buffers

38 views
Skip to first unread message

Luke Brown

unread,
Jan 31, 2023, 10:54:26 AM1/31/23
to Dawn Graphics
Hi, I was curious what the intended way is to resize swap buffers in dawn (for example when the window is resized)

I'm testing using the d3d12 implementation which I believe has support for resizing the buffers, but it looks as though dawn's native swap chain implementation does use that. Calling the "Configure" function again on the swap chain with a different size also seems to fail.

So far the only solution I can really see here is to destroy the current device and recreate it.

Any info would be greatly appreciated,
Luke

Corentin Wallez

unread,
Jan 31, 2023, 11:05:49 AM1/31/23
to Luke Brown, Dawn Graphics
On a phone, excuse brevity, but it should be possible to resize windows without recreating the device just using configure. See https://dawn.googlesource.com/dawn/+/refs/heads/main/src/dawn/samples/ManualSwapChainTest.cpp that are the tests we use to check the resizing works.

--
You received this message because you are subscribed to the Google Groups "Dawn Graphics" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dawn-graphic...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dawn-graphics/01b5c7b6-04a3-4cad-97f1-33e2fc73e5bfn%40googlegroups.com.

Luke Brown

unread,
Jan 31, 2023, 11:12:18 AM1/31/23
to Dawn Graphics
Thanks. I'll take a look

Luke

Message has been deleted

Jean-Colas Prunier

unread,
Feb 1, 2023, 11:11:35 AM2/1/23
to Dawn Graphics
I am not part of the Dawn dev team, but I have been doing some tests with the API so maybe I can share my experience. Are you speaking about what you need to do when the window is resized? So far what has worked for me was to:

- Recreate the SwapChain with (with the new window size)
- Recreate the depth stencil view (with the new window size)

This was enough in my case. I didn't touch the `wgpu::Surface surface`, which I initialize at the beginning of the program. It's my understanding that it's the WSI's responsibility to adjust the surface when the window size changes but I am might be wrong. For my tests I used GLFW. Sorry if I didn't get your question right. I have tested this with the Vulkan backend. I also tried `swapChain.Configure(...)` but this didn't work for me. The only method that worked was the one I described above. Interested to hear from the Dawn developers if there's a better / other solution (or if this one is wrong).

Corentin Wallez

unread,
Feb 1, 2023, 11:27:19 AM2/1/23
to Jean-Colas Prunier, Dawn Graphics
The approach you followed Jean-Colas should be the correct one and even though I implemented the thing I was wrong in the previous email. The way to resize surface-based swapchains (the only ones you should use, the others are deprecated and we want to remove them soon) is to recreate a swapchain on the same surface but with a different size. That's what the ManualSwapchainTest example does and we have previously checked it works on Windows, Linux and macOS with the various backends.

--
You received this message because you are subscribed to the Google Groups "Dawn Graphics" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dawn-graphic...@googlegroups.com.

Luke Brown

unread,
Feb 2, 2023, 8:51:07 AM2/2/23
to Dawn Graphics
Thanks, that led to a solution.

We're using SDL2 for windowing and there wasn't a simple way in dawn, like with glfw, to get a surface for a SDL_Window so we were using the native swap chain implementation method instead. After reading you last reply I switched over to creating a wgpu Surface for the SDL_Window - or more accurately the HWND in this particular case (mostly taking code from the glfw utils and modifying it a bit) - and now that works perfectly.

Thanks for the help
Luke

Reply all
Reply to author
Forward
0 new messages