Standardize the use of UNREACHABLE in switches.
A lot of our switches over enum values use the following pattern:
default:
UNREACHABLE();
return foo;
This is problematic because when adding a new value to one of the WebGPU
enums, there is no compilation error for switches that are missing it.
Currently we're supposed to write code and tests and fix UNREACHABLEs when
we see them.
Instead we should strive to have most switches on enums to be complete
and explicitily tag unreachable values as UNREACHABLE. Some switches
might still want to use default: UNREACHABLE() if only a couple values
need to be handled out of very many.
In this CL we go through all the UNRAECHABLEs and change them if need
be. Also an ErrorQueue class is added to avoid having
QueueBase::SubmitImpl just be UNREACHABLE (and force overriding
instead).
Bug: dawn:527
Change-Id: I33dfb4703104912cc5f001f9faf907a61324de68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/28501
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
diff --git a/src/dawn_native/vulkan/UtilsVulkan.cpp b/src/dawn_native/vulkan/UtilsVulkan.cpp
index 1b6b2d6..8941656 100644
--- a/src/dawn_native/vulkan/UtilsVulkan.cpp
+++ b/src/dawn_native/vulkan/UtilsVulkan.cpp
@@ -40,7 +40,8 @@
return VK_COMPARE_OP_NOT_EQUAL;
case wgpu::CompareFunction::Always:
return VK_COMPARE_OP_ALWAYS;
- default:
+
+ case wgpu::CompareFunction::Undefined:
UNREACHABLE();
}
}
@@ -59,9 +60,8 @@
case Aspect::Stencil:
flags |= VK_IMAGE_ASPECT_STENCIL_BIT;
break;
- default:
+ case Aspect::None:
UNREACHABLE();
- break;
}
}
return flags;
@@ -133,9 +133,9 @@
break;
}
- default:
+ case wgpu::TextureDimension::e1D:
+ case wgpu::TextureDimension::e3D:
UNREACHABLE();
- break;
}
return region;