From 8980fc5524cbfc8253c70deb9fa5be887d76de10 Mon Sep 17 00:00:00 2001 From: Eladash Date: Fri, 16 Dec 2022 19:10:23 +0200 Subject: [PATCH] rsx: Fix exceptions --- Utilities/Thread.cpp | 16 ++--- rpcs3/Emu/RSX/GL/GLDraw.cpp | 6 +- rpcs3/Emu/RSX/VK/VKGSRender.cpp | 6 +- rpcs3/Emu/RSX/gcm_enums.cpp | 115 +++++++++++++++++++++++--------- rpcs3/Emu/RSX/gcm_enums.h | 48 ++++++++++--- rpcs3/Loader/PUP.cpp | 4 +- 6 files changed, 135 insertions(+), 60 deletions(-) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index fdb695f85b..d763443abd 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -100,23 +100,17 @@ extern thread_local std::string(*g_tls_log_prefix)(); std::string dump_useful_thread_info() { - thread_local volatile bool guard = false; - std::string result; - // In case the dumping function was the cause for the exception/access violation - // Avoid recursion - if (std::exchange(guard, true)) - { - return result; - } - if (auto cpu = get_current_cpu_thread()) { - cpu->dump_all(result); + // Wrap it to disable some internal exceptions when printing (not thrown on main thread) + Emu.BlockingCallFromMainThread([&]() + { + cpu->dump_all(result); + }); } - guard = false; return result; } diff --git a/rpcs3/Emu/RSX/GL/GLDraw.cpp b/rpcs3/Emu/RSX/GL/GLDraw.cpp index be402812e3..f33ddf8cec 100644 --- a/rpcs3/Emu/RSX/GL/GLDraw.cpp +++ b/rpcs3/Emu/RSX/GL/GLDraw.cpp @@ -48,11 +48,11 @@ namespace gl case rsx::blend_equation::add: return GL_FUNC_ADD; case rsx::blend_equation::min: return GL_MIN; case rsx::blend_equation::max: return GL_MAX; - case rsx::blend_equation::substract: return GL_FUNC_SUBTRACT; - case rsx::blend_equation::reverse_substract_signed: + case rsx::blend_equation::subtract: return GL_FUNC_SUBTRACT; + case rsx::blend_equation::reverse_subtract_signed: rsx_log.trace("blend equation reverse_subtract_signed used. Emulating using FUNC_REVERSE_SUBTRACT"); [[fallthrough]]; - case rsx::blend_equation::reverse_substract: return GL_FUNC_REVERSE_SUBTRACT; + case rsx::blend_equation::reverse_subtract: return GL_FUNC_REVERSE_SUBTRACT; case rsx::blend_equation::reverse_add_signed: default: rsx_log.error("Blend equation 0x%X is unimplemented!", static_cast(op)); diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 4d0764228d..562973aedd 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -158,11 +158,11 @@ namespace vk [[fallthrough]]; case rsx::blend_equation::add: return VK_BLEND_OP_ADD; - case rsx::blend_equation::substract: return VK_BLEND_OP_SUBTRACT; - case rsx::blend_equation::reverse_substract_signed: + case rsx::blend_equation::subtract: return VK_BLEND_OP_SUBTRACT; + case rsx::blend_equation::reverse_subtract_signed: rsx_log.trace("blend equation reverse_subtract_signed used. Emulating using FUNC_REVERSE_SUBTRACT"); [[fallthrough]]; - case rsx::blend_equation::reverse_substract: return VK_BLEND_OP_REVERSE_SUBTRACT; + case rsx::blend_equation::reverse_subtract: return VK_BLEND_OP_REVERSE_SUBTRACT; case rsx::blend_equation::min: return VK_BLEND_OP_MIN; case rsx::blend_equation::max: return VK_BLEND_OP_MAX; default: diff --git a/rpcs3/Emu/RSX/gcm_enums.cpp b/rpcs3/Emu/RSX/gcm_enums.cpp index a610c5e5f4..532d8ced5d 100644 --- a/rpcs3/Emu/RSX/gcm_enums.cpp +++ b/rpcs3/Emu/RSX/gcm_enums.cpp @@ -1,8 +1,32 @@ #include "gcm_enums.h" #include "Utilities/StrFmt.h" +#include "Utilities/Thread.h" + using namespace rsx; +struct convertible_to_invalid +{ + convertible_to_invalid() noexcept = default; + + template requires (std::is_enum_v) + constexpr operator T() const + { + return T::invalid; + } +}; + +template +convertible_to_invalid throw_exception_if_emulating(const char(&fmt)[Size], Args&&... args) +{ + if (thread_ctrl::get_current()) + { + fmt::throw_exception(fmt, std::forward(args)...); + } + + return {}; +} + vertex_base_type rsx::to_vertex_base_type(u8 in) { switch (in) @@ -16,7 +40,7 @@ vertex_base_type rsx::to_vertex_base_type(u8 in) case 6: return vertex_base_type::cmp; case 7: return vertex_base_type::ub256; } - fmt::throw_exception("Unknown vertex base type %d", in); + return throw_exception_if_emulating("Unknown vertex base type %d", in); } primitive_type rsx::to_primitive_type(u8 in) @@ -52,7 +76,7 @@ window_origin rsx::to_window_origin(u8 in) case CELL_GCM_WINDOW_ORIGIN_TOP: return window_origin::top; case CELL_GCM_WINDOW_ORIGIN_BOTTOM: return window_origin::bottom; } - fmt::throw_exception("Unknown window origin modifier 0x%x", in); + return throw_exception_if_emulating("Unknown window origin modifier 0x%x", in); } window_pixel_center rsx::to_window_pixel_center(u8 in) @@ -62,7 +86,7 @@ window_pixel_center rsx::to_window_pixel_center(u8 in) case CELL_GCM_WINDOW_PIXEL_CENTER_HALF: return window_pixel_center::half; case CELL_GCM_WINDOW_PIXEL_CENTER_INTEGER: return window_pixel_center::integer; } - fmt::throw_exception("Unknown window pixel center 0x%x", in); + return throw_exception_if_emulating("Unknown window pixel center 0x%x", in); } comparison_function rsx::to_comparison_function(u16 in) @@ -101,7 +125,7 @@ comparison_function rsx::to_comparison_function(u16 in) case CELL_GCM_ALWAYS: return comparison_function::always; } - fmt::throw_exception("Unknown comparison function 0x%x", in); + return throw_exception_if_emulating("Unknown comparison function 0x%x", in); } fog_mode rsx::to_fog_mode(u32 in) @@ -115,7 +139,7 @@ fog_mode rsx::to_fog_mode(u32 in) case CELL_GCM_FOG_MODE_EXP2_ABS: return fog_mode::exponential2_abs; case CELL_GCM_FOG_MODE_LINEAR_ABS: return fog_mode::linear_abs; } - fmt::throw_exception("Unknown fog mode 0x%x", in); + return throw_exception_if_emulating("Unknown fog mode 0x%x", in); } texture_dimension rsx::to_texture_dimension(u8 in) @@ -126,7 +150,7 @@ texture_dimension rsx::to_texture_dimension(u8 in) case 2: return texture_dimension::dimension2d; case 3: return texture_dimension::dimension3d; } - fmt::throw_exception("Unknown texture dimension %d", in); + return throw_exception_if_emulating("Unknown texture dimension %d", in); } template <> @@ -228,6 +252,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case comparison_function::not_equal: return "Not_equal"; case comparison_function::greater_or_equal: return "Greater_equal"; case comparison_function::always: return "Always"; + case comparison_function::invalid: return "Invalid"; } return unknown; @@ -249,6 +274,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case stencil_op::incr_wrap: return "Incr_wrap"; case stencil_op::decr_wrap: return "Decr_wrap"; case stencil_op::invert: return "Invert"; + case stencil_op::invalid: return "Invalid"; } return unknown; @@ -268,6 +294,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case fog_mode::exponential_abs: return "exponential(abs)"; case fog_mode::linear: return "linear"; case fog_mode::linear_abs: return "linear(abs)"; + case fog_mode::invalid: return "Invalid"; } return unknown; @@ -297,6 +324,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case logic_op::logic_copy_inverted: return "Copy_inverted"; case logic_op::logic_or_inverted: return "Or_inverted"; case logic_op::logic_nand: return "Nand"; + case logic_op::invalid: return "Invalid"; } return unknown; @@ -312,6 +340,7 @@ void fmt_class_string::format(std::string& out, u64 arg) { case front_face::ccw: return "counter clock wise"; case front_face::cw: return "clock wise"; + case front_face::invalid: return "Invalid"; } return unknown; @@ -328,6 +357,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case cull_face::back: return "back"; case cull_face::front: return "front"; case cull_face::front_and_back: return "front and back"; + case cull_face::invalid: return "Invalid"; } return unknown; @@ -347,6 +377,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case surface_target::surfaces_a_b: return "surfaces A and B"; case surface_target::surfaces_a_b_c: return "surfaces A, B and C"; case surface_target::surfaces_a_b_c_d: return "surfaces A,B, C and D"; + case surface_target::invalid: return "Invalid"; } return unknown; @@ -390,6 +421,7 @@ void fmt_class_string::format(std::string& out, case blit_engine::transfer_operation::srccopy: return "srccopy"; case blit_engine::transfer_operation::srccopy_and: return "srccopy_and"; case blit_engine::transfer_operation::srccopy_premult: return "srccopy_premult"; + case blit_engine::transfer_operation::invalid: return "Invalid"; default: return unknown; } }); @@ -415,6 +447,7 @@ void fmt_class_string::format(std::string& case blit_engine::transfer_source_format::x8r8g8b8: return "x8r8g8b8"; case blit_engine::transfer_source_format::y8: return "y8"; case blit_engine::transfer_source_format::yb8cr8ya8cb8: return "yb8cr8ya8cb8"; + case blit_engine::transfer_source_format::invalid: return "Invalid"; default: return unknown; } }); @@ -429,6 +462,7 @@ void fmt_class_string::format(std::string& out, u6 { case blit_engine::context_surface::surface2d: return "surface 2d"; case blit_engine::context_surface::swizzle2d: return "swizzle 2d"; + case blit_engine::context_surface::invalid: return "Invalid"; } return unknown; @@ -445,6 +479,7 @@ void fmt_class_string::format(std::str case blit_engine::transfer_destination_format::a8r8g8b8: return "a8r8g8b8"; case blit_engine::transfer_destination_format::r5g6b5: return "r5g6b5"; case blit_engine::transfer_destination_format::y32: return "y32"; + case blit_engine::transfer_destination_format::invalid: return "Invalid"; default: return unknown; } }); @@ -459,6 +494,7 @@ void fmt_class_string::format(std::string& out, u64 arg) { case index_array_type::u16: return "u16"; case index_array_type::u32: return "u32"; + case index_array_type::invalid: return "Invalid"; } return unknown; @@ -475,6 +511,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case polygon_mode::fill: return "fill"; case polygon_mode::line: return "line"; case polygon_mode::point: return "point"; + case polygon_mode::invalid: return "Invalid"; } return unknown; @@ -502,6 +539,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case surface_color_format::x8b8g8r8_z8b8g8r8: return "X8B8G8R8_Z8B8G8R8"; case surface_color_format::x8b8g8r8_o8b8g8r8: return "X8B8G8R8_O8B8G8R8"; case surface_color_format::a8b8g8r8: return "A8B8G8R8"; + case surface_color_format::invalid: return "Invalid"; } return unknown; @@ -519,6 +557,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case surface_antialiasing::diagonal_centered_2_samples: return "2 samples diagonal centered"; case surface_antialiasing::square_centered_4_samples: return "4 samples square centered"; case surface_antialiasing::square_rotated_4_samples: return "4 samples diagonal rotated"; + case surface_antialiasing::invalid: return "Invalid"; } return unknown; @@ -533,13 +572,14 @@ void fmt_class_string::format(std::string& out, u64 arg) switch (value) { case blend_equation::add: return "Add"; - case blend_equation::substract: return "Substract"; - case blend_equation::reverse_substract: return "Reverse_substract"; + case blend_equation::subtract: return "Subtract"; + case blend_equation::reverse_subtract: return "Reverse_subtract"; case blend_equation::min: return "Min"; case blend_equation::max: return "Max"; case blend_equation::add_signed: return "Add_signed"; case blend_equation::reverse_add_signed: return "Reverse_add_signed"; - case blend_equation::reverse_substract_signed: return "Reverse_substract_signed"; + case blend_equation::reverse_subtract_signed: return "Reverse_subtract_signed"; + case blend_equation::invalid: return "Invalid"; } return unknown; @@ -568,6 +608,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case blend_factor::one_minus_constant_color: return "(1 - const.rgb)"; case blend_factor::constant_alpha: return "const.a"; case blend_factor::one_minus_constant_alpha: return "(1 - const.a)"; + case blend_factor::invalid: return "Invalid"; } return unknown; @@ -583,6 +624,7 @@ void fmt_class_string::format(std::string& out, u64 arg) { case window_origin::bottom: return "bottom"; case window_origin::top: return "top"; + case window_origin::invalid: return "Invalid"; } return unknown; @@ -598,6 +640,7 @@ void fmt_class_string::format(std::string& out, u64 arg) { case window_pixel_center::half: return "half"; case window_pixel_center::integer: return "integer"; + case window_pixel_center::invalid: return "Invalid"; } return unknown; @@ -614,6 +657,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case user_clip_plane_op::disable: return "disabled"; case user_clip_plane_op::greater_or_equal: return "greater or equal"; case user_clip_plane_op::less_than: return "less than"; + case user_clip_plane_op::invalid: return "Invalid"; } return unknown; @@ -630,6 +674,7 @@ void fmt_class_string::format(std::string& out, u64 ar case blit_engine::context_dma::report_location_main: return "report location main"; case blit_engine::context_dma::to_memory_get_report: return "to memory get report"; case blit_engine::context_dma::memory_host_buffer: return "memory host buffer"; + case blit_engine::context_dma::invalid: return "Invalid"; } return unknown; @@ -645,6 +690,7 @@ void fmt_class_string::format(std::string& out, u6 { case blit_engine::transfer_origin::center: return "center"; case blit_engine::transfer_origin::corner: return "corner"; + case blit_engine::transfer_origin::invalid: return "Invalid"; } return unknown; @@ -660,6 +706,7 @@ void fmt_class_string::format(std::string& out, u64 arg) { case shading_mode::flat: return "flat"; case shading_mode::smooth: return "smooth"; + case shading_mode::invalid: return "Invalid"; } return unknown; @@ -675,6 +722,7 @@ void fmt_class_string::format(std::string& out, u64 arg) { case surface_depth_format::z16: return "Z16"; case surface_depth_format::z24s8: return "Z24S8"; + case surface_depth_format::invalid: return "Invalid"; } return unknown; @@ -691,6 +739,7 @@ void fmt_class_string::format(std::string& o { case blit_engine::transfer_interpolator::foh: return "foh"; case blit_engine::transfer_interpolator::zoh: return "zoh"; + case blit_engine::transfer_interpolator::invalid: return "Invalid"; } return unknown; @@ -708,6 +757,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case texture_dimension::dimension1d: return "1D"; case texture_dimension::dimension2d: return "2D"; case texture_dimension::dimension3d: return "3D"; + case texture_dimension::invalid: return "Invalid"; } return unknown; @@ -729,6 +779,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case texture_max_anisotropy::x10: return "10"; case texture_max_anisotropy::x12: return "12"; case texture_max_anisotropy::x16: return "16"; + case texture_max_anisotropy::invalid: return "Invalid"; } return unknown; @@ -823,7 +874,7 @@ texture_wrap_mode rsx::to_texture_wrap_mode(u8 in) case CELL_GCM_TEXTURE_MIRROR_ONCE_BORDER: return texture_wrap_mode::mirror_once_border; case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP: return texture_wrap_mode::mirror_once_clamp; } - fmt::throw_exception("Unknown wrap mode 0x%x", in); + return throw_exception_if_emulating("Unknown wrap mode 0x%x", in); } texture_max_anisotropy rsx::to_texture_max_anisotropy(u8 in) @@ -839,7 +890,7 @@ texture_max_anisotropy rsx::to_texture_max_anisotropy(u8 in) case CELL_GCM_TEXTURE_MAX_ANISO_12: return texture_max_anisotropy::x12; case CELL_GCM_TEXTURE_MAX_ANISO_16: return texture_max_anisotropy::x16; } - fmt::throw_exception("Unknown anisotropy max mode 0x%x", in); + return throw_exception_if_emulating("Unknown anisotropy max mode 0x%x", in); } texture_minify_filter rsx::to_texture_minify_filter(u8 in) @@ -854,7 +905,7 @@ texture_minify_filter rsx::to_texture_minify_filter(u8 in) case CELL_GCM_TEXTURE_LINEAR_LINEAR: return texture_minify_filter::linear_linear; case CELL_GCM_TEXTURE_CONVOLUTION_MIN: return texture_minify_filter::linear_linear; } - fmt::throw_exception("Unknown minify filter 0x%x", in); + return throw_exception_if_emulating("Unknown minify filter 0x%x", in); } @@ -866,7 +917,7 @@ texture_magnify_filter rsx::to_texture_magnify_filter(u8 in) case CELL_GCM_TEXTURE_LINEAR: return texture_magnify_filter::linear; case CELL_GCM_TEXTURE_CONVOLUTION_MAG: return texture_magnify_filter::convolution_mag; } - fmt::throw_exception("Unknown magnify filter 0x%x", in); + return throw_exception_if_emulating("Unknown magnify filter 0x%x", in); } surface_target rsx::to_surface_target(u8 in) @@ -880,7 +931,7 @@ surface_target rsx::to_surface_target(u8 in) case CELL_GCM_SURFACE_TARGET_MRT2: return surface_target::surfaces_a_b_c; case CELL_GCM_SURFACE_TARGET_MRT3: return surface_target::surfaces_a_b_c_d; } - fmt::throw_exception("Unknown surface target 0x%x", in); + return throw_exception_if_emulating("Unknown surface target 0x%x", in); } surface_depth_format rsx::to_surface_depth_format(u8 in) @@ -890,7 +941,7 @@ surface_depth_format rsx::to_surface_depth_format(u8 in) case CELL_GCM_SURFACE_Z16: return surface_depth_format::z16; case CELL_GCM_SURFACE_Z24S8: return surface_depth_format::z24s8; } - fmt::throw_exception("Unknown surface depth format 0x%x", in); + return throw_exception_if_emulating("Unknown surface depth format 0x%x", in); } surface_antialiasing rsx::to_surface_antialiasing(u8 in) @@ -902,7 +953,7 @@ surface_antialiasing rsx::to_surface_antialiasing(u8 in) case CELL_GCM_SURFACE_SQUARE_CENTERED_4: return surface_antialiasing::square_centered_4_samples; case CELL_GCM_SURFACE_SQUARE_ROTATED_4: return surface_antialiasing::square_rotated_4_samples; } - fmt::throw_exception("Unknown surface antialiasing format 0x%x", in); + return throw_exception_if_emulating("Unknown surface antialiasing format 0x%x", in); } surface_color_format rsx::to_surface_color_format(u8 in) @@ -924,7 +975,7 @@ surface_color_format rsx::to_surface_color_format(u8 in) case CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8: return surface_color_format::x8b8g8r8_o8b8g8r8; case CELL_GCM_SURFACE_A8B8G8R8: return surface_color_format::a8b8g8r8; } - fmt::throw_exception("Unknown surface color format 0x%x", in); + return throw_exception_if_emulating("Unknown surface color format 0x%x", in); } stencil_op rsx::to_stencil_op(u16 in) @@ -940,7 +991,7 @@ stencil_op rsx::to_stencil_op(u16 in) case CELL_GCM_DECR_WRAP: return stencil_op::decr_wrap; case CELL_GCM_ZERO: return stencil_op::zero; } - fmt::throw_exception("Unknown stencil op 0x%x", in); + return throw_exception_if_emulating("Unknown stencil op 0x%x", in); } blend_equation rsx::to_blend_equation(u16 in) @@ -950,13 +1001,13 @@ blend_equation rsx::to_blend_equation(u16 in) case CELL_GCM_FUNC_ADD: return blend_equation::add; case CELL_GCM_MIN: return blend_equation::min; case CELL_GCM_MAX: return blend_equation::max; - case CELL_GCM_FUNC_SUBTRACT: return blend_equation::substract; - case CELL_GCM_FUNC_REVERSE_SUBTRACT: return blend_equation::reverse_substract; - case CELL_GCM_FUNC_REVERSE_SUBTRACT_SIGNED: return blend_equation::reverse_substract_signed; + case CELL_GCM_FUNC_SUBTRACT: return blend_equation::subtract; + case CELL_GCM_FUNC_REVERSE_SUBTRACT: return blend_equation::reverse_subtract; + case CELL_GCM_FUNC_REVERSE_SUBTRACT_SIGNED: return blend_equation::reverse_subtract_signed; case CELL_GCM_FUNC_ADD_SIGNED: return blend_equation::add_signed; case CELL_GCM_FUNC_REVERSE_ADD_SIGNED: return blend_equation::reverse_add_signed; } - fmt::throw_exception("Unknown blend eq 0x%x", in); + return throw_exception_if_emulating("Unknown blend eq 0x%x", in); } blend_factor rsx::to_blend_factor(u16 in) @@ -979,7 +1030,7 @@ blend_factor rsx::to_blend_factor(u16 in) case CELL_GCM_CONSTANT_ALPHA: return blend_factor::constant_alpha; case CELL_GCM_ONE_MINUS_CONSTANT_ALPHA: return blend_factor::one_minus_constant_alpha; } - fmt::throw_exception("Unknown blend factor 0x%x", in); + return throw_exception_if_emulating("Unknown blend factor 0x%x", in); } enum @@ -1022,7 +1073,7 @@ logic_op rsx::to_logic_op(u16 in) case CELL_GCM_NAND: return logic_op::logic_nand; case CELL_GCM_SET: return logic_op::logic_set; } - fmt::throw_exception("Unknown logic op 0x%x", in); + return throw_exception_if_emulating("Unknown logic op 0x%x", in); } front_face rsx::to_front_face(u16 in) @@ -1033,7 +1084,7 @@ front_face rsx::to_front_face(u16 in) case CELL_GCM_CW: return front_face::cw; case CELL_GCM_CCW: return front_face::ccw; } - fmt::throw_exception("Unknown front face 0x%x", in); + return throw_exception_if_emulating("Unknown front face 0x%x", in); } enum @@ -1052,7 +1103,7 @@ blit_engine::transfer_origin blit_engine::to_transfer_origin(u8 in) case CELL_GCM_TRANSFER_ORIGIN_CENTER: return blit_engine::transfer_origin::center; case CELL_GCM_TRANSFER_ORIGIN_CORNER: return blit_engine::transfer_origin::corner; } - fmt::throw_exception("Unknown transfer origin 0x%x", in); + return throw_exception_if_emulating("Unknown transfer origin 0x%x", in); } blit_engine::transfer_interpolator blit_engine::to_transfer_interpolator(u8 in) @@ -1062,7 +1113,7 @@ blit_engine::transfer_interpolator blit_engine::to_transfer_interpolator(u8 in) case CELL_GCM_TRANSFER_INTERPOLATOR_ZOH: return blit_engine::transfer_interpolator::zoh; case CELL_GCM_TRANSFER_INTERPOLATOR_FOH: return blit_engine::transfer_interpolator::foh; } - fmt::throw_exception("Unknown transfer interpolator 0x%x", in); + return throw_exception_if_emulating("Unknown transfer interpolator 0x%x", in); } enum @@ -1159,7 +1210,7 @@ blit_engine::context_surface blit_engine::to_context_surface(u32 in) case CELL_GCM_CONTEXT_SURFACE2D: return blit_engine::context_surface::surface2d; case CELL_GCM_CONTEXT_SWIZZLE2D: return blit_engine::context_surface::swizzle2d; } - fmt::throw_exception("Unknown context surface 0x%x", in); + return throw_exception_if_emulating("Unknown context surface 0x%x", in); } blit_engine::context_dma blit_engine::to_context_dma(u32 in) @@ -1170,7 +1221,7 @@ blit_engine::context_dma blit_engine::to_context_dma(u32 in) case CELL_GCM_CONTEXT_DMA_REPORT_LOCATION_MAIN: return blit_engine::context_dma::report_location_main; case CELL_GCM_CONTEXT_DMA_MEMORY_HOST_BUFFER: return blit_engine::context_dma::memory_host_buffer; } - fmt::throw_exception("Unknown context dma 0x%x", in); + return throw_exception_if_emulating("Unknown context dma 0x%x", in); } enum @@ -1188,7 +1239,7 @@ user_clip_plane_op rsx::to_user_clip_plane_op(u8 in) case CELL_GCM_USER_CLIP_PLANE_ENABLE_LT: return user_clip_plane_op::less_than; case CELL_GCM_USER_CLIP_PLANE_ENABLE_GE: return user_clip_plane_op::greater_or_equal; } - fmt::throw_exception("Unknown user clip plane 0x%x", in); + return throw_exception_if_emulating("Unknown user clip plane 0x%x", in); } enum @@ -1204,7 +1255,7 @@ shading_mode rsx::to_shading_mode(u32 in) case CELL_GCM_FLAT: return shading_mode::flat; case CELL_GCM_SMOOTH: return shading_mode::smooth; } - fmt::throw_exception("Unknown shading mode 0x%x", in); + return throw_exception_if_emulating("Unknown shading mode 0x%x", in); } enum @@ -1222,5 +1273,5 @@ polygon_mode rsx::to_polygon_mode(u32 in) case CELL_GCM_POLYGON_MODE_LINE: return polygon_mode::line; case CELL_GCM_POLYGON_MODE_FILL: return polygon_mode::fill; } - fmt::throw_exception("Unknown polygon mode 0x%x", in); + return throw_exception_if_emulating("Unknown polygon mode 0x%x", in); } diff --git a/rpcs3/Emu/RSX/gcm_enums.h b/rpcs3/Emu/RSX/gcm_enums.h index 7cc313703d..8c0e5c2b8d 100644 --- a/rpcs3/Emu/RSX/gcm_enums.h +++ b/rpcs3/Emu/RSX/gcm_enums.h @@ -13,6 +13,7 @@ namespace rsx s32k, ///< signed 16bits int cmp, ///< compressed aka X11G11Z10 and always 1. W. ub256, ///< unsigned byte interpreted as between 0 and 255. + invalid, }; vertex_base_type to_vertex_base_type(u8 in); @@ -21,6 +22,7 @@ namespace rsx { u32 = 0, // CELL_GCM_DRAW_INDEX_ARRAY_TYPE_32 u16 = 1, // CELL_GCM_DRAW_INDEX_ARRAY_TYPE_16 + invalid, }; enum class primitive_type : u8 @@ -48,6 +50,7 @@ namespace rsx surfaces_a_b, surfaces_a_b_c, surfaces_a_b_c_d, + invalid, }; surface_target to_surface_target(u8 in); @@ -56,6 +59,7 @@ namespace rsx { z16, // typeless 16 bits depth z24s8, // typeless 24 bits depth + 8 bits stencil + invalid, }; enum class surface_depth_format2 : u8 @@ -64,6 +68,7 @@ namespace rsx z24s8_uint, // unsigned 24 bits depth + 8 bits stencil z16_float, // floating point 16 bits depth z24s8_float, // floating point 24 bits depth + 8 bits stencil + invalid, }; surface_depth_format to_surface_depth_format(u8 in); @@ -94,6 +99,7 @@ namespace rsx diagonal_centered_2_samples, square_centered_4_samples, square_rotated_4_samples, + invalid, }; surface_antialiasing to_surface_antialiasing(u8 in); @@ -114,6 +120,7 @@ namespace rsx x8b8g8r8_z8b8g8r8, x8b8g8r8_o8b8g8r8, a8b8g8r8, + invalid, }; surface_color_format to_surface_color_format(u8 in); @@ -121,7 +128,8 @@ namespace rsx enum class window_origin : u8 { top, - bottom + bottom, + invalid, }; window_origin to_window_origin(u8 in); @@ -129,7 +137,8 @@ namespace rsx enum class window_pixel_center : u8 { half, - integer + integer, + invalid, }; window_pixel_center to_window_pixel_center(u8 in); @@ -143,7 +152,8 @@ namespace rsx greater, not_equal, greater_or_equal, - always + always, + invalid, }; comparison_function to_comparison_function(u16 in); @@ -155,7 +165,8 @@ namespace rsx exponential2, exponential_abs, exponential2_abs, - linear_abs + linear_abs, + invalid, }; fog_mode to_fog_mode(u32 in); @@ -169,6 +180,7 @@ namespace rsx texture_dimension_2d = 1, texture_dimension_cubemap = 2, texture_dimension_3d = 3, + invalid, }; enum class texture_dimension : u8 @@ -176,6 +188,7 @@ namespace rsx dimension1d, dimension2d, dimension3d, + invalid, }; texture_dimension to_texture_dimension(u8 in); @@ -190,6 +203,7 @@ namespace rsx mirror_once_clamp_to_edge, mirror_once_border, mirror_once_clamp, + invalid, }; texture_wrap_mode to_texture_wrap_mode(u8 in); @@ -204,6 +218,7 @@ namespace rsx x10, x12, x16, + invalid, }; texture_max_anisotropy to_texture_max_anisotropy(u8 in); @@ -217,6 +232,7 @@ namespace rsx nearest_linear, ///< no filtering, linear mix between closest mipmap levels linear_linear, ///< linear filtering, linear mix between closest mipmap levels convolution_min, ///< Unknown mode but looks close to linear_linear + invalid, }; texture_minify_filter to_texture_minify_filter(u8 in); @@ -226,6 +242,7 @@ namespace rsx nearest, ///< no filtering linear, ///< linear filtering convolution_mag, ///< Unknown mode but looks close to linear + invalid, }; texture_magnify_filter to_texture_magnify_filter(u8 in); @@ -240,6 +257,7 @@ namespace rsx invert, incr_wrap, decr_wrap, + invalid, }; stencil_op to_stencil_op(u16 in); @@ -249,11 +267,12 @@ namespace rsx add, min, max, - substract, - reverse_substract, - reverse_substract_signed, + subtract, + reverse_subtract, + reverse_subtract_signed, add_signed, reverse_add_signed, + invalid, }; blend_equation to_blend_equation(u16 in); @@ -275,6 +294,7 @@ namespace rsx one_minus_constant_color, constant_alpha, one_minus_constant_alpha, + invalid, }; blend_factor to_blend_factor(u16 in); @@ -297,6 +317,7 @@ namespace rsx logic_or_inverted, logic_nand, logic_set, + invalid, }; logic_op to_logic_op(u16 in); @@ -304,7 +325,8 @@ namespace rsx enum class front_face : u8 { cw, /// clockwise - ccw /// counter clockwise + ccw, /// counter clockwise + invalid, }; front_face to_front_face(u16 in); @@ -314,6 +336,7 @@ namespace rsx front = 0x0404, // CELL_GCM_FRONT back = 0x0405, // CELL_GCM_BACK front_and_back = 0x0408, // CELL_GCM_FRONT_AND_BACK + invalid, }; enum class user_clip_plane_op : u8 @@ -321,6 +344,7 @@ namespace rsx disable, less_than, greater_or_equal, + invalid, }; user_clip_plane_op to_user_clip_plane_op(u8 in); @@ -329,6 +353,7 @@ namespace rsx { smooth, flat, + invalid, }; shading_mode to_shading_mode(u32 in); @@ -338,6 +363,7 @@ namespace rsx point, line, fill, + invalid, }; polygon_mode to_polygon_mode(u32 in); @@ -348,6 +374,7 @@ namespace rsx { center, corner, + invalid, }; transfer_origin to_transfer_origin(u8 in); @@ -356,6 +383,7 @@ namespace rsx { zoh, foh, + invalid, }; transfer_interpolator to_transfer_interpolator(u8 in); @@ -398,7 +426,7 @@ namespace rsx r5g6b5, a8r8g8b8, y32, - invalid + invalid, }; transfer_destination_format to_transfer_destination_format(u8 in); @@ -407,6 +435,7 @@ namespace rsx { surface2d, swizzle2d, + invalid, }; context_surface to_context_surface(u32 in); @@ -416,6 +445,7 @@ namespace rsx to_memory_get_report, report_location_main, memory_host_buffer, + invalid, }; context_dma to_context_dma(u32 in); diff --git a/rpcs3/Loader/PUP.cpp b/rpcs3/Loader/PUP.cpp index 38bfc827d5..398014cb88 100644 --- a/rpcs3/Loader/PUP.cpp +++ b/rpcs3/Loader/PUP.cpp @@ -32,7 +32,7 @@ pup_object::pup_object(fs::file&& file) : m_file(std::move(file)) return; } - // Check if file size is the expected size, use substraction to avoid overflows + // Check if file size is the expected size, use subtraction to avoid overflows if (file_size < m_header.header_length || file_size - m_header.header_length < m_header.data_length) { m_formatted_error = fmt::format("Firmware size mismatch, expected: 0x%x + 0x%x, actual: 0x%x", m_header.header_length, m_header.data_length, file_size); @@ -89,7 +89,7 @@ pup_error pup_object::validate_hashes() for (const PUPFileEntry& file : m_file_tbl) { - // Sanity check for offset and length, use substraction to avoid overflows + // Sanity check for offset and length, use subtraction to avoid overflows if (size < file.data_offset || size - file.data_offset < file.data_length) { m_formatted_error = fmt::format("File database entry is invalid. (offset=0x%x, length=0x%x, PUP.size=0x%x)", file.data_offset, file.data_length, size);