VERY experimental Nintendo Switch 2 emulator
C++
video_core: Enforce -Werror=switch
ReinUsesLispee7e70cfbc5d
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txtindex d85f1e9d1a..f52b55ef3e 100644--- a/src/video_core/CMakeLists.txt+++ b/src/video_core/CMakeLists.txt@@ -269,5 +269,5 @@ endif()if (MSVC)target_compile_options(video_core PRIVATE /we4267)else()- target_compile_options(video_core PRIVATE -Werror=conversion -Wno-error=sign-conversion)+ target_compile_options(video_core PRIVATE -Werror=conversion -Wno-error=sign-conversion -Werror=switch)endif()diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cppindex 3f75fcd2b6..ce3a651224 100644--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp@@ -1443,8 +1443,10 @@ private:return expr + ", vec2(0.0), vec2(0.0))";case TextureType::TextureCube:return expr + ", vec3(0.0), vec3(0.0))";+ default:+ UNREACHABLE();+ break;}- UNREACHABLE();}for (const auto& variant : extras) {diff --git a/src/video_core/renderer_opengl/maxwell_to_gl.h b/src/video_core/renderer_opengl/maxwell_to_gl.hindex fe9bd4b5ab..a8be2aa379 100644--- a/src/video_core/renderer_opengl/maxwell_to_gl.h+++ b/src/video_core/renderer_opengl/maxwell_to_gl.h@@ -47,6 +47,8 @@ inline GLenum VertexFormat(Maxwell::VertexAttribute attrib) {return GL_UNSIGNED_INT;case Maxwell::VertexAttribute::Size::Size_10_10_10_2:return GL_UNSIGNED_INT_2_10_10_10_REV;+ default:+ break;}break;case Maxwell::VertexAttribute::Type::SignedNorm:@@ -70,6 +72,8 @@ inline GLenum VertexFormat(Maxwell::VertexAttribute attrib) {return GL_INT;case Maxwell::VertexAttribute::Size::Size_10_10_10_2:return GL_INT_2_10_10_10_REV;+ default:+ break;}break;case Maxwell::VertexAttribute::Type::Float:@@ -84,6 +88,8 @@ inline GLenum VertexFormat(Maxwell::VertexAttribute attrib) {case Maxwell::VertexAttribute::Size::Size_32_32_32:case Maxwell::VertexAttribute::Size::Size_32_32_32_32:return GL_FLOAT;+ default:+ break;}break;}diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cppindex f8c77f4faa..d22de1d810 100644--- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp+++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp@@ -78,9 +78,10 @@ VkSamplerAddressMode WrapMode(const VKDevice& device, Tegra::Texture::WrapMode wcase Tegra::Texture::WrapMode::MirrorOnceBorder:UNIMPLEMENTED();return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;+ default:+ UNIMPLEMENTED_MSG("Unimplemented wrap mode={}", static_cast<u32>(wrap_mode));+ return {};}- UNIMPLEMENTED_MSG("Unimplemented wrap mode={}", static_cast<u32>(wrap_mode));- return {};}VkCompareOp DepthCompareFunction(Tegra::Texture::DepthCompareFunc depth_compare_func) {@@ -298,9 +299,10 @@ VkPrimitiveTopology PrimitiveTopology([[maybe_unused]] const VKDevice& device,return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;case Maxwell::PrimitiveTopology::Patches:return VK_PRIMITIVE_TOPOLOGY_PATCH_LIST;+ default:+ UNIMPLEMENTED_MSG("Unimplemented topology={}", static_cast<u32>(topology));+ return {};}- UNIMPLEMENTED_MSG("Unimplemented topology={}", static_cast<u32>(topology));- return {};}VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttribute::Size size) {@@ -325,6 +327,8 @@ VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttribreturn VK_FORMAT_R16G16B16A16_UNORM;case Maxwell::VertexAttribute::Size::Size_10_10_10_2:return VK_FORMAT_A2B10G10R10_UNORM_PACK32;+ default:+ break;}break;case Maxwell::VertexAttribute::Type::SignedNorm:@@ -347,6 +351,8 @@ VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttribreturn VK_FORMAT_R16G16B16A16_SNORM;case Maxwell::VertexAttribute::Size::Size_10_10_10_2:return VK_FORMAT_A2B10G10R10_SNORM_PACK32;+ default:+ break;}break;case Maxwell::VertexAttribute::Type::UnsignedScaled:@@ -369,6 +375,8 @@ VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttribreturn VK_FORMAT_R16G16B16A16_USCALED;case Maxwell::VertexAttribute::Size::Size_10_10_10_2:return VK_FORMAT_A2B10G10R10_USCALED_PACK32;+ default:+ break;}break;case Maxwell::VertexAttribute::Type::SignedScaled:@@ -391,6 +399,8 @@ VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttribreturn VK_FORMAT_R16G16B16A16_SSCALED;case Maxwell::VertexAttribute::Size::Size_10_10_10_2:return VK_FORMAT_A2B10G10R10_SSCALED_PACK32;+ default:+ break;}break;case Maxwell::VertexAttribute::Type::UnsignedInt:@@ -421,6 +431,8 @@ VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttribreturn VK_FORMAT_R32G32B32A32_UINT;case Maxwell::VertexAttribute::Size::Size_10_10_10_2:return VK_FORMAT_A2B10G10R10_UINT_PACK32;+ default:+ break;}break;case Maxwell::VertexAttribute::Type::SignedInt:@@ -451,6 +463,8 @@ VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttribreturn VK_FORMAT_R32G32B32A32_SINT;case Maxwell::VertexAttribute::Size::Size_10_10_10_2:return VK_FORMAT_A2B10G10R10_SINT_PACK32;+ default:+ break;}break;case Maxwell::VertexAttribute::Type::Float:@@ -471,6 +485,8 @@ VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttribreturn VK_FORMAT_R32G32B32_SFLOAT;case Maxwell::VertexAttribute::Size::Size_32_32_32_32:return VK_FORMAT_R32G32B32A32_SFLOAT;+ default:+ break;}break;}diff --git a/src/video_core/renderer_vulkan/wrapper.cpp b/src/video_core/renderer_vulkan/wrapper.cppindex 013865aa4d..fe291a1488 100644--- a/src/video_core/renderer_vulkan/wrapper.cpp+++ b/src/video_core/renderer_vulkan/wrapper.cpp@@ -262,6 +262,22 @@ const char* ToString(VkResult result) noexcept {return "VK_ERROR_INVALID_DEVICE_ADDRESS_EXT";case VkResult::VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT:return "VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT";+ case VkResult::VK_ERROR_UNKNOWN:+ return "VK_ERROR_UNKNOWN";+ case VkResult::VK_ERROR_INCOMPATIBLE_VERSION_KHR:+ return "VK_ERROR_INCOMPATIBLE_VERSION_KHR";+ case VkResult::VK_THREAD_IDLE_KHR:+ return "VK_THREAD_IDLE_KHR";+ case VkResult::VK_THREAD_DONE_KHR:+ return "VK_THREAD_DONE_KHR";+ case VkResult::VK_OPERATION_DEFERRED_KHR:+ return "VK_OPERATION_DEFERRED_KHR";+ case VkResult::VK_OPERATION_NOT_DEFERRED_KHR:+ return "VK_OPERATION_NOT_DEFERRED_KHR";+ case VkResult::VK_PIPELINE_COMPILE_REQUIRED_EXT:+ return "VK_PIPELINE_COMPILE_REQUIRED_EXT";+ case VkResult::VK_RESULT_MAX_ENUM:+ return "VK_RESULT_MAX_ENUM";}return "Unknown";}diff --git a/src/video_core/shader/decode/arithmetic_half.cpp b/src/video_core/shader/decode/arithmetic_half.cppindex a276aee445..88103fede4 100644--- a/src/video_core/shader/decode/arithmetic_half.cpp+++ b/src/video_core/shader/decode/arithmetic_half.cpp@@ -53,6 +53,9 @@ u32 ShaderIR::DecodeArithmeticHalf(NodeBlock& bb, u32 pc) {absolute_a = ((instr.value >> 44) & 1) != 0;absolute_b = ((instr.value >> 54) & 1) != 0;break;+ default:+ UNREACHABLE();+ break;}Node op_a = UnpackHalfFloat(GetRegister(instr.gpr8), instr.alu_half.type_a);diff --git a/src/video_core/shader/decode/image.cpp b/src/video_core/shader/decode/image.cppindex e75ca4fdbc..cd424aa913 100644--- a/src/video_core/shader/decode/image.cpp+++ b/src/video_core/shader/decode/image.cpp@@ -119,6 +119,8 @@ ComponentType GetComponentType(Tegra::Engines::SamplerDescriptor descriptor,return descriptor.r_type;}break;+ default:+ break;}UNIMPLEMENTED_MSG("Texture format not implemented={}", format);return ComponentType::FLOAT;@@ -220,9 +222,10 @@ u32 GetComponentSize(TextureFormat format, std::size_t component) {return (component == 0 || component == 1) ? 8 : 0;case TextureFormat::G4R4:return (component == 0 || component == 1) ? 4 : 0;+ default:+ UNIMPLEMENTED_MSG("Texture format not implemented={}", format);+ return 0;}- UNIMPLEMENTED_MSG("Texture format not implemented={}", format);- return 0;}std::size_t GetImageComponentMask(TextureFormat format) {@@ -257,9 +260,10 @@ std::size_t GetImageComponentMask(TextureFormat format) {case TextureFormat::R8:case TextureFormat::R1:return std::size_t{R};+ default:+ UNIMPLEMENTED_MSG("Texture format not implemented={}", format);+ return std::size_t{R | G | B | A};}- UNIMPLEMENTED_MSG("Texture format not implemented={}", format);- return std::size_t{R | G | B | A};}std::size_t GetImageTypeNumCoordinates(Tegra::Shader::ImageType image_type) {@@ -463,6 +467,8 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) {return OperationCode::AtomicImageXor;case Tegra::Shader::ImageAtomicOperation::Exch:return OperationCode::AtomicImageExchange;+ default:+ break;}default:break;