diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b243a6c4e..e382edc101 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,10 @@ Bottom level categories: #### WebGPU - Implement `queue_validate_write_buffer` by @jinleili in [#3098](https://github.com/gfx-rs/wgpu/pull/3098) +#### GLES + +- Browsers that support `OVR_multiview2` now report the `MULTIVIEW` feature by @expenses in [#3121](https://github.com/gfx-rs/wgpu/pull/3121). + ### Added/New Features #### General diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 8e2eda06f9..53b11029d0 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -330,6 +330,10 @@ impl super::Adapter { downlevel_flags.contains(wgt::DownlevelFlags::VERTEX_STORAGE) && vertex_shader_storage_textures != 0, ); + features.set( + wgt::Features::MULTIVIEW, + extensions.contains("OVR_multiview2"), + ); let gles_bcn_exts = [ "GL_EXT_texture_compression_s3tc_srgb", "GL_EXT_texture_compression_rgtc", diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index 6756d1884c..96be1f569b 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -20,6 +20,7 @@ struct CompilationContext<'a> { layout: &'a super::PipelineLayout, sampler_map: &'a mut super::SamplerBindMap, name_binding_map: &'a mut NameBindingMap, + multiview: Option, } impl CompilationContext<'_> { @@ -205,7 +206,7 @@ impl super::Device { let pipeline_options = glsl::PipelineOptions { shader_stage: naga_stage, entry_point: stage.entry_point.to_string(), - multiview: None, + multiview: context.multiview, }; let shader = &stage.module.naga; @@ -269,6 +270,7 @@ impl super::Device { shaders: I, layout: &super::PipelineLayout, #[cfg_attr(target_arch = "wasm32", allow(unused))] label: Option<&str>, + multiview: Option, ) -> Result { let program = gl.create_program().unwrap(); #[cfg(not(target_arch = "wasm32"))] @@ -289,6 +291,7 @@ impl super::Device { layout, sampler_map: &mut sampler_map, name_binding_map: &mut name_binding_map, + multiview, }; let shader = Self::create_shader(gl, naga_stage, stage, context)?; @@ -1032,7 +1035,7 @@ impl crate::Device for super::Device { .as_ref() .map(|fs| (naga::ShaderStage::Fragment, fs)), ); - let inner = self.create_pipeline(gl, shaders, desc.layout, desc.label)?; + let inner = self.create_pipeline(gl, shaders, desc.layout, desc.label, desc.multiview)?; let (vertex_buffers, vertex_attributes) = { let mut buffers = Vec::new(); @@ -1100,7 +1103,7 @@ impl crate::Device for super::Device { ) -> Result { let gl = &self.shared.context.lock(); let shaders = iter::once((naga::ShaderStage::Compute, &desc.stage)); - let inner = self.create_pipeline(gl, shaders, desc.layout, desc.label)?; + let inner = self.create_pipeline(gl, shaders, desc.layout, desc.label, None)?; Ok(super::ComputePipeline { inner }) } diff --git a/wgpu-hal/src/gles/queue.rs b/wgpu-hal/src/gles/queue.rs index 6cdccd9141..69edfd5c86 100644 --- a/wgpu-hal/src/gles/queue.rs +++ b/wgpu-hal/src/gles/queue.rs @@ -89,7 +89,18 @@ impl super::Queue { } super::TextureInner::DefaultRenderbuffer => panic!("Unexpected default RBO"), super::TextureInner::Texture { raw, target } => { - if is_layered_target(target) { + let num_layers = view.array_layers.end - view.array_layers.start; + if num_layers > 1 { + #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] + gl.framebuffer_texture_multiview_ovr( + fbo_target, + attachment, + Some(raw), + view.mip_levels.start as i32, + view.array_layers.start as i32, + num_layers as i32, + ); + } else if is_layered_target(target) { gl.framebuffer_texture_layer( fbo_target, attachment, diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index ed82c00ded..9fce6ca524 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -586,6 +586,7 @@ bitflags::bitflags! { /// /// Supported platforms: /// - Vulkan + /// - OpenGL (web only) /// /// This is a native only feature. const MULTIVIEW = 1 << 37;