graphics: fix fullscreen

This commit is contained in:
2026-03-26 15:53:15 -07:00
parent 4898a5f866
commit 288ce04060

View File

@@ -39,24 +39,19 @@ impl<'window> Surface<'window>{
}
#[must_use]
pub fn new_frame(&self,device:&wgpu::Device)->Result<Frame,FrameError>{
let frame=match self.surface.get_current_texture(){
wgpu::CurrentSurfaceTexture::Success(surface_texture)=>surface_texture,
wgpu::CurrentSurfaceTexture::Suboptimal(surface_texture)=>{
self.surface.configure(device,&self.config);
surface_texture
},
wgpu::CurrentSurfaceTexture::Outdated=>{
self.surface.configure(device,&self.config);
let frame=loop{
match self.surface.get_current_texture(){
wgpu::CurrentSurfaceTexture::Success(surface_texture)=>surface_texture,
_=>panic!("Failed to acquire next surface texture!"),
}
}
wgpu::CurrentSurfaceTexture::Success(surface_texture)=>break surface_texture,
// Suboptimal -> surface_texture must be dropped and surface reconfigured
wgpu::CurrentSurfaceTexture::Suboptimal(_)
|wgpu::CurrentSurfaceTexture::Outdated=>{},
wgpu::CurrentSurfaceTexture::Timeout
|wgpu::CurrentSurfaceTexture::Occluded=>return Err(FrameError::Skip),
wgpu::CurrentSurfaceTexture::Lost=>return Err(FrameError::DeviceLost),
wgpu::CurrentSurfaceTexture::Validation=>unreachable!(),
};
self.surface.configure(device,&self.config);
};
let view=frame.texture.create_view(&wgpu::TextureViewDescriptor{
format:Some(self.config.view_formats[0]),
..wgpu::TextureViewDescriptor::default()