Skip to content

Commit 7bca8f3

Browse files
refactor(gpu-tests): array_size_overrides: use pipeline_constants more monadically
1 parent 88a8147 commit 7bca8f3

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

tests/tests/wgpu-gpu/shader/array_size_overrides.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ async fn array_size_overrides(
7373
label: None,
7474
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(SHADER)),
7575
});
76-
let pipeline_options = wgpu::PipelineCompilationOptions {
77-
constants: &[("n", f64::from(n.unwrap_or(0)))],
78-
..Default::default()
79-
};
76+
let pipeline_constants = n.map(f64::from).map(|n| [("n", n)]);
8077
let compute_pipeline = fail_if(
8178
&ctx.device,
8279
should_fail,
@@ -87,11 +84,13 @@ async fn array_size_overrides(
8784
layout: None,
8885
module: &module,
8986
entry_point: Some("main"),
90-
compilation_options: if n.is_some() {
91-
pipeline_options
92-
} else {
93-
wgpu::PipelineCompilationOptions::default()
94-
},
87+
compilation_options: pipeline_constants
88+
.as_ref()
89+
.map(|constants| wgpu::PipelineCompilationOptions {
90+
constants,
91+
..Default::default()
92+
})
93+
.unwrap_or_default(),
9594
cache: None,
9695
})
9796
},

0 commit comments

Comments
 (0)