diff --git a/rpcs3/Emu/RSX/Common/simple_array.hpp b/rpcs3/Emu/RSX/Common/simple_array.hpp index 0fec530852..aa482ef418 100644 --- a/rpcs3/Emu/RSX/Common/simple_array.hpp +++ b/rpcs3/Emu/RSX/Common/simple_array.hpp @@ -390,14 +390,22 @@ namespace rsx } bool ret = false; - for (auto ptr = _data, last = _data + _size - 1; ptr < last; ptr++) + for (auto ptr = _data, last = _data + _size - 1; ptr <= last; ptr++) { if (predicate(*ptr)) { + ret = true; + + if (ptr == last) + { + // Popping the last entry from list. Just set the new size and exit + _size--; + break; + } + // Move item to the end of the list and shrink by 1 std::memcpy(ptr, last, sizeof(Ty)); last = _data + (--_size); - ret = true; } } diff --git a/rpcs3/Emu/RSX/Core/RSXDrawCommands.cpp b/rpcs3/Emu/RSX/Core/RSXDrawCommands.cpp index 9d218edb89..97cf918e57 100644 --- a/rpcs3/Emu/RSX/Core/RSXDrawCommands.cpp +++ b/rpcs3/Emu/RSX/Core/RSXDrawCommands.cpp @@ -4,7 +4,6 @@ #include "Emu/RSX/Common/BufferUtils.h" #include "Emu/RSX/Common/buffer_stream.hpp" #include "Emu/RSX/Common/io_buffer.h" -#include "Emu/RSX/Common/simple_array.hpp" #include "Emu/RSX/NV47/HW/context_accessors.define.h" #include "Emu/RSX/Program/GLSLCommon.h" #include "Emu/RSX/rsx_methods.h" @@ -759,7 +758,8 @@ namespace rsx ensure(draw_call.is_trivial_instanced_draw); // Temp indirection table. Used to track "running" updates. - rsx::simple_array instancing_indirection_table; + auto& instancing_indirection_table = m_scratch_buffers.u32buf; + // indirection table size const auto full_reupload = !prog || prog->has_indexed_constants; const auto reloc_table = full_reupload ? decltype(prog->constant_ids){} : prog->constant_ids; @@ -767,7 +767,8 @@ namespace rsx instancing_indirection_table.resize(redirection_table_size); // Temp constants data - rsx::simple_array constants_data; + auto& constants_data = m_scratch_buffers.u128buf; + constants_data.clear(); constants_data.reserve(redirection_table_size * draw_call.pass_count()); // Allocate indirection buffer on GPU stream diff --git a/rpcs3/Emu/RSX/Core/RSXDrawCommands.h b/rpcs3/Emu/RSX/Core/RSXDrawCommands.h index 5bc5991a18..fd61a9a67c 100644 --- a/rpcs3/Emu/RSX/Core/RSXDrawCommands.h +++ b/rpcs3/Emu/RSX/Core/RSXDrawCommands.h @@ -2,6 +2,7 @@ #include +#include "Emu/RSX/Common/simple_array.hpp" #include "Emu/RSX/Core/RSXVertexTypes.h" #include "Emu/RSX/NV47/FW/draw_call.hpp" #include "Emu/RSX/Program/ProgramStateCache.h" @@ -28,6 +29,12 @@ namespace rsx std::array m_vertex_push_buffers; rsx::simple_array m_element_push_buffer; + struct + { + rsx::simple_array u32buf; + rsx::simple_array u128buf; + } mutable m_scratch_buffers; + public: draw_command_processor() = default; diff --git a/rpcs3/Input/evdev_joystick_handler.cpp b/rpcs3/Input/evdev_joystick_handler.cpp index 989e95929d..3b8677afd8 100644 --- a/rpcs3/Input/evdev_joystick_handler.cpp +++ b/rpcs3/Input/evdev_joystick_handler.cpp @@ -18,6 +18,33 @@ LOG_CHANNEL(evdev_log, "evdev"); +bool positive_axis::load() +{ + if (fs::file cfg_file{ cfg_name, fs::read }) + { + return from_string(cfg_file.to_string()); + } + + from_default(); + return false; +} + +void positive_axis::save() const +{ + fs::pending_file file(cfg_name); + + if (file.file) + { + file.file.write(to_string()); + file.commit(); + } +} + +bool positive_axis::exist() const +{ + return fs::is_file(cfg_name); +} + evdev_joystick_handler::evdev_joystick_handler() : PadHandlerBase(pad_handler::evdev) { @@ -110,7 +137,12 @@ bool evdev_joystick_handler::Init() if (m_is_init) return true; - m_pos_axis_config.load(); + if (!m_pos_axis_config.load()) + { + evdev_log.notice("positive_axis config missing. Using defaults"); + } + + evdev_log.notice("positive_axis config=\n%s", m_pos_axis_config.to_string()); if (!m_pos_axis_config.exist()) m_pos_axis_config.save(); @@ -783,7 +815,7 @@ std::shared_ptr evdev_joystick_handler::add // Let's log axis information while we are in the settings in order to identify problems more easily. for (const auto& [code, axis_name] : axis_list) { - if (const input_absinfo *info = libevdev_get_abs_info(dev, code)) + if (const input_absinfo* info = libevdev_get_abs_info(dev, code)) { const char* code_name = libevdev_event_code_get_name(EV_ABS, code); evdev_log.notice("Axis info for %s: %s (%s) => minimum=%d, maximum=%d, fuzz=%d, flat=%d, resolution=%d", @@ -857,7 +889,7 @@ std::shared_ptr evdev_joystick_handler::add // A device must not mix regular directional axes and accelerometer axes on the same event node. for (const auto& [code, axis_name] : axis_list) { - if (const input_absinfo *info = libevdev_get_abs_info(dev, code)) + if (const input_absinfo* info = libevdev_get_abs_info(dev, code)) { const bool is_accel = code == ABS_X || code == ABS_Y || code == ABS_Z; const char* code_name = libevdev_event_code_get_name(EV_ABS, code); diff --git a/rpcs3/Input/evdev_joystick_handler.h b/rpcs3/Input/evdev_joystick_handler.h index 7b23903091..6919a32205 100644 --- a/rpcs3/Input/evdev_joystick_handler.h +++ b/rpcs3/Input/evdev_joystick_handler.h @@ -57,31 +57,9 @@ struct positive_axis : cfg::node cfg::_bool abs_mt_tool_x{ this, "ABS_MT_TOOL_X", false }; cfg::_bool abs_mt_tool_y{ this, "ABS_MT_TOOL_Y", false }; - bool load() - { - if (fs::file cfg_file{ cfg_name, fs::read }) - { - return from_string(cfg_file.to_string()); - } - - return false; - } - - void save() - { - fs::pending_file file(cfg_name); - - if (file.file) - { - file.file.write(to_string()); - file.commit(); - } - } - - bool exist() - { - return fs::is_file(cfg_name); - } + bool load(); + void save() const; + bool exist() const; }; class evdev_joystick_handler final : public PadHandlerBase