Skip to content

Commit

Permalink
Working multiview!
Browse files Browse the repository at this point in the history
  • Loading branch information
expenses committed May 20, 2022
1 parent e1f0755 commit 7da24f3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ impl super::Adapter {
let mut features = wgt::Features::empty()
| wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
| wgt::Features::CLEAR_TEXTURE
| wgt::Features::PUSH_CONSTANTS;
| wgt::Features::PUSH_CONSTANTS
| wgt::Features::MULTIVIEW;
features.set(
wgt::Features::ADDRESS_MODE_CLAMP_TO_BORDER | wgt::Features::ADDRESS_MODE_CLAMP_TO_ZERO,
extensions.contains("GL_EXT_texture_border_clamp"),
Expand Down
8 changes: 6 additions & 2 deletions wgpu-hal/src/gles/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<'_> {
Expand Down Expand Up @@ -134,6 +135,7 @@ impl super::Device {
let pipeline_options = glsl::PipelineOptions {
shader_stage: naga_stage,
entry_point: stage.entry_point.to_string(),
multiview: context.multiview,
};

let shader = &stage.module.naga;
Expand Down Expand Up @@ -179,6 +181,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"))]
Expand All @@ -199,6 +202,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)?;
Expand Down Expand Up @@ -960,7 +964,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();
Expand Down Expand Up @@ -1028,7 +1032,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 })
}
Expand Down
12 changes: 11 additions & 1 deletion wgpu-hal/src/gles/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,17 @@ 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 {
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,
Expand Down

0 comments on commit 7da24f3

Please sign in to comment.