Skip to content

Commit

Permalink
webgl: Comment why it's okay to overwrite webgl2_context. (#4064)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid authored Aug 16, 2023
1 parent f61ed50 commit a2c9294
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions wgpu-hal/src/gles/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ impl AdapterContext {

#[derive(Debug)]
pub struct Instance {
/// Set when a canvas is provided, and used to implement [`Instance::enumerate_adapters()`].
webgl2_context: Mutex<Option<web_sys::WebGl2RenderingContext>>,
}

Expand Down Expand Up @@ -82,6 +83,8 @@ impl Instance {
.dyn_into()
.expect("canvas context is not a WebGl2RenderingContext");

// It is not inconsistent to overwrite an existing context, because the only thing that
// `self.webgl2_context` is used for is producing the response to `enumerate_adapters()`.
*self.webgl2_context.lock() = Some(webgl2_context.clone());

Ok(Surface {
Expand Down

0 comments on commit a2c9294

Please sign in to comment.