VERY experimental Nintendo Switch 2 emulator
C++
video_core: Silent -Wswitch warnings
ReinUsesLisp7a56d07632dd
diff --git a/src/video_core/dma_pusher.cpp b/src/video_core/dma_pusher.cppindex 046d047cbe..12828d9264 100644--- a/src/video_core/dma_pusher.cpp+++ b/src/video_core/dma_pusher.cpp@@ -105,6 +105,8 @@ bool DmaPusher::Step() {dma_state.non_incrementing = false;dma_increment_once = true;break;+ default:+ break;}}}diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.hindex 321af32974..a47d5607c9 100644--- a/src/video_core/engines/maxwell_3d.h+++ b/src/video_core/engines/maxwell_3d.h@@ -243,9 +243,10 @@ public:return "10_10_10_2";case Size::Size_11_11_10:return "11_11_10";+ default:+ UNREACHABLE();+ return {};}- UNREACHABLE();- return {};}std::string TypeString() const {diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cppindex d250d5cbb9..416955a7b0 100644--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp@@ -313,6 +313,8 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {case Maxwell::ShaderProgram::Geometry:shader_program_manager->UseTrivialGeometryShader();break;+ default:+ break;}continue;}diff --git a/src/video_core/renderer_opengl/maxwell_to_gl.h b/src/video_core/renderer_opengl/maxwell_to_gl.hindex a8833c06e7..95b7731350 100644--- a/src/video_core/renderer_opengl/maxwell_to_gl.h+++ b/src/video_core/renderer_opengl/maxwell_to_gl.h@@ -27,8 +27,7 @@ using Maxwell = Tegra::Engines::Maxwell3D::Regs;inline GLenum VertexType(Maxwell::VertexAttribute attrib) {switch (attrib.type) {case Maxwell::VertexAttribute::Type::UnsignedInt:- case Maxwell::VertexAttribute::Type::UnsignedNorm: {-+ case Maxwell::VertexAttribute::Type::UnsignedNorm:switch (attrib.size) {case Maxwell::VertexAttribute::Size::Size_8:case Maxwell::VertexAttribute::Size::Size_8_8:@@ -47,16 +46,13 @@ inline GLenum VertexType(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:+ LOG_CRITICAL(Render_OpenGL, "Unimplemented vertex size={}", attrib.SizeString());+ UNREACHABLE();+ return {};}-- LOG_CRITICAL(Render_OpenGL, "Unimplemented vertex size={}", attrib.SizeString());- UNREACHABLE();- return {};- }-case Maxwell::VertexAttribute::Type::SignedInt:- case Maxwell::VertexAttribute::Type::SignedNorm: {-+ case Maxwell::VertexAttribute::Type::SignedNorm:switch (attrib.size) {case Maxwell::VertexAttribute::Size::Size_8:case Maxwell::VertexAttribute::Size::Size_8_8:@@ -75,14 +71,12 @@ inline GLenum VertexType(Maxwell::VertexAttribute attrib) {return GL_INT;case Maxwell::VertexAttribute::Size::Size_10_10_10_2:return GL_INT_2_10_10_10_REV;+ default:+ LOG_CRITICAL(Render_OpenGL, "Unimplemented vertex size={}", attrib.SizeString());+ UNREACHABLE();+ return {};}-- LOG_CRITICAL(Render_OpenGL, "Unimplemented vertex size={}", attrib.SizeString());- UNREACHABLE();- return {};- }-- case Maxwell::VertexAttribute::Type::Float: {+ case Maxwell::VertexAttribute::Type::Float:switch (attrib.size) {case Maxwell::VertexAttribute::Size::Size_16:case Maxwell::VertexAttribute::Size::Size_16_16:@@ -94,13 +88,16 @@ inline GLenum VertexType(Maxwell::VertexAttribute attrib) {case Maxwell::VertexAttribute::Size::Size_32_32_32:case Maxwell::VertexAttribute::Size::Size_32_32_32_32:return GL_FLOAT;+ default:+ LOG_CRITICAL(Render_OpenGL, "Unimplemented vertex size={}", attrib.SizeString());+ UNREACHABLE();+ return {};}+ default:+ LOG_CRITICAL(Render_OpenGL, "Unimplemented vertex type={}", attrib.TypeString());+ UNREACHABLE();+ return {};}- }-- LOG_CRITICAL(Render_OpenGL, "Unimplemented vertex type={}", attrib.TypeString());- UNREACHABLE();- return {};}inline GLenum IndexFormat(Maxwell::IndexFormat index_format) {@@ -129,10 +126,11 @@ inline GLenum PrimitiveTopology(Maxwell::PrimitiveTopology topology) {return GL_TRIANGLES;case Maxwell::PrimitiveTopology::TriangleStrip:return GL_TRIANGLE_STRIP;+ default:+ LOG_CRITICAL(Render_OpenGL, "Unimplemented topology={}", static_cast<u32>(topology));+ UNREACHABLE();+ return {};}- LOG_CRITICAL(Render_OpenGL, "Unimplemented topology={}", static_cast<u32>(topology));- UNREACHABLE();- return {};}inline GLenum TextureFilterMode(Tegra::Texture::TextureFilter filter_mode,@@ -186,9 +184,10 @@ inline GLenum WrapMode(Tegra::Texture::WrapMode wrap_mode) {} else {return GL_MIRROR_CLAMP_TO_EDGE;}+ default:+ LOG_ERROR(Render_OpenGL, "Unimplemented texture wrap mode={}", static_cast<u32>(wrap_mode));+ return GL_REPEAT;}- LOG_ERROR(Render_OpenGL, "Unimplemented texture wrap mode={}", static_cast<u32>(wrap_mode));- return GL_REPEAT;}inline GLenum DepthCompareFunc(Tegra::Texture::DepthCompareFunc func) {diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cppindex 34bf26ff2e..9fe1e3280c 100644--- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp+++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp@@ -62,9 +62,10 @@ vk::SamplerAddressMode WrapMode(Tegra::Texture::WrapMode wrap_mode) {case Tegra::Texture::WrapMode::MirrorOnceBorder:UNIMPLEMENTED();return vk::SamplerAddressMode::eMirrorClampToEdge;+ default:+ UNIMPLEMENTED_MSG("Unimplemented wrap mode={}", static_cast<u32>(wrap_mode));+ return {};}- UNIMPLEMENTED_MSG("Unimplemented wrap mode={}", static_cast<u32>(wrap_mode));- return {};}vk::CompareOp DepthCompareFunction(Tegra::Texture::DepthCompareFunc depth_compare_func) {@@ -225,9 +226,10 @@ vk::PrimitiveTopology PrimitiveTopology(Maxwell::PrimitiveTopology topology) {return vk::PrimitiveTopology::eTriangleList;case Maxwell::PrimitiveTopology::TriangleStrip:return vk::PrimitiveTopology::eTriangleStrip;+ default:+ UNIMPLEMENTED_MSG("Unimplemented topology={}", static_cast<u32>(topology));+ return {};}- UNIMPLEMENTED_MSG("Unimplemented topology={}", static_cast<u32>(topology));- return {};}vk::Format VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttribute::Size size) {diff --git a/src/video_core/shader/decode.cpp b/src/video_core/shader/decode.cppindex e4c4387929..2da595c0d1 100644--- a/src/video_core/shader/decode.cpp+++ b/src/video_core/shader/decode.cpp@@ -116,6 +116,8 @@ ExitMethod ShaderIR::Scan(u32 begin, u32 end, std::set<u32>& labels) {// Continue scanning for an exit method.break;}+ default:+ break;}}return exit_method = ExitMethod::AlwaysReturn;@@ -206,4 +208,4 @@ u32 ShaderIR::DecodeInstr(NodeBlock& bb, u32 pc) {return pc + 1;}-} // namespace VideoCommon::Shader\ No newline at end of file+} // namespace VideoCommon::Shaderdiff --git a/src/video_core/shader/decode/conversion.cpp b/src/video_core/shader/decode/conversion.cppindex 55a6fbbf20..da26489a09 100644--- a/src/video_core/shader/decode/conversion.cpp+++ b/src/video_core/shader/decode/conversion.cpp@@ -90,10 +90,11 @@ u32 ShaderIR::DecodeConversion(NodeBlock& bb, u32 pc) {return Operation(OperationCode::FCeil, PRECISE, value);case Tegra::Shader::F2fRoundingOp::Trunc:return Operation(OperationCode::FTrunc, PRECISE, value);+ default:+ UNIMPLEMENTED_MSG("Unimplemented F2F rounding mode {}",+ static_cast<u32>(instr.conversion.f2f.rounding.Value()));+ return Immediate(0);}- UNIMPLEMENTED_MSG("Unimplemented F2F rounding mode {}",- static_cast<u32>(instr.conversion.f2f.rounding.Value()));- return Immediate(0);}();value = GetSaturatedFloat(value, instr.alu.saturate_d);diff --git a/src/video_core/shader/decode/xmad.cpp b/src/video_core/shader/decode/xmad.cppindex db15c0718f..04a7763982 100644--- a/src/video_core/shader/decode/xmad.cpp+++ b/src/video_core/shader/decode/xmad.cpp@@ -56,9 +56,10 @@ u32 ShaderIR::DecodeXmad(NodeBlock& bb, u32 pc) {instr.xmad.mode,Immediate(static_cast<u32>(instr.xmad.imm20_16)),GetRegister(instr.gpr39)};+ default:+ UNIMPLEMENTED_MSG("Unhandled XMAD instruction: {}", opcode->get().GetName());+ return {false, false, false, Tegra::Shader::XmadMode::None, Immediate(0), Immediate(0)};}- UNIMPLEMENTED_MSG("Unhandled XMAD instruction: {}", opcode->get().GetName());- return {false, false, false, Tegra::Shader::XmadMode::None, Immediate(0), Immediate(0)};}();op_a = BitfieldExtract(op_a, instr.xmad.high_a ? 16 : 0, 16);diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cppindex ac5112d78f..cb60b8886b 100644--- a/src/video_core/shader/shader_ir.cpp+++ b/src/video_core/shader/shader_ir.cpp@@ -434,11 +434,14 @@ Node ShaderIR::BitfieldExtract(Node value, u32 offset, u32 bits) {return OperationCode::LogicalUGreaterEqual;case OperationCode::INegate:UNREACHABLE_MSG("Can't negate an unsigned integer");+ return {};case OperationCode::IAbsolute:UNREACHABLE_MSG("Can't apply absolute to an unsigned integer");+ return {};+ default:+ UNREACHABLE_MSG("Unknown signed operation with code={}", static_cast<u32>(operation_code));+ return {};}- UNREACHABLE_MSG("Unknown signed operation with code={}", static_cast<u32>(operation_code));- return {};}-} // namespace VideoCommon::Shader\ No newline at end of file+} // namespace VideoCommon::Shaderdiff --git a/src/video_core/surface.cpp b/src/video_core/surface.cppindex 3b022a4566..6384fa8d2c 100644--- a/src/video_core/surface.cpp+++ b/src/video_core/surface.cpp@@ -178,39 +178,44 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,return PixelFormat::ABGR8S;case Tegra::Texture::ComponentType::UINT:return PixelFormat::ABGR8UI;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;case Tegra::Texture::TextureFormat::B5G6R5:switch (component_type) {case Tegra::Texture::ComponentType::UNORM:return PixelFormat::B5G6R5U;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;case Tegra::Texture::TextureFormat::A2B10G10R10:switch (component_type) {case Tegra::Texture::ComponentType::UNORM:return PixelFormat::A2B10G10R10U;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;case Tegra::Texture::TextureFormat::A1B5G5R5:switch (component_type) {case Tegra::Texture::ComponentType::UNORM:return PixelFormat::A1B5G5R5U;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;case Tegra::Texture::TextureFormat::R8:switch (component_type) {case Tegra::Texture::ComponentType::UNORM:return PixelFormat::R8U;case Tegra::Texture::ComponentType::UINT:return PixelFormat::R8UI;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;case Tegra::Texture::TextureFormat::G8R8:// TextureFormat::G8R8 is actually ordered red then green, as such we can use// PixelFormat::RG8U and PixelFormat::RG8S. This was tested with The Legend of Zelda: Breath@@ -220,50 +225,55 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,return PixelFormat::RG8U;case Tegra::Texture::ComponentType::SNORM:return PixelFormat::RG8S;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;case Tegra::Texture::TextureFormat::R16_G16_B16_A16:switch (component_type) {case Tegra::Texture::ComponentType::UNORM:return PixelFormat::RGBA16U;case Tegra::Texture::ComponentType::FLOAT:return PixelFormat::RGBA16F;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;case Tegra::Texture::TextureFormat::BF10GF11RF11:switch (component_type) {case Tegra::Texture::ComponentType::FLOAT:return PixelFormat::R11FG11FB10F;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();case Tegra::Texture::TextureFormat::R32_G32_B32_A32:switch (component_type) {case Tegra::Texture::ComponentType::FLOAT:return PixelFormat::RGBA32F;case Tegra::Texture::ComponentType::UINT:return PixelFormat::RGBA32UI;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;case Tegra::Texture::TextureFormat::R32_G32:switch (component_type) {case Tegra::Texture::ComponentType::FLOAT:return PixelFormat::RG32F;case Tegra::Texture::ComponentType::UINT:return PixelFormat::RG32UI;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;case Tegra::Texture::TextureFormat::R32_G32_B32:switch (component_type) {case Tegra::Texture::ComponentType::FLOAT:return PixelFormat::RGB32F;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;case Tegra::Texture::TextureFormat::R16:switch (component_type) {case Tegra::Texture::ComponentType::FLOAT:@@ -276,18 +286,20 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,return PixelFormat::R16UI;case Tegra::Texture::ComponentType::SINT:return PixelFormat::R16I;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;case Tegra::Texture::TextureFormat::R32:switch (component_type) {case Tegra::Texture::ComponentType::FLOAT:return PixelFormat::R32F;case Tegra::Texture::ComponentType::UINT:return PixelFormat::R32UI;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;case Tegra::Texture::TextureFormat::ZF32:return PixelFormat::Z32F;case Tegra::Texture::TextureFormat::Z16:@@ -310,9 +322,10 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,return PixelFormat::DXN2UNORM;case Tegra::Texture::ComponentType::SNORM:return PixelFormat::DXN2SNORM;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;case Tegra::Texture::TextureFormat::BC7U:return is_srgb ? PixelFormat::BC7U_SRGB : PixelFormat::BC7U;case Tegra::Texture::TextureFormat::BC6H_UF16:@@ -343,15 +356,17 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,return PixelFormat::RG16UI;case Tegra::Texture::ComponentType::SINT:return PixelFormat::RG16I;+ default:+ break;}- LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));- UNREACHABLE();+ break;default:- LOG_CRITICAL(HW_GPU, "Unimplemented format={}, component_type={}", static_cast<u32>(format),- static_cast<u32>(component_type));- UNREACHABLE();- return PixelFormat::ABGR8U;+ break;}+ LOG_CRITICAL(HW_GPU, "Unimplemented format={}, component_type={}", static_cast<u32>(format),+ static_cast<u32>(component_type));+ UNREACHABLE();+ return PixelFormat::ABGR8U;}ComponentType ComponentTypeFromTexture(Tegra::Texture::ComponentType type) {@@ -513,8 +528,9 @@ bool IsFormatBCn(PixelFormat format) {case PixelFormat::DXT45_SRGB:case PixelFormat::BC7U_SRGB:return true;+ default:+ return false;}- return false;}} // namespace VideoCore::Surface