Skip to content
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

Remove unwraps inside surface.configure #3585

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ By @teoxoy in [#3534](https://github.com/gfx-rs/wgpu/pull/3534)

- [gles] fix: Set FORCE_POINT_SIZE if it is vertex shader with mesh consist of point list. By @REASY in [3440](https://github.com/gfx-rs/wgpu/pull/3440)
- [gles] fix: enable `WEBGL_debug_renderer_info` before querying unmasked vendor/renderer to avoid crashing on emscripten in [#3519](https://github.com/gfx-rs/wgpu/pull/3519)
- Remove unwraps inside `surface.configure`. By @cwfitzgerald in [#3585](https://github.com/gfx-rs/wgpu/pull/3585)

#### General

Expand Down
10 changes: 8 additions & 2 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,10 @@ impl crate::Surface<super::Api> for Surface {

let format_desc = device.shared.describe_texture_format(config.format);
let gl = &device.shared.context.lock();
let renderbuffer = unsafe { gl.create_renderbuffer() }.unwrap();
let renderbuffer = unsafe { gl.create_renderbuffer() }.map_err(|error| {
log::error!("Internal swapchain renderbuffer creation failed: {error}");
crate::DeviceError::OutOfMemory
})?;
unsafe { gl.bind_renderbuffer(glow::RENDERBUFFER, Some(renderbuffer)) };
unsafe {
gl.renderbuffer_storage(
Expand All @@ -1232,7 +1235,10 @@ impl crate::Surface<super::Api> for Surface {
config.extent.height as _,
)
};
let framebuffer = unsafe { gl.create_framebuffer() }.unwrap();
let framebuffer = unsafe { gl.create_framebuffer() }.map_err(|error| {
log::error!("Internal swapchain framebuffer creation failed: {error}");
crate::DeviceError::OutOfMemory
})?;
unsafe { gl.bind_framebuffer(glow::READ_FRAMEBUFFER, Some(framebuffer)) };
unsafe {
gl.framebuffer_renderbuffer(
Expand Down
10 changes: 8 additions & 2 deletions wgpu-hal/src/gles/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ impl crate::Surface<super::Api> for Surface {
unsafe { gl.delete_texture(texture) };
}

self.texture = Some(unsafe { gl.create_texture() }.unwrap());
self.texture = Some(unsafe { gl.create_texture() }.map_err(|error| {
log::error!("Internal swapchain texture creation failed: {error}");
crate::DeviceError::OutOfMemory
})?);

let desc = device.shared.describe_texture_format(config.format);
unsafe { gl.bind_texture(glow::TEXTURE_2D, self.texture) };
Expand Down Expand Up @@ -313,7 +316,10 @@ impl crate::Surface<super::Api> for Surface {
)
};

let framebuffer = unsafe { gl.create_framebuffer() }.unwrap();
let framebuffer = unsafe { gl.create_framebuffer() }.map_err(|error| {
log::error!("Internal swapchain framebuffer creation failed: {error}");
crate::DeviceError::OutOfMemory
})?;
unsafe { gl.bind_framebuffer(glow::READ_FRAMEBUFFER, Some(framebuffer)) };
unsafe {
gl.framebuffer_texture_2d(
Expand Down