ir: Use std::optional::value_or to simplify code

Change-Id: Iaf3ec58a70cd49c508c3279f62c029440b82c599
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131520
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2023-05-04 11:53:31 +00:00 committed by Dawn LUCI CQ
parent f789854a94
commit 29bff642fc
1 changed files with 5 additions and 13 deletions

View File

@ -226,19 +226,11 @@ void BuilderImpl::EmitFunction(const ast::Function* ast_func) {
ir_func->pipeline_stage = Function::PipelineStage::kCompute;
auto wg_size = sem->WorkgroupSize();
uint32_t x = wg_size[0].value();
uint32_t y = 1;
uint32_t z = 1;
if (wg_size[1].has_value()) {
y = wg_size[1].value();
if (wg_size[2].has_value()) {
z = wg_size[2].value();
}
}
ir_func->workgroup_size = {x, y, z};
ir_func->workgroup_size = {
wg_size[0].value(),
wg_size[1].value_or(1),
wg_size[2].value_or(1),
};
break;
}
default: {