From 729d9e2f37337c8f96c5178d1933f8f151b7f016 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 5 Apr 2021 23:27:53 -0400 Subject: [PATCH] Update wgpu with depth clamping API changes --- Cargo.toml | 6 +++--- examples/shadow/main.rs | 3 +-- examples/skybox/main.rs | 2 -- examples/water/main.rs | 2 -- src/backend/web.rs | 3 ++- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f04d2df6ef..a4f8242a74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,20 +28,20 @@ cross = ["wgc/cross"] [target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "eef478fc5d4de9c114084a4f8a7a3d434697fdba" +rev = "e430cf4bcc10aea447f637067fe81c75c80f0e46" features = ["raw-window-handle"] [target.'cfg(target_arch = "wasm32")'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "eef478fc5d4de9c114084a4f8a7a3d434697fdba" +rev = "e430cf4bcc10aea447f637067fe81c75c80f0e46" features = ["raw-window-handle"] optional = true [dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "eef478fc5d4de9c114084a4f8a7a3d434697fdba" +rev = "e430cf4bcc10aea447f637067fe81c75c80f0e46" [dependencies] arrayvec = "0.5" diff --git a/examples/shadow/main.rs b/examples/shadow/main.rs index 6b241d7fcb..67dda6838d 100644 --- a/examples/shadow/main.rs +++ b/examples/shadow/main.rs @@ -507,6 +507,7 @@ impl framework::Example for Example { topology: wgpu::PrimitiveTopology::TriangleList, front_face: wgpu::FrontFace::Ccw, cull_mode: Some(wgpu::Face::Back), + clamp_depth: device.features().contains(wgpu::Features::DEPTH_CLAMPING), ..Default::default() }, depth_stencil: Some(wgpu::DepthStencilState { @@ -519,7 +520,6 @@ impl framework::Example for Example { slope_scale: 2.0, clamp: 0.0, }, - clamp_depth: device.features().contains(wgpu::Features::DEPTH_CLAMPING), }), multisample: wgpu::MultisampleState::default(), }); @@ -646,7 +646,6 @@ impl framework::Example for Example { depth_compare: wgpu::CompareFunction::Less, stencil: wgpu::StencilState::default(), bias: wgpu::DepthBiasState::default(), - clamp_depth: false, }), multisample: wgpu::MultisampleState::default(), }); diff --git a/examples/skybox/main.rs b/examples/skybox/main.rs index 3fdace6b4a..4ebec3ee14 100644 --- a/examples/skybox/main.rs +++ b/examples/skybox/main.rs @@ -232,7 +232,6 @@ impl framework::Example for Skybox { depth_compare: wgpu::CompareFunction::LessEqual, stencil: wgpu::StencilState::default(), bias: wgpu::DepthBiasState::default(), - clamp_depth: false, }), multisample: wgpu::MultisampleState::default(), }); @@ -263,7 +262,6 @@ impl framework::Example for Skybox { depth_compare: wgpu::CompareFunction::LessEqual, stencil: wgpu::StencilState::default(), bias: wgpu::DepthBiasState::default(), - clamp_depth: false, }), multisample: wgpu::MultisampleState::default(), }); diff --git a/examples/water/main.rs b/examples/water/main.rs index f2ccbe325d..789d689772 100644 --- a/examples/water/main.rs +++ b/examples/water/main.rs @@ -570,7 +570,6 @@ impl framework::Example for Example { depth_compare: wgpu::CompareFunction::Less, stencil: wgpu::StencilState::default(), bias: wgpu::DepthBiasState::default(), - clamp_depth: false, }), // No multisampling is used. multisample: wgpu::MultisampleState::default(), @@ -605,7 +604,6 @@ impl framework::Example for Example { depth_compare: wgpu::CompareFunction::Less, stencil: wgpu::StencilState::default(), bias: wgpu::DepthBiasState::default(), - clamp_depth: false, }), multisample: wgpu::MultisampleState::default(), }); diff --git a/src/backend/web.rs b/src/backend/web.rs index 4862949b8b..e2d696febc 100644 --- a/src/backend/web.rs +++ b/src/backend/web.rs @@ -603,6 +603,8 @@ fn map_primitive_state(primitive: &wgt::PrimitiveState) -> web_sys::GpuPrimitive PrimitiveTopology::TriangleStrip => pt::TriangleStrip, }); + //mapped.clamp_depth(primitive.clamp_depth); + mapped } @@ -647,7 +649,6 @@ fn map_stencil_state_face(desc: &wgt::StencilFaceState) -> web_sys::GpuStencilFa fn map_depth_stencil_state(desc: &wgt::DepthStencilState) -> web_sys::GpuDepthStencilState { let mut mapped = web_sys::GpuDepthStencilState::new(map_texture_format(desc.format)); - mapped.clamp_depth(desc.clamp_depth); mapped.depth_bias(desc.bias.constant); mapped.depth_bias_clamp(desc.bias.clamp); mapped.depth_bias_slope_scale(desc.bias.slope_scale);