From 57f9a13ee7d87bb8289f8262bcf9448ac7a5b547 Mon Sep 17 00:00:00 2001 From: chyyran Date: Fri, 13 Sep 2024 18:03:27 -0400 Subject: [PATCH] rt(wgpu): use `Option::filter` instead of `let_chains` --- librashader-runtime-wgpu/src/filter_pass.rs | 7 +++++-- librashader-runtime-wgpu/src/graphics_pipeline.rs | 12 ++++++++---- librashader-runtime-wgpu/src/lib.rs | 1 - librashader-runtime-wgpu/tests/hello_triangle.rs | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/librashader-runtime-wgpu/src/filter_pass.rs b/librashader-runtime-wgpu/src/filter_pass.rs index b04a0f4..f50935a 100644 --- a/librashader-runtime-wgpu/src/filter_pass.rs +++ b/librashader-runtime-wgpu/src/filter_pass.rs @@ -180,8 +180,11 @@ impl FilterPass { render_pass.set_bind_group(1, &sampler_bind_group, &[]); - if let Some(push) = &self.reflection.push_constant - && !has_pcb_buffer + if let Some(push) = &self + .reflection + .push_constant + .as_ref() + .filter(|_| !has_pcb_buffer) { let mut stage_mask = ShaderStages::empty(); if push.stage_mask.contains(BindingStage::FRAGMENT) { diff --git a/librashader-runtime-wgpu/src/graphics_pipeline.rs b/librashader-runtime-wgpu/src/graphics_pipeline.rs index c0d338a..4cc16ce 100644 --- a/librashader-runtime-wgpu/src/graphics_pipeline.rs +++ b/librashader-runtime-wgpu/src/graphics_pipeline.rs @@ -56,8 +56,10 @@ impl PipelineLayoutObjects { let mut push_constant_range = Vec::new(); - if let Some(push_meta) = reflection.push_constant.as_ref() - && !push_meta.stage_mask.is_empty() + if let Some(push_meta) = reflection + .push_constant + .as_ref() + .filter(|push_meta| !push_meta.stage_mask.is_empty()) { let push_mask = util::binding_stage_to_wgpu_stage(push_meta.stage_mask); @@ -80,8 +82,10 @@ impl PipelineLayoutObjects { } } - if let Some(ubo_meta) = reflection.ubo.as_ref() - && !ubo_meta.stage_mask.is_empty() + if let Some(ubo_meta) = reflection + .ubo + .as_ref() + .filter(|ubo_meta| !ubo_meta.stage_mask.is_empty()) { let ubo_mask = util::binding_stage_to_wgpu_stage(ubo_meta.stage_mask); main_bindings.push(BindGroupLayoutEntry { diff --git a/librashader-runtime-wgpu/src/lib.rs b/librashader-runtime-wgpu/src/lib.rs index 7eb1cec..9efb1e8 100644 --- a/librashader-runtime-wgpu/src/lib.rs +++ b/librashader-runtime-wgpu/src/lib.rs @@ -4,7 +4,6 @@ //! See [`librashader::runtime::wgpu`](https://docs.rs/librashader/latest/librashader/runtime/wgpu/index.html) instead. #![deny(unsafe_op_in_unsafe_fn)] #![feature(type_alias_impl_trait)] -#![feature(let_chains)] mod buffer; mod draw_quad; diff --git a/librashader-runtime-wgpu/tests/hello_triangle.rs b/librashader-runtime-wgpu/tests/hello_triangle.rs index d487a35..bceaca9 100644 --- a/librashader-runtime-wgpu/tests/hello_triangle.rs +++ b/librashader-runtime-wgpu/tests/hello_triangle.rs @@ -124,7 +124,8 @@ impl<'a> State<'a> { // // let preset = ShaderPreset::try_parse("../test/basic.slangp").unwrap(); // - let preset = ShaderPreset::try_parse("../test/shaders_slang/test/feedback.slangp").unwrap(); + let preset = + ShaderPreset::try_parse("../test/shaders_slang/crt/crt-royale.slangp").unwrap(); // let preset = ShaderPreset::try_parse( // "../test/shaders_slang/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",