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>
This commit is contained in:
Corentin Wallez
2020-09-24 14:56:50 +00:00
committed by Commit Bot service account
parent a46737c0aa
commit eec9edfd57
42 changed files with 136 additions and 276 deletions

View File

@@ -40,9 +40,9 @@ namespace dawn_native { namespace opengl {
}
}
default:
case wgpu::TextureDimension::e1D:
case wgpu::TextureDimension::e3D:
UNREACHABLE();
return GL_TEXTURE_2D;
}
}
@@ -62,9 +62,11 @@ namespace dawn_native { namespace opengl {
return GL_TEXTURE_CUBE_MAP;
case wgpu::TextureViewDimension::CubeArray:
return GL_TEXTURE_CUBE_MAP_ARRAY;
default:
case wgpu::TextureViewDimension::e1D:
case wgpu::TextureViewDimension::e3D:
case wgpu::TextureViewDimension::Undefined:
UNREACHABLE();
return GL_TEXTURE_2D;
}
}
@@ -141,7 +143,9 @@ namespace dawn_native { namespace opengl {
}
}
break;
default:
case wgpu::TextureDimension::e1D:
case wgpu::TextureDimension::e3D:
UNREACHABLE();
}
@@ -279,7 +283,8 @@ namespace dawn_native { namespace opengl {
}
break;
default:
case wgpu::TextureDimension::e1D:
case wgpu::TextureDimension::e3D:
UNREACHABLE();
}
}
@@ -386,7 +391,8 @@ namespace dawn_native { namespace opengl {
}
break;
default:
case wgpu::TextureDimension::e1D:
case wgpu::TextureDimension::e3D:
UNREACHABLE();
}
}