graphics: fix fullscreen

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

View File

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