From 23094b48bbb4743382bf361aa3c913ad883a6f4f Mon Sep 17 00:00:00 2001 From: JohnHolmesII Date: Fri, 10 May 2019 22:36:16 -0700 Subject: [PATCH] Fix warnings related to -Wswitch Add default cases. Move default breaks to newline Add proper handling in some instances. Add missing enums to switches --- rpcs3/Emu/Cell/Modules/cellSysutil.cpp | 1 + rpcs3/Emu/Cell/lv2/lv2.cpp | 1 + rpcs3/Emu/RSX/GL/GLTextureCache.h | 2 ++ rpcs3/Emu/RSX/Overlays/overlay_osk.cpp | 2 ++ rpcs3/Emu/RSX/RSXThread.cpp | 12 ++++++++++++ rpcs3/Emu/RSX/VK/VKFormats.cpp | 26 ++++++++++++++++++++++++-- rpcs3/Emu/RSX/VK/VKGSRender.cpp | 8 +++++++- rpcs3/Emu/RSX/VK/VKHelpers.cpp | 6 ++++++ rpcs3/Emu/RSX/VK/VKHelpers.h | 3 +++ rpcs3/Emu/RSX/VK/VKTexture.cpp | 3 +++ rpcs3/Emu/RSX/VK/VKTextureCache.h | 7 ++++++- rpcs3/Emu/RSX/rsx_methods.cpp | 2 ++ 12 files changed, 69 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp index 5080a2115e..db498b60b6 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp @@ -124,6 +124,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case CELL_SYSUTIL_SYSTEMPARAM_ID_JAPANESE_KEYBOARD_ENTRY_METHOD: return "ID_JAPANESE_KEYBOARD_ENTRY_METHOD"; case CELL_SYSUTIL_SYSTEMPARAM_ID_CHINESE_KEYBOARD_ENTRY_METHOD: return "ID_CHINESE_KEYBOARD_ENTRY_METHOD"; case CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_AUTOOFF: return "ID_PAD_AUTOOFF"; + case CELL_SYSUTIL_SYSTEMPARAM_ID_MAGNETOMETER: return "ID_MAGNETOMETER"; case CELL_SYSUTIL_SYSTEMPARAM_ID_NICKNAME: return "ID_NICKNAME"; case CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USERNAME: return "ID_CURRENT_USERNAME"; } diff --git a/rpcs3/Emu/Cell/lv2/lv2.cpp b/rpcs3/Emu/Cell/lv2/lv2.cpp index 4c8121ce64..cf9f2ac734 100644 --- a/rpcs3/Emu/Cell/lv2/lv2.cpp +++ b/rpcs3/Emu/Cell/lv2/lv2.cpp @@ -913,6 +913,7 @@ void fmt_class_string::format(std::string& out, u64 arg) STR_CASE(CELL_ETIMEDOUT); STR_CASE(CELL_EABORT); STR_CASE(CELL_EFAULT); + STR_CASE(CELL_ENOCHILD); STR_CASE(CELL_ESTAT); STR_CASE(CELL_EALIGN); STR_CASE(CELL_EKRESOURCE); diff --git a/rpcs3/Emu/RSX/GL/GLTextureCache.h b/rpcs3/Emu/RSX/GL/GLTextureCache.h index a70c51c408..564d7a29cb 100644 --- a/rpcs3/Emu/RSX/GL/GLTextureCache.h +++ b/rpcs3/Emu/RSX/GL/GLTextureCache.h @@ -212,6 +212,8 @@ namespace gl case gl::texture::type::f32: gcm_format = CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT; break; + default: + break; } } } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp index 9b8d44fd6c..43d11e0be5 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp @@ -397,6 +397,8 @@ namespace rsx } break; } + default: + break; } } diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 5f87e8aafc..c5d2982b23 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -118,6 +118,8 @@ namespace rsx return sizeof(u16) * size; case 3: return sizeof(u16) * 4; + default: + break; } fmt::throw_exception("Wrong vector size" HERE); case vertex_base_type::f: return sizeof(f32) * size; @@ -130,6 +132,8 @@ namespace rsx return sizeof(f16) * size; case 3: return sizeof(f16) * 4; + default: + break; } fmt::throw_exception("Wrong vector size" HERE); case vertex_base_type::ub: @@ -141,10 +145,14 @@ namespace rsx return sizeof(u8) * size; case 3: return sizeof(u8) * 4; + default: + break; } fmt::throw_exception("Wrong vector size" HERE); case vertex_base_type::cmp: return 4; case vertex_base_type::ub256: verify(HERE), (size == 4); return sizeof(u8) * 4; + default: + break; } fmt::throw_exception("RSXVertexData::GetTypeSize: Bad vertex data type (%d)!" HERE, (u8)type); } @@ -2036,6 +2044,8 @@ namespace rsx // These are single byte formats, but inverted order (BGRA vs ARGB) when passed via registers to_swap_bytes = (layout.attribute_placement[index] == attribute_buffer_placement::transient); break; + default: + break; } if (to_swap_bytes) attrib1 |= swap_storage_mask; @@ -2451,6 +2461,8 @@ namespace rsx case frame_limit_type::_60: limit = 60.; break; case frame_limit_type::_30: limit = 30.; break; case frame_limit_type::_auto: limit = fps_limit; break; // TODO + default: + break; } if (limit) diff --git a/rpcs3/Emu/RSX/VK/VKFormats.cpp b/rpcs3/Emu/RSX/VK/VKFormats.cpp index 4b7cba6e18..4e7ce46a30 100644 --- a/rpcs3/Emu/RSX/VK/VKFormats.cpp +++ b/rpcs3/Emu/RSX/VK/VKFormats.cpp @@ -42,6 +42,8 @@ namespace vk if (support.d32_sfloat_s8) return VK_FORMAT_D32_SFLOAT_S8_UINT; fmt::throw_exception("No hardware support for z24s8" HERE); } + default: + break; } fmt::throw_exception("Invalid format (0x%x)" HERE, (u32)format); } @@ -57,6 +59,9 @@ namespace vk case rsx::texture_minify_filter::nearest_linear: return std::make_tuple(VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_LINEAR); case rsx::texture_minify_filter::linear_linear: return std::make_tuple(VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_LINEAR); case rsx::texture_minify_filter::convolution_min: return std::make_tuple(VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_LINEAR); + default: + ASSUME(0); + break; } fmt::throw_exception("Invalid max filter" HERE); } @@ -68,6 +73,9 @@ namespace vk case rsx::texture_magnify_filter::nearest: return VK_FILTER_NEAREST; case rsx::texture_magnify_filter::linear: return VK_FILTER_LINEAR; case rsx::texture_magnify_filter::convolution_mag: return VK_FILTER_LINEAR; + default: + ASSUME(0); + break; } fmt::throw_exception("Invalid mag filter (0x%x)" HERE, (u32)mag_filter); } @@ -119,6 +127,9 @@ namespace vk case rsx::texture_wrap_mode::mirror_once_clamp_to_edge: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE; case rsx::texture_wrap_mode::mirror_once_border: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE; case rsx::texture_wrap_mode::mirror_once_clamp: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE; + default: + ASSUME(0); + break; } fmt::throw_exception("unhandled texture clamp mode" HERE); } @@ -135,6 +146,9 @@ namespace vk case rsx::texture_max_anisotropy::x10: return 10.0f; case rsx::texture_max_anisotropy::x12: return 12.0f; case rsx::texture_max_anisotropy::x16: return 16.0f; + default: + ASSUME(0); + break; } fmt::throw_exception("Texture anisotropy error: bad max aniso (%d)" HERE, (u32)gcm_aniso); @@ -188,7 +202,7 @@ namespace vk case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT: case CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT: mapping = { VK_COMPONENT_SWIZZLE_A, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B }; break; - + case CELL_GCM_TEXTURE_D8R8G8B8: mapping = { VK_COMPONENT_SWIZZLE_ONE, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_A }; break; @@ -209,7 +223,7 @@ namespace vk default: fmt::throw_exception("Invalid or unsupported component mapping for texture format (0x%x)" HERE, format); } - + return mapping; } @@ -244,6 +258,8 @@ namespace vk case CELL_GCM_TEXTURE_COMPRESSED_HILO_S8: return VK_FORMAT_R8G8_SNORM; case CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8: return VK_FORMAT_B8G8R8A8_UNORM; case CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8: return VK_FORMAT_B8G8R8A8_UNORM; + default: + break; } fmt::throw_exception("Invalid or unsupported sampler format for texture format (0x%x)" HERE, format); } @@ -305,6 +321,8 @@ namespace vk case VK_FORMAT_D32_SFLOAT_S8_UINT: //TODO: Translate to D24S8 case VK_FORMAT_D24_UNORM_S8_UINT: return 4; + default: + break; } fmt::throw_exception("Unexpected vkFormat 0x%X", (u32)format); @@ -364,6 +382,8 @@ namespace vk case VK_FORMAT_D32_SFLOAT_S8_UINT: case VK_FORMAT_D24_UNORM_S8_UINT: return{ 4, 1 }; + default: + break; } fmt::throw_exception("Unexpected vkFormat 0x%X", (u32)format); @@ -414,6 +434,8 @@ namespace vk case VK_FORMAT_D32_SFLOAT_S8_UINT: case VK_FORMAT_D24_UNORM_S8_UINT: return{ true, 4 }; + default: + break; } fmt::throw_exception("Unknown vkFormat 0x%x" HERE, (u32)format); diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index a4ff930332..8fc11a2fd5 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -17,6 +17,9 @@ namespace { case rsx::surface_depth_format::z16: return 0xFFFF; case rsx::surface_depth_format::z24s8: return 0xFFFFFF; + default: + ASSUME(0); + break; } fmt::throw_exception("Unknown depth format" HERE); } @@ -27,6 +30,9 @@ namespace { case rsx::surface_depth_format::z16: return 2; case rsx::surface_depth_format::z24s8: return 4; + default: + ASSUME(0); + break; } fmt::throw_exception("Unknown depth format" HERE); } @@ -1068,7 +1074,7 @@ void VKGSRender::emit_geometry(u32 sub_index) } else if (draw_call.execute_pipeline_dependencies() & rsx::vertex_base_changed) { - // Rebase vertex bases instead of + // Rebase vertex bases instead of for (auto &info : m_vertex_layout.interleaved_blocks) { const auto vertex_base_offset = rsx::method_registers.vertex_data_base_offset(); diff --git a/rpcs3/Emu/RSX/VK/VKHelpers.cpp b/rpcs3/Emu/RSX/VK/VKHelpers.cpp index d1dcad6405..47e55ed399 100644 --- a/rpcs3/Emu/RSX/VK/VKHelpers.cpp +++ b/rpcs3/Emu/RSX/VK/VKHelpers.cpp @@ -504,6 +504,7 @@ namespace vk barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT; dst_stage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; break; + default: case VK_IMAGE_LAYOUT_UNDEFINED: case VK_IMAGE_LAYOUT_PREINITIALIZED: fmt::throw_exception("Attempted to transition to an invalid layout"); @@ -575,6 +576,8 @@ namespace vk barrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT; src_stage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; break; + default: + break; //TODO Investigate what happens here } vkCmdPipelineBarrier(cmd, src_stage, dst_stage, 0, 0, nullptr, 0, nullptr, 1, &barrier); @@ -856,11 +859,14 @@ namespace vk switch (severity) { + default: case 0: fmt::throw_exception("Assertion Failed! Vulkan API call failed with unrecoverable error: %s%s", error_message.c_str(), faulting_addr); case 1: LOG_ERROR(RSX, "Vulkan API call has failed with an error but will continue: %s%s", error_message.c_str(), faulting_addr); break; + case 2: + break; } } diff --git a/rpcs3/Emu/RSX/VK/VKHelpers.h b/rpcs3/Emu/RSX/VK/VKHelpers.h index 9d5478396b..02c10c52ec 100644 --- a/rpcs3/Emu/RSX/VK/VKHelpers.h +++ b/rpcs3/Emu/RSX/VK/VKHelpers.h @@ -1215,6 +1215,9 @@ private: case VK_IMAGE_TYPE_3D: info.viewType = VK_IMAGE_VIEW_TYPE_3D; break; + default: + ASSUME(0); + break; } create_impl(); diff --git a/rpcs3/Emu/RSX/VK/VKTexture.cpp b/rpcs3/Emu/RSX/VK/VKTexture.cpp index 961c72d907..a4bfcd2239 100644 --- a/rpcs3/Emu/RSX/VK/VKTexture.cpp +++ b/rpcs3/Emu/RSX/VK/VKTexture.cpp @@ -476,6 +476,9 @@ namespace vk stretch_image_typeless_safe(src, dst, typeless_stencil->value, src_rect, dst_rect, depth_stencil, VK_IMAGE_ASPECT_STENCIL_BIT); break; } + default: + fmt::throw_exception("Unreachable" HERE); + break; } } } diff --git a/rpcs3/Emu/RSX/VK/VKTextureCache.h b/rpcs3/Emu/RSX/VK/VKTextureCache.h index 138aeb1f36..d4bcf9bc42 100644 --- a/rpcs3/Emu/RSX/VK/VKTextureCache.h +++ b/rpcs3/Emu/RSX/VK/VKTextureCache.h @@ -140,7 +140,7 @@ namespace vk return managed_texture.get(); } - std::unique_ptr& get_texture() + std::unique_ptr& get_texture() { return managed_texture; } @@ -914,6 +914,9 @@ namespace vk image_view_type = VK_IMAGE_VIEW_TYPE_3D; layer = 1; break; + default: + ASSUME(0); + break; } switch (gcm_format) @@ -991,6 +994,8 @@ namespace vk case VK_FORMAT_D24_UNORM_S8_UINT: subres_range.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT; break; + default: + break; } change_image_layout(cmd, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, subres_range); diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index 39f11e92db..33c791de73 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -245,6 +245,8 @@ namespace rsx // Get BE data arg = be_t{arg}.raw(); break; + default: + break; } if (rsx->in_begin_end)