From e97bda20b25baa1bf2e60de70e5487fd76262d89 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Thu, 23 Jul 2020 22:35:13 -0400 Subject: [PATCH] [rs] Update wgpu, use defaults for rasterizer states, use depth-clamping --- wgpu/Cargo.toml | 4 ++-- wgpu/examples/README.md | 1 + wgpu/examples/boids/main.rs | 4 +--- wgpu/examples/cube/main.rs | 4 +--- wgpu/examples/mipmap/main.rs | 8 ++------ wgpu/examples/msaa-line/main.rs | 4 +--- wgpu/examples/shadow/main.rs | 9 ++++++--- wgpu/examples/skybox/main.rs | 4 +--- wgpu/examples/texture-arrays/main.rs | 4 +--- wgpu/examples/water/main.rs | 8 ++------ wgpu/src/backend/direct.rs | 5 +++-- 11 files changed, 21 insertions(+), 34 deletions(-) diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 9d22aaa007..aa0d2e1691 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -27,14 +27,14 @@ vulkan-portability = ["wgc/gfx-backend-vulkan"] package = "wgpu-core" version = "0.5" git = "https://github.com/gfx-rs/wgpu" -rev = "4ed2c0a313deb48a99f15e8fe0558ad3d095ca01" +rev = "0591c48fd234b4faa4c60346454568548ecbe507" features = ["raw-window-handle"] [dependencies.wgt] package = "wgpu-types" version = "0.5" git = "https://github.com/gfx-rs/wgpu" -rev = "4ed2c0a313deb48a99f15e8fe0558ad3d095ca01" +rev = "0591c48fd234b4faa4c60346454568548ecbe507" [dependencies] arrayvec = "0.5" diff --git a/wgpu/examples/README.md b/wgpu/examples/README.md index d6e69079be..8060bfa6b1 100644 --- a/wgpu/examples/README.md +++ b/wgpu/examples/README.md @@ -33,6 +33,7 @@ All framework-based examples render to the window. | optional extensions | | | | | | | :star: | | | - binding indexing | | | | | | | :star: | | | - push constants | | | | | | | :star: | | +| - depth clamping | | | | | :star | | | | | WGSL shaders | | | | | | | | | ## Hacking diff --git a/wgpu/examples/boids/main.rs b/wgpu/examples/boids/main.rs index 17e33c964a..75833953f1 100644 --- a/wgpu/examples/boids/main.rs +++ b/wgpu/examples/boids/main.rs @@ -116,9 +116,7 @@ impl framework::Example for Example { rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Ccw, cull_mode: wgpu::CullMode::None, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, + ..Default::default() }), primitive_topology: wgpu::PrimitiveTopology::TriangleList, color_states: Borrowed(&[wgpu::ColorStateDescriptor { diff --git a/wgpu/examples/cube/main.rs b/wgpu/examples/cube/main.rs index b0b3714456..1805f6b895 100644 --- a/wgpu/examples/cube/main.rs +++ b/wgpu/examples/cube/main.rs @@ -252,9 +252,7 @@ impl framework::Example for Example { rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Ccw, cull_mode: wgpu::CullMode::Back, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, + ..Default::default() }), primitive_topology: wgpu::PrimitiveTopology::TriangleList, color_states: Borrowed(&[wgpu::ColorStateDescriptor { diff --git a/wgpu/examples/mipmap/main.rs b/wgpu/examples/mipmap/main.rs index 8224a18f1c..23aafe2600 100644 --- a/wgpu/examples/mipmap/main.rs +++ b/wgpu/examples/mipmap/main.rs @@ -121,9 +121,7 @@ impl Example { rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Ccw, cull_mode: wgpu::CullMode::None, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, + ..Default::default() }), primitive_topology: wgpu::PrimitiveTopology::TriangleStrip, color_states: Borrowed(&[wgpu::ColorStateDescriptor { @@ -351,9 +349,7 @@ impl framework::Example for Example { rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Ccw, cull_mode: wgpu::CullMode::Back, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, + ..Default::default() }), primitive_topology: wgpu::PrimitiveTopology::TriangleStrip, color_states: Borrowed(&[wgpu::ColorStateDescriptor { diff --git a/wgpu/examples/msaa-line/main.rs b/wgpu/examples/msaa-line/main.rs index 3062ab77c4..56f44e9dba 100644 --- a/wgpu/examples/msaa-line/main.rs +++ b/wgpu/examples/msaa-line/main.rs @@ -62,9 +62,7 @@ impl Example { rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Ccw, cull_mode: wgpu::CullMode::None, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, + ..Default::default() }), primitive_topology: wgpu::PrimitiveTopology::LineList, color_states: Cow::Borrowed(&[wgpu::ColorStateDescriptor { diff --git a/wgpu/examples/shadow/main.rs b/wgpu/examples/shadow/main.rs index f1324d0fe0..2971db74fb 100644 --- a/wgpu/examples/shadow/main.rs +++ b/wgpu/examples/shadow/main.rs @@ -203,6 +203,10 @@ impl Example { } impl framework::Example for Example { + fn needed_features() -> wgpu::Features { + wgpu::Features::DEPTH_CLAMPING + } + fn init( sc_desc: &wgpu::SwapChainDescriptor, device: &wgpu::Device, @@ -483,6 +487,7 @@ impl framework::Example for Example { depth_bias: 2, // corresponds to bilinear filtering depth_bias_slope_scale: 2.0, depth_bias_clamp: 0.0, + clamp_depth: device.features().contains(wgpu::Features::DEPTH_CLAMPING), }), primitive_topology: wgpu::PrimitiveTopology::TriangleList, color_states: Borrowed(&[]), @@ -609,9 +614,7 @@ impl framework::Example for Example { rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Ccw, cull_mode: wgpu::CullMode::Back, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, + ..Default::default() }), primitive_topology: wgpu::PrimitiveTopology::TriangleList, color_states: Borrowed(&[wgpu::ColorStateDescriptor { diff --git a/wgpu/examples/skybox/main.rs b/wgpu/examples/skybox/main.rs index 610cfbfed7..6abc745d75 100644 --- a/wgpu/examples/skybox/main.rs +++ b/wgpu/examples/skybox/main.rs @@ -102,9 +102,7 @@ impl framework::Example for Skybox { rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Cw, cull_mode: wgpu::CullMode::None, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, + ..Default::default() }), primitive_topology: wgpu::PrimitiveTopology::TriangleList, color_states: Borrowed(&[wgpu::ColorStateDescriptor { diff --git a/wgpu/examples/texture-arrays/main.rs b/wgpu/examples/texture-arrays/main.rs index 3b3c6ad4fb..f481248525 100644 --- a/wgpu/examples/texture-arrays/main.rs +++ b/wgpu/examples/texture-arrays/main.rs @@ -269,9 +269,7 @@ impl framework::Example for Example { rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Ccw, cull_mode: wgpu::CullMode::None, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, + ..Default::default() }), primitive_topology: wgpu::PrimitiveTopology::TriangleList, color_states: Borrowed(&[wgpu::ColorStateDescriptor { diff --git a/wgpu/examples/water/main.rs b/wgpu/examples/water/main.rs index 39f55a6173..cdb2170115 100644 --- a/wgpu/examples/water/main.rs +++ b/wgpu/examples/water/main.rs @@ -504,9 +504,7 @@ impl framework::Example for Example { rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Cw, cull_mode: wgpu::CullMode::None, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, + ..Default::default() }), // What kind of data are we passing in? primitive_topology: wgpu::PrimitiveTopology::TriangleList, @@ -577,9 +575,7 @@ impl framework::Example for Example { rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Ccw, cull_mode: wgpu::CullMode::Front, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, + ..Default::default() }), primitive_topology: wgpu::PrimitiveTopology::TriangleList, color_states: Borrowed(&[wgpu::ColorStateDescriptor { diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 55e966e10a..ee79e5a3fc 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -586,11 +586,12 @@ impl crate::Context for Context { source: ShaderModuleSource, ) -> Self::ShaderModuleId { let desc = match source { - ShaderModuleSource::SpirV(ref spv) => wgc::pipeline::ShaderModuleSource::SpirV(spv), - ShaderModuleSource::Wgsl(ref code) => wgc::pipeline::ShaderModuleSource::Wgsl(code), + ShaderModuleSource::SpirV(spv) => wgc::pipeline::ShaderModuleSource::SpirV(spv), + ShaderModuleSource::Wgsl(code) => wgc::pipeline::ShaderModuleSource::Wgsl(code), }; let global = &self.0; wgc::gfx_select!(*device => global.device_create_shader_module(*device, desc, PhantomData)) + .unwrap() } fn device_create_bind_group_layout(