Skip to content

Commit

Permalink
Web: handle None for depth_ops and stencil_ops (#3660)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaskorz authored Apr 10, 2023
1 parent c7f3d8d commit 2c37608
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 34 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ By @cwfitzgerald in [#3610](https://github.com/gfx-rs/wgpu/pull/3610).

### Bug Fixes

#### WebGPU

- Fix handling of `None` values for `depth_ops` and `stencil_ops` in `RenderPassDescriptor::depth_stencil_attachment`. By @niklaskorz in [#3660](https://github.com/gfx-rs/wgpu/pull/3660)

#### Metal
- Fix incorrect mipmap being sampled when using `MinLod <= 0.0` and `MaxLod >= 32.0` or when the fragment shader samples different Lods in the same quad. By @cwfitzgerald in [#3610](https://github.com/gfx-rs/wgpu/pull/3610).

Expand Down
56 changes: 22 additions & 34 deletions wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2079,44 +2079,32 @@ impl crate::context::Context for Context {
}

if let Some(dsa) = &desc.depth_stencil_attachment {
let mut depth_clear_value = 0.0;
let mut stencil_clear_value = 0;
let (depth_load_op, depth_store_op) = match dsa.depth_ops {
Some(ref ops) => {
let load_op = match ops.load {
crate::LoadOp::Clear(v) => {
depth_clear_value = v;
web_sys::GpuLoadOp::Clear
}
crate::LoadOp::Load => web_sys::GpuLoadOp::Load,
};
(load_op, map_store_op(ops.store))
}
None => (web_sys::GpuLoadOp::Load, web_sys::GpuStoreOp::Store),
};
let (stencil_load_op, stencil_store_op) = match dsa.stencil_ops {
Some(ref ops) => {
let load_op = match ops.load {
crate::LoadOp::Clear(v) => {
stencil_clear_value = v;
web_sys::GpuLoadOp::Clear
}
crate::LoadOp::Load => web_sys::GpuLoadOp::Load,
};
(load_op, map_store_op(ops.store))
}
None => (web_sys::GpuLoadOp::Load, web_sys::GpuStoreOp::Store),
};
let mut mapped_depth_stencil_attachment =
web_sys::GpuRenderPassDepthStencilAttachment::new(
&<<Context as crate::Context>::TextureViewId>::from(dsa.view.id).0,
);
mapped_depth_stencil_attachment.depth_clear_value(depth_clear_value);
mapped_depth_stencil_attachment.depth_load_op(depth_load_op);
mapped_depth_stencil_attachment.depth_store_op(depth_store_op);
mapped_depth_stencil_attachment.stencil_clear_value(stencil_clear_value);
mapped_depth_stencil_attachment.stencil_load_op(stencil_load_op);
mapped_depth_stencil_attachment.stencil_store_op(stencil_store_op);
if let Some(ref ops) = dsa.depth_ops {
let load_op = match ops.load {
crate::LoadOp::Clear(v) => {
mapped_depth_stencil_attachment.depth_clear_value(v);
web_sys::GpuLoadOp::Clear
}
crate::LoadOp::Load => web_sys::GpuLoadOp::Load,
};
mapped_depth_stencil_attachment.depth_load_op(load_op);
mapped_depth_stencil_attachment.depth_store_op(map_store_op(ops.store));
}
if let Some(ref ops) = dsa.stencil_ops {
let load_op = match ops.load {
crate::LoadOp::Clear(v) => {
mapped_depth_stencil_attachment.stencil_clear_value(v);
web_sys::GpuLoadOp::Clear
}
crate::LoadOp::Load => web_sys::GpuLoadOp::Load,
};
mapped_depth_stencil_attachment.stencil_load_op(load_op);
mapped_depth_stencil_attachment.stencil_store_op(map_store_op(ops.store));
}
mapped_desc.depth_stencil_attachment(&mapped_depth_stencil_attachment);
}

Expand Down

0 comments on commit 2c37608

Please sign in to comment.