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

@ -159,6 +159,7 @@ namespace dawn_native {
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
break;
} }
return {}; return {};

View File

@ -57,17 +57,14 @@ namespace dawn_native {
private: private:
bool IsCPUWritableAtCreation() const override { bool IsCPUWritableAtCreation() const override {
UNREACHABLE(); UNREACHABLE();
return false;
} }
MaybeError MapAtCreationImpl() override { MaybeError MapAtCreationImpl() override {
UNREACHABLE(); UNREACHABLE();
return {};
} }
MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override { MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override {
UNREACHABLE(); UNREACHABLE();
return {};
} }
void* GetMappedPointerImpl() override { void* GetMappedPointerImpl() override {
return mFakeMappedData.get(); return mFakeMappedData.get();
@ -212,8 +209,6 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR("Buffer used in a submit while mapped"); return DAWN_VALIDATION_ERROR("Buffer used in a submit while mapped");
case BufferState::Unmapped: case BufferState::Unmapped:
return {}; return {};
default:
UNREACHABLE();
} }
} }
@ -480,9 +475,6 @@ namespace dawn_native {
case BufferState::Unmapped: case BufferState::Unmapped:
case BufferState::Destroyed: case BufferState::Destroyed:
return false; return false;
default:
UNREACHABLE();
} }
} }
@ -503,8 +495,6 @@ namespace dawn_native {
return {}; return {};
case BufferState::Destroyed: case BufferState::Destroyed:
return DAWN_VALIDATION_ERROR("Buffer is destroyed"); return DAWN_VALIDATION_ERROR("Buffer is destroyed");
default:
UNREACHABLE();
} }
} }

View File

@ -121,10 +121,6 @@ namespace dawn_native {
case wgpu::StoreOp::Clear: case wgpu::StoreOp::Clear:
view->GetTexture()->SetIsSubresourceContentInitialized(false, range); view->GetTexture()->SetIsSubresourceContentInitialized(false, range);
break; break;
default:
UNREACHABLE();
break;
} }
} }

View File

@ -127,8 +127,6 @@ namespace dawn_native {
case wgpu::TextureAspect::StencilOnly: case wgpu::TextureAspect::StencilOnly:
ASSERT(format.aspects & Aspect::Stencil); ASSERT(format.aspects & Aspect::Stencil);
break; break;
default:
UNREACHABLE();
} }
if (depthSelected) { if (depthSelected) {
@ -141,9 +139,9 @@ namespace dawn_native {
break; break;
case wgpu::TextureFormat::Depth32Float: case wgpu::TextureFormat::Depth32Float:
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
break;
} }
} }

View File

@ -65,7 +65,9 @@ namespace dawn_native {
return BackendType::OpenGL; return BackendType::OpenGL;
case wgpu::BackendType::Vulkan: case wgpu::BackendType::Vulkan:
return BackendType::Vulkan; return BackendType::Vulkan;
default:
case wgpu::BackendType::D3D11:
case wgpu::BackendType::OpenGLES:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -80,8 +82,6 @@ namespace dawn_native {
return DeviceType::CPU; return DeviceType::CPU;
case wgpu::AdapterType::Unknown: case wgpu::AdapterType::Unknown:
return DeviceType::Unknown; return DeviceType::Unknown;
default:
UNREACHABLE();
} }
} }

View File

@ -95,7 +95,6 @@ namespace dawn_native {
break; break;
case wgpu::ErrorType::NoError: case wgpu::ErrorType::NoError:
default:
UNREACHABLE(); UNREACHABLE();
return; return;
} }

View File

@ -32,8 +32,6 @@ namespace dawn_native {
case wgpu::TextureComponentType::Sint: case wgpu::TextureComponentType::Sint:
case wgpu::TextureComponentType::Uint: case wgpu::TextureComponentType::Uint:
break; break;
default:
UNREACHABLE();
} }
// Check that Type correctly mirrors TextureComponentType except for "Other". // Check that Type correctly mirrors TextureComponentType except for "Other".
static_assert(static_cast<Type>(wgpu::TextureComponentType::Float) == Type::Float, ""); static_assert(static_cast<Type>(wgpu::TextureComponentType::Float) == Type::Float, "");
@ -49,7 +47,8 @@ namespace dawn_native {
case Type::Sint: case Type::Sint:
case Type::Uint: case Type::Uint:
break; break;
default:
case Type::Other:
UNREACHABLE(); UNREACHABLE();
} }
// Check that Type correctly mirrors TextureComponentType except for "Other". // Check that Type correctly mirrors TextureComponentType except for "Other".
@ -105,10 +104,6 @@ namespace dawn_native {
break; break;
} }
break; break;
default:
UNREACHABLE();
break;
} }
} }
@ -136,9 +131,9 @@ namespace dawn_native {
break; break;
} }
break; break;
default:
case Aspect::None:
UNREACHABLE(); UNREACHABLE();
break;
} }
} }

View File

@ -119,7 +119,21 @@ namespace dawn_native {
return uploadHandle; return uploadHandle;
} }
class ErrorQueue : public QueueBase {
public:
ErrorQueue(DeviceBase* device) : QueueBase(device, ObjectBase::kError) {
}
private:
MaybeError SubmitImpl(uint32_t commandCount,
CommandBufferBase* const* commands) override {
UNREACHABLE();
}
};
} // namespace } // namespace
// QueueBase // QueueBase
QueueBase::QueueBase(DeviceBase* device) : ObjectBase(device) { QueueBase::QueueBase(DeviceBase* device) : ObjectBase(device) {
@ -130,12 +144,7 @@ namespace dawn_native {
// static // static
QueueBase* QueueBase::MakeError(DeviceBase* device) { QueueBase* QueueBase::MakeError(DeviceBase* device) {
return new QueueBase(device, ObjectBase::kError); return new ErrorQueue(device);
}
MaybeError QueueBase::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) {
UNREACHABLE();
return {};
} }
void QueueBase::Submit(uint32_t commandCount, CommandBufferBase* const* commands) { void QueueBase::Submit(uint32_t commandCount, CommandBufferBase* const* commands) {

View File

@ -25,8 +25,6 @@ namespace dawn_native {
class QueueBase : public ObjectBase { class QueueBase : public ObjectBase {
public: public:
QueueBase(DeviceBase* device);
static QueueBase* MakeError(DeviceBase* device); static QueueBase* MakeError(DeviceBase* device);
// Dawn API // Dawn API
@ -40,9 +38,11 @@ namespace dawn_native {
const TextureDataLayout* dataLayout, const TextureDataLayout* dataLayout,
const Extent3D* writeSize); const Extent3D* writeSize);
private: protected:
QueueBase(DeviceBase* device);
QueueBase(DeviceBase* device, ObjectBase::ErrorTag tag); QueueBase(DeviceBase* device, ObjectBase::ErrorTag tag);
private:
MaybeError WriteBufferInternal(BufferBase* buffer, MaybeError WriteBufferInternal(BufferBase* buffer,
uint64_t bufferOffset, uint64_t bufferOffset,
const void* data, const void* data,
@ -53,7 +53,8 @@ namespace dawn_native {
const TextureDataLayout* dataLayout, const TextureDataLayout* dataLayout,
const Extent3D* writeSize); const Extent3D* writeSize);
virtual MaybeError SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands); virtual MaybeError SubmitImpl(uint32_t commandCount,
CommandBufferBase* const* commands) = 0;
virtual MaybeError WriteBufferImpl(BufferBase* buffer, virtual MaybeError WriteBufferImpl(BufferBase* buffer,
uint64_t bufferOffset, uint64_t bufferOffset,
const void* data, const void* data,

View File

@ -205,7 +205,7 @@ namespace dawn_native {
return sizeof(uint16_t); return sizeof(uint16_t);
case wgpu::IndexFormat::Uint32: case wgpu::IndexFormat::Uint32:
return sizeof(uint32_t); return sizeof(uint32_t);
default: case wgpu::IndexFormat::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -246,8 +246,6 @@ namespace dawn_native {
case wgpu::VertexFormat::UInt: case wgpu::VertexFormat::UInt:
case wgpu::VertexFormat::Int: case wgpu::VertexFormat::Int:
return 1; return 1;
default:
UNREACHABLE();
} }
} }
@ -287,8 +285,6 @@ namespace dawn_native {
case wgpu::VertexFormat::Int3: case wgpu::VertexFormat::Int3:
case wgpu::VertexFormat::Int4: case wgpu::VertexFormat::Int4:
return sizeof(int32_t); return sizeof(int32_t);
default:
UNREACHABLE();
} }
} }

View File

@ -24,8 +24,6 @@ namespace dawn_native {
return spv::ExecutionModelFragment; return spv::ExecutionModelFragment;
case SingleShaderStage::Compute: case SingleShaderStage::Compute:
return spv::ExecutionModelGLCompute; return spv::ExecutionModelGLCompute;
default:
UNREACHABLE();
} }
} }
@ -62,7 +60,6 @@ namespace dawn_native {
} }
default: default:
UNREACHABLE(); UNREACHABLE();
return wgpu::TextureViewDimension::Undefined;
} }
} }
@ -147,7 +144,6 @@ namespace dawn_native {
return Format::Type::Uint; return Format::Type::Uint;
default: default:
UNREACHABLE(); UNREACHABLE();
return Format::Type::Other;
} }
} }

View File

@ -47,9 +47,11 @@ namespace dawn_native {
case wgpu::TextureViewDimension::Cube: case wgpu::TextureViewDimension::Cube:
case wgpu::TextureViewDimension::CubeArray: case wgpu::TextureViewDimension::CubeArray:
return textureDimension == wgpu::TextureDimension::e2D; return textureDimension == wgpu::TextureDimension::e2D;
default:
case wgpu::TextureViewDimension::e1D:
case wgpu::TextureViewDimension::e3D:
case wgpu::TextureViewDimension::Undefined:
UNREACHABLE(); UNREACHABLE();
return false;
} }
} }
@ -66,9 +68,11 @@ namespace dawn_native {
return textureViewArrayLayer == 6u; return textureViewArrayLayer == 6u;
case wgpu::TextureViewDimension::CubeArray: case wgpu::TextureViewDimension::CubeArray:
return textureViewArrayLayer % 6 == 0; return textureViewArrayLayer % 6 == 0;
default:
case wgpu::TextureViewDimension::e1D:
case wgpu::TextureViewDimension::e3D:
case wgpu::TextureViewDimension::Undefined:
UNREACHABLE(); UNREACHABLE();
return false;
} }
} }
@ -82,9 +86,11 @@ namespace dawn_native {
case wgpu::TextureViewDimension::e2D: case wgpu::TextureViewDimension::e2D:
case wgpu::TextureViewDimension::e2DArray: case wgpu::TextureViewDimension::e2DArray:
return true; return true;
default:
case wgpu::TextureViewDimension::e1D:
case wgpu::TextureViewDimension::e3D:
case wgpu::TextureViewDimension::Undefined:
UNREACHABLE(); UNREACHABLE();
return false;
} }
} }
@ -316,9 +322,6 @@ namespace dawn_native {
case wgpu::TextureDimension::e3D: case wgpu::TextureDimension::e3D:
desc.dimension = wgpu::TextureViewDimension::e3D; desc.dimension = wgpu::TextureViewDimension::e3D;
break; break;
default:
UNREACHABLE();
} }
} }
@ -361,9 +364,6 @@ namespace dawn_native {
case wgpu::TextureAspect::StencilOnly: case wgpu::TextureAspect::StencilOnly:
ASSERT(format.aspects & Aspect::Stencil); ASSERT(format.aspects & Aspect::Stencil);
return Aspect::Stencil; return Aspect::Stencil;
default:
UNREACHABLE();
break;
} }
} }

View File

@ -54,8 +54,6 @@ namespace dawn_native { namespace d3d12 {
return DXGI_FORMAT_R16_UINT; return DXGI_FORMAT_R16_UINT;
case wgpu::IndexFormat::Uint32: case wgpu::IndexFormat::Uint32:
return DXGI_FORMAT_R32_UINT; return DXGI_FORMAT_R32_UINT;
default:
UNREACHABLE();
} }
} }
@ -67,8 +65,6 @@ namespace dawn_native { namespace d3d12 {
return D3D12_QUERY_TYPE_PIPELINE_STATISTICS; return D3D12_QUERY_TYPE_PIPELINE_STATISTICS;
case wgpu::QueryType::Timestamp: case wgpu::QueryType::Timestamp:
return D3D12_QUERY_TYPE_TIMESTAMP; return D3D12_QUERY_TYPE_TIMESTAMP;
default:
UNREACHABLE();
} }
} }
@ -389,7 +385,6 @@ namespace dawn_native { namespace d3d12 {
case wgpu::BindingType::ReadonlyStorageTexture: case wgpu::BindingType::ReadonlyStorageTexture:
case wgpu::BindingType::WriteonlyStorageTexture: case wgpu::BindingType::WriteonlyStorageTexture:
UNREACHABLE(); UNREACHABLE();
break;
} }
} }
} }
@ -954,10 +949,9 @@ namespace dawn_native { namespace d3d12 {
} }
break; break;
} }
default: {
default:
UNREACHABLE(); UNREACHABLE();
break;
}
} }
} }
@ -1072,10 +1066,8 @@ namespace dawn_native { namespace d3d12 {
break; break;
} }
default: { default:
UNREACHABLE(); UNREACHABLE();
break;
}
} }
} }

View File

@ -28,8 +28,6 @@ namespace dawn_native { namespace d3d12 {
return D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS; return D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS;
case wgpu::QueryType::Timestamp: case wgpu::QueryType::Timestamp:
return D3D12_QUERY_HEAP_TYPE_TIMESTAMP; return D3D12_QUERY_HEAP_TYPE_TIMESTAMP;
default:
UNREACHABLE();
} }
} }
} // anonymous namespace } // anonymous namespace

View File

@ -30,8 +30,6 @@ namespace dawn_native { namespace d3d12 {
return D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR; return D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR;
case wgpu::LoadOp::Load: case wgpu::LoadOp::Load:
return D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE; return D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE;
default:
UNREACHABLE();
} }
} }
@ -41,8 +39,6 @@ namespace dawn_native { namespace d3d12 {
return D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_DISCARD; return D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_DISCARD;
case wgpu::StoreOp::Store: case wgpu::StoreOp::Store:
return D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE; return D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE;
default:
UNREACHABLE();
} }
} }

View File

@ -91,8 +91,6 @@ namespace dawn_native { namespace d3d12 {
return DXGI_FORMAT_R32G32B32_SINT; return DXGI_FORMAT_R32G32B32_SINT;
case wgpu::VertexFormat::Int4: case wgpu::VertexFormat::Int4:
return DXGI_FORMAT_R32G32B32A32_SINT; return DXGI_FORMAT_R32G32B32A32_SINT;
default:
UNREACHABLE();
} }
} }
@ -102,8 +100,6 @@ namespace dawn_native { namespace d3d12 {
return D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA; return D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA;
case wgpu::InputStepMode::Instance: case wgpu::InputStepMode::Instance:
return D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA; return D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA;
default:
UNREACHABLE();
} }
} }
@ -119,8 +115,6 @@ namespace dawn_native { namespace d3d12 {
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
case wgpu::PrimitiveTopology::TriangleStrip: case wgpu::PrimitiveTopology::TriangleStrip:
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
default:
UNREACHABLE();
} }
} }
@ -135,8 +129,6 @@ namespace dawn_native { namespace d3d12 {
case wgpu::PrimitiveTopology::TriangleList: case wgpu::PrimitiveTopology::TriangleList:
case wgpu::PrimitiveTopology::TriangleStrip: case wgpu::PrimitiveTopology::TriangleStrip:
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
default:
UNREACHABLE();
} }
} }
@ -148,8 +140,6 @@ namespace dawn_native { namespace d3d12 {
return D3D12_CULL_MODE_FRONT; return D3D12_CULL_MODE_FRONT;
case wgpu::CullMode::Back: case wgpu::CullMode::Back:
return D3D12_CULL_MODE_BACK; return D3D12_CULL_MODE_BACK;
default:
UNREACHABLE();
} }
} }
@ -181,8 +171,6 @@ namespace dawn_native { namespace d3d12 {
return D3D12_BLEND_BLEND_FACTOR; return D3D12_BLEND_BLEND_FACTOR;
case wgpu::BlendFactor::OneMinusBlendColor: case wgpu::BlendFactor::OneMinusBlendColor:
return D3D12_BLEND_INV_BLEND_FACTOR; return D3D12_BLEND_INV_BLEND_FACTOR;
default:
UNREACHABLE();
} }
} }
@ -198,8 +186,6 @@ namespace dawn_native { namespace d3d12 {
return D3D12_BLEND_OP_MIN; return D3D12_BLEND_OP_MIN;
case wgpu::BlendOperation::Max: case wgpu::BlendOperation::Max:
return D3D12_BLEND_OP_MAX; return D3D12_BLEND_OP_MAX;
default:
UNREACHABLE();
} }
} }
@ -252,8 +238,6 @@ namespace dawn_native { namespace d3d12 {
return D3D12_STENCIL_OP_INCR; return D3D12_STENCIL_OP_INCR;
case wgpu::StencilOperation::DecrementWrap: case wgpu::StencilOperation::DecrementWrap:
return D3D12_STENCIL_OP_DECR; return D3D12_STENCIL_OP_DECR;
default:
UNREACHABLE();
} }
} }

View File

@ -51,7 +51,7 @@ namespace dawn_native { namespace d3d12 {
case Upload_OnlyBuffers: case Upload_OnlyBuffers:
case Upload_AllBuffersAndTextures: case Upload_AllBuffersAndTextures:
return D3D12_HEAP_TYPE_UPLOAD; return D3D12_HEAP_TYPE_UPLOAD;
default: case EnumCount:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -70,7 +70,7 @@ namespace dawn_native { namespace d3d12 {
return D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES; return D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES;
case Default_OnlyRenderableOrDepthTextures: case Default_OnlyRenderableOrDepthTextures:
return D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES; return D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES;
default: case EnumCount:
UNREACHABLE(); UNREACHABLE();
} }
} }

View File

@ -28,8 +28,6 @@ namespace dawn_native { namespace d3d12 {
return D3D12_TEXTURE_ADDRESS_MODE_MIRROR; return D3D12_TEXTURE_ADDRESS_MODE_MIRROR;
case wgpu::AddressMode::ClampToEdge: case wgpu::AddressMode::ClampToEdge:
return D3D12_TEXTURE_ADDRESS_MODE_CLAMP; return D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
default:
UNREACHABLE();
} }
} }
} // namespace } // namespace
@ -44,9 +42,6 @@ namespace dawn_native { namespace d3d12 {
case wgpu::FilterMode::Linear: case wgpu::FilterMode::Linear:
minFilter = D3D12_FILTER_TYPE_LINEAR; minFilter = D3D12_FILTER_TYPE_LINEAR;
break; break;
default:
UNREACHABLE();
break;
} }
D3D12_FILTER_TYPE magFilter; D3D12_FILTER_TYPE magFilter;
@ -57,9 +52,6 @@ namespace dawn_native { namespace d3d12 {
case wgpu::FilterMode::Linear: case wgpu::FilterMode::Linear:
magFilter = D3D12_FILTER_TYPE_LINEAR; magFilter = D3D12_FILTER_TYPE_LINEAR;
break; break;
default:
UNREACHABLE();
break;
} }
D3D12_FILTER_TYPE mipmapFilter; D3D12_FILTER_TYPE mipmapFilter;
@ -70,9 +62,6 @@ namespace dawn_native { namespace d3d12 {
case wgpu::FilterMode::Linear: case wgpu::FilterMode::Linear:
mipmapFilter = D3D12_FILTER_TYPE_LINEAR; mipmapFilter = D3D12_FILTER_TYPE_LINEAR;
break; break;
default:
UNREACHABLE();
break;
} }
D3D12_FILTER_REDUCTION_TYPE reduction = D3D12_FILTER_REDUCTION_TYPE reduction =

View File

@ -96,7 +96,9 @@ namespace dawn_native { namespace d3d12 {
switch (dimension) { switch (dimension) {
case wgpu::TextureDimension::e2D: case wgpu::TextureDimension::e2D:
return D3D12_RESOURCE_DIMENSION_TEXTURE2D; return D3D12_RESOURCE_DIMENSION_TEXTURE2D;
default:
case wgpu::TextureDimension::e1D:
case wgpu::TextureDimension::e3D:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -199,7 +201,7 @@ namespace dawn_native { namespace d3d12 {
case wgpu::TextureFormat::BC7RGBAUnormSrgb: case wgpu::TextureFormat::BC7RGBAUnormSrgb:
return DXGI_FORMAT_BC7_TYPELESS; return DXGI_FORMAT_BC7_TYPELESS;
default: case wgpu::TextureFormat::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -321,7 +323,7 @@ namespace dawn_native { namespace d3d12 {
case wgpu::TextureFormat::BC7RGBAUnormSrgb: case wgpu::TextureFormat::BC7RGBAUnormSrgb:
return DXGI_FORMAT_BC7_UNORM_SRGB; return DXGI_FORMAT_BC7_UNORM_SRGB;
default: case wgpu::TextureFormat::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -552,7 +554,6 @@ namespace dawn_native { namespace d3d12 {
return DXGI_FORMAT_R8_UINT; return DXGI_FORMAT_R8_UINT;
default: default:
UNREACHABLE(); UNREACHABLE();
return GetD3D12Format();
} }
default: default:
ASSERT(HasOneBit(GetFormat().aspects)); ASSERT(HasOneBit(GetFormat().aspects));
@ -888,7 +889,6 @@ namespace dawn_native { namespace d3d12 {
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
break;
} }
} }
@ -1050,6 +1050,7 @@ namespace dawn_native { namespace d3d12 {
ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D); ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D);
mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMS; mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMS;
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
@ -1077,7 +1078,10 @@ namespace dawn_native { namespace d3d12 {
mSrvDesc.TextureCubeArray.MipLevels = descriptor->mipLevelCount; mSrvDesc.TextureCubeArray.MipLevels = descriptor->mipLevelCount;
mSrvDesc.TextureCubeArray.ResourceMinLODClamp = 0; mSrvDesc.TextureCubeArray.ResourceMinLODClamp = 0;
break; break;
default:
case wgpu::TextureViewDimension::e1D:
case wgpu::TextureViewDimension::e3D:
case wgpu::TextureViewDimension::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
} }

View File

@ -60,7 +60,8 @@ namespace dawn_native { namespace d3d12 {
return D3D12_COMPARISON_FUNC_NOT_EQUAL; return D3D12_COMPARISON_FUNC_NOT_EQUAL;
case wgpu::CompareFunction::Always: case wgpu::CompareFunction::Always:
return D3D12_COMPARISON_FUNC_ALWAYS; return D3D12_COMPARISON_FUNC_ALWAYS;
default:
case wgpu::CompareFunction::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
} }

View File

@ -47,7 +47,7 @@ namespace dawn_native { namespace metal {
return MTLIndexTypeUInt16; return MTLIndexTypeUInt16;
case wgpu::IndexFormat::Uint32: case wgpu::IndexFormat::Uint32:
return MTLIndexTypeUInt32; return MTLIndexTypeUInt32;
default: case wgpu::IndexFormat::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -74,10 +74,6 @@ namespace dawn_native { namespace metal {
case wgpu::LoadOp::Load: case wgpu::LoadOp::Load:
descriptor.colorAttachments[i].loadAction = MTLLoadActionLoad; descriptor.colorAttachments[i].loadAction = MTLLoadActionLoad;
break; break;
default:
UNREACHABLE();
break;
} }
descriptor.colorAttachments[i].texture = descriptor.colorAttachments[i].texture =
@ -107,10 +103,6 @@ namespace dawn_native { namespace metal {
case wgpu::StoreOp::Clear: case wgpu::StoreOp::Clear:
descriptor.colorAttachments[i].storeAction = MTLStoreActionDontCare; descriptor.colorAttachments[i].storeAction = MTLStoreActionDontCare;
break; break;
default:
UNREACHABLE();
break;
} }
} }
@ -134,10 +126,6 @@ namespace dawn_native { namespace metal {
case wgpu::StoreOp::Clear: case wgpu::StoreOp::Clear:
descriptor.depthAttachment.storeAction = MTLStoreActionDontCare; descriptor.depthAttachment.storeAction = MTLStoreActionDontCare;
break; break;
default:
UNREACHABLE();
break;
} }
switch (attachmentInfo.depthLoadOp) { switch (attachmentInfo.depthLoadOp) {
@ -149,10 +137,6 @@ namespace dawn_native { namespace metal {
case wgpu::LoadOp::Load: case wgpu::LoadOp::Load:
descriptor.depthAttachment.loadAction = MTLLoadActionLoad; descriptor.depthAttachment.loadAction = MTLLoadActionLoad;
break; break;
default:
UNREACHABLE();
break;
} }
} }
@ -169,10 +153,6 @@ namespace dawn_native { namespace metal {
case wgpu::StoreOp::Clear: case wgpu::StoreOp::Clear:
descriptor.stencilAttachment.storeAction = MTLStoreActionDontCare; descriptor.stencilAttachment.storeAction = MTLStoreActionDontCare;
break; break;
default:
UNREACHABLE();
break;
} }
switch (attachmentInfo.stencilLoadOp) { switch (attachmentInfo.stencilLoadOp) {
@ -184,10 +164,6 @@ namespace dawn_native { namespace metal {
case wgpu::LoadOp::Load: case wgpu::LoadOp::Load:
descriptor.stencilAttachment.loadAction = MTLLoadActionLoad; descriptor.stencilAttachment.loadAction = MTLLoadActionLoad;
break; break;
default:
UNREACHABLE();
break;
} }
} }
} }
@ -797,10 +773,8 @@ namespace dawn_native { namespace metal {
break; break;
} }
default: { default:
UNREACHABLE(); UNREACHABLE();
break;
}
} }
} }

View File

@ -63,9 +63,11 @@ namespace dawn_native { namespace metal {
return MTLTextureTypeCube; return MTLTextureTypeCube;
case wgpu::TextureViewDimension::CubeArray: case wgpu::TextureViewDimension::CubeArray:
return MTLTextureTypeCubeArray; return MTLTextureTypeCubeArray;
default:
case wgpu::TextureViewDimension::e1D:
case wgpu::TextureViewDimension::e3D:
case wgpu::TextureViewDimension::Undefined:
UNREACHABLE(); UNREACHABLE();
return MTLTextureType2D;
} }
} }
@ -316,7 +318,8 @@ namespace dawn_native { namespace metal {
} }
break; break;
default: case wgpu::TextureDimension::e1D:
case wgpu::TextureDimension::e3D:
UNREACHABLE(); UNREACHABLE();
} }
@ -430,7 +433,6 @@ namespace dawn_native { namespace metal {
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
break;
} }
} }

View File

@ -37,7 +37,8 @@ namespace dawn_native { namespace metal {
return MTLCompareFunctionEqual; return MTLCompareFunctionEqual;
case wgpu::CompareFunction::Always: case wgpu::CompareFunction::Always:
return MTLCompareFunctionAlways; return MTLCompareFunctionAlways;
default:
case wgpu::CompareFunction::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
} }

View File

@ -42,7 +42,7 @@ namespace dawn_native { namespace opengl {
return GL_UNSIGNED_SHORT; return GL_UNSIGNED_SHORT;
case wgpu::IndexFormat::Uint32: case wgpu::IndexFormat::Uint32:
return GL_UNSIGNED_INT; return GL_UNSIGNED_INT;
default: case wgpu::IndexFormat::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -87,8 +87,6 @@ namespace dawn_native { namespace opengl {
case wgpu::VertexFormat::Int3: case wgpu::VertexFormat::Int3:
case wgpu::VertexFormat::Int4: case wgpu::VertexFormat::Int4:
return GL_INT; return GL_INT;
default:
UNREACHABLE();
} }
} }
@ -328,9 +326,9 @@ namespace dawn_native { namespace opengl {
case wgpu::BindingType::WriteonlyStorageTexture: case wgpu::BindingType::WriteonlyStorageTexture:
access = GL_WRITE_ONLY; access = GL_WRITE_ONLY;
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
break;
} }
// OpenGL ES only supports either binding a layer or the entire texture // OpenGL ES only supports either binding a layer or the entire texture
@ -466,7 +464,7 @@ namespace dawn_native { namespace opengl {
case Command::BeginComputePass: { case Command::BeginComputePass: {
mCommands.NextCommand<BeginComputePassCmd>(); mCommands.NextCommand<BeginComputePassCmd>();
TransitionForPass(passResourceUsages[nextPassNumber]); TransitionForPass(passResourceUsages[nextPassNumber]);
ExecuteComputePass(); DAWN_TRY(ExecuteComputePass());
nextPassNumber++; nextPassNumber++;
break; break;
@ -477,7 +475,7 @@ namespace dawn_native { namespace opengl {
TransitionForPass(passResourceUsages[nextPassNumber]); TransitionForPass(passResourceUsages[nextPassNumber]);
LazyClearRenderPassAttachments(cmd); LazyClearRenderPassAttachments(cmd);
ExecuteRenderPass(cmd); DAWN_TRY(ExecuteRenderPass(cmd));
nextPassNumber++; nextPassNumber++;
break; break;
@ -581,7 +579,8 @@ namespace dawn_native { namespace opengl {
} }
break; break;
default: case wgpu::TextureDimension::e1D:
case wgpu::TextureDimension::e3D:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -649,9 +648,9 @@ namespace dawn_native { namespace opengl {
glFormat = GL_STENCIL_INDEX; glFormat = GL_STENCIL_INDEX;
glType = GL_UNSIGNED_BYTE; glType = GL_UNSIGNED_BYTE;
break; break;
default:
case Aspect::None:
UNREACHABLE(); UNREACHABLE();
break;
} }
uint8_t* offset = uint8_t* offset =
@ -680,7 +679,8 @@ namespace dawn_native { namespace opengl {
break; break;
} }
default: case wgpu::TextureDimension::e1D:
case wgpu::TextureDimension::e3D:
UNREACHABLE(); UNREACHABLE();
} }
@ -730,9 +730,7 @@ namespace dawn_native { namespace opengl {
} }
case Command::WriteTimestamp: { case Command::WriteTimestamp: {
// WriteTimestamp is not supported on OpenGL return DAWN_UNIMPLEMENTED_ERROR("WriteTimestamp unimplemented");
UNREACHABLE();
break;
} }
case Command::InsertDebugMarker: case Command::InsertDebugMarker:
@ -744,17 +742,15 @@ namespace dawn_native { namespace opengl {
break; break;
} }
default: { default:
UNREACHABLE(); UNREACHABLE();
break;
}
} }
} }
return {}; return {};
} }
void CommandBuffer::ExecuteComputePass() { MaybeError CommandBuffer::ExecuteComputePass() {
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl; const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
ComputePipeline* lastPipeline = nullptr; ComputePipeline* lastPipeline = nullptr;
BindGroupTracker bindGroupTracker = {}; BindGroupTracker bindGroupTracker = {};
@ -764,7 +760,7 @@ namespace dawn_native { namespace opengl {
switch (type) { switch (type) {
case Command::EndComputePass: { case Command::EndComputePass: {
mCommands.NextCommand<EndComputePassCmd>(); mCommands.NextCommand<EndComputePassCmd>();
return; return {};
} }
case Command::Dispatch: { case Command::Dispatch: {
@ -821,15 +817,11 @@ namespace dawn_native { namespace opengl {
} }
case Command::WriteTimestamp: { case Command::WriteTimestamp: {
// WriteTimestamp is not supported on OpenGL return DAWN_UNIMPLEMENTED_ERROR("WriteTimestamp unimplemented");
UNREACHABLE();
break;
} }
default: { default:
UNREACHABLE(); UNREACHABLE();
break;
}
} }
} }
@ -837,7 +829,7 @@ namespace dawn_native { namespace opengl {
UNREACHABLE(); UNREACHABLE();
} }
void CommandBuffer::ExecuteRenderPass(BeginRenderPassCmd* renderPass) { MaybeError CommandBuffer::ExecuteRenderPass(BeginRenderPassCmd* renderPass) {
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl; const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
GLuint fbo = 0; GLuint fbo = 0;
@ -1159,7 +1151,7 @@ namespace dawn_native { namespace opengl {
ResolveMultisampledRenderTargets(gl, renderPass); ResolveMultisampledRenderTargets(gl, renderPass);
} }
gl.DeleteFramebuffers(1, &fbo); gl.DeleteFramebuffers(1, &fbo);
return; return {};
} }
case Command::SetStencilReference: { case Command::SetStencilReference: {
@ -1202,11 +1194,8 @@ namespace dawn_native { namespace opengl {
break; break;
} }
case Command::WriteTimestamp: { case Command::WriteTimestamp:
// WriteTimestamp is not supported on OpenGL return DAWN_UNIMPLEMENTED_ERROR("WriteTimestamp unimplemented");
UNREACHABLE();
break;
}
default: { default: {
DoRenderBundleCommand(&mCommands, type); DoRenderBundleCommand(&mCommands, type);

View File

@ -32,8 +32,8 @@ namespace dawn_native { namespace opengl {
MaybeError Execute(); MaybeError Execute();
private: private:
void ExecuteComputePass(); MaybeError ExecuteComputePass();
void ExecuteRenderPass(BeginRenderPassCmd* renderPass); MaybeError ExecuteRenderPass(BeginRenderPassCmd* renderPass);
}; };
}} // namespace dawn_native::opengl }} // namespace dawn_native::opengl

View File

@ -37,8 +37,6 @@ namespace dawn_native { namespace opengl {
return GL_FRAGMENT_SHADER; return GL_FRAGMENT_SHADER;
case SingleShaderStage::Compute: case SingleShaderStage::Compute:
return GL_COMPUTE_SHADER; return GL_COMPUTE_SHADER;
default:
UNREACHABLE();
} }
} }

View File

@ -35,8 +35,6 @@ namespace dawn_native { namespace opengl {
return GL_TRIANGLES; return GL_TRIANGLES;
case wgpu::PrimitiveTopology::TriangleStrip: case wgpu::PrimitiveTopology::TriangleStrip:
return GL_TRIANGLE_STRIP; return GL_TRIANGLE_STRIP;
default:
UNREACHABLE();
} }
} }
@ -86,8 +84,6 @@ namespace dawn_native { namespace opengl {
return alpha ? GL_CONSTANT_ALPHA : GL_CONSTANT_COLOR; return alpha ? GL_CONSTANT_ALPHA : GL_CONSTANT_COLOR;
case wgpu::BlendFactor::OneMinusBlendColor: case wgpu::BlendFactor::OneMinusBlendColor:
return alpha ? GL_ONE_MINUS_CONSTANT_ALPHA : GL_ONE_MINUS_CONSTANT_COLOR; return alpha ? GL_ONE_MINUS_CONSTANT_ALPHA : GL_ONE_MINUS_CONSTANT_COLOR;
default:
UNREACHABLE();
} }
} }
@ -103,8 +99,6 @@ namespace dawn_native { namespace opengl {
return GL_MIN; return GL_MIN;
case wgpu::BlendOperation::Max: case wgpu::BlendOperation::Max:
return GL_MAX; return GL_MAX;
default:
UNREACHABLE();
} }
} }
@ -149,8 +143,6 @@ namespace dawn_native { namespace opengl {
return GL_INCR_WRAP; return GL_INCR_WRAP;
case wgpu::StencilOperation::DecrementWrap: case wgpu::StencilOperation::DecrementWrap:
return GL_DECR_WRAP; return GL_DECR_WRAP;
default:
UNREACHABLE();
} }
} }
@ -249,8 +241,6 @@ namespace dawn_native { namespace opengl {
case wgpu::InputStepMode::Instance: case wgpu::InputStepMode::Instance:
gl.VertexAttribDivisor(glAttrib, 1); gl.VertexAttribDivisor(glAttrib, 1);
break; break;
default:
UNREACHABLE();
} }
} }
} }

View File

@ -27,8 +27,6 @@ namespace dawn_native { namespace opengl {
return GL_NEAREST; return GL_NEAREST;
case wgpu::FilterMode::Linear: case wgpu::FilterMode::Linear:
return GL_LINEAR; return GL_LINEAR;
default:
UNREACHABLE();
} }
} }
@ -40,8 +38,6 @@ namespace dawn_native { namespace opengl {
return GL_NEAREST_MIPMAP_NEAREST; return GL_NEAREST_MIPMAP_NEAREST;
case wgpu::FilterMode::Linear: case wgpu::FilterMode::Linear:
return GL_NEAREST_MIPMAP_LINEAR; return GL_NEAREST_MIPMAP_LINEAR;
default:
UNREACHABLE();
} }
case wgpu::FilterMode::Linear: case wgpu::FilterMode::Linear:
switch (mipMapFilter) { switch (mipMapFilter) {
@ -49,11 +45,7 @@ namespace dawn_native { namespace opengl {
return GL_LINEAR_MIPMAP_NEAREST; return GL_LINEAR_MIPMAP_NEAREST;
case wgpu::FilterMode::Linear: case wgpu::FilterMode::Linear:
return GL_LINEAR_MIPMAP_LINEAR; return GL_LINEAR_MIPMAP_LINEAR;
default:
UNREACHABLE();
} }
default:
UNREACHABLE();
} }
} }
@ -65,8 +57,6 @@ namespace dawn_native { namespace opengl {
return GL_MIRRORED_REPEAT; return GL_MIRRORED_REPEAT;
case wgpu::AddressMode::ClampToEdge: case wgpu::AddressMode::ClampToEdge:
return GL_CLAMP_TO_EDGE; return GL_CLAMP_TO_EDGE;
default:
UNREACHABLE();
} }
} }

View File

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

View File

@ -36,7 +36,8 @@ namespace dawn_native { namespace opengl {
return GL_EQUAL; return GL_EQUAL;
case wgpu::CompareFunction::Always: case wgpu::CompareFunction::Always:
return GL_ALWAYS; return GL_ALWAYS;
default:
case wgpu::CompareFunction::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -45,6 +46,7 @@ namespace dawn_native { namespace opengl {
switch (depthStencilFormat) { switch (depthStencilFormat) {
case wgpu::TextureFormat::Depth24PlusStencil8: case wgpu::TextureFormat::Depth24PlusStencil8:
return 0xFF; return 0xFF;
default: default:
UNREACHABLE(); UNREACHABLE();
} }

View File

@ -44,7 +44,7 @@ namespace dawn_native { namespace vulkan {
return VK_INDEX_TYPE_UINT16; return VK_INDEX_TYPE_UINT16;
case wgpu::IndexFormat::Uint32: case wgpu::IndexFormat::Uint32:
return VK_INDEX_TYPE_UINT32; return VK_INDEX_TYPE_UINT32;
default: case wgpu::IndexFormat::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -820,12 +820,10 @@ namespace dawn_native { namespace vulkan {
break; break;
} }
default: { default:
UNREACHABLE();
break; break;
} }
} }
}
return {}; return {};
} }
@ -946,10 +944,8 @@ namespace dawn_native { namespace vulkan {
break; break;
} }
default: { default:
UNREACHABLE(); UNREACHABLE();
break;
}
} }
} }

View File

@ -95,7 +95,7 @@ namespace dawn_native { namespace vulkan {
// the decision if it is not applicable. // the decision if it is not applicable.
ApplyDepth24PlusS8Toggle(); ApplyDepth24PlusS8Toggle();
return DeviceBase::Initialize(new Queue(this)); return DeviceBase::Initialize(Queue::Create(this));
} }
Device::~Device() { Device::~Device() {

View File

@ -30,8 +30,6 @@ namespace dawn_native { namespace vulkan {
return VK_QUERY_TYPE_PIPELINE_STATISTICS; return VK_QUERY_TYPE_PIPELINE_STATISTICS;
case wgpu::QueryType::Timestamp: case wgpu::QueryType::Timestamp:
return VK_QUERY_TYPE_TIMESTAMP; return VK_QUERY_TYPE_TIMESTAMP;
default:
UNREACHABLE();
} }
} }
@ -58,9 +56,6 @@ namespace dawn_native { namespace vulkan {
pipelineStatistics |= pipelineStatistics |=
VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT; VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT;
break; break;
default:
UNREACHABLE();
break;
} }
} }

View File

@ -32,6 +32,9 @@ namespace dawn_native { namespace vulkan {
return new Queue(device); return new Queue(device);
} }
Queue::Queue(Device* device) : QueueBase(device) {
}
Queue::~Queue() { Queue::~Queue() {
} }

View File

@ -27,6 +27,7 @@ namespace dawn_native { namespace vulkan {
static Queue* Create(Device* device); static Queue* Create(Device* device);
private: private:
Queue(Device* device);
~Queue() override; ~Queue() override;
using QueueBase::QueueBase; using QueueBase::QueueBase;

View File

@ -29,8 +29,6 @@ namespace dawn_native { namespace vulkan {
return VK_ATTACHMENT_LOAD_OP_LOAD; return VK_ATTACHMENT_LOAD_OP_LOAD;
case wgpu::LoadOp::Clear: case wgpu::LoadOp::Clear:
return VK_ATTACHMENT_LOAD_OP_CLEAR; return VK_ATTACHMENT_LOAD_OP_CLEAR;
default:
UNREACHABLE();
} }
} }
} // anonymous namespace } // anonymous namespace

View File

@ -33,8 +33,6 @@ namespace dawn_native { namespace vulkan {
return VK_VERTEX_INPUT_RATE_VERTEX; return VK_VERTEX_INPUT_RATE_VERTEX;
case wgpu::InputStepMode::Instance: case wgpu::InputStepMode::Instance:
return VK_VERTEX_INPUT_RATE_INSTANCE; return VK_VERTEX_INPUT_RATE_INSTANCE;
default:
UNREACHABLE();
} }
} }
@ -100,8 +98,6 @@ namespace dawn_native { namespace vulkan {
return VK_FORMAT_R32G32B32_SINT; return VK_FORMAT_R32G32B32_SINT;
case wgpu::VertexFormat::Int4: case wgpu::VertexFormat::Int4:
return VK_FORMAT_R32G32B32A32_SINT; return VK_FORMAT_R32G32B32A32_SINT;
default:
UNREACHABLE();
} }
} }
@ -117,8 +113,6 @@ namespace dawn_native { namespace vulkan {
return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
case wgpu::PrimitiveTopology::TriangleStrip: case wgpu::PrimitiveTopology::TriangleStrip:
return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
default:
UNREACHABLE();
} }
} }
@ -133,8 +127,6 @@ namespace dawn_native { namespace vulkan {
case wgpu::PrimitiveTopology::LineStrip: case wgpu::PrimitiveTopology::LineStrip:
case wgpu::PrimitiveTopology::TriangleStrip: case wgpu::PrimitiveTopology::TriangleStrip:
return true; return true;
default:
UNREACHABLE();
} }
} }
@ -144,8 +136,6 @@ namespace dawn_native { namespace vulkan {
return VK_FRONT_FACE_COUNTER_CLOCKWISE; return VK_FRONT_FACE_COUNTER_CLOCKWISE;
case wgpu::FrontFace::CW: case wgpu::FrontFace::CW:
return VK_FRONT_FACE_CLOCKWISE; return VK_FRONT_FACE_CLOCKWISE;
default:
UNREACHABLE();
} }
} }
@ -157,8 +147,6 @@ namespace dawn_native { namespace vulkan {
return VK_CULL_MODE_FRONT_BIT; return VK_CULL_MODE_FRONT_BIT;
case wgpu::CullMode::Back: case wgpu::CullMode::Back:
return VK_CULL_MODE_BACK_BIT; return VK_CULL_MODE_BACK_BIT;
default:
UNREACHABLE();
} }
} }
@ -190,8 +178,6 @@ namespace dawn_native { namespace vulkan {
return VK_BLEND_FACTOR_CONSTANT_COLOR; return VK_BLEND_FACTOR_CONSTANT_COLOR;
case wgpu::BlendFactor::OneMinusBlendColor: case wgpu::BlendFactor::OneMinusBlendColor:
return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR; return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR;
default:
UNREACHABLE();
} }
} }
@ -207,8 +193,6 @@ namespace dawn_native { namespace vulkan {
return VK_BLEND_OP_MIN; return VK_BLEND_OP_MIN;
case wgpu::BlendOperation::Max: case wgpu::BlendOperation::Max:
return VK_BLEND_OP_MAX; return VK_BLEND_OP_MAX;
default:
UNREACHABLE();
} }
} }
@ -269,8 +253,6 @@ namespace dawn_native { namespace vulkan {
return VK_STENCIL_OP_INCREMENT_AND_WRAP; return VK_STENCIL_OP_INCREMENT_AND_WRAP;
case wgpu::StencilOperation::DecrementWrap: case wgpu::StencilOperation::DecrementWrap:
return VK_STENCIL_OP_DECREMENT_AND_WRAP; return VK_STENCIL_OP_DECREMENT_AND_WRAP;
default:
UNREACHABLE();
} }
} }

View File

@ -30,8 +30,6 @@ namespace dawn_native { namespace vulkan {
return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT; return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT;
case wgpu::AddressMode::ClampToEdge: case wgpu::AddressMode::ClampToEdge:
return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
default:
UNREACHABLE();
} }
} }
@ -41,8 +39,6 @@ namespace dawn_native { namespace vulkan {
return VK_FILTER_LINEAR; return VK_FILTER_LINEAR;
case wgpu::FilterMode::Nearest: case wgpu::FilterMode::Nearest:
return VK_FILTER_NEAREST; return VK_FILTER_NEAREST;
default:
UNREACHABLE();
} }
} }
@ -52,8 +48,6 @@ namespace dawn_native { namespace vulkan {
return VK_SAMPLER_MIPMAP_MODE_LINEAR; return VK_SAMPLER_MIPMAP_MODE_LINEAR;
case wgpu::FilterMode::Nearest: case wgpu::FilterMode::Nearest:
return VK_SAMPLER_MIPMAP_MODE_NEAREST; return VK_SAMPLER_MIPMAP_MODE_NEAREST;
default:
UNREACHABLE();
} }
} }
} // anonymous namespace } // anonymous namespace

View File

@ -45,7 +45,10 @@ namespace dawn_native { namespace vulkan {
return VK_IMAGE_VIEW_TYPE_CUBE; return VK_IMAGE_VIEW_TYPE_CUBE;
case wgpu::TextureViewDimension::CubeArray: case wgpu::TextureViewDimension::CubeArray:
return VK_IMAGE_VIEW_TYPE_CUBE_ARRAY; return VK_IMAGE_VIEW_TYPE_CUBE_ARRAY;
default:
case wgpu::TextureViewDimension::e1D:
case wgpu::TextureViewDimension::e3D:
case wgpu::TextureViewDimension::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -135,7 +138,8 @@ namespace dawn_native { namespace vulkan {
} }
case kPresentTextureUsage: case kPresentTextureUsage:
return VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; return VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
default:
case wgpu::TextureUsage::None:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -237,9 +241,9 @@ namespace dawn_native { namespace vulkan {
info->arrayLayers = size.depth; info->arrayLayers = size.depth;
break; break;
default: case wgpu::TextureDimension::e1D:
case wgpu::TextureDimension::e3D:
UNREACHABLE(); UNREACHABLE();
break;
} }
} }
@ -369,7 +373,7 @@ namespace dawn_native { namespace vulkan {
case wgpu::TextureFormat::BC7RGBAUnormSrgb: case wgpu::TextureFormat::BC7RGBAUnormSrgb:
return VK_FORMAT_BC7_SRGB_BLOCK; return VK_FORMAT_BC7_SRGB_BLOCK;
default: case wgpu::TextureFormat::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -714,9 +718,6 @@ namespace dawn_native { namespace vulkan {
case wgpu::TextureAspect::StencilOnly: case wgpu::TextureAspect::StencilOnly:
ASSERT(GetFormat().aspects & Aspect::Stencil); ASSERT(GetFormat().aspects & Aspect::Stencil);
return VulkanAspectMask(Aspect::Stencil); return VulkanAspectMask(Aspect::Stencil);
default:
UNREACHABLE();
return 0;
} }
} }
@ -1057,7 +1058,8 @@ namespace dawn_native { namespace vulkan {
clearColorValue.uint32[2] = uClearColor; clearColorValue.uint32[2] = uClearColor;
clearColorValue.uint32[3] = uClearColor; clearColorValue.uint32[3] = uClearColor;
break; break;
default:
case Format::Type::Other:
UNREACHABLE(); UNREACHABLE();
} }
device->fn.CmdClearColorImage(recordingContext->commandBuffer, GetHandle(), device->fn.CmdClearColorImage(recordingContext->commandBuffer, GetHandle(),

View File

@ -40,7 +40,8 @@ namespace dawn_native { namespace vulkan {
return VK_COMPARE_OP_NOT_EQUAL; return VK_COMPARE_OP_NOT_EQUAL;
case wgpu::CompareFunction::Always: case wgpu::CompareFunction::Always:
return VK_COMPARE_OP_ALWAYS; return VK_COMPARE_OP_ALWAYS;
default:
case wgpu::CompareFunction::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -59,9 +60,8 @@ namespace dawn_native { namespace vulkan {
case Aspect::Stencil: case Aspect::Stencil:
flags |= VK_IMAGE_ASPECT_STENCIL_BIT; flags |= VK_IMAGE_ASPECT_STENCIL_BIT;
break; break;
default: case Aspect::None:
UNREACHABLE(); UNREACHABLE();
break;
} }
} }
return flags; return flags;
@ -133,9 +133,9 @@ namespace dawn_native { namespace vulkan {
break; break;
} }
default: case wgpu::TextureDimension::e1D:
case wgpu::TextureDimension::e3D:
UNREACHABLE(); UNREACHABLE();
break;
} }
return region; return region;

View File

@ -113,9 +113,8 @@ namespace dawn_native { namespace vulkan {
hasDependencies = HasDep(InstanceExt::Surface); hasDependencies = HasDep(InstanceExt::Surface);
break; break;
default: case InstanceExt::EnumCount:
UNREACHABLE(); UNREACHABLE();
break;
} }
trimmedSet.Set(ext, hasDependencies && advertisedExts.Has(ext)); trimmedSet.Set(ext, hasDependencies && advertisedExts.Has(ext));
@ -297,9 +296,8 @@ namespace dawn_native { namespace vulkan {
hasDependencies = icdVersion >= VulkanVersion_1_1; hasDependencies = icdVersion >= VulkanVersion_1_1;
break; break;
default: case DeviceExt::EnumCount:
UNREACHABLE(); UNREACHABLE();
break;
} }
trimmedSet.Set(ext, hasDependencies && advertisedExts.Has(ext)); trimmedSet.Set(ext, hasDependencies && advertisedExts.Has(ext));

View File

@ -58,9 +58,9 @@ namespace utils {
case wgpu::TextureFormat::RGBA16Sint: case wgpu::TextureFormat::RGBA16Sint:
case wgpu::TextureFormat::RGBA32Sint: case wgpu::TextureFormat::RGBA32Sint:
return "i"; return "i";
default: default:
UNREACHABLE(); UNREACHABLE();
return "";
} }
} }
@ -83,6 +83,7 @@ namespace utils {
case wgpu::TextureFormat::RGBA32Sint: case wgpu::TextureFormat::RGBA32Sint:
case wgpu::TextureFormat::RGBA32Float: case wgpu::TextureFormat::RGBA32Float:
return true; return true;
default: default:
return false; return false;
} }
@ -158,9 +159,7 @@ namespace utils {
case wgpu::TextureFormat::Depth24Plus: case wgpu::TextureFormat::Depth24Plus:
case wgpu::TextureFormat::Depth24PlusStencil8: case wgpu::TextureFormat::Depth24PlusStencil8:
case wgpu::TextureFormat::Undefined: case wgpu::TextureFormat::Undefined:
default:
UNREACHABLE(); UNREACHABLE();
return 0u;
} }
} }
@ -224,9 +223,7 @@ namespace utils {
return 4u; return 4u;
case wgpu::TextureFormat::Undefined: case wgpu::TextureFormat::Undefined:
default:
UNREACHABLE(); UNREACHABLE();
return 0u;
} }
} }
@ -290,9 +287,7 @@ namespace utils {
return 4u; return 4u;
case wgpu::TextureFormat::Undefined: case wgpu::TextureFormat::Undefined:
default:
UNREACHABLE(); UNREACHABLE();
return 0u;
} }
} }
@ -386,7 +381,6 @@ namespace utils {
case wgpu::TextureFormat::Depth24PlusStencil8: case wgpu::TextureFormat::Depth24PlusStencil8:
case wgpu::TextureFormat::Undefined: case wgpu::TextureFormat::Undefined:
UNREACHABLE(); UNREACHABLE();
return "";
} }
} }
} // namespace utils } // namespace utils