From eec9edfd5769774d1becf6c2fa8f8241a474c4f4 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Thu, 24 Sep 2020 14:56:50 +0000 Subject: [PATCH] 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 Reviewed-by: Jiawei Shao --- src/dawn_native/BindGroup.cpp | 1 + src/dawn_native/Buffer.cpp | 10 ---- src/dawn_native/CommandBuffer.cpp | 4 -- src/dawn_native/CommandEncoder.cpp | 4 +- src/dawn_native/DawnNative.cpp | 6 +-- src/dawn_native/ErrorScope.cpp | 1 - src/dawn_native/Format.cpp | 13 ++--- src/dawn_native/Queue.cpp | 21 +++++--- src/dawn_native/Queue.h | 9 ++-- src/dawn_native/RenderPipeline.cpp | 6 +-- src/dawn_native/SpirvUtils.cpp | 4 -- src/dawn_native/Texture.cpp | 24 ++++----- src/dawn_native/d3d12/CommandBufferD3D12.cpp | 14 ++--- src/dawn_native/d3d12/QuerySetD3D12.cpp | 2 - .../d3d12/RenderPassBuilderD3D12.cpp | 4 -- src/dawn_native/d3d12/RenderPipelineD3D12.cpp | 16 ------ .../d3d12/ResourceAllocatorManagerD3D12.cpp | 4 +- src/dawn_native/d3d12/SamplerD3D12.cpp | 11 ---- src/dawn_native/d3d12/TextureD3D12.cpp | 16 +++--- src/dawn_native/d3d12/UtilsD3D12.cpp | 3 +- src/dawn_native/metal/CommandBufferMTL.mm | 30 +---------- src/dawn_native/metal/TextureMTL.mm | 10 ++-- src/dawn_native/metal/UtilsMetal.mm | 3 +- src/dawn_native/opengl/CommandBufferGL.cpp | 51 ++++++++----------- src/dawn_native/opengl/CommandBufferGL.h | 4 +- src/dawn_native/opengl/PipelineGL.cpp | 2 - src/dawn_native/opengl/RenderPipelineGL.cpp | 10 ---- src/dawn_native/opengl/SamplerGL.cpp | 10 ---- src/dawn_native/opengl/TextureGL.cpp | 20 +++++--- src/dawn_native/opengl/UtilsGL.cpp | 4 +- src/dawn_native/vulkan/CommandBufferVk.cpp | 10 ++-- src/dawn_native/vulkan/DeviceVk.cpp | 2 +- src/dawn_native/vulkan/QuerySetVk.cpp | 5 -- src/dawn_native/vulkan/QueueVk.cpp | 3 ++ src/dawn_native/vulkan/QueueVk.h | 3 +- src/dawn_native/vulkan/RenderPassCache.cpp | 2 - src/dawn_native/vulkan/RenderPipelineVk.cpp | 18 ------- src/dawn_native/vulkan/SamplerVk.cpp | 6 --- src/dawn_native/vulkan/TextureVk.cpp | 20 ++++---- src/dawn_native/vulkan/UtilsVulkan.cpp | 10 ++-- src/dawn_native/vulkan/VulkanExtensions.cpp | 6 +-- src/utils/TextureFormatUtils.cpp | 10 +--- 42 files changed, 136 insertions(+), 276 deletions(-) diff --git a/src/dawn_native/BindGroup.cpp b/src/dawn_native/BindGroup.cpp index 9b2e9df0a3..a2b79b4a46 100644 --- a/src/dawn_native/BindGroup.cpp +++ b/src/dawn_native/BindGroup.cpp @@ -159,6 +159,7 @@ namespace dawn_native { break; default: UNREACHABLE(); + break; } return {}; diff --git a/src/dawn_native/Buffer.cpp b/src/dawn_native/Buffer.cpp index 65c21b0a07..1a2fbc29f8 100644 --- a/src/dawn_native/Buffer.cpp +++ b/src/dawn_native/Buffer.cpp @@ -57,17 +57,14 @@ namespace dawn_native { private: bool IsCPUWritableAtCreation() const override { UNREACHABLE(); - return false; } MaybeError MapAtCreationImpl() override { UNREACHABLE(); - return {}; } MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override { UNREACHABLE(); - return {}; } void* GetMappedPointerImpl() override { return mFakeMappedData.get(); @@ -212,8 +209,6 @@ namespace dawn_native { return DAWN_VALIDATION_ERROR("Buffer used in a submit while mapped"); case BufferState::Unmapped: return {}; - default: - UNREACHABLE(); } } @@ -480,9 +475,6 @@ namespace dawn_native { case BufferState::Unmapped: case BufferState::Destroyed: return false; - - default: - UNREACHABLE(); } } @@ -503,8 +495,6 @@ namespace dawn_native { return {}; case BufferState::Destroyed: return DAWN_VALIDATION_ERROR("Buffer is destroyed"); - default: - UNREACHABLE(); } } diff --git a/src/dawn_native/CommandBuffer.cpp b/src/dawn_native/CommandBuffer.cpp index bb8f570d72..095a0d93cf 100644 --- a/src/dawn_native/CommandBuffer.cpp +++ b/src/dawn_native/CommandBuffer.cpp @@ -121,10 +121,6 @@ namespace dawn_native { case wgpu::StoreOp::Clear: view->GetTexture()->SetIsSubresourceContentInitialized(false, range); break; - - default: - UNREACHABLE(); - break; } } diff --git a/src/dawn_native/CommandEncoder.cpp b/src/dawn_native/CommandEncoder.cpp index 09eb91f12a..0a8cfec3a6 100644 --- a/src/dawn_native/CommandEncoder.cpp +++ b/src/dawn_native/CommandEncoder.cpp @@ -127,8 +127,6 @@ namespace dawn_native { case wgpu::TextureAspect::StencilOnly: ASSERT(format.aspects & Aspect::Stencil); break; - default: - UNREACHABLE(); } if (depthSelected) { @@ -141,9 +139,9 @@ namespace dawn_native { break; case wgpu::TextureFormat::Depth32Float: break; + default: UNREACHABLE(); - break; } } diff --git a/src/dawn_native/DawnNative.cpp b/src/dawn_native/DawnNative.cpp index 22b3ddedc9..bfc47db68d 100644 --- a/src/dawn_native/DawnNative.cpp +++ b/src/dawn_native/DawnNative.cpp @@ -65,7 +65,9 @@ namespace dawn_native { return BackendType::OpenGL; case wgpu::BackendType::Vulkan: return BackendType::Vulkan; - default: + + case wgpu::BackendType::D3D11: + case wgpu::BackendType::OpenGLES: UNREACHABLE(); } } @@ -80,8 +82,6 @@ namespace dawn_native { return DeviceType::CPU; case wgpu::AdapterType::Unknown: return DeviceType::Unknown; - default: - UNREACHABLE(); } } diff --git a/src/dawn_native/ErrorScope.cpp b/src/dawn_native/ErrorScope.cpp index daa0e48f2a..45036278cb 100644 --- a/src/dawn_native/ErrorScope.cpp +++ b/src/dawn_native/ErrorScope.cpp @@ -95,7 +95,6 @@ namespace dawn_native { break; case wgpu::ErrorType::NoError: - default: UNREACHABLE(); return; } diff --git a/src/dawn_native/Format.cpp b/src/dawn_native/Format.cpp index 0f47a8145b..cda4394b63 100644 --- a/src/dawn_native/Format.cpp +++ b/src/dawn_native/Format.cpp @@ -32,8 +32,6 @@ namespace dawn_native { case wgpu::TextureComponentType::Sint: case wgpu::TextureComponentType::Uint: break; - default: - UNREACHABLE(); } // Check that Type correctly mirrors TextureComponentType except for "Other". static_assert(static_cast(wgpu::TextureComponentType::Float) == Type::Float, ""); @@ -49,7 +47,8 @@ namespace dawn_native { case Type::Sint: case Type::Uint: break; - default: + + case Type::Other: UNREACHABLE(); } // Check that Type correctly mirrors TextureComponentType except for "Other". @@ -105,10 +104,6 @@ namespace dawn_native { break; } break; - - default: - UNREACHABLE(); - break; } } @@ -136,9 +131,9 @@ namespace dawn_native { break; } break; - default: + + case Aspect::None: UNREACHABLE(); - break; } } diff --git a/src/dawn_native/Queue.cpp b/src/dawn_native/Queue.cpp index 2ec53c6cf6..3b7376eff9 100644 --- a/src/dawn_native/Queue.cpp +++ b/src/dawn_native/Queue.cpp @@ -119,7 +119,21 @@ namespace dawn_native { 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 + // QueueBase QueueBase::QueueBase(DeviceBase* device) : ObjectBase(device) { @@ -130,12 +144,7 @@ namespace dawn_native { // static QueueBase* QueueBase::MakeError(DeviceBase* device) { - return new QueueBase(device, ObjectBase::kError); - } - - MaybeError QueueBase::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) { - UNREACHABLE(); - return {}; + return new ErrorQueue(device); } void QueueBase::Submit(uint32_t commandCount, CommandBufferBase* const* commands) { diff --git a/src/dawn_native/Queue.h b/src/dawn_native/Queue.h index 0c6c14cf20..2a0f7fc4d0 100644 --- a/src/dawn_native/Queue.h +++ b/src/dawn_native/Queue.h @@ -25,8 +25,6 @@ namespace dawn_native { class QueueBase : public ObjectBase { public: - QueueBase(DeviceBase* device); - static QueueBase* MakeError(DeviceBase* device); // Dawn API @@ -40,9 +38,11 @@ namespace dawn_native { const TextureDataLayout* dataLayout, const Extent3D* writeSize); - private: + protected: + QueueBase(DeviceBase* device); QueueBase(DeviceBase* device, ObjectBase::ErrorTag tag); + private: MaybeError WriteBufferInternal(BufferBase* buffer, uint64_t bufferOffset, const void* data, @@ -53,7 +53,8 @@ namespace dawn_native { const TextureDataLayout* dataLayout, 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, uint64_t bufferOffset, const void* data, diff --git a/src/dawn_native/RenderPipeline.cpp b/src/dawn_native/RenderPipeline.cpp index 7144f33771..b7d51870b2 100644 --- a/src/dawn_native/RenderPipeline.cpp +++ b/src/dawn_native/RenderPipeline.cpp @@ -205,7 +205,7 @@ namespace dawn_native { return sizeof(uint16_t); case wgpu::IndexFormat::Uint32: return sizeof(uint32_t); - default: + case wgpu::IndexFormat::Undefined: UNREACHABLE(); } } @@ -246,8 +246,6 @@ namespace dawn_native { case wgpu::VertexFormat::UInt: case wgpu::VertexFormat::Int: return 1; - default: - UNREACHABLE(); } } @@ -287,8 +285,6 @@ namespace dawn_native { case wgpu::VertexFormat::Int3: case wgpu::VertexFormat::Int4: return sizeof(int32_t); - default: - UNREACHABLE(); } } diff --git a/src/dawn_native/SpirvUtils.cpp b/src/dawn_native/SpirvUtils.cpp index e462e0d1f7..ecaf1726a0 100644 --- a/src/dawn_native/SpirvUtils.cpp +++ b/src/dawn_native/SpirvUtils.cpp @@ -24,8 +24,6 @@ namespace dawn_native { return spv::ExecutionModelFragment; case SingleShaderStage::Compute: return spv::ExecutionModelGLCompute; - default: - UNREACHABLE(); } } @@ -62,7 +60,6 @@ namespace dawn_native { } default: UNREACHABLE(); - return wgpu::TextureViewDimension::Undefined; } } @@ -147,7 +144,6 @@ namespace dawn_native { return Format::Type::Uint; default: UNREACHABLE(); - return Format::Type::Other; } } diff --git a/src/dawn_native/Texture.cpp b/src/dawn_native/Texture.cpp index 38ce4d209a..98e9abdc9d 100644 --- a/src/dawn_native/Texture.cpp +++ b/src/dawn_native/Texture.cpp @@ -47,9 +47,11 @@ namespace dawn_native { case wgpu::TextureViewDimension::Cube: case wgpu::TextureViewDimension::CubeArray: return textureDimension == wgpu::TextureDimension::e2D; - default: + + case wgpu::TextureViewDimension::e1D: + case wgpu::TextureViewDimension::e3D: + case wgpu::TextureViewDimension::Undefined: UNREACHABLE(); - return false; } } @@ -66,9 +68,11 @@ namespace dawn_native { return textureViewArrayLayer == 6u; case wgpu::TextureViewDimension::CubeArray: return textureViewArrayLayer % 6 == 0; - default: + + case wgpu::TextureViewDimension::e1D: + case wgpu::TextureViewDimension::e3D: + case wgpu::TextureViewDimension::Undefined: UNREACHABLE(); - return false; } } @@ -82,9 +86,11 @@ namespace dawn_native { case wgpu::TextureViewDimension::e2D: case wgpu::TextureViewDimension::e2DArray: return true; - default: + + case wgpu::TextureViewDimension::e1D: + case wgpu::TextureViewDimension::e3D: + case wgpu::TextureViewDimension::Undefined: UNREACHABLE(); - return false; } } @@ -316,9 +322,6 @@ namespace dawn_native { case wgpu::TextureDimension::e3D: desc.dimension = wgpu::TextureViewDimension::e3D; break; - - default: - UNREACHABLE(); } } @@ -361,9 +364,6 @@ namespace dawn_native { case wgpu::TextureAspect::StencilOnly: ASSERT(format.aspects & Aspect::Stencil); return Aspect::Stencil; - default: - UNREACHABLE(); - break; } } diff --git a/src/dawn_native/d3d12/CommandBufferD3D12.cpp b/src/dawn_native/d3d12/CommandBufferD3D12.cpp index 3b4b3a479e..306ef0a44e 100644 --- a/src/dawn_native/d3d12/CommandBufferD3D12.cpp +++ b/src/dawn_native/d3d12/CommandBufferD3D12.cpp @@ -54,8 +54,6 @@ namespace dawn_native { namespace d3d12 { return DXGI_FORMAT_R16_UINT; case wgpu::IndexFormat::Uint32: return DXGI_FORMAT_R32_UINT; - default: - UNREACHABLE(); } } @@ -67,8 +65,6 @@ namespace dawn_native { namespace d3d12 { return D3D12_QUERY_TYPE_PIPELINE_STATISTICS; case wgpu::QueryType::Timestamp: return D3D12_QUERY_TYPE_TIMESTAMP; - default: - UNREACHABLE(); } } @@ -389,7 +385,6 @@ namespace dawn_native { namespace d3d12 { case wgpu::BindingType::ReadonlyStorageTexture: case wgpu::BindingType::WriteonlyStorageTexture: UNREACHABLE(); - break; } } } @@ -954,10 +949,9 @@ namespace dawn_native { namespace d3d12 { } break; } - default: { + + default: UNREACHABLE(); - break; - } } } @@ -1072,10 +1066,8 @@ namespace dawn_native { namespace d3d12 { break; } - default: { + default: UNREACHABLE(); - break; - } } } diff --git a/src/dawn_native/d3d12/QuerySetD3D12.cpp b/src/dawn_native/d3d12/QuerySetD3D12.cpp index 2bea526316..726e6a201a 100644 --- a/src/dawn_native/d3d12/QuerySetD3D12.cpp +++ b/src/dawn_native/d3d12/QuerySetD3D12.cpp @@ -28,8 +28,6 @@ namespace dawn_native { namespace d3d12 { return D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS; case wgpu::QueryType::Timestamp: return D3D12_QUERY_HEAP_TYPE_TIMESTAMP; - default: - UNREACHABLE(); } } } // anonymous namespace diff --git a/src/dawn_native/d3d12/RenderPassBuilderD3D12.cpp b/src/dawn_native/d3d12/RenderPassBuilderD3D12.cpp index 5edf6ad101..be30ab2df7 100644 --- a/src/dawn_native/d3d12/RenderPassBuilderD3D12.cpp +++ b/src/dawn_native/d3d12/RenderPassBuilderD3D12.cpp @@ -30,8 +30,6 @@ namespace dawn_native { namespace d3d12 { return D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR; case wgpu::LoadOp::Load: 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; case wgpu::StoreOp::Store: return D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE; - default: - UNREACHABLE(); } } diff --git a/src/dawn_native/d3d12/RenderPipelineD3D12.cpp b/src/dawn_native/d3d12/RenderPipelineD3D12.cpp index 1187f756e4..5cdfc240fd 100644 --- a/src/dawn_native/d3d12/RenderPipelineD3D12.cpp +++ b/src/dawn_native/d3d12/RenderPipelineD3D12.cpp @@ -91,8 +91,6 @@ namespace dawn_native { namespace d3d12 { return DXGI_FORMAT_R32G32B32_SINT; case wgpu::VertexFormat::Int4: return DXGI_FORMAT_R32G32B32A32_SINT; - default: - UNREACHABLE(); } } @@ -102,8 +100,6 @@ namespace dawn_native { namespace d3d12 { return D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA; case wgpu::InputStepMode::Instance: return D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA; - default: - UNREACHABLE(); } } @@ -119,8 +115,6 @@ namespace dawn_native { namespace d3d12 { return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; case wgpu::PrimitiveTopology::TriangleStrip: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; - default: - UNREACHABLE(); } } @@ -135,8 +129,6 @@ namespace dawn_native { namespace d3d12 { case wgpu::PrimitiveTopology::TriangleList: case wgpu::PrimitiveTopology::TriangleStrip: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - default: - UNREACHABLE(); } } @@ -148,8 +140,6 @@ namespace dawn_native { namespace d3d12 { return D3D12_CULL_MODE_FRONT; case wgpu::CullMode::Back: return D3D12_CULL_MODE_BACK; - default: - UNREACHABLE(); } } @@ -181,8 +171,6 @@ namespace dawn_native { namespace d3d12 { return D3D12_BLEND_BLEND_FACTOR; case wgpu::BlendFactor::OneMinusBlendColor: return D3D12_BLEND_INV_BLEND_FACTOR; - default: - UNREACHABLE(); } } @@ -198,8 +186,6 @@ namespace dawn_native { namespace d3d12 { return D3D12_BLEND_OP_MIN; case wgpu::BlendOperation::Max: return D3D12_BLEND_OP_MAX; - default: - UNREACHABLE(); } } @@ -252,8 +238,6 @@ namespace dawn_native { namespace d3d12 { return D3D12_STENCIL_OP_INCR; case wgpu::StencilOperation::DecrementWrap: return D3D12_STENCIL_OP_DECR; - default: - UNREACHABLE(); } } diff --git a/src/dawn_native/d3d12/ResourceAllocatorManagerD3D12.cpp b/src/dawn_native/d3d12/ResourceAllocatorManagerD3D12.cpp index 8090b7db46..4fefccdac2 100644 --- a/src/dawn_native/d3d12/ResourceAllocatorManagerD3D12.cpp +++ b/src/dawn_native/d3d12/ResourceAllocatorManagerD3D12.cpp @@ -51,7 +51,7 @@ namespace dawn_native { namespace d3d12 { case Upload_OnlyBuffers: case Upload_AllBuffersAndTextures: return D3D12_HEAP_TYPE_UPLOAD; - default: + case EnumCount: UNREACHABLE(); } } @@ -70,7 +70,7 @@ namespace dawn_native { namespace d3d12 { return D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES; case Default_OnlyRenderableOrDepthTextures: return D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES; - default: + case EnumCount: UNREACHABLE(); } } diff --git a/src/dawn_native/d3d12/SamplerD3D12.cpp b/src/dawn_native/d3d12/SamplerD3D12.cpp index 931a3b78d8..e453fc4a23 100644 --- a/src/dawn_native/d3d12/SamplerD3D12.cpp +++ b/src/dawn_native/d3d12/SamplerD3D12.cpp @@ -28,8 +28,6 @@ namespace dawn_native { namespace d3d12 { return D3D12_TEXTURE_ADDRESS_MODE_MIRROR; case wgpu::AddressMode::ClampToEdge: return D3D12_TEXTURE_ADDRESS_MODE_CLAMP; - default: - UNREACHABLE(); } } } // namespace @@ -44,9 +42,6 @@ namespace dawn_native { namespace d3d12 { case wgpu::FilterMode::Linear: minFilter = D3D12_FILTER_TYPE_LINEAR; break; - default: - UNREACHABLE(); - break; } D3D12_FILTER_TYPE magFilter; @@ -57,9 +52,6 @@ namespace dawn_native { namespace d3d12 { case wgpu::FilterMode::Linear: magFilter = D3D12_FILTER_TYPE_LINEAR; break; - default: - UNREACHABLE(); - break; } D3D12_FILTER_TYPE mipmapFilter; @@ -70,9 +62,6 @@ namespace dawn_native { namespace d3d12 { case wgpu::FilterMode::Linear: mipmapFilter = D3D12_FILTER_TYPE_LINEAR; break; - default: - UNREACHABLE(); - break; } D3D12_FILTER_REDUCTION_TYPE reduction = diff --git a/src/dawn_native/d3d12/TextureD3D12.cpp b/src/dawn_native/d3d12/TextureD3D12.cpp index d9ef627e98..959155cbe7 100644 --- a/src/dawn_native/d3d12/TextureD3D12.cpp +++ b/src/dawn_native/d3d12/TextureD3D12.cpp @@ -96,7 +96,9 @@ namespace dawn_native { namespace d3d12 { switch (dimension) { case wgpu::TextureDimension::e2D: return D3D12_RESOURCE_DIMENSION_TEXTURE2D; - default: + + case wgpu::TextureDimension::e1D: + case wgpu::TextureDimension::e3D: UNREACHABLE(); } } @@ -199,7 +201,7 @@ namespace dawn_native { namespace d3d12 { case wgpu::TextureFormat::BC7RGBAUnormSrgb: return DXGI_FORMAT_BC7_TYPELESS; - default: + case wgpu::TextureFormat::Undefined: UNREACHABLE(); } } @@ -321,7 +323,7 @@ namespace dawn_native { namespace d3d12 { case wgpu::TextureFormat::BC7RGBAUnormSrgb: return DXGI_FORMAT_BC7_UNORM_SRGB; - default: + case wgpu::TextureFormat::Undefined: UNREACHABLE(); } } @@ -552,7 +554,6 @@ namespace dawn_native { namespace d3d12 { return DXGI_FORMAT_R8_UINT; default: UNREACHABLE(); - return GetD3D12Format(); } default: ASSERT(HasOneBit(GetFormat().aspects)); @@ -888,7 +889,6 @@ namespace dawn_native { namespace d3d12 { break; default: UNREACHABLE(); - break; } } @@ -1050,6 +1050,7 @@ namespace dawn_native { namespace d3d12 { ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D); mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMS; break; + default: UNREACHABLE(); } @@ -1077,7 +1078,10 @@ namespace dawn_native { namespace d3d12 { mSrvDesc.TextureCubeArray.MipLevels = descriptor->mipLevelCount; mSrvDesc.TextureCubeArray.ResourceMinLODClamp = 0; break; - default: + + case wgpu::TextureViewDimension::e1D: + case wgpu::TextureViewDimension::e3D: + case wgpu::TextureViewDimension::Undefined: UNREACHABLE(); } } diff --git a/src/dawn_native/d3d12/UtilsD3D12.cpp b/src/dawn_native/d3d12/UtilsD3D12.cpp index 283727486b..ec8c05199d 100644 --- a/src/dawn_native/d3d12/UtilsD3D12.cpp +++ b/src/dawn_native/d3d12/UtilsD3D12.cpp @@ -60,7 +60,8 @@ namespace dawn_native { namespace d3d12 { return D3D12_COMPARISON_FUNC_NOT_EQUAL; case wgpu::CompareFunction::Always: return D3D12_COMPARISON_FUNC_ALWAYS; - default: + + case wgpu::CompareFunction::Undefined: UNREACHABLE(); } } diff --git a/src/dawn_native/metal/CommandBufferMTL.mm b/src/dawn_native/metal/CommandBufferMTL.mm index c767f9f606..b84fe13327 100644 --- a/src/dawn_native/metal/CommandBufferMTL.mm +++ b/src/dawn_native/metal/CommandBufferMTL.mm @@ -47,7 +47,7 @@ namespace dawn_native { namespace metal { return MTLIndexTypeUInt16; case wgpu::IndexFormat::Uint32: return MTLIndexTypeUInt32; - default: + case wgpu::IndexFormat::Undefined: UNREACHABLE(); } } @@ -74,10 +74,6 @@ namespace dawn_native { namespace metal { case wgpu::LoadOp::Load: descriptor.colorAttachments[i].loadAction = MTLLoadActionLoad; break; - - default: - UNREACHABLE(); - break; } descriptor.colorAttachments[i].texture = @@ -107,10 +103,6 @@ namespace dawn_native { namespace metal { case wgpu::StoreOp::Clear: descriptor.colorAttachments[i].storeAction = MTLStoreActionDontCare; break; - - default: - UNREACHABLE(); - break; } } @@ -134,10 +126,6 @@ namespace dawn_native { namespace metal { case wgpu::StoreOp::Clear: descriptor.depthAttachment.storeAction = MTLStoreActionDontCare; break; - - default: - UNREACHABLE(); - break; } switch (attachmentInfo.depthLoadOp) { @@ -149,10 +137,6 @@ namespace dawn_native { namespace metal { case wgpu::LoadOp::Load: descriptor.depthAttachment.loadAction = MTLLoadActionLoad; break; - - default: - UNREACHABLE(); - break; } } @@ -169,10 +153,6 @@ namespace dawn_native { namespace metal { case wgpu::StoreOp::Clear: descriptor.stencilAttachment.storeAction = MTLStoreActionDontCare; break; - - default: - UNREACHABLE(); - break; } switch (attachmentInfo.stencilLoadOp) { @@ -184,10 +164,6 @@ namespace dawn_native { namespace metal { case wgpu::LoadOp::Load: descriptor.stencilAttachment.loadAction = MTLLoadActionLoad; break; - - default: - UNREACHABLE(); - break; } } } @@ -797,10 +773,8 @@ namespace dawn_native { namespace metal { break; } - default: { + default: UNREACHABLE(); - break; - } } } diff --git a/src/dawn_native/metal/TextureMTL.mm b/src/dawn_native/metal/TextureMTL.mm index c1a6abfa8d..d47dda0623 100644 --- a/src/dawn_native/metal/TextureMTL.mm +++ b/src/dawn_native/metal/TextureMTL.mm @@ -63,9 +63,11 @@ namespace dawn_native { namespace metal { return MTLTextureTypeCube; case wgpu::TextureViewDimension::CubeArray: return MTLTextureTypeCubeArray; - default: + + case wgpu::TextureViewDimension::e1D: + case wgpu::TextureViewDimension::e3D: + case wgpu::TextureViewDimension::Undefined: UNREACHABLE(); - return MTLTextureType2D; } } @@ -316,7 +318,8 @@ namespace dawn_native { namespace metal { } break; - default: + case wgpu::TextureDimension::e1D: + case wgpu::TextureDimension::e3D: UNREACHABLE(); } @@ -430,7 +433,6 @@ namespace dawn_native { namespace metal { break; default: UNREACHABLE(); - break; } } diff --git a/src/dawn_native/metal/UtilsMetal.mm b/src/dawn_native/metal/UtilsMetal.mm index 840524b8af..3d843e3e27 100644 --- a/src/dawn_native/metal/UtilsMetal.mm +++ b/src/dawn_native/metal/UtilsMetal.mm @@ -37,7 +37,8 @@ namespace dawn_native { namespace metal { return MTLCompareFunctionEqual; case wgpu::CompareFunction::Always: return MTLCompareFunctionAlways; - default: + + case wgpu::CompareFunction::Undefined: UNREACHABLE(); } } diff --git a/src/dawn_native/opengl/CommandBufferGL.cpp b/src/dawn_native/opengl/CommandBufferGL.cpp index 2188f1b0f4..c7ce9a9f53 100644 --- a/src/dawn_native/opengl/CommandBufferGL.cpp +++ b/src/dawn_native/opengl/CommandBufferGL.cpp @@ -42,7 +42,7 @@ namespace dawn_native { namespace opengl { return GL_UNSIGNED_SHORT; case wgpu::IndexFormat::Uint32: return GL_UNSIGNED_INT; - default: + case wgpu::IndexFormat::Undefined: UNREACHABLE(); } } @@ -87,8 +87,6 @@ namespace dawn_native { namespace opengl { case wgpu::VertexFormat::Int3: case wgpu::VertexFormat::Int4: return GL_INT; - default: - UNREACHABLE(); } } @@ -328,9 +326,9 @@ namespace dawn_native { namespace opengl { case wgpu::BindingType::WriteonlyStorageTexture: access = GL_WRITE_ONLY; break; + default: UNREACHABLE(); - break; } // OpenGL ES only supports either binding a layer or the entire texture @@ -466,7 +464,7 @@ namespace dawn_native { namespace opengl { case Command::BeginComputePass: { mCommands.NextCommand(); TransitionForPass(passResourceUsages[nextPassNumber]); - ExecuteComputePass(); + DAWN_TRY(ExecuteComputePass()); nextPassNumber++; break; @@ -477,7 +475,7 @@ namespace dawn_native { namespace opengl { TransitionForPass(passResourceUsages[nextPassNumber]); LazyClearRenderPassAttachments(cmd); - ExecuteRenderPass(cmd); + DAWN_TRY(ExecuteRenderPass(cmd)); nextPassNumber++; break; @@ -581,7 +579,8 @@ namespace dawn_native { namespace opengl { } break; - default: + case wgpu::TextureDimension::e1D: + case wgpu::TextureDimension::e3D: UNREACHABLE(); } } @@ -649,9 +648,9 @@ namespace dawn_native { namespace opengl { glFormat = GL_STENCIL_INDEX; glType = GL_UNSIGNED_BYTE; break; - default: + + case Aspect::None: UNREACHABLE(); - break; } uint8_t* offset = @@ -680,7 +679,8 @@ namespace dawn_native { namespace opengl { break; } - default: + case wgpu::TextureDimension::e1D: + case wgpu::TextureDimension::e3D: UNREACHABLE(); } @@ -730,9 +730,7 @@ namespace dawn_native { namespace opengl { } case Command::WriteTimestamp: { - // WriteTimestamp is not supported on OpenGL - UNREACHABLE(); - break; + return DAWN_UNIMPLEMENTED_ERROR("WriteTimestamp unimplemented"); } case Command::InsertDebugMarker: @@ -744,17 +742,15 @@ namespace dawn_native { namespace opengl { break; } - default: { + default: UNREACHABLE(); - break; - } } } return {}; } - void CommandBuffer::ExecuteComputePass() { + MaybeError CommandBuffer::ExecuteComputePass() { const OpenGLFunctions& gl = ToBackend(GetDevice())->gl; ComputePipeline* lastPipeline = nullptr; BindGroupTracker bindGroupTracker = {}; @@ -764,7 +760,7 @@ namespace dawn_native { namespace opengl { switch (type) { case Command::EndComputePass: { mCommands.NextCommand(); - return; + return {}; } case Command::Dispatch: { @@ -821,15 +817,11 @@ namespace dawn_native { namespace opengl { } case Command::WriteTimestamp: { - // WriteTimestamp is not supported on OpenGL - UNREACHABLE(); - break; + return DAWN_UNIMPLEMENTED_ERROR("WriteTimestamp unimplemented"); } - default: { + default: UNREACHABLE(); - break; - } } } @@ -837,7 +829,7 @@ namespace dawn_native { namespace opengl { UNREACHABLE(); } - void CommandBuffer::ExecuteRenderPass(BeginRenderPassCmd* renderPass) { + MaybeError CommandBuffer::ExecuteRenderPass(BeginRenderPassCmd* renderPass) { const OpenGLFunctions& gl = ToBackend(GetDevice())->gl; GLuint fbo = 0; @@ -1159,7 +1151,7 @@ namespace dawn_native { namespace opengl { ResolveMultisampledRenderTargets(gl, renderPass); } gl.DeleteFramebuffers(1, &fbo); - return; + return {}; } case Command::SetStencilReference: { @@ -1202,11 +1194,8 @@ namespace dawn_native { namespace opengl { break; } - case Command::WriteTimestamp: { - // WriteTimestamp is not supported on OpenGL - UNREACHABLE(); - break; - } + case Command::WriteTimestamp: + return DAWN_UNIMPLEMENTED_ERROR("WriteTimestamp unimplemented"); default: { DoRenderBundleCommand(&mCommands, type); diff --git a/src/dawn_native/opengl/CommandBufferGL.h b/src/dawn_native/opengl/CommandBufferGL.h index b860be8c84..c21f574668 100644 --- a/src/dawn_native/opengl/CommandBufferGL.h +++ b/src/dawn_native/opengl/CommandBufferGL.h @@ -32,8 +32,8 @@ namespace dawn_native { namespace opengl { MaybeError Execute(); private: - void ExecuteComputePass(); - void ExecuteRenderPass(BeginRenderPassCmd* renderPass); + MaybeError ExecuteComputePass(); + MaybeError ExecuteRenderPass(BeginRenderPassCmd* renderPass); }; }} // namespace dawn_native::opengl diff --git a/src/dawn_native/opengl/PipelineGL.cpp b/src/dawn_native/opengl/PipelineGL.cpp index fb6d21eedc..331cf5f37f 100644 --- a/src/dawn_native/opengl/PipelineGL.cpp +++ b/src/dawn_native/opengl/PipelineGL.cpp @@ -37,8 +37,6 @@ namespace dawn_native { namespace opengl { return GL_FRAGMENT_SHADER; case SingleShaderStage::Compute: return GL_COMPUTE_SHADER; - default: - UNREACHABLE(); } } diff --git a/src/dawn_native/opengl/RenderPipelineGL.cpp b/src/dawn_native/opengl/RenderPipelineGL.cpp index f176cd6ce8..bc5882b0f7 100644 --- a/src/dawn_native/opengl/RenderPipelineGL.cpp +++ b/src/dawn_native/opengl/RenderPipelineGL.cpp @@ -35,8 +35,6 @@ namespace dawn_native { namespace opengl { return GL_TRIANGLES; case wgpu::PrimitiveTopology::TriangleStrip: return GL_TRIANGLE_STRIP; - default: - UNREACHABLE(); } } @@ -86,8 +84,6 @@ namespace dawn_native { namespace opengl { return alpha ? GL_CONSTANT_ALPHA : GL_CONSTANT_COLOR; case wgpu::BlendFactor::OneMinusBlendColor: 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; case wgpu::BlendOperation::Max: return GL_MAX; - default: - UNREACHABLE(); } } @@ -149,8 +143,6 @@ namespace dawn_native { namespace opengl { return GL_INCR_WRAP; case wgpu::StencilOperation::DecrementWrap: return GL_DECR_WRAP; - default: - UNREACHABLE(); } } @@ -249,8 +241,6 @@ namespace dawn_native { namespace opengl { case wgpu::InputStepMode::Instance: gl.VertexAttribDivisor(glAttrib, 1); break; - default: - UNREACHABLE(); } } } diff --git a/src/dawn_native/opengl/SamplerGL.cpp b/src/dawn_native/opengl/SamplerGL.cpp index 1b5b44cc5c..6f9235d3bf 100644 --- a/src/dawn_native/opengl/SamplerGL.cpp +++ b/src/dawn_native/opengl/SamplerGL.cpp @@ -27,8 +27,6 @@ namespace dawn_native { namespace opengl { return GL_NEAREST; case wgpu::FilterMode::Linear: return GL_LINEAR; - default: - UNREACHABLE(); } } @@ -40,8 +38,6 @@ namespace dawn_native { namespace opengl { return GL_NEAREST_MIPMAP_NEAREST; case wgpu::FilterMode::Linear: return GL_NEAREST_MIPMAP_LINEAR; - default: - UNREACHABLE(); } case wgpu::FilterMode::Linear: switch (mipMapFilter) { @@ -49,11 +45,7 @@ namespace dawn_native { namespace opengl { return GL_LINEAR_MIPMAP_NEAREST; case wgpu::FilterMode::Linear: return GL_LINEAR_MIPMAP_LINEAR; - default: - UNREACHABLE(); } - default: - UNREACHABLE(); } } @@ -65,8 +57,6 @@ namespace dawn_native { namespace opengl { return GL_MIRRORED_REPEAT; case wgpu::AddressMode::ClampToEdge: return GL_CLAMP_TO_EDGE; - default: - UNREACHABLE(); } } diff --git a/src/dawn_native/opengl/TextureGL.cpp b/src/dawn_native/opengl/TextureGL.cpp index 98641713be..97d877ce5e 100644 --- a/src/dawn_native/opengl/TextureGL.cpp +++ b/src/dawn_native/opengl/TextureGL.cpp @@ -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(); } } diff --git a/src/dawn_native/opengl/UtilsGL.cpp b/src/dawn_native/opengl/UtilsGL.cpp index 3905b269f7..804df662f1 100644 --- a/src/dawn_native/opengl/UtilsGL.cpp +++ b/src/dawn_native/opengl/UtilsGL.cpp @@ -36,7 +36,8 @@ namespace dawn_native { namespace opengl { return GL_EQUAL; case wgpu::CompareFunction::Always: return GL_ALWAYS; - default: + + case wgpu::CompareFunction::Undefined: UNREACHABLE(); } } @@ -45,6 +46,7 @@ namespace dawn_native { namespace opengl { switch (depthStencilFormat) { case wgpu::TextureFormat::Depth24PlusStencil8: return 0xFF; + default: UNREACHABLE(); } diff --git a/src/dawn_native/vulkan/CommandBufferVk.cpp b/src/dawn_native/vulkan/CommandBufferVk.cpp index 90d892600f..9c431acc16 100644 --- a/src/dawn_native/vulkan/CommandBufferVk.cpp +++ b/src/dawn_native/vulkan/CommandBufferVk.cpp @@ -44,7 +44,7 @@ namespace dawn_native { namespace vulkan { return VK_INDEX_TYPE_UINT16; case wgpu::IndexFormat::Uint32: return VK_INDEX_TYPE_UINT32; - default: + case wgpu::IndexFormat::Undefined: UNREACHABLE(); } } @@ -820,10 +820,8 @@ namespace dawn_native { namespace vulkan { break; } - default: { - UNREACHABLE(); + default: break; - } } } @@ -946,10 +944,8 @@ namespace dawn_native { namespace vulkan { break; } - default: { + default: UNREACHABLE(); - break; - } } } diff --git a/src/dawn_native/vulkan/DeviceVk.cpp b/src/dawn_native/vulkan/DeviceVk.cpp index c96cede4b1..857930de04 100644 --- a/src/dawn_native/vulkan/DeviceVk.cpp +++ b/src/dawn_native/vulkan/DeviceVk.cpp @@ -95,7 +95,7 @@ namespace dawn_native { namespace vulkan { // the decision if it is not applicable. ApplyDepth24PlusS8Toggle(); - return DeviceBase::Initialize(new Queue(this)); + return DeviceBase::Initialize(Queue::Create(this)); } Device::~Device() { diff --git a/src/dawn_native/vulkan/QuerySetVk.cpp b/src/dawn_native/vulkan/QuerySetVk.cpp index 0d740a63ff..c74ef7c7b8 100644 --- a/src/dawn_native/vulkan/QuerySetVk.cpp +++ b/src/dawn_native/vulkan/QuerySetVk.cpp @@ -30,8 +30,6 @@ namespace dawn_native { namespace vulkan { return VK_QUERY_TYPE_PIPELINE_STATISTICS; case wgpu::QueryType::Timestamp: return VK_QUERY_TYPE_TIMESTAMP; - default: - UNREACHABLE(); } } @@ -58,9 +56,6 @@ namespace dawn_native { namespace vulkan { pipelineStatistics |= VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT; break; - default: - UNREACHABLE(); - break; } } diff --git a/src/dawn_native/vulkan/QueueVk.cpp b/src/dawn_native/vulkan/QueueVk.cpp index b185c65bf1..b7fa159159 100644 --- a/src/dawn_native/vulkan/QueueVk.cpp +++ b/src/dawn_native/vulkan/QueueVk.cpp @@ -32,6 +32,9 @@ namespace dawn_native { namespace vulkan { return new Queue(device); } + Queue::Queue(Device* device) : QueueBase(device) { + } + Queue::~Queue() { } diff --git a/src/dawn_native/vulkan/QueueVk.h b/src/dawn_native/vulkan/QueueVk.h index 58d5e0dc1f..d5d15af5c5 100644 --- a/src/dawn_native/vulkan/QueueVk.h +++ b/src/dawn_native/vulkan/QueueVk.h @@ -27,6 +27,7 @@ namespace dawn_native { namespace vulkan { static Queue* Create(Device* device); private: + Queue(Device* device); ~Queue() override; using QueueBase::QueueBase; @@ -35,4 +36,4 @@ namespace dawn_native { namespace vulkan { }} // namespace dawn_native::vulkan -#endif // DAWNNATIVE_VULKAN_QUEUEVK_H_ \ No newline at end of file +#endif // DAWNNATIVE_VULKAN_QUEUEVK_H_ diff --git a/src/dawn_native/vulkan/RenderPassCache.cpp b/src/dawn_native/vulkan/RenderPassCache.cpp index 9ea957635c..1bafac2088 100644 --- a/src/dawn_native/vulkan/RenderPassCache.cpp +++ b/src/dawn_native/vulkan/RenderPassCache.cpp @@ -29,8 +29,6 @@ namespace dawn_native { namespace vulkan { return VK_ATTACHMENT_LOAD_OP_LOAD; case wgpu::LoadOp::Clear: return VK_ATTACHMENT_LOAD_OP_CLEAR; - default: - UNREACHABLE(); } } } // anonymous namespace diff --git a/src/dawn_native/vulkan/RenderPipelineVk.cpp b/src/dawn_native/vulkan/RenderPipelineVk.cpp index 7908451c7c..41536a2dbc 100644 --- a/src/dawn_native/vulkan/RenderPipelineVk.cpp +++ b/src/dawn_native/vulkan/RenderPipelineVk.cpp @@ -33,8 +33,6 @@ namespace dawn_native { namespace vulkan { return VK_VERTEX_INPUT_RATE_VERTEX; case wgpu::InputStepMode::Instance: return VK_VERTEX_INPUT_RATE_INSTANCE; - default: - UNREACHABLE(); } } @@ -100,8 +98,6 @@ namespace dawn_native { namespace vulkan { return VK_FORMAT_R32G32B32_SINT; case wgpu::VertexFormat::Int4: return VK_FORMAT_R32G32B32A32_SINT; - default: - UNREACHABLE(); } } @@ -117,8 +113,6 @@ namespace dawn_native { namespace vulkan { return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; case wgpu::PrimitiveTopology::TriangleStrip: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; - default: - UNREACHABLE(); } } @@ -133,8 +127,6 @@ namespace dawn_native { namespace vulkan { case wgpu::PrimitiveTopology::LineStrip: case wgpu::PrimitiveTopology::TriangleStrip: return true; - default: - UNREACHABLE(); } } @@ -144,8 +136,6 @@ namespace dawn_native { namespace vulkan { return VK_FRONT_FACE_COUNTER_CLOCKWISE; case wgpu::FrontFace::CW: return VK_FRONT_FACE_CLOCKWISE; - default: - UNREACHABLE(); } } @@ -157,8 +147,6 @@ namespace dawn_native { namespace vulkan { return VK_CULL_MODE_FRONT_BIT; case wgpu::CullMode::Back: return VK_CULL_MODE_BACK_BIT; - default: - UNREACHABLE(); } } @@ -190,8 +178,6 @@ namespace dawn_native { namespace vulkan { return VK_BLEND_FACTOR_CONSTANT_COLOR; case wgpu::BlendFactor::OneMinusBlendColor: return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR; - default: - UNREACHABLE(); } } @@ -207,8 +193,6 @@ namespace dawn_native { namespace vulkan { return VK_BLEND_OP_MIN; case wgpu::BlendOperation::Max: return VK_BLEND_OP_MAX; - default: - UNREACHABLE(); } } @@ -269,8 +253,6 @@ namespace dawn_native { namespace vulkan { return VK_STENCIL_OP_INCREMENT_AND_WRAP; case wgpu::StencilOperation::DecrementWrap: return VK_STENCIL_OP_DECREMENT_AND_WRAP; - default: - UNREACHABLE(); } } diff --git a/src/dawn_native/vulkan/SamplerVk.cpp b/src/dawn_native/vulkan/SamplerVk.cpp index f2a71288c5..9429830517 100644 --- a/src/dawn_native/vulkan/SamplerVk.cpp +++ b/src/dawn_native/vulkan/SamplerVk.cpp @@ -30,8 +30,6 @@ namespace dawn_native { namespace vulkan { return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT; case wgpu::AddressMode::ClampToEdge: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; - default: - UNREACHABLE(); } } @@ -41,8 +39,6 @@ namespace dawn_native { namespace vulkan { return VK_FILTER_LINEAR; case wgpu::FilterMode::Nearest: return VK_FILTER_NEAREST; - default: - UNREACHABLE(); } } @@ -52,8 +48,6 @@ namespace dawn_native { namespace vulkan { return VK_SAMPLER_MIPMAP_MODE_LINEAR; case wgpu::FilterMode::Nearest: return VK_SAMPLER_MIPMAP_MODE_NEAREST; - default: - UNREACHABLE(); } } } // anonymous namespace diff --git a/src/dawn_native/vulkan/TextureVk.cpp b/src/dawn_native/vulkan/TextureVk.cpp index 7627282f77..882866d9fd 100644 --- a/src/dawn_native/vulkan/TextureVk.cpp +++ b/src/dawn_native/vulkan/TextureVk.cpp @@ -45,7 +45,10 @@ namespace dawn_native { namespace vulkan { return VK_IMAGE_VIEW_TYPE_CUBE; case wgpu::TextureViewDimension::CubeArray: return VK_IMAGE_VIEW_TYPE_CUBE_ARRAY; - default: + + case wgpu::TextureViewDimension::e1D: + case wgpu::TextureViewDimension::e3D: + case wgpu::TextureViewDimension::Undefined: UNREACHABLE(); } } @@ -135,7 +138,8 @@ namespace dawn_native { namespace vulkan { } case kPresentTextureUsage: return VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; - default: + + case wgpu::TextureUsage::None: UNREACHABLE(); } } @@ -237,9 +241,9 @@ namespace dawn_native { namespace vulkan { info->arrayLayers = size.depth; break; - default: + case wgpu::TextureDimension::e1D: + case wgpu::TextureDimension::e3D: UNREACHABLE(); - break; } } @@ -369,7 +373,7 @@ namespace dawn_native { namespace vulkan { case wgpu::TextureFormat::BC7RGBAUnormSrgb: return VK_FORMAT_BC7_SRGB_BLOCK; - default: + case wgpu::TextureFormat::Undefined: UNREACHABLE(); } } @@ -714,9 +718,6 @@ namespace dawn_native { namespace vulkan { case wgpu::TextureAspect::StencilOnly: ASSERT(GetFormat().aspects & 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[3] = uClearColor; break; - default: + + case Format::Type::Other: UNREACHABLE(); } device->fn.CmdClearColorImage(recordingContext->commandBuffer, GetHandle(), diff --git a/src/dawn_native/vulkan/UtilsVulkan.cpp b/src/dawn_native/vulkan/UtilsVulkan.cpp index 1b6b2d66d3..89416563d6 100644 --- a/src/dawn_native/vulkan/UtilsVulkan.cpp +++ b/src/dawn_native/vulkan/UtilsVulkan.cpp @@ -40,7 +40,8 @@ namespace dawn_native { namespace vulkan { 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 @@ namespace dawn_native { namespace vulkan { case Aspect::Stencil: flags |= VK_IMAGE_ASPECT_STENCIL_BIT; break; - default: + case Aspect::None: UNREACHABLE(); - break; } } return flags; @@ -133,9 +133,9 @@ namespace dawn_native { namespace vulkan { break; } - default: + case wgpu::TextureDimension::e1D: + case wgpu::TextureDimension::e3D: UNREACHABLE(); - break; } return region; diff --git a/src/dawn_native/vulkan/VulkanExtensions.cpp b/src/dawn_native/vulkan/VulkanExtensions.cpp index 1e7f23d5e7..949f51f68f 100644 --- a/src/dawn_native/vulkan/VulkanExtensions.cpp +++ b/src/dawn_native/vulkan/VulkanExtensions.cpp @@ -113,9 +113,8 @@ namespace dawn_native { namespace vulkan { hasDependencies = HasDep(InstanceExt::Surface); break; - default: + case InstanceExt::EnumCount: UNREACHABLE(); - break; } trimmedSet.Set(ext, hasDependencies && advertisedExts.Has(ext)); @@ -297,9 +296,8 @@ namespace dawn_native { namespace vulkan { hasDependencies = icdVersion >= VulkanVersion_1_1; break; - default: + case DeviceExt::EnumCount: UNREACHABLE(); - break; } trimmedSet.Set(ext, hasDependencies && advertisedExts.Has(ext)); diff --git a/src/utils/TextureFormatUtils.cpp b/src/utils/TextureFormatUtils.cpp index af5ff10ef7..8430058b2c 100644 --- a/src/utils/TextureFormatUtils.cpp +++ b/src/utils/TextureFormatUtils.cpp @@ -58,9 +58,9 @@ namespace utils { case wgpu::TextureFormat::RGBA16Sint: case wgpu::TextureFormat::RGBA32Sint: return "i"; + default: UNREACHABLE(); - return ""; } } @@ -83,6 +83,7 @@ namespace utils { case wgpu::TextureFormat::RGBA32Sint: case wgpu::TextureFormat::RGBA32Float: return true; + default: return false; } @@ -158,9 +159,7 @@ namespace utils { case wgpu::TextureFormat::Depth24Plus: case wgpu::TextureFormat::Depth24PlusStencil8: case wgpu::TextureFormat::Undefined: - default: UNREACHABLE(); - return 0u; } } @@ -224,9 +223,7 @@ namespace utils { return 4u; case wgpu::TextureFormat::Undefined: - default: UNREACHABLE(); - return 0u; } } @@ -290,9 +287,7 @@ namespace utils { return 4u; case wgpu::TextureFormat::Undefined: - default: UNREACHABLE(); - return 0u; } } @@ -386,7 +381,6 @@ namespace utils { case wgpu::TextureFormat::Depth24PlusStencil8: case wgpu::TextureFormat::Undefined: UNREACHABLE(); - return ""; } } } // namespace utils