WebGL2 multiview support via OVR_multiview2 (#3121)

* Add OVR_multiview2 support

* Add changelog entry

* Only use multiview on wasm32 + unknown

* Add note to Features::MULTIVIEW
This commit is contained in:
Ashley
2022-10-18 18:14:18 +02:00
committed by GitHub
parent ce081796c8
commit d3ab5a197e
5 changed files with 27 additions and 4 deletions

View File

@@ -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

View File

@@ -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",

View File

@@ -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<std::num::NonZeroU32>,
}
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<std::num::NonZeroU32>,
) -> Result<super::PipelineInner, crate::PipelineError> {
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<super::Api> 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<super::Api> for super::Device {
) -> Result<super::ComputePipeline, crate::PipelineError> {
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 })
}

View File

@@ -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,

View File

@@ -586,6 +586,7 @@ bitflags::bitflags! {
///
/// Supported platforms:
/// - Vulkan
/// - OpenGL (web only)
///
/// This is a native only feature.
const MULTIVIEW = 1 << 37;