diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index b4cadf09a4..e2d2d70645 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -5,6 +5,7 @@ #include "Emu/Cell/RawSPUThread.h" #include "Emu/Cell/lv2/sys_mmapper.h" #include "Emu/Cell/lv2/sys_event.h" +#include "Emu/RSX/RSXThread.h" #include "Thread.h" #include "Utilities/JIT.h" #include @@ -104,6 +105,32 @@ void fmt_class_string::format(std::string& out, u64 arg) out += ss.str(); } +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()) + { + result = cpu->dump_all(); + } + else if (auto render = rsx::get_current_renderer(); render && render->is_current_thread()) + { + result = render->dump_regs(); + } + + guard = false; + return result; +} + #ifndef _WIN32 bool IsDebuggerPresent() { @@ -1531,7 +1558,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no { if (!g_tls_access_violation_recovered) { - vm_log.notice("\n%s", cpu->dump_all()); + vm_log.notice("\n%s", dump_useful_thread_info()); vm_log.error("Access violation %s location 0x%x (%s) [type=u%u]", is_writing ? "writing" : "reading", addr, (is_writing && vm::check_addr(addr)) ? "read-only memory" : "unmapped memory", d_size * 8); } @@ -1560,9 +1587,9 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no Emu.Pause(); - if (cpu && !g_tls_access_violation_recovered) + if (!g_tls_access_violation_recovered) { - vm_log.notice("\n%s", cpu->dump_all()); + vm_log.notice("\n%s", dump_useful_thread_info()); } // Note: a thread may access violate more than once after hack_alloc recovery @@ -1647,10 +1674,7 @@ static LONG exception_filter(PEXCEPTION_POINTERS pExp) noexcept { fmt::append(msg, "Emu Thread Name: '%s'.\n", thread_ctrl::get_name()); - if (const auto cpu = get_current_cpu_thread()) - { - sys_log.notice("\n%s", cpu->dump_all()); - } + sys_log.notice("\n%s", dump_useful_thread_info()); } // TODO: Report full thread name if not an emu thread @@ -1775,16 +1799,12 @@ static void signal_handler(int sig, siginfo_t* info, void* uct) noexcept } } - if (const auto cpu = get_current_cpu_thread()) - { - sys_log.notice("\n%s", cpu->dump_all()); - } - std::string msg = fmt::format("Segfault %s location %p at %p.\n", cause, info->si_addr, RIP(context)); if (thread_ctrl::get_current()) { fmt::append(msg, "Emu Thread Name: '%s'.\n", thread_ctrl::get_name()); + sys_log.notice("\n%s", dump_useful_thread_info()); } // TODO: Report full thread name if not an emu thread @@ -2391,6 +2411,11 @@ u64 thread_base::get_cycles() [[noreturn]] void thread_ctrl::emergency_exit(std::string_view reason) { + if (std::string info = dump_useful_thread_info(); !info.empty()) + { + sys_log.notice("\%s", info); + } + sig_log.fatal("Thread terminated due to fatal error: %s", reason); std::fprintf(stderr, "Thread '%s' terminated due to fatal error: %s\n", g_tls_log_prefix().c_str(), std::string(reason).c_str()); diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index 8aecfbbc38..504b0e57f4 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -531,7 +531,7 @@ void cpu_thread::operator()() { if (_this) { - sys_log.warning("CPU Thread '%s' terminated abnormally:\n%s", name, _this->dump_all()); + sys_log.warning("CPU Thread '%s' terminated abnormally!", name); cleanup(); } } diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index ded5d474b1..595b8aec68 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -10,6 +10,7 @@ #include "Capture/rsx_capture.h" #include "rsx_methods.h" #include "rsx_utils.h" +#include "gcm_printing.h" #include "Emu/Cell/lv2/sys_event.h" #include "Emu/Cell/Modules/cellGcmSys.h" #include "Overlays/overlay_perf_metrics.h" @@ -469,7 +470,7 @@ namespace rsx if (capture_current_frame) { u32 element_count = rsx::method_registers.current_draw_clause.get_elements_count(); - capture_frame("Draw " + rsx::to_string(rsx::method_registers.current_draw_clause.primitive) + std::to_string(element_count)); + capture_frame(fmt::format("Draw %s %d", rsx::method_registers.current_draw_clause.primitive, element_count)); } } @@ -524,8 +525,6 @@ namespace rsx g_fxo->get()->init(); on_init_thread(); - method_registers.init(); - if (!zcull_ctrl) { //Backend did not provide an implementation, provide NULL object @@ -2018,11 +2017,13 @@ namespace rsx void thread::init(u32 ctrlAddress) { + method_registers.init(); + dma_address = ctrlAddress; ctrl = vm::_ptr(ctrlAddress); flip_status = CELL_GCM_DISPLAY_FLIP_STATUS_DONE; - memset(display_buffers, 0, sizeof(display_buffers)); + std::memset(display_buffers, 0, sizeof(display_buffers)); on_init_rsx(); m_rsx_thread_exiting = false; @@ -2565,6 +2566,18 @@ namespace rsx recovered_fifo_cmds_history.push({fifo_ctrl->last_cmd(), current_time}); } + std::vector> thread::dump_callstack() const + { + std::vector> result; + + if (u32 addr = fifo_ret_addr; addr != RSX_CALL_STACK_EMPTY) + { + result.emplace_back(addr, 0); + } + + return result; + } + void thread::fifo_wake_delay(u64 div) { // TODO: Nanoseconds accuracy @@ -2626,6 +2639,48 @@ namespace rsx return fifo_ctrl->last_cmd(); } + void invalid_method(thread*, u32, u32); + + std::string thread::dump_regs() const + { + std::string result; + + for (u32 i = 0; i < 1 << 14; i++) + { + if (rsx::methods[i] == &invalid_method) + { + continue; + } + + switch (i) + { + case NV4097_NO_OPERATION: + case NV4097_INVALIDATE_L2: + case NV4097_INVALIDATE_VERTEX_FILE: + case NV4097_INVALIDATE_VERTEX_CACHE_FILE: + case NV4097_INVALIDATE_ZCULL: + case NV4097_WAIT_FOR_IDLE: + case NV4097_PM_TRIGGER: + case NV4097_ZCULL_SYNC: + continue; + + default: + { + if (i >= NV308A_COLOR && i < NV3089_SET_OBJECT) + { + continue; + } + + break; + } + } + + fmt::append(result, "[%04x] %s\n", i, ensure(rsx::get_pretty_printing_function(i))(i, method_registers.registers[i])); + } + + return result; + } + flags32_t thread::read_barrier(u32 memory_address, u32 memory_range, bool unconditional) { flags32_t zcull_flags = (unconditional)? reports::sync_none : reports::sync_defer_copy; diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index dec6dba0ba..6ee26d31e7 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -615,6 +615,8 @@ namespace rsx // FIFO public: std::unique_ptr fifo_ctrl; + std::vector> dump_callstack() const; + protected: FIFO::flattening_helper m_flattener; u32 fifo_ret_addr = RSX_CALL_STACK_EMPTY; @@ -652,6 +654,8 @@ namespace rsx void recover_fifo(); static void fifo_wake_delay(u64 div = 1); u32 get_fifo_cmd() const; + + std::string dump_regs() const; // Performance approximation counters struct diff --git a/rpcs3/Emu/RSX/gcm_enums.cpp b/rpcs3/Emu/RSX/gcm_enums.cpp index 9d13198f95..a66243b9e8 100644 --- a/rpcs3/Emu/RSX/gcm_enums.cpp +++ b/rpcs3/Emu/RSX/gcm_enums.cpp @@ -1,37 +1,39 @@ #include "gcm_enums.h" #include "Utilities/StrFmt.h" -rsx::vertex_base_type rsx::to_vertex_base_type(u8 in) +using namespace rsx; + +vertex_base_type rsx::to_vertex_base_type(u8 in) { switch (in) { - case 0: return rsx::vertex_base_type::ub256; - case 1: return rsx::vertex_base_type::s1; - case 2: return rsx::vertex_base_type::f; - case 3: return rsx::vertex_base_type::sf; - case 4: return rsx::vertex_base_type::ub; - case 5: return rsx::vertex_base_type::s32k; - case 6: return rsx::vertex_base_type::cmp; - case 7: return rsx::vertex_base_type::ub256; + case 0: return vertex_base_type::ub256; + case 1: return vertex_base_type::s1; + case 2: return vertex_base_type::f; + case 3: return vertex_base_type::sf; + case 4: return vertex_base_type::ub; + case 5: return vertex_base_type::s32k; + case 6: return vertex_base_type::cmp; + case 7: return vertex_base_type::ub256; } fmt::throw_exception("Unknown vertex base type %d", in); } -rsx::primitive_type rsx::to_primitive_type(u8 in) +primitive_type rsx::to_primitive_type(u8 in) { switch (in) { - case CELL_GCM_PRIMITIVE_POINTS: return rsx::primitive_type::points; - case CELL_GCM_PRIMITIVE_LINES: return rsx::primitive_type::lines; - case CELL_GCM_PRIMITIVE_LINE_LOOP: return rsx::primitive_type::line_loop; - case CELL_GCM_PRIMITIVE_LINE_STRIP: return rsx::primitive_type::line_strip; - case CELL_GCM_PRIMITIVE_TRIANGLES: return rsx::primitive_type::triangles; - case CELL_GCM_PRIMITIVE_TRIANGLE_STRIP: return rsx::primitive_type::triangle_strip; - case CELL_GCM_PRIMITIVE_TRIANGLE_FAN: return rsx::primitive_type::triangle_fan; - case CELL_GCM_PRIMITIVE_QUADS: return rsx::primitive_type::quads; - case CELL_GCM_PRIMITIVE_QUAD_STRIP: return rsx::primitive_type::quad_strip; - case CELL_GCM_PRIMITIVE_POLYGON: return rsx::primitive_type::polygon; - default: return rsx::primitive_type::invalid; + case CELL_GCM_PRIMITIVE_POINTS: return primitive_type::points; + case CELL_GCM_PRIMITIVE_LINES: return primitive_type::lines; + case CELL_GCM_PRIMITIVE_LINE_LOOP: return primitive_type::line_loop; + case CELL_GCM_PRIMITIVE_LINE_STRIP: return primitive_type::line_strip; + case CELL_GCM_PRIMITIVE_TRIANGLES: return primitive_type::triangles; + case CELL_GCM_PRIMITIVE_TRIANGLE_STRIP: return primitive_type::triangle_strip; + case CELL_GCM_PRIMITIVE_TRIANGLE_FAN: return primitive_type::triangle_fan; + case CELL_GCM_PRIMITIVE_QUADS: return primitive_type::quads; + case CELL_GCM_PRIMITIVE_QUAD_STRIP: return primitive_type::quad_strip; + case CELL_GCM_PRIMITIVE_POLYGON: return primitive_type::polygon; + default: return primitive_type::invalid; } } @@ -43,100 +45,167 @@ enum CELL_GCM_WINDOW_PIXEL_CENTER_INTEGER = 1, }; -rsx::window_origin rsx::to_window_origin(u8 in) +window_origin rsx::to_window_origin(u8 in) { switch (in) { - case CELL_GCM_WINDOW_ORIGIN_TOP: return rsx::window_origin::top; - case CELL_GCM_WINDOW_ORIGIN_BOTTOM: return rsx::window_origin::bottom; + 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); } -rsx::window_pixel_center rsx::to_window_pixel_center(u8 in) +window_pixel_center rsx::to_window_pixel_center(u8 in) { switch (in) { - case CELL_GCM_WINDOW_PIXEL_CENTER_HALF: return rsx::window_pixel_center::half; - case CELL_GCM_WINDOW_PIXEL_CENTER_INTEGER: return rsx::window_pixel_center::integer; + 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); } -rsx::comparison_function rsx::to_comparison_function(u16 in) +comparison_function rsx::to_comparison_function(u16 in) { switch (in) { case CELL_GCM_TEXTURE_ZFUNC_NEVER & CELL_GCM_SCULL_SFUNC_NEVER: case CELL_GCM_NEVER: - return rsx::comparison_function::never; + return comparison_function::never; case CELL_GCM_TEXTURE_ZFUNC_LESS & CELL_GCM_SCULL_SFUNC_LESS: case CELL_GCM_LESS: - return rsx::comparison_function::less; + return comparison_function::less; case CELL_GCM_TEXTURE_ZFUNC_EQUAL & CELL_GCM_SCULL_SFUNC_EQUAL: case CELL_GCM_EQUAL: - return rsx::comparison_function::equal; + return comparison_function::equal; case CELL_GCM_TEXTURE_ZFUNC_LEQUAL & CELL_GCM_SCULL_SFUNC_LEQUAL: case CELL_GCM_LEQUAL: - return rsx::comparison_function::less_or_equal; + return comparison_function::less_or_equal; case CELL_GCM_TEXTURE_ZFUNC_GREATER & CELL_GCM_SCULL_SFUNC_GREATER: case CELL_GCM_GREATER: - return rsx::comparison_function::greater; + return comparison_function::greater; case CELL_GCM_TEXTURE_ZFUNC_NOTEQUAL & CELL_GCM_SCULL_SFUNC_NOTEQUAL: case CELL_GCM_NOTEQUAL: - return rsx::comparison_function::not_equal; + return comparison_function::not_equal; case CELL_GCM_TEXTURE_ZFUNC_GEQUAL & CELL_GCM_SCULL_SFUNC_GEQUAL: case CELL_GCM_GEQUAL: - return rsx::comparison_function::greater_or_equal; + return comparison_function::greater_or_equal; case CELL_GCM_TEXTURE_ZFUNC_ALWAYS & CELL_GCM_SCULL_SFUNC_ALWAYS: case CELL_GCM_ALWAYS: - return rsx::comparison_function::always; + return comparison_function::always; } fmt::throw_exception("Unknown comparison function 0x%x", in); } -rsx::fog_mode rsx::to_fog_mode(u32 in) +fog_mode rsx::to_fog_mode(u32 in) { switch (in) { - case CELL_GCM_FOG_MODE_LINEAR: return rsx::fog_mode::linear; - case CELL_GCM_FOG_MODE_EXP: return rsx::fog_mode::exponential; - case CELL_GCM_FOG_MODE_EXP2: return rsx::fog_mode::exponential2; - case CELL_GCM_FOG_MODE_EXP_ABS: return rsx::fog_mode::exponential_abs; - case CELL_GCM_FOG_MODE_EXP2_ABS: return rsx::fog_mode::exponential2_abs; - case CELL_GCM_FOG_MODE_LINEAR_ABS: return rsx::fog_mode::linear_abs; + case CELL_GCM_FOG_MODE_LINEAR: return fog_mode::linear; + case CELL_GCM_FOG_MODE_EXP: return fog_mode::exponential; + case CELL_GCM_FOG_MODE_EXP2: return fog_mode::exponential2; + case CELL_GCM_FOG_MODE_EXP_ABS: return fog_mode::exponential_abs; + 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); } -rsx::texture_dimension rsx::to_texture_dimension(u8 in) +texture_dimension rsx::to_texture_dimension(u8 in) { switch (in) { - case 1: return rsx::texture_dimension::dimension1d; - case 2: return rsx::texture_dimension::dimension2d; - case 3: return rsx::texture_dimension::dimension3d; + case 1: return texture_dimension::dimension1d; + case 2: return texture_dimension::dimension2d; + case 3: return texture_dimension::dimension3d; } fmt::throw_exception("Unknown texture dimension %d", in); } -namespace rsx +template <> +void fmt_class_string::format(std::string& out, u64 arg) { - std::string print_boolean(bool b) + format_enum(out, arg, [](CellGcmLocation value) { - return b ? "enabled" : "disabled"; + switch (value) + { + case CELL_GCM_LOCATION_LOCAL: return "Local"; + case CELL_GCM_LOCATION_MAIN: return "Main"; + + case CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER: return "Local-Buffer"; // Local memory for DMA operations + case CELL_GCM_CONTEXT_DMA_MEMORY_HOST_BUFFER: return "Main-Buffer"; // Main memory for DMA operations + case CELL_GCM_CONTEXT_DMA_REPORT_LOCATION_LOCAL: return "Report Local"; + case CELL_GCM_CONTEXT_DMA_REPORT_LOCATION_MAIN: return "Report Main"; + case CELL_GCM_CONTEXT_DMA_NOTIFY_MAIN_0: return "Notify"; // TODO + + //case CELL_GCM_CONTEXT_DMA_TO_MEMORY_GET_NOTIFY0: + case CELL_GCM_CONTEXT_DMA_SEMAPHORE_RW: return "SEMA-RW"; + case CELL_GCM_CONTEXT_DMA_SEMAPHORE_R: return "SEMA-R"; + case CELL_GCM_CONTEXT_DMA_DEVICE_RW: return "DEVICE-RW"; + case CELL_GCM_CONTEXT_DMA_DEVICE_R: return "DEVICE-R"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + switch (static_cast(arg) & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN)) + { + case CELL_GCM_TEXTURE_COMPRESSED_HILO8: out += "COMPRESSED_HILO8"; break; + case CELL_GCM_TEXTURE_COMPRESSED_HILO_S8: out += "COMPRESSED_HILO_S8"; break; + case CELL_GCM_TEXTURE_B8: out += "B8"; break; + case CELL_GCM_TEXTURE_A1R5G5B5: out += "A1R5G5B5"; break; + case CELL_GCM_TEXTURE_A4R4G4B4: out += "A4R4G4B4"; break; + case CELL_GCM_TEXTURE_R5G6B5: out += "R5G6B5"; break; + case CELL_GCM_TEXTURE_A8R8G8B8: out += "A8R8G8B8"; break; + case CELL_GCM_TEXTURE_COMPRESSED_DXT1: out += "COMPRESSED_DXT1"; break; + case CELL_GCM_TEXTURE_COMPRESSED_DXT23: out += "COMPRESSED_DXT23"; break; + case CELL_GCM_TEXTURE_COMPRESSED_DXT45: out += "COMPRESSED_DXT45"; break; + case CELL_GCM_TEXTURE_G8B8: out += "G8B8"; break; + case CELL_GCM_TEXTURE_R6G5B5: out += "R6G5B5"; break; + case CELL_GCM_TEXTURE_DEPTH24_D8: out += "DEPTH24_D8"; break; + case CELL_GCM_TEXTURE_DEPTH24_D8_FLOAT: out += "DEPTH24_D8_FLOAT"; break; + case CELL_GCM_TEXTURE_DEPTH16: out += "DEPTH16"; break; + case CELL_GCM_TEXTURE_DEPTH16_FLOAT: out += "DEPTH16_FLOAT"; break; + case CELL_GCM_TEXTURE_X16: out += "X16"; break; + case CELL_GCM_TEXTURE_Y16_X16: out += "Y16_X16"; break; + case CELL_GCM_TEXTURE_R5G5B5A1: out += "R5G5B5A1"; break; + case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT: out += "W16_Z16_Y16_X16_FLOAT"; break; + case CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT: out += "W32_Z32_Y32_X32_FLOAT"; break; + case CELL_GCM_TEXTURE_X32_FLOAT: out += "X32_FLOAT"; break; + case CELL_GCM_TEXTURE_D1R5G5B5: out += "D1R5G5B5"; break; + case CELL_GCM_TEXTURE_D8R8G8B8: out += "D8R8G8B8"; break; + case CELL_GCM_TEXTURE_Y16_X16_FLOAT: out += "Y16_X16_FLOAT"; break; + case CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8: out += "COMPRESSED_B8R8_G8R8"; break; + case CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8: out += "COMPRESSED_R8B8_R8G8"; break; + default: fmt::append(out, "%s", arg); return; } - std::string to_string(comparison_function f) + switch (arg & (CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN)) { - switch (f) + case CELL_GCM_TEXTURE_LN: out += "-LN"; break; + case CELL_GCM_TEXTURE_UN: out += "-UN"; break; + case CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN: out += "-LN-UN"; break; + default: break; + } +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](comparison_function value) + { + switch (value) { case comparison_function::never: return "Never"; case comparison_function::less: return "Less"; @@ -147,12 +216,17 @@ namespace rsx case comparison_function::greater_or_equal: return "Greater_equal"; case comparison_function::always: return "Always"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(stencil_op op) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](stencil_op value) { - switch (op) + switch (value) { case stencil_op::keep: return "Keep"; case stencil_op::zero: return "Zero"; @@ -163,12 +237,17 @@ namespace rsx case stencil_op::decr_wrap: return "Decr_wrap"; case stencil_op::invert: return "Invert"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(fog_mode op) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](fog_mode value) { - switch (op) + switch (value) { case fog_mode::exponential: return "exponential"; case fog_mode::exponential2: return "exponential2"; @@ -177,12 +256,17 @@ namespace rsx case fog_mode::linear: return "linear"; case fog_mode::linear_abs: return "linear(abs)"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(logic_op op) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](logic_op value) { - switch (op) + switch (value) { case logic_op::logic_clear: return "Clear"; case logic_op::logic_and: return "And"; @@ -201,33 +285,48 @@ namespace rsx case logic_op::logic_or_inverted: return "Or_inverted"; case logic_op::logic_nand: return "Nand"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(front_face op) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](front_face value) { - switch (op) + switch (value) { case front_face::ccw: return "counter clock wise"; case front_face::cw: return "clock wise"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(cull_face op) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](cull_face value) { - switch (op) + switch (value) { case cull_face::back: return "back"; case cull_face::front: return "front"; case cull_face::front_and_back: return "front and back"; } - return "Unknown cull face value"; - } - std::string to_string(surface_target target) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](surface_target value) { - switch (target) + switch (value) { case surface_target::none: return "none"; case surface_target::surface_a: return "surface A"; @@ -236,12 +335,17 @@ namespace rsx 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"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(primitive_type draw_mode) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](primitive_type value) { - switch (draw_mode) + switch (value) { case primitive_type::invalid: return ""; case primitive_type::points: return "Points"; @@ -255,12 +359,17 @@ namespace rsx case primitive_type::quad_strip: return "Quad_strip"; case primitive_type::polygon: return "Polygon"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(blit_engine::transfer_operation op) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](blit_engine::transfer_operation value) { - switch (op) + switch (value) { case blit_engine::transfer_operation::blend_and: return "blend and"; case blit_engine::transfer_operation::blend_premult: return "blend premult"; @@ -269,12 +378,17 @@ namespace rsx case blit_engine::transfer_operation::srccopy_and: return "srccopy_and"; case blit_engine::transfer_operation::srccopy_premult: return "srccopy_premult"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(blit_engine::transfer_source_format op) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](blit_engine::transfer_source_format value) { - switch (op) + switch (value) { case blit_engine::transfer_source_format::a1r5g5b5: return "a1r5g5b5"; case blit_engine::transfer_source_format::a8b8g8r8: return "a8b8g8r8"; @@ -290,34 +404,123 @@ namespace rsx case blit_engine::transfer_source_format::y8: return "y8"; case blit_engine::transfer_source_format::yb8cr8ya8cb8: return "yb8cr8ya8cb8"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(blit_engine::context_surface op) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](blit_engine::context_surface value) { - switch (op) + switch (value) { case blit_engine::context_surface::surface2d: return "surface 2d"; case blit_engine::context_surface::swizzle2d: return "swizzle 2d"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(blit_engine::transfer_destination_format op) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](blit_engine::transfer_destination_format value) { - switch (op) + switch (value) { 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"; } - fmt::throw_exception("Unexpected enum found"); - } + return unknown; + }); +} - std::string to_string(blend_equation op) +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](index_array_type value) { - switch (op) + switch (value) + { + case index_array_type::u16: return "u16"; + case index_array_type::u32: return "u32"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](polygon_mode value) + { + switch (value) + { + case polygon_mode::fill: return "fill"; + case polygon_mode::line: return "line"; + case polygon_mode::point: return "point"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](surface_color_format value) + { + switch (value) + { + case surface_color_format::x1r5g5b5_z1r5g5b5: return "X1R5G5B5_Z1R5G5B5"; + case surface_color_format::x1r5g5b5_o1r5g5b5: return "X1R5G5B5_O1R5G5B5"; + case surface_color_format::r5g6b5: return "R5G6B5"; + case surface_color_format::x8r8g8b8_z8r8g8b8: return "X8R8G8B8_Z8R8G8B8"; + case surface_color_format::x8r8g8b8_o8r8g8b8: return "X8R8G8B8_O8R8G8B8"; + case surface_color_format::a8r8g8b8: return "A8R8G8B8"; + case surface_color_format::b8: return "B8"; + case surface_color_format::g8b8: return "G8B8"; + case surface_color_format::w16z16y16x16: return "F_W16Z16Y16X16"; + case surface_color_format::w32z32y32x32: return "F_W32Z32Y32X32"; + case surface_color_format::x32: return "F_X32"; + 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"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](surface_antialiasing value) + { + switch (value) + { + case surface_antialiasing::center_1_sample: return "1 sample centered"; + 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"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](blend_equation value) + { + switch (value) { case blend_equation::add: return "Add"; case blend_equation::substract: return "Substract"; @@ -328,12 +531,17 @@ namespace rsx case blend_equation::reverse_add_signed: return "Reverse_add_signed"; case blend_equation::reverse_substract_signed: return "Reverse_substract_signed"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(blend_factor factor) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](blend_factor value) { - switch (factor) + switch (value) { case blend_factor::zero: return "0"; case blend_factor::one: return "1"; @@ -351,148 +559,178 @@ namespace rsx case blend_factor::constant_alpha: return "const.a"; case blend_factor::one_minus_constant_alpha: return "(1 - const.a)"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(window_origin origin) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](window_origin value) { - switch (origin) + switch (value) { case window_origin::bottom: return "bottom"; case window_origin::top: return "top"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(window_pixel_center in) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](window_pixel_center value) { - switch (in) + switch (value) { case window_pixel_center::half: return "half"; case window_pixel_center::integer: return "integer"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(user_clip_plane_op op) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](user_clip_plane_op value) { - switch (op) + switch (value) { 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"; } - fmt::throw_exception("Unexpected enum found"); - } + return unknown; + }); +} - - std::string to_string(surface_depth_format format) +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](blit_engine::context_dma value) { - switch (format) - { - case surface_depth_format::z16: return "CELL_GCM_SURFACE_Z16"; - case surface_depth_format::z24s8: return "CELL_GCM_SURFACE_Z24S8"; - } - fmt::throw_exception("Unexpected enum found"); - } - - std::string to_string(surface_antialiasing format) - { - switch (format) - { - case surface_antialiasing::center_1_sample: return "1 sample centered"; - 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"; - } - fmt::throw_exception("Unexpected enum found"); - } - - std::string to_string(surface_color_format format) - { - switch (format) - { - case surface_color_format::x1r5g5b5_z1r5g5b5: return "CELL_GCM_SURFACE_X1R5G5B5_Z1R5G5B5"; - case surface_color_format::x1r5g5b5_o1r5g5b5: return "CELL_GCM_SURFACE_X1R5G5B5_O1R5G5B5"; - case surface_color_format::r5g6b5: return "CELL_GCM_SURFACE_R5G6B5"; - case surface_color_format::x8r8g8b8_z8r8g8b8: return "CELL_GCM_SURFACE_X8R8G8B8_Z8R8G8B8"; - case surface_color_format::x8r8g8b8_o8r8g8b8: return "CELL_GCM_SURFACE_X8R8G8B8_O8R8G8B8"; - case surface_color_format::a8r8g8b8: return "CELL_GCM_SURFACE_A8R8G8B8"; - case surface_color_format::b8: return "CELL_GCM_SURFACE_B8"; - case surface_color_format::g8b8: return "CELL_GCM_SURFACE_G8B8"; - case surface_color_format::w16z16y16x16: return "CELL_GCM_SURFACE_F_W16Z16Y16X16"; - case surface_color_format::w32z32y32x32: return "CELL_GCM_SURFACE_F_W32Z32Y32X32"; - case surface_color_format::x32: return "CELL_GCM_SURFACE_F_X32"; - case surface_color_format::x8b8g8r8_z8b8g8r8: return "CELL_GCM_SURFACE_X8B8G8R8_Z8B8G8R8"; - case surface_color_format::x8b8g8r8_o8b8g8r8: return "CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8"; - case surface_color_format::a8b8g8r8: return "CELL_GCM_SURFACE_A8B8G8R8"; - } - fmt::throw_exception("Unexpected enum found"); - } - - std::string to_string(index_array_type arg) - { - switch (arg) - { - case index_array_type::u16: return "unsigned short"; - case index_array_type::u32: return "unsigned int"; - } - fmt::throw_exception("Unexpected enum found"); - } - - std::string to_string(blit_engine::context_dma op) - { - switch (op) + switch (value) { 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"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(blit_engine::transfer_origin op) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](blit_engine::transfer_origin value) { - switch (op) + switch (value) { case blit_engine::transfer_origin::center: return "center"; case blit_engine::transfer_origin::corner: return "corner"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(blit_engine::transfer_interpolator op) - { - switch (op) - { - case blit_engine::transfer_interpolator::foh: return "foh"; - case blit_engine::transfer_interpolator::zoh: return "zoh"; - } - fmt::throw_exception("Unexpected enum found"); - } + return unknown; + }); +} - std::string to_string(shading_mode op) +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](shading_mode value) { - switch (op) + switch (value) { case shading_mode::flat: return "flat"; case shading_mode::smooth: return "smooth"; } - fmt::throw_exception("Unexpected enum found"); - } - std::string to_string(polygon_mode op) + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](surface_depth_format value) { - switch (op) + switch (value) { - case polygon_mode::fill: return "fill"; - case polygon_mode::line: return "line"; - case polygon_mode::point: return "point"; + case surface_depth_format::z16: return "Z16"; + case surface_depth_format::z24s8: return "Z24S8"; } - fmt::throw_exception("Unexpected enum found"); - } + return unknown; + }); +} + + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](blit_engine::transfer_interpolator value) + { + switch (value) + { + case blit_engine::transfer_interpolator::foh: return "foh"; + case blit_engine::transfer_interpolator::zoh: return "zoh"; + } + + return unknown; + }); +} + + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](texture_dimension value) + { + switch (value) + { + case texture_dimension::dimension1d: return "1D"; + case texture_dimension::dimension2d: return "2D"; + case texture_dimension::dimension3d: return "3D"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](texture_max_anisotropy value) + { + switch (value) + { + case texture_max_anisotropy::x1: return "1"; + case texture_max_anisotropy::x2: return "2"; + case texture_max_anisotropy::x4: return "4"; + case texture_max_anisotropy::x6: return "6"; + case texture_max_anisotropy::x8: return "8"; + case texture_max_anisotropy::x10: return "10"; + case texture_max_anisotropy::x12: return "12"; + case texture_max_anisotropy::x16: return "16"; + } + + return unknown; + }); +} + +namespace rsx +{ + std::string print_boolean(bool b) + { + return b ? "enabled" : "disabled"; + } } // end namespace rsx enum @@ -562,174 +800,174 @@ enum CELL_GCM_TEXTURE_CONVOLUTION_MAG = 4, }; -rsx::texture_wrap_mode rsx::to_texture_wrap_mode(u8 in) +texture_wrap_mode rsx::to_texture_wrap_mode(u8 in) { switch (in) { - case CELL_GCM_TEXTURE_WRAP: return rsx::texture_wrap_mode::wrap; - case CELL_GCM_TEXTURE_MIRROR: return rsx::texture_wrap_mode::mirror; - case CELL_GCM_TEXTURE_CLAMP_TO_EDGE: return rsx::texture_wrap_mode::clamp_to_edge; - case CELL_GCM_TEXTURE_BORDER: return rsx::texture_wrap_mode::border; - case CELL_GCM_TEXTURE_CLAMP: return rsx::texture_wrap_mode::clamp; - case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP_TO_EDGE: return rsx::texture_wrap_mode::mirror_once_clamp_to_edge; - case CELL_GCM_TEXTURE_MIRROR_ONCE_BORDER: return rsx::texture_wrap_mode::mirror_once_border; - case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP: return rsx::texture_wrap_mode::mirror_once_clamp; + case CELL_GCM_TEXTURE_WRAP: return texture_wrap_mode::wrap; + case CELL_GCM_TEXTURE_MIRROR: return texture_wrap_mode::mirror; + case CELL_GCM_TEXTURE_CLAMP_TO_EDGE: return texture_wrap_mode::clamp_to_edge; + case CELL_GCM_TEXTURE_BORDER: return texture_wrap_mode::border; + case CELL_GCM_TEXTURE_CLAMP: return texture_wrap_mode::clamp; + case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP_TO_EDGE: return texture_wrap_mode::mirror_once_clamp_to_edge; + 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); } -rsx::texture_max_anisotropy rsx::to_texture_max_anisotropy(u8 in) +texture_max_anisotropy rsx::to_texture_max_anisotropy(u8 in) { switch (in) { - case CELL_GCM_TEXTURE_MAX_ANISO_1: return rsx::texture_max_anisotropy::x1; - case CELL_GCM_TEXTURE_MAX_ANISO_2: return rsx::texture_max_anisotropy::x2; - case CELL_GCM_TEXTURE_MAX_ANISO_4: return rsx::texture_max_anisotropy::x4; - case CELL_GCM_TEXTURE_MAX_ANISO_6: return rsx::texture_max_anisotropy::x6; - case CELL_GCM_TEXTURE_MAX_ANISO_8: return rsx::texture_max_anisotropy::x8; - case CELL_GCM_TEXTURE_MAX_ANISO_10: return rsx::texture_max_anisotropy::x10; - case CELL_GCM_TEXTURE_MAX_ANISO_12: return rsx::texture_max_anisotropy::x12; - case CELL_GCM_TEXTURE_MAX_ANISO_16: return rsx::texture_max_anisotropy::x16; + case CELL_GCM_TEXTURE_MAX_ANISO_1: return texture_max_anisotropy::x1; + case CELL_GCM_TEXTURE_MAX_ANISO_2: return texture_max_anisotropy::x2; + case CELL_GCM_TEXTURE_MAX_ANISO_4: return texture_max_anisotropy::x4; + case CELL_GCM_TEXTURE_MAX_ANISO_6: return texture_max_anisotropy::x6; + case CELL_GCM_TEXTURE_MAX_ANISO_8: return texture_max_anisotropy::x8; + case CELL_GCM_TEXTURE_MAX_ANISO_10: return texture_max_anisotropy::x10; + 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); } -rsx::texture_minify_filter rsx::to_texture_minify_filter(u8 in) +texture_minify_filter rsx::to_texture_minify_filter(u8 in) { switch (in) { - case CELL_GCM_TEXTURE_NEAREST: return rsx::texture_minify_filter::nearest; - case CELL_GCM_TEXTURE_LINEAR: return rsx::texture_minify_filter::linear; - case CELL_GCM_TEXTURE_NEAREST_NEAREST: return rsx::texture_minify_filter::nearest_nearest; - case CELL_GCM_TEXTURE_LINEAR_NEAREST: return rsx::texture_minify_filter::linear_nearest; - case CELL_GCM_TEXTURE_NEAREST_LINEAR: return rsx::texture_minify_filter::nearest_linear; - case CELL_GCM_TEXTURE_LINEAR_LINEAR: return rsx::texture_minify_filter::linear_linear; - case CELL_GCM_TEXTURE_CONVOLUTION_MIN: return rsx::texture_minify_filter::linear_linear; + case CELL_GCM_TEXTURE_NEAREST: return texture_minify_filter::nearest; + case CELL_GCM_TEXTURE_LINEAR: return texture_minify_filter::linear; + case CELL_GCM_TEXTURE_NEAREST_NEAREST: return texture_minify_filter::nearest_nearest; + case CELL_GCM_TEXTURE_LINEAR_NEAREST: return texture_minify_filter::linear_nearest; + case CELL_GCM_TEXTURE_NEAREST_LINEAR: return texture_minify_filter::nearest_linear; + 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); } -rsx::texture_magnify_filter rsx::to_texture_magnify_filter(u8 in) +texture_magnify_filter rsx::to_texture_magnify_filter(u8 in) { switch (in) { - case CELL_GCM_TEXTURE_NEAREST: return rsx::texture_magnify_filter::nearest; - case CELL_GCM_TEXTURE_LINEAR: return rsx::texture_magnify_filter::linear; - case CELL_GCM_TEXTURE_CONVOLUTION_MAG: return rsx::texture_magnify_filter::convolution_mag; + case CELL_GCM_TEXTURE_NEAREST: return texture_magnify_filter::nearest; + 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); } -rsx::surface_target rsx::to_surface_target(u8 in) +surface_target rsx::to_surface_target(u8 in) { switch (in) { - case CELL_GCM_SURFACE_TARGET_NONE: return rsx::surface_target::none; - case CELL_GCM_SURFACE_TARGET_0: return rsx::surface_target::surface_a; - case CELL_GCM_SURFACE_TARGET_1: return rsx::surface_target::surface_b; - case CELL_GCM_SURFACE_TARGET_MRT1: return rsx::surface_target::surfaces_a_b; - case CELL_GCM_SURFACE_TARGET_MRT2: return rsx::surface_target::surfaces_a_b_c; - case CELL_GCM_SURFACE_TARGET_MRT3: return rsx::surface_target::surfaces_a_b_c_d; + case CELL_GCM_SURFACE_TARGET_NONE: return surface_target::none; + case CELL_GCM_SURFACE_TARGET_0: return surface_target::surface_a; + case CELL_GCM_SURFACE_TARGET_1: return surface_target::surface_b; + case CELL_GCM_SURFACE_TARGET_MRT1: return surface_target::surfaces_a_b; + 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); } -rsx::surface_depth_format rsx::to_surface_depth_format(u8 in) +surface_depth_format rsx::to_surface_depth_format(u8 in) { switch (in) { - case CELL_GCM_SURFACE_Z16: return rsx::surface_depth_format::z16; - case CELL_GCM_SURFACE_Z24S8: return rsx::surface_depth_format::z24s8; + 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); } -rsx::surface_antialiasing rsx::to_surface_antialiasing(u8 in) +surface_antialiasing rsx::to_surface_antialiasing(u8 in) { switch (in) { - case CELL_GCM_SURFACE_CENTER_1: return rsx::surface_antialiasing::center_1_sample; - case CELL_GCM_SURFACE_DIAGONAL_CENTERED_2: return rsx::surface_antialiasing::diagonal_centered_2_samples; - case CELL_GCM_SURFACE_SQUARE_CENTERED_4: return rsx::surface_antialiasing::square_centered_4_samples; - case CELL_GCM_SURFACE_SQUARE_ROTATED_4: return rsx::surface_antialiasing::square_rotated_4_samples; + case CELL_GCM_SURFACE_CENTER_1: return surface_antialiasing::center_1_sample; + case CELL_GCM_SURFACE_DIAGONAL_CENTERED_2: return surface_antialiasing::diagonal_centered_2_samples; + 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); } -rsx::surface_color_format rsx::to_surface_color_format(u8 in) +surface_color_format rsx::to_surface_color_format(u8 in) { switch (in) { - case CELL_GCM_SURFACE_X1R5G5B5_Z1R5G5B5: return rsx::surface_color_format::x1r5g5b5_z1r5g5b5; - case CELL_GCM_SURFACE_X1R5G5B5_O1R5G5B5: return rsx::surface_color_format::x1r5g5b5_o1r5g5b5; - case CELL_GCM_SURFACE_R5G6B5: return rsx::surface_color_format::r5g6b5; - case CELL_GCM_SURFACE_X8R8G8B8_Z8R8G8B8: return rsx::surface_color_format::x8r8g8b8_z8r8g8b8; - case CELL_GCM_SURFACE_X8R8G8B8_O8R8G8B8: return rsx::surface_color_format::x8r8g8b8_o8r8g8b8; - case CELL_GCM_SURFACE_A8R8G8B8: return rsx::surface_color_format::a8r8g8b8; - case CELL_GCM_SURFACE_B8: return rsx::surface_color_format::b8; - case CELL_GCM_SURFACE_G8B8: return rsx::surface_color_format::g8b8; - case CELL_GCM_SURFACE_F_W16Z16Y16X16: return rsx::surface_color_format::w16z16y16x16; - case CELL_GCM_SURFACE_F_W32Z32Y32X32: return rsx::surface_color_format::w32z32y32x32; - case CELL_GCM_SURFACE_F_X32: return rsx::surface_color_format::x32; - case CELL_GCM_SURFACE_X8B8G8R8_Z8B8G8R8: return rsx::surface_color_format::x8b8g8r8_z8b8g8r8; - case CELL_GCM_SURFACE_X8B8G8R8_O8B8G8R8: return rsx::surface_color_format::x8b8g8r8_o8b8g8r8; - case CELL_GCM_SURFACE_A8B8G8R8: return rsx::surface_color_format::a8b8g8r8; + case CELL_GCM_SURFACE_X1R5G5B5_Z1R5G5B5: return surface_color_format::x1r5g5b5_z1r5g5b5; + case CELL_GCM_SURFACE_X1R5G5B5_O1R5G5B5: return surface_color_format::x1r5g5b5_o1r5g5b5; + case CELL_GCM_SURFACE_R5G6B5: return surface_color_format::r5g6b5; + case CELL_GCM_SURFACE_X8R8G8B8_Z8R8G8B8: return surface_color_format::x8r8g8b8_z8r8g8b8; + case CELL_GCM_SURFACE_X8R8G8B8_O8R8G8B8: return surface_color_format::x8r8g8b8_o8r8g8b8; + case CELL_GCM_SURFACE_A8R8G8B8: return surface_color_format::a8r8g8b8; + case CELL_GCM_SURFACE_B8: return surface_color_format::b8; + case CELL_GCM_SURFACE_G8B8: return surface_color_format::g8b8; + case CELL_GCM_SURFACE_F_W16Z16Y16X16: return surface_color_format::w16z16y16x16; + case CELL_GCM_SURFACE_F_W32Z32Y32X32: return surface_color_format::w32z32y32x32; + case CELL_GCM_SURFACE_F_X32: return surface_color_format::x32; + case CELL_GCM_SURFACE_X8B8G8R8_Z8B8G8R8: return surface_color_format::x8b8g8r8_z8b8g8r8; + 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); } -rsx::stencil_op rsx::to_stencil_op(u16 in) +stencil_op rsx::to_stencil_op(u16 in) { switch (in) { - case CELL_GCM_INVERT: return rsx::stencil_op::invert; - case CELL_GCM_KEEP: return rsx::stencil_op::keep; - case CELL_GCM_REPLACE: return rsx::stencil_op::replace; - case CELL_GCM_INCR: return rsx::stencil_op::incr; - case CELL_GCM_DECR: return rsx::stencil_op::decr; - case CELL_GCM_INCR_WRAP: return rsx::stencil_op::incr_wrap; - case CELL_GCM_DECR_WRAP: return rsx::stencil_op::decr_wrap; - case CELL_GCM_ZERO: return rsx::stencil_op::zero; + case CELL_GCM_INVERT: return stencil_op::invert; + case CELL_GCM_KEEP: return stencil_op::keep; + case CELL_GCM_REPLACE: return stencil_op::replace; + case CELL_GCM_INCR: return stencil_op::incr; + case CELL_GCM_DECR: return stencil_op::decr; + case CELL_GCM_INCR_WRAP: return stencil_op::incr_wrap; + 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); } -rsx::blend_equation rsx::to_blend_equation(u16 in) +blend_equation rsx::to_blend_equation(u16 in) { switch (in) { - case CELL_GCM_FUNC_ADD: return rsx::blend_equation::add; - case CELL_GCM_MIN: return rsx::blend_equation::min; - case CELL_GCM_MAX: return rsx::blend_equation::max; - case CELL_GCM_FUNC_SUBTRACT: return rsx::blend_equation::substract; - case CELL_GCM_FUNC_REVERSE_SUBTRACT: return rsx::blend_equation::reverse_substract; - case CELL_GCM_FUNC_REVERSE_SUBTRACT_SIGNED: return rsx::blend_equation::reverse_substract_signed; - case CELL_GCM_FUNC_ADD_SIGNED: return rsx::blend_equation::add_signed; - case CELL_GCM_FUNC_REVERSE_ADD_SIGNED: return rsx::blend_equation::reverse_add_signed; + 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_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); } -rsx::blend_factor rsx::to_blend_factor(u16 in) +blend_factor rsx::to_blend_factor(u16 in) { switch (in) { - case CELL_GCM_ZERO: return rsx::blend_factor::zero; - case CELL_GCM_ONE: return rsx::blend_factor::one; - case CELL_GCM_SRC_COLOR: return rsx::blend_factor::src_color; - case CELL_GCM_ONE_MINUS_SRC_COLOR: return rsx::blend_factor::one_minus_src_color; - case CELL_GCM_SRC_ALPHA: return rsx::blend_factor::src_alpha; - case CELL_GCM_ONE_MINUS_SRC_ALPHA: return rsx::blend_factor::one_minus_src_alpha; - case CELL_GCM_DST_ALPHA: return rsx::blend_factor::dst_alpha; - case CELL_GCM_ONE_MINUS_DST_ALPHA: return rsx::blend_factor::one_minus_dst_alpha; - case CELL_GCM_DST_COLOR: return rsx::blend_factor::dst_color; - case CELL_GCM_ONE_MINUS_DST_COLOR: return rsx::blend_factor::one_minus_dst_color; - case CELL_GCM_SRC_ALPHA_SATURATE: return rsx::blend_factor::src_alpha_saturate; - case CELL_GCM_CONSTANT_COLOR: return rsx::blend_factor::constant_color; - case CELL_GCM_ONE_MINUS_CONSTANT_COLOR: return rsx::blend_factor::one_minus_constant_color; - case CELL_GCM_CONSTANT_ALPHA: return rsx::blend_factor::constant_alpha; - case CELL_GCM_ONE_MINUS_CONSTANT_ALPHA: return rsx::blend_factor::one_minus_constant_alpha; + case CELL_GCM_ZERO: return blend_factor::zero; + case CELL_GCM_ONE: return blend_factor::one; + case CELL_GCM_SRC_COLOR: return blend_factor::src_color; + case CELL_GCM_ONE_MINUS_SRC_COLOR: return blend_factor::one_minus_src_color; + case CELL_GCM_SRC_ALPHA: return blend_factor::src_alpha; + case CELL_GCM_ONE_MINUS_SRC_ALPHA: return blend_factor::one_minus_src_alpha; + case CELL_GCM_DST_ALPHA: return blend_factor::dst_alpha; + case CELL_GCM_ONE_MINUS_DST_ALPHA: return blend_factor::one_minus_dst_alpha; + case CELL_GCM_DST_COLOR: return blend_factor::dst_color; + case CELL_GCM_ONE_MINUS_DST_COLOR: return blend_factor::one_minus_dst_color; + case CELL_GCM_SRC_ALPHA_SATURATE: return blend_factor::src_alpha_saturate; + case CELL_GCM_CONSTANT_COLOR: return blend_factor::constant_color; + case CELL_GCM_ONE_MINUS_CONSTANT_COLOR: return blend_factor::one_minus_constant_color; + 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); } @@ -753,37 +991,37 @@ enum CELL_GCM_SET = 0x150F, }; -rsx::logic_op rsx::to_logic_op(u16 in) +logic_op rsx::to_logic_op(u16 in) { switch (in) { - case CELL_GCM_CLEAR: return rsx::logic_op::logic_clear; - case CELL_GCM_AND: return rsx::logic_op::logic_and; - case CELL_GCM_AND_REVERSE: return rsx::logic_op::logic_and_reverse; - case CELL_GCM_COPY: return rsx::logic_op::logic_copy; - case CELL_GCM_AND_INVERTED: return rsx::logic_op::logic_and_inverted; - case CELL_GCM_NOOP: return rsx::logic_op::logic_noop; - case CELL_GCM_XOR: return rsx::logic_op::logic_xor; - case CELL_GCM_OR: return rsx::logic_op::logic_or; - case CELL_GCM_NOR: return rsx::logic_op::logic_nor; - case CELL_GCM_EQUIV: return rsx::logic_op::logic_equiv; - case CELL_GCM_INVERT: return rsx::logic_op::logic_invert; - case CELL_GCM_OR_REVERSE: return rsx::logic_op::logic_or_reverse; - case CELL_GCM_COPY_INVERTED: return rsx::logic_op::logic_copy_inverted; - case CELL_GCM_OR_INVERTED: return rsx::logic_op::logic_or_inverted; - case CELL_GCM_NAND: return rsx::logic_op::logic_nand; - case CELL_GCM_SET: return rsx::logic_op::logic_set; + case CELL_GCM_CLEAR: return logic_op::logic_clear; + case CELL_GCM_AND: return logic_op::logic_and; + case CELL_GCM_AND_REVERSE: return logic_op::logic_and_reverse; + case CELL_GCM_COPY: return logic_op::logic_copy; + case CELL_GCM_AND_INVERTED: return logic_op::logic_and_inverted; + case CELL_GCM_NOOP: return logic_op::logic_noop; + case CELL_GCM_XOR: return logic_op::logic_xor; + case CELL_GCM_OR: return logic_op::logic_or; + case CELL_GCM_NOR: return logic_op::logic_nor; + case CELL_GCM_EQUIV: return logic_op::logic_equiv; + case CELL_GCM_INVERT: return logic_op::logic_invert; + case CELL_GCM_OR_REVERSE: return logic_op::logic_or_reverse; + case CELL_GCM_COPY_INVERTED: return logic_op::logic_copy_inverted; + case CELL_GCM_OR_INVERTED: return logic_op::logic_or_inverted; + 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); } -rsx::front_face rsx::to_front_face(u16 in) +front_face rsx::to_front_face(u16 in) { switch (in) { default: // Disgaea 3 pass some garbage value at startup, this is needed to survive. - case CELL_GCM_CW: return rsx::front_face::cw; - case CELL_GCM_CCW: return rsx::front_face::ccw; + 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); } @@ -797,22 +1035,22 @@ enum CELL_GCM_TRANSFER_INTERPOLATOR_FOH = 1, }; -rsx::blit_engine::transfer_origin rsx::blit_engine::to_transfer_origin(u8 in) +blit_engine::transfer_origin blit_engine::to_transfer_origin(u8 in) { switch (in) { - case CELL_GCM_TRANSFER_ORIGIN_CENTER: return rsx::blit_engine::transfer_origin::center; - case CELL_GCM_TRANSFER_ORIGIN_CORNER: return rsx::blit_engine::transfer_origin::corner; + 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); } -rsx::blit_engine::transfer_interpolator rsx::blit_engine::to_transfer_interpolator(u8 in) +blit_engine::transfer_interpolator blit_engine::to_transfer_interpolator(u8 in) { switch (in) { - case CELL_GCM_TRANSFER_INTERPOLATOR_ZOH: return rsx::blit_engine::transfer_interpolator::zoh; - case CELL_GCM_TRANSFER_INTERPOLATOR_FOH: return rsx::blit_engine::transfer_interpolator::foh; + 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); } @@ -827,16 +1065,16 @@ enum CELL_GCM_TRANSFER_OPERATION_BLEND_PREMULT = 5, }; -rsx::blit_engine::transfer_operation rsx::blit_engine::to_transfer_operation(u8 in) +blit_engine::transfer_operation blit_engine::to_transfer_operation(u8 in) { switch (in) { - case CELL_GCM_TRANSFER_OPERATION_SRCCOPY_AND: return rsx::blit_engine::transfer_operation::srccopy_and; - case CELL_GCM_TRANSFER_OPERATION_ROP_AND: return rsx::blit_engine::transfer_operation::rop_and; - case CELL_GCM_TRANSFER_OPERATION_BLEND_AND: return rsx::blit_engine::transfer_operation::blend_and; - case CELL_GCM_TRANSFER_OPERATION_SRCCOPY: return rsx::blit_engine::transfer_operation::srccopy; - case CELL_GCM_TRANSFER_OPERATION_SRCCOPY_PREMULT: return rsx::blit_engine::transfer_operation::srccopy_premult; - case CELL_GCM_TRANSFER_OPERATION_BLEND_PREMULT: return rsx::blit_engine::transfer_operation::blend_premult; + case CELL_GCM_TRANSFER_OPERATION_SRCCOPY_AND: return blit_engine::transfer_operation::srccopy_and; + case CELL_GCM_TRANSFER_OPERATION_ROP_AND: return blit_engine::transfer_operation::rop_and; + case CELL_GCM_TRANSFER_OPERATION_BLEND_AND: return blit_engine::transfer_operation::blend_and; + case CELL_GCM_TRANSFER_OPERATION_SRCCOPY: return blit_engine::transfer_operation::srccopy; + case CELL_GCM_TRANSFER_OPERATION_SRCCOPY_PREMULT: return blit_engine::transfer_operation::srccopy_premult; + case CELL_GCM_TRANSFER_OPERATION_BLEND_PREMULT: return blit_engine::transfer_operation::blend_premult; } fmt::throw_exception("Unknown transfer operation 0x%x", in); } @@ -858,23 +1096,23 @@ enum CELL_GCM_TRANSFER_SCALE_FORMAT_X8B8G8R8 = 13, }; -rsx::blit_engine::transfer_source_format rsx::blit_engine::to_transfer_source_format(u8 in) +blit_engine::transfer_source_format blit_engine::to_transfer_source_format(u8 in) { switch (in) { - case CELL_GCM_TRANSFER_SCALE_FORMAT_A1R5G5B5: return rsx::blit_engine::transfer_source_format::a1r5g5b5; - case CELL_GCM_TRANSFER_SCALE_FORMAT_X1R5G5B5: return rsx::blit_engine::transfer_source_format::x1r5g5b5; - case CELL_GCM_TRANSFER_SCALE_FORMAT_A8R8G8B8: return rsx::blit_engine::transfer_source_format::a8r8g8b8; - case CELL_GCM_TRANSFER_SCALE_FORMAT_X8R8G8B8: return rsx::blit_engine::transfer_source_format::x8r8g8b8; - case CELL_GCM_TRANSFER_SCALE_FORMAT_CR8YB8CB8YA8: return rsx::blit_engine::transfer_source_format::cr8yb8cb8ya8; - case CELL_GCM_TRANSFER_SCALE_FORMAT_YB8CR8YA8CB8: return rsx::blit_engine::transfer_source_format::yb8cr8ya8cb8; - case CELL_GCM_TRANSFER_SCALE_FORMAT_R5G6B5: return rsx::blit_engine::transfer_source_format::r5g6b5; - case CELL_GCM_TRANSFER_SCALE_FORMAT_Y8: return rsx::blit_engine::transfer_source_format::y8; - case CELL_GCM_TRANSFER_SCALE_FORMAT_AY8: return rsx::blit_engine::transfer_source_format::ay8; - case CELL_GCM_TRANSFER_SCALE_FORMAT_EYB8ECR8EYA8ECB8: return rsx::blit_engine::transfer_source_format::eyb8ecr8eya8ecb8; - case CELL_GCM_TRANSFER_SCALE_FORMAT_ECR8EYB8ECB8EYA8: return rsx::blit_engine::transfer_source_format::ecr8eyb8ecb8eya8; - case CELL_GCM_TRANSFER_SCALE_FORMAT_A8B8G8R8: return rsx::blit_engine::transfer_source_format::a8b8g8r8; - case CELL_GCM_TRANSFER_SCALE_FORMAT_X8B8G8R8: return rsx::blit_engine::transfer_source_format::x8b8g8r8; + case CELL_GCM_TRANSFER_SCALE_FORMAT_A1R5G5B5: return blit_engine::transfer_source_format::a1r5g5b5; + case CELL_GCM_TRANSFER_SCALE_FORMAT_X1R5G5B5: return blit_engine::transfer_source_format::x1r5g5b5; + case CELL_GCM_TRANSFER_SCALE_FORMAT_A8R8G8B8: return blit_engine::transfer_source_format::a8r8g8b8; + case CELL_GCM_TRANSFER_SCALE_FORMAT_X8R8G8B8: return blit_engine::transfer_source_format::x8r8g8b8; + case CELL_GCM_TRANSFER_SCALE_FORMAT_CR8YB8CB8YA8: return blit_engine::transfer_source_format::cr8yb8cb8ya8; + case CELL_GCM_TRANSFER_SCALE_FORMAT_YB8CR8YA8CB8: return blit_engine::transfer_source_format::yb8cr8ya8cb8; + case CELL_GCM_TRANSFER_SCALE_FORMAT_R5G6B5: return blit_engine::transfer_source_format::r5g6b5; + case CELL_GCM_TRANSFER_SCALE_FORMAT_Y8: return blit_engine::transfer_source_format::y8; + case CELL_GCM_TRANSFER_SCALE_FORMAT_AY8: return blit_engine::transfer_source_format::ay8; + case CELL_GCM_TRANSFER_SCALE_FORMAT_EYB8ECR8EYA8ECB8: return blit_engine::transfer_source_format::eyb8ecr8eya8ecb8; + case CELL_GCM_TRANSFER_SCALE_FORMAT_ECR8EYB8ECB8EYA8: return blit_engine::transfer_source_format::ecr8eyb8ecb8eya8; + case CELL_GCM_TRANSFER_SCALE_FORMAT_A8B8G8R8: return blit_engine::transfer_source_format::a8b8g8r8; + case CELL_GCM_TRANSFER_SCALE_FORMAT_X8B8G8R8: return blit_engine::transfer_source_format::x8b8g8r8; } fmt::throw_exception("Unknown transfer source format 0x%x", in); } @@ -887,13 +1125,13 @@ enum CELL_GCM_TRANSFER_SURFACE_FORMAT_Y32 = 11, }; -rsx::blit_engine::transfer_destination_format rsx::blit_engine::to_transfer_destination_format(u8 in) +blit_engine::transfer_destination_format blit_engine::to_transfer_destination_format(u8 in) { switch (in) { - case CELL_GCM_TRANSFER_SURFACE_FORMAT_R5G6B5: return rsx::blit_engine::transfer_destination_format::r5g6b5; - case CELL_GCM_TRANSFER_SURFACE_FORMAT_A8R8G8B8: return rsx::blit_engine::transfer_destination_format::a8r8g8b8; - case CELL_GCM_TRANSFER_SURFACE_FORMAT_Y32: return rsx::blit_engine::transfer_destination_format::y32; + case CELL_GCM_TRANSFER_SURFACE_FORMAT_R5G6B5: return blit_engine::transfer_destination_format::r5g6b5; + case CELL_GCM_TRANSFER_SURFACE_FORMAT_A8R8G8B8: return blit_engine::transfer_destination_format::a8r8g8b8; + case CELL_GCM_TRANSFER_SURFACE_FORMAT_Y32: return blit_engine::transfer_destination_format::y32; } fmt::throw_exception("Unknown transfer destination format 0x%x", in); } @@ -904,23 +1142,23 @@ enum CELL_GCM_CONTEXT_SWIZZLE2D = 0x31337A73, }; -rsx::blit_engine::context_surface rsx::blit_engine::to_context_surface(u32 in) +blit_engine::context_surface blit_engine::to_context_surface(u32 in) { switch (in) { - case CELL_GCM_CONTEXT_SURFACE2D: return rsx::blit_engine::context_surface::surface2d; - case CELL_GCM_CONTEXT_SWIZZLE2D: return rsx::blit_engine::context_surface::swizzle2d; + 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); } -rsx::blit_engine::context_dma rsx::blit_engine::to_context_dma(u32 in) +blit_engine::context_dma blit_engine::to_context_dma(u32 in) { switch (in) { - case CELL_GCM_CONTEXT_DMA_REPORT_LOCATION_LOCAL: return rsx::blit_engine::context_dma::to_memory_get_report; - case CELL_GCM_CONTEXT_DMA_REPORT_LOCATION_MAIN: return rsx::blit_engine::context_dma::report_location_main; - case CELL_GCM_CONTEXT_DMA_MEMORY_HOST_BUFFER: return rsx::blit_engine::context_dma::memory_host_buffer; + case CELL_GCM_CONTEXT_DMA_REPORT_LOCATION_LOCAL: return blit_engine::context_dma::to_memory_get_report; + 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); } @@ -932,13 +1170,13 @@ enum CELL_GCM_USER_CLIP_PLANE_ENABLE_GE = 2, }; -rsx::user_clip_plane_op rsx::to_user_clip_plane_op(u8 in) +user_clip_plane_op rsx::to_user_clip_plane_op(u8 in) { switch (in) { - case CELL_GCM_USER_CLIP_PLANE_DISABLE: return rsx::user_clip_plane_op::disable; - case CELL_GCM_USER_CLIP_PLANE_ENABLE_LT: return rsx::user_clip_plane_op::less_than; - case CELL_GCM_USER_CLIP_PLANE_ENABLE_GE: return rsx::user_clip_plane_op::greater_or_equal; + case CELL_GCM_USER_CLIP_PLANE_DISABLE: return user_clip_plane_op::disable; + 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); } @@ -949,12 +1187,12 @@ enum CELL_GCM_SMOOTH = 0x1D01, }; -rsx::shading_mode rsx::to_shading_mode(u32 in) +shading_mode rsx::to_shading_mode(u32 in) { switch (in) { - case CELL_GCM_FLAT: return rsx::shading_mode::flat; - case CELL_GCM_SMOOTH: return rsx::shading_mode::smooth; + 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); } @@ -966,13 +1204,13 @@ enum CELL_GCM_POLYGON_MODE_FILL = 0x1B02, }; -rsx::polygon_mode rsx::to_polygon_mode(u32 in) +polygon_mode rsx::to_polygon_mode(u32 in) { switch (in) { - case CELL_GCM_POLYGON_MODE_POINT: return rsx::polygon_mode::point; - case CELL_GCM_POLYGON_MODE_LINE: return rsx::polygon_mode::line; - case CELL_GCM_POLYGON_MODE_FILL: return rsx::polygon_mode::fill; + case CELL_GCM_POLYGON_MODE_POINT: return polygon_mode::point; + 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); } diff --git a/rpcs3/Emu/RSX/gcm_enums.h b/rpcs3/Emu/RSX/gcm_enums.h index 489b1e29d8..9da3b73732 100644 --- a/rpcs3/Emu/RSX/gcm_enums.h +++ b/rpcs3/Emu/RSX/gcm_enums.h @@ -466,12 +466,6 @@ enum CELL_GCM_DISPLAY_FLIP_STATUS_WAITING = 1, }; -enum -{ - CELL_GCM_LOCATION_LOCAL = 0, - CELL_GCM_LOCATION_MAIN = 1, -}; - enum { CELL_GCM_FREQUENCY_MODULO = 1, @@ -511,7 +505,7 @@ enum }; // GCM Texture -enum +enum CellGcmTexture : u32 { // Color Flag CELL_GCM_TEXTURE_B8 = 0x81, @@ -815,8 +809,11 @@ enum }; // GPU Class Handles -enum +enum CellGcmLocation : u32 { + CELL_GCM_LOCATION_LOCAL = 0, + CELL_GCM_LOCATION_MAIN = 1, + CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER = 0xFEED0000, // Local memory CELL_GCM_CONTEXT_DMA_MEMORY_HOST_BUFFER = 0xFEED0001, // Main memory CELL_GCM_CONTEXT_DMA_REPORT_LOCATION_LOCAL = 0x66626660, @@ -830,7 +827,7 @@ enum CELL_GCM_CONTEXT_DMA_DEVICE_R = 0x56616661 }; -enum +enum CellGcmMethod : u16 { // NV40_CHANNEL_DMA (NV406E) NV406E_SET_REFERENCE = 0x00000050 >> 2, diff --git a/rpcs3/Emu/RSX/gcm_printing.cpp b/rpcs3/Emu/RSX/gcm_printing.cpp index 7276a6af6d..16ce949b85 100644 --- a/rpcs3/Emu/RSX/gcm_printing.cpp +++ b/rpcs3/Emu/RSX/gcm_printing.cpp @@ -6,62 +6,69 @@ namespace { constexpr u32 opcode_list[] = {NV4097_SET_VIEWPORT_HORIZONTAL, NV4097_SET_VIEWPORT_VERTICAL, - NV4097_SET_SCISSOR_HORIZONTAL, NV4097_SET_SCISSOR_VERTICAL, NV4097_SET_SURFACE_CLIP_HORIZONTAL, - NV4097_SET_SURFACE_CLIP_VERTICAL, NV4097_SET_CLEAR_RECT_HORIZONTAL, - NV4097_SET_CLEAR_RECT_VERTICAL, NV3089_CLIP_POINT, NV3089_CLIP_SIZE, NV3089_IMAGE_OUT_POINT, - NV3089_IMAGE_OUT_SIZE, NV3089_IMAGE_IN_SIZE, NV3062_SET_PITCH, NV308A_POINT, - NV4097_SET_DEPTH_TEST_ENABLE, NV4097_SET_DEPTH_MASK, NV4097_SET_ALPHA_TEST_ENABLE, - NV4097_SET_STENCIL_TEST_ENABLE, NV4097_SET_RESTART_INDEX_ENABLE, - NV4097_SET_DEPTH_BOUNDS_TEST_ENABLE, NV4097_SET_LOGIC_OP_ENABLE, NV4097_SET_DITHER_ENABLE, - NV4097_SET_BLEND_ENABLE, NV4097_SET_LINE_SMOOTH_ENABLE, NV4097_SET_POLY_OFFSET_POINT_ENABLE, - NV4097_SET_POLY_OFFSET_LINE_ENABLE, NV4097_SET_POLY_OFFSET_FILL_ENABLE, - NV4097_SET_CULL_FACE_ENABLE, NV4097_SET_POLY_SMOOTH_ENABLE, - NV4097_SET_TWO_SIDED_STENCIL_TEST_ENABLE, NV4097_SET_TWO_SIDE_LIGHT_EN, - NV4097_SET_RESTART_INDEX, NV4097_SET_SURFACE_COLOR_AOFFSET, NV4097_SET_SURFACE_COLOR_BOFFSET, - NV4097_SET_SURFACE_COLOR_COFFSET, NV4097_SET_SURFACE_COLOR_DOFFSET, NV4097_SET_SURFACE_PITCH_A, - NV4097_SET_SURFACE_PITCH_B, NV4097_SET_SURFACE_PITCH_C, NV4097_SET_SURFACE_PITCH_D, - NV4097_SET_SURFACE_ZETA_OFFSET, NV4097_SET_SURFACE_PITCH_Z, - NV4097_SET_VERTEX_ATTRIB_OUTPUT_MASK, NV4097_SET_SHADER_CONTROL, - NV4097_SET_VERTEX_DATA_BASE_OFFSET, NV4097_SET_INDEX_ARRAY_ADDRESS, - NV4097_SET_VERTEX_DATA_BASE_INDEX, NV4097_SET_SHADER_PROGRAM, - NV4097_SET_TRANSFORM_PROGRAM_START, NV406E_SET_CONTEXT_DMA_SEMAPHORE, NV406E_SEMAPHORE_OFFSET, NV4097_SET_SEMAPHORE_OFFSET, - NV3089_IMAGE_IN_OFFSET, NV3062_SET_OFFSET_DESTIN, NV309E_SET_OFFSET, NV3089_DS_DX, NV3089_DT_DY, - NV0039_PITCH_IN, NV0039_PITCH_OUT, NV0039_LINE_LENGTH_IN, NV0039_LINE_COUNT, NV0039_OFFSET_OUT, - NV0039_OFFSET_IN, NV4097_SET_VERTEX_ATTRIB_INPUT_MASK, NV4097_SET_FREQUENCY_DIVIDER_OPERATION, - NV4097_SET_DEPTH_BOUNDS_MIN, NV4097_SET_DEPTH_BOUNDS_MAX, NV4097_SET_FOG_PARAMS, - NV4097_SET_FOG_PARAMS + 1, NV4097_SET_CLIP_MIN, NV4097_SET_CLIP_MAX, - NV4097_SET_POLYGON_OFFSET_SCALE_FACTOR, NV4097_SET_POLYGON_OFFSET_BIAS, - NV4097_SET_VIEWPORT_SCALE, NV4097_SET_VIEWPORT_SCALE + 1, NV4097_SET_VIEWPORT_SCALE + 2, - NV4097_SET_VIEWPORT_SCALE + 3, NV4097_SET_VIEWPORT_OFFSET, NV4097_SET_VIEWPORT_OFFSET + 1, - NV4097_SET_VIEWPORT_OFFSET + 2, NV4097_SET_VIEWPORT_OFFSET + 3, NV4097_SET_DEPTH_FUNC, - NV4097_SET_STENCIL_FUNC, NV4097_SET_BACK_STENCIL_FUNC, NV4097_SET_STENCIL_OP_FAIL, - NV4097_SET_STENCIL_OP_ZFAIL, NV4097_SET_STENCIL_OP_ZPASS, NV4097_SET_BACK_STENCIL_OP_FAIL, - NV4097_SET_BACK_STENCIL_OP_ZFAIL, NV4097_SET_BACK_STENCIL_OP_ZPASS, NV4097_SET_LOGIC_OP, - NV4097_SET_FRONT_FACE, NV4097_SET_CULL_FACE, NV4097_SET_SURFACE_COLOR_TARGET, - NV4097_SET_FOG_MODE, NV4097_SET_ALPHA_FUNC, NV4097_SET_BEGIN_END, NV3089_SET_OPERATION, - NV3089_SET_COLOR_FORMAT, NV3089_SET_CONTEXT_SURFACE, NV3062_SET_COLOR_FORMAT, - NV4097_SET_STENCIL_FUNC_REF, NV4097_SET_BACK_STENCIL_FUNC_REF, NV4097_SET_STENCIL_FUNC_MASK, - NV4097_SET_BACK_STENCIL_FUNC_MASK, NV4097_SET_ALPHA_REF, NV4097_SET_COLOR_CLEAR_VALUE, - NV4097_SET_STENCIL_MASK, NV4097_SET_BACK_STENCIL_MASK, NV4097_SET_BLEND_EQUATION, - NV4097_SET_BLEND_FUNC_SFACTOR, NV4097_SET_BLEND_FUNC_DFACTOR, NV4097_SET_COLOR_MASK, - NV4097_SET_SHADER_WINDOW, NV4097_SET_BLEND_ENABLE_MRT, NV4097_SET_USER_CLIP_PLANE_CONTROL, - NV4097_SET_LINE_WIDTH, NV4097_SET_SURFACE_FORMAT, NV4097_SET_WINDOW_OFFSET, - NV4097_SET_ZSTENCIL_CLEAR_VALUE, NV4097_SET_INDEX_ARRAY_DMA, NV4097_SET_CONTEXT_DMA_COLOR_A, - NV4097_SET_CONTEXT_DMA_COLOR_B, NV4097_SET_CONTEXT_DMA_COLOR_C, NV4097_SET_CONTEXT_DMA_COLOR_D, - NV4097_SET_CONTEXT_DMA_ZETA, NV3089_SET_CONTEXT_DMA_IMAGE, NV3062_SET_CONTEXT_DMA_IMAGE_DESTIN, - NV309E_SET_CONTEXT_DMA_IMAGE, NV0039_SET_CONTEXT_DMA_BUFFER_OUT, - NV0039_SET_CONTEXT_DMA_BUFFER_IN, NV4097_SET_CONTEXT_DMA_REPORT, NV3089_IMAGE_IN_FORMAT, - NV309E_SET_FORMAT, NV0039_FORMAT, NV4097_SET_BLEND_COLOR2, NV4097_SET_BLEND_COLOR, - NV3089_IMAGE_IN, NV4097_NO_OPERATION, NV4097_INVALIDATE_VERTEX_CACHE_FILE, - NV4097_INVALIDATE_VERTEX_FILE, NV4097_SET_ANTI_ALIASING_CONTROL, NV4097_SET_FRONT_POLYGON_MODE, - NV4097_SET_BACK_POLYGON_MODE, - EXPAND_RANGE_16(0, DECLARE_VERTEX_DATA_ARRAY_FORMAT) - EXPAND_RANGE_16(0, DECLARE_VERTEX_DATA_ARRAY_OFFSET) - EXPAND_RANGE_32(0, DECLARE_TRANSFORM_CONSTANT) NV4097_SET_TRANSFORM_CONSTANT_LOAD, - NV4097_DRAW_ARRAYS, NV4097_DRAW_INDEX_ARRAY, - EXPAND_RANGE_512(0, DECLARE_TRANSFORM_PROGRAM) NV4097_SET_TRANSFORM_PROGRAM_LOAD}; + NV4097_SET_SCISSOR_HORIZONTAL, NV4097_SET_SCISSOR_VERTICAL, NV4097_SET_SURFACE_CLIP_HORIZONTAL, + NV4097_SET_SURFACE_CLIP_VERTICAL, NV4097_SET_CLEAR_RECT_HORIZONTAL, + NV4097_SET_CLEAR_RECT_VERTICAL, NV3089_CLIP_POINT, NV3089_CLIP_SIZE, NV3089_IMAGE_OUT_POINT, + NV3089_IMAGE_OUT_SIZE, NV3089_IMAGE_IN_SIZE, NV3062_SET_PITCH, NV308A_POINT, + NV4097_SET_DEPTH_TEST_ENABLE, NV4097_SET_DEPTH_MASK, NV4097_SET_ALPHA_TEST_ENABLE, + NV4097_SET_STENCIL_TEST_ENABLE, NV4097_SET_RESTART_INDEX_ENABLE, + NV4097_SET_DEPTH_BOUNDS_TEST_ENABLE, NV4097_SET_LOGIC_OP_ENABLE, NV4097_SET_DITHER_ENABLE, + NV4097_SET_BLEND_ENABLE, NV4097_SET_LINE_SMOOTH_ENABLE, NV4097_SET_POLY_OFFSET_POINT_ENABLE, + NV4097_SET_POLY_OFFSET_LINE_ENABLE, NV4097_SET_POLY_OFFSET_FILL_ENABLE, + NV4097_SET_CULL_FACE_ENABLE, NV4097_SET_POLY_SMOOTH_ENABLE, + NV4097_SET_TWO_SIDED_STENCIL_TEST_ENABLE, NV4097_SET_TWO_SIDE_LIGHT_EN, + NV4097_SET_RESTART_INDEX, NV4097_SET_SURFACE_COLOR_AOFFSET, NV4097_SET_SURFACE_COLOR_BOFFSET, + NV4097_SET_SURFACE_COLOR_COFFSET, NV4097_SET_SURFACE_COLOR_DOFFSET, NV4097_SET_SURFACE_PITCH_A, + NV4097_SET_SURFACE_PITCH_B, NV4097_SET_SURFACE_PITCH_C, NV4097_SET_SURFACE_PITCH_D, + NV4097_SET_SURFACE_ZETA_OFFSET, NV4097_SET_SURFACE_PITCH_Z, + NV4097_SET_VERTEX_ATTRIB_OUTPUT_MASK, NV4097_SET_SHADER_CONTROL, + NV4097_SET_VERTEX_DATA_BASE_OFFSET, NV4097_SET_INDEX_ARRAY_ADDRESS, + NV4097_SET_VERTEX_DATA_BASE_INDEX, NV4097_SET_SHADER_PROGRAM, + NV4097_SET_TRANSFORM_PROGRAM_START, NV406E_SET_CONTEXT_DMA_SEMAPHORE, NV406E_SEMAPHORE_OFFSET, NV4097_SET_SEMAPHORE_OFFSET, + NV3089_IMAGE_IN_OFFSET, NV3062_SET_OFFSET_DESTIN, NV309E_SET_OFFSET, NV3089_DS_DX, NV3089_DT_DY, + NV0039_PITCH_IN, NV0039_PITCH_OUT, NV0039_LINE_LENGTH_IN, NV0039_LINE_COUNT, NV0039_OFFSET_OUT, + NV0039_OFFSET_IN, NV4097_SET_VERTEX_ATTRIB_INPUT_MASK, NV4097_SET_FREQUENCY_DIVIDER_OPERATION, + NV4097_SET_DEPTH_BOUNDS_MIN, NV4097_SET_DEPTH_BOUNDS_MAX, NV4097_SET_FOG_PARAMS, + NV4097_SET_FOG_PARAMS + 1, NV4097_SET_CLIP_MIN, NV4097_SET_CLIP_MAX, + NV4097_SET_POLYGON_OFFSET_SCALE_FACTOR, NV4097_SET_POLYGON_OFFSET_BIAS, + NV4097_SET_VIEWPORT_SCALE, NV4097_SET_VIEWPORT_SCALE + 1, NV4097_SET_VIEWPORT_SCALE + 2, + NV4097_SET_VIEWPORT_SCALE + 3, NV4097_SET_VIEWPORT_OFFSET, NV4097_SET_VIEWPORT_OFFSET + 1, + NV4097_SET_VIEWPORT_OFFSET + 2, NV4097_SET_VIEWPORT_OFFSET + 3, NV4097_SET_DEPTH_FUNC, + NV4097_SET_STENCIL_FUNC, NV4097_SET_BACK_STENCIL_FUNC, NV4097_SET_STENCIL_OP_FAIL, + NV4097_SET_STENCIL_OP_ZFAIL, NV4097_SET_STENCIL_OP_ZPASS, NV4097_SET_BACK_STENCIL_OP_FAIL, + NV4097_SET_BACK_STENCIL_OP_ZFAIL, NV4097_SET_BACK_STENCIL_OP_ZPASS, NV4097_SET_LOGIC_OP, + NV4097_SET_FRONT_FACE, NV4097_SET_CULL_FACE, NV4097_SET_SURFACE_COLOR_TARGET, + NV4097_SET_FOG_MODE, NV4097_SET_ALPHA_FUNC, NV4097_SET_BEGIN_END, NV3089_SET_OPERATION, + NV3089_SET_COLOR_FORMAT, NV3089_SET_CONTEXT_SURFACE, NV3062_SET_COLOR_FORMAT, + NV4097_SET_STENCIL_FUNC_REF, NV4097_SET_BACK_STENCIL_FUNC_REF, NV4097_SET_STENCIL_FUNC_MASK, + NV4097_SET_BACK_STENCIL_FUNC_MASK, NV4097_SET_ALPHA_REF, NV4097_SET_COLOR_CLEAR_VALUE, + NV4097_SET_STENCIL_MASK, NV4097_SET_BACK_STENCIL_MASK, NV4097_SET_BLEND_EQUATION, + NV4097_SET_BLEND_FUNC_SFACTOR, NV4097_SET_BLEND_FUNC_DFACTOR, NV4097_SET_COLOR_MASK, + NV4097_SET_SHADER_WINDOW, NV4097_SET_BLEND_ENABLE_MRT, NV4097_SET_USER_CLIP_PLANE_CONTROL, + NV4097_SET_LINE_WIDTH, NV4097_SET_SURFACE_FORMAT, NV4097_SET_WINDOW_OFFSET, + NV4097_SET_ZSTENCIL_CLEAR_VALUE, NV4097_SET_INDEX_ARRAY_DMA, NV4097_SET_CONTEXT_DMA_COLOR_A, + NV4097_SET_CONTEXT_DMA_COLOR_B, NV4097_SET_CONTEXT_DMA_COLOR_C, NV4097_SET_CONTEXT_DMA_COLOR_D, + NV4097_SET_CONTEXT_DMA_ZETA, NV3089_SET_CONTEXT_DMA_IMAGE, NV3062_SET_CONTEXT_DMA_IMAGE_DESTIN, + NV309E_SET_CONTEXT_DMA_IMAGE, NV0039_SET_CONTEXT_DMA_BUFFER_OUT, + NV0039_SET_CONTEXT_DMA_BUFFER_IN, NV4097_SET_CONTEXT_DMA_REPORT, NV3089_IMAGE_IN_FORMAT, + NV309E_SET_FORMAT, NV0039_FORMAT, NV4097_SET_BLEND_COLOR2, NV4097_SET_BLEND_COLOR, + NV3089_IMAGE_IN, NV4097_NO_OPERATION, NV4097_INVALIDATE_VERTEX_CACHE_FILE, + NV4097_INVALIDATE_VERTEX_FILE, NV4097_SET_ANTI_ALIASING_CONTROL, NV4097_SET_FRONT_POLYGON_MODE, + NV4097_SET_BACK_POLYGON_MODE, NV406E_SET_REFERENCE, NV406E_SEMAPHORE_RELEASE, NV406E_SEMAPHORE_ACQUIRE, + NV4097_SET_ZCULL_EN, NV4097_SET_ZCULL_STATS_ENABLE, NV4097_SET_ZPASS_PIXEL_COUNT_ENABLE, + EXPAND_RANGE_16(0, DECLARE_VERTEX_DATA_ARRAY_FORMAT) + EXPAND_RANGE_16(0, DECLARE_VERTEX_DATA_ARRAY_OFFSET) + EXPAND_RANGE_32(0, DECLARE_TRANSFORM_CONSTANT) NV4097_SET_TRANSFORM_CONSTANT_LOAD, + NV4097_DRAW_ARRAYS, NV4097_DRAW_INDEX_ARRAY, + EXPAND_RANGE_32(0, DECLARE_TRANSFORM_PROGRAM) NV4097_SET_TRANSFORM_PROGRAM_LOAD, + EXPAND_RANGE_16(0, DECLARE_TEXTURE_OFFSET) EXPAND_RANGE_16(0, DECLARE_TEXTURE_FORMAT) + EXPAND_RANGE_16(0, DECLARE_TEXTURE_IMAGE_RECT) EXPAND_RANGE_16(0, DECLARE_TEXTURE_CONTROL0) + EXPAND_RANGE_16(0, DECLARE_TEXTURE_CONTROL3) EXPAND_RANGE_4(0, DECLARE_VERTEX_TEXTURE_CONTROL0)}; - const std::unordered_map methods_name = { + #define KEY_STR(key) { key, #key } + + const std::unordered_map methods_name = + { {NV406E_SET_REFERENCE, "NV406E_SET_REFERENCE"}, {NV406E_SET_CONTEXT_DMA_SEMAPHORE, "NV406E_SET_CONTEXT_DMA_SEMAPHORE"}, {NV406E_SEMAPHORE_OFFSET, "NV406E_SEMAPHORE_OFFSET"}, @@ -321,7 +328,37 @@ namespace {NV4097_SET_EDGE_FLAG, "NV4097_SET_EDGE_FLAG"}, {NV4097_SET_USER_CLIP_PLANE_CONTROL, "NV4097_SET_USER_CLIP_PLANE_CONTROL"}, {NV4097_SET_POLYGON_STIPPLE, "NV4097_SET_POLYGON_STIPPLE"}, - {NV4097_SET_POLYGON_STIPPLE_PATTERN, "NV4097_SET_POLYGON_STIPPLE_PATTERN"}, + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 1), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 2), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 3), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 4), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 5), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 6), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 7), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 8), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 9), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 10), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 11), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 12), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 13), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 14), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 15), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 16), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 17), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 18), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 19), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 20), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 21), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 22), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 23), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 24), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 25), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 26), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 28), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 29), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 30), + KEY_STR(NV4097_SET_POLYGON_STIPPLE_PATTERN + 31), {NV4097_SET_VERTEX_DATA3F_M, "NV4097_SET_VERTEX_DATA3F_M"}, {NV4097_SET_VERTEX_DATA3F_M + 4 / 4, "NV4097_SET_VERTEX_DATA3F_M + 4"}, {NV4097_SET_VERTEX_DATA3F_M + 8 / 4, "NV4097_SET_VERTEX_DATA3F_M + 8"}, @@ -853,149 +890,36 @@ namespace {NV3089_IMAGE_IN_FORMAT, "NV3089_IMAGE_IN_FORMAT"}, {NV3089_IMAGE_IN_OFFSET, "NV3089_IMAGE_IN_OFFSET"}, {NV3089_IMAGE_IN, "NV3089_IMAGE_IN"}, - {GCM_SET_DRIVER_OBJECT, "GCM_SET_DRIVER_OBJECT"}, - {GCM_DRIVER_QUEUE, "GCM_DRIVER_QUEUE + 0x0"}, - {GCM_DRIVER_QUEUE+1, "GCM_DRIVER_QUEUE + 0x4"}, - {GCM_FLIP_HEAD, "GCM_FLIP_HEAD"}, - {GCM_FLIP_HEAD+1, "GCM_FLIP_HEAD + 0x4"}, - {GCM_SET_USER_COMMAND, "GCM_SET_USER_COMMAND"}, - {GCM_FLIP_COMMAND, "GCM_FLIP_COMMAND"}, + {GCM_SET_DRIVER_OBJECT, "SET_DRIVER_OBJECT"}, + {GCM_DRIVER_QUEUE, "DRIVER_QUEUE + 0x0"}, + {GCM_DRIVER_QUEUE+1, "DRIVER_QUEUE + 0x4"}, + {GCM_FLIP_HEAD, "FLIP_HEAD"}, + {GCM_FLIP_HEAD+1, "FLIP_HEAD + 0x4"}, + {GCM_SET_USER_COMMAND, "SET_USER_COMMAND"}, + {GCM_FLIP_COMMAND, "FLIP_COMMAND"}, }; + + #undef KEY_STR } std::string rsx::get_method_name(const u32 id) { - auto found = methods_name.find(id); - if (found != methods_name.end()) { - return std::string("CELL_GCM_") + found->second; + const auto found = methods_name.find(id); + + if (found != methods_name.end()) + { + std::string prefix("CELL_GCM_"sv); + prefix.append(found->second.data(), found->second.size()); + return prefix; } - return fmt::format("Unknown/illegal method [0x%04x]", id << 2); + return fmt::format("Unnamed method 0x%04x", id); } // Various parameter pretty printing function namespace { - std::string ptr_to_string(u32 ptr) - { - return fmt::format("0x%08x", ptr); - } - - std::string dma_mode(u32 arg) - { - switch (arg) - { - case CELL_GCM_LOCATION_LOCAL: - case CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER: return "Local memory"; - case CELL_GCM_LOCATION_MAIN: - case CELL_GCM_CONTEXT_DMA_MEMORY_HOST_BUFFER: return "Main memory"; - } - return "Error"; - } - - std::string texture_dimension(u8 dim) - { - switch (rsx::to_texture_dimension(dim)) - { - case rsx::texture_dimension::dimension1d: return "1D"; - case rsx::texture_dimension::dimension2d: return "2D"; - case rsx::texture_dimension::dimension3d: return "3D"; - } - return ""; - } - - std::string get_vertex_attribute_format(u8 type) - { - switch (rsx::to_vertex_base_type(type)) - { - case rsx::vertex_base_type::s1: return "Signed short normalized"; - case rsx::vertex_base_type::f: return "Float"; - case rsx::vertex_base_type::sf: return "Half float"; - case rsx::vertex_base_type::ub: return "Unsigned byte normalized"; - case rsx::vertex_base_type::s32k: return "Signed short unormalized"; - case rsx::vertex_base_type::cmp: return "CMP"; - case rsx::vertex_base_type::ub256: return "Unsigned byte unormalized"; - } - return ""; - } - - std::string unpack_vertex_format(u32 arg) - { - u32 frequency = arg >> 16; - u32 stride = (arg >> 8) & 0xff; - u32 size = (arg >> 4) & 0xf; - u32 type = arg & 0xf; - if (size == 0) return "(disabled)"; - - return "Type = " + get_vertex_attribute_format(type) + " size = " + std::to_string(size) + - " stride = " + std::to_string(stride) + " frequency = " + std::to_string(frequency); - } - - std::string transform_constant(usz index, u32 arg) - { - return "Transform constant " + std::to_string(index) + ": " + std::to_string(arg) + "/" + - std::to_string(std::bit_cast(arg)); - } - - std::string texture_offset(usz index, u32 arg) - { - return "Texture " + std::to_string(index) + ": Offset @" + ptr_to_string(arg); - } - - std::string texture_size(usz index, u32 arg) - { - return "Texture " + std::to_string(index) + ": width = " + std::to_string(arg & 0xffff) + - " height = " + std::to_string(arg >> 16); - } - - static std::string get_texture_format_name(u32 format) - { - switch (format) - { - case CELL_GCM_TEXTURE_COMPRESSED_HILO8: return "CELL_GCM_TEXTURE_COMPRESSED_HILO8"; - case CELL_GCM_TEXTURE_COMPRESSED_HILO_S8: return "CELL_GCM_TEXTURE_COMPRESSED_HILO_S8"; - case CELL_GCM_TEXTURE_B8: return "CELL_GCM_TEXTURE_B8"; - case CELL_GCM_TEXTURE_A1R5G5B5: return "CELL_GCM_TEXTURE_A1R5G5B5"; - case CELL_GCM_TEXTURE_A4R4G4B4: return "CELL_GCM_TEXTURE_A4R4G4B4"; - case CELL_GCM_TEXTURE_R5G6B5: return "CELL_GCM_TEXTURE_R5G6B5"; - case CELL_GCM_TEXTURE_A8R8G8B8: return "CELL_GCM_TEXTURE_A8R8G8B8"; - case CELL_GCM_TEXTURE_COMPRESSED_DXT1: return "CELL_GCM_TEXTURE_COMPRESSED_DXT1"; - case CELL_GCM_TEXTURE_COMPRESSED_DXT23: return "CELL_GCM_TEXTURE_COMPRESSED_DXT23"; - case CELL_GCM_TEXTURE_COMPRESSED_DXT45: return "CELL_GCM_TEXTURE_COMPRESSED_DXT45"; - case CELL_GCM_TEXTURE_G8B8: return "CELL_GCM_TEXTURE_G8B8"; - case CELL_GCM_TEXTURE_R6G5B5: return "CELL_GCM_TEXTURE_R6G5B5"; - case CELL_GCM_TEXTURE_DEPTH24_D8: return "CELL_GCM_TEXTURE_DEPTH24_D8"; - case CELL_GCM_TEXTURE_DEPTH24_D8_FLOAT: return "CELL_GCM_TEXTURE_DEPTH24_D8_FLOAT"; - case CELL_GCM_TEXTURE_DEPTH16: return "CELL_GCM_TEXTURE_DEPTH16"; - case CELL_GCM_TEXTURE_DEPTH16_FLOAT: return "CELL_GCM_TEXTURE_DEPTH16_FLOAT"; - case CELL_GCM_TEXTURE_X16: return "CELL_GCM_TEXTURE_X16"; - case CELL_GCM_TEXTURE_Y16_X16: return "CELL_GCM_TEXTURE_Y16_X16"; - case CELL_GCM_TEXTURE_R5G5B5A1: return "CELL_GCM_TEXTURE_R5G5B5A1"; - case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT: return "CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT"; - case CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT: return "CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT"; - case CELL_GCM_TEXTURE_X32_FLOAT: return "CELL_GCM_TEXTURE_X32_FLOAT"; - case CELL_GCM_TEXTURE_D1R5G5B5: return "CELL_GCM_TEXTURE_D1R5G5B5"; - case CELL_GCM_TEXTURE_D8R8G8B8: return "CELL_GCM_TEXTURE_D8R8G8B8"; - case CELL_GCM_TEXTURE_Y16_X16_FLOAT: return "CELL_GCM_TEXTURE_Y16_X16_FLOAT"; - case CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8: return "CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8"; - case CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8: return "CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8"; - } - return "Error"; - } - - std::string texture_format(usz index, u32 arg) - { - int format = ((arg >> 8) & 0xFF); - return "Texture " + std::to_string(index) + ": location = " + ptr_to_string((arg & 0x3) - 1) + - (((arg >> 2) & 0x1) ? " cubemap " : "") + " border type = " + - std::to_string((arg >> 3) & 0x1) + " dimension = " + std::to_string((arg >> 4) & 0xF) + - " format = " + - get_texture_format_name(format & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN)) + - ((format & CELL_GCM_TEXTURE_LN) ? "" : " swizzled") + - ((format & CELL_GCM_TEXTURE_UN) ? " unormalized coordinates" : "") + " mipmap levels = " + - std::to_string((arg >> 16) & 0xFFFF); - } - + /* std::string get_texture_wrap_mode(u8 wrap) { switch (rsx::to_texture_wrap_mode(wrap)) @@ -1012,22 +936,6 @@ namespace return "Error"; } - std::string get_zfunc_name(u8 op) - { - switch (op) - { - case 0: return "Never"; - case 1: return "Less"; - case 2: return "Equal"; - case 3: return "LEqual"; - case 4: return "Greater"; - case 5: return "NotEqual"; - case 6: return "GreaterOrEqual"; - case 7: return "Always"; - } - return "Error"; - } - std::string texture_address(usz index, u32 arg) { return "Texture " + std::to_string(index) + ": wrap_s = " + get_texture_wrap_mode(arg & 0xF) + @@ -1038,36 +946,6 @@ namespace std::to_string((arg >> 4) & 0xF) + " signed remap = " + std::to_string((arg >> 24) & 0xF); } - std::string get_texture_max_aniso_name(u8 aniso) - { - switch (rsx::to_texture_max_anisotropy(aniso)) - { - case rsx::texture_max_anisotropy::x1: return "1"; - case rsx::texture_max_anisotropy::x2: return "2"; - case rsx::texture_max_anisotropy::x4: return "4"; - case rsx::texture_max_anisotropy::x6: return "6"; - case rsx::texture_max_anisotropy::x8: return "8"; - case rsx::texture_max_anisotropy::x10: return "10"; - case rsx::texture_max_anisotropy::x12: return "12"; - case rsx::texture_max_anisotropy::x16: return "16"; - } - return "Error"; - } - - std::string texture_control0(usz index, u32 arg) - { - std::string result = "Texture " + std::to_string(index); - if ((arg >> 31) & 0x1) { - result += " min lod = " + std::to_string((arg >> 19) & 0xFFF) + " max lod = " + - std::to_string((arg >> 7) & 0xFFF) + " max aniso = " + - get_texture_max_aniso_name((arg >> 4) & 0x7) + " alpha kill = " + - (((arg >> 2) & 0x1) ? "true" : "false"); - } - else - result += " (disabled)"; - return result; - } - std::string get_remap_channel(u8 op) noexcept { switch (op) @@ -1088,12 +966,6 @@ namespace get_remap_channel((arg >> 6) & 0x3); } - std::string texture_control3(usz index, u32 arg) - { - return "Texture " + std::to_string(index) + " depth = " + std::to_string(arg >> 20) + - " pitch = " + std::to_string(arg & 0xFFFFF); - } - std::string texture_border_color(usz index, u32 arg) { return "Texture " + std::to_string(index) + " border color = " + std::to_string(arg); @@ -1107,32 +979,33 @@ namespace std::to_string((arg >> 13) & 0xF) + " a_signed = " + std::to_string((arg >> 28) & 0x1) + " r_signed = " + std::to_string((arg >> 29) & 0x1) + " g_signed = " + std::to_string((arg >> 30) & 0x1) + " b_signed = " + std::to_string((arg >> 31) & 0x1); - } + }*/ namespace { - template - auto register_pretty_printing(u32 arg) + template + std::string register_pretty_function(u32 /*id*/, u32 arg) { - typename rsx::registers_decoder::decoded_type decoded_value(arg); - return rsx::registers_decoder::dump(std::move(arg)); + return rsx::registers_decoder::dump(arg); } template - auto create_printing_table(std::integer_sequence seq) + std::array create_printing_table(std::integer_sequence seq) { - std::unordered_map result; - (result.insert({ - {opcode_list[Index * 5 + 0], ®ister_pretty_printing}, - {opcode_list[Index * 5 + 1], ®ister_pretty_printing}, - {opcode_list[Index * 5 + 2], ®ister_pretty_printing}, - {opcode_list[Index * 5 + 3], ®ister_pretty_printing}, - {opcode_list[Index * 5 + 4], ®ister_pretty_printing}}), ...); + std::array result{}; + + ((result[opcode_list[Index * 5 + 0]] = ®ister_pretty_function, + result[opcode_list[Index * 5 + 1]] = ®ister_pretty_function, + result[opcode_list[Index * 5 + 2]] = ®ister_pretty_function, + result[opcode_list[Index * 5 + 3]] = ®ister_pretty_function, + result[opcode_list[Index * 5 + 4]] = ®ister_pretty_function + ), ...); + return result; } } - const std::unordered_map printing_functions = + const auto printing_functions = create_printing_table(std::make_index_sequence()); static_assert(std::size(opcode_list) % 5 == 0); @@ -1141,8 +1014,6 @@ namespace 1) + " vertex starting from " + std::to_string(arg & 0xFFFFFF); } }, { NV4097_DRAW_INDEX_ARRAY, [](u32 arg) -> std::string { return "Draw " + std::to_string((arg >> 24) + 1) + " index starting from " + std::to_string(arg & 0xFFFFFF); } }, - { NV4097_SET_SEMAPHORE_OFFSET, [](u32 arg) -> std::string { return "Semaphore: @ " + - ptr_to_string(arg); } }, { NV4097_TEXTURE_READ_SEMAPHORE_RELEASE, [](u32 arg) -> std::string { return "Write semaphore value " + std::to_string(arg); } }, { NV4097_CLEAR_SURFACE, [](u32 arg) -> std::string { return "Clear surface " + std::string(arg & @@ -1151,12 +1022,20 @@ namespace };*/ } -std::function rsx::get_pretty_printing_function(u32 id) +std::add_pointer_t rsx::get_pretty_printing_function(u32 id) { - auto found = printing_functions.find(id); - if (found != printing_functions.end()) { - return found->second; + const auto found = id < printing_functions.size() ? printing_functions[id] : nullptr; + + if (found) + { + return found; } - return [=](u32 v) { return fmt::format("%s : 0x%08x", rsx::get_method_name(id), v); }; + return [](u32 id, u32 v) + { + const std::string name = rsx::get_method_name(id); + const std::string_view view = name, prefix = "CELL_GCM_"sv; + + return fmt::format("%s: 0x%08x", name.starts_with("CELL_GCM_"sv) ? view.substr(prefix.size()) : view, v); + }; } diff --git a/rpcs3/Emu/RSX/gcm_printing.h b/rpcs3/Emu/RSX/gcm_printing.h index f5e67aec6f..eb803f93b6 100644 --- a/rpcs3/Emu/RSX/gcm_printing.h +++ b/rpcs3/Emu/RSX/gcm_printing.h @@ -8,5 +8,5 @@ namespace rsx { std::string get_method_name(u32 id); - std::function get_pretty_printing_function(u32 id); + std::add_pointer_t get_pretty_printing_function(u32 id); } diff --git a/rpcs3/Emu/RSX/rsx_decode.h b/rpcs3/Emu/RSX/rsx_decode.h index be847d3ecd..b61ca242d0 100644 --- a/rpcs3/Emu/RSX/rsx_decode.h +++ b/rpcs3/Emu/RSX/rsx_decode.h @@ -5,40 +5,15 @@ #include "Utilities/StrFmt.h" #include #include +#include #include "gcm_enums.h" #include "rsx_utils.h" namespace rsx { std::string print_boolean(bool b); - std::string to_string(comparison_function f); - std::string to_string(stencil_op op); - std::string to_string(fog_mode op); - std::string to_string(logic_op op); - std::string to_string(front_face op); - std::string to_string(cull_face op); - std::string to_string(surface_target target); - std::string to_string(primitive_type draw_mode); - std::string to_string(blit_engine::transfer_operation op); - std::string to_string(blit_engine::transfer_source_format op); - std::string to_string(blit_engine::context_surface op); - std::string to_string(blit_engine::transfer_destination_format op); - std::string to_string(blend_equation op); - std::string to_string(blend_factor factor); - std::string to_string(window_origin origin); - std::string to_string(window_pixel_center in); - std::string to_string(user_clip_plane_op op); - std::string to_string(surface_depth_format format); - std::string to_string(surface_antialiasing format); - std::string to_string(surface_color_format format); - std::string to_string(index_array_type arg); - std::string to_string(blit_engine::context_dma op); - std::string to_string(blit_engine::transfer_origin op); - std::string to_string(blit_engine::transfer_interpolator op); - std::string to_string(shading_mode op); - std::string to_string(polygon_mode op); -template +template struct registers_decoder {}; @@ -49,6 +24,22 @@ constexpr T bf_decoder(u32 bits) return static_cast(bf_t::extract(bits)); } +template <> +struct registers_decoder +{ + struct decoded_type + { + const u32 value; + + decoded_type(u32 value) : value(value) {} + }; + + static std::string dump(const decoded_type& decoded) + { + return fmt::format("NV406E Ref: 0x%08x", decoded.value); + } +}; + template<> struct registers_decoder { @@ -71,9 +62,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Viewport: x = " + std::to_string(decoded_values.origin_x()) + " width = " + std::to_string(decoded_values.width()); + return fmt::format("Viewport: x: %u width: %u", decoded.origin_x(), decoded.width()); } }; @@ -99,9 +90,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Viewport: y = " + std::to_string(decoded_values.origin_y()) + " height = " + std::to_string(decoded_values.height()); + return fmt::format("Viewport: y: %u height: %u", decoded.origin_y(), decoded.height()); } }; @@ -127,9 +118,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Scissor: x = " + std::to_string(decoded_values.origin_x()) + " width = " + std::to_string(decoded_values.width()); + return "Scissor: x = " + std::to_string(decoded.origin_x()) + " width = " + std::to_string(decoded.width()); } }; @@ -155,9 +146,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Scissor: y = " + std::to_string(decoded_values.origin_y()) + " height = " + std::to_string(decoded_values.height()); + return "Scissor: y = " + std::to_string(decoded.origin_y()) + " height = " + std::to_string(decoded.height()); } }; @@ -183,9 +174,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: clip x = " + std::to_string(decoded_values.origin_x()) + " width = " + std::to_string(decoded_values.width()); + return "Surface: clip x = " + std::to_string(decoded.origin_x()) + " width = " + std::to_string(decoded.width()); } }; @@ -211,9 +202,9 @@ struct registers_decoder< NV4097_SET_SURFACE_CLIP_VERTICAL> } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: clip y = " + std::to_string(decoded_values.origin_y()) + " height = " + std::to_string(decoded_values.height()); + return "Surface: clip y = " + std::to_string(decoded.origin_y()) + " height = " + std::to_string(decoded.height()); } }; @@ -239,9 +230,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Clear: rect x = " + std::to_string(decoded_values.origin_x()) + " width = " + std::to_string(decoded_values.width()); + return "Clear: rect x = " + std::to_string(decoded.origin_x()) + " width = " + std::to_string(decoded.width()); } }; @@ -267,9 +258,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Clear: rect y = " + std::to_string(decoded_values.origin_y()) + " height = " + std::to_string(decoded_values.height()); + return "Clear: rect y = " + std::to_string(decoded.origin_y()) + " height = " + std::to_string(decoded.height()); } }; @@ -295,9 +286,9 @@ struct registers_decoder< NV3089_CLIP_POINT> } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Blit engine: clip x = " + std::to_string(decoded_values.clip_x()) + " y = " + std::to_string(decoded_values.clip_y()); + return "Blit engine: clip x = " + std::to_string(decoded.clip_x()) + " y = " + std::to_string(decoded.clip_y()); } }; @@ -323,9 +314,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Blit engine: clip width = " + std::to_string(decoded_values.clip_width()) + " height = " + std::to_string(decoded_values.clip_height()); + return "Blit engine: clip width = " + std::to_string(decoded.clip_width()) + " height = " + std::to_string(decoded.clip_height()); } }; @@ -351,9 +342,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Blit engine: output x = " + std::to_string(decoded_values.x()) + " y = " + std::to_string(decoded_values.y()); + return "Blit engine: output x = " + std::to_string(decoded.x()) + " y = " + std::to_string(decoded.y()); } }; @@ -379,9 +370,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Window: offset x = " + std::to_string(decoded_values.window_offset_x()) + " y = " + std::to_string(decoded_values.window_offset_y()); + return fmt::format("Window: offset x: %u y: %u", decoded.window_offset_x(), decoded.window_offset_y()); } }; @@ -408,9 +399,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Blit engine: output width = " + std::to_string(decoded_values.width()) + " height = " + std::to_string(decoded_values.height()); + return "Blit engine: output width = " + std::to_string(decoded.width()) + " height = " + std::to_string(decoded.height()); } }; @@ -436,9 +427,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Blit engine: input width = " + std::to_string(decoded_values.width()) + " height = " + std::to_string(decoded_values.height()); + return "Blit engine: input width = " + std::to_string(decoded.width()) + " height = " + std::to_string(decoded.height()); } }; @@ -464,9 +455,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Blit engine: output alignment = " + std::to_string(decoded_values.alignment()) + " pitch = " + std::to_string(decoded_values.pitch()); + return "Blit engine: output alignment = " + std::to_string(decoded.alignment()) + " pitch = " + std::to_string(decoded.pitch()); } }; @@ -492,9 +483,9 @@ struct registers_decoder< NV308A_POINT> } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV308A: x = " + std::to_string(decoded_values.x()) + " y = " + std::to_string(decoded_values.y()); + return "NV308A: x = " + std::to_string(decoded.x()) + " y = " + std::to_string(decoded.y()); } }; @@ -515,7 +506,7 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { std::string result = "Transform program enabled inputs:"; const std::string input_names[] = @@ -528,7 +519,7 @@ struct registers_decoder "in_tc4", "in_tc5", "in_tc6", "in_tc7" }; for (unsigned i = 0; i < 16; i++) - if (decoded_values.mask() & (1 << i)) + if (decoded.mask() & (1 << i)) result += input_names[i] + " "; return result; } @@ -551,11 +542,11 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { std::string result = "Frequency divider: "; for (unsigned i = 0; i < 16; i++) - if (decoded_values.frequency_divider_operation_mask() & (1 << i)) + if (decoded.frequency_divider_operation_mask() & (1 << i)) result += std::to_string(i) + " "; return result; } @@ -578,9 +569,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Depth: test " + print_boolean(decoded_values.depth_test_enabled()); + return "Depth: test " + print_boolean(decoded.depth_test_enabled()); } }; @@ -601,9 +592,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Depth: write " + print_boolean(decoded_values.depth_write_enabled()); + return "Depth: write " + print_boolean(decoded.depth_write_enabled()); } }; @@ -634,11 +625,11 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Depth: clip_enabled " + print_boolean(decoded_values.depth_clip_enabled()) + - " clamp " + print_boolean(decoded_values.depth_clamp_enabled()) + - " ignore_w " + print_boolean(decoded_values.depth_clip_ignore_w()); + return "Depth: clip_enabled " + print_boolean(decoded.depth_clip_enabled()) + + " clamp " + print_boolean(decoded.depth_clamp_enabled()) + + " ignore_w " + print_boolean(decoded.depth_clip_ignore_w()); } }; @@ -659,9 +650,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Alpha: test " + print_boolean(decoded_values.alpha_test_enabled()); + return "Alpha: test " + print_boolean(decoded.alpha_test_enabled()); } }; @@ -682,9 +673,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: test " + print_boolean(decoded_values.stencil_test_enabled()); + return "Stencil: test " + print_boolean(decoded.stencil_test_enabled()); } }; @@ -705,9 +696,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Restart Index: " + print_boolean(decoded_values.restart_index_enabled()); + return "Restart Index: " + print_boolean(decoded.restart_index_enabled()); } }; @@ -728,9 +719,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Depth: bound test " + print_boolean(decoded_values.depth_bound_enabled()); + return "Depth: bound test " + print_boolean(decoded.depth_bound_enabled()); } }; @@ -751,9 +742,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Logic: " + print_boolean(decoded_values.logic_op_enabled()); + return "Logic: " + print_boolean(decoded.logic_op_enabled()); } }; @@ -774,9 +765,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Dither: " + print_boolean(decoded_values.dither_enabled()); + return "Dither: " + print_boolean(decoded.dither_enabled()); } }; @@ -797,9 +788,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Blend: " + print_boolean(decoded_values.blend_enabled()); + return "Blend: " + print_boolean(decoded.blend_enabled()); } }; @@ -820,9 +811,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Line: smooth " + print_boolean(decoded_values.line_smooth_enabled()); + return "Line: smooth " + print_boolean(decoded.line_smooth_enabled()); } }; @@ -843,9 +834,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Polygon: offset point " + print_boolean(decoded_values.poly_offset_point_enabled()); + return "Polygon: offset point " + print_boolean(decoded.poly_offset_point_enabled()); } }; @@ -866,9 +857,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Polygon: offset line " + print_boolean(decoded_values.poly_offset_line_enabled()); + return "Polygon: offset line " + print_boolean(decoded.poly_offset_line_enabled()); } }; @@ -889,9 +880,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Polygon: offset fill " + print_boolean(decoded_values.poly_offset_fill_enabled()); + return "Polygon: offset fill " + print_boolean(decoded.poly_offset_fill_enabled()); } }; @@ -912,9 +903,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Cull face: " + print_boolean(decoded_values.cull_face_enabled()); + return "Cull face: " + print_boolean(decoded.cull_face_enabled()); } }; @@ -935,9 +926,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Polygon: smooth " + print_boolean(decoded_values.poly_smooth_enabled()); + return "Polygon: smooth " + print_boolean(decoded.poly_smooth_enabled()); } }; @@ -958,9 +949,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: per side " + print_boolean(decoded_values.two_sided_stencil_test_enabled()); + return "Stencil: per side " + print_boolean(decoded.two_sided_stencil_test_enabled()); } }; @@ -981,9 +972,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Light: per side " + print_boolean(decoded_values.two_sided_lighting_enabled()); + return "Light: per side " + print_boolean(decoded.two_sided_lighting_enabled()); } }; @@ -1004,9 +995,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Depth: bound min = " + std::to_string(decoded_values.depth_bound_min()); + return "Depth: bound min = " + std::to_string(decoded.depth_bound_min()); } }; @@ -1027,9 +1018,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Depth: bound max = " + std::to_string(decoded_values.depth_bound_max()); + return "Depth: bound max = " + std::to_string(decoded.depth_bound_max()); } }; @@ -1050,9 +1041,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Fog: param 0 = " + std::to_string(decoded_values.fog_param_0()); + return "Fog: param 0 = " + std::to_string(decoded.fog_param_0()); } }; @@ -1073,9 +1064,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Fog: param 1 = " + std::to_string(decoded_values.fog_param_1()); + return "Fog: param 1 = " + std::to_string(decoded.fog_param_1()); } }; @@ -1096,9 +1087,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Depth: clip min = " + std::to_string(decoded_values.clip_min()); + return "Depth: clip min = " + std::to_string(decoded.clip_min()); } }; @@ -1119,9 +1110,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Depth: clip max = " + std::to_string(decoded_values.clip_max()); + return "Depth: clip max = " + std::to_string(decoded.clip_max()); } }; @@ -1142,9 +1133,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Polygon: offset scale = " + std::to_string(decoded_values.polygon_offset_scale_factor()); + return "Polygon: offset scale = " + std::to_string(decoded.polygon_offset_scale_factor()); } }; @@ -1165,9 +1156,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Polygon: offset bias = " + std::to_string(decoded_values.polygon_offset_scale_bias()); + return "Polygon: offset bias = " + std::to_string(decoded.polygon_offset_scale_bias()); } }; @@ -1188,9 +1179,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Viewport: scale x = " + std::to_string(decoded_values.viewport_scale_x()); + return "Viewport: scale x = " + std::to_string(decoded.viewport_scale_x()); } }; @@ -1211,9 +1202,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Viewport: scale y = " + std::to_string(decoded_values.viewport_scale_y()); + return "Viewport: scale y = " + std::to_string(decoded.viewport_scale_y()); } }; @@ -1234,9 +1225,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Viewport: scale z = " + std::to_string(decoded_values.viewport_scale_z()); + return "Viewport: scale z = " + std::to_string(decoded.viewport_scale_z()); } }; @@ -1257,9 +1248,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Viewport: scale w = " + std::to_string(decoded_values.viewport_scale_w()); + return "Viewport: scale w = " + std::to_string(decoded.viewport_scale_w()); } }; @@ -1280,9 +1271,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Viewport: offset x = " + std::to_string(decoded_values.viewport_offset_x()); + return "Viewport: offset x = " + std::to_string(decoded.viewport_offset_x()); } }; @@ -1303,9 +1294,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Viewport: offset y = " + std::to_string(decoded_values.viewport_offset_y()); + return "Viewport: offset y = " + std::to_string(decoded.viewport_offset_y()); } }; @@ -1326,9 +1317,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Viewport: offset z = " + std::to_string(decoded_values.viewport_offset_z()); + return "Viewport: offset z = " + std::to_string(decoded.viewport_offset_z()); } }; @@ -1349,9 +1340,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Viewport: offset w = " + std::to_string(decoded_values.viewport_offset_w()); + return "Viewport: offset w = " + std::to_string(decoded.viewport_offset_w()); } }; @@ -1372,9 +1363,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Restart index: " + std::to_string(decoded_values.restart_index()); + return "Restart index: " + std::to_string(decoded.restart_index()); } }; @@ -1395,9 +1386,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: A offset " + std::to_string(decoded_values.surface_a_offset()); + return fmt::format("Surface: A offset 0x%x", decoded.surface_a_offset()); } }; @@ -1418,9 +1409,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: B offset " + std::to_string(decoded_values.surface_b_offset()); + return fmt::format("Surface: B offset 0x%x", decoded.surface_b_offset()); } }; @@ -1441,9 +1432,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: C offset " + std::to_string(decoded_values.surface_c_offset()); + return fmt::format("Surface: C offset 0x%x", decoded.surface_c_offset()); } }; @@ -1464,9 +1455,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: D offset " + std::to_string(decoded_values.surface_d_offset()); + return fmt::format("Surface: D offset 0x%x", decoded.surface_d_offset()); } }; @@ -1487,9 +1478,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: A pitch " + std::to_string(decoded_values.surface_a_pitch()); + return "Surface: A pitch " + std::to_string(decoded.surface_a_pitch()); } }; @@ -1510,9 +1501,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: B pitch " + std::to_string(decoded_values.surface_b_pitch()); + return "Surface: B pitch " + std::to_string(decoded.surface_b_pitch()); } }; @@ -1533,9 +1524,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: C pitch " + std::to_string(decoded_values.surface_c_pitch()); + return "Surface: C pitch " + std::to_string(decoded.surface_c_pitch()); } }; @@ -1556,9 +1547,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: D pitch " + std::to_string(decoded_values.surface_d_pitch()); + return "Surface: D pitch " + std::to_string(decoded.surface_d_pitch()); } }; @@ -1579,9 +1570,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: Z offset " + std::to_string(decoded_values.surface_z_offset()); + return "Surface: Z offset " + std::to_string(decoded.surface_z_offset()); } }; @@ -1602,9 +1593,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: Z pitch " + std::to_string(decoded_values.surface_z_pitch()); + return "Surface: Z pitch " + std::to_string(decoded.surface_z_pitch()); } }; @@ -1625,7 +1616,7 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { const std::string output_names[] = { @@ -1654,7 +1645,7 @@ struct registers_decoder }; std::string result = "Transform program outputs:"; for (unsigned i = 0; i < 22; i++) - if (decoded_values.output_mask() & (1 << i)) + if (decoded.output_mask() & (1 << i)) result += output_names[i] + " "; return result; } @@ -1677,12 +1668,12 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Shader control: raw_value =" + std::to_string(decoded_values.shader_ctrl()) + - " reg_count = " + std::to_string((decoded_values.shader_ctrl() >> 24) & 0xFF) + - ((decoded_values.shader_ctrl() & CELL_GCM_SHADER_CONTROL_DEPTH_EXPORT) ? " depth_replace " : "") + - ((decoded_values.shader_ctrl() & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS) ? " 32b_exports " : ""); + return "Shader control: raw_value =" + std::to_string(decoded.shader_ctrl()) + + " reg_count = " + std::to_string((decoded.shader_ctrl() >> 24) & 0xFF) + + ((decoded.shader_ctrl() & CELL_GCM_SHADER_CONTROL_DEPTH_EXPORT) ? " depth_replace " : "") + + ((decoded.shader_ctrl() & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS) ? " 32b_exports " : ""); } }; @@ -1703,9 +1694,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Shader packer control: srgb_enabled = " + std::to_string(decoded_values.srgb_output_enabled()); + return "Shader packer control: srgb_enabled = " + std::to_string(decoded.srgb_output_enabled()); } }; @@ -1726,9 +1717,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Vertex: base offset " + std::to_string(decoded_values.vertex_data_base_offset()); + return fmt::format("Vertex: base offset 0x%x", decoded.vertex_data_base_offset()); } }; @@ -1749,9 +1740,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Index: array offset " + std::to_string(decoded_values.index_array_offset()); + return fmt::format("Index: array offset 0x%x", decoded.index_array_offset()); } }; @@ -1772,9 +1763,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Vertex: base index " + std::to_string(decoded_values.vertex_data_base_index()); + return "Vertex: base index " + std::to_string(decoded.vertex_data_base_index()); } }; @@ -1795,9 +1786,10 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Shader: program offset = " + std::to_string(decoded_values.shader_program_address()); + const u32 address = decoded.shader_program_address(); + return fmt::format("Shader: %s, offset: 0x%x", CellGcmLocation{(address & 3) - 1}, address & ~3); } }; @@ -1818,9 +1810,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Transform program: start = " + std::to_string(decoded_values.transform_program_start()); + return "Transform program: start = " + std::to_string(decoded.transform_program_start()); } }; @@ -1835,15 +1827,15 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u32 context_dma() const + CellGcmLocation context_dma() const { - return value; + return CellGcmLocation{value}; } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV406E semaphore: context = " + std::to_string(decoded_values.context_dma()); + return fmt::format("NV406E semaphore: context: %s", decoded.context_dma()); } }; @@ -1865,9 +1857,42 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV406E semaphore: offset = " + std::to_string(decoded_values.semaphore_offset()); + return fmt::format("NV406E semaphore: offset: 0x%x", decoded.semaphore_offset()); + } +}; + +template <> +struct registers_decoder +{ + struct decoded_type + { + const u32 value; + + decoded_type(u32 value) : value(value) {} + }; + + static std::string dump(const decoded_type& decoded) + { + return fmt::format("NV409E semaphore: release: 0x%x", decoded.value); + } +}; + + +template <> +struct registers_decoder +{ + struct decoded_type + { + const u32 value; + + decoded_type(u32 value) : value(value) {} + }; + + static std::string dump(const decoded_type& decoded) + { + return fmt::format("NV409E semaphore: acquire: 0x%x", decoded.value); } }; @@ -1882,15 +1907,15 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u32 context_dma() const + CellGcmLocation context_dma() const { - return value; + return CellGcmLocation{value}; } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV4097 semaphore: context = " + std::to_string(decoded_values.context_dma()); + return fmt::format("NV4097 semaphore: context: %s", decoded.context_dma()); } }; @@ -1911,9 +1936,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "semaphore: offset = " + std::to_string(decoded_values.semaphore_offset()); + return fmt::format("NV4097 semaphore: offset: 0x%x", decoded.semaphore_offset()); } }; @@ -1934,9 +1959,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV3089: input offset = " + std::to_string(decoded_values.input_offset()); + return fmt::format("NV3089: input offset: 0x%x", decoded.input_offset()); } }; @@ -1957,9 +1982,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV3062: output offset = " + std::to_string(decoded_values.output_offset()); + return fmt::format("NV3062: output offset: 0x%x", decoded.output_offset()); } }; @@ -1980,9 +2005,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV309E: offset = " + std::to_string(decoded_values.offset()); + return fmt::format("NV309E: offset: 0x%x", decoded.offset()); } }; @@ -2012,9 +2037,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV3089: dsdx = " + std::to_string(decoded_values.ds_dx()); + return "NV3089: dsdx = " + std::to_string(decoded.ds_dx()); } }; @@ -2044,9 +2069,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV3089: dtdy = " + std::to_string(decoded_values.dt_dy()); + return "NV3089: dtdy = " + std::to_string(decoded.dt_dy()); } }; @@ -2067,9 +2092,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV0039: input pitch = " + std::to_string(decoded_values.input_pitch()); + return "NV0039: input pitch = " + std::to_string(decoded.input_pitch()); } }; @@ -2090,9 +2115,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV0039: output pitch = " + std::to_string(decoded_values.output_pitch()); + return "NV0039: output pitch = " + std::to_string(decoded.output_pitch()); } }; @@ -2113,9 +2138,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV0039: line length input = " + std::to_string(decoded_values.input_line_length()); + return "NV0039: line length input = " + std::to_string(decoded.input_line_length()); } }; @@ -2136,9 +2161,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV0039: line count = " + std::to_string(decoded_values.line_count()); + return "NV0039: line count = " + std::to_string(decoded.line_count()); } }; @@ -2159,9 +2184,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV0039: output offset = " + std::to_string(decoded_values.output_offset()); + return fmt::format("NV0039: output offset: 0x%x", decoded.output_offset()); } }; @@ -2182,9 +2207,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV0039: input offset = " + std::to_string(decoded_values.input_offset()); + return fmt::format("NV0039: input offset: 00x%x", decoded.input_offset()); } }; @@ -2205,9 +2230,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Depth: compare_function = " + to_string(decoded_values.depth_func()); + return fmt::format("Depth: compare_function: %s", decoded.depth_func()); } }; @@ -2228,9 +2253,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: (front) compare_function = " + to_string(decoded_values.stencil_func()); + return fmt::format("Stencil: (front) compare_function: %s", decoded.stencil_func()); } }; @@ -2251,9 +2276,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: back compare_function = " + to_string(decoded_values.back_stencil_func()); + return fmt::format("Stencil: back compare_function: %s", decoded.back_stencil_func()); } }; @@ -2274,9 +2299,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Alpha: compare_function = " + to_string(decoded_values.alpha_func()); + return fmt::format("Alpha: compare_function: %s", decoded.alpha_func()); } }; @@ -2297,9 +2322,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: (front) fail op = " + to_string(decoded_values.fail()); + return fmt::format("Stencil: (front) fail op: %s", decoded.fail()); } }; @@ -2320,9 +2345,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: (front) zfail op = " + to_string(decoded_values.zfail()); + return fmt::format("Stencil: (front) zfail op: %s", decoded.zfail()); } }; @@ -2343,9 +2368,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: (front) zpass op = " + to_string(decoded_values.zpass()); + return fmt::format("Stencil: (front) zpass op: %s", decoded.zpass()); } }; @@ -2366,9 +2391,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: (back) fail op = " + to_string(decoded_values.back_fail()); + return fmt::format("Stencil: (back) fail op: %s", decoded.back_fail()); } }; @@ -2389,9 +2414,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: (back) zfail op = " + to_string(decoded_values.back_zfail()); + return fmt::format("Stencil: (back) zfail op: %s", decoded.back_zfail()); } }; @@ -2412,9 +2437,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: (back) zpass op = " + to_string(decoded_values.back_zpass()); + return fmt::format("Stencil: (back) zpass op: %s", decoded.back_zpass()); } }; @@ -2435,9 +2460,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: (front) func ref = " + std::to_string(decoded_values.stencil_func_ref()); + return "Stencil: (front) func ref = " + std::to_string(decoded.stencil_func_ref()); } }; @@ -2458,9 +2483,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: (back) func ref = " + std::to_string(decoded_values.back_stencil_func_ref()); + return "Stencil: (back) func ref = " + std::to_string(decoded.back_stencil_func_ref()); } }; @@ -2481,9 +2506,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: (front) func mask = " + std::to_string(decoded_values.stencil_func_mask()); + return "Stencil: (front) func mask = " + std::to_string(decoded.stencil_func_mask()); } }; @@ -2504,9 +2529,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: (back) func mask = " + std::to_string(decoded_values.back_stencil_func_mask()); + return "Stencil: (back) func mask = " + std::to_string(decoded.back_stencil_func_mask()); } }; @@ -2537,10 +2562,10 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Alpha: ref unorm8 = " + std::to_string(decoded_values.alpha_ref8()) + - " f16 = " + std::to_string(decoded_values.alpha_ref16()); + return "Alpha: ref unorm8 = " + std::to_string(decoded.alpha_ref8()) + + " f16 = " + std::to_string(decoded.alpha_ref16()); } }; @@ -2561,12 +2586,12 @@ struct registers_decoder u8 alpha() const { return bf_decoder<24, 8>(value); } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Clear: R = " + std::to_string(decoded_values.red()) + - " G = " + std::to_string(decoded_values.green()) + - " B = " + std::to_string(decoded_values.blue()) + - " A = " + std::to_string(decoded_values.alpha()); + return "Clear: R = " + std::to_string(decoded.red()) + + " G = " + std::to_string(decoded.green()) + + " B = " + std::to_string(decoded.blue()) + + " A = " + std::to_string(decoded.alpha()); } }; @@ -2587,9 +2612,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: (front) mask = " + std::to_string(decoded_values.stencil_mask()); + return "Stencil: (front) mask = " + std::to_string(decoded.stencil_mask()); } }; @@ -2610,9 +2635,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Stencil: (back) mask = " + std::to_string(decoded_values.back_stencil_mask()); + return "Stencil: (back) mask = " + std::to_string(decoded.back_stencil_mask()); } }; @@ -2633,9 +2658,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Logic: op = " + to_string(decoded_values.logic_operation()); + return fmt::format("Logic: op: %s", decoded.logic_operation()); } }; @@ -2656,9 +2681,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Front Face: " + to_string(decoded_values.front_face_mode()); + return fmt::format("Front Face: %s", decoded.front_face_mode()); } }; @@ -2680,9 +2705,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Cull Face: " + to_string(decoded_values.cull_face_mode()); + return fmt::format("Cull Face: %s", decoded.cull_face_mode()); } }; @@ -2703,9 +2728,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: Color target(s) = " + to_string(decoded_values.target()); + return fmt::format("Surface: Color target(s): %s", decoded.target()); } }; @@ -2726,9 +2751,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Fog: " + to_string(decoded_values.fog_equation()); + return fmt::format("Fog: %s", decoded.fog_equation()); } }; @@ -2749,9 +2774,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "-- " + to_string(decoded_values.primitive()) + " --"; + return fmt::format("Primitive: %s", decoded.primitive()); } }; @@ -2772,9 +2797,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV3089: op = " + to_string(decoded_values.transfer_op()); + return fmt::format("NV3089: op: %s", decoded.transfer_op()); } }; @@ -2795,9 +2820,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV3089: source fmt = " + to_string(decoded_values.transfer_source_fmt()); + return fmt::format("NV3089: source fmt: %s", decoded.transfer_source_fmt()); } }; @@ -2818,9 +2843,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV3089: context surface = " + to_string(decoded_values.ctx_surface()); + return fmt::format("NV3089: context surface: %s", decoded.ctx_surface()); } }; @@ -2841,9 +2866,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV3062: output fmt = " + to_string(decoded_values.transfer_dest_fmt()); + return fmt::format("NV3062: output fmt: %s", decoded.transfer_dest_fmt()); } }; @@ -2878,10 +2903,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Blend: equation rgb = " + to_string(decoded_values.blend_rgb()) + - " a = " + to_string(decoded_values.blend_a()); + return fmt::format("Blend: equation rgb: %s a: %s", decoded.blend_rgb(), decoded.blend_a()); } }; @@ -2916,10 +2940,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Blend: sfactor rgb = " + to_string(decoded_values.src_blend_rgb()) + - " a = " + to_string(decoded_values.src_blend_a()); + return fmt::format("Blend: sfactor rgb: %s a: %s", decoded.src_blend_rgb(), decoded.src_blend_a()); } }; @@ -2954,10 +2977,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Blend: dfactor rgb = " + to_string(decoded_values.dst_blend_rgb()) + - " a = " + to_string(decoded_values.dst_blend_a()); + return fmt::format("Blend: dfactor rgb: %s a: %s", decoded.dst_blend_rgb(), decoded.dst_blend_a()); } }; @@ -2998,12 +3020,12 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: color mask A = " + print_boolean(decoded_values.color_a()) + - " R = " + print_boolean(decoded_values.color_r()) + - " G = " + print_boolean(decoded_values.color_g()) + - " B = " + print_boolean(decoded_values.color_b()); + return "Surface: color mask A = " + print_boolean(decoded.color_a()) + + " R = " + print_boolean(decoded.color_r()) + + " G = " + print_boolean(decoded.color_g()) + + " B = " + print_boolean(decoded.color_b()); } }; @@ -3044,17 +3066,17 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { std::string result; for (int index = 1; index < 4; ++index) { result += fmt::format("Surface[%d]: A:%d R:%d G:%d B:%d\n", index, - decoded_values.color_a(index), - decoded_values.color_r(index), - decoded_values.color_g(index), - decoded_values.color_b(index)); + decoded.color_a(index), + decoded.color_r(index), + decoded.color_g(index), + decoded.color_b(index)); } return "Color Mask MRT:\n" + result; @@ -3091,11 +3113,10 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Viewport: height = " + std::to_string(decoded_values.window_shader_height()) + - " origin = " + to_string(decoded_values.window_shader_origin()) + - " pixel center = " + to_string(decoded_values.window_shader_pixel_center()); + return fmt::format("Viewport: height: %u origin: %s pixel center: %s", decoded.window_shader_height() + , decoded.window_shader_origin(), decoded.window_shader_pixel_center()); } }; @@ -3126,11 +3147,11 @@ struct registers_decoder } }; - static std::string dump(decoded_type&& decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Blend: mrt1 = " + print_boolean(decoded_values.blend_surface_b()) + - " mrt2 = " + print_boolean(decoded_values.blend_surface_c()) + - " mrt3 = " + print_boolean(decoded_values.blend_surface_d()); + return "Blend: mrt1 = " + print_boolean(decoded.blend_surface_b()) + + " mrt2 = " + print_boolean(decoded.blend_surface_c()) + + " mrt3 = " + print_boolean(decoded.blend_surface_d()); } }; @@ -3184,14 +3205,15 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "User clip: UC0 = " + to_string(decoded_values.clip_plane0()) + - " UC1 = " + to_string(decoded_values.clip_plane1()) + - " UC2 = " + to_string(decoded_values.clip_plane2()) + - " UC2 = " + to_string(decoded_values.clip_plane3()) + - " UC2 = " + to_string(decoded_values.clip_plane4()) + - " UC2 = " + to_string(decoded_values.clip_plane5()); + return fmt::format("User clip: UC0: %s UC1: %s UC2: %s UC3: %s UC4: %s" + , decoded.clip_plane0() + , decoded.clip_plane1() + , decoded.clip_plane2() + , decoded.clip_plane3() + , decoded.clip_plane4() + , decoded.clip_plane5()); } }; @@ -3212,9 +3234,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Line width: " + std::to_string(decoded_values.line_width()); + return "Line width: " + std::to_string(decoded.line_width()); } }; @@ -3235,9 +3257,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Point size: " + std::to_string(decoded_values.point_size()); + return "Point size: " + std::to_string(decoded.point_size()); } }; @@ -3263,10 +3285,10 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Point sprite: enabled = " + print_boolean(decoded_values.enabled()) + - "override mask = " + fmt::format("0x%x", decoded_values.texcoord_mask()); + return "Point sprite: enabled = " + print_boolean(decoded.enabled()) + + "override mask = " + fmt::format("0x%x", decoded.texcoord_mask()); } }; @@ -3317,13 +3339,10 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: Color format = " + to_string(decoded_values.color_fmt()) + - " DepthStencil format = " + to_string(decoded_values.depth_fmt()) + - " Anti aliasing =" + to_string(decoded_values.antialias()) + - " w = " + std::to_string(decoded_values.log2width()) + - " h = " + std::to_string(decoded_values.log2height()); + return fmt::format("Surface: Color format: %s DepthStencil format: %s Anti aliasing: %s w: %u h: %u", decoded.color_fmt() + , decoded.depth_fmt(), decoded.antialias(), decoded.log2width(), decoded.log2height()); } }; @@ -3355,11 +3374,11 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Clear: Z24 = " + std::to_string(decoded_values.clear_z(true)) + - " z16 = " + std::to_string(decoded_values.clear_z(false)) + - " Stencil = " + std::to_string(decoded_values.clear_stencil()); + return "Clear: Z24 = " + std::to_string(decoded.clear_z(true)) + + " z16 = " + std::to_string(decoded.clear_z(false)) + + " Stencil = " + std::to_string(decoded.clear_stencil()); } }; @@ -3376,9 +3395,9 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u8 index_dma() const + CellGcmLocation index_dma() const { - return bf_decoder<0, 4>(value); + return CellGcmLocation{bf_decoder<0, 4>(value)}; } index_array_type type() const @@ -3388,10 +3407,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Index: type = " + to_string(decoded_values.type()) + - " dma = " + std::to_string(decoded_values.index_dma()); + return fmt::format("Index: type: %s dma: %s", decoded.type(), decoded.index_dma()); } }; @@ -3406,15 +3424,15 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u32 dma_surface_a() const + CellGcmLocation dma_surface_a() const { - return value; + return CellGcmLocation{value}; } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: A DMA = " + std::to_string(decoded_values.dma_surface_a()); + return fmt::format("Surface: A DMA: %s", decoded.dma_surface_a()); } }; @@ -3429,15 +3447,15 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u32 dma_surface_b() const + CellGcmLocation dma_surface_b() const { - return value; + return CellGcmLocation{value}; } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: B DMA = " + std::to_string(decoded_values.dma_surface_b()); + return fmt::format("Surface: B DMA: %s", decoded.dma_surface_b()); } }; @@ -3452,15 +3470,15 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u32 dma_surface_c() const + CellGcmLocation dma_surface_c() const { - return value; + return CellGcmLocation{value}; } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: C DMA = " + std::to_string(decoded_values.dma_surface_c()); + return fmt::format("Surface: C DMA: %s", decoded.dma_surface_c()); } }; @@ -3475,15 +3493,15 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u32 dma_surface_d() const + CellGcmLocation dma_surface_d() const { - return value; + return CellGcmLocation{value}; } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: D DMA = " + std::to_string(decoded_values.dma_surface_d()); + return fmt::format("Surface: D DMA: %s", decoded.dma_surface_d()); } }; @@ -3498,15 +3516,15 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u32 dma_surface_z() const + CellGcmLocation dma_surface_z() const { - return value; + return CellGcmLocation{value}; } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Surface: Z DMA = " + std::to_string(decoded_values.dma_surface_z()); + return fmt::format("Surface: Z DMA: %s", decoded.dma_surface_z()); } }; @@ -3521,15 +3539,15 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u32 context_dma() const + CellGcmLocation context_dma() const { - return value; + return CellGcmLocation{value}; } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV3089: input DMA = " + std::to_string(decoded_values.context_dma()); + return fmt::format("NV3089: input DMA: %s", decoded.context_dma()); } }; @@ -3544,15 +3562,15 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u32 output_dma() const + CellGcmLocation output_dma() const { - return value; + return CellGcmLocation{value}; } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV3062: output DMA = " + std::to_string(decoded_values.output_dma()); + return fmt::format("NV3062: output DMA: %s", decoded.output_dma()); } }; @@ -3567,15 +3585,15 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u32 context_dma() const + CellGcmLocation context_dma() const { - return value; + return CellGcmLocation{value}; } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV309E: output DMA = " + std::to_string(decoded_values.context_dma()); + return fmt::format("NV309E: output DMA: %s", decoded.context_dma()); } }; @@ -3590,15 +3608,15 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u32 output_dma() const + CellGcmLocation output_dma() const { - return value; + return CellGcmLocation{value}; } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV0039: output DMA = " + std::to_string(decoded_values.output_dma()); + return fmt::format("NV0039: output DMA: %s", decoded.output_dma()); } }; @@ -3613,15 +3631,15 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u32 input_dma() const + CellGcmLocation input_dma() const { - return value; + return CellGcmLocation{value}; } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV0039: input DMA = " + std::to_string(decoded_values.input_dma()); + return fmt::format("NV0039: input DMA: %s", decoded.input_dma()); } }; @@ -3642,9 +3660,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Report: context DMA = " + to_string(decoded_values.context_dma_report()); + return fmt::format("REPORT: context DMA: %s", decoded.context_dma_report()); } }; @@ -3659,15 +3677,15 @@ struct registers_decoder public: decoded_type(u32 value) : value(value) {} - u32 context_dma_notify() const + CellGcmLocation context_dma_notify() const { - return value; + return CellGcmLocation{value}; } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return fmt::format("NOTIFY: context DMA = 0x%x, index=%d", decoded_values.context_dma_notify(), (decoded_values.context_dma_notify() & 7) ^ 7); + return fmt::format("NOTIFY: context DMA: %s, index: %d", decoded.context_dma_notify(), (decoded.context_dma_notify() & 7) ^ 7); } }; @@ -3701,11 +3719,10 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV3089: input fmt " + std::to_string(decoded_values.format()) + - " origin = " + to_string(decoded_values.transfer_origin()) + - " interp = " + to_string(decoded_values.transfer_interpolator()); + return fmt::format("NV3089: input fmt: %u origin: %s interp: %s", decoded.format() + , decoded.transfer_origin(), decoded.transfer_interpolator()); } }; @@ -3738,11 +3755,10 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV309E: output fmt = " + to_string(decoded_values.format()) + - " log2-width = " + std::to_string(decoded_values.sw_width_log2()) + - " log2-height = " + std::to_string(decoded_values.sw_height_log2()); + return fmt::format("NV309E: output fmt: %s log2-width: %u log2-height: %u", decoded.format(), + decoded.sw_width_log2(), decoded.sw_height_log2()); } }; @@ -3772,10 +3788,10 @@ struct registers_decoder return std::make_tuple(static_cast(value & 0xff), static_cast(value >> 8)); } - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV0039: input format = " + std::to_string(decoded_values.input_format()) + - " output format = " + std::to_string(decoded_values.output_format()); + return "NV0039: input format = " + std::to_string(decoded.input_format()) + + " output format = " + std::to_string(decoded.output_format()); } }; @@ -3801,10 +3817,10 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Blend color: 16b BA = " + std::to_string(decoded_values.blue()) + - ", " + std::to_string(decoded_values.alpha()); + return "Blend color: 16b BA = " + std::to_string(decoded.blue()) + + ", " + std::to_string(decoded.alpha()); } }; @@ -3850,11 +3866,11 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { return "Blend color: 8b BGRA = " + - std::to_string(decoded_values.blue8()) + ", " + std::to_string(decoded_values.green8()) + ", " + std::to_string(decoded_values.red8()) + ", " + std::to_string(decoded_values.alpha8()) + - " 16b RG = " + std::to_string(decoded_values.red16()) + ", " + std::to_string(decoded_values.green16()); + std::to_string(decoded.blue8()) + ", " + std::to_string(decoded.green8()) + ", " + std::to_string(decoded.red8()) + ", " + std::to_string(decoded.alpha8()) + + " 16b RG = " + std::to_string(decoded.red16()) + ", " + std::to_string(decoded.green16()); } }; @@ -3892,10 +3908,10 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "NV3089: in x = " + std::to_string(decoded_values.x()) + - " y = " + std::to_string(decoded_values.y()); + return "NV3089: in x = " + std::to_string(decoded.x()) + + " y = " + std::to_string(decoded.y()); } }; @@ -3907,7 +3923,7 @@ struct registers_decoder decoded_type(u32) {} }; - static std::string dump(u32 &&) + static std::string dump(u32) { return "(nop)"; } @@ -3921,7 +3937,7 @@ struct registers_decoder decoded_type(u32) {} }; - static std::string dump(u32 &&) + static std::string dump(u32) { return "(invalidate vertex cache file)"; } @@ -3935,7 +3951,7 @@ struct registers_decoder decoded_type(u32) {} }; - static std::string dump(u32 &&) + static std::string dump(u32) { return "(invalidate vertex file)"; } @@ -3973,12 +3989,12 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Anti_aliasing: " + print_boolean(decoded_values.msaa_enabled()) + - " alpha_to_coverage = " + print_boolean(decoded_values.msaa_alpha_to_coverage()) + - " alpha_to_one = " + print_boolean(decoded_values.msaa_alpha_to_one()) + - " sample_mask = " + std::to_string(decoded_values.msaa_sample_mask()); + return "Anti_aliasing: " + print_boolean(decoded.msaa_enabled()) + + " alpha_to_coverage = " + print_boolean(decoded.msaa_alpha_to_coverage()) + + " alpha_to_one = " + print_boolean(decoded.msaa_alpha_to_one()) + + " sample_mask = " + std::to_string(decoded.msaa_sample_mask()); } }; @@ -3999,9 +4015,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Shading mode: " + to_string(decoded_values.shading()); + return fmt::format("Shading mode: %s", decoded.shading()); } }; @@ -4022,9 +4038,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Front polygon mode: " + to_string(decoded_values.front_polygon_mode()); + return fmt::format("Front polygon mode: %s", decoded.front_polygon_mode()); } }; @@ -4045,9 +4061,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "back polygon mode: " + to_string(decoded_values.back_polygon_mode()); + return fmt::format("back polygon mode: %s", decoded.back_polygon_mode()); } }; @@ -4068,9 +4084,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Set transform constant pointer at " + std::to_string(decoded_values.transform_constant_load()); + return fmt::format("Transform constant load: %u", decoded.transform_constant_load()); } }; @@ -4091,9 +4107,78 @@ struct registers_decoder } }; - static std::string dump(decoded_type&& decoded_values) + static std::string dump(const decoded_type& decoded) { - return std::string("polygon_stipple: ") + (decoded_values.enabled()? "true" : "false"); + return fmt::format("polygon_stipple: %s", print_boolean(decoded.enabled())); + } +}; + +template <> +struct registers_decoder +{ + struct decoded_type + { + private: + u32 value; + + public: + decoded_type(u32 value) : value(value) {} + + bool enabled() const + { + return value > 0; + } + }; + + static std::string dump(const decoded_type& decoded) + { + return fmt::format("ZCULL: %s", print_boolean(decoded.enabled())); + } +}; + +template <> +struct registers_decoder +{ + struct decoded_type + { + private: + u32 value; + + public: + decoded_type(u32 value) : value(value) {} + + bool enabled() const + { + return value > 0; + } + }; + + static std::string dump(const decoded_type& decoded) + { + return fmt::format("ZCULL: stats %s", print_boolean(decoded.enabled())); + } +}; + +template <> +struct registers_decoder +{ + struct decoded_type + { + private: + u32 value; + + public: + decoded_type(u32 value) : value(value) {} + + bool enabled() const + { + return value > 0; + } + }; + + static std::string dump(const decoded_type& decoded) + { + return fmt::format("ZCULL: pixel count %s", print_boolean(decoded.enabled())); } }; @@ -4156,17 +4241,17 @@ struct transform_constant_helper static constexpr u32 reg = index / 4; static constexpr u8 subreg = index % 4; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - auto get_subreg_name = [](u8 subreg) -> std::string + auto get_subreg_name = [](u8 subreg) -> std::string_view { - return subreg == 0 ? "x" : - subreg == 1 ? "y" : - subreg == 2 ? "z" : - "w"; + return subreg == 0 ? "x"sv : + subreg == 1 ? "y"sv : + subreg == 2 ? "z"sv : + "w"sv; }; - return "TransformConstant[base + " + std::to_string(reg) + "]." + get_subreg_name(subreg) + " = " + std::to_string(decoded_values.constant_value()); + return fmt::format("TransformConstant[%u].%s: %g (0x%08x)", reg, get_subreg_name(subreg), decoded.constant_value(), std::bit_cast(decoded.constant_value())); } }; @@ -4185,9 +4270,9 @@ struct transform_program_helper decoded_type(u32 value) : value(value) {} }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Transform Program (" + std::to_string(index) + "):"+ std::to_string(decoded_values.value); + return fmt::format("Transform Program (%u): 0x%08x", index, decoded.value); } }; @@ -4208,9 +4293,9 @@ struct registers_decoder } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Transform Program pointer :" + std::to_string(decoded_values.transform_program_load()); + return fmt::format("Transform Program Load: %u", decoded.transform_program_load()); } }; @@ -4241,10 +4326,10 @@ struct registers_decoder } }; - static std::string dump(decoded_type&& decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Draw vertexes range [" + std::to_string(decoded_values.start()) + ", " + - std::to_string(decoded_values.start() + decoded_values.count()) + "]"; + return "Draw vertexes range [" + std::to_string(decoded.start()) + ", " + + std::to_string(decoded.start() + decoded.count()) + "]"; } }; @@ -4270,10 +4355,10 @@ struct registers_decoder } }; - static std::string dump(decoded_type&& decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Draw vertexes range [IdxArray[" + std::to_string(decoded_values.start()) + - "], IdxArray[" + std::to_string(decoded_values.start() + decoded_values.count()) + "}]"; + return "Draw vertexes range [IdxArray[" + std::to_string(decoded.start()) + + "], IdxArray[" + std::to_string(decoded.start() + decoded.count()) + "}]"; } }; @@ -4294,15 +4379,15 @@ struct registers_decoder } }; - static std::string dump(decoded_type&& decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Depth float enabled: " + (decoded_values.depth_float() ? std::string("true") : std::string("false")); + return fmt::format("Depth float: %s", print_boolean(decoded.depth_float())); } }; #define TRANSFORM_PROGRAM(index) template<> struct registers_decoder : public transform_program_helper {}; #define DECLARE_TRANSFORM_PROGRAM(index) NV4097_SET_TRANSFORM_PROGRAM + index, -EXPAND_RANGE_512(0, TRANSFORM_PROGRAM) +EXPAND_RANGE_32(0, TRANSFORM_PROGRAM) template struct vertex_array_helper @@ -4340,10 +4425,10 @@ struct vertex_array_helper } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - if (decoded_values.size() == 0) - return "(disabled)"; + if (decoded.size() == 0) + return fmt::format("Vertex Data Array %u (disabled)", index); auto print_vertex_attribute_format = [](rsx::vertex_base_type type) -> std::string { @@ -4360,10 +4445,10 @@ struct vertex_array_helper fmt::throw_exception("Unexpected enum found"); }; - return "Vertex array " + std::to_string(index) + ": Type = " + print_vertex_attribute_format(decoded_values.type()) + - " size = " + std::to_string(decoded_values.size()) + - " stride = " + std::to_string(decoded_values.stride()) + - " frequency = " + std::to_string(decoded_values.frequency()); + return "Vertex array " + std::to_string(index) + ": Type = " + print_vertex_attribute_format(decoded.type()) + + " size = " + std::to_string(decoded.size()) + + " stride = " + std::to_string(decoded.stride()) + + " frequency = " + std::to_string(decoded.frequency()); } }; @@ -4388,9 +4473,9 @@ struct vertex_array_offset_helper } }; - static std::string dump(decoded_type &&decoded_values) + static std::string dump(const decoded_type& decoded) { - return "Vertex array " + std::to_string(index) + ": Offset = " + std::to_string(decoded_values.offset()); + return fmt::format("Vertex array %u: Offset: 0x%x", index, decoded.offset()); } }; @@ -4458,10 +4543,10 @@ struct register_vertex_helper static constexpr usz attribute_index = index / increment_per_array_index; static constexpr usz vertex_subreg = index % increment_per_array_index; - static std::string dump(decoded_type&& decoded_values) + static std::string dump(const decoded_type& decoded) { return "register vertex " + std::to_string(attribute_index) + " as " + register_vertex_printer::type() + ": " + - register_vertex_printer::value(decoded_values.value); + register_vertex_printer::value(decoded.value); } }; @@ -4502,4 +4587,237 @@ EXPAND_RANGE_16(0, VERTEX_DATA3F) EXPAND_RANGE_16(0, VERTEX_DATA4F) EXPAND_RANGE_16(0, VERTEX_DATA2S) EXPAND_RANGE_16(0, VERTEX_DATA4S) + +template +struct texture_offset_helper +{ + struct decoded_type + { + const u32 value; + + decoded_type(u32 value) : value(value) {} + + u32 offset() const + { + return value; + } + }; + + static std::string dump(const decoded_type& decoded) + { + return fmt::format("Texture %u: Offset: 0x%x", index, decoded.offset()); + } +}; + +template +struct texture_format_helper +{ + struct decoded_type + { + const u32 value; + + decoded_type(u32 value) : value(value) {} + + CellGcmLocation location() const + { + return CellGcmLocation{(value & 3) - 1}; + } + + bool cubemap() const + { + return bf_decoder<2, 1, bool>(value); + } + + u8 border_type() const + { + return bf_decoder<3, 1>(value); + } + + texture_dimension dimension() const + { + // Hack: avoid debugger crash on not-written value (needs checking on realhw) + // This is not the function RSX uses so it's safe + return rsx::to_texture_dimension(std::clamp(bf_decoder<4, 4>(value), 1, 3)); + } + + CellGcmTexture format() const + { + return CellGcmTexture{bf_decoder<8, 8>(value)}; + } + + u16 mipmap() const + { + return bf_decoder<16, 16>(value); + } + }; + + static std::string dump(const decoded_type& decoded) + { + return fmt::format("Texture %u: %s, Cubemap: %s, %s, %s, Mipmap: %u", index, + decoded.location(), decoded.cubemap(), decoded.dimension(), decoded.format(), decoded.mipmap()); + } +}; + +template +struct texture_image_rect_helper +{ + struct decoded_type + { + const u32 value; + + decoded_type(u32 value) : value(value) {} + + u16 height() const + { + return bf_decoder<0, 16>(value); + } + + u16 width() const + { + return bf_decoder<16, 16>(value); + } + }; + + static std::string dump(const decoded_type& decoded) + { + return fmt::format("Texture %u: W: %u, H: %u", index, decoded.width(), decoded.height()); + } +}; + +template +struct texture_control0_helper +{ + struct decoded_type + { + const u32 value; + + decoded_type(u32 value) : value(value) {} + + bool enabled() const + { + return bf_decoder<31, 1, bool>(value); + } + + f32 min_lod() const + { + return rsx::decode_fxp<4, 8, false>(bf_decoder<19, 12>(value)); + } + + f32 max_lod() const + { + return rsx::decode_fxp<4, 8, false>(bf_decoder<7, 12>(value)); + } + + texture_max_anisotropy max_aniso() const + { + return rsx::to_texture_max_anisotropy(bf_decoder<4, 3>(value)); + } + + bool alpha_kill_enabled() const + { + return bf_decoder<2, 1, bool>(value); + } + }; + + static std::string dump(const decoded_type& decoded) + { + return fmt::format("Texture %u: %s, Min/Max LOD: %g/%g, Max Aniso: %s, AKill: %s", index, print_boolean(decoded.enabled()) + , decoded.min_lod(), decoded.max_lod(), decoded.max_aniso(), print_boolean(decoded.alpha_kill_enabled())); + } +}; + +template +struct texture_control3_helper +{ + struct decoded_type + { + const u32 value; + + decoded_type(u32 value) : value(value) {} + + u16 depth() const + { + return bf_decoder<20, 12>(value); + } + + u32 pitch() const + { + return bf_decoder<0, 16>(value); + } + }; + + static std::string dump(const decoded_type& decoded) + { + return fmt::format("Texture %u: Pitch: %u, Depth: %u", index, decoded.pitch(), decoded.depth()); + } +}; + +#define TEXTURE_OFFSET(index) \ + template<> struct registers_decoder : public texture_offset_helper {}; +#define TEXTURE_FORMAT(index) \ + template<> struct registers_decoder : public texture_format_helper {}; +#define TEXTURE_IMAGE_RECT(index) \ + template<> struct registers_decoder : public texture_image_rect_helper {}; +#define TEXTURE_CONTROL0(index) \ + template<> struct registers_decoder : public texture_control0_helper {}; +#define TEXTURE_CONTROL3(index) \ + template<> struct registers_decoder : public texture_control3_helper {}; + +#define DECLARE_TEXTURE_OFFSET(index) \ + NV4097_SET_TEXTURE_OFFSET + ((index) * 8), +#define DECLARE_TEXTURE_FORMAT(index) \ + NV4097_SET_TEXTURE_FORMAT + ((index) * 8), +#define DECLARE_TEXTURE_IMAGE_RECT(index) \ + NV4097_SET_TEXTURE_IMAGE_RECT + ((index) * 8), +#define DECLARE_TEXTURE_CONTROL0(index) \ + NV4097_SET_TEXTURE_CONTROL0 + ((index) * 8), +#define DECLARE_TEXTURE_CONTROL3(index) \ + NV4097_SET_TEXTURE_CONTROL3 + index, + +EXPAND_RANGE_16(0, TEXTURE_OFFSET) +EXPAND_RANGE_16(0, TEXTURE_FORMAT) +EXPAND_RANGE_16(0, TEXTURE_IMAGE_RECT) +EXPAND_RANGE_16(0, TEXTURE_CONTROL0) +EXPAND_RANGE_16(0, TEXTURE_CONTROL3) + +template +struct vertex_texture_control0_helper +{ + struct decoded_type + { + const u32 value; + + decoded_type(u32 value) : value(value) {} + + bool enabled() const + { + return bf_decoder<31, 1, bool>(value); + } + + f32 min_lod() const + { + return rsx::decode_fxp<4, 8, false>(bf_decoder<19, 12>(value)); + } + + f32 max_lod() const + { + return rsx::decode_fxp<4, 8, false>(bf_decoder<7, 12>(value)); + } + }; + + static std::string dump(const decoded_type& decoded) + { + return fmt::format("VTexture %u: %s, Min/Max LOD: %g/%g", index, print_boolean(decoded.enabled()) + , decoded.min_lod(), decoded.max_lod()); + } +}; + +#define VERTEX_TEXTURE_CONTROL0(index) \ + template<> struct registers_decoder : public vertex_texture_control0_helper {}; + +#define DECLARE_VERTEX_TEXTURE_CONTROL0(index) \ + NV4097_SET_VERTEX_TEXTURE_CONTROL0 + ((index) * 8), + +EXPAND_RANGE_4(0, VERTEX_TEXTURE_CONTROL0) + } // end namespace rsx diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index b5d7b6d856..17a4d0a1c8 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -25,7 +25,7 @@ namespace rsx rsx->recover_fifo(); } - void trace_method(thread* rsx, u32 _reg, u32 arg) + static void trace_method(thread* rsx, u32 _reg, u32 arg) { // For unknown yet valid methods rsx_log.trace("RSX method 0x%x (arg=0x%x)", _reg << 2, arg); diff --git a/rpcs3/rpcs3qt/debugger_frame.cpp b/rpcs3/rpcs3qt/debugger_frame.cpp index 0f1ed5f511..48b0385bf6 100644 --- a/rpcs3/rpcs3qt/debugger_frame.cpp +++ b/rpcs3/rpcs3qt/debugger_frame.cpp @@ -11,6 +11,7 @@ #include "Emu/System.h" #include "Emu/IdManager.h" +#include "Emu/RSX/RSXThread.h" #include "Emu/Cell/PPUDisAsm.h" #include "Emu/Cell/PPUThread.h" #include "Emu/Cell/SPUDisAsm.h" @@ -337,13 +338,32 @@ void debugger_frame::keyPressEvent(QKeyEvent* event) } } +rsx::thread* debugger_frame::get_rsx() +{ + // m_rsx is raw pointer, when emulation is stopped it won't be cleared + // Therefore need to do invalidation checks manually + + if (g_fxo->get() != m_rsx) + { + m_rsx = nullptr; + } + + if (m_rsx && !m_rsx->ctrl) + { + m_rsx = nullptr; + } + + return m_rsx; +} + void debugger_frame::UpdateUI() { UpdateUnitList(); const auto cpu = this->cpu.lock(); + const auto rsx = this->get_rsx(); - if (!cpu) + if (!cpu && !rsx) { if (m_last_pc != umax || !m_last_query_state.empty()) { @@ -351,10 +371,15 @@ void debugger_frame::UpdateUI() m_last_pc = -1; DoUpdate(); } - - m_btn_run->setEnabled(false); - m_btn_step->setEnabled(false); - m_btn_step_over->setEnabled(false); + } + else if (rsx) + { + if (m_last_pc != rsx->ctrl->get || !m_last_query_state.empty()) + { + m_last_query_state.clear(); + m_last_pc = rsx->ctrl->get; + DoUpdate(); + } } else { @@ -387,6 +412,7 @@ void debugger_frame::UpdateUI() } Q_DECLARE_METATYPE(std::weak_ptr); +Q_DECLARE_METATYPE(::rsx::thread*); void debugger_frame::UpdateUnitList() { @@ -424,6 +450,13 @@ void debugger_frame::UpdateUnitList() idm::select>(on_select); idm::select>(on_select); + + if (auto render = g_fxo->get(); render && render->ctrl) + { + QVariant var_cpu = QVariant::fromValue(render); + m_choice_units->addItem("RSX[0x55555555]", var_cpu); + if (old_cpu == var_cpu) m_choice_units->setCurrentIndex(m_choice_units->count() - 1); + } } OnSelectUnit(); @@ -436,15 +469,22 @@ void debugger_frame::OnSelectUnit() if (m_choice_units->count() < 1) return; const auto weak = m_choice_units->currentData().value>(); + const auto render = m_choice_units->currentData().value(); - if (!weak.owner_before(cpu) && !cpu.owner_before(weak)) + if (!render && !weak.owner_before(cpu) && !cpu.owner_before(weak)) { // They match, nothing to do. return; } + if (render && render == this->get_rsx()) + { + return; + } + m_disasm.reset(); cpu.reset(); + m_rsx = nullptr; if (!weak.expired()) { @@ -468,6 +508,10 @@ void debugger_frame::OnSelectUnit() } } } + else + { + m_rsx = render; + } EnableButtons(true); @@ -494,8 +538,9 @@ void debugger_frame::DoUpdate() void debugger_frame::WritePanels() { const auto cpu = this->cpu.lock(); + const auto rsx = this->get_rsx(); - if (!cpu) + if (!cpu && !rsx) { m_misc_state->clear(); m_regs->clear(); @@ -506,15 +551,15 @@ void debugger_frame::WritePanels() loc = m_misc_state->verticalScrollBar()->value(); m_misc_state->clear(); - m_misc_state->setText(qstr(cpu->dump_misc())); + m_misc_state->setText(qstr(rsx ? "" : cpu->dump_misc())); m_misc_state->verticalScrollBar()->setValue(loc); loc = m_regs->verticalScrollBar()->value(); m_regs->clear(); - m_regs->setText(qstr(cpu->dump_regs())); + m_regs->setText(qstr(rsx ? rsx->dump_regs() : cpu->dump_regs())); m_regs->verticalScrollBar()->setValue(loc); - Q_EMIT CallStackUpdateRequested(cpu->dump_callstack_list()); + Q_EMIT CallStackUpdateRequested(rsx ? rsx->dump_callstack() : cpu->dump_callstack_list()); } void debugger_frame::ShowGotoAddressDialog() @@ -581,16 +626,16 @@ void debugger_frame::ShowGotoAddressDialog() u64 debugger_frame::EvaluateExpression(const QString& expression) { - auto thread = cpu.lock(); - - if (!thread) return 0; - bool ok = false; // Parse expression(or at least used to, was nuked to remove the need for QtJsEngine) const QString fixed_expression = QRegExp("^[A-Fa-f0-9]+$").exactMatch(expression) ? "0x" + expression : expression; const u64 res = static_cast(fixed_expression.toULong(&ok, 16)); - return ok ? res : thread->get_pc(); + + if (ok) return res; + if (auto thread = get_rsx()) return thread->ctrl->get; + if (auto thread = cpu.lock()) return thread->get_pc(); + return 0; } void debugger_frame::ClearBreakpoints() @@ -606,7 +651,11 @@ void debugger_frame::ClearCallStack() void debugger_frame::ShowPC() { const auto cpu0 = cpu.lock(); - m_debugger_list->ShowAddress(cpu0 ? cpu0->get_pc() : 0); + + const u32 pc = get_rsx() ? +m_rsx->ctrl->get + : (cpu0 ? cpu0->get_pc() : 0); + + m_debugger_list->ShowAddress(pc); } void debugger_frame::DoStep(bool stepOver) diff --git a/rpcs3/rpcs3qt/debugger_frame.h b/rpcs3/rpcs3qt/debugger_frame.h index f91459a0b0..f22b6c9d34 100644 --- a/rpcs3/rpcs3qt/debugger_frame.h +++ b/rpcs3/rpcs3qt/debugger_frame.h @@ -20,6 +20,11 @@ class breakpoint_list; class breakpoint_handler; class call_stack_list; +namespace rsx +{ + class thread; +} + class debugger_frame : public custom_dock_widget { Q_OBJECT @@ -50,6 +55,7 @@ class debugger_frame : public custom_dock_widget std::shared_ptr m_disasm; std::weak_ptr cpu; + rsx::thread* m_rsx = nullptr; breakpoint_list* m_breakpoint_list; breakpoint_handler* m_breakpoint_handler; @@ -58,6 +64,7 @@ class debugger_frame : public custom_dock_widget std::shared_ptr xgui_settings; + rsx::thread* get_rsx(); // Do not read m_rsx directy, use this instead. public: explicit debugger_frame(std::shared_ptr settings, QWidget *parent = 0); diff --git a/rpcs3/rpcs3qt/rsx_debugger.cpp b/rpcs3/rpcs3qt/rsx_debugger.cpp index fad760cece..4e05c0bf71 100644 --- a/rpcs3/rpcs3qt/rsx_debugger.cpp +++ b/rpcs3/rpcs3qt/rsx_debugger.cpp @@ -645,11 +645,12 @@ void rsx_debugger::GetMemory() } std::string dump; + u32 cmd_i = 0; - for (u32 i = 0; i < frame_debug.command_queue.size(); i++) + for (const auto& command : frame_debug.command_queue) { - const std::string& str = rsx::get_pretty_printing_function(frame_debug.command_queue[i].first)(frame_debug.command_queue[i].second); - m_list_captured_frame->setItem(i, 0, new QTableWidgetItem(qstr(str))); + const std::string str = rsx::get_pretty_printing_function(command.first)(command.first, command.second); + m_list_captured_frame->setItem(cmd_i++, 0, new QTableWidgetItem(qstr(str))); dump += str; dump += '\n'; @@ -739,93 +740,6 @@ void rsx_debugger::GetBuffers() //m_buffer_tex->showImage(QImage(buffer, m_text_width, m_text_height, QImage::Format_RGB32)); } -const char* rsx_debugger::ParseGCMEnum(u32 value, u32 type) -{ - switch(type) - { - case CELL_GCM_ENUM: - { - switch(value) - { - case 0x0200: return "Never"; - case 0x0201: return "Less"; - case 0x0202: return "Equal"; - case 0x0203: return "Less or Equal"; - case 0x0204: return "Greater"; - case 0x0205: return "Not Equal"; - case 0x0206: return "Greater or Equal"; - case 0x0207: return "Always"; - - case 0x0: return "Zero"; - case 0x1: return "One"; - case 0x0300: return "SRC_COLOR"; - case 0x0301: return "1 - SRC_COLOR"; - case 0x0302: return "SRC_ALPHA"; - case 0x0303: return "1 - SRC_ALPHA"; - case 0x0304: return "DST_ALPHA"; - case 0x0305: return "1 - DST_ALPHA"; - case 0x0306: return "DST_COLOR"; - case 0x0307: return "1 - DST_COLOR"; - case 0x0308: return "SRC_ALPHA_SATURATE"; - case 0x8001: return "CONSTANT_COLOR"; - case 0x8002: return "1 - CONSTANT_COLOR"; - case 0x8003: return "CONSTANT_ALPHA"; - case 0x8004: return "1 - CONSTANT_ALPHA"; - - case 0x8006: return "Add"; - case 0x8007: return "Min"; - case 0x8008: return "Max"; - case 0x800A: return "Substract"; - case 0x800B: return "Reverse Substract"; - case 0xF005: return "Reverse Substract Signed"; - case 0xF006: return "Add Signed"; - case 0xF007: return "Reverse Add Signed"; - - default: return "Wrong Value!"; - } - } - case CELL_GCM_PRIMITIVE_ENUM: - { - switch(value) - { - case 1: return "POINTS"; - case 2: return "LINES"; - case 3: return "LINE_LOOP"; - case 4: return "LINE_STRIP"; - case 5: return "TRIANGLES"; - case 6: return "TRIANGLE_STRIP"; - case 7: return "TRIANGLE_FAN"; - case 8: return "QUADS"; - case 9: return "QUAD_STRIP"; - case 10: return "POLYGON"; - - default: return "Wrong Value!"; - } - } - default: return "Unknown!"; - } -} - -#define case_16(a, m) \ - case a + m: \ - case a + m * 2: \ - case a + m * 3: \ - case a + m * 4: \ - case a + m * 5: \ - case a + m * 6: \ - case a + m * 7: \ - case a + m * 8: \ - case a + m * 9: \ - case a + m * 10: \ - case a + m * 11: \ - case a + m * 12: \ - case a + m * 13: \ - case a + m * 14: \ - case a + m * 15: \ - index = (cmd - a) / m; \ - [[fallthrough]]; \ - case a \ - QString rsx_debugger::DisAsmCommand(u32 cmd, u32 count, u32 ioAddr) { std::string disasm; @@ -874,30 +788,10 @@ QString rsx_debugger::DisAsmCommand(u32 cmd, u32 count, u32 ioAddr) DISASM("Flip and change current buffer: %d", args[0]); break; } - case_16(NV4097_SET_TEXTURE_OFFSET, 0x20): - { - DISASM("Texture Offset[%d]: %07x", index, args[0]); - switch ((args[1] & 0x3) - 1) - { - case CELL_GCM_LOCATION_LOCAL: DISASM("(Local memory);"); break; - case CELL_GCM_LOCATION_MAIN: DISASM("(Main memory);"); break; - default: DISASM("(Bad location!);"); break; - } - DISASM(" Cubemap:%s; Dimension:0x%x; Format:0x%x; Mipmap:0x%x", - (((args[1] >> 2) & 0x1) ? "True" : "False"), - ((args[1] >> 4) & 0xf), - ((args[1] >> 8) & 0xff), - ((args[1] >> 16) & 0xffff)); - break; - } - case NV4097_SET_DEPTH_BOUNDS_TEST_ENABLE: - { - DISASM("Depth bounds test: %s", args[0] ? "Enable" : "Disable"); - break; - } default: { - std::string str = rsx::get_pretty_printing_function((cmd & 0x3ffff) >> 2)(args[0]); + const u32 id = (cmd & 0x3ffff) >> 2; + std::string str = rsx::get_pretty_printing_function(id)(id, args[0]); DISASM("%s", str.c_str()); break; } diff --git a/rpcs3/rpcs3qt/rsx_debugger.h b/rpcs3/rpcs3qt/rsx_debugger.h index d40528ba11..69c818c89b 100644 --- a/rpcs3/rpcs3qt/rsx_debugger.h +++ b/rpcs3/rpcs3qt/rsx_debugger.h @@ -72,7 +72,6 @@ public: virtual void GetMemory(); virtual void GetBuffers(); - const char* ParseGCMEnum(u32 value, u32 type); QString DisAsmCommand(u32 cmd, u32 count, u32 ioAddr); void SetPC(const uint pc);