wgpu
wgpu copied to clipboard
`SurfaceTexture::present` with no work, does not allow the `SurfaceTexture` to be returned in future calls to `Surface::get_current_texture`
Description
While using the Vulkan backend, if you call SurfaceTexture::present without submitting work that would draw to it that frame that SurfaceTexture will never be "released". By this I mean, if you manage to do it to all textures in the swapchain, no textures are available for Surface::get_current_texture to return.
Having followed this through, the Context::surface_present method, in the no work case, calls the hal backend discard_texture function. In the case of Vulkan, this does nothing. Maybe something has to happen here? (I'm going to guess something to do with the fences around the swapchain)
Repro steps
Take the hello_triangle example, force it to use VULKAN backend, and remove any of the code that would draw (don't construct the CommandEncoder and remove the code that needs the CommandEncoder), leaving just the Surface::get_current_texture call and SurfaceTexture::present call.
Expected vs observed behavior I'd expect that this texture would be available for use in future frames, currently it is not.
Extra materials Screenshots to help explain your problem. Validation logs can be attached in case there are warnings and errors. Zip-compressed API traces and GPU captures can also land here.
Platform Arch Linux, wgpu 0.12.0, i3 on X11.
https://docs.rs/wgpu/latest/wgpu/struct.Surface.html#method.get_current_texture does explicitly mention that
In order to present the SurfaceTexture returned by this method, first a Queue::submit needs to be done with some work rendering to this texture. Then SurfaceTexture::present needs to be called.
@coderedart While true, (I hadn't actually looked at that documentation), it's probably not best to put the program into a strange state, if it can be avoided, and if it can't it should probably result in some form of error.