From 1546cc234a61d731e45bd85a718587f60ca168d0 Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Fri, 20 May 2022 17:05:56 +0200 Subject: [PATCH 1/5] Add multiview ext --- Cargo.toml | 1 + src/web_sys.rs | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0793e7f..262e495 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -93,6 +93,7 @@ features = [ "WebglDepthTexture", "WebglDrawBuffers", "WebglLoseContext", + "OvrMultiview2", ] [workspace] diff --git a/src/web_sys.rs b/src/web_sys.rs index 7e70867..0b3a0b6 100644 --- a/src/web_sys.rs +++ b/src/web_sys.rs @@ -40,7 +40,7 @@ struct Extensions { pub oes_texture_half_float: Option, pub oes_texture_half_float_linear: Option, pub oes_vertex_array_object: Option, - pub ovr_multiview2: Option<()>, + pub ovr_multiview2: Option, pub webgl_color_buffer_float: Option, pub webgl_compressed_texture_astc: Option, pub webgl_compressed_texture_etc: Option, @@ -181,7 +181,7 @@ macro_rules! build_extensions { &$context, "OES_vertex_array_object", ), - ovr_multiview2: get_extension_no_object(&$context, "OVR_multiview2"), + ovr_multiview2: get_extension::(&$context, "OVR_multiview2"), webgl_color_buffer_float: get_extension::( &$context, "WEBGL_color_buffer_float", @@ -705,6 +705,36 @@ impl Context { } } } + + pub unsafe fn framebuffer_texture_multiview_ovr( + &self, + target: u32, + attachment: u32, + texture: Option<::Texture>, + level: i32, + base_view_index: i32, + num_views: i32, + ) { + let textures = self.textures.borrow(); + let raw_texture = texture.map(|t| textures.get_unchecked(t)); + match self.raw { + RawRenderingContext::WebGl1(ref _gl) => { + panic!("OVR_multiview2 is not supported in WebGL1") + } + RawRenderingContext::WebGl2(ref gl) => { + if let Some(ext) = &self.extensions.ovr_multiview2 { + ext.framebuffer_texture_multiview_ovr( + target, + attachment, + raw_texture, + level, + base_view_index, + num_views, + ); + } + } + } + } } new_key_type! { pub struct WebShaderKey; } From c4141c91b34d3631544c4c2cde39fe5305dc6fd0 Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Fri, 20 May 2022 19:26:23 +0200 Subject: [PATCH 2/5] patch wasm-bindgen --- Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 262e495..c32c6b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -101,3 +101,8 @@ members = [ "examples/hello", "examples/howto", ] + +[patch.crates-io] +web-sys = { git = "https://github.com/rustwasm/wasm-bindgen" } +js-sys = { git = "https://github.com/rustwasm/wasm-bindgen" } +wasm-bindgen = { git = "https://github.com/rustwasm/wasm-bindgen" } \ No newline at end of file From 7c2e009ba729cb8530278c399129bf3a3af70ab9 Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Fri, 20 May 2022 19:27:17 +0200 Subject: [PATCH 3/5] Add newline --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c32c6b5..527a9ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -105,4 +105,4 @@ members = [ [patch.crates-io] web-sys = { git = "https://github.com/rustwasm/wasm-bindgen" } js-sys = { git = "https://github.com/rustwasm/wasm-bindgen" } -wasm-bindgen = { git = "https://github.com/rustwasm/wasm-bindgen" } \ No newline at end of file +wasm-bindgen = { git = "https://github.com/rustwasm/wasm-bindgen" } From a92e0b76e37816a9b14b7f5a88ee09282f2e796f Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Fri, 20 May 2022 19:51:00 +0200 Subject: [PATCH 4/5] Mark unused variable with _ --- src/web_sys.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web_sys.rs b/src/web_sys.rs index 0b3a0b6..f98ee7e 100644 --- a/src/web_sys.rs +++ b/src/web_sys.rs @@ -721,7 +721,7 @@ impl Context { RawRenderingContext::WebGl1(ref _gl) => { panic!("OVR_multiview2 is not supported in WebGL1") } - RawRenderingContext::WebGl2(ref gl) => { + RawRenderingContext::WebGl2(ref _gl) => { if let Some(ext) = &self.extensions.ovr_multiview2 { ext.framebuffer_texture_multiview_ovr( target, From 91bc259992490861a67ae25673b525fe00814a56 Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Thu, 30 Jun 2022 18:42:23 +0200 Subject: [PATCH 5/5] Update tilde web-sys requirement --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 262e495..291e565 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ wasm-bindgen = "~0.2" slotmap = "1" [target.'cfg(target_arch = "wasm32")'.dependencies.web_sys] -version = "~0.3.37" +version = "~0.3.58" package = "web-sys" features = [ "Document",