From 8cd0d7826928c8a366eb15cd3697a14e53eb0d5a Mon Sep 17 00:00:00 2001 From: weakboson Date: Wed, 23 Jul 2025 18:07:16 +0800 Subject: [PATCH] Ran clang-format. Fixed Qt6 deprecations. --- .../dynarmic/src/dynarmic/ir/basic_block.cpp | 8 +- .../dynarmic/src/dynarmic/ir/basic_block.h | 4 +- .../src/dynarmic/ir/microinstruction.h | 12 +- .../app/src/main/jni/android_settings.h | 357 +++--- src/android/app/src/main/jni/native.cpp | 114 +- src/audio_core/in/audio_in.cpp | 4 +- src/audio_core/in/audio_in_system.cpp | 4 +- src/audio_core/out/audio_out.cpp | 4 +- src/audio_core/out/audio_out_system.cpp | 4 +- .../renderer/behavior/info_updater.cpp | 7 +- .../renderer/memory/pool_mapper.cpp | 4 +- src/audio_core/sink/sink_stream.cpp | 4 +- src/common/address_space.h | 3 +- src/common/android/android_common.cpp | 4 +- src/common/android/id_cache.cpp | 1045 ++++++++--------- src/common/android/id_cache.h | 1 - .../android/multiplayer/multiplayer.cpp | 238 ++-- src/common/android/multiplayer/multiplayer.h | 31 +- src/common/concepts.h | 6 +- src/common/device_power_state.cpp | 107 +- src/common/expected.h | 8 +- src/common/fs/path_util.cpp | 28 +- src/common/intrusive_list.h | 4 +- src/common/intrusive_red_black_tree.h | 10 +- src/common/logging/backend.cpp | 4 +- src/common/multi_level_page_table.h | 8 +- src/common/parent_of_member.h | 4 +- src/common/point.h | 4 +- src/common/polyfill_ranges.h | 6 +- src/common/polyfill_thread.h | 4 +- src/common/settings.h | 170 ++- src/common/settings_enums.h | 15 +- src/common/string_util.cpp | 12 +- src/common/tree.h | 6 +- src/common/vector_math.h | 12 +- src/common/virtual_buffer.h | 4 +- src/common/x64/native_clock.cpp | 4 +- src/core/arm/arm_interface.cpp | 3 +- src/core/arm/dynarmic/arm_dynarmic.cpp | 4 +- src/core/arm/dynarmic/arm_dynarmic_32.cpp | 13 +- src/core/arm/dynarmic/arm_dynarmic_64.cpp | 11 +- src/core/arm/nce/arm_nce.cpp | 30 +- src/core/arm/nce/interpreter_visitor.cpp | 2 +- src/core/arm/nce/lru_cache.h | 63 +- src/core/arm/nce/patcher.cpp | 13 +- src/core/arm/nce/patcher.h | 13 +- src/core/core_timing.cpp | 36 +- src/core/file_sys/card_image.cpp | 4 +- src/core/file_sys/fs_path_utility.h | 11 +- ...ssystem_integrity_verification_storage.cpp | 22 +- src/core/file_sys/registered_cache.cpp | 4 +- src/core/file_sys/sdmc_factory.cpp | 4 +- src/core/file_sys/submission_package.cpp | 6 +- src/core/file_sys/xts_archive.cpp | 8 +- src/core/hle/kernel/k_auto_object.h | 16 +- src/core/hle/kernel/k_memory_layout.cpp | 4 +- src/core/hle/kernel/k_priority_queue.h | 48 +- src/core/hle/kernel/k_process.h | 2 +- src/core/hle/kernel/k_scoped_lock.h | 9 +- src/core/hle/kernel/svc/svc_info.cpp | 12 +- src/core/hle/kernel/svc_types.h | 2 +- src/core/hle/result.h | 8 +- src/core/hle/service/acc/profile_manager.cpp | 1 - src/core/hle/service/am/applet.cpp | 4 +- .../service/am/frontend/applet_cabinet.cpp | 5 +- .../am/frontend/applet_net_connect.cpp | 4 +- .../service/am/frontend/applet_net_connect.h | 4 +- src/core/hle/service/am/frontend/applets.cpp | 3 +- src/core/hle/service/am/frontend/applets.h | 2 +- src/core/hle/service/am/process_creation.cpp | 2 +- .../service/am/service/application_proxy.cpp | 4 +- .../service/am/service/display_controller.h | 2 +- .../am/service/library_applet_accessor.cpp | 12 +- .../am/service/library_applet_creator.cpp | 4 +- .../am/service/library_applet_proxy.cpp | 4 +- .../service/am/service/self_controller.cpp | 4 +- .../am/service/system_applet_proxy.cpp | 4 +- .../service/am/service/window_controller.cpp | 4 +- .../service/aoc/purchase_event_manager.cpp | 4 +- src/core/hle/service/audio/audio_in.cpp | 5 +- .../hle/service/audio/audio_in_manager.cpp | 4 +- src/core/hle/service/audio/audio_renderer.cpp | 4 +- .../bcat/news/newly_arrived_event_holder.cpp | 5 +- .../bcat/news/overwrite_event_holder.cpp | 4 +- .../filesystem/fsp/fs_i_filesystem.cpp | 4 +- .../fsp/fs_i_save_data_info_reader.cpp | 4 +- .../hle/service/glue/time/alarm_worker.cpp | 4 +- src/core/hle/service/glue/time/manager.cpp | 6 +- src/core/hle/service/glue/time/time_zone.cpp | 6 +- src/core/hle/service/glue/time/worker.cpp | 8 +- src/core/hle/service/hid/hid_debug_server.cpp | 4 +- src/core/hle/service/hid/hid_server.cpp | 6 +- src/core/hle/service/ipc_helpers.h | 4 +- src/core/hle/service/jit/jit_context.cpp | 4 +- src/core/hle/service/ldn/lan_discovery.cpp | 2 +- .../ldn/user_local_communication_service.cpp | 3 +- src/core/hle/service/mii/mii.cpp | 4 +- src/core/hle/service/mm/mm_u.cpp | 266 ++--- src/core/hle/service/nifm/nifm.cpp | 26 +- src/core/hle/service/nim/nim.cpp | 18 +- .../ns/application_manager_interface.cpp | 3 +- .../service/ns/dynamic_rights_interface.cpp | 4 +- .../hle/service/ns/dynamic_rights_interface.h | 3 +- .../service/nvdrv/core/syncpoint_manager.h | 2 +- src/core/hle/service/psc/time/alarms.cpp | 4 +- .../standard_user_system_clock_core.cpp | 4 +- src/core/hle/service/psc/time/common.cpp | 4 +- src/core/hle/service/psc/time/manager.h | 4 +- .../service/psc/time/power_state_service.cpp | 4 +- src/core/hle/service/psc/time/static.cpp | 4 +- .../hle/service/psc/time/steady_clock.cpp | 4 +- .../hle/service/psc/time/system_clock.cpp | 4 +- .../service/psc/time/time_zone_service.cpp | 4 +- src/core/hle/service/set/settings_server.cpp | 3 +- src/core/hle/service/set/settings_server.h | 5 +- src/core/hle/service/sm/sm.cpp | 4 +- src/core/hle/service/sm/sm_controller.cpp | 4 +- src/core/hle/service/sockets/bsd.cpp | 5 +- src/core/hle/service/ssl/ssl.cpp | 238 ++-- src/core/hle/service/ssl/ssl_types.h | 69 +- .../vi/application_display_service.cpp | 9 +- src/core/hle/service/vi/conductor.cpp | 5 +- src/core/internal_network/emu_net_state.h | 2 +- .../internal_network/network_interface.cpp | 32 +- src/core/loader/nca.cpp | 5 +- src/core/memory/cheat_engine.cpp | 4 +- src/dedicated_room/yuzu_room.cpp | 14 +- src/frontend_common/firmware_manager.cpp | 36 +- src/frontend_common/firmware_manager.h | 45 +- src/hid_core/frontend/emulated_controller.cpp | 9 +- src/input_common/drivers/udp_client.cpp | 1 - src/input_common/input_poller.cpp | 4 +- src/network/announce_multiplayer_session.cpp | 16 +- src/network/packet.cpp | 4 +- src/network/room.cpp | 2 +- .../glasm/emit_glasm_context_get_set.cpp | 2 +- .../backend/spirv/emit_spirv_atomic.cpp | 2 +- .../spirv/emit_spirv_context_get_set.cpp | 11 +- .../backend/spirv/emit_spirv_convert.cpp | 2 +- .../backend/spirv/emit_spirv_memory.cpp | 6 +- .../backend/spirv/spirv_emit_context.cpp | 6 +- .../backend/spirv/spirv_emit_context.h | 4 +- .../frontend/maxwell/control_flow.cpp | 4 +- .../maxwell/structured_control_flow.cpp | 4 +- src/shader_recompiler/ir_opt/texture_pass.cpp | 8 +- src/tests/common/host_memory.cpp | 8 +- .../calibration_configuration_job.cpp | 1 - src/video_core/cdma_pusher.cpp | 4 +- src/video_core/engines/maxwell_3d.cpp | 5 +- src/video_core/engines/puller.cpp | 4 +- src/video_core/host1x/codecs/decoder.cpp | 4 +- src/video_core/host1x/ffmpeg/ffmpeg.cpp | 70 +- src/video_core/host1x/host1x.cpp | 4 +- src/video_core/host1x/vic.cpp | 4 +- src/video_core/memory_manager.cpp | 4 +- src/video_core/query_cache/query_stream.h | 1 - .../renderer_opengl/gl_compute_pipeline.cpp | 4 +- .../renderer_opengl/gl_query_cache.cpp | 5 +- .../renderer_opengl/gl_shader_cache.cpp | 3 +- src/video_core/renderer_vulkan/blit_image.cpp | 113 +- src/video_core/renderer_vulkan/blit_image.h | 9 +- .../renderer_vulkan/present/fsr.cpp | 4 +- .../renderer_vulkan/renderer_vulkan.cpp | 269 ++--- .../renderer_vulkan/renderer_vulkan.h | 4 +- .../renderer_vulkan/vk_compute_pass.cpp | 4 +- .../renderer_vulkan/vk_compute_pipeline.cpp | 4 +- .../renderer_vulkan/vk_graphics_pipeline.cpp | 37 +- .../renderer_vulkan/vk_graphics_pipeline.h | 4 +- .../renderer_vulkan/vk_pipeline_cache.cpp | 31 +- .../renderer_vulkan/vk_present_manager.cpp | 26 +- .../renderer_vulkan/vk_present_manager.h | 7 +- .../vk_staging_buffer_pool.cpp | 4 +- .../renderer_vulkan/vk_state_tracker.h | 11 +- .../renderer_vulkan/vk_swapchain.cpp | 18 +- .../renderer_vulkan/vk_texture_cache.cpp | 57 +- .../renderer_vulkan/vk_texture_cache.h | 5 +- .../renderer_vulkan/vk_texture_manager.cpp | 46 +- src/video_core/shader_environment.cpp | 4 +- src/video_core/textures/astc.cpp | 6 +- .../vulkan_common/vulkan_device.cpp | 129 +- src/video_core/vulkan_common/vulkan_raii.h | 57 +- src/video_core/vulkan_common/vulkan_wrapper.h | 18 +- src/yuzu/about_dialog.cpp | 13 +- src/yuzu/applets/qt_controller.cpp | 17 +- src/yuzu/applets/qt_web_browser.cpp | 4 +- src/yuzu/configuration/configure_dialog.cpp | 33 +- .../configuration/configure_filesystem.cpp | 4 +- .../configure_graphics_extensions.cpp | 7 +- src/yuzu/configuration/configure_input.cpp | 9 +- .../configure_input_advanced.cpp | 8 +- .../configuration/configure_input_player.cpp | 16 +- src/yuzu/configuration/configure_per_game.cpp | 4 +- .../configure_profile_manager.cpp | 2 +- src/yuzu/configuration/configure_system.cpp | 2 +- .../configure_touch_from_button.cpp | 5 +- src/yuzu/configuration/configure_ui.cpp | 10 +- src/yuzu/configuration/configure_web.cpp | 18 +- src/yuzu/configuration/configure_web.h | 4 +- src/yuzu/configuration/shared_translation.cpp | 264 ++--- src/yuzu/configuration/shared_widget.cpp | 8 +- src/yuzu/game_list.cpp | 18 +- src/yuzu/game_list_worker.cpp | 66 +- src/yuzu/game_list_worker.h | 3 +- src/yuzu/main.h | 9 +- src/yuzu/migration_dialog.cpp | 25 +- src/yuzu/migration_dialog.h | 22 +- src/yuzu/migration_worker.cpp | 27 +- src/yuzu/migration_worker.h | 19 +- src/yuzu/multiplayer/host_room.cpp | 3 +- src/yuzu/multiplayer/lobby.cpp | 3 +- src/yuzu/update_checker.cpp | 36 +- src/yuzu/user_data_migration.cpp | 119 +- src/yuzu/user_data_migration.h | 3 +- src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 10 +- .../emu_window/emu_window_sdl2_vk.cpp | 6 +- src/yuzu_cmd/yuzu.cpp | 4 +- src/yuzu_room_standalone/main.cpp | 3 +- .../yuzu_room_standalone.cpp | 3 +- tools/clang-format.sh | 2 +- 219 files changed, 2635 insertions(+), 2845 deletions(-) mode change 100755 => 100644 src/video_core/host1x/codecs/decoder.cpp diff --git a/externals/dynarmic/src/dynarmic/ir/basic_block.cpp b/externals/dynarmic/src/dynarmic/ir/basic_block.cpp index c818fe0b17..9c039a6694 100644 --- a/externals/dynarmic/src/dynarmic/ir/basic_block.cpp +++ b/externals/dynarmic/src/dynarmic/ir/basic_block.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -22,12 +21,7 @@ namespace Dynarmic::IR { Block::Block(const LocationDescriptor& location) - : location{location}, - end_location{location}, - cond{Cond::AL}, - instruction_alloc_pool{std::make_unique>()} -{ - + : location{location}, end_location{location}, cond{Cond::AL}, instruction_alloc_pool{std::make_unique()} { } /// Prepends a new instruction to this basic block before the insertion point, diff --git a/externals/dynarmic/src/dynarmic/ir/basic_block.h b/externals/dynarmic/src/dynarmic/ir/basic_block.h index 6608f0e3a2..ad81727ef2 100644 --- a/externals/dynarmic/src/dynarmic/ir/basic_block.h +++ b/externals/dynarmic/src/dynarmic/ir/basic_block.h @@ -17,7 +17,6 @@ #include "dynarmic/ir/microinstruction.h" #include "dynarmic/ir/terminal.h" #include "dynarmic/ir/value.h" -#include "dynarmic/ir/dense_list.h" #include "dynarmic/common/memory_pool.h" namespace Dynarmic::IR { @@ -171,8 +170,9 @@ private: LocationDescriptor end_location; /// Conditional to pass in order to execute this block Cond cond; + using InstPool = Common::Pool; /// Memory pool for instruction list - std::unique_ptr> instruction_alloc_pool; + std::unique_ptr instruction_alloc_pool; /// Terminal instruction of this block. Terminal terminal = Term::Invalid{}; /// Number of cycles this block takes to execute if the conditional fails. diff --git a/externals/dynarmic/src/dynarmic/ir/microinstruction.h b/externals/dynarmic/src/dynarmic/ir/microinstruction.h index a26a9d80b3..ab44b490d6 100644 --- a/externals/dynarmic/src/dynarmic/ir/microinstruction.h +++ b/externals/dynarmic/src/dynarmic/ir/microinstruction.h @@ -23,7 +23,7 @@ constexpr size_t max_arg_count = 4; /// A representation of a microinstruction. A single ARM/Thumb instruction may be /// converted into zero or more microinstructions. //class Inst final { -class Inst final : public mcl::intrusive_list_node { +class alignas(64) Inst final : public mcl::intrusive_list_node { public: explicit Inst(Opcode op) : op(op) {} @@ -74,12 +74,12 @@ private: void UndoUse(const Value& value); // TODO: so much padding wasted with mcl::intrusive_node - // 16 + 1, 24 - Opcode op; //2 (6) + // 17 + Opcode op; // 20(4) // Linked list of pseudooperations associated with this instruction. - Inst* next_pseudoop = nullptr; //8 (14) - unsigned use_count = 0; //4 (0) - unsigned name = 0; //4 (4) + Inst* next_pseudoop = nullptr; // 24(8) + unsigned use_count = 0; // 32(4) + unsigned name = 0; // 36(4) alignas(64) std::array args; //16 * 4 = 64 (1 cache line) }; static_assert(sizeof(Inst) == 128); diff --git a/src/android/app/src/main/jni/android_settings.h b/src/android/app/src/main/jni/android_settings.h index cd18f1e5b3..af87ea132a 100644 --- a/src/android/app/src/main/jni/android_settings.h +++ b/src/android/app/src/main/jni/android_settings.h @@ -8,172 +8,233 @@ #include #include "common/common_types.h" -#include "common/settings_setting.h" #include "common/settings_enums.h" +#include "common/settings_setting.h" namespace AndroidSettings { - struct GameDir { - std::string path; - bool deep_scan = false; - }; +struct GameDir { + std::string path; + bool deep_scan = false; +}; - struct OverlayControlData { - std::string id; - bool enabled; - std::pair landscape_position; - std::pair portrait_position; - std::pair foldable_position; - }; +struct OverlayControlData { + std::string id; + bool enabled; + std::pair landscape_position; + std::pair portrait_position; + std::pair foldable_position; +}; - struct Values { - Settings::Linkage linkage; +struct Values { + Settings::Linkage linkage; - // Path settings - std::vector game_dirs; + // Path settings + std::vector game_dirs; - // Android - Settings::Setting picture_in_picture{linkage, false, "picture_in_picture", - Settings::Category::Android}; - Settings::Setting screen_layout{linkage, - 5, - "screen_layout", - Settings::Category::Android, - Settings::Specialization::Default, - true, - true}; - Settings::Setting vertical_alignment{linkage, - 0, - "vertical_alignment", - Settings::Category::Android, + // Android + Settings::Setting picture_in_picture{linkage, false, "picture_in_picture", + Settings::Category::Android}; + Settings::Setting screen_layout{linkage, + 5, + "screen_layout", + Settings::Category::Android, + Settings::Specialization::Default, + true, + true}; + Settings::Setting vertical_alignment{linkage, + 0, + "vertical_alignment", + Settings::Category::Android, + Settings::Specialization::Default, + true, + true}; + + Settings::SwitchableSetting driver_path{linkage, "", "driver_path", + Settings::Category::GpuDriver}; + + // LRU Cache + Settings::SwitchableSetting use_lru_cache{linkage, true, "use_lru_cache", + Settings::Category::System}; + + Settings::Setting theme{linkage, 0, "theme", Settings::Category::Android}; + Settings::Setting theme_mode{linkage, -1, "theme_mode", Settings::Category::Android}; + Settings::Setting black_backgrounds{linkage, false, "black_backgrounds", + Settings::Category::Android}; + + // Input/performance overlay settings + std::vector overlay_control_data; + Settings::Setting overlay_scale{linkage, 50, "control_scale", Settings::Category::Overlay}; + Settings::Setting overlay_opacity{linkage, 100, "control_opacity", + Settings::Category::Overlay}; + + Settings::Setting joystick_rel_center{linkage, true, "joystick_rel_center", + Settings::Category::Overlay}; + Settings::Setting dpad_slide{linkage, true, "dpad_slide", Settings::Category::Overlay}; + Settings::Setting haptic_feedback{linkage, true, "haptic_feedback", + Settings::Category::Overlay}; + Settings::Setting show_performance_overlay{linkage, + true, + "show_performance_overlay", + Settings::Category::Overlay, + Settings::Specialization::Paired, + true, + true}; + Settings::Setting perf_overlay_background{linkage, + false, + "perf_overlay_background", + Settings::Category::Overlay, + Settings::Specialization::Default, + true, + true, + &show_performance_overlay}; + Settings::Setting perf_overlay_position{linkage, + 0, + "perf_overlay_position", + Settings::Category::Overlay, + Settings::Specialization::Default, + true, + true, + &show_performance_overlay}; + + Settings::Setting show_fps{linkage, + true, + "show_fps", + Settings::Category::Overlay, + Settings::Specialization::Default, + true, + true, + &show_performance_overlay}; + Settings::Setting show_frame_time{linkage, + false, + "show_frame_time", + Settings::Category::Overlay, + Settings::Specialization::Default, + true, + true, + &show_performance_overlay}; + Settings::Setting show_app_ram_usage{linkage, + false, + "show_app_ram_usage", + Settings::Category::Overlay, + Settings::Specialization::Default, + true, + true, + &show_performance_overlay}; + Settings::Setting show_system_ram_usage{linkage, + false, + "show_system_ram_usage", + Settings::Category::Overlay, Settings::Specialization::Default, true, - true}; - - Settings::SwitchableSetting driver_path{linkage, "", "driver_path", - Settings::Category::GpuDriver}; - - // LRU Cache - Settings::SwitchableSetting use_lru_cache{linkage, true, "use_lru_cache", - Settings::Category::System}; - - Settings::Setting theme{linkage, 0, "theme", Settings::Category::Android}; - Settings::Setting theme_mode{linkage, -1, "theme_mode", Settings::Category::Android}; - Settings::Setting black_backgrounds{linkage, false, "black_backgrounds", - Settings::Category::Android}; - - // Input/performance overlay settings - std::vector overlay_control_data; - Settings::Setting overlay_scale{linkage, 50, "control_scale", - Settings::Category::Overlay}; - Settings::Setting overlay_opacity{linkage, 100, "control_opacity", - Settings::Category::Overlay}; - - Settings::Setting joystick_rel_center{linkage, true, "joystick_rel_center", - Settings::Category::Overlay}; - Settings::Setting dpad_slide{linkage, true, "dpad_slide", - Settings::Category::Overlay}; - Settings::Setting haptic_feedback{linkage, true, "haptic_feedback", - Settings::Category::Overlay}; - Settings::Setting show_performance_overlay{linkage, true, "show_performance_overlay", - Settings::Category::Overlay, - Settings::Specialization::Paired, true, - true}; - Settings::Setting perf_overlay_background{linkage, false, "perf_overlay_background", - Settings::Category::Overlay, - Settings::Specialization::Default, true, - true, - &show_performance_overlay}; - Settings::Setting perf_overlay_position{linkage, 0, "perf_overlay_position", - Settings::Category::Overlay, - Settings::Specialization::Default, true, true, - &show_performance_overlay}; - - Settings::Setting show_fps{linkage, true, "show_fps", - Settings::Category::Overlay, - Settings::Specialization::Default, true, true, - &show_performance_overlay}; - Settings::Setting show_frame_time{linkage, false, "show_frame_time", - Settings::Category::Overlay, - Settings::Specialization::Default, true, true, - &show_performance_overlay}; - Settings::Setting show_app_ram_usage{linkage, false, "show_app_ram_usage", - Settings::Category::Overlay, - Settings::Specialization::Default, true, true, - &show_performance_overlay}; - Settings::Setting show_system_ram_usage{linkage, false, "show_system_ram_usage", - Settings::Category::Overlay, - Settings::Specialization::Default, true, true, - &show_performance_overlay}; - Settings::Setting show_bat_temperature{linkage, false, "show_bat_temperature", - Settings::Category::Overlay, - Settings::Specialization::Default, true, true, - &show_performance_overlay}; - Settings::Setting bat_temperature_unit{linkage, - Settings::TemperatureUnits::Celsius, - "bat_temperature_unit", - Settings::Category::Overlay, - Settings::Specialization::Default, - true, true, - &show_bat_temperature}; - Settings::Setting show_power_info{linkage, false, "show_power_info", - Settings::Category::Overlay, - Settings::Specialization::Default, true, true, - &show_performance_overlay}; - Settings::Setting show_shaders_building{linkage, true, "show_shaders_building", - Settings::Category::Overlay, - Settings::Specialization::Default, true, true, - &show_performance_overlay}; - - - Settings::Setting show_input_overlay{linkage, true, "show_input_overlay", - Settings::Category::Overlay}; - Settings::Setting touchscreen{linkage, true, "touchscreen", - Settings::Category::Overlay}; - Settings::Setting lock_drawer{linkage, false, "lock_drawer", - Settings::Category::Overlay}; - - /// DEVICE/SOC OVERLAY - - Settings::Setting show_soc_overlay{linkage, true, "show_soc_overlay", + true, + &show_performance_overlay}; + Settings::Setting show_bat_temperature{linkage, + false, + "show_bat_temperature", Settings::Category::Overlay, - Settings::Specialization::Paired, true, true}; - - Settings::Setting show_device_model{linkage, true, "show_device_model", + Settings::Specialization::Default, + true, + true, + &show_performance_overlay}; + Settings::Setting bat_temperature_unit{ + linkage, + Settings::TemperatureUnits::Celsius, + "bat_temperature_unit", + Settings::Category::Overlay, + Settings::Specialization::Default, + true, + true, + &show_bat_temperature}; + Settings::Setting show_power_info{linkage, + false, + "show_power_info", + Settings::Category::Overlay, + Settings::Specialization::Default, + true, + true, + &show_performance_overlay}; + Settings::Setting show_shaders_building{linkage, + true, + "show_shaders_building", Settings::Category::Overlay, - Settings::Specialization::Default, true, true, + Settings::Specialization::Default, + true, + true, &show_performance_overlay}; - Settings::Setting show_gpu_model{linkage, true, "show_gpu_model", - Settings::Category::Overlay, - Settings::Specialization::Default, true, true, - &show_performance_overlay}; + Settings::Setting show_input_overlay{linkage, true, "show_input_overlay", + Settings::Category::Overlay}; + Settings::Setting touchscreen{linkage, true, "touchscreen", Settings::Category::Overlay}; + Settings::Setting lock_drawer{linkage, false, "lock_drawer", Settings::Category::Overlay}; - Settings::Setting show_soc_model{linkage, true, "show_soc_model", - Settings::Category::Overlay, - Settings::Specialization::Default, true, true, - &show_soc_overlay}; + /// DEVICE/SOC OVERLAY - Settings::Setting show_fw_version{linkage, true, "show_firmware_version", + Settings::Setting show_soc_overlay{linkage, + true, + "show_soc_overlay", + Settings::Category::Overlay, + Settings::Specialization::Paired, + true, + true}; + + Settings::Setting show_device_model{linkage, + true, + "show_device_model", + Settings::Category::Overlay, + Settings::Specialization::Default, + true, + true, + &show_performance_overlay}; + + Settings::Setting show_gpu_model{linkage, + true, + "show_gpu_model", + Settings::Category::Overlay, + Settings::Specialization::Default, + true, + true, + &show_performance_overlay}; + + Settings::Setting show_soc_model{linkage, + true, + "show_soc_model", + Settings::Category::Overlay, + Settings::Specialization::Default, + true, + true, + &show_soc_overlay}; + + Settings::Setting show_fw_version{linkage, + true, + "show_firmware_version", + Settings::Category::Overlay, + Settings::Specialization::Default, + true, + true, + &show_performance_overlay}; + + Settings::Setting soc_overlay_background{linkage, + false, + "soc_overlay_background", + Settings::Category::Overlay, + Settings::Specialization::Default, + true, + true, + &show_soc_overlay}; + Settings::Setting soc_overlay_position{linkage, + 2, + "soc_overlay_position", Settings::Category::Overlay, - Settings::Specialization::Default, true, true, - &show_performance_overlay}; + Settings::Specialization::Default, + true, + true, + &show_soc_overlay}; - Settings::Setting soc_overlay_background{linkage, false, "soc_overlay_background", - Settings::Category::Overlay, - Settings::Specialization::Default, true, - true, - &show_soc_overlay}; - Settings::Setting soc_overlay_position{linkage, 2, "soc_overlay_position", - Settings::Category::Overlay, - Settings::Specialization::Default, true, true, - &show_soc_overlay}; + Settings::Setting dont_show_eden_veil_warning{ + linkage, false, "dont_show_eden_veil_warning", Settings::Category::Miscellaneous}; +}; - Settings::Setting dont_show_eden_veil_warning{linkage, false, - "dont_show_eden_veil_warning", - Settings::Category::Miscellaneous}; - }; - - extern Values values; +extern Values values; } // namespace AndroidSettings diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 9fed0b1449..36f7d04386 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -4,7 +4,6 @@ // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later - #include #include #include @@ -24,9 +23,9 @@ #include #include -#include "common/android/multiplayer/multiplayer.h" #include "common/android/android_common.h" #include "common/android/id_cache.h" +#include "common/android/multiplayer/multiplayer.h" #include "common/detached_tasks.h" #include "common/dynamic_library.h" #include "common/fs/path_util.h" @@ -65,23 +64,23 @@ #include "hid_core/hid_core.h" #include "hid_core/hid_types.h" #include "jni/native.h" +#include "network/announce_multiplayer_session.h" #include "video_core/renderer_base.h" #include "video_core/renderer_vulkan/renderer_vulkan.h" +#include "video_core/shader_notify.h" #include "video_core/vulkan_common/vulkan_instance.h" #include "video_core/vulkan_common/vulkan_surface.h" -#include "video_core/shader_notify.h" -#include "network/announce_multiplayer_session.h" #define jconst [[maybe_unused]] const auto #define jauto [[maybe_unused]] auto static EmulationSession s_instance; -//Abdroid Multiplayer which can be initialized with parameters +// Abdroid Multiplayer which can be initialized with parameters std::unique_ptr multiplayer{nullptr}; std::shared_ptr announce_multiplayer_session; -//Power Status default values +// Power Status default values std::atomic g_battery_percentage = {100}; std::atomic g_is_charging = {false}; std::atomic g_has_battery = {true}; @@ -581,7 +580,9 @@ jobjectArray Java_org_yuzu_yuzu_1emu_utils_GpuDriverHelper_getSystemDriverInfo( return j_driver_info; } -jstring Java_org_yuzu_yuzu_1emu_utils_GpuDriverHelper_getGpuModel(JNIEnv *env, jobject j_obj, jobject j_surf, jstring j_hook_lib_dir) { +jstring Java_org_yuzu_yuzu_1emu_utils_GpuDriverHelper_getGpuModel(JNIEnv* env, jobject j_obj, + jobject j_surf, + jstring j_hook_lib_dir) { const char* file_redirect_dir_{}; int featureFlags{}; std::string hook_lib_dir = Common::Android::GetJString(env, j_hook_lib_dir); @@ -590,11 +591,11 @@ jstring Java_org_yuzu_yuzu_1emu_utils_GpuDriverHelper_getGpuModel(JNIEnv *env, j auto driver_library = std::make_shared(handle); InputCommon::InputSubsystem input_subsystem; auto window = - std::make_unique(ANativeWindow_fromSurface(env, j_surf), driver_library); + std::make_unique(ANativeWindow_fromSurface(env, j_surf), driver_library); Vulkan::vk::InstanceDispatch dld; Vulkan::vk::Instance vk_instance = Vulkan::CreateInstance( - *driver_library, dld, VK_API_VERSION_1_1, Core::Frontend::WindowSystemType::Android); + *driver_library, dld, VK_API_VERSION_1_1, Core::Frontend::WindowSystemType::Android); auto surface = Vulkan::CreateSurface(vk_instance, window->GetWindowInfo()); @@ -791,16 +792,19 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_firmwareVersion(JNIEnv* env, jclas } jint Java_org_yuzu_yuzu_1emu_NativeLibrary_verifyFirmware(JNIEnv* env, jclass clazz) { - return static_cast(FirmwareManager::VerifyFirmware(EmulationSession::GetInstance().System())); + return static_cast( + FirmwareManager::VerifyFirmware(EmulationSession::GetInstance().System())); } -jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_gameRequiresFirmware(JNIEnv* env, jclass clazz, jstring jprogramId) { +jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_gameRequiresFirmware(JNIEnv* env, jclass clazz, + jstring jprogramId) { auto program_id = EmulationSession::GetProgramId(env, jprogramId); return FirmwareManager::GameRequiresFirmware(program_id); } -jint Java_org_yuzu_yuzu_1emu_NativeLibrary_installKeys(JNIEnv* env, jclass clazz, jstring jpath, jstring jext) { +jint Java_org_yuzu_yuzu_1emu_NativeLibrary_installKeys(JNIEnv* env, jclass clazz, jstring jpath, + jstring jext) { const auto path = Common::Android::GetJString(env, jpath); const auto ext = Common::Android::GetJString(env, jext); @@ -957,105 +961,97 @@ jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_areKeysPresent(JNIEnv* env, jobje } JNIEXPORT void JNICALL -Java_org_yuzu_yuzu_1emu_NativeLibrary_initMultiplayer( - JNIEnv* env, [[maybe_unused]] jobject obj) { +Java_org_yuzu_yuzu_1emu_NativeLibrary_initMultiplayer(JNIEnv* env, [[maybe_unused]] jobject obj) { if (multiplayer) { return; } announce_multiplayer_session = std::make_shared(); - multiplayer = std::make_unique(s_instance.System(), announce_multiplayer_session); + multiplayer = + std::make_unique(s_instance.System(), announce_multiplayer_session); multiplayer->NetworkInit(); } -JNIEXPORT jobjectArray JNICALL -Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayGetPublicRooms( - JNIEnv *env, [[maybe_unused]] jobject obj) { +JNIEXPORT jobjectArray JNICALL Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayGetPublicRooms( + JNIEnv* env, [[maybe_unused]] jobject obj) { return Common::Android::ToJStringArray(env, multiplayer->NetPlayGetPublicRooms()); } JNIEXPORT jint JNICALL Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayCreateRoom( - JNIEnv* env, [[maybe_unused]] jobject obj, jstring ipaddress, jint port, - jstring username, jstring preferredGameName, jlong preferredGameId, jstring password, - jstring room_name, jint max_players, jboolean isPublic) { - return static_cast( - multiplayer->NetPlayCreateRoom(Common::Android::GetJString(env, ipaddress), port, - Common::Android::GetJString(env, username), Common::Android::GetJString(env, preferredGameName), - preferredGameId,Common::Android::GetJString(env, password), - Common::Android::GetJString(env, room_name), max_players, isPublic)); + JNIEnv* env, [[maybe_unused]] jobject obj, jstring ipaddress, jint port, jstring username, + jstring preferredGameName, jlong preferredGameId, jstring password, jstring room_name, + jint max_players, jboolean isPublic) { + return static_cast(multiplayer->NetPlayCreateRoom( + Common::Android::GetJString(env, ipaddress), port, + Common::Android::GetJString(env, username), + Common::Android::GetJString(env, preferredGameName), preferredGameId, + Common::Android::GetJString(env, password), Common::Android::GetJString(env, room_name), + max_players, isPublic)); } JNIEXPORT jint JNICALL Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayJoinRoom( - JNIEnv* env, [[maybe_unused]] jobject obj, jstring ipaddress, jint port, - jstring username, jstring password) { - return static_cast( - multiplayer->NetPlayJoinRoom(Common::Android::GetJString(env, ipaddress), port, - Common::Android::GetJString(env, username), Common::Android::GetJString(env, password))); + JNIEnv* env, [[maybe_unused]] jobject obj, jstring ipaddress, jint port, jstring username, + jstring password) { + return static_cast(multiplayer->NetPlayJoinRoom( + Common::Android::GetJString(env, ipaddress), port, + Common::Android::GetJString(env, username), Common::Android::GetJString(env, password))); } -JNIEXPORT jobjectArray JNICALL -Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayRoomInfo( - JNIEnv* env, [[maybe_unused]] jobject obj) { +JNIEXPORT jobjectArray JNICALL Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayRoomInfo( + JNIEnv* env, [[maybe_unused]] jobject obj) { return Common::Android::ToJStringArray(env, multiplayer->NetPlayRoomInfo()); } -JNIEXPORT jboolean JNICALL -Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayIsJoined( - [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { +JNIEXPORT jboolean JNICALL Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayIsJoined( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { return multiplayer->NetPlayIsJoined(); } -JNIEXPORT jboolean JNICALL -Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayIsHostedRoom( - [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { +JNIEXPORT jboolean JNICALL Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayIsHostedRoom( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { return multiplayer->NetPlayIsHostedRoom(); } -JNIEXPORT void JNICALL -Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlaySendMessage( - JNIEnv* env, [[maybe_unused]] jobject obj, jstring msg) { +JNIEXPORT void JNICALL Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlaySendMessage( + JNIEnv* env, [[maybe_unused]] jobject obj, jstring msg) { multiplayer->NetPlaySendMessage(Common::Android::GetJString(env, msg)); } JNIEXPORT void JNICALL Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayKickUser( - JNIEnv* env, [[maybe_unused]] jobject obj, jstring username) { + JNIEnv* env, [[maybe_unused]] jobject obj, jstring username) { multiplayer->NetPlayKickUser(Common::Android::GetJString(env, username)); } JNIEXPORT void JNICALL Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayLeaveRoom( - [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { multiplayer->NetPlayLeaveRoom(); } -JNIEXPORT jboolean JNICALL -Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayIsModerator( - [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { +JNIEXPORT jboolean JNICALL Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayIsModerator( + [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj) { return multiplayer->NetPlayIsModerator(); } -JNIEXPORT jobjectArray JNICALL -Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayGetBanList( - JNIEnv* env, [[maybe_unused]] jobject obj) { +JNIEXPORT jobjectArray JNICALL Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayGetBanList( + JNIEnv* env, [[maybe_unused]] jobject obj) { return Common::Android::ToJStringArray(env, multiplayer->NetPlayGetBanList()); } JNIEXPORT void JNICALL Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayBanUser( - JNIEnv* env, [[maybe_unused]] jobject obj, jstring username) { + JNIEnv* env, [[maybe_unused]] jobject obj, jstring username) { multiplayer->NetPlayBanUser(Common::Android::GetJString(env, username)); } JNIEXPORT void JNICALL Java_org_yuzu_yuzu_1emu_network_NetPlayManager_netPlayUnbanUser( - JNIEnv* env, [[maybe_unused]] jobject obj, jstring username) { + JNIEnv* env, [[maybe_unused]] jobject obj, jstring username) { multiplayer->NetPlayUnbanUser(Common::Android::GetJString(env, username)); } -JNIEXPORT void JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_updatePowerState( - JNIEnv* env, - jobject, - jint percentage, - jboolean isCharging, - jboolean hasBattery) { +JNIEXPORT void JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_updatePowerState(JNIEnv* env, jobject, + jint percentage, + jboolean isCharging, + jboolean hasBattery) { g_battery_percentage.store(percentage, std::memory_order_relaxed); g_is_charging.store(isCharging, std::memory_order_relaxed); diff --git a/src/audio_core/in/audio_in.cpp b/src/audio_core/in/audio_in.cpp index df8c44d1f2..b28eb69786 100644 --- a/src/audio_core/in/audio_in.cpp +++ b/src/audio_core/in/audio_in.cpp @@ -8,8 +8,8 @@ namespace AudioCore::AudioIn { In::In(Core::System& system_, Manager& manager_, Kernel::KEvent* event_, size_t session_id_) - : manager{manager_}, parent_mutex{manager.mutex}, event{event_}, system{system_, event, - session_id_} {} + : manager{manager_}, parent_mutex{manager.mutex}, event{event_}, + system{system_, event, session_id_} {} void In::Free() { std::scoped_lock l{parent_mutex}; diff --git a/src/audio_core/in/audio_in_system.cpp b/src/audio_core/in/audio_in_system.cpp index b2dd3ef9f7..84d99877cb 100644 --- a/src/audio_core/in/audio_in_system.cpp +++ b/src/audio_core/in/audio_in_system.cpp @@ -14,8 +14,8 @@ namespace AudioCore::AudioIn { System::System(Core::System& system_, Kernel::KEvent* event_, const size_t session_id_) - : system{system_}, buffer_event{event_}, - session_id{session_id_}, session{std::make_unique(system_)} {} + : system{system_}, buffer_event{event_}, session_id{session_id_}, + session{std::make_unique(system_)} {} System::~System() { Finalize(); diff --git a/src/audio_core/out/audio_out.cpp b/src/audio_core/out/audio_out.cpp index b7ea134055..d31bced9df 100644 --- a/src/audio_core/out/audio_out.cpp +++ b/src/audio_core/out/audio_out.cpp @@ -8,8 +8,8 @@ namespace AudioCore::AudioOut { Out::Out(Core::System& system_, Manager& manager_, Kernel::KEvent* event_, size_t session_id_) - : manager{manager_}, parent_mutex{manager.mutex}, event{event_}, system{system_, event, - session_id_} {} + : manager{manager_}, parent_mutex{manager.mutex}, event{event_}, + system{system_, event, session_id_} {} void Out::Free() { std::scoped_lock l{parent_mutex}; diff --git a/src/audio_core/out/audio_out_system.cpp b/src/audio_core/out/audio_out_system.cpp index 7b3ff4e881..4c940be2d3 100644 --- a/src/audio_core/out/audio_out_system.cpp +++ b/src/audio_core/out/audio_out_system.cpp @@ -14,8 +14,8 @@ namespace AudioCore::AudioOut { System::System(Core::System& system_, Kernel::KEvent* event_, size_t session_id_) - : system{system_}, buffer_event{event_}, - session_id{session_id_}, session{std::make_unique(system_)} {} + : system{system_}, buffer_event{event_}, session_id{session_id_}, + session{std::make_unique(system_)} {} System::~System() { Finalize(); diff --git a/src/audio_core/renderer/behavior/info_updater.cpp b/src/audio_core/renderer/behavior/info_updater.cpp index 3dae6069f7..163127789c 100644 --- a/src/audio_core/renderer/behavior/info_updater.cpp +++ b/src/audio_core/renderer/behavior/info_updater.cpp @@ -19,10 +19,9 @@ namespace AudioCore::Renderer { InfoUpdater::InfoUpdater(std::span input_, std::span output_, Kernel::KProcess* process_handle_, BehaviorInfo& behaviour_) - : input{input_.data() + sizeof(UpdateDataHeader)}, - input_origin{input_}, output{output_.data() + sizeof(UpdateDataHeader)}, - output_origin{output_}, in_header{reinterpret_cast( - input_origin.data())}, + : input{input_.data() + sizeof(UpdateDataHeader)}, input_origin{input_}, + output{output_.data() + sizeof(UpdateDataHeader)}, output_origin{output_}, + in_header{reinterpret_cast(input_origin.data())}, out_header{reinterpret_cast(output_origin.data())}, expected_input_size{input_.size()}, expected_output_size{output_.size()}, process_handle{process_handle_}, behaviour{behaviour_} { diff --git a/src/audio_core/renderer/memory/pool_mapper.cpp b/src/audio_core/renderer/memory/pool_mapper.cpp index e47eb66d51..1df786feb5 100644 --- a/src/audio_core/renderer/memory/pool_mapper.cpp +++ b/src/audio_core/renderer/memory/pool_mapper.cpp @@ -13,8 +13,8 @@ PoolMapper::PoolMapper(Kernel::KProcess* process_handle_, bool force_map_) PoolMapper::PoolMapper(Kernel::KProcess* process_handle_, std::span pool_infos_, u32 pool_count_, bool force_map_) - : process_handle{process_handle_}, pool_infos{pool_infos_.data()}, - pool_count{pool_count_}, force_map{force_map_} {} + : process_handle{process_handle_}, pool_infos{pool_infos_.data()}, pool_count{pool_count_}, + force_map{force_map_} {} void PoolMapper::ClearUseState(std::span pools, const u32 count) { for (u32 i = 0; i < count; i++) { diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index 0a98eb31e2..e687d201aa 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp @@ -240,7 +240,9 @@ void SinkStream::ProcessAudioOutAndRender(std::span output_buffer, std::siz // Successfully dequeued a new buffer. queued_buffers--; - { std::unique_lock lk{release_mutex}; } + { + std::unique_lock lk{release_mutex}; + } release_cv.notify_one(); } diff --git a/src/common/address_space.h b/src/common/address_space.h index 8683c23c39..694bb2aed3 100644 --- a/src/common/address_space.h +++ b/src/common/address_space.h @@ -12,8 +12,7 @@ namespace Common { template -concept AddressSpaceValid = std::is_unsigned_v && sizeof(VaType) * 8 >= -AddressSpaceBits; +concept AddressSpaceValid = std::is_unsigned_v && sizeof(VaType) * 8 >= AddressSpaceBits; struct EmptyStruct {}; diff --git a/src/common/android/android_common.cpp b/src/common/android/android_common.cpp index a1cf081695..14598fe2f0 100644 --- a/src/common/android/android_common.cpp +++ b/src/common/android/android_common.cpp @@ -38,8 +38,8 @@ jstring ToJString(JNIEnv* env, std::string_view str) { } jobjectArray ToJStringArray(JNIEnv* env, const std::vector& strs) { - jobjectArray array = - env->NewObjectArray(static_cast(strs.size()), env->FindClass("java/lang/String"), env->NewStringUTF("")); + jobjectArray array = env->NewObjectArray( + static_cast(strs.size()), env->FindClass("java/lang/String"), env->NewStringUTF("")); for (std::size_t i = 0; i < strs.size(); ++i) { env->SetObjectArrayElement(array, static_cast(i), ToJString(env, strs[i])); } diff --git a/src/common/android/id_cache.cpp b/src/common/android/id_cache.cpp index e0edd006a5..1d53710e32 100644 --- a/src/common/android/id_cache.cpp +++ b/src/common/android/id_cache.cpp @@ -6,16 +6,15 @@ #include +#include #include "applets/software_keyboard.h" #include "common/android/id_cache.h" +#include "common/android/multiplayer/multiplayer.h" #include "common/assert.h" #include "common/fs/fs_android.h" #include "video_core/rasterizer_interface.h" -#include "common/android/multiplayer/multiplayer.h" -#include - -static JavaVM *s_java_vm; +static JavaVM* s_java_vm; static jclass s_native_library_class; static jclass s_disk_cache_progress_class; static jclass s_load_callback_stage_class; @@ -105,534 +104,530 @@ static constexpr jint JNI_VERSION = JNI_VERSION_1_6; namespace Common::Android { - JNIEnv *GetEnvForThread() { - thread_local static struct OwnedEnv { - OwnedEnv() { - status = s_java_vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6); - if (status == JNI_EDETACHED) - s_java_vm->AttachCurrentThread(&env, nullptr); - } - - ~OwnedEnv() { - if (status == JNI_EDETACHED) - s_java_vm->DetachCurrentThread(); - } - - int status; - JNIEnv *env = nullptr; - } owned; - return owned.env; - } - - jclass GetNativeLibraryClass() { - return s_native_library_class; - } - - jclass GetDiskCacheProgressClass() { - return s_disk_cache_progress_class; - } - - jclass GetDiskCacheLoadCallbackStageClass() { - return s_load_callback_stage_class; - } - - jclass GetGameDirClass() { - return s_game_dir_class; - } - - jmethodID GetGameDirConstructor() { - return s_game_dir_constructor; - } - - jmethodID GetExitEmulationActivity() { - return s_exit_emulation_activity; - } - - jmethodID GetDiskCacheLoadProgress() { - return s_disk_cache_load_progress; - } - - jmethodID GetCopyToStorage() { - return s_copy_to_storage; - } - - jmethodID GetFileExists() { - return s_file_exists; - } - - jmethodID GetFileExtension() { - return s_file_extension; - } - - jmethodID GetOnEmulationStarted() { - return s_on_emulation_started; - } - - jmethodID GetOnEmulationStopped() { - return s_on_emulation_stopped; - } - - jmethodID GetOnProgramChanged() { - return s_on_program_changed; - } - - jclass GetGameClass() { - return s_game_class; - } - - jmethodID GetGameConstructor() { - return s_game_constructor; - } - - jfieldID GetGameTitleField() { - return s_game_title_field; - } - - jfieldID GetGamePathField() { - return s_game_path_field; - } - - jfieldID GetGameProgramIdField() { - return s_game_program_id_field; - } - - jfieldID GetGameDeveloperField() { - return s_game_developer_field; - } - - jfieldID GetGameVersionField() { - return s_game_version_field; - } - - jfieldID GetGameIsHomebrewField() { - return s_game_is_homebrew_field; - } - - jclass GetStringClass() { - return s_string_class; - } - - jclass GetPairClass() { - return s_pair_class; - } - - jmethodID GetPairConstructor() { - return s_pair_constructor; - } - - jfieldID GetPairFirstField() { - return s_pair_first_field; - } - - jfieldID GetPairSecondField() { - return s_pair_second_field; - } - - jclass GetOverlayControlDataClass() { - return s_overlay_control_data_class; - } - - jmethodID GetOverlayControlDataConstructor() { - return s_overlay_control_data_constructor; - } - - jfieldID GetOverlayControlDataIdField() { - return s_overlay_control_data_id_field; - } - - jfieldID GetOverlayControlDataEnabledField() { - return s_overlay_control_data_enabled_field; - } - - jfieldID GetOverlayControlDataLandscapePositionField() { - return s_overlay_control_data_landscape_position_field; - } - - jfieldID GetOverlayControlDataPortraitPositionField() { - return s_overlay_control_data_portrait_position_field; - } - - jfieldID GetOverlayControlDataFoldablePositionField() { - return s_overlay_control_data_foldable_position_field; - } - - jclass GetPatchClass() { - return s_patch_class; - } - - jmethodID GetPatchConstructor() { - return s_patch_constructor; - } - - jfieldID GetPatchEnabledField() { - return s_patch_enabled_field; - } - - jfieldID GetPatchNameField() { - return s_patch_name_field; - } - - jfieldID GetPatchVersionField() { - return s_patch_version_field; - } - - jfieldID GetPatchTypeField() { - return s_patch_type_field; - } - - jfieldID GetPatchProgramIdField() { - return s_patch_program_id_field; - } - - jfieldID GetPatchTitleIdField() { - return s_patch_title_id_field; - } - - jclass GetDoubleClass() { - return s_double_class; - } - - jmethodID GetDoubleConstructor() { - return s_double_constructor; - } - - jfieldID GetDoubleValueField() { - return s_double_value_field; - } - - jclass GetIntegerClass() { - return s_integer_class; - } - - jmethodID GetIntegerConstructor() { - return s_integer_constructor; - } - - jfieldID GetIntegerValueField() { - return s_integer_value_field; - } - - jclass GetBooleanClass() { - return s_boolean_class; - } - - jmethodID GetBooleanConstructor() { - return s_boolean_constructor; - } - - jfieldID GetBooleanValueField() { - return s_boolean_value_field; - } - - jclass GetPlayerInputClass() { - return s_player_input_class; - } - - jmethodID GetPlayerInputConstructor() { - return s_player_input_constructor; - } - - jfieldID GetPlayerInputConnectedField() { - return s_player_input_connected_field; - } - - jfieldID GetPlayerInputButtonsField() { - return s_player_input_buttons_field; - } - - jfieldID GetPlayerInputAnalogsField() { - return s_player_input_analogs_field; - } - - jfieldID GetPlayerInputMotionsField() { - return s_player_input_motions_field; - } - - jfieldID GetPlayerInputVibrationEnabledField() { - return s_player_input_vibration_enabled_field; - } - - jfieldID GetPlayerInputVibrationStrengthField() { - return s_player_input_vibration_strength_field; - } - - jfieldID GetPlayerInputBodyColorLeftField() { - return s_player_input_body_color_left_field; - } - - jfieldID GetPlayerInputBodyColorRightField() { - return s_player_input_body_color_right_field; - } - - jfieldID GetPlayerInputButtonColorLeftField() { - return s_player_input_button_color_left_field; - } - - jfieldID GetPlayerInputButtonColorRightField() { - return s_player_input_button_color_right_field; - } - - jfieldID GetPlayerInputProfileNameField() { - return s_player_input_profile_name_field; - } - - jfieldID GetPlayerInputUseSystemVibratorField() { - return s_player_input_use_system_vibrator_field; - } - - jclass GetYuzuInputDeviceInterface() { - return s_yuzu_input_device_interface; - } - - jmethodID GetYuzuDeviceGetName() { - return s_yuzu_input_device_get_name; - } - - jmethodID GetYuzuDeviceGetGUID() { - return s_yuzu_input_device_get_guid; - } - - jmethodID GetYuzuDeviceGetPort() { - return s_yuzu_input_device_get_port; - } - - jmethodID GetYuzuDeviceGetSupportsVibration() { - return s_yuzu_input_device_get_supports_vibration; - } - - jmethodID GetYuzuDeviceVibrate() { - return s_yuzu_input_device_vibrate; - } - - jmethodID GetYuzuDeviceGetAxes() { - return s_yuzu_input_device_get_axes; - } - - jmethodID GetYuzuDeviceHasKeys() { - return s_yuzu_input_device_has_keys; - } - - jmethodID GetAddNetPlayMessage() { - return s_add_netplay_message; - } - - jmethodID ClearChat() { - return s_clear_chat; - } - -#ifdef __cplusplus - extern "C" { -#endif - - jint JNI_OnLoad(JavaVM *vm, void *reserved) { - s_java_vm = vm; - - JNIEnv *env; - if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION) != JNI_OK) - return JNI_ERR; - - // Initialize Java classes - const jclass native_library_class = env->FindClass("org/yuzu/yuzu_emu/NativeLibrary"); - s_native_library_class = reinterpret_cast(env->NewGlobalRef(native_library_class)); - s_disk_cache_progress_class = reinterpret_cast(env->NewGlobalRef( - env->FindClass("org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress"))); - s_load_callback_stage_class = reinterpret_cast(env->NewGlobalRef(env->FindClass( - "org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress$LoadCallbackStage"))); - - const jclass game_dir_class = env->FindClass("org/yuzu/yuzu_emu/model/GameDir"); - s_game_dir_class = reinterpret_cast(env->NewGlobalRef(game_dir_class)); - s_game_dir_constructor = env->GetMethodID(game_dir_class, "", - "(Ljava/lang/String;Z)V"); - env->DeleteLocalRef(game_dir_class); - - // Initialize methods - s_exit_emulation_activity = - env->GetStaticMethodID(s_native_library_class, "exitEmulationActivity", "(I)V"); - s_disk_cache_load_progress = - env->GetStaticMethodID(s_disk_cache_progress_class, "loadProgress", "(III)V"); - s_copy_to_storage = env->GetStaticMethodID(s_native_library_class, "copyFileToStorage", - "(Ljava/lang/String;Ljava/lang/String;)Z"); - s_file_exists = env->GetStaticMethodID(s_native_library_class, "exists", - "(Ljava/lang/String;)Z"); - s_file_extension = env->GetStaticMethodID(s_native_library_class, "getFileExtension", - "(Ljava/lang/String;)Ljava/lang/String;"); - s_on_emulation_started = - env->GetStaticMethodID(s_native_library_class, "onEmulationStarted", "()V"); - s_on_emulation_stopped = - env->GetStaticMethodID(s_native_library_class, "onEmulationStopped", "(I)V"); - s_on_program_changed = - env->GetStaticMethodID(s_native_library_class, "onProgramChanged", "(I)V"); - - const jclass game_class = env->FindClass("org/yuzu/yuzu_emu/model/Game"); - s_game_class = reinterpret_cast(env->NewGlobalRef(game_class)); - s_game_constructor = env->GetMethodID(game_class, "", - "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/" - "String;Ljava/lang/String;Ljava/lang/String;Z)V"); - s_game_title_field = env->GetFieldID(game_class, "title", "Ljava/lang/String;"); - s_game_path_field = env->GetFieldID(game_class, "path", "Ljava/lang/String;"); - s_game_program_id_field = env->GetFieldID(game_class, "programId", "Ljava/lang/String;"); - s_game_developer_field = env->GetFieldID(game_class, "developer", "Ljava/lang/String;"); - s_game_version_field = env->GetFieldID(game_class, "version", "Ljava/lang/String;"); - s_game_is_homebrew_field = env->GetFieldID(game_class, "isHomebrew", "Z"); - env->DeleteLocalRef(game_class); - - const jclass string_class = env->FindClass("java/lang/String"); - s_string_class = reinterpret_cast(env->NewGlobalRef(string_class)); - env->DeleteLocalRef(string_class); - - const jclass pair_class = env->FindClass("kotlin/Pair"); - s_pair_class = reinterpret_cast(env->NewGlobalRef(pair_class)); - s_pair_constructor = - env->GetMethodID(pair_class, "", "(Ljava/lang/Object;Ljava/lang/Object;)V"); - s_pair_first_field = env->GetFieldID(pair_class, "first", "Ljava/lang/Object;"); - s_pair_second_field = env->GetFieldID(pair_class, "second", "Ljava/lang/Object;"); - env->DeleteLocalRef(pair_class); - - const jclass overlay_control_data_class = - env->FindClass("org/yuzu/yuzu_emu/overlay/model/OverlayControlData"); - s_overlay_control_data_class = - reinterpret_cast(env->NewGlobalRef(overlay_control_data_class)); - s_overlay_control_data_constructor = - env->GetMethodID(overlay_control_data_class, "", - "(Ljava/lang/String;ZLkotlin/Pair;Lkotlin/Pair;Lkotlin/Pair;)V"); - s_overlay_control_data_id_field = - env->GetFieldID(overlay_control_data_class, "id", "Ljava/lang/String;"); - s_overlay_control_data_enabled_field = - env->GetFieldID(overlay_control_data_class, "enabled", "Z"); - s_overlay_control_data_landscape_position_field = - env->GetFieldID(overlay_control_data_class, "landscapePosition", "Lkotlin/Pair;"); - s_overlay_control_data_portrait_position_field = - env->GetFieldID(overlay_control_data_class, "portraitPosition", "Lkotlin/Pair;"); - s_overlay_control_data_foldable_position_field = - env->GetFieldID(overlay_control_data_class, "foldablePosition", "Lkotlin/Pair;"); - env->DeleteLocalRef(overlay_control_data_class); - - const jclass patch_class = env->FindClass("org/yuzu/yuzu_emu/model/Patch"); - s_patch_class = reinterpret_cast(env->NewGlobalRef(patch_class)); - s_patch_constructor = env->GetMethodID( - patch_class, "", - "(ZLjava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)V"); - s_patch_enabled_field = env->GetFieldID(patch_class, "enabled", "Z"); - s_patch_name_field = env->GetFieldID(patch_class, "name", "Ljava/lang/String;"); - s_patch_version_field = env->GetFieldID(patch_class, "version", "Ljava/lang/String;"); - s_patch_type_field = env->GetFieldID(patch_class, "type", "I"); - s_patch_program_id_field = env->GetFieldID(patch_class, "programId", "Ljava/lang/String;"); - s_patch_title_id_field = env->GetFieldID(patch_class, "titleId", "Ljava/lang/String;"); - env->DeleteLocalRef(patch_class); - - const jclass double_class = env->FindClass("java/lang/Double"); - s_double_class = reinterpret_cast(env->NewGlobalRef(double_class)); - s_double_constructor = env->GetMethodID(double_class, "", "(D)V"); - s_double_value_field = env->GetFieldID(double_class, "value", "D"); - env->DeleteLocalRef(double_class); - - const jclass int_class = env->FindClass("java/lang/Integer"); - s_integer_class = reinterpret_cast(env->NewGlobalRef(int_class)); - s_integer_constructor = env->GetMethodID(int_class, "", "(I)V"); - s_integer_value_field = env->GetFieldID(int_class, "value", "I"); - env->DeleteLocalRef(int_class); - - const jclass boolean_class = env->FindClass("java/lang/Boolean"); - s_boolean_class = reinterpret_cast(env->NewGlobalRef(boolean_class)); - s_boolean_constructor = env->GetMethodID(boolean_class, "", "(Z)V"); - s_boolean_value_field = env->GetFieldID(boolean_class, "value", "Z"); - env->DeleteLocalRef(boolean_class); - - const jclass player_input_class = - env->FindClass("org/yuzu/yuzu_emu/features/input/model/PlayerInput"); - s_player_input_class = reinterpret_cast(env->NewGlobalRef(player_input_class)); - s_player_input_constructor = env->GetMethodID( - player_input_class, "", - "(Z[Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;ZIJJJJLjava/lang/String;Z)V"); - s_player_input_connected_field = env->GetFieldID(player_input_class, "connected", "Z"); - s_player_input_buttons_field = - env->GetFieldID(player_input_class, "buttons", "[Ljava/lang/String;"); - s_player_input_analogs_field = - env->GetFieldID(player_input_class, "analogs", "[Ljava/lang/String;"); - s_player_input_motions_field = - env->GetFieldID(player_input_class, "motions", "[Ljava/lang/String;"); - s_player_input_vibration_enabled_field = - env->GetFieldID(player_input_class, "vibrationEnabled", "Z"); - s_player_input_vibration_strength_field = - env->GetFieldID(player_input_class, "vibrationStrength", "I"); - s_player_input_body_color_left_field = - env->GetFieldID(player_input_class, "bodyColorLeft", "J"); - s_player_input_body_color_right_field = - env->GetFieldID(player_input_class, "bodyColorRight", "J"); - s_player_input_button_color_left_field = - env->GetFieldID(player_input_class, "buttonColorLeft", "J"); - s_player_input_button_color_right_field = - env->GetFieldID(player_input_class, "buttonColorRight", "J"); - s_player_input_profile_name_field = - env->GetFieldID(player_input_class, "profileName", "Ljava/lang/String;"); - s_player_input_use_system_vibrator_field = - env->GetFieldID(player_input_class, "useSystemVibrator", "Z"); - env->DeleteLocalRef(player_input_class); - - const jclass yuzu_input_device_interface = - env->FindClass("org/yuzu/yuzu_emu/features/input/YuzuInputDevice"); - s_yuzu_input_device_interface = - reinterpret_cast(env->NewGlobalRef(yuzu_input_device_interface)); - s_yuzu_input_device_get_name = - env->GetMethodID(yuzu_input_device_interface, "getName", "()Ljava/lang/String;"); - s_yuzu_input_device_get_guid = - env->GetMethodID(yuzu_input_device_interface, "getGUID", "()Ljava/lang/String;"); - s_yuzu_input_device_get_port = env->GetMethodID(yuzu_input_device_interface, "getPort", - "()I"); - s_yuzu_input_device_get_supports_vibration = - env->GetMethodID(yuzu_input_device_interface, "getSupportsVibration", "()Z"); - s_yuzu_input_device_vibrate = env->GetMethodID(yuzu_input_device_interface, "vibrate", - "(F)V"); - s_yuzu_input_device_get_axes = - env->GetMethodID(yuzu_input_device_interface, "getAxes", "()[Ljava/lang/Integer;"); - s_yuzu_input_device_has_keys = - env->GetMethodID(yuzu_input_device_interface, "hasKeys", "([I)[Z"); - env->DeleteLocalRef(yuzu_input_device_interface); - s_add_netplay_message = env->GetStaticMethodID(s_native_library_class, "addNetPlayMessage", - "(ILjava/lang/String;)V"); - s_clear_chat = env->GetStaticMethodID(s_native_library_class, "clearChat", "()V"); - - - // Initialize Android Storage - Common::FS::Android::RegisterCallbacks(env, s_native_library_class); - - // Initialize applets - Common::Android::SoftwareKeyboard::InitJNI(env); - - return JNI_VERSION; - } - - void JNI_OnUnload(JavaVM *vm, void *reserved) { - JNIEnv *env; - if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION) != JNI_OK) { - return; +JNIEnv* GetEnvForThread() { + thread_local static struct OwnedEnv { + OwnedEnv() { + status = s_java_vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6); + if (status == JNI_EDETACHED) + s_java_vm->AttachCurrentThread(&env, nullptr); } - // UnInitialize Android Storage - Common::FS::Android::UnRegisterCallbacks(); - env->DeleteGlobalRef(s_native_library_class); - env->DeleteGlobalRef(s_disk_cache_progress_class); - env->DeleteGlobalRef(s_load_callback_stage_class); - env->DeleteGlobalRef(s_game_dir_class); - env->DeleteGlobalRef(s_game_class); - env->DeleteGlobalRef(s_string_class); - env->DeleteGlobalRef(s_pair_class); - env->DeleteGlobalRef(s_overlay_control_data_class); - env->DeleteGlobalRef(s_patch_class); - env->DeleteGlobalRef(s_double_class); - env->DeleteGlobalRef(s_integer_class); - env->DeleteGlobalRef(s_boolean_class); - env->DeleteGlobalRef(s_player_input_class); - env->DeleteGlobalRef(s_yuzu_input_device_interface); + ~OwnedEnv() { + if (status == JNI_EDETACHED) + s_java_vm->DetachCurrentThread(); + } - // UnInitialize applets - SoftwareKeyboard::CleanupJNI(env); + int status; + JNIEnv* env = nullptr; + } owned; + return owned.env; +} - AndroidMultiplayer::NetworkShutdown(); - } +jclass GetNativeLibraryClass() { + return s_native_library_class; +} + +jclass GetDiskCacheProgressClass() { + return s_disk_cache_progress_class; +} + +jclass GetDiskCacheLoadCallbackStageClass() { + return s_load_callback_stage_class; +} + +jclass GetGameDirClass() { + return s_game_dir_class; +} + +jmethodID GetGameDirConstructor() { + return s_game_dir_constructor; +} + +jmethodID GetExitEmulationActivity() { + return s_exit_emulation_activity; +} + +jmethodID GetDiskCacheLoadProgress() { + return s_disk_cache_load_progress; +} + +jmethodID GetCopyToStorage() { + return s_copy_to_storage; +} + +jmethodID GetFileExists() { + return s_file_exists; +} + +jmethodID GetFileExtension() { + return s_file_extension; +} + +jmethodID GetOnEmulationStarted() { + return s_on_emulation_started; +} + +jmethodID GetOnEmulationStopped() { + return s_on_emulation_stopped; +} + +jmethodID GetOnProgramChanged() { + return s_on_program_changed; +} + +jclass GetGameClass() { + return s_game_class; +} + +jmethodID GetGameConstructor() { + return s_game_constructor; +} + +jfieldID GetGameTitleField() { + return s_game_title_field; +} + +jfieldID GetGamePathField() { + return s_game_path_field; +} + +jfieldID GetGameProgramIdField() { + return s_game_program_id_field; +} + +jfieldID GetGameDeveloperField() { + return s_game_developer_field; +} + +jfieldID GetGameVersionField() { + return s_game_version_field; +} + +jfieldID GetGameIsHomebrewField() { + return s_game_is_homebrew_field; +} + +jclass GetStringClass() { + return s_string_class; +} + +jclass GetPairClass() { + return s_pair_class; +} + +jmethodID GetPairConstructor() { + return s_pair_constructor; +} + +jfieldID GetPairFirstField() { + return s_pair_first_field; +} + +jfieldID GetPairSecondField() { + return s_pair_second_field; +} + +jclass GetOverlayControlDataClass() { + return s_overlay_control_data_class; +} + +jmethodID GetOverlayControlDataConstructor() { + return s_overlay_control_data_constructor; +} + +jfieldID GetOverlayControlDataIdField() { + return s_overlay_control_data_id_field; +} + +jfieldID GetOverlayControlDataEnabledField() { + return s_overlay_control_data_enabled_field; +} + +jfieldID GetOverlayControlDataLandscapePositionField() { + return s_overlay_control_data_landscape_position_field; +} + +jfieldID GetOverlayControlDataPortraitPositionField() { + return s_overlay_control_data_portrait_position_field; +} + +jfieldID GetOverlayControlDataFoldablePositionField() { + return s_overlay_control_data_foldable_position_field; +} + +jclass GetPatchClass() { + return s_patch_class; +} + +jmethodID GetPatchConstructor() { + return s_patch_constructor; +} + +jfieldID GetPatchEnabledField() { + return s_patch_enabled_field; +} + +jfieldID GetPatchNameField() { + return s_patch_name_field; +} + +jfieldID GetPatchVersionField() { + return s_patch_version_field; +} + +jfieldID GetPatchTypeField() { + return s_patch_type_field; +} + +jfieldID GetPatchProgramIdField() { + return s_patch_program_id_field; +} + +jfieldID GetPatchTitleIdField() { + return s_patch_title_id_field; +} + +jclass GetDoubleClass() { + return s_double_class; +} + +jmethodID GetDoubleConstructor() { + return s_double_constructor; +} + +jfieldID GetDoubleValueField() { + return s_double_value_field; +} + +jclass GetIntegerClass() { + return s_integer_class; +} + +jmethodID GetIntegerConstructor() { + return s_integer_constructor; +} + +jfieldID GetIntegerValueField() { + return s_integer_value_field; +} + +jclass GetBooleanClass() { + return s_boolean_class; +} + +jmethodID GetBooleanConstructor() { + return s_boolean_constructor; +} + +jfieldID GetBooleanValueField() { + return s_boolean_value_field; +} + +jclass GetPlayerInputClass() { + return s_player_input_class; +} + +jmethodID GetPlayerInputConstructor() { + return s_player_input_constructor; +} + +jfieldID GetPlayerInputConnectedField() { + return s_player_input_connected_field; +} + +jfieldID GetPlayerInputButtonsField() { + return s_player_input_buttons_field; +} + +jfieldID GetPlayerInputAnalogsField() { + return s_player_input_analogs_field; +} + +jfieldID GetPlayerInputMotionsField() { + return s_player_input_motions_field; +} + +jfieldID GetPlayerInputVibrationEnabledField() { + return s_player_input_vibration_enabled_field; +} + +jfieldID GetPlayerInputVibrationStrengthField() { + return s_player_input_vibration_strength_field; +} + +jfieldID GetPlayerInputBodyColorLeftField() { + return s_player_input_body_color_left_field; +} + +jfieldID GetPlayerInputBodyColorRightField() { + return s_player_input_body_color_right_field; +} + +jfieldID GetPlayerInputButtonColorLeftField() { + return s_player_input_button_color_left_field; +} + +jfieldID GetPlayerInputButtonColorRightField() { + return s_player_input_button_color_right_field; +} + +jfieldID GetPlayerInputProfileNameField() { + return s_player_input_profile_name_field; +} + +jfieldID GetPlayerInputUseSystemVibratorField() { + return s_player_input_use_system_vibrator_field; +} + +jclass GetYuzuInputDeviceInterface() { + return s_yuzu_input_device_interface; +} + +jmethodID GetYuzuDeviceGetName() { + return s_yuzu_input_device_get_name; +} + +jmethodID GetYuzuDeviceGetGUID() { + return s_yuzu_input_device_get_guid; +} + +jmethodID GetYuzuDeviceGetPort() { + return s_yuzu_input_device_get_port; +} + +jmethodID GetYuzuDeviceGetSupportsVibration() { + return s_yuzu_input_device_get_supports_vibration; +} + +jmethodID GetYuzuDeviceVibrate() { + return s_yuzu_input_device_vibrate; +} + +jmethodID GetYuzuDeviceGetAxes() { + return s_yuzu_input_device_get_axes; +} + +jmethodID GetYuzuDeviceHasKeys() { + return s_yuzu_input_device_has_keys; +} + +jmethodID GetAddNetPlayMessage() { + return s_add_netplay_message; +} + +jmethodID ClearChat() { + return s_clear_chat; +} #ifdef __cplusplus +extern "C" { +#endif + +jint JNI_OnLoad(JavaVM* vm, void* reserved) { + s_java_vm = vm; + + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION) != JNI_OK) + return JNI_ERR; + + // Initialize Java classes + const jclass native_library_class = env->FindClass("org/yuzu/yuzu_emu/NativeLibrary"); + s_native_library_class = reinterpret_cast(env->NewGlobalRef(native_library_class)); + s_disk_cache_progress_class = reinterpret_cast(env->NewGlobalRef( + env->FindClass("org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress"))); + s_load_callback_stage_class = reinterpret_cast(env->NewGlobalRef(env->FindClass( + "org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress$LoadCallbackStage"))); + + const jclass game_dir_class = env->FindClass("org/yuzu/yuzu_emu/model/GameDir"); + s_game_dir_class = reinterpret_cast(env->NewGlobalRef(game_dir_class)); + s_game_dir_constructor = env->GetMethodID(game_dir_class, "", "(Ljava/lang/String;Z)V"); + env->DeleteLocalRef(game_dir_class); + + // Initialize methods + s_exit_emulation_activity = + env->GetStaticMethodID(s_native_library_class, "exitEmulationActivity", "(I)V"); + s_disk_cache_load_progress = + env->GetStaticMethodID(s_disk_cache_progress_class, "loadProgress", "(III)V"); + s_copy_to_storage = env->GetStaticMethodID(s_native_library_class, "copyFileToStorage", + "(Ljava/lang/String;Ljava/lang/String;)Z"); + s_file_exists = + env->GetStaticMethodID(s_native_library_class, "exists", "(Ljava/lang/String;)Z"); + s_file_extension = env->GetStaticMethodID(s_native_library_class, "getFileExtension", + "(Ljava/lang/String;)Ljava/lang/String;"); + s_on_emulation_started = + env->GetStaticMethodID(s_native_library_class, "onEmulationStarted", "()V"); + s_on_emulation_stopped = + env->GetStaticMethodID(s_native_library_class, "onEmulationStopped", "(I)V"); + s_on_program_changed = + env->GetStaticMethodID(s_native_library_class, "onProgramChanged", "(I)V"); + + const jclass game_class = env->FindClass("org/yuzu/yuzu_emu/model/Game"); + s_game_class = reinterpret_cast(env->NewGlobalRef(game_class)); + s_game_constructor = env->GetMethodID(game_class, "", + "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/" + "String;Ljava/lang/String;Ljava/lang/String;Z)V"); + s_game_title_field = env->GetFieldID(game_class, "title", "Ljava/lang/String;"); + s_game_path_field = env->GetFieldID(game_class, "path", "Ljava/lang/String;"); + s_game_program_id_field = env->GetFieldID(game_class, "programId", "Ljava/lang/String;"); + s_game_developer_field = env->GetFieldID(game_class, "developer", "Ljava/lang/String;"); + s_game_version_field = env->GetFieldID(game_class, "version", "Ljava/lang/String;"); + s_game_is_homebrew_field = env->GetFieldID(game_class, "isHomebrew", "Z"); + env->DeleteLocalRef(game_class); + + const jclass string_class = env->FindClass("java/lang/String"); + s_string_class = reinterpret_cast(env->NewGlobalRef(string_class)); + env->DeleteLocalRef(string_class); + + const jclass pair_class = env->FindClass("kotlin/Pair"); + s_pair_class = reinterpret_cast(env->NewGlobalRef(pair_class)); + s_pair_constructor = + env->GetMethodID(pair_class, "", "(Ljava/lang/Object;Ljava/lang/Object;)V"); + s_pair_first_field = env->GetFieldID(pair_class, "first", "Ljava/lang/Object;"); + s_pair_second_field = env->GetFieldID(pair_class, "second", "Ljava/lang/Object;"); + env->DeleteLocalRef(pair_class); + + const jclass overlay_control_data_class = + env->FindClass("org/yuzu/yuzu_emu/overlay/model/OverlayControlData"); + s_overlay_control_data_class = + reinterpret_cast(env->NewGlobalRef(overlay_control_data_class)); + s_overlay_control_data_constructor = + env->GetMethodID(overlay_control_data_class, "", + "(Ljava/lang/String;ZLkotlin/Pair;Lkotlin/Pair;Lkotlin/Pair;)V"); + s_overlay_control_data_id_field = + env->GetFieldID(overlay_control_data_class, "id", "Ljava/lang/String;"); + s_overlay_control_data_enabled_field = + env->GetFieldID(overlay_control_data_class, "enabled", "Z"); + s_overlay_control_data_landscape_position_field = + env->GetFieldID(overlay_control_data_class, "landscapePosition", "Lkotlin/Pair;"); + s_overlay_control_data_portrait_position_field = + env->GetFieldID(overlay_control_data_class, "portraitPosition", "Lkotlin/Pair;"); + s_overlay_control_data_foldable_position_field = + env->GetFieldID(overlay_control_data_class, "foldablePosition", "Lkotlin/Pair;"); + env->DeleteLocalRef(overlay_control_data_class); + + const jclass patch_class = env->FindClass("org/yuzu/yuzu_emu/model/Patch"); + s_patch_class = reinterpret_cast(env->NewGlobalRef(patch_class)); + s_patch_constructor = env->GetMethodID( + patch_class, "", + "(ZLjava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)V"); + s_patch_enabled_field = env->GetFieldID(patch_class, "enabled", "Z"); + s_patch_name_field = env->GetFieldID(patch_class, "name", "Ljava/lang/String;"); + s_patch_version_field = env->GetFieldID(patch_class, "version", "Ljava/lang/String;"); + s_patch_type_field = env->GetFieldID(patch_class, "type", "I"); + s_patch_program_id_field = env->GetFieldID(patch_class, "programId", "Ljava/lang/String;"); + s_patch_title_id_field = env->GetFieldID(patch_class, "titleId", "Ljava/lang/String;"); + env->DeleteLocalRef(patch_class); + + const jclass double_class = env->FindClass("java/lang/Double"); + s_double_class = reinterpret_cast(env->NewGlobalRef(double_class)); + s_double_constructor = env->GetMethodID(double_class, "", "(D)V"); + s_double_value_field = env->GetFieldID(double_class, "value", "D"); + env->DeleteLocalRef(double_class); + + const jclass int_class = env->FindClass("java/lang/Integer"); + s_integer_class = reinterpret_cast(env->NewGlobalRef(int_class)); + s_integer_constructor = env->GetMethodID(int_class, "", "(I)V"); + s_integer_value_field = env->GetFieldID(int_class, "value", "I"); + env->DeleteLocalRef(int_class); + + const jclass boolean_class = env->FindClass("java/lang/Boolean"); + s_boolean_class = reinterpret_cast(env->NewGlobalRef(boolean_class)); + s_boolean_constructor = env->GetMethodID(boolean_class, "", "(Z)V"); + s_boolean_value_field = env->GetFieldID(boolean_class, "value", "Z"); + env->DeleteLocalRef(boolean_class); + + const jclass player_input_class = + env->FindClass("org/yuzu/yuzu_emu/features/input/model/PlayerInput"); + s_player_input_class = reinterpret_cast(env->NewGlobalRef(player_input_class)); + s_player_input_constructor = env->GetMethodID( + player_input_class, "", + "(Z[Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;ZIJJJJLjava/lang/String;Z)V"); + s_player_input_connected_field = env->GetFieldID(player_input_class, "connected", "Z"); + s_player_input_buttons_field = + env->GetFieldID(player_input_class, "buttons", "[Ljava/lang/String;"); + s_player_input_analogs_field = + env->GetFieldID(player_input_class, "analogs", "[Ljava/lang/String;"); + s_player_input_motions_field = + env->GetFieldID(player_input_class, "motions", "[Ljava/lang/String;"); + s_player_input_vibration_enabled_field = + env->GetFieldID(player_input_class, "vibrationEnabled", "Z"); + s_player_input_vibration_strength_field = + env->GetFieldID(player_input_class, "vibrationStrength", "I"); + s_player_input_body_color_left_field = + env->GetFieldID(player_input_class, "bodyColorLeft", "J"); + s_player_input_body_color_right_field = + env->GetFieldID(player_input_class, "bodyColorRight", "J"); + s_player_input_button_color_left_field = + env->GetFieldID(player_input_class, "buttonColorLeft", "J"); + s_player_input_button_color_right_field = + env->GetFieldID(player_input_class, "buttonColorRight", "J"); + s_player_input_profile_name_field = + env->GetFieldID(player_input_class, "profileName", "Ljava/lang/String;"); + s_player_input_use_system_vibrator_field = + env->GetFieldID(player_input_class, "useSystemVibrator", "Z"); + env->DeleteLocalRef(player_input_class); + + const jclass yuzu_input_device_interface = + env->FindClass("org/yuzu/yuzu_emu/features/input/YuzuInputDevice"); + s_yuzu_input_device_interface = + reinterpret_cast(env->NewGlobalRef(yuzu_input_device_interface)); + s_yuzu_input_device_get_name = + env->GetMethodID(yuzu_input_device_interface, "getName", "()Ljava/lang/String;"); + s_yuzu_input_device_get_guid = + env->GetMethodID(yuzu_input_device_interface, "getGUID", "()Ljava/lang/String;"); + s_yuzu_input_device_get_port = env->GetMethodID(yuzu_input_device_interface, "getPort", "()I"); + s_yuzu_input_device_get_supports_vibration = + env->GetMethodID(yuzu_input_device_interface, "getSupportsVibration", "()Z"); + s_yuzu_input_device_vibrate = env->GetMethodID(yuzu_input_device_interface, "vibrate", "(F)V"); + s_yuzu_input_device_get_axes = + env->GetMethodID(yuzu_input_device_interface, "getAxes", "()[Ljava/lang/Integer;"); + s_yuzu_input_device_has_keys = + env->GetMethodID(yuzu_input_device_interface, "hasKeys", "([I)[Z"); + env->DeleteLocalRef(yuzu_input_device_interface); + s_add_netplay_message = env->GetStaticMethodID(s_native_library_class, "addNetPlayMessage", + "(ILjava/lang/String;)V"); + s_clear_chat = env->GetStaticMethodID(s_native_library_class, "clearChat", "()V"); + + // Initialize Android Storage + Common::FS::Android::RegisterCallbacks(env, s_native_library_class); + + // Initialize applets + Common::Android::SoftwareKeyboard::InitJNI(env); + + return JNI_VERSION; +} + +void JNI_OnUnload(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION) != JNI_OK) { + return; } + + // UnInitialize Android Storage + Common::FS::Android::UnRegisterCallbacks(); + env->DeleteGlobalRef(s_native_library_class); + env->DeleteGlobalRef(s_disk_cache_progress_class); + env->DeleteGlobalRef(s_load_callback_stage_class); + env->DeleteGlobalRef(s_game_dir_class); + env->DeleteGlobalRef(s_game_class); + env->DeleteGlobalRef(s_string_class); + env->DeleteGlobalRef(s_pair_class); + env->DeleteGlobalRef(s_overlay_control_data_class); + env->DeleteGlobalRef(s_patch_class); + env->DeleteGlobalRef(s_double_class); + env->DeleteGlobalRef(s_integer_class); + env->DeleteGlobalRef(s_boolean_class); + env->DeleteGlobalRef(s_player_input_class); + env->DeleteGlobalRef(s_yuzu_input_device_interface); + + // UnInitialize applets + SoftwareKeyboard::CleanupJNI(env); + + AndroidMultiplayer::NetworkShutdown(); +} + +#ifdef __cplusplus +} #endif } // namespace Common::Android diff --git a/src/common/android/id_cache.h b/src/common/android/id_cache.h index c56ffcf5c6..413a3c2ec5 100644 --- a/src/common/android/id_cache.h +++ b/src/common/android/id_cache.h @@ -118,5 +118,4 @@ jmethodID GetYuzuDeviceHasKeys(); jmethodID GetAddNetPlayMessage(); jmethodID ClearChat(); - } // namespace Common::Android diff --git a/src/common/android/multiplayer/multiplayer.cpp b/src/common/android/multiplayer/multiplayer.cpp index 26bb800ce2..ec7912421a 100644 --- a/src/common/android/multiplayer/multiplayer.cpp +++ b/src/common/android/multiplayer/multiplayer.cpp @@ -6,23 +6,23 @@ #include "common/android/android_common.h" +#include "android/log.h" #include "core/core.h" #include "network/network.h" -#include "android/log.h" #include "common/settings.h" -#include "web_service/web_backend.h" #include "web_service/verify_user_jwt.h" +#include "web_service/web_backend.h" #include "web_service/web_result.h" -#include #include +#include namespace IDCache = Common::Android; -AndroidMultiplayer::AndroidMultiplayer(Core::System &system_, +AndroidMultiplayer::AndroidMultiplayer(Core::System& system_, std::shared_ptr session) - : system{system_}, announce_multiplayer_session(session) {} + : system{system_}, announce_multiplayer_session(session) {} AndroidMultiplayer::~AndroidMultiplayer() = default; @@ -31,8 +31,8 @@ void AndroidMultiplayer::AddNetPlayMessage(jint type, jstring msg) { IDCache::GetAddNetPlayMessage(), type, msg); } -void AndroidMultiplayer::AddNetPlayMessage(int type, const std::string &msg) { - JNIEnv *env = IDCache::GetEnvForThread(); +void AndroidMultiplayer::AddNetPlayMessage(int type, const std::string& msg) { + JNIEnv* env = IDCache::GetEnvForThread(); AddNetPlayMessage(type, Common::Android::ToJString(env, msg)); } @@ -50,91 +50,91 @@ bool AndroidMultiplayer::NetworkInit() { if (auto member = Network::GetRoomMember().lock()) { // register the network structs to use in slots and signals - member->BindOnStateChanged([this](const Network::RoomMember::State &state) { + member->BindOnStateChanged([this](const Network::RoomMember::State& state) { if (state == Network::RoomMember::State::Joined || state == Network::RoomMember::State::Moderator) { NetPlayStatus status; std::string msg; switch (state) { - case Network::RoomMember::State::Joined: - status = NetPlayStatus::ROOM_JOINED; - break; - case Network::RoomMember::State::Moderator: - status = NetPlayStatus::ROOM_MODERATOR; - break; - default: - return; + case Network::RoomMember::State::Joined: + status = NetPlayStatus::ROOM_JOINED; + break; + case Network::RoomMember::State::Moderator: + status = NetPlayStatus::ROOM_MODERATOR; + break; + default: + return; } AddNetPlayMessage(static_cast(status), msg); } }); - member->BindOnError([this](const Network::RoomMember::Error &error) { + member->BindOnError([this](const Network::RoomMember::Error& error) { NetPlayStatus status; std::string msg; switch (error) { - case Network::RoomMember::Error::LostConnection: - status = NetPlayStatus::LOST_CONNECTION; - break; - case Network::RoomMember::Error::HostKicked: - status = NetPlayStatus::HOST_KICKED; - break; - case Network::RoomMember::Error::UnknownError: - status = NetPlayStatus::UNKNOWN_ERROR; - break; - case Network::RoomMember::Error::NameCollision: - status = NetPlayStatus::NAME_COLLISION; - break; - case Network::RoomMember::Error::IpCollision: - status = NetPlayStatus::MAC_COLLISION; - break; - case Network::RoomMember::Error::WrongVersion: - status = NetPlayStatus::WRONG_VERSION; - break; - case Network::RoomMember::Error::WrongPassword: - status = NetPlayStatus::WRONG_PASSWORD; - break; - case Network::RoomMember::Error::CouldNotConnect: - status = NetPlayStatus::COULD_NOT_CONNECT; - break; - case Network::RoomMember::Error::RoomIsFull: - status = NetPlayStatus::ROOM_IS_FULL; - break; - case Network::RoomMember::Error::HostBanned: - status = NetPlayStatus::HOST_BANNED; - break; - case Network::RoomMember::Error::PermissionDenied: - status = NetPlayStatus::PERMISSION_DENIED; - break; - case Network::RoomMember::Error::NoSuchUser: - status = NetPlayStatus::NO_SUCH_USER; - break; + case Network::RoomMember::Error::LostConnection: + status = NetPlayStatus::LOST_CONNECTION; + break; + case Network::RoomMember::Error::HostKicked: + status = NetPlayStatus::HOST_KICKED; + break; + case Network::RoomMember::Error::UnknownError: + status = NetPlayStatus::UNKNOWN_ERROR; + break; + case Network::RoomMember::Error::NameCollision: + status = NetPlayStatus::NAME_COLLISION; + break; + case Network::RoomMember::Error::IpCollision: + status = NetPlayStatus::MAC_COLLISION; + break; + case Network::RoomMember::Error::WrongVersion: + status = NetPlayStatus::WRONG_VERSION; + break; + case Network::RoomMember::Error::WrongPassword: + status = NetPlayStatus::WRONG_PASSWORD; + break; + case Network::RoomMember::Error::CouldNotConnect: + status = NetPlayStatus::COULD_NOT_CONNECT; + break; + case Network::RoomMember::Error::RoomIsFull: + status = NetPlayStatus::ROOM_IS_FULL; + break; + case Network::RoomMember::Error::HostBanned: + status = NetPlayStatus::HOST_BANNED; + break; + case Network::RoomMember::Error::PermissionDenied: + status = NetPlayStatus::PERMISSION_DENIED; + break; + case Network::RoomMember::Error::NoSuchUser: + status = NetPlayStatus::NO_SUCH_USER; + break; } AddNetPlayMessage(static_cast(status), msg); }); member->BindOnStatusMessageReceived( - [this](const Network::StatusMessageEntry &status_message) { - NetPlayStatus status = NetPlayStatus::NO_ERROR; - std::string msg(status_message.nickname); - switch (status_message.type) { - case Network::IdMemberJoin: - status = NetPlayStatus::MEMBER_JOIN; - break; - case Network::IdMemberLeave: - status = NetPlayStatus::MEMBER_LEAVE; - break; - case Network::IdMemberKicked: - status = NetPlayStatus::MEMBER_KICKED; - break; - case Network::IdMemberBanned: - status = NetPlayStatus::MEMBER_BANNED; - break; - case Network::IdAddressUnbanned: - status = NetPlayStatus::ADDRESS_UNBANNED; - break; - } - AddNetPlayMessage(static_cast(status), msg); - }); - member->BindOnChatMessageReceived([this](const Network::ChatEntry &chat) { + [this](const Network::StatusMessageEntry& status_message) { + NetPlayStatus status = NetPlayStatus::NO_ERROR; + std::string msg(status_message.nickname); + switch (status_message.type) { + case Network::IdMemberJoin: + status = NetPlayStatus::MEMBER_JOIN; + break; + case Network::IdMemberLeave: + status = NetPlayStatus::MEMBER_LEAVE; + break; + case Network::IdMemberKicked: + status = NetPlayStatus::MEMBER_KICKED; + break; + case Network::IdMemberBanned: + status = NetPlayStatus::MEMBER_BANNED; + break; + case Network::IdAddressUnbanned: + status = NetPlayStatus::ADDRESS_UNBANNED; + break; + } + AddNetPlayMessage(static_cast(status), msg); + }); + member->BindOnChatMessageReceived([this](const Network::ChatEntry& chat) { NetPlayStatus status = NetPlayStatus::CHAT_MESSAGE; std::string msg(chat.nickname); msg += ": "; @@ -146,13 +146,10 @@ bool AndroidMultiplayer::NetworkInit() { return true; } -NetPlayStatus AndroidMultiplayer::NetPlayCreateRoom(const std::string &ipaddress, int port, - const std::string &username, - const std::string &preferredGameName, - const u64 &preferredGameId, - const std::string &password, - const std::string &room_name, int max_players, - bool isPublic) { +NetPlayStatus AndroidMultiplayer::NetPlayCreateRoom( + const std::string& ipaddress, int port, const std::string& username, + const std::string& preferredGameName, const u64& preferredGameId, const std::string& password, + const std::string& room_name, int max_players, bool isPublic) { auto member = Network::GetRoomMember().lock(); if (!member) { return NetPlayStatus::NETWORK_ERROR; @@ -173,8 +170,8 @@ NetPlayStatus AndroidMultiplayer::NetPlayCreateRoom(const std::string &ipaddress // Placeholder game info const AnnounceMultiplayerRoom::GameInfo game{ - .name = preferredGameName, - .id = preferredGameId, + .name = preferredGameName, + .id = preferredGameId, }; port = (port == 0) ? Network::DefaultRoomPort : static_cast(port); @@ -205,8 +202,8 @@ NetPlayStatus AndroidMultiplayer::NetPlayCreateRoom(const std::string &ipaddress std::string token; // TODO(alekpop): properly handle the compile definition, it's not working right -//#ifdef ENABLE_WEB_SERVICE -// LOG_INFO(WebService, "Web Service enabled"); + // #ifdef ENABLE_WEB_SERVICE + // LOG_INFO(WebService, "Web Service enabled"); if (isPublic) { WebService::Client client(Settings::values.web_api_url.GetValue(), Settings::values.eden_username.GetValue(), @@ -220,9 +217,9 @@ NetPlayStatus AndroidMultiplayer::NetPlayCreateRoom(const std::string &ipaddress LOG_INFO(WebService, "Successfully requested external JWT: size={}", token.size()); } } -//#else -// LOG_INFO(WebService, "Web Service disabled"); -//#endif + // #else + // LOG_INFO(WebService, "Web Service disabled"); + // #endif member->Join(username, ipaddress.c_str(), static_cast(port), 0, Network::NoPreferredIP, password, token); @@ -241,17 +238,15 @@ NetPlayStatus AndroidMultiplayer::NetPlayCreateRoom(const std::string &ipaddress return NetPlayStatus::CREATE_ROOM_ERROR; } -NetPlayStatus AndroidMultiplayer::NetPlayJoinRoom(const std::string &ipaddress, int port, - const std::string &username, - const std::string &password) { +NetPlayStatus AndroidMultiplayer::NetPlayJoinRoom(const std::string& ipaddress, int port, + const std::string& username, + const std::string& password) { auto member = Network::GetRoomMember().lock(); if (!member) { return NetPlayStatus::NETWORK_ERROR; } - port = - (port == 0) ? Network::DefaultRoomPort : static_cast(port); - + port = (port == 0) ? Network::DefaultRoomPort : static_cast(port); if (member->GetState() == Network::RoomMember::State::Joining || member->IsConnected()) { return NetPlayStatus::ALREADY_IN_ROOM; @@ -275,7 +270,7 @@ NetPlayStatus AndroidMultiplayer::NetPlayJoinRoom(const std::string &ipaddress, return NetPlayStatus::WRONG_PASSWORD; } -void AndroidMultiplayer::NetPlaySendMessage(const std::string &msg) { +void AndroidMultiplayer::NetPlaySendMessage(const std::string& msg) { if (auto room = Network::GetRoomMember().lock()) { if (room->GetState() != Network::RoomMember::State::Joined && room->GetState() != Network::RoomMember::State::Moderator) { @@ -286,11 +281,11 @@ void AndroidMultiplayer::NetPlaySendMessage(const std::string &msg) { } } -void AndroidMultiplayer::NetPlayKickUser(const std::string &username) { +void AndroidMultiplayer::NetPlayKickUser(const std::string& username) { if (auto room = Network::GetRoomMember().lock()) { auto members = room->GetMemberInformation(); auto it = std::find_if(members.begin(), members.end(), - [&username](const Network::RoomMember::MemberInformation &member) { + [&username](const Network::RoomMember::MemberInformation& member) { return member.nickname == username; }); if (it != members.end()) { @@ -299,11 +294,11 @@ void AndroidMultiplayer::NetPlayKickUser(const std::string &username) { } } -void AndroidMultiplayer::NetPlayBanUser(const std::string &username) { +void AndroidMultiplayer::NetPlayBanUser(const std::string& username) { if (auto room = Network::GetRoomMember().lock()) { auto members = room->GetMemberInformation(); auto it = std::find_if(members.begin(), members.end(), - [&username](const Network::RoomMember::MemberInformation &member) { + [&username](const Network::RoomMember::MemberInformation& member) { return member.nickname == username; }); if (it != members.end()) { @@ -312,7 +307,7 @@ void AndroidMultiplayer::NetPlayBanUser(const std::string &username) { } } -void AndroidMultiplayer::NetPlayUnbanUser(const std::string &username) { +void AndroidMultiplayer::NetPlayUnbanUser(const std::string& username) { if (auto room = Network::GetRoomMember().lock()) { room->SendModerationRequest(Network::RoomMessageTypes::IdModUnban, username); } @@ -327,7 +322,7 @@ std::vector AndroidMultiplayer::NetPlayRoomInfo() { auto room_info = room->GetRoomInformation(); info_list.push_back(room_info.name + "|" + std::to_string(room_info.member_slots)); // all members - for (const auto &member: members) { + for (const auto& member : members) { info_list.push_back(member.nickname); } } @@ -385,30 +380,24 @@ std::vector AndroidMultiplayer::NetPlayGetPublicRooms() { if (auto session = announce_multiplayer_session.lock()) { auto rooms = session->GetRoomList(); - for (const auto &room: rooms) { - room_list.push_back(room.information.name + "|" + - (room.has_password ? "1" : "0") + "|" + - std::to_string(room.information.member_slots) + "|" + - room.ip + "|" + - std::to_string(room.information.port) + "|" + + for (const auto& room : rooms) { + room_list.push_back(room.information.name + "|" + (room.has_password ? "1" : "0") + + "|" + std::to_string(room.information.member_slots) + "|" + + room.ip + "|" + std::to_string(room.information.port) + "|" + room.information.description + "|" + room.information.host_username + "|" + std::to_string(room.information.preferred_game.id) + "|" + room.information.preferred_game.name + "|" + room.information.preferred_game.version); - for (const auto &member: room.members) { - room_list.push_back("MEMBER|" + room.information.name + "|" + - member.username + "|" + - member.nickname + "|" + - std::to_string(member.game.id) + "|" + - member.game.name); + for (const auto& member : room.members) { + room_list.push_back("MEMBER|" + room.information.name + "|" + member.username + + "|" + member.nickname + "|" + std::to_string(member.game.id) + + "|" + member.game.name); } } - } return room_list; - } std::vector AndroidMultiplayer::NetPlayGetBanList() { @@ -417,27 +406,28 @@ std::vector AndroidMultiplayer::NetPlayGetBanList() { auto [username_bans, ip_bans] = room->GetBanList(); // Add username bans - for (const auto &username: username_bans) { + for (const auto& username : username_bans) { ban_list.push_back(username); } // Add IP bans - for (const auto &ip: ip_bans) { + for (const auto& ip : ip_bans) { ban_list.push_back(ip); } } return ban_list; } -std::unique_ptr AndroidMultiplayer::CreateVerifyBackend(bool use_validation) { +std::unique_ptr AndroidMultiplayer::CreateVerifyBackend( + bool use_validation) { std::unique_ptr verify_backend; if (use_validation) { -//#ifdef ENABLE_WEB_SERVICE + // #ifdef ENABLE_WEB_SERVICE verify_backend = std::make_unique(Settings::values.web_api_url.GetValue()); -//#else -// verify_backend = std::make_unique(); -//#endif + // #else + // verify_backend = std::make_unique(); + // #endif } else { verify_backend = std::make_unique(); } diff --git a/src/common/android/multiplayer/multiplayer.h b/src/common/android/multiplayer/multiplayer.h index 39ea80f5b7..0b01a95594 100644 --- a/src/common/android/multiplayer/multiplayer.h +++ b/src/common/android/multiplayer/multiplayer.h @@ -7,13 +7,13 @@ #include #include -#include #include +#include namespace Core { - class System; - class AnnounceMultiplayerSession; -} +class System; +class AnnounceMultiplayerSession; +} // namespace Core enum class NetPlayStatus : s32 { NO_ERROR, @@ -63,13 +63,14 @@ public: void ClearChat(); - NetPlayStatus NetPlayCreateRoom(const std::string &ipaddress, int port, - const std::string &username, const std::string &preferredGameName, - const u64 &preferredGameId, const std::string &password, - const std::string &room_name, int max_players, bool isPublic); + NetPlayStatus NetPlayCreateRoom(const std::string& ipaddress, int port, + const std::string& username, + const std::string& preferredGameName, + const u64& preferredGameId, const std::string& password, + const std::string& room_name, int max_players, bool isPublic); - NetPlayStatus NetPlayJoinRoom(const std::string &ipaddress, int port, - const std::string &username, const std::string &password); + NetPlayStatus NetPlayJoinRoom(const std::string& ipaddress, int port, + const std::string& username, const std::string& password); std::vector NetPlayRoomInfo(); @@ -79,11 +80,11 @@ public: bool NetPlayIsModerator(); - void NetPlaySendMessage(const std::string &msg); + void NetPlaySendMessage(const std::string& msg); - void NetPlayKickUser(const std::string &username); + void NetPlayKickUser(const std::string& username); - void NetPlayBanUser(const std::string &username); + void NetPlayBanUser(const std::string& username); void NetPlayLeaveRoom(); @@ -91,12 +92,12 @@ public: std::vector NetPlayGetBanList(); - void NetPlayUnbanUser(const std::string &username); + void NetPlayUnbanUser(const std::string& username); std::vector NetPlayGetPublicRooms(); private: Core::System& system; - static std::unique_ptr CreateVerifyBackend(bool use_validation) ; + static std::unique_ptr CreateVerifyBackend(bool use_validation); std::weak_ptr announce_multiplayer_session; }; diff --git a/src/common/concepts.h b/src/common/concepts.h index 61df1d32a2..a9acff3e79 100644 --- a/src/common/concepts.h +++ b/src/common/concepts.h @@ -16,9 +16,9 @@ concept IsContiguousContainer = std::contiguous_iterator; // is available on all supported platforms. template concept DerivedFrom = requires { - std::is_base_of_v; - std::is_convertible_v; - }; + std::is_base_of_v; + std::is_convertible_v; +}; // TODO: Replace with std::convertible_to when libc++ implements it. template diff --git a/src/common/device_power_state.cpp b/src/common/device_power_state.cpp index 2dfa7dc305..3da0c1f5d2 100644 --- a/src/common/device_power_state.cpp +++ b/src/common/device_power_state.cpp @@ -27,76 +27,73 @@ extern std::atomic g_has_battery; namespace Common { - PowerStatus GetPowerStatus() - { - PowerStatus info; +PowerStatus GetPowerStatus() { + PowerStatus info; #if defined(_WIN32) - SYSTEM_POWER_STATUS status; - if (GetSystemPowerStatus(&status)) { - if (status.BatteryFlag == 128) { - info.has_battery = false; - } else { - info.percentage = status.BatteryLifePercent; - info.charging = (status.BatteryFlag & 8) != 0; - } - } else { + SYSTEM_POWER_STATUS status; + if (GetSystemPowerStatus(&status)) { + if (status.BatteryFlag == 128) { info.has_battery = false; + } else { + info.percentage = status.BatteryLifePercent; + info.charging = (status.BatteryFlag & 8) != 0; } + } else { + info.has_battery = false; + } #elif defined(__ANDROID__) - info.percentage = g_battery_percentage.load(std::memory_order_relaxed); - info.charging = g_is_charging.load(std::memory_order_relaxed); - info.has_battery = g_has_battery.load(std::memory_order_relaxed); + info.percentage = g_battery_percentage.load(std::memory_order_relaxed); + info.charging = g_is_charging.load(std::memory_order_relaxed); + info.has_battery = g_has_battery.load(std::memory_order_relaxed); #elif defined(__APPLE__) && TARGET_OS_MAC - CFTypeRef info_ref = IOPSCopyPowerSourcesInfo(); - CFArrayRef sources = IOPSCopyPowerSourcesList(info_ref); - if (CFArrayGetCount(sources) > 0) { - CFDictionaryRef battery = - IOPSGetPowerSourceDescription(info_ref, CFArrayGetValueAtIndex(sources, 0)); + CFTypeRef info_ref = IOPSCopyPowerSourcesInfo(); + CFArrayRef sources = IOPSCopyPowerSourcesList(info_ref); + if (CFArrayGetCount(sources) > 0) { + CFDictionaryRef battery = + IOPSGetPowerSourceDescription(info_ref, CFArrayGetValueAtIndex(sources, 0)); - CFNumberRef curNum = - (CFNumberRef)CFDictionaryGetValue(battery, CFSTR(kIOPSCurrentCapacityKey)); - CFNumberRef maxNum = - (CFNumberRef)CFDictionaryGetValue(battery, CFSTR(kIOPSMaxCapacityKey)); - int cur = 0, max = 0; - CFNumberGetValue(curNum, kCFNumberIntType, &cur); - CFNumberGetValue(maxNum, kCFNumberIntType, &max); + CFNumberRef curNum = + (CFNumberRef)CFDictionaryGetValue(battery, CFSTR(kIOPSCurrentCapacityKey)); + CFNumberRef maxNum = (CFNumberRef)CFDictionaryGetValue(battery, CFSTR(kIOPSMaxCapacityKey)); + int cur = 0, max = 0; + CFNumberGetValue(curNum, kCFNumberIntType, &cur); + CFNumberGetValue(maxNum, kCFNumberIntType, &max); - if (max > 0) - info.percentage = (cur * 100) / max; + if (max > 0) + info.percentage = (cur * 100) / max; - CFBooleanRef isCharging = - (CFBooleanRef)CFDictionaryGetValue(battery, CFSTR(kIOPSIsChargingKey)); - info.charging = CFBooleanGetValue(isCharging); - } else { - info.has_battery = false; - } - CFRelease(sources); - CFRelease(info_ref); + CFBooleanRef isCharging = + (CFBooleanRef)CFDictionaryGetValue(battery, CFSTR(kIOPSIsChargingKey)); + info.charging = CFBooleanGetValue(isCharging); + } else { + info.has_battery = false; + } + CFRelease(sources); + CFRelease(info_ref); #elif defined(__linux__) - const char* battery_path = "/sys/class/power_supply/BAT0/"; + const char* battery_path = "/sys/class/power_supply/BAT0/"; - std::ifstream capFile(std::string(battery_path) + "capacity"); - if (capFile) { - capFile >> info.percentage; - } - else { - info.has_battery = false; - } - - std::ifstream statFile(std::string(battery_path) + "status"); - if (statFile) { - std::string status; - std::getline(statFile, status); - info.charging = (status == "Charging"); - } -#else + std::ifstream capFile(std::string(battery_path) + "capacity"); + if (capFile) { + capFile >> info.percentage; + } else { info.has_battery = false; + } + + std::ifstream statFile(std::string(battery_path) + "status"); + if (statFile) { + std::string status; + std::getline(statFile, status); + info.charging = (status == "Charging"); + } +#else + info.has_battery = false; #endif - return info; - } + return info; } +} // namespace Common diff --git a/src/common/expected.h b/src/common/expected.h index 5fccfbcbdd..c62e43164d 100644 --- a/src/common/expected.h +++ b/src/common/expected.h @@ -598,14 +598,14 @@ public: template >* = nullptr, std::enable_if_t>* = nullptr> constexpr explicit Expected(Unexpected&& e) noexcept(std::is_nothrow_constructible_v) - : impl_base{unexpect_t{}, std::move(e.value())}, ctor_base{ - detail::default_constructor_tag{}} {} + : impl_base{unexpect_t{}, std::move(e.value())}, + ctor_base{detail::default_constructor_tag{}} {} template >* = nullptr, std::enable_if_t>* = nullptr> constexpr Expected(Unexpected&& e) noexcept(std::is_nothrow_constructible_v) - : impl_base{unexpect_t{}, std::move(e.value())}, ctor_base{ - detail::default_constructor_tag{}} {} + : impl_base{unexpect_t{}, std::move(e.value())}, + ctor_base{detail::default_constructor_tag{}} {} template >* = nullptr> constexpr explicit Expected(unexpect_t, Args&&... args) diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp index e032360961..eb0950ec33 100644 --- a/src/common/fs/path_util.cpp +++ b/src/common/fs/path_util.cpp @@ -88,9 +88,8 @@ public: } void CreateEdenPaths() { - std::for_each(eden_paths.begin(), eden_paths.end(), [](auto &path) { - void(FS::CreateDir(path.second)); - }); + std::for_each(eden_paths.begin(), eden_paths.end(), + [](auto& path) { void(FS::CreateDir(path.second)); }); } void SetEdenPathImpl(EdenPath eden_path, const fs::path& new_path) { @@ -116,9 +115,13 @@ public: eden_path_cache = eden_path / CACHE_DIR; eden_path_config = eden_path / CONFIG_DIR; -#define LEGACY_PATH(titleName, upperName) GenerateLegacyPath(LegacyPath::titleName##Dir, GetAppDataRoamingDirectory() / upperName##_DIR); \ - GenerateLegacyPath(LegacyPath::titleName##ConfigDir, GetAppDataRoamingDirectory() / upperName##_DIR / CONFIG_DIR); \ - GenerateLegacyPath(LegacyPath::titleName##CacheDir, GetAppDataRoamingDirectory() / upperName##_DIR / CACHE_DIR); +#define LEGACY_PATH(titleName, upperName) \ + GenerateLegacyPath(LegacyPath::titleName##Dir, \ + GetAppDataRoamingDirectory() / upperName##_DIR); \ + GenerateLegacyPath(LegacyPath::titleName##ConfigDir, \ + GetAppDataRoamingDirectory() / upperName##_DIR / CONFIG_DIR); \ + GenerateLegacyPath(LegacyPath::titleName##CacheDir, \ + GetAppDataRoamingDirectory() / upperName##_DIR / CACHE_DIR); LEGACY_PATH(Citron, CITRON) LEGACY_PATH(Sudachi, SUDACHI) @@ -143,9 +146,13 @@ public: eden_path_config = GetDataDirectory("XDG_CONFIG_HOME") / EDEN_DIR; } -#define LEGACY_PATH(titleName, upperName) GenerateLegacyPath(LegacyPath::titleName##Dir, GetDataDirectory("XDG_DATA_HOME") / upperName##_DIR); \ - GenerateLegacyPath(LegacyPath::titleName##ConfigDir, GetDataDirectory("XDG_CONFIG_HOME") / upperName##_DIR); \ - GenerateLegacyPath(LegacyPath::titleName##CacheDir, GetDataDirectory("XDG_CACHE_HOME") / upperName##_DIR); +#define LEGACY_PATH(titleName, upperName) \ + GenerateLegacyPath(LegacyPath::titleName##Dir, \ + GetDataDirectory("XDG_DATA_HOME") / upperName##_DIR); \ + GenerateLegacyPath(LegacyPath::titleName##ConfigDir, \ + GetDataDirectory("XDG_CONFIG_HOME") / upperName##_DIR); \ + GenerateLegacyPath(LegacyPath::titleName##CacheDir, \ + GetDataDirectory("XDG_CACHE_HOME") / upperName##_DIR); LEGACY_PATH(Citron, CITRON) LEGACY_PATH(Sudachi, SUDACHI) @@ -301,8 +308,7 @@ void SetEdenPath(EdenPath eden_path, const fs::path& new_path) { PathManagerImpl::GetInstance().SetEdenPathImpl(eden_path, new_path); } -void CreateEdenPaths() -{ +void CreateEdenPaths() { PathManagerImpl::GetInstance().CreateEdenPaths(); } diff --git a/src/common/intrusive_list.h b/src/common/intrusive_list.h index d330dc1c22..56eee8839f 100644 --- a/src/common/intrusive_list.h +++ b/src/common/intrusive_list.h @@ -538,7 +538,7 @@ public: template > class IntrusiveListMemberTraits; -template +template class IntrusiveListMemberTraits { public: using ListType = IntrusiveList; @@ -566,7 +566,7 @@ private: template > class IntrusiveListMemberTraitsByNonConstexprOffsetOf; -template +template class IntrusiveListMemberTraitsByNonConstexprOffsetOf { public: using ListType = IntrusiveList; diff --git a/src/common/intrusive_red_black_tree.h b/src/common/intrusive_red_black_tree.h index bc2940fa0a..27ce59cd0c 100644 --- a/src/common/intrusive_red_black_tree.h +++ b/src/common/intrusive_red_black_tree.h @@ -238,10 +238,8 @@ public: template concept HasRedBlackKeyType = requires { - { - std::is_same::value - } -> std::convertible_to; - }; + { std::is_same::value } -> std::convertible_to; +}; namespace impl { @@ -497,7 +495,7 @@ public: template > class IntrusiveRedBlackTreeMemberTraits; -template +template class IntrusiveRedBlackTreeMemberTraits { public: template @@ -530,7 +528,7 @@ private: template > class IntrusiveRedBlackTreeMemberTraitsDeferredAssert; -template +template class IntrusiveRedBlackTreeMemberTraitsDeferredAssert { public: template diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index ff07ab68eb..921778e18e 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -90,8 +90,8 @@ public: auto old_filename = filename; old_filename += ".old.txt"; - // Existence checks are done within the functions themselves. - // We don't particularly care if these succeed or not. + // Existence checks are done within the functions themselves. + // We don't particularly care if these succeed or not. static_cast(FS::RemoveFile(old_filename)); static_cast(FS::RenameFile(filename, old_filename)); diff --git a/src/common/multi_level_page_table.h b/src/common/multi_level_page_table.h index 31f6676a06..4eefb4d5f8 100644 --- a/src/common/multi_level_page_table.h +++ b/src/common/multi_level_page_table.h @@ -25,12 +25,12 @@ public: MultiLevelPageTable(MultiLevelPageTable&& other) noexcept : address_space_bits{std::exchange(other.address_space_bits, 0)}, - first_level_bits{std::exchange(other.first_level_bits, 0)}, page_bits{std::exchange( - other.page_bits, 0)}, + first_level_bits{std::exchange(other.first_level_bits, 0)}, + page_bits{std::exchange(other.page_bits, 0)}, first_level_shift{std::exchange(other.first_level_shift, 0)}, first_level_chunk_size{std::exchange(other.first_level_chunk_size, 0)}, - first_level_map{std::move(other.first_level_map)}, base_ptr{std::exchange(other.base_ptr, - nullptr)} {} + first_level_map{std::move(other.first_level_map)}, + base_ptr{std::exchange(other.base_ptr, nullptr)} {} MultiLevelPageTable& operator=(MultiLevelPageTable&& other) noexcept { address_space_bits = std::exchange(other.address_space_bits, 0); diff --git a/src/common/parent_of_member.h b/src/common/parent_of_member.h index 8e03f17d8b..f141b33ac7 100644 --- a/src/common/parent_of_member.h +++ b/src/common/parent_of_member.h @@ -92,7 +92,7 @@ struct OffsetOfCalculator { } template - static constexpr std::ptrdiff_t OffsetOfImpl(MemberType ParentType::*member, + static constexpr std::ptrdiff_t OffsetOfImpl(MemberType ParentType::* member, CurUnion& cur_union) { constexpr size_t Offset = CurUnion::GetOffset(); const auto target = std::addressof(GetPointer(U.parent)->*member); @@ -111,7 +111,7 @@ struct OffsetOfCalculator { Offset); } - static constexpr std::ptrdiff_t OffsetOf(MemberType ParentType::*member) { + static constexpr std::ptrdiff_t OffsetOf(MemberType ParentType::* member) { return OffsetOfImpl(member, U.first_union); } }; diff --git a/src/common/point.h b/src/common/point.h index 6491856ea8..329f5a424a 100644 --- a/src/common/point.h +++ b/src/common/point.h @@ -34,12 +34,12 @@ struct Point { .y = static_cast(value op rhs.y), \ }; \ } \ - friend constexpr Point& operator compound_op(Point& lhs, const Point& rhs) noexcept { \ + friend constexpr Point& operator compound_op(Point & lhs, const Point & rhs) noexcept { \ lhs.x = static_cast(lhs.x op rhs.x); \ lhs.y = static_cast(lhs.y op rhs.y); \ return lhs; \ } \ - friend constexpr Point& operator compound_op(Point& lhs, T value) noexcept { \ + friend constexpr Point& operator compound_op(Point & lhs, T value) noexcept { \ lhs.x = static_cast(lhs.x op value); \ lhs.y = static_cast(lhs.y op value); \ return lhs; \ diff --git a/src/common/polyfill_ranges.h b/src/common/polyfill_ranges.h index 512dbcbcb7..ea542fe120 100644 --- a/src/common/polyfill_ranges.h +++ b/src/common/polyfill_ranges.h @@ -18,9 +18,9 @@ namespace ranges { template concept range = requires(T& t) { - begin(t); - end(t); - }; + begin(t); + end(t); +}; template concept input_range = range; diff --git a/src/common/polyfill_thread.h b/src/common/polyfill_thread.h index 12e59a8939..ca04810554 100644 --- a/src/common/polyfill_thread.h +++ b/src/common/polyfill_thread.h @@ -339,7 +339,9 @@ void CondvarWait(Condvar& cv, std::unique_lock& lk, std::stop_token token, } std::stop_callback callback(token, [&] { - { std::scoped_lock lk2{*lk.mutex()}; } + { + std::scoped_lock lk2{*lk.mutex()}; + } cv.notify_all(); }); diff --git a/src/common/settings.h b/src/common/settings.h index 551e66c57e..468452da23 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -150,7 +150,7 @@ struct Values { Setting net_connect_applet_mode{linkage, AppletMode::LLE, "net_connect_applet_mode", Category::LibraryApplet}; Setting player_select_applet_mode{ - linkage, AppletMode::LLE, "player_select_applet_mode", Category::LibraryApplet}; + linkage, AppletMode::LLE, "player_select_applet_mode", Category::LibraryApplet}; Setting swkbd_applet_mode{linkage, AppletMode::HLE, "swkbd_applet_mode", Category::LibraryApplet}; Setting mii_edit_applet_mode{linkage, AppletMode::LLE, "mii_edit_applet_mode", @@ -160,13 +160,13 @@ struct Values { Setting shop_applet_mode{linkage, AppletMode::HLE, "shop_applet_mode", Category::LibraryApplet}; Setting photo_viewer_applet_mode{ - linkage, AppletMode::LLE, "photo_viewer_applet_mode", Category::LibraryApplet}; + linkage, AppletMode::LLE, "photo_viewer_applet_mode", Category::LibraryApplet}; Setting offline_web_applet_mode{linkage, AppletMode::LLE, "offline_web_applet_mode", Category::LibraryApplet}; Setting login_share_applet_mode{linkage, AppletMode::HLE, "login_share_applet_mode", Category::LibraryApplet}; Setting wifi_web_auth_applet_mode{ - linkage, AppletMode::HLE, "wifi_web_auth_applet_mode", Category::LibraryApplet}; + linkage, AppletMode::HLE, "wifi_web_auth_applet_mode", Category::LibraryApplet}; Setting my_page_applet_mode{linkage, AppletMode::LLE, "my_page_applet_mode", Category::LibraryApplet}; @@ -174,13 +174,13 @@ struct Values { SwitchableSetting sink_id{linkage, AudioEngine::Auto, "output_engine", Category::Audio, Specialization::RuntimeList}; SwitchableSetting audio_output_device_id{ - linkage, "auto", "output_device", Category::Audio, Specialization::RuntimeList}; + linkage, "auto", "output_device", Category::Audio, Specialization::RuntimeList}; SwitchableSetting audio_input_device_id{ - linkage, "auto", "input_device", Category::Audio, Specialization::RuntimeList}; + linkage, "auto", "input_device", Category::Audio, Specialization::RuntimeList}; SwitchableSetting sound_index{ - linkage, AudioMode::Stereo, AudioMode::Mono, AudioMode::Surround, - "sound_index", Category::SystemAudio, Specialization::Default, true, - true}; + linkage, AudioMode::Stereo, AudioMode::Mono, AudioMode::Surround, + "sound_index", Category::SystemAudio, Specialization::Default, true, + true}; SwitchableSetting volume{linkage, 100, 0, @@ -191,9 +191,9 @@ struct Values { true, true}; Setting audio_muted{ - linkage, false, "audio_muted", Category::Audio, Specialization::Default, true, true}; + linkage, false, "audio_muted", Category::Audio, Specialization::Default, true, true}; Setting dump_audio_commands{ - linkage, false, "dump_audio_commands", Category::Audio, Specialization::Default, false}; + linkage, false, "dump_audio_commands", Category::Audio, Specialization::Default, false}; // Core SwitchableSetting use_multi_core{linkage, true, "use_multi_core", Category::Core}; @@ -206,7 +206,7 @@ struct Values { Specialization::Default, true}; SwitchableSetting use_speed_limit{ - linkage, true, "use_speed_limit", Category::Core, Specialization::Paired, true, true}; + linkage, true, "use_speed_limit", Category::Core, Specialization::Paired, true, true}; SwitchableSetting speed_limit{linkage, 100, 0, @@ -217,7 +217,8 @@ struct Values { true, true, &use_speed_limit}; - SwitchableSetting sync_core_speed{linkage, false, "sync_core_speed", Category::Core, Specialization::Default}; + SwitchableSetting sync_core_speed{linkage, false, "sync_core_speed", Category::Core, + Specialization::Default}; // Memory #ifdef HAS_NCE @@ -243,29 +244,14 @@ struct Values { CpuAccuracy::Auto, CpuAccuracy::Paranoid, "cpu_accuracy", Category::Cpu}; - SwitchableSetting use_fast_cpu_time{linkage, - false, - "use_fast_cpu_time", - Category::Cpu, - Specialization::Paired, - true, - true}; - SwitchableSetting fast_cpu_time{linkage, - CpuClock::Boost, - "fast_cpu_time", - Category::Cpu, - Specialization::Default, - true, - true, - &use_fast_cpu_time}; + SwitchableSetting use_fast_cpu_time{ + linkage, false, "use_fast_cpu_time", Category::Cpu, Specialization::Paired, true, true}; + SwitchableSetting fast_cpu_time{ + linkage, CpuClock::Boost, "fast_cpu_time", Category::Cpu, Specialization::Default, true, + true, &use_fast_cpu_time}; - SwitchableSetting use_custom_cpu_ticks{linkage, - false, - "use_custom_cpu_ticks", - Category::Cpu, - Specialization::Paired, - true, - true}; + SwitchableSetting use_custom_cpu_ticks{ + linkage, false, "use_custom_cpu_ticks", Category::Cpu, Specialization::Paired, true, true}; SwitchableSetting cpu_ticks{linkage, 16000, @@ -302,29 +288,29 @@ struct Values { SwitchableSetting cpuopt_unsafe_unfuse_fma{linkage, true, "cpuopt_unsafe_unfuse_fma", Category::CpuUnsafe}; SwitchableSetting cpuopt_unsafe_reduce_fp_error{ - linkage, true, "cpuopt_unsafe_reduce_fp_error", Category::CpuUnsafe}; + linkage, true, "cpuopt_unsafe_reduce_fp_error", Category::CpuUnsafe}; SwitchableSetting cpuopt_unsafe_ignore_standard_fpcr{ - linkage, true, "cpuopt_unsafe_ignore_standard_fpcr", Category::CpuUnsafe}; + linkage, true, "cpuopt_unsafe_ignore_standard_fpcr", Category::CpuUnsafe}; SwitchableSetting cpuopt_unsafe_inaccurate_nan{ - linkage, true, "cpuopt_unsafe_inaccurate_nan", Category::CpuUnsafe}; + linkage, true, "cpuopt_unsafe_inaccurate_nan", Category::CpuUnsafe}; SwitchableSetting cpuopt_unsafe_fastmem_check{ - linkage, true, "cpuopt_unsafe_fastmem_check", Category::CpuUnsafe}; + linkage, true, "cpuopt_unsafe_fastmem_check", Category::CpuUnsafe}; SwitchableSetting cpuopt_unsafe_ignore_global_monitor{ - linkage, true, "cpuopt_unsafe_ignore_global_monitor", Category::CpuUnsafe}; + linkage, true, "cpuopt_unsafe_ignore_global_monitor", Category::CpuUnsafe}; // Renderer SwitchableSetting renderer_backend{ - linkage, RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null, - "backend", Category::Renderer}; + linkage, RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null, + "backend", Category::Renderer}; SwitchableSetting shader_backend{ - linkage, ShaderBackend::SpirV, ShaderBackend::Glsl, ShaderBackend::SpirV, - "shader_backend", Category::Renderer, Specialization::RuntimeList}; + linkage, ShaderBackend::SpirV, ShaderBackend::Glsl, ShaderBackend::SpirV, + "shader_backend", Category::Renderer, Specialization::RuntimeList}; SwitchableSetting vulkan_device{linkage, 0, "vulkan_device", Category::Renderer, Specialization::RuntimeList}; SwitchableSetting enable_raii{linkage, false, "enable_raii", Category::Renderer}; #ifdef __ANDROID__ - SwitchableSetting frame_interpolation{linkage, true, "frame_interpolation", Category::Renderer, - Specialization::RuntimeList}; + SwitchableSetting frame_interpolation{linkage, true, "frame_interpolation", + Category::Renderer, Specialization::RuntimeList}; SwitchableSetting frame_skipping{linkage, false, "frame_skipping", Category::Renderer, Specialization::RuntimeList}; #endif @@ -337,7 +323,7 @@ struct Values { "optimize_spirv_output", Category::Renderer}; SwitchableSetting use_asynchronous_gpu_emulation{ - linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; + linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; SwitchableSetting accelerate_astc{linkage, #ifdef ANDROID AstcDecodeMode::Cpu, @@ -349,9 +335,9 @@ struct Values { "accelerate_astc", Category::Renderer}; SwitchableSetting vsync_mode{ - linkage, VSyncMode::Fifo, VSyncMode::Immediate, VSyncMode::FifoRelaxed, - "use_vsync", Category::Renderer, Specialization::RuntimeList, true, - true}; + linkage, VSyncMode::Fifo, VSyncMode::Immediate, VSyncMode::FifoRelaxed, + "use_vsync", Category::Renderer, Specialization::RuntimeList, true, + true}; SwitchableSetting nvdec_emulation{linkage, NvdecEmulation::Gpu, "nvdec_emulation", Category::Renderer}; // *nix platforms may have issues with the borderless windowed fullscreen mode. @@ -408,11 +394,11 @@ struct Values { true}; SwitchableSetting bg_red{ - linkage, 0, "bg_red", Category::Renderer, Specialization::Default, true, true}; + linkage, 0, "bg_red", Category::Renderer, Specialization::Default, true, true}; SwitchableSetting bg_green{ - linkage, 0, "bg_green", Category::Renderer, Specialization::Default, true, true}; + linkage, 0, "bg_green", Category::Renderer, Specialization::Default, true, true}; SwitchableSetting bg_blue{ - linkage, 0, "bg_blue", Category::Renderer, Specialization::Default, true, true}; + linkage, 0, "bg_blue", Category::Renderer, Specialization::Default, true, true}; SwitchableSetting gpu_accuracy{linkage, #ifdef ANDROID @@ -476,13 +462,9 @@ struct Values { Category::RendererAdvanced}; SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", Category::RendererAdvanced}; - SwitchableSetting use_fast_gpu_time{linkage, - true, - "use_fast_gpu_time", - Category::RendererAdvanced, - Specialization::Paired, - true, - true}; + SwitchableSetting use_fast_gpu_time{ + linkage, true, "use_fast_gpu_time", Category::RendererAdvanced, Specialization::Paired, + true, true}; SwitchableSetting fast_gpu_time{linkage, GpuOverclock::Low, @@ -507,17 +489,15 @@ struct Values { SwitchableSetting barrier_feedback_loops{linkage, true, "barrier_feedback_loops", Category::RendererAdvanced}; - SwitchableSetting dyna_state{linkage, - 0, - 0, - 3, - "dyna_state", - Category::RendererExtensions, - Specialization::Scalar}; + SwitchableSetting dyna_state{ + linkage, 0, 0, 3, "dyna_state", Category::RendererExtensions, Specialization::Scalar}; - SwitchableSetting provoking_vertex{linkage, false, "provoking_vertex", Category::RendererExtensions}; - SwitchableSetting descriptor_indexing{linkage, false, "descriptor_indexing", Category::RendererExtensions}; - SwitchableSetting sample_shading{linkage, false, "sample_shading", Category::RendererExtensions}; + SwitchableSetting provoking_vertex{linkage, false, "provoking_vertex", + Category::RendererExtensions}; + SwitchableSetting descriptor_indexing{linkage, false, "descriptor_indexing", + Category::RendererExtensions}; + SwitchableSetting sample_shading{linkage, false, "sample_shading", + Category::RendererExtensions}; Setting renderer_debug{linkage, false, "debug", Category::RendererDebug}; Setting renderer_shader_feedback{linkage, false, "shader_feedback", @@ -525,19 +505,16 @@ struct Values { Setting enable_nsight_aftermath{linkage, false, "nsight_aftermath", Category::RendererDebug}; Setting disable_shader_loop_safety_checks{ - linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug}; + linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug}; Setting enable_renderdoc_hotkey{linkage, false, "renderdoc_hotkey", Category::RendererDebug}; Setting disable_buffer_reorder{linkage, false, "disable_buffer_reorder", Category::RendererDebug}; // System - SwitchableSetting language_index{linkage, - Language::EnglishAmerican, - Language::Japanese, - Language::Serbian, - "language_index", - Category::System}; + SwitchableSetting language_index{ + linkage, Language::EnglishAmerican, Language::Japanese, + Language::Serbian, "language_index", Category::System}; SwitchableSetting region_index{linkage, Region::Usa, Region::Japan, Region::Taiwan, "region_index", Category::System}; SwitchableSetting time_zone_index{linkage, TimeZone::Auto, @@ -545,10 +522,10 @@ struct Values { "time_zone_index", Category::System}; // Measured in seconds since epoch SwitchableSetting custom_rtc_enabled{ - linkage, false, "custom_rtc_enabled", Category::System, Specialization::Paired, true, true}; + linkage, false, "custom_rtc_enabled", Category::System, Specialization::Paired, true, true}; SwitchableSetting custom_rtc{ - linkage, 0, "custom_rtc", Category::System, Specialization::Time, - false, true, &custom_rtc_enabled}; + linkage, 0, "custom_rtc", Category::System, Specialization::Time, + false, true, &custom_rtc_enabled}; SwitchableSetting custom_rtc_offset{linkage, 0, std::numeric_limits::min(), @@ -559,12 +536,12 @@ struct Values { true, true}; SwitchableSetting rng_seed_enabled{ - linkage, false, "rng_seed_enabled", Category::System, Specialization::Paired, true, true}; + linkage, false, "rng_seed_enabled", Category::System, Specialization::Paired, true, true}; SwitchableSetting rng_seed{ - linkage, 0, "rng_seed", Category::System, Specialization::Hex, - true, true, &rng_seed_enabled}; + linkage, 0, "rng_seed", Category::System, Specialization::Hex, + true, true, &rng_seed_enabled}; Setting device_name{ - linkage, "eden", "device_name", Category::System, Specialization::Default, true, true}; + linkage, "eden", "device_name", Category::System, Specialization::Default, true, true}; Setting current_user{linkage, 0, "current_user", Category::System}; @@ -615,21 +592,21 @@ struct Values { Setting tas_loop{linkage, false, "tas_loop", Category::Controls}; Setting mouse_panning{ - linkage, false, "mouse_panning", Category::Controls, Specialization::Default, false}; + linkage, false, "mouse_panning", Category::Controls, Specialization::Default, false}; Setting mouse_panning_sensitivity{ - linkage, 50, 1, 100, "mouse_panning_sensitivity", Category::Controls}; + linkage, 50, 1, 100, "mouse_panning_sensitivity", Category::Controls}; Setting mouse_enabled{linkage, false, "mouse_enabled", Category::Controls}; Setting mouse_panning_x_sensitivity{ - linkage, 50, 1, 100, "mouse_panning_x_sensitivity", Category::Controls}; + linkage, 50, 1, 100, "mouse_panning_x_sensitivity", Category::Controls}; Setting mouse_panning_y_sensitivity{ - linkage, 50, 1, 100, "mouse_panning_y_sensitivity", Category::Controls}; + linkage, 50, 1, 100, "mouse_panning_y_sensitivity", Category::Controls}; Setting mouse_panning_deadzone_counterweight{ - linkage, 20, 0, 100, "mouse_panning_deadzone_counterweight", Category::Controls}; + linkage, 20, 0, 100, "mouse_panning_deadzone_counterweight", Category::Controls}; Setting mouse_panning_decay_strength{ - linkage, 18, 0, 100, "mouse_panning_decay_strength", Category::Controls}; + linkage, 18, 0, 100, "mouse_panning_decay_strength", Category::Controls}; Setting mouse_panning_min_decay{ - linkage, 6, 0, 100, "mouse_panning_min_decay", Category::Controls}; + linkage, 6, 0, 100, "mouse_panning_min_decay", Category::Controls}; Setting emulate_analog_keyboard{linkage, false, "emulate_analog_keyboard", Category::Controls}; @@ -672,23 +649,22 @@ struct Values { Setting dump_exefs{linkage, false, "dump_exefs", Category::Debugging}; Setting dump_nso{linkage, false, "dump_nso", Category::Debugging}; Setting dump_shaders{ - linkage, false, "dump_shaders", Category::DebuggingGraphics, Specialization::Default, - false}; + linkage, false, "dump_shaders", Category::DebuggingGraphics, Specialization::Default, + false}; Setting dump_macros{ - linkage, false, "dump_macros", Category::DebuggingGraphics, Specialization::Default, false}; + linkage, false, "dump_macros", Category::DebuggingGraphics, Specialization::Default, false}; Setting enable_fs_access_log{linkage, false, "enable_fs_access_log", Category::Debugging}; Setting reporting_services{ - linkage, false, "reporting_services", Category::Debugging, Specialization::Default, false}; + linkage, false, "reporting_services", Category::Debugging, Specialization::Default, false}; Setting quest_flag{linkage, false, "quest_flag", Category::Debugging}; Setting disable_macro_jit{linkage, false, "disable_macro_jit", Category::DebuggingGraphics}; Setting disable_macro_hle{linkage, false, "disable_macro_hle", Category::DebuggingGraphics}; Setting extended_logging{ - linkage, false, "extended_logging", Category::Debugging, Specialization::Default, false}; + linkage, false, "extended_logging", Category::Debugging, Specialization::Default, false}; Setting use_debug_asserts{linkage, false, "use_debug_asserts", Category::Debugging}; - Setting use_auto_stub{ - linkage, false, "use_auto_stub", Category::Debugging}; + Setting use_auto_stub{linkage, false, "use_auto_stub", Category::Debugging}; Setting enable_all_controllers{linkage, false, "enable_all_controllers", Category::Debugging}; Setting perform_vulkan_check{linkage, true, "perform_vulkan_check", Category::Debugging}; diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index c2347f74d0..a038bc4b6a 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -150,19 +150,8 @@ ENUM(FullscreenMode, Borderless, Exclusive); ENUM(NvdecEmulation, Off, Cpu, Gpu); -ENUM(ResolutionSetup, - Res1_4X, - Res1_2X, - Res3_4X, - Res1X, - Res3_2X, - Res2X, - Res3X, - Res4X, - Res5X, - Res6X, - Res7X, - Res8X); +ENUM(ResolutionSetup, Res1_4X, Res1_2X, Res3_4X, Res1X, Res3_2X, Res2X, Res3X, Res4X, Res5X, Res6X, + Res7X, Res8X); ENUM(ScalingFilter, NearestNeighbor, Bilinear, Bicubic, Gaussian, ScaleForce, Fsr, Area, MaxEnum); diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 1909aced54..12f4791d67 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -4,9 +4,8 @@ #include #include -#include -#include #include +#include #include "common/string_util.h" @@ -142,18 +141,15 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st } std::string UTF16ToUTF8(std::u16string_view input) { - std::wstring_convert, char16_t> convert; - return convert.to_bytes(input.data(), input.data() + input.size()); + return boost::locale::conv::utf_to_utf(input.data(), input.data() + input.size()); } std::u16string UTF8ToUTF16(std::string_view input) { - std::wstring_convert, char16_t> convert; - return convert.from_bytes(input.data(), input.data() + input.size()); + return boost::locale::conv::utf_to_utf(input.data(), input.data() + input.size()); } std::u32string UTF8ToUTF32(std::string_view input) { - std::wstring_convert, char32_t> convert; - return convert.from_bytes(input.data(), input.data() + input.size()); + return boost::locale::conv::utf_to_utf(input.data(), input.data() + input.size()); } #ifdef _WIN32 diff --git a/src/common/tree.h b/src/common/tree.h index f4fc43de36..a260e83a32 100644 --- a/src/common/tree.h +++ b/src/common/tree.h @@ -103,9 +103,9 @@ concept IsRBEntry = CheckRBEntry::value; template concept HasRBEntry = requires(T& t, const T& ct) { - { t.GetRBEntry() } -> std::same_as&>; - { ct.GetRBEntry() } -> std::same_as&>; - }; + { t.GetRBEntry() } -> std::same_as&>; + { ct.GetRBEntry() } -> std::same_as&>; +}; template requires HasRBEntry diff --git a/src/common/vector_math.h b/src/common/vector_math.h index b4885835df..720e89f491 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h @@ -362,7 +362,9 @@ public: // _DEFINE_SWIZZLER2 defines a single such function, DEFINE_SWIZZLER2 defines all of them for all // component names (x<->r) and permutations (xy<->yx) #define _DEFINE_SWIZZLER2(a, b, name) \ - [[nodiscard]] constexpr Vec2 name() const { return Vec2(a, b); } + [[nodiscard]] constexpr Vec2 name() const { \ + return Vec2(a, b); \ + } #define DEFINE_SWIZZLER2(a, b, a2, b2, a3, b3, a4, b4) \ _DEFINE_SWIZZLER2(a, b, a##b); \ _DEFINE_SWIZZLER2(a, b, a2##b2); \ @@ -555,7 +557,9 @@ public: // DEFINE_SWIZZLER2_COMP2 defines two component functions for all component names (x<->r) and // permutations (xy<->yx) #define _DEFINE_SWIZZLER2(a, b, name) \ - [[nodiscard]] constexpr Vec2 name() const { return Vec2(a, b); } + [[nodiscard]] constexpr Vec2 name() const { \ + return Vec2(a, b); \ + } #define DEFINE_SWIZZLER2_COMP1(a, a2) \ _DEFINE_SWIZZLER2(a, a, a##a); \ _DEFINE_SWIZZLER2(a, a, a2##a2) @@ -580,7 +584,9 @@ public: #undef _DEFINE_SWIZZLER2 #define _DEFINE_SWIZZLER3(a, b, c, name) \ - [[nodiscard]] constexpr Vec3 name() const { return Vec3(a, b, c); } + [[nodiscard]] constexpr Vec3 name() const { \ + return Vec3(a, b, c); \ + } #define DEFINE_SWIZZLER3_COMP1(a, a2) \ _DEFINE_SWIZZLER3(a, a, a, a##a##a); \ _DEFINE_SWIZZLER3(a, a, a, a2##a2##a2) diff --git a/src/common/virtual_buffer.h b/src/common/virtual_buffer.h index 4f6e3e6e5c..a6cf25baa2 100644 --- a/src/common/virtual_buffer.h +++ b/src/common/virtual_buffer.h @@ -33,8 +33,8 @@ public: VirtualBuffer& operator=(const VirtualBuffer&) = delete; VirtualBuffer(VirtualBuffer&& other) noexcept - : alloc_size{std::exchange(other.alloc_size, 0)}, base_ptr{std::exchange(other.base_ptr), - nullptr} {} + : alloc_size{std::exchange(other.alloc_size, 0)}, + base_ptr{std::exchange(other.base_ptr), nullptr} {} VirtualBuffer& operator=(VirtualBuffer&& other) noexcept { alloc_size = std::exchange(other.alloc_size, 0); diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index d2d27fafea..80d6e2bc5c 100644 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp @@ -8,8 +8,8 @@ namespace Common::X64 { NativeClock::NativeClock(u64 rdtsc_frequency_) - : rdtsc_frequency{rdtsc_frequency_}, ns_rdtsc_factor{GetFixedPoint64Factor(NsRatio::den, - rdtsc_frequency)}, + : rdtsc_frequency{rdtsc_frequency_}, + ns_rdtsc_factor{GetFixedPoint64Factor(NsRatio::den, rdtsc_frequency)}, us_rdtsc_factor{GetFixedPoint64Factor(UsRatio::den, rdtsc_frequency)}, ms_rdtsc_factor{GetFixedPoint64Factor(MsRatio::den, rdtsc_frequency)}, cntpct_rdtsc_factor{GetFixedPoint64Factor(CNTFRQ, rdtsc_frequency)}, diff --git a/src/core/arm/arm_interface.cpp b/src/core/arm/arm_interface.cpp index 34acec9ebf..b1cb2b8984 100644 --- a/src/core/arm/arm_interface.cpp +++ b/src/core/arm/arm_interface.cpp @@ -14,7 +14,8 @@ void ArmInterface::LogBacktrace(Kernel::KProcess* process) const { this->GetContext(ctx); LOG_ERROR(Core_ARM, "Backtrace, sp={:016X}, pc={:016X}", ctx.sp, ctx.pc); - LOG_ERROR(Core_ARM, "{:20}{:20}{:20}{:20}{}", "Module Name", "Address", "Original Address", "Offset", "Symbol"); + LOG_ERROR(Core_ARM, "{:20}{:20}{:20}{:20}{}", "Module Name", "Address", "Original Address", + "Offset", "Symbol"); LOG_ERROR(Core_ARM, ""); const auto backtrace = GetBacktraceFromContext(process, ctx); diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index e6e9fc45be..2a9f19a98b 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp @@ -15,7 +15,7 @@ namespace { thread_local Core::Memory::Memory* g_current_memory{}; std::once_flag g_registered{}; -struct sigaction g_old_segv {}; +struct sigaction g_old_segv{}; void HandleSigSegv(int sig, siginfo_t* info, void* ctx) { if (g_current_memory && g_current_memory->InvalidateSeparateHeap(info->si_addr)) { @@ -37,7 +37,7 @@ ScopedJitExecution::~ScopedJitExecution() { void ScopedJitExecution::RegisterHandler() { std::call_once(g_registered, [] { - struct sigaction sa {}; + struct sigaction sa{}; sa.sa_sigaction = &HandleSigSegv; sa.sa_flags = SA_SIGINFO | SA_ONSTACK; Common::SigAction(SIGSEGV, std::addressof(sa), std::addressof(g_old_segv)); diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index afbf178349..e8c62ea2d9 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -19,8 +19,8 @@ using namespace Common::Literals; class DynarmicCallbacks32 : public Dynarmic::A32::UserCallbacks { public: explicit DynarmicCallbacks32(ArmDynarmic32& parent, Kernel::KProcess* process) - : m_parent{parent}, m_memory(process->GetMemory()), - m_process(process), m_debugger_enabled{parent.m_system.DebuggerEnabled()}, + : m_parent{parent}, m_memory(process->GetMemory()), m_process(process), + m_debugger_enabled{parent.m_system.DebuggerEnabled()}, m_check_memory_access{m_debugger_enabled || !Settings::values.cpuopt_ignore_memory_aborts.GetValue()} {} @@ -195,11 +195,12 @@ std::shared_ptr ArmDynarmic32::MakeJit(Common::PageTable* pa config.detect_misaligned_access_via_page_table = 16 | 32 | 64 | 128; config.only_detect_misalignment_via_page_table_on_page_boundary = true; - config.fastmem_pointer = page_table->fastmem_arena ? - std::optional{reinterpret_cast(page_table->fastmem_arena)} : - std::nullopt; + config.fastmem_pointer = + page_table->fastmem_arena + ? std::optional{reinterpret_cast(page_table->fastmem_arena)} + : std::nullopt; - config.fastmem_exclusive_access = config.fastmem_pointer != std::nullopt; + config.fastmem_exclusive_access = config.fastmem_pointer != std::nullopt; config.recompile_on_exclusive_fastmem_failure = true; } diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index 99a80644ad..f0b180bccd 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -19,8 +19,8 @@ using namespace Common::Literals; class DynarmicCallbacks64 : public Dynarmic::A64::UserCallbacks { public: explicit DynarmicCallbacks64(ArmDynarmic64& parent, Kernel::KProcess* process) - : m_parent{parent}, m_memory(process->GetMemory()), - m_process(process), m_debugger_enabled{parent.m_system.DebuggerEnabled()}, + : m_parent{parent}, m_memory(process->GetMemory()), m_process(process), + m_debugger_enabled{parent.m_system.DebuggerEnabled()}, m_check_memory_access{m_debugger_enabled || !Settings::values.cpuopt_ignore_memory_aborts.GetValue()} {} @@ -242,9 +242,10 @@ std::shared_ptr ArmDynarmic64::MakeJit(Common::PageTable* pa config.detect_misaligned_access_via_page_table = 16 | 32 | 64 | 128; config.only_detect_misalignment_via_page_table_on_page_boundary = true; - config.fastmem_pointer = page_table->fastmem_arena ? - std::optional{reinterpret_cast(page_table->fastmem_arena)} : - std::nullopt; + config.fastmem_pointer = + page_table->fastmem_arena + ? std::optional{reinterpret_cast(page_table->fastmem_arena)} + : std::nullopt; config.fastmem_address_space_bits = std::uint32_t(address_space_bits); config.silently_mirror_fastmem = false; diff --git a/src/core/arm/nce/arm_nce.cpp b/src/core/arm/nce/arm_nce.cpp index 877e8ac3c7..8115743322 100644 --- a/src/core/arm/nce/arm_nce.cpp +++ b/src/core/arm/nce/arm_nce.cpp @@ -302,7 +302,7 @@ void ArmNce::Initialize() { sigaddset(&signal_mask, GuestAlignmentFaultSignal); sigaddset(&signal_mask, GuestAccessFaultSignal); - struct sigaction return_to_run_code_action {}; + struct sigaction return_to_run_code_action{}; return_to_run_code_action.sa_flags = SA_SIGINFO | SA_ONSTACK; return_to_run_code_action.sa_sigaction = reinterpret_cast( &ArmNce::ReturnToRunCodeByExceptionLevelChangeSignalHandler); @@ -310,21 +310,21 @@ void ArmNce::Initialize() { Common::SigAction(ReturnToRunCodeByExceptionLevelChangeSignal, &return_to_run_code_action, nullptr); - struct sigaction break_from_run_code_action {}; + struct sigaction break_from_run_code_action{}; break_from_run_code_action.sa_flags = SA_SIGINFO | SA_ONSTACK; break_from_run_code_action.sa_sigaction = reinterpret_cast(&ArmNce::BreakFromRunCodeSignalHandler); break_from_run_code_action.sa_mask = signal_mask; Common::SigAction(BreakFromRunCodeSignal, &break_from_run_code_action, nullptr); - struct sigaction alignment_fault_action {}; + struct sigaction alignment_fault_action{}; alignment_fault_action.sa_flags = SA_SIGINFO | SA_ONSTACK; alignment_fault_action.sa_sigaction = reinterpret_cast(&ArmNce::GuestAlignmentFaultSignalHandler); alignment_fault_action.sa_mask = signal_mask; Common::SigAction(GuestAlignmentFaultSignal, &alignment_fault_action, nullptr); - struct sigaction access_fault_action {}; + struct sigaction access_fault_action{}; access_fault_action.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_RESTART; access_fault_action.sa_sigaction = reinterpret_cast(&ArmNce::GuestAccessFaultSignalHandler); @@ -405,19 +405,19 @@ void ArmNce::ClearInstructionCache() { } void ArmNce::InvalidateCacheRange(u64 addr, std::size_t size) { - #if defined(__GNUC__) || defined(__clang__) - // Align the start address to cache line boundary for better performance - const size_t CACHE_LINE_SIZE = 64; - addr &= ~(CACHE_LINE_SIZE - 1); +#if defined(__GNUC__) || defined(__clang__) + // Align the start address to cache line boundary for better performance + const size_t CACHE_LINE_SIZE = 64; + addr &= ~(CACHE_LINE_SIZE - 1); - // Round up size to nearest cache line - size = (size + CACHE_LINE_SIZE - 1) & ~(CACHE_LINE_SIZE - 1); + // Round up size to nearest cache line + size = (size + CACHE_LINE_SIZE - 1) & ~(CACHE_LINE_SIZE - 1); - // Prefetch the range to be invalidated - for (size_t offset = 0; offset < size; offset += CACHE_LINE_SIZE) { - __builtin_prefetch((void*)(addr + offset), 1, 3); - } - #endif + // Prefetch the range to be invalidated + for (size_t offset = 0; offset < size; offset += CACHE_LINE_SIZE) { + __builtin_prefetch((void*)(addr + offset), 1, 3); + } +#endif this->ClearInstructionCache(); } diff --git a/src/core/arm/nce/interpreter_visitor.cpp b/src/core/arm/nce/interpreter_visitor.cpp index bbe0289f8e..afc2bb4e27 100644 --- a/src/core/arm/nce/interpreter_visitor.cpp +++ b/src/core/arm/nce/interpreter_visitor.cpp @@ -10,7 +10,7 @@ namespace Core { namespace { // Prefetch tuning parameters constexpr size_t CACHE_LINE_SIZE = 64; -constexpr size_t PREFETCH_STRIDE = 128; // 2 cache lines ahead +constexpr size_t PREFETCH_STRIDE = 128; // 2 cache lines ahead constexpr size_t SIMD_PREFETCH_THRESHOLD = 32; // Bytes } // namespace diff --git a/src/core/arm/nce/lru_cache.h b/src/core/arm/nce/lru_cache.h index 1bc00c8f14..517c121442 100644 --- a/src/core/arm/nce/lru_cache.h +++ b/src/core/arm/nce/lru_cache.h @@ -13,28 +13,34 @@ template class LRUCache { public: - using key_type = KeyType; + using key_type = KeyType; using value_type = ValueType; - using size_type = std::size_t; + using size_type = std::size_t; struct Statistics { - size_type hits = 0; + size_type hits = 0; size_type misses = 0; - void reset() noexcept { hits = misses = 0; } + void reset() noexcept { + hits = misses = 0; + } }; explicit LRUCache(size_type capacity, bool enabled = true) : enabled_{enabled}, capacity_{capacity} { cache_map_.reserve(capacity_); - LOG_WARNING(Core, "LRU Cache initialised (state: {} | capacity: {})", enabled_ ? "enabled" : "disabled", capacity_); + LOG_WARNING(Core, "LRU Cache initialised (state: {} | capacity: {})", + enabled_ ? "enabled" : "disabled", capacity_); } // Non-movable copy semantics - LRUCache(const LRUCache&) = delete; + LRUCache(const LRUCache&) = delete; LRUCache& operator=(const LRUCache&) = delete; - LRUCache(LRUCache&& other) noexcept { *this = std::move(other); } + LRUCache(LRUCache&& other) noexcept { + *this = std::move(other); + } LRUCache& operator=(LRUCache&& other) noexcept { - if (this == &other) return *this; + if (this == &other) + return *this; std::unique_lock this_lock(mutex_, std::defer_lock); std::unique_lock other_lock(other.mutex_, std::defer_lock); std::lock(this_lock, other_lock); @@ -48,7 +54,8 @@ public: ~LRUCache() = default; [[nodiscard]] value_type* get(const key_type& key) { - if (!enabled_) [[unlikely]] return nullptr; + if (!enabled_) [[unlikely]] + return nullptr; std::unique_lock lock(mutex_); auto it = cache_map_.find(key); if (it == cache_map_.end()) { @@ -61,7 +68,8 @@ public: } [[nodiscard]] value_type* peek(const key_type& key) const { - if (!enabled_) [[unlikely]] return nullptr; + if (!enabled_) [[unlikely]] + return nullptr; std::shared_lock lock(mutex_); auto it = cache_map_.find(key); return it == cache_map_.end() ? nullptr : &it->second.second; @@ -69,7 +77,8 @@ public: template void put(const key_type& key, V&& value) { - if (!enabled_) [[unlikely]] return; + if (!enabled_) [[unlikely]] + return; std::unique_lock lock(mutex_); insert_or_update(key, std::forward(value)); } @@ -88,16 +97,19 @@ public: } [[nodiscard]] bool contains(const key_type& key) const { - if (!enabled_) return false; + if (!enabled_) + return false; std::shared_lock lock(mutex_); return cache_map_.find(key) != cache_map_.end(); } bool erase(const key_type& key) { - if (!enabled_) return false; + if (!enabled_) + return false; std::unique_lock lock(mutex_); auto it = cache_map_.find(key); - if (it == cache_map_.end()) return false; + if (it == cache_map_.end()) + return false; cache_list_.erase(it->second.first); cache_map_.erase(it); return true; @@ -111,15 +123,19 @@ public: } [[nodiscard]] size_type size() const { - if (!enabled_) return 0; + if (!enabled_) + return 0; std::shared_lock lock(mutex_); return cache_map_.size(); } - [[nodiscard]] size_type get_capacity() const { return capacity_; } + [[nodiscard]] size_type get_capacity() const { + return capacity_; + } void resize(size_type new_capacity) { - if (!enabled_) return; + if (!enabled_) + return; std::unique_lock lock(mutex_); capacity_ = new_capacity; shrink_if_needed(); @@ -130,10 +146,13 @@ public: std::unique_lock lock(mutex_); enabled_ = state; LOG_WARNING(Core, "LRU Cache state changed to: {}", state ? "enabled" : "disabled"); - if (!enabled_) clear(); + if (!enabled_) + clear(); } - [[nodiscard]] bool isEnabled() const { return enabled_; } + [[nodiscard]] bool isEnabled() const { + return enabled_; + } [[nodiscard]] Statistics stats() const { std::shared_lock lock(mutex_); @@ -141,10 +160,10 @@ public: } private: - using list_type = std::list; - using list_iterator = typename list_type::iterator; + using list_type = std::list; + using list_iterator = typename list_type::iterator; using map_value_type = std::pair; - using map_type = std::unordered_map; + using map_type = std::unordered_map; template void insert_or_update(const key_type& key, V&& value) { diff --git a/src/core/arm/nce/patcher.cpp b/src/core/arm/nce/patcher.cpp index b8387ce7cb..a3c5cdc7a0 100644 --- a/src/core/arm/nce/patcher.cpp +++ b/src/core/arm/nce/patcher.cpp @@ -16,21 +16,16 @@ namespace Core::NCE { Patcher::Patcher(Patcher&& other) noexcept : patch_cache(std::move(other.patch_cache)), - m_patch_instructions(std::move(other.m_patch_instructions)), - c(m_patch_instructions), - m_save_context(other.m_save_context), - m_load_context(other.m_load_context), - mode(other.mode), + m_patch_instructions(std::move(other.m_patch_instructions)), c(m_patch_instructions), + m_save_context(other.m_save_context), m_load_context(other.m_load_context), mode(other.mode), total_program_size(other.total_program_size), - m_relocate_module_index(other.m_relocate_module_index), - modules(std::move(other.modules)), + m_relocate_module_index(other.m_relocate_module_index), modules(std::move(other.modules)), curr_patch(nullptr) { if (!modules.empty()) { curr_patch = &modules.back(); } } - using namespace Common::Literals; using namespace oaknut::util; @@ -41,7 +36,7 @@ constexpr u32 ModuleCodeIndex = 0x24 / sizeof(u32); Patcher::Patcher() : c(m_patch_instructions) { LOG_WARNING(Core_ARM, "Patcher initialized with LRU cache {}", - patch_cache.isEnabled() ? "enabled" : "disabled"); + patch_cache.isEnabled() ? "enabled" : "disabled"); // The first word of the patch section is always a branch to the first instruction of the // module. c.dw(0); diff --git a/src/core/arm/nce/patcher.h b/src/core/arm/nce/patcher.h index 53a923138c..2e92d13906 100644 --- a/src/core/arm/nce/patcher.h +++ b/src/core/arm/nce/patcher.h @@ -9,13 +9,13 @@ #include #include +#include #include "common/common_types.h" #include "common/settings.h" #include "core/hle/kernel/code_set.h" #include "core/hle/kernel/k_typed_address.h" #include "core/hle/kernel/physical_memory.h" #include "lru_cache.h" -#include namespace Core::NCE { @@ -67,8 +67,9 @@ private: void WriteCntpctHandler(ModuleDestLabel module_dest, oaknut::XReg dest_reg); private: - static constexpr size_t CACHE_SIZE = 16384; // Cache size for patch entries - LRUCache patch_cache{CACHE_SIZE, Settings::values.lru_cache_enabled.GetValue()}; + static constexpr size_t CACHE_SIZE = 16384; // Cache size for patch entries + LRUCache patch_cache{ + CACHE_SIZE, Settings::values.lru_cache_enabled.GetValue()}; void BranchToPatch(uintptr_t module_dest) { if (patch_cache.isEnabled()) { @@ -79,14 +80,16 @@ private: curr_patch->m_branch_to_patch_relocations.push_back({c.offset(), *cached_patch}); return; } - LOG_DEBUG(Core_ARM, "LRU cache miss for address {:#x}, creating new patch", module_dest); + LOG_DEBUG(Core_ARM, "LRU cache miss for address {:#x}, creating new patch", + module_dest); // If not in cache, create new entry and cache it const auto patch_addr = c.offset(); curr_patch->m_branch_to_patch_relocations.push_back({patch_addr, module_dest}); patch_cache.put(module_dest, patch_addr); } else { - LOG_DEBUG(Core_ARM, "LRU cache disabled - creating direct patch for address {:#x}", module_dest); + LOG_DEBUG(Core_ARM, "LRU cache disabled - creating direct patch for address {:#x}", + module_dest); // LRU disabled - use pre-LRU approach curr_patch->m_branch_to_patch_relocations.push_back({c.offset(), module_dest}); } diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index c4ea15c1dd..0c82831f89 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -17,8 +17,8 @@ #include "common/x64/cpu_wait.h" #endif -#include "common/settings.h" #include "common/microprofile.h" +#include "common/settings.h" #include "core/core_timing.h" #include "core/hardware_properties.h" @@ -175,9 +175,9 @@ void CoreTiming::UnscheduleEvent(const std::shared_ptr& event_type, } void CoreTiming::AddTicks(u64 ticks_to_add) { - cpu_ticks = Settings::values.use_custom_cpu_ticks.GetValue() - ? Settings::values.cpu_ticks.GetValue() - : cpu_ticks + ticks_to_add; + cpu_ticks = Settings::values.use_custom_cpu_ticks.GetValue() + ? Settings::values.cpu_ticks.GetValue() + : cpu_ticks + ticks_to_add; downcount -= static_cast(cpu_ticks); } @@ -193,22 +193,22 @@ u64 CoreTiming::GetClockTicks() const { u64 fres; if (is_multicore) [[likely]] { fres = clock->GetCNTPCT(); - } else { - fres = Common::WallClock::CPUTickToCNTPCT(cpu_ticks); - } + } else { + fres = Common::WallClock::CPUTickToCNTPCT(cpu_ticks); + } - if (Settings::values.use_fast_cpu_time) { - fres = (u64) ((double) fres - * (1.7 + 0.3 * (u32) Settings::values.fast_cpu_time.GetValue())); - } + if (Settings::values.use_fast_cpu_time) { + fres = (u64)((double)fres * (1.7 + 0.3 * (u32)Settings::values.fast_cpu_time.GetValue())); + } - if (Settings::values.sync_core_speed.GetValue()) { - const double ticks = static_cast(fres); - const double speed_limit = static_cast(Settings::values.speed_limit.GetValue())*0.01; - return static_cast(ticks/speed_limit); - } else { - return fres; - } + if (Settings::values.sync_core_speed.GetValue()) { + const double ticks = static_cast(fres); + const double speed_limit = + static_cast(Settings::values.speed_limit.GetValue()) * 0.01; + return static_cast(ticks / speed_limit); + } else { + return fres; + } } u64 CoreTiming::GetGPUTicks() const { diff --git a/src/core/file_sys/card_image.cpp b/src/core/file_sys/card_image.cpp index 0bcf40cf86..396a40d013 100644 --- a/src/core/file_sys/card_image.cpp +++ b/src/core/file_sys/card_image.cpp @@ -29,8 +29,8 @@ constexpr std::array partition_names{ XCI::XCI(VirtualFile file_, u64 program_id, size_t program_index) : file(std::move(file_)), program_nca_status{Loader::ResultStatus::ErrorXCIMissingProgramNCA}, - partitions(partition_names.size()), - partitions_raw(partition_names.size()), keys{Core::Crypto::KeyManager::Instance()} { + partitions(partition_names.size()), partitions_raw(partition_names.size()), + keys{Core::Crypto::KeyManager::Instance()} { const auto header_status = TryReadHeader(); if (header_status != Loader::ResultStatus::Success) { status = header_status; diff --git a/src/core/file_sys/fs_path_utility.h b/src/core/file_sys/fs_path_utility.h index cdfd8c7729..b59636f386 100644 --- a/src/core/file_sys/fs_path_utility.h +++ b/src/core/file_sys/fs_path_utility.h @@ -87,12 +87,15 @@ private: u32 m_value; public: - constexpr PathFlags() : m_value(0) { /* ... */ - } + constexpr PathFlags() : m_value(0) { /* ... */ } #define DECLARE_PATH_FLAG_HANDLER(__WHICH__) \ - constexpr bool Is##__WHICH__##Allowed() const { return (m_value & __WHICH__##Flag) != 0; } \ - constexpr void Allow##__WHICH__() { m_value |= __WHICH__##Flag; } + constexpr bool Is##__WHICH__##Allowed() const { \ + return (m_value & __WHICH__##Flag) != 0; \ + } \ + constexpr void Allow##__WHICH__() { \ + m_value |= __WHICH__##Flag; \ + } DECLARE_PATH_FLAG_HANDLER(WindowsPath) DECLARE_PATH_FLAG_HANDLER(RelativePath) diff --git a/src/core/file_sys/fssystem/fssystem_integrity_verification_storage.cpp b/src/core/file_sys/fssystem/fssystem_integrity_verification_storage.cpp index 046571e9ef..9960e394fc 100644 --- a/src/core/file_sys/fssystem/fssystem_integrity_verification_storage.cpp +++ b/src/core/file_sys/fssystem/fssystem_integrity_verification_storage.cpp @@ -4,23 +4,18 @@ // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/file_sys/fssystem/fssystem_integrity_verification_storage.h" #include "common/alignment.h" +#include "core/file_sys/fssystem/fssystem_integrity_verification_storage.h" namespace FileSys { -constexpr inline u32 ILog2(u32 val) -{ +constexpr inline u32 ILog2(u32 val) { ASSERT(val > 0); return static_cast((sizeof(u32) * 8) - 1 - std::countl_zero(val)); } -void IntegrityVerificationStorage::Initialize(VirtualFile hs, - VirtualFile ds, - s64 verif_block_size, - s64 upper_layer_verif_block_size, - bool is_real_data) -{ +void IntegrityVerificationStorage::Initialize(VirtualFile hs, VirtualFile ds, s64 verif_block_size, + s64 upper_layer_verif_block_size, bool is_real_data) { // Validate preconditions. ASSERT(verif_block_size >= HashSize); @@ -54,14 +49,12 @@ void IntegrityVerificationStorage::Initialize(VirtualFile hs, m_is_real_data = is_real_data; } -void IntegrityVerificationStorage::Finalize() -{ +void IntegrityVerificationStorage::Finalize() { m_hash_storage = VirtualFile(); m_data_storage = VirtualFile(); } -size_t IntegrityVerificationStorage::Read(u8* buffer, size_t size, size_t offset) const -{ +size_t IntegrityVerificationStorage::Read(u8* buffer, size_t size, size_t offset) const { // Succeed if zero size. if (size == 0) { return size; @@ -104,8 +97,7 @@ size_t IntegrityVerificationStorage::Read(u8* buffer, size_t size, size_t offset return m_data_storage->Read(buffer, read_size, offset); } -size_t IntegrityVerificationStorage::GetSize() const -{ +size_t IntegrityVerificationStorage::GetSize() const { return m_data_storage->GetSize(); } diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 85d30543c1..18a515015e 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -790,7 +790,9 @@ InstallResult RegisteredCache::RawInstallNCA(const NCA& nca, const VfsCopyFuncti if (GetFileAtID(id) != nullptr) { LOG_WARNING(Loader, "Overwriting existing NCA..."); VirtualDir c_dir; - { c_dir = dir->GetFileRelative(path)->GetContainingDirectory(); } + { + c_dir = dir->GetFileRelative(path)->GetContainingDirectory(); + } c_dir->DeleteFile(Common::FS::GetFilename(path)); } diff --git a/src/core/file_sys/sdmc_factory.cpp b/src/core/file_sys/sdmc_factory.cpp index f3e2e21f4c..9ff4b2b2dc 100644 --- a/src/core/file_sys/sdmc_factory.cpp +++ b/src/core/file_sys/sdmc_factory.cpp @@ -15,9 +15,7 @@ SDMCFactory::SDMCFactory(VirtualDir sd_dir_, VirtualDir sd_mod_dir_) : sd_dir(std::move(sd_dir_)), sd_mod_dir(std::move(sd_mod_dir_)), contents(std::make_unique( GetOrCreateDirectoryRelative(sd_dir, "/Nintendo/Contents/registered"), - [](const VirtualFile& file, const NcaID& id) { - return NAX{file, id}.GetDecrypted(); - })), + [](const VirtualFile& file, const NcaID& id) { return NAX{file, id}.GetDecrypted(); })), placeholder(std::make_unique( GetOrCreateDirectoryRelative(sd_dir, "/Nintendo/Contents/placehld"))) {} diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp index 68e8ec22fc..59173c6170 100644 --- a/src/core/file_sys/submission_package.cpp +++ b/src/core/file_sys/submission_package.cpp @@ -19,9 +19,9 @@ namespace FileSys { NSP::NSP(VirtualFile file_, u64 title_id_, std::size_t program_index_) - : file(std::move(file_)), expected_program_id(title_id_), - program_index(program_index_), status{Loader::ResultStatus::Success}, - pfs(std::make_shared(file)), keys{Core::Crypto::KeyManager::Instance()} { + : file(std::move(file_)), expected_program_id(title_id_), program_index(program_index_), + status{Loader::ResultStatus::Success}, pfs(std::make_shared(file)), + keys{Core::Crypto::KeyManager::Instance()} { if (pfs->GetStatus() != Loader::ResultStatus::Success) { status = pfs->GetStatus(); return; diff --git a/src/core/file_sys/xts_archive.cpp b/src/core/file_sys/xts_archive.cpp index 6692211e1d..64fa442826 100644 --- a/src/core/file_sys/xts_archive.cpp +++ b/src/core/file_sys/xts_archive.cpp @@ -44,8 +44,8 @@ static bool CalculateHMAC256(Destination* out, const SourceKey* key, std::size_t } NAX::NAX(VirtualFile file_) - : header(std::make_unique()), - file(std::move(file_)), keys{Core::Crypto::KeyManager::Instance()} { + : header(std::make_unique()), file(std::move(file_)), + keys{Core::Crypto::KeyManager::Instance()} { std::string path = Common::FS::SanitizePath(file->GetFullPath()); static const std::regex nax_path_regex("/registered/(000000[0-9A-F]{2})/([0-9A-F]{32})\\.nca", std::regex_constants::ECMAScript | @@ -62,8 +62,8 @@ NAX::NAX(VirtualFile file_) } NAX::NAX(VirtualFile file_, std::array nca_id) - : header(std::make_unique()), - file(std::move(file_)), keys{Core::Crypto::KeyManager::Instance()} { + : header(std::make_unique()), file(std::move(file_)), + keys{Core::Crypto::KeyManager::Instance()} { Core::Crypto::SHA256Hash hash{}; mbedtls_sha256_ret(nca_id.data(), nca_id.size(), hash.data(), 0); status = Parse(fmt::format("/registered/000000{:02X}/{}.nca", hash[0], diff --git a/src/core/hle/kernel/k_auto_object.h b/src/core/hle/kernel/k_auto_object.h index 8d4e0df44f..fa6e16164b 100644 --- a/src/core/hle/kernel/k_auto_object.h +++ b/src/core/hle/kernel/k_auto_object.h @@ -24,7 +24,9 @@ private: friend class ::Kernel::KClassTokenGenerator; \ static constexpr inline auto ObjectType = ::Kernel::KClassTokenGenerator::ObjectType::CLASS; \ static constexpr inline const char* const TypeName = #CLASS; \ - static constexpr inline ClassTokenType ClassToken() { return ::Kernel::ClassToken; } \ + static constexpr inline ClassTokenType ClassToken() { \ + return ::Kernel::ClassToken; \ + } \ \ public: \ YUZU_NON_COPYABLE(CLASS); \ @@ -35,9 +37,15 @@ public: constexpr ClassTokenType Token = ClassToken(); \ return TypeObj(TypeName, Token); \ } \ - static constexpr const char* GetStaticTypeName() { return TypeName; } \ - virtual TypeObj GetTypeObj() ATTRIBUTE { return GetStaticTypeObj(); } \ - virtual const char* GetTypeName() ATTRIBUTE { return GetStaticTypeName(); } \ + static constexpr const char* GetStaticTypeName() { \ + return TypeName; \ + } \ + virtual TypeObj GetTypeObj() ATTRIBUTE { \ + return GetStaticTypeObj(); \ + } \ + virtual const char* GetTypeName() ATTRIBUTE { \ + return GetStaticTypeName(); \ + } \ \ private: \ constexpr bool operator!=(const TypeObj& rhs) diff --git a/src/core/hle/kernel/k_memory_layout.cpp b/src/core/hle/kernel/k_memory_layout.cpp index bec7146688..8aec520010 100644 --- a/src/core/hle/kernel/k_memory_layout.cpp +++ b/src/core/hle/kernel/k_memory_layout.cpp @@ -128,8 +128,8 @@ KVirtualAddress KMemoryRegionTree::GetRandomAlignedRegion(size_t size, size_t al KMemoryLayout::KMemoryLayout() : m_virtual_tree{m_memory_region_allocator}, m_physical_tree{m_memory_region_allocator}, - m_virtual_linear_tree{m_memory_region_allocator}, m_physical_linear_tree{ - m_memory_region_allocator} {} + m_virtual_linear_tree{m_memory_region_allocator}, + m_physical_linear_tree{m_memory_region_allocator} {} void KMemoryLayout::InitializeLinearMemoryRegionTrees(KPhysicalAddress aligned_linear_phys_start, KVirtualAddress linear_virtual_start) { diff --git a/src/core/hle/kernel/k_priority_queue.h b/src/core/hle/kernel/k_priority_queue.h index 26677ec65c..b250700293 100644 --- a/src/core/hle/kernel/k_priority_queue.h +++ b/src/core/hle/kernel/k_priority_queue.h @@ -17,38 +17,32 @@ namespace Kernel { class KThread; template -concept KPriorityQueueAffinityMask = ! -std::is_reference_v&& requires(T& t) { - { t.GetAffinityMask() } -> Common::ConvertibleTo; - { t.SetAffinityMask(0) }; +concept KPriorityQueueAffinityMask = !std::is_reference_v && requires(T& t) { + { t.GetAffinityMask() } -> Common::ConvertibleTo; + { t.SetAffinityMask(0) }; - { t.GetAffinity(0) } -> std::same_as; - { t.SetAffinity(0, false) }; - { t.SetAll() }; - }; + { t.GetAffinity(0) } -> std::same_as; + { t.SetAffinity(0, false) }; + { t.SetAll() }; +}; template -concept KPriorityQueueMember = ! -std::is_reference_v&& requires(T& t) { - { typename T::QueueEntry() }; - { (typename T::QueueEntry()).Initialize() }; - { (typename T::QueueEntry()).SetPrev(std::addressof(t)) }; - { (typename T::QueueEntry()).SetNext(std::addressof(t)) }; - { (typename T::QueueEntry()).GetNext() } -> std::same_as; - { (typename T::QueueEntry()).GetPrev() } -> std::same_as; - { - t.GetPriorityQueueEntry(0) - } -> std::same_as; +concept KPriorityQueueMember = !std::is_reference_v && requires(T& t) { + { typename T::QueueEntry() }; + { (typename T::QueueEntry()).Initialize() }; + { (typename T::QueueEntry()).SetPrev(std::addressof(t)) }; + { (typename T::QueueEntry()).SetNext(std::addressof(t)) }; + { (typename T::QueueEntry()).GetNext() } -> std::same_as; + { (typename T::QueueEntry()).GetPrev() } -> std::same_as; + { t.GetPriorityQueueEntry(0) } -> std::same_as; - { t.GetAffinityMask() }; - { - std::remove_cvref_t() - } -> KPriorityQueueAffinityMask; + { t.GetAffinityMask() }; + { std::remove_cvref_t() } -> KPriorityQueueAffinityMask; - { t.GetActiveCore() } -> Common::ConvertibleTo; - { t.GetPriority() } -> Common::ConvertibleTo; - { t.IsDummyThread() } -> Common::ConvertibleTo; - }; + { t.GetActiveCore() } -> Common::ConvertibleTo; + { t.GetPriority() } -> Common::ConvertibleTo; + { t.IsDummyThread() } -> Common::ConvertibleTo; +}; template requires KPriorityQueueMember diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h index df3e540dc2..7b997bb5e7 100644 --- a/src/core/hle/kernel/k_process.h +++ b/src/core/hle/kernel/k_process.h @@ -84,7 +84,7 @@ private: std::array m_entropy{}; bool m_is_signaled{}; bool m_is_initialized{}; - u32 m_pointer_buffer_size = 0x8000; // Default pointer buffer size (can be game-specific later) + u32 m_pointer_buffer_size = 0x8000; // Default pointer buffer size (can be game-specific later) bool m_is_application{}; bool m_is_default_application_system_resource{}; bool m_is_hbl{}; diff --git a/src/core/hle/kernel/k_scoped_lock.h b/src/core/hle/kernel/k_scoped_lock.h index 629a7d20dd..bc9830b4da 100644 --- a/src/core/hle/kernel/k_scoped_lock.h +++ b/src/core/hle/kernel/k_scoped_lock.h @@ -10,11 +10,10 @@ namespace Kernel { template -concept KLockable = ! -std::is_reference_v&& requires(T& t) { - { t.Lock() } -> std::same_as; - { t.Unlock() } -> std::same_as; - }; +concept KLockable = !std::is_reference_v && requires(T& t) { + { t.Lock() } -> std::same_as; + { t.Unlock() } -> std::same_as; +}; template requires KLockable diff --git a/src/core/hle/kernel/svc/svc_info.cpp b/src/core/hle/kernel/svc/svc_info.cpp index 1814f5e90e..f6e2cece81 100644 --- a/src/core/hle/kernel/svc/svc_info.cpp +++ b/src/core/hle/kernel/svc/svc_info.cpp @@ -37,8 +37,8 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle case InfoType::TotalNonSystemMemorySize: case InfoType::UsedNonSystemMemorySize: case InfoType::IsApplication: - case InfoType::FreeThreadCount: - case InfoType::AliasRegionExtraSize: { + case InfoType::FreeThreadCount: + case InfoType::AliasRegionExtraSize: { R_UNLESS(info_sub_id == 0, ResultInvalidEnumValue); const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable(); @@ -135,10 +135,10 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle } R_SUCCEED(); - case InfoType::AliasRegionExtraSize: - // TODO (jarrodnorwell): do this when KIP's NPDM header is finished - R_SUCCEED(); - + case InfoType::AliasRegionExtraSize: + // TODO (jarrodnorwell): do this when KIP's NPDM header is finished + R_SUCCEED(); + default: break; } diff --git a/src/core/hle/kernel/svc_types.h b/src/core/hle/kernel/svc_types.h index d02548ba73..985e95e3fa 100644 --- a/src/core/hle/kernel/svc_types.h +++ b/src/core/hle/kernel/svc_types.h @@ -153,7 +153,7 @@ enum class InfoType : u32 { ThreadTickCount = 25, IsSvcPermitted = 26, IoRegionHint = 27, - AliasRegionExtraSize = 28, + AliasRegionExtraSize = 28, MesosphereMeta = 65000, MesosphereCurrentProcess = 65001, diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 316370266d..ad27898114 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -458,9 +458,13 @@ constexpr inline Result __TmpCurrentResultReference = ResultSuccess; if (true) #define R_CONVERT(catch_type, convert_type) \ - R_CATCH(catch_type) { R_THROW(static_cast(convert_type)); } + R_CATCH(catch_type) { \ + R_THROW(static_cast(convert_type)); \ + } #define R_CONVERT_ALL(convert_type) \ - R_CATCH_ALL() { R_THROW(static_cast(convert_type)); } + R_CATCH_ALL() { \ + R_THROW(static_cast(convert_type)); \ + } #define R_ASSERT(res_expr) ASSERT(R_SUCCEEDED(res_expr)) diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 80a2b0b72b..2b014d99c9 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp @@ -496,5 +496,4 @@ void ProfileManager::SetUserPosition(u64 position, Common::UUID uuid) { WriteUserSaveFile(); } - }; // namespace Service::Account diff --git a/src/core/hle/service/am/applet.cpp b/src/core/hle/service/am/applet.cpp index 59ade29c8e..1c9f811104 100644 --- a/src/core/hle/service/am/applet.cpp +++ b/src/core/hle/service/am/applet.cpp @@ -26,7 +26,7 @@ void Applet::UpdateSuspensionStateLocked(bool force_message) { // Remove any forced resumption. lifecycle_manager.RemoveForceResumeIfPossible(); - const bool update_requested_focus_state = lifecycle_manager.UpdateRequestedFocusState(); + const bool update_requested_focus_state = lifecycle_manager.UpdateRequestedFocusState(); const bool curr_activity_runnable = lifecycle_manager.IsRunnable(); const bool prev_activity_runnable = is_activity_runnable; const bool was_changed = curr_activity_runnable != prev_activity_runnable; @@ -36,7 +36,7 @@ void Applet::UpdateSuspensionStateLocked(bool force_message) { process->Suspend(false); } else { process->Suspend(true); - lifecycle_manager.RequestResumeNotification(); + lifecycle_manager.RequestResumeNotification(); } is_activity_runnable = curr_activity_runnable; diff --git a/src/core/hle/service/am/frontend/applet_cabinet.cpp b/src/core/hle/service/am/frontend/applet_cabinet.cpp index 4cbc80d639..2fb9a83531 100644 --- a/src/core/hle/service/am/frontend/applet_cabinet.cpp +++ b/src/core/hle/service/am/frontend/applet_cabinet.cpp @@ -18,9 +18,8 @@ namespace Service::AM::Frontend { Cabinet::Cabinet(Core::System& system_, std::shared_ptr applet_, LibraryAppletMode applet_mode_, const Core::Frontend::CabinetApplet& frontend_) - : FrontendApplet{system_, applet_, applet_mode_}, frontend{frontend_}, service_context{ - system_, - "CabinetApplet"} { + : FrontendApplet{system_, applet_, applet_mode_}, frontend{frontend_}, + service_context{system_, "CabinetApplet"} { availability_change_event = service_context.CreateEvent("CabinetApplet:AvailabilityChangeEvent"); diff --git a/src/core/hle/service/am/frontend/applet_net_connect.cpp b/src/core/hle/service/am/frontend/applet_net_connect.cpp index 91ba664b7a..1bd81f7b41 100644 --- a/src/core/hle/service/am/frontend/applet_net_connect.cpp +++ b/src/core/hle/service/am/frontend/applet_net_connect.cpp @@ -15,7 +15,9 @@ namespace Service::AM::Frontend { -NetConnect::NetConnect(Core::System& system_, std::shared_ptr applet_, LibraryAppletMode applet_mode_, const Core::Frontend::NetConnectApplet& frontend_) +NetConnect::NetConnect(Core::System& system_, std::shared_ptr applet_, + LibraryAppletMode applet_mode_, + const Core::Frontend::NetConnectApplet& frontend_) : FrontendApplet{system_, applet_, applet_mode_}, frontend{frontend_} {} NetConnect::~NetConnect() = default; diff --git a/src/core/hle/service/am/frontend/applet_net_connect.h b/src/core/hle/service/am/frontend/applet_net_connect.h index d5d503ed41..4c667fa64e 100644 --- a/src/core/hle/service/am/frontend/applet_net_connect.h +++ b/src/core/hle/service/am/frontend/applet_net_connect.h @@ -14,8 +14,8 @@ namespace Service::AM::Frontend { class NetConnect final : public FrontendApplet { public: explicit NetConnect(Core::System& system_, std::shared_ptr applet_, - LibraryAppletMode applet_mode_, - const Core::Frontend::NetConnectApplet& frontend_); + LibraryAppletMode applet_mode_, + const Core::Frontend::NetConnectApplet& frontend_); ~NetConnect() override; void Initialize() override; diff --git a/src/core/hle/service/am/frontend/applets.cpp b/src/core/hle/service/am/frontend/applets.cpp index bb69869ade..2fd731c919 100644 --- a/src/core/hle/service/am/frontend/applets.cpp +++ b/src/core/hle/service/am/frontend/applets.cpp @@ -85,7 +85,8 @@ FrontendAppletSet::FrontendAppletSet(CabinetApplet cabinet_applet, MiiEdit mii_edit_, ParentalControlsApplet parental_controls_applet, PhotoViewer photo_viewer_, ProfileSelect profile_select_, - SoftwareKeyboard software_keyboard_, WebBrowser web_browser_, NetConnect net_connect_) + SoftwareKeyboard software_keyboard_, WebBrowser web_browser_, + NetConnect net_connect_) : cabinet{std::move(cabinet_applet)}, controller{std::move(controller_applet)}, error{std::move(error_applet)}, mii_edit{std::move(mii_edit_)}, parental_controls{std::move(parental_controls_applet)}, diff --git a/src/core/hle/service/am/frontend/applets.h b/src/core/hle/service/am/frontend/applets.h index 8eb08ea77b..73387cfc63 100644 --- a/src/core/hle/service/am/frontend/applets.h +++ b/src/core/hle/service/am/frontend/applets.h @@ -10,8 +10,8 @@ #include #include "common/swap.h" -#include "core/hle/service/am/applet.h" #include "core/frontend/applets/net_connect.h" +#include "core/hle/service/am/applet.h" union Result; diff --git a/src/core/hle/service/am/process_creation.cpp b/src/core/hle/service/am/process_creation.cpp index b5e31353a2..a1c6d8a5da 100644 --- a/src/core/hle/service/am/process_creation.cpp +++ b/src/core/hle/service/am/process_creation.cpp @@ -106,7 +106,7 @@ std::unique_ptr CreateApplicationProcess(std::vector& out_control, out_control = nacp.GetRawBytes(); } else { out_control.resize(sizeof(FileSys::RawNACP)); - std::fill(out_control.begin(), out_control.end(), (u8) 0); + std::fill(out_control.begin(), out_control.end(), (u8)0); } auto& storage = system.GetContentProviderUnion(); diff --git a/src/core/hle/service/am/service/application_proxy.cpp b/src/core/hle/service/am/service/application_proxy.cpp index 6e1328fee7..633f2c2bbd 100644 --- a/src/core/hle/service/am/service/application_proxy.cpp +++ b/src/core/hle/service/am/service/application_proxy.cpp @@ -18,8 +18,8 @@ namespace Service::AM { IApplicationProxy::IApplicationProxy(Core::System& system_, std::shared_ptr applet, Kernel::KProcess* process, WindowSystem& window_system) - : ServiceFramework{system_, "IApplicationProxy"}, - m_window_system{window_system}, m_process{process}, m_applet{std::move(applet)} { + : ServiceFramework{system_, "IApplicationProxy"}, m_window_system{window_system}, + m_process{process}, m_applet{std::move(applet)} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IApplicationProxy::GetCommonStateGetter>, "GetCommonStateGetter"}, diff --git a/src/core/hle/service/am/service/display_controller.h b/src/core/hle/service/am/service/display_controller.h index 171feace6e..6e0cfff2db 100644 --- a/src/core/hle/service/am/service/display_controller.h +++ b/src/core/hle/service/am/service/display_controller.h @@ -20,7 +20,7 @@ public: private: Result GetLastForegroundCaptureImageEx(Out out_was_written, - OutBuffer out_image_data); + OutBuffer out_image_data); Result GetCallerAppletCaptureImageEx(Out out_was_written, OutBuffer out_image_data); Result TakeScreenShotOfOwnLayer(bool unknown0, s32 fbshare_layer_index); diff --git a/src/core/hle/service/am/service/library_applet_accessor.cpp b/src/core/hle/service/am/service/library_applet_accessor.cpp index 5ce96a1e3f..e7e2398649 100644 --- a/src/core/hle/service/am/service/library_applet_accessor.cpp +++ b/src/core/hle/service/am/service/library_applet_accessor.cpp @@ -101,12 +101,12 @@ Result ILibraryAppletAccessor::PushInData(SharedPointer storage) { Result ILibraryAppletAccessor::PopOutData(Out> out_storage) { LOG_DEBUG(Service_AM, "called"); - if (auto caller_applet = m_applet->caller_applet.lock(); caller_applet) { - Event m_system_event = caller_applet->lifecycle_manager.GetSystemEvent(); - m_system_event.Signal(); - caller_applet->lifecycle_manager.RequestResumeNotification(); - m_system_event.Clear(); - } + if (auto caller_applet = m_applet->caller_applet.lock(); caller_applet) { + Event m_system_event = caller_applet->lifecycle_manager.GetSystemEvent(); + m_system_event.Signal(); + caller_applet->lifecycle_manager.RequestResumeNotification(); + m_system_event.Clear(); + } R_RETURN(m_broker->GetOutData().Pop(out_storage.Get())); } diff --git a/src/core/hle/service/am/service/library_applet_creator.cpp b/src/core/hle/service/am/service/library_applet_creator.cpp index 413388d40a..63124bf050 100644 --- a/src/core/hle/service/am/service/library_applet_creator.cpp +++ b/src/core/hle/service/am/service/library_applet_creator.cpp @@ -167,8 +167,8 @@ std::shared_ptr CreateFrontendApplet(Core::System& syste ILibraryAppletCreator::ILibraryAppletCreator(Core::System& system_, std::shared_ptr applet, WindowSystem& window_system) - : ServiceFramework{system_, "ILibraryAppletCreator"}, - m_window_system{window_system}, m_applet{std::move(applet)} { + : ServiceFramework{system_, "ILibraryAppletCreator"}, m_window_system{window_system}, + m_applet{std::move(applet)} { static const FunctionInfo functions[] = { {0, D<&ILibraryAppletCreator::CreateLibraryApplet>, "CreateLibraryApplet"}, {1, nullptr, "TerminateAllLibraryApplets"}, diff --git a/src/core/hle/service/am/service/library_applet_proxy.cpp b/src/core/hle/service/am/service/library_applet_proxy.cpp index f9cfb82a90..655dd69b29 100644 --- a/src/core/hle/service/am/service/library_applet_proxy.cpp +++ b/src/core/hle/service/am/service/library_applet_proxy.cpp @@ -20,8 +20,8 @@ namespace Service::AM { ILibraryAppletProxy::ILibraryAppletProxy(Core::System& system_, std::shared_ptr applet, Kernel::KProcess* process, WindowSystem& window_system) - : ServiceFramework{system_, "ILibraryAppletProxy"}, - m_window_system{window_system}, m_process{process}, m_applet{std::move(applet)} { + : ServiceFramework{system_, "ILibraryAppletProxy"}, m_window_system{window_system}, + m_process{process}, m_applet{std::move(applet)} { // clang-format off static const FunctionInfo functions[] = { {0, D<&ILibraryAppletProxy::GetCommonStateGetter>, "GetCommonStateGetter"}, diff --git a/src/core/hle/service/am/service/self_controller.cpp b/src/core/hle/service/am/service/self_controller.cpp index 1db02b88fd..67851d3afb 100644 --- a/src/core/hle/service/am/service/self_controller.cpp +++ b/src/core/hle/service/am/service/self_controller.cpp @@ -16,8 +16,8 @@ namespace Service::AM { ISelfController::ISelfController(Core::System& system_, std::shared_ptr applet, Kernel::KProcess* process) - : ServiceFramework{system_, "ISelfController"}, m_process{process}, m_applet{ - std::move(applet)} { + : ServiceFramework{system_, "ISelfController"}, m_process{process}, + m_applet{std::move(applet)} { // clang-format off static const FunctionInfo functions[] = { {0, D<&ISelfController::Exit>, "Exit"}, diff --git a/src/core/hle/service/am/service/system_applet_proxy.cpp b/src/core/hle/service/am/service/system_applet_proxy.cpp index c435288a26..609c4aad3e 100644 --- a/src/core/hle/service/am/service/system_applet_proxy.cpp +++ b/src/core/hle/service/am/service/system_applet_proxy.cpp @@ -20,8 +20,8 @@ namespace Service::AM { ISystemAppletProxy::ISystemAppletProxy(Core::System& system_, std::shared_ptr applet, Kernel::KProcess* process, WindowSystem& window_system) - : ServiceFramework{system_, "ISystemAppletProxy"}, - m_window_system{window_system}, m_process{process}, m_applet{std::move(applet)} { + : ServiceFramework{system_, "ISystemAppletProxy"}, m_window_system{window_system}, + m_process{process}, m_applet{std::move(applet)} { // clang-format off static const FunctionInfo functions[] = { {0, D<&ISystemAppletProxy::GetCommonStateGetter>, "GetCommonStateGetter"}, diff --git a/src/core/hle/service/am/service/window_controller.cpp b/src/core/hle/service/am/service/window_controller.cpp index 54396affbe..6b1759f037 100644 --- a/src/core/hle/service/am/service/window_controller.cpp +++ b/src/core/hle/service/am/service/window_controller.cpp @@ -11,8 +11,8 @@ namespace Service::AM { IWindowController::IWindowController(Core::System& system_, std::shared_ptr applet, WindowSystem& window_system) - : ServiceFramework{system_, "IWindowController"}, - m_window_system{window_system}, m_applet{std::move(applet)} { + : ServiceFramework{system_, "IWindowController"}, m_window_system{window_system}, + m_applet{std::move(applet)} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "CreateWindow"}, diff --git a/src/core/hle/service/aoc/purchase_event_manager.cpp b/src/core/hle/service/aoc/purchase_event_manager.cpp index 9e718510b4..1192263f8a 100644 --- a/src/core/hle/service/aoc/purchase_event_manager.cpp +++ b/src/core/hle/service/aoc/purchase_event_manager.cpp @@ -9,8 +9,8 @@ namespace Service::AOC { constexpr Result ResultNoPurchasedProductInfoAvailable{ErrorModule::NIMShop, 400}; IPurchaseEventManager::IPurchaseEventManager(Core::System& system_) - : ServiceFramework{system_, "IPurchaseEventManager"}, service_context{system, - "IPurchaseEventManager"} { + : ServiceFramework{system_, "IPurchaseEventManager"}, + service_context{system, "IPurchaseEventManager"} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IPurchaseEventManager::SetDefaultDeliveryTarget>, "SetDefaultDeliveryTarget"}, diff --git a/src/core/hle/service/audio/audio_in.cpp b/src/core/hle/service/audio/audio_in.cpp index 416803acc3..9240cc3363 100644 --- a/src/core/hle/service/audio/audio_in.cpp +++ b/src/core/hle/service/audio/audio_in.cpp @@ -12,9 +12,8 @@ IAudioIn::IAudioIn(Core::System& system_, Manager& manager, size_t session_id, const std::string& device_name, const AudioInParameter& in_params, Kernel::KProcess* handle, u64 applet_resource_user_id) : ServiceFramework{system_, "IAudioIn"}, process{handle}, service_context{system_, "IAudioIn"}, - event{service_context.CreateEvent("AudioInEvent")}, impl{std::make_shared(system_, - manager, event, - session_id)} { + event{service_context.CreateEvent("AudioInEvent")}, + impl{std::make_shared(system_, manager, event, session_id)} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IAudioIn::GetAudioInState>, "GetAudioInState"}, diff --git a/src/core/hle/service/audio/audio_in_manager.cpp b/src/core/hle/service/audio/audio_in_manager.cpp index 2675a57735..d55da17c84 100644 --- a/src/core/hle/service/audio/audio_in_manager.cpp +++ b/src/core/hle/service/audio/audio_in_manager.cpp @@ -10,8 +10,8 @@ namespace Service::Audio { using namespace AudioCore::AudioIn; IAudioInManager::IAudioInManager(Core::System& system_) - : ServiceFramework{system_, "audin:u"}, impl{std::make_unique( - system_)} { + : ServiceFramework{system_, "audin:u"}, + impl{std::make_unique(system_)} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IAudioInManager::ListAudioIns>, "ListAudioIns"}, diff --git a/src/core/hle/service/audio/audio_renderer.cpp b/src/core/hle/service/audio/audio_renderer.cpp index fc4aad2339..b78660cea6 100644 --- a/src/core/hle/service/audio/audio_renderer.cpp +++ b/src/core/hle/service/audio/audio_renderer.cpp @@ -14,8 +14,8 @@ IAudioRenderer::IAudioRenderer(Core::System& system_, Manager& manager_, s32 session_id) : ServiceFramework{system_, "IAudioRenderer"}, service_context{system_, "IAudioRenderer"}, rendered_event{service_context.CreateEvent("IAudioRendererEvent")}, manager{manager_}, - impl{std::make_unique(system_, manager, rendered_event)}, process_handle{ - process_handle_} { + impl{std::make_unique(system_, manager, rendered_event)}, + process_handle{process_handle_} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IAudioRenderer::GetSampleRate>, "GetSampleRate"}, diff --git a/src/core/hle/service/bcat/news/newly_arrived_event_holder.cpp b/src/core/hle/service/bcat/news/newly_arrived_event_holder.cpp index ed393f7a26..8d64bd697a 100644 --- a/src/core/hle/service/bcat/news/newly_arrived_event_holder.cpp +++ b/src/core/hle/service/bcat/news/newly_arrived_event_holder.cpp @@ -7,9 +7,8 @@ namespace Service::News { INewlyArrivedEventHolder::INewlyArrivedEventHolder(Core::System& system_) - : ServiceFramework{system_, "INewlyArrivedEventHolder"}, service_context{ - system_, - "INewlyArrivedEventHolder"} { + : ServiceFramework{system_, "INewlyArrivedEventHolder"}, + service_context{system_, "INewlyArrivedEventHolder"} { // clang-format off static const FunctionInfo functions[] = { {0, D<&INewlyArrivedEventHolder::Get>, "Get"}, diff --git a/src/core/hle/service/bcat/news/overwrite_event_holder.cpp b/src/core/hle/service/bcat/news/overwrite_event_holder.cpp index 1712971e4d..33ea7c8951 100644 --- a/src/core/hle/service/bcat/news/overwrite_event_holder.cpp +++ b/src/core/hle/service/bcat/news/overwrite_event_holder.cpp @@ -7,8 +7,8 @@ namespace Service::News { IOverwriteEventHolder::IOverwriteEventHolder(Core::System& system_) - : ServiceFramework{system_, "IOverwriteEventHolder"}, service_context{system_, - "IOverwriteEventHolder"} { + : ServiceFramework{system_, "IOverwriteEventHolder"}, + service_context{system_, "IOverwriteEventHolder"} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IOverwriteEventHolder::Get>, "Get"}, diff --git a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp index d881e144d3..de7b550544 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp +++ b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp @@ -11,8 +11,8 @@ namespace Service::FileSystem { IFileSystem::IFileSystem(Core::System& system_, FileSys::VirtualDir dir_, SizeGetter size_getter_) - : ServiceFramework{system_, "IFileSystem"}, backend{std::make_unique( - dir_)}, + : ServiceFramework{system_, "IFileSystem"}, + backend{std::make_unique(dir_)}, size_getter{std::move(size_getter_)} { static const FunctionInfo functions[] = { {0, D<&IFileSystem::CreateFile>, "CreateFile"}, diff --git a/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp index ff823586b3..9a603e89a2 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp +++ b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp @@ -12,8 +12,8 @@ namespace Service::FileSystem { ISaveDataInfoReader::ISaveDataInfoReader(Core::System& system_, std::shared_ptr save_data_controller_, FileSys::SaveDataSpaceId space) - : ServiceFramework{system_, "ISaveDataInfoReader"}, save_data_controller{ - save_data_controller_} { + : ServiceFramework{system_, "ISaveDataInfoReader"}, + save_data_controller{save_data_controller_} { static const FunctionInfo functions[] = { {0, D<&ISaveDataInfoReader::ReadSaveDataInfo>, "ReadSaveDataInfo"}, }; diff --git a/src/core/hle/service/glue/time/alarm_worker.cpp b/src/core/hle/service/glue/time/alarm_worker.cpp index 3ff071f4a0..21ace76936 100644 --- a/src/core/hle/service/glue/time/alarm_worker.cpp +++ b/src/core/hle/service/glue/time/alarm_worker.cpp @@ -11,8 +11,8 @@ namespace Service::Glue::Time { AlarmWorker::AlarmWorker(Core::System& system, StandardSteadyClockResource& steady_clock_resource) - : m_system{system}, m_ctx{system, "Glue:AlarmWorker"}, m_steady_clock_resource{ - steady_clock_resource} {} + : m_system{system}, m_ctx{system, "Glue:AlarmWorker"}, + m_steady_clock_resource{steady_clock_resource} {} AlarmWorker::~AlarmWorker() { m_system.CoreTiming().UnscheduleEvent(m_timer_timing_event); diff --git a/src/core/hle/service/glue/time/manager.cpp b/src/core/hle/service/glue/time/manager.cpp index 77bf8896cd..c1faf8eaab 100644 --- a/src/core/hle/service/glue/time/manager.cpp +++ b/src/core/hle/service/glue/time/manager.cpp @@ -87,10 +87,8 @@ static Service::PSC::Time::LocationName GetTimeZoneString( } TimeManager::TimeManager(Core::System& system) - : m_steady_clock_resource{system}, m_time_zone_binary{system}, m_worker{ - system, - m_steady_clock_resource, - m_file_timestamp_worker} { + : m_steady_clock_resource{system}, m_time_zone_binary{system}, + m_worker{system, m_steady_clock_resource, m_file_timestamp_worker} { m_time_m = system.ServiceManager().GetService("time:m", true); diff --git a/src/core/hle/service/glue/time/time_zone.cpp b/src/core/hle/service/glue/time/time_zone.cpp index b2e8159653..a89df753a4 100644 --- a/src/core/hle/service/glue/time/time_zone.cpp +++ b/src/core/hle/service/glue/time/time_zone.cpp @@ -22,9 +22,9 @@ TimeZoneService::TimeZoneService( std::shared_ptr time_zone_service) : ServiceFramework{system_, "ITimeZoneService"}, m_system{system}, m_can_write_timezone_device_location{can_write_timezone_device_location}, - m_file_timestamp_worker{file_timestamp_worker}, m_wrapped_service{std::move( - time_zone_service)}, - m_operation_event{m_system}, m_time_zone_binary{time_zone_binary} { + m_file_timestamp_worker{file_timestamp_worker}, + m_wrapped_service{std::move(time_zone_service)}, m_operation_event{m_system}, + m_time_zone_binary{time_zone_binary} { // clang-format off static const FunctionInfo functions[] = { {0, D<&TimeZoneService::GetDeviceLocationName>, "GetDeviceLocationName"}, diff --git a/src/core/hle/service/glue/time/worker.cpp b/src/core/hle/service/glue/time/worker.cpp index 1dab3e9dcb..90cfe0a973 100644 --- a/src/core/hle/service/glue/time/worker.cpp +++ b/src/core/hle/service/glue/time/worker.cpp @@ -19,11 +19,11 @@ namespace Service::Glue::Time { TimeWorker::TimeWorker(Core::System& system, StandardSteadyClockResource& steady_clock_resource, FileTimestampWorker& file_timestamp_worker) - : m_system{system}, m_ctx{m_system, "Glue:TimeWorker"}, m_event{m_ctx.CreateEvent( - "Glue:TimeWorker:Event")}, + : m_system{system}, m_ctx{m_system, "Glue:TimeWorker"}, + m_event{m_ctx.CreateEvent("Glue:TimeWorker:Event")}, m_steady_clock_resource{steady_clock_resource}, - m_file_timestamp_worker{file_timestamp_worker}, m_timer_steady_clock{m_ctx.CreateEvent( - "Glue:TimeWorker:SteadyClockTimerEvent")}, + m_file_timestamp_worker{file_timestamp_worker}, + m_timer_steady_clock{m_ctx.CreateEvent("Glue:TimeWorker:SteadyClockTimerEvent")}, m_timer_file_system{m_ctx.CreateEvent("Glue:TimeWorker:FileTimeTimerEvent")}, m_alarm_worker{m_system, m_steady_clock_resource}, m_pm_state_change_handler{m_alarm_worker} { m_timer_steady_clock_timing_event = Core::Timing::CreateEvent( diff --git a/src/core/hle/service/hid/hid_debug_server.cpp b/src/core/hle/service/hid/hid_debug_server.cpp index 738c6d9ae2..9a9a188eca 100644 --- a/src/core/hle/service/hid/hid_debug_server.cpp +++ b/src/core/hle/service/hid/hid_debug_server.cpp @@ -17,8 +17,8 @@ namespace Service::HID { IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr resource, std::shared_ptr settings) - : ServiceFramework{system_, "hid:dbg"}, resource_manager{resource}, firmware_settings{ - settings} { + : ServiceFramework{system_, "hid:dbg"}, resource_manager{resource}, + firmware_settings{settings} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "DeactivateDebugPad"}, diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp index ebda7fc3f2..bbd541cb82 100644 --- a/src/core/hle/service/hid/hid_server.cpp +++ b/src/core/hle/service/hid/hid_server.cpp @@ -587,10 +587,8 @@ Result IHidServer::ActivateGesture(u32 basic_gesture_id, ClientAppletResourceUse Result IHidServer::SetGestureOutputRanges(u32 param1, u32 param2, u32 param3, u32 param4) { // https://switchbrew.org/wiki/HID_services , Undocumented. 92 [18.0.0+] SetGestureOutputRanges - LOG_WARNING( - Service_HID, - "(STUBBED) called, param1={}, param2={}, param3={}, param4={}", - param1, param2, param3, param4); + LOG_WARNING(Service_HID, "(STUBBED) called, param1={}, param2={}, param3={}, param4={}", param1, + param2, param3, param4); R_SUCCEED(); } diff --git a/src/core/hle/service/ipc_helpers.h b/src/core/hle/service/ipc_helpers.h index 4b02872fba..97b46d5889 100644 --- a/src/core/hle/service/ipc_helpers.h +++ b/src/core/hle/service/ipc_helpers.h @@ -72,8 +72,8 @@ public: u32 num_handles_to_copy_ = 0, u32 num_objects_to_move_ = 0, Flags flags = Flags::None) : RequestHelperBase(ctx), normal_params_size(normal_params_size_), - num_handles_to_copy(num_handles_to_copy_), - num_objects_to_move(num_objects_to_move_), kernel{ctx.kernel} { + num_handles_to_copy(num_handles_to_copy_), num_objects_to_move(num_objects_to_move_), + kernel{ctx.kernel} { memset(cmdbuf, 0, sizeof(u32) * IPC::COMMAND_BUFFER_LENGTH); diff --git a/src/core/hle/service/jit/jit_context.cpp b/src/core/hle/service/jit/jit_context.cpp index 0090e8568d..8df63f9e26 100644 --- a/src/core/hle/service/jit/jit_context.cpp +++ b/src/core/hle/service/jit/jit_context.cpp @@ -40,8 +40,8 @@ class DynarmicCallbacks64 : public Dynarmic::A64::UserCallbacks { public: explicit DynarmicCallbacks64(Core::Memory::Memory& memory_, std::vector& local_memory_, IntervalSet& mapped_ranges_, JITContextImpl& parent_) - : memory{memory_}, local_memory{local_memory_}, - mapped_ranges{mapped_ranges_}, parent{parent_} {} + : memory{memory_}, local_memory{local_memory_}, mapped_ranges{mapped_ranges_}, + parent{parent_} {} u8 MemoryRead8(u64 vaddr) override { return ReadMemory(vaddr); diff --git a/src/core/hle/service/ldn/lan_discovery.cpp b/src/core/hle/service/ldn/lan_discovery.cpp index 7d677e6664..e24a8fb28c 100644 --- a/src/core/hle/service/ldn/lan_discovery.cpp +++ b/src/core/hle/service/ldn/lan_discovery.cpp @@ -37,7 +37,7 @@ void LanStation::OverrideInfo() { } LANDiscovery::LANDiscovery() - : stations({{{1, this}, {2, this}, {3, this}, {4, this}, {5, this}, {6, this}, {7, this}}}){} + : stations({{{1, this}, {2, this}, {3, this}, {4, this}, {5, this}, {6, this}, {7, this}}}) {} LANDiscovery::~LANDiscovery() { if (inited) { diff --git a/src/core/hle/service/ldn/user_local_communication_service.cpp b/src/core/hle/service/ldn/user_local_communication_service.cpp index 69170a879d..743244b996 100644 --- a/src/core/hle/service/ldn/user_local_communication_service.cpp +++ b/src/core/hle/service/ldn/user_local_communication_service.cpp @@ -24,8 +24,7 @@ namespace Service::LDN { IUserLocalCommunicationService::IUserLocalCommunicationService(Core::System& system_) : ServiceFramework{system_, "IUserLocalCommunicationService"}, - service_context{system, "IUserLocalCommunicationService"}, - lan_discovery{} { + service_context{system, "IUserLocalCommunicationService"}, lan_discovery{} { // clang-format off static const FunctionInfo functions[] = { {0, C<&IUserLocalCommunicationService::GetState>, "GetState"}, diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index adaaea571a..5232bcd050 100644 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp @@ -23,8 +23,8 @@ class IDatabaseService final : public ServiceFramework { public: explicit IDatabaseService(Core::System& system_, std::shared_ptr mii_manager, bool is_system_) - : ServiceFramework{system_, "IDatabaseService"}, manager{mii_manager}, is_system{ - is_system_} { + : ServiceFramework{system_, "IDatabaseService"}, manager{mii_manager}, + is_system{is_system_} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IDatabaseService::IsUpdated>, "IsUpdated"}, diff --git a/src/core/hle/service/mm/mm_u.cpp b/src/core/hle/service/mm/mm_u.cpp index 8fa2341ffb..da9fbc98fc 100644 --- a/src/core/hle/service/mm/mm_u.cpp +++ b/src/core/hle/service/mm/mm_u.cpp @@ -7,43 +7,43 @@ #include "core/hle/service/server_manager.h" #include "core/hle/service/sm/sm.h" -#include - -namespace Service::MM { -enum class Module : u32 { - CPU = 0, - GPU = 1, - EMC = 2, - SYS_BUS = 3, - M_SELECT = 4, - NVDEC = 5, - NVENC = 6, - NVJPG = 7, - TEST = 8 -}; - -class Session { -public: - Session(Module module_, u32 request_id_, bool is_auto_clear_event_) { - this->module = module_; - this->request_id = request_id_; - this->is_auto_clear_event = is_auto_clear_event_; - this->min = 0; - this->max = -1; - }; - -public: - Module module; - u32 request_id, min; - s32 max; - bool is_auto_clear_event; +#include + +namespace Service::MM { +enum class Module : u32 { + CPU = 0, + GPU = 1, + EMC = 2, + SYS_BUS = 3, + M_SELECT = 4, + NVDEC = 5, + NVENC = 6, + NVJPG = 7, + TEST = 8 +}; + +class Session { +public: + Session(Module module_, u32 request_id_, bool is_auto_clear_event_) { + this->module = module_; + this->request_id = request_id_; + this->is_auto_clear_event = is_auto_clear_event_; + this->min = 0; + this->max = -1; + }; + +public: + Module module; + u32 request_id, min; + s32 max; + bool is_auto_clear_event; + + void SetAndWait(u32 min_, s32 max_) { + this->min = min_; + this->max = max_; + } +}; - void SetAndWait(u32 min_, s32 max_) { - this->min = min_; - this->max = max_; - } -}; - class MM_U final : public ServiceFramework { public: explicit MM_U(Core::System& system_) : ServiceFramework{system_, "mm:u"} { @@ -65,53 +65,53 @@ public: private: void InitializeOld(HLERequestContext& ctx) { - LOG_DEBUG(Service_MM, "(STUBBED) called"); - - IPC::RequestParser rp{ctx}; - const auto module = rp.PopEnum(); - rp.Pop(); - const auto event_clear_mode = rp.Pop(); + LOG_DEBUG(Service_MM, "(STUBBED) called"); + + IPC::RequestParser rp{ctx}; + const auto module = rp.PopEnum(); + rp.Pop(); + const auto event_clear_mode = rp.Pop(); + + const bool is_auto_clear_event = event_clear_mode == 1; + + sessions.push_back({module, request_id++, is_auto_clear_event}); - const bool is_auto_clear_event = event_clear_mode == 1; - - sessions.push_back({module, request_id++, is_auto_clear_event}); - IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } void FinalizeOld(HLERequestContext& ctx) { - LOG_DEBUG(Service_MM, "(STUBBED) called"); - - IPC::RequestParser rp{ctx}; - const auto module = rp.PopEnum(); - - for (auto it = sessions.begin(); it != sessions.end(); ++it) { - if (it->module == module) { - sessions.erase(it); - break; - } - } + LOG_DEBUG(Service_MM, "(STUBBED) called"); + + IPC::RequestParser rp{ctx}; + const auto module = rp.PopEnum(); + + for (auto it = sessions.begin(); it != sessions.end(); ++it) { + if (it->module == module) { + sessions.erase(it); + break; + } + } IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } void SetAndWaitOld(HLERequestContext& ctx) { - LOG_DEBUG(Service_MM, "(STUBBED) called"); - - IPC::RequestParser rp{ctx}; - const auto module = rp.PopEnum(); - const auto min = rp.Pop(); - const auto max = rp.Pop(); + LOG_DEBUG(Service_MM, "(STUBBED) called"); + + IPC::RequestParser rp{ctx}; + const auto module = rp.PopEnum(); + const auto min = rp.Pop(); + const auto max = rp.Pop(); + + for (auto& session : sessions) { + if (session.module == module) { + session.SetAndWait(min, max); + break; + } + } - for (auto& session : sessions) { - if (session.module == module) { - session.SetAndWait(min, max); - break; - } - } - IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } @@ -119,72 +119,72 @@ private: void GetOld(HLERequestContext& ctx) { LOG_DEBUG(Service_MM, "(STUBBED) called"); - IPC::RequestParser rp{ctx}; - const auto module = rp.PopEnum(); - - for (const auto& session : sessions) { - if (session.module == module) { - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); - rb.Push(session.min); - return; - } - } - + IPC::RequestParser rp{ctx}; + const auto module = rp.PopEnum(); + + for (const auto& session : sessions) { + if (session.module == module) { + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + rb.Push(session.min); + return; + } + } + IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push(0); + rb.Push(0); } void Initialize(HLERequestContext& ctx) { - LOG_DEBUG(Service_MM, "(STUBBED) called"); - - IPC::RequestParser rp{ctx}; - const auto module = rp.PopEnum(); - rp.Pop(); - const auto event_clear_mode = rp.Pop(); - - const bool is_auto_clear_event = event_clear_mode == 1; - - sessions.push_back({module, request_id++, is_auto_clear_event}); + LOG_DEBUG(Service_MM, "(STUBBED) called"); + + IPC::RequestParser rp{ctx}; + const auto module = rp.PopEnum(); + rp.Pop(); + const auto event_clear_mode = rp.Pop(); + + const bool is_auto_clear_event = event_clear_mode == 1; + + sessions.push_back({module, request_id++, is_auto_clear_event}); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push(request_id - 1); + rb.Push(request_id - 1); } void Finalize(HLERequestContext& ctx) { - LOG_DEBUG(Service_MM, "(STUBBED) called"); + LOG_DEBUG(Service_MM, "(STUBBED) called"); + + IPC::RequestParser rp{ctx}; + const auto id = rp.Pop(); + + for (auto it = sessions.begin(); it != sessions.end(); ++it) { + if (it->request_id == id) { + sessions.erase(it); + break; + } + } - IPC::RequestParser rp{ctx}; - const auto id = rp.Pop(); - - for (auto it = sessions.begin(); it != sessions.end(); ++it) { - if (it->request_id == id) { - sessions.erase(it); - break; - } - } - IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } void SetAndWait(HLERequestContext& ctx) { - LOG_DEBUG(Service_MM, "(STUBBED) called"); - - IPC::RequestParser rp{ctx}; - const auto id = rp.Pop(); - const auto min = rp.Pop(); - const auto max = rp.Pop(); + LOG_DEBUG(Service_MM, "(STUBBED) called"); + + IPC::RequestParser rp{ctx}; + const auto id = rp.Pop(); + const auto min = rp.Pop(); + const auto max = rp.Pop(); + + for (auto& session : sessions) { + if (session.request_id == id) { + session.SetAndWait(min, max); + break; + } + } - for (auto& session : sessions) { - if (session.request_id == id) { - session.SetAndWait(min, max); - break; - } - } - IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } @@ -192,25 +192,25 @@ private: void Get(HLERequestContext& ctx) { LOG_DEBUG(Service_MM, "(STUBBED) called"); - IPC::RequestParser rp{ctx}; - const auto id = rp.Pop(); - - for (const auto& session : sessions) { - if (session.request_id == id) { - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(session.min); - return; - } - } - + IPC::RequestParser rp{ctx}; + const auto id = rp.Pop(); + + for (const auto& session : sessions) { + if (session.request_id == id) { + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(session.min); + return; + } + } + IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push(0); + rb.Push(0); } - std::vector sessions; - u32 request_id{1}; + std::vector sessions; + u32 request_id{1}; }; void LoopProcess(Core::System& system) { diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index e18afdb88b..7d37710bb0 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -67,7 +67,6 @@ static u128 MakeUuidFromName(std::string_view name) { return {h1, h2}; } - // This is nn::nifm::RequestState enum class RequestState : u32 { NotSubmitted = 1, @@ -217,7 +216,6 @@ struct PendingProfile { std::array passphrase{}; }; - constexpr Result ResultPendingConnection{ErrorModule::NIFM, 111}; constexpr Result ResultInvalidInput{ErrorModule::NIFM, 112}; constexpr Result ResultNetworkCommunicationDisabled{ErrorModule::NIFM, 1111}; @@ -278,8 +276,7 @@ private: IPC::ResponseBuilder{ctx, 2}.Push(ResultSuccess); } - void IsProcessing(HLERequestContext& ctx) - { + void IsProcessing(HLERequestContext& ctx) { const bool processing = state.load() == State::Processing; IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); @@ -306,7 +303,7 @@ private: enum class State { Idle, Processing, Finished }; - void WorkerThread() { + void WorkerThread() { using namespace std::chrono_literals; scan_results = Network::ScanWifiNetworks(3s); @@ -321,7 +318,6 @@ private: Finish(ok ? ResultSuccess : ResultPendingConnection); } - void Finish(Result rc) { worker_result.store(rc); state.store(State::Finished); @@ -665,8 +661,9 @@ void IGeneralService::GetNetworkProfile(HLERequestContext& ctx) { std::memcpy(net_name.data(), net_state.ssid, ssid_len); SfWirelessSettingData wifi{}; - wifi.ssid_length = static_cast(std::min(std::strlen(net_state.ssid), net_name.size())); - wifi.is_secured = !net_state.secure; //somehow reversed + wifi.ssid_length = + static_cast(std::min(std::strlen(net_state.ssid), net_name.size())); + wifi.is_secured = !net_state.secure; // somehow reversed wifi.passphrase = {"password"}; std::memcpy(wifi.ssid.data(), net_state.ssid, wifi.ssid_length); @@ -693,11 +690,10 @@ void IGeneralService::GetNetworkProfile(HLERequestContext& ctx) { .uuid{MakeUuidFromName(net_state.ssid)}, .network_name{net_name}, .profile_type = static_cast(NetworkProfileType::User), - .interface_type = - static_cast(net_iface->kind == - Network::HostAdapterKind::Wifi ? NetworkInterfaceType::WiFi_Ieee80211 : NetworkInterfaceType::Ethernet), - .wireless_setting_data{wifi} - }; + .interface_type = static_cast(net_iface->kind == Network::HostAdapterKind::Wifi + ? NetworkInterfaceType::WiFi_Ieee80211 + : NetworkInterfaceType::Ethernet), + .wireless_setting_data{wifi}}; }(); ctx.WriteBuffer(profile); @@ -732,7 +728,6 @@ void IGeneralService::SetNetworkProfile(HLERequestContext& ctx) { IPC::ResponseBuilder{ctx, 2}.Push(ResultSuccess); } - void IGeneralService::RemoveNetworkProfile(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); @@ -759,7 +754,6 @@ void IGeneralService::GetScanDataV2(HLERequestContext& ctx) { const std::size_t max_rows = guest_bytes / sizeof(AccessPointDataV3); const std::size_t rows_copy = std::min(scans.size(), max_rows); - std::vector rows; rows.resize(rows_copy); @@ -776,7 +770,7 @@ void IGeneralService::GetScanDataV2(HLERequestContext& ctx) { ap.strength = to_bars(s.quality); bool is_connected = std::strncmp(net_state.ssid, ap.ssid, ap.ssid_len) == 0 && - net_state.ssid[ap.ssid_len] == '\0'; + net_state.ssid[ap.ssid_len] == '\0'; ap.visible = (is_connected) ? 0 : 1; ap.has_password = (s.flags & 2) ? 2 : 1; diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp index 8210fd92a6..8963f86c78 100644 --- a/src/core/hle/service/nim/nim.cpp +++ b/src/core/hle/service/nim/nim.cpp @@ -241,7 +241,7 @@ public: private: void CreateServerInterface(HLERequestContext& ctx) { - LOG_DEBUG(Service_NIM, "(STUBBED) called"); + LOG_DEBUG(Service_NIM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); rb.PushIpcInterface(system); @@ -258,14 +258,14 @@ private: rb.Push(ResultSuccess); rb.Push(false); } - - void CreateServerInterface2(HLERequestContext& ctx) { - LOG_DEBUG(Service_NIM, "(STUBBED) called."); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system); - } + + void CreateServerInterface2(HLERequestContext& ctx) { + LOG_DEBUG(Service_NIM, "(STUBBED) called."); + + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(ResultSuccess); + rb.PushIpcInterface(system); + } }; class NIM_SHP final : public ServiceFramework { diff --git a/src/core/hle/service/ns/application_manager_interface.cpp b/src/core/hle/service/ns/application_manager_interface.cpp index f1ddba8231..6f16f39bb6 100644 --- a/src/core/hle/service/ns/application_manager_interface.cpp +++ b/src/core/hle/service/ns/application_manager_interface.cpp @@ -315,7 +315,8 @@ IApplicationManagerInterface::IApplicationManagerInterface(Core::System& system_ IApplicationManagerInterface::~IApplicationManagerInterface() = default; -Result IApplicationManagerInterface::UnregisterNetworkServiceAccountWithUserSaveDataDeletion(Common::UUID user_id) { +Result IApplicationManagerInterface::UnregisterNetworkServiceAccountWithUserSaveDataDeletion( + Common::UUID user_id) { LOG_DEBUG(Service_NS, "called, user_id={}", user_id.FormattedString()); R_SUCCEED(); } diff --git a/src/core/hle/service/ns/dynamic_rights_interface.cpp b/src/core/hle/service/ns/dynamic_rights_interface.cpp index b5a507d6e9..8ba8e5fd66 100644 --- a/src/core/hle/service/ns/dynamic_rights_interface.cpp +++ b/src/core/hle/service/ns/dynamic_rights_interface.cpp @@ -63,8 +63,8 @@ Result IDynamicRightsInterface::VerifyActivatedRightsOwners(u64 rights_handle) { R_SUCCEED(); } -Result IDynamicRightsInterface::HasAccountRestrictedRightsInRunningApplications( - Out out_status, u64 rights_handle) { +Result IDynamicRightsInterface::HasAccountRestrictedRightsInRunningApplications(Out out_status, + u64 rights_handle) { LOG_WARNING(Service_NS, "(STUBBED) called, rights_handle={:#x}", rights_handle); *out_status = 0; R_SUCCEED(); diff --git a/src/core/hle/service/ns/dynamic_rights_interface.h b/src/core/hle/service/ns/dynamic_rights_interface.h index e9429ea915..fbf44053bc 100644 --- a/src/core/hle/service/ns/dynamic_rights_interface.h +++ b/src/core/hle/service/ns/dynamic_rights_interface.h @@ -20,8 +20,7 @@ private: Result NotifyApplicationRightsCheckStart(); Result GetRunningApplicationStatus(Out out_status, u64 rights_handle); Result VerifyActivatedRightsOwners(u64 rights_handle); - Result HasAccountRestrictedRightsInRunningApplications(Out out_status, - u64 rights_handle); + Result HasAccountRestrictedRightsInRunningApplications(Out out_status, u64 rights_handle); }; } // namespace Service::NS diff --git a/src/core/hle/service/nvdrv/core/syncpoint_manager.h b/src/core/hle/service/nvdrv/core/syncpoint_manager.h index 7728ff5967..12cdf6b19b 100644 --- a/src/core/hle/service/nvdrv/core/syncpoint_manager.h +++ b/src/core/hle/service/nvdrv/core/syncpoint_manager.h @@ -97,7 +97,7 @@ public: 0x0, // `Display` is unimplemented 0x37, // `NvJpg` 0x0, // `TSec` is unimplemented - }; //!< Maps each channel ID to a constant syncpoint + }; //!< Maps each channel ID to a constant syncpoint private: /** diff --git a/src/core/hle/service/psc/time/alarms.cpp b/src/core/hle/service/psc/time/alarms.cpp index 5e52c19f82..64af6db573 100644 --- a/src/core/hle/service/psc/time/alarms.cpp +++ b/src/core/hle/service/psc/time/alarms.cpp @@ -30,8 +30,8 @@ Alarm::~Alarm() { Alarms::Alarms(Core::System& system, StandardSteadyClockCore& steady_clock, PowerStateRequestManager& power_state_request_manager) : m_system{system}, m_ctx{system, "Psc:Alarms"}, m_steady_clock{steady_clock}, - m_power_state_request_manager{power_state_request_manager}, m_event{m_ctx.CreateEvent( - "Psc:Alarms:Event")} {} + m_power_state_request_manager{power_state_request_manager}, + m_event{m_ctx.CreateEvent("Psc:Alarms:Event")} {} Alarms::~Alarms() { m_ctx.CloseEvent(m_event); diff --git a/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.cpp b/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.cpp index 31ed273966..aa5b4c33c2 100644 --- a/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.cpp +++ b/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.cpp @@ -11,8 +11,8 @@ StandardUserSystemClockCore::StandardUserSystemClockCore( StandardNetworkSystemClockCore& network_clock) : SystemClockCore{local_clock.GetSteadyClock()}, m_system{system}, m_ctx{m_system, "Psc:StandardUserSystemClockCore"}, m_local_system_clock{local_clock}, - m_network_system_clock{network_clock}, m_event{m_ctx.CreateEvent( - "Psc:StandardUserSystemClockCore:Event")} {} + m_network_system_clock{network_clock}, + m_event{m_ctx.CreateEvent("Psc:StandardUserSystemClockCore:Event")} {} StandardUserSystemClockCore::~StandardUserSystemClockCore() { m_ctx.CloseEvent(m_event); diff --git a/src/core/hle/service/psc/time/common.cpp b/src/core/hle/service/psc/time/common.cpp index a6d9f02ca3..1728c84499 100644 --- a/src/core/hle/service/psc/time/common.cpp +++ b/src/core/hle/service/psc/time/common.cpp @@ -6,8 +6,8 @@ namespace Service::PSC::Time { OperationEvent::OperationEvent(Core::System& system) - : m_ctx{system, "Time:OperationEvent"}, m_event{ - m_ctx.CreateEvent("Time:OperationEvent:Event")} {} + : m_ctx{system, "Time:OperationEvent"}, + m_event{m_ctx.CreateEvent("Time:OperationEvent:Event")} {} OperationEvent::~OperationEvent() { m_ctx.CloseEvent(m_event); diff --git a/src/core/hle/service/psc/time/manager.h b/src/core/hle/service/psc/time/manager.h index 62ded12475..57c682c690 100644 --- a/src/core/hle/service/psc/time/manager.h +++ b/src/core/hle/service/psc/time/manager.h @@ -29,8 +29,8 @@ public: m_standard_user_system_clock{m_system, m_standard_local_system_clock, m_standard_network_system_clock}, m_ephemeral_network_clock{m_tick_based_steady_clock}, m_shared_memory{m_system}, - m_power_state_request_manager{m_system}, m_alarms{m_system, m_standard_steady_clock, - m_power_state_request_manager}, + m_power_state_request_manager{m_system}, + m_alarms{m_system, m_standard_steady_clock, m_power_state_request_manager}, m_local_system_clock_context_writer{m_system, m_shared_memory}, m_network_system_clock_context_writer{m_system, m_shared_memory, m_standard_user_system_clock}, diff --git a/src/core/hle/service/psc/time/power_state_service.cpp b/src/core/hle/service/psc/time/power_state_service.cpp index ab1d32c703..6fe03dc2e8 100644 --- a/src/core/hle/service/psc/time/power_state_service.cpp +++ b/src/core/hle/service/psc/time/power_state_service.cpp @@ -8,8 +8,8 @@ namespace Service::PSC::Time { IPowerStateRequestHandler::IPowerStateRequestHandler( Core::System& system_, PowerStateRequestManager& power_state_request_manager) - : ServiceFramework{system_, "time:p"}, m_system{system}, m_power_state_request_manager{ - power_state_request_manager} { + : ServiceFramework{system_, "time:p"}, m_system{system}, + m_power_state_request_manager{power_state_request_manager} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IPowerStateRequestHandler::GetPowerStateRequestEventReadableHandle>, "GetPowerStateRequestEventReadableHandle"}, diff --git a/src/core/hle/service/psc/time/static.cpp b/src/core/hle/service/psc/time/static.cpp index 9a0adb2955..591849813e 100644 --- a/src/core/hle/service/psc/time/static.cpp +++ b/src/core/hle/service/psc/time/static.cpp @@ -37,8 +37,8 @@ StaticService::StaticService(Core::System& system_, StaticServiceSetupInfo setup m_user_system_clock{m_time->m_standard_user_system_clock}, m_network_system_clock{m_time->m_standard_network_system_clock}, m_time_zone{m_time->m_time_zone}, - m_ephemeral_network_clock{m_time->m_ephemeral_network_clock}, m_shared_memory{ - m_time->m_shared_memory} { + m_ephemeral_network_clock{m_time->m_ephemeral_network_clock}, + m_shared_memory{m_time->m_shared_memory} { // clang-format off static const FunctionInfo functions[] = { {0, D<&StaticService::GetStandardUserSystemClock>, "GetStandardUserSystemClock"}, diff --git a/src/core/hle/service/psc/time/steady_clock.cpp b/src/core/hle/service/psc/time/steady_clock.cpp index 78dcf532ce..cb10024f2f 100644 --- a/src/core/hle/service/psc/time/steady_clock.cpp +++ b/src/core/hle/service/psc/time/steady_clock.cpp @@ -12,8 +12,8 @@ SteadyClock::SteadyClock(Core::System& system_, std::shared_ptr man bool can_write_steady_clock, bool can_write_uninitialized_clock) : ServiceFramework{system_, "ISteadyClock"}, m_system{system}, m_clock_core{manager->m_standard_steady_clock}, - m_can_write_steady_clock{can_write_steady_clock}, m_can_write_uninitialized_clock{ - can_write_uninitialized_clock} { + m_can_write_steady_clock{can_write_steady_clock}, + m_can_write_uninitialized_clock{can_write_uninitialized_clock} { // clang-format off static const FunctionInfo functions[] = { {0, D<&SteadyClock::GetCurrentTimePoint>, "GetCurrentTimePoint"}, diff --git a/src/core/hle/service/psc/time/system_clock.cpp b/src/core/hle/service/psc/time/system_clock.cpp index 9f841d8e04..ed9f098045 100644 --- a/src/core/hle/service/psc/time/system_clock.cpp +++ b/src/core/hle/service/psc/time/system_clock.cpp @@ -11,8 +11,8 @@ namespace Service::PSC::Time { SystemClock::SystemClock(Core::System& system_, SystemClockCore& clock_core, bool can_write_clock, bool can_write_uninitialized_clock) : ServiceFramework{system_, "ISystemClock"}, m_system{system}, m_clock_core{clock_core}, - m_can_write_clock{can_write_clock}, m_can_write_uninitialized_clock{ - can_write_uninitialized_clock} { + m_can_write_clock{can_write_clock}, + m_can_write_uninitialized_clock{can_write_uninitialized_clock} { // clang-format off static const FunctionInfo functions[] = { {0, D<&SystemClock::GetCurrentTime>, "GetCurrentTime"}, diff --git a/src/core/hle/service/psc/time/time_zone_service.cpp b/src/core/hle/service/psc/time/time_zone_service.cpp index 9e0674f275..92e695a326 100644 --- a/src/core/hle/service/psc/time/time_zone_service.cpp +++ b/src/core/hle/service/psc/time/time_zone_service.cpp @@ -13,8 +13,8 @@ namespace Service::PSC::Time { TimeZoneService::TimeZoneService(Core::System& system_, StandardSteadyClockCore& clock_core, TimeZone& time_zone, bool can_write_timezone_device_location) : ServiceFramework{system_, "ITimeZoneService"}, m_system{system}, m_clock_core{clock_core}, - m_time_zone{time_zone}, m_can_write_timezone_device_location{ - can_write_timezone_device_location} { + m_time_zone{time_zone}, + m_can_write_timezone_device_location{can_write_timezone_device_location} { // clang-format off static const FunctionInfo functions[] = { {0, D<&TimeZoneService::GetDeviceLocationName>, "GetDeviceLocationName"}, diff --git a/src/core/hle/service/set/settings_server.cpp b/src/core/hle/service/set/settings_server.cpp index aa873bc8c5..5e235b66d8 100644 --- a/src/core/hle/service/set/settings_server.cpp +++ b/src/core/hle/service/set/settings_server.cpp @@ -240,7 +240,8 @@ Result ISettingsServer::GetDeviceNickName( R_SUCCEED(); } -Result ISettingsServer::GetKeyCodeMapByPort(OutLargeData out_key_code_map, u32 port) { +Result ISettingsServer::GetKeyCodeMapByPort( + OutLargeData out_key_code_map, u32 port) { LOG_DEBUG(Service_SET, "called, port={}", port); // Similar to other key code map functions, just pass through to the main implementation diff --git a/src/core/hle/service/set/settings_server.h b/src/core/hle/service/set/settings_server.h index a9cee5f626..5d47dcd70c 100644 --- a/src/core/hle/service/set/settings_server.h +++ b/src/core/hle/service/set/settings_server.h @@ -46,8 +46,9 @@ private: Result GetDeviceNickName( OutLargeData, BufferAttr_HipcMapAlias> out_device_name); - - Result GetKeyCodeMapByPort(OutLargeData out_key_code_map, u32 port); + + Result GetKeyCodeMapByPort(OutLargeData out_key_code_map, + u32 port); }; } // namespace Service::Set diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 1095dcf6c3..1373da17fa 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -251,8 +251,8 @@ void SM::UnregisterService(HLERequestContext& ctx) { } SM::SM(ServiceManager& service_manager_, Core::System& system_) - : ServiceFramework{system_, "sm:", 4}, - service_manager{service_manager_}, kernel{system_.Kernel()} { + : ServiceFramework{system_, "sm:", 4}, service_manager{service_manager_}, + kernel{system_.Kernel()} { RegisterHandlers({ {0, &SM::Initialize, "Initialize"}, {1, &SM::GetServiceCmif, "GetService"}, diff --git a/src/core/hle/service/sm/sm_controller.cpp b/src/core/hle/service/sm/sm_controller.cpp index 9e25eae4d4..b9d3990c43 100644 --- a/src/core/hle/service/sm/sm_controller.cpp +++ b/src/core/hle/service/sm/sm_controller.cpp @@ -101,13 +101,13 @@ void Controller::SetPointerBufferSize(HLERequestContext& ctx) { process->SetPointerBufferSize(requested_size); - LOG_INFO(Service, "Pointer buffer size dynamically updated to {:#x} bytes by process", requested_size); + LOG_INFO(Service, "Pointer buffer size dynamically updated to {:#x} bytes by process", + requested_size); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - // https://switchbrew.org/wiki/IPC_Marshalling Controller::Controller(Core::System& system_) : ServiceFramework{system_, "IpcController"} { static const FunctionInfo functions[] = { diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index a5e1378197..5fe7d97653 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp @@ -11,6 +11,7 @@ #include +#include #include "common/microprofile.h" #include "common/socket_types.h" #include "core/core.h" @@ -22,7 +23,6 @@ #include "core/internal_network/socket_proxy.h" #include "core/internal_network/sockets.h" #include "network/network.h" -#include using Common::Expected; using Common::Unexpected; @@ -979,8 +979,7 @@ void BSD::OnProxyPacketReceived(const Network::ProxyPacket& packet) { } } -BSD::BSD(Core::System& system_, const char* name) - : ServiceFramework{system_, name} { +BSD::BSD(Core::System& system_, const char* name) : ServiceFramework{system_, name} { // clang-format off static const FunctionInfo functions[] = { {0, &BSD::RegisterClient, "RegisterClient"}, diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index 67e37e0823..dbe88ccf5a 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp @@ -562,9 +562,9 @@ private: }; class ISslServiceForSystem final : public ServiceFramework { - public: - explicit ISslServiceForSystem(Core::System& system_) : ServiceFramework{system_, "ssl:s"} { - // clang-format off +public: + explicit ISslServiceForSystem(Core::System& system_) : ServiceFramework{system_, "ssl:s"} { + // clang-format off static const FunctionInfo functions[] = { {0, D<&ISslServiceForSystem::CreateContext>, "CreateContext"}, {1, D<&ISslServiceForSystem::GetContextCount>, "GetContextCount"}, @@ -581,124 +581,124 @@ class ISslServiceForSystem final : public ServiceFramework {102, D<&ISslServiceForSystem::GetThreadCoreMask>, "GetThreadCoreMask"}, {103, D<&ISslServiceForSystem::VerifySignature>, "VerifySignature"} }; - // clang-format on - - RegisterHandlers(functions); - }; - - Result CreateContext() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; - - Result GetContextCount() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; - - Result GetCertificates() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; - - Result GetCertificateBufSize() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; - - Result DebugIoctl() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; - - Result SetInterfaceVersion() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; - - Result FlushSessionCache() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; - - Result SetDebugOption() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; - - Result GetDebugOption() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; - - Result ClearTls12FallbackFlag() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; - - Result CreateContextForSystem() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; - - Result SetThreadCoreMask() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; - - Result GetThreadCoreMask() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; - - Result VerifySignature() { - LOG_DEBUG(Service_SSL, "(STUBBED) called."); - - // TODO (jarrodnorwell) - - return ResultSuccess; - }; + // clang-format on + + RegisterHandlers(functions); }; + Result CreateContext() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; + + Result GetContextCount() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; + + Result GetCertificates() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; + + Result GetCertificateBufSize() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; + + Result DebugIoctl() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; + + Result SetInterfaceVersion() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; + + Result FlushSessionCache() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; + + Result SetDebugOption() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; + + Result GetDebugOption() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; + + Result ClearTls12FallbackFlag() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; + + Result CreateContextForSystem() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; + + Result SetThreadCoreMask() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; + + Result GetThreadCoreMask() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; + + Result VerifySignature() { + LOG_DEBUG(Service_SSL, "(STUBBED) called."); + + // TODO (jarrodnorwell) + + return ResultSuccess; + }; +}; + void LoopProcess(Core::System& system) { auto server_manager = std::make_unique(system); diff --git a/src/core/hle/service/ssl/ssl_types.h b/src/core/hle/service/ssl/ssl_types.h index 16623c0fc5..1d327a653c 100644 --- a/src/core/hle/service/ssl/ssl_types.h +++ b/src/core/hle/service/ssl/ssl_types.h @@ -40,39 +40,42 @@ enum class CaCertificateId : s32 { GoDaddyRootCertificateAuthorityG2 = 1025, StarfieldClass2CertificationAuthority = 1026, StarfieldRootCertificateAuthorityG2 = 1027, - thawtePrimaryRootCAG3 = 1028, // [8.0.0+] TrustedCertStatus is EnabledNotTrusted - thawtePrimaryRootCA = 1029, // [8.0.0+] TrustedCertStatus is EnabledNotTrusted - VeriSignClass3PublicPrimaryCertificationAuthorityG3 = 1030, // [8.0.0+] TrustedCertStatus is EnabledNotTrusted - VeriSignClass3PublicPrimaryCertificationAuthorityG5 = 1031, // [8.0.0+] TrustedCertStatus is EnabledNotTrusted - VeriSignUniversalRootCertificationAuthority = 1032, // [8.0.0+] TrustedCertStatus is EnabledNotTrusted - DSTRootCAX3 = 1033, // [6.0.0+] - USERTrustRsaCertificationAuthority = 1034, // [10.0.3+] - ISRGRootX10 = 1035, // [10.1.0+] - USERTrustEccCertificationAuthority = 1036, // [10.1.0+] - COMODORsaCertificationAuthority = 1037, // [10.1.0+] - COMODOEccCertificationAuthority = 1038, // [10.1.0+] - AmazonRootCA2 = 1039, // [11.0.0+] - AmazonRootCA3 = 1040, // [11.0.0+] - AmazonRootCA4 = 1041, // [11.0.0+] - DigiCertAssuredIDRootG3 = 1042, // [11.0.0+] - DigiCertGlobalRootG3 = 1043, // [11.0.0+] - DigiCertTrustedRootG4 = 1044, // [11.0.0+] - EntrustRootCertificationAuthorityEC1 = 1045, // [11.0.0+] - EntrustRootCertificationAuthorityG4 = 1046, // [11.0.0+] - GlobalSignECCRootCAR4 = 1047, // [11.0.0+] - GlobalSignECCRootCAR5 = 1048, // [11.0.0+] - GlobalSignECCRootCAR6 = 1049, // [11.0.0+] - GTSRootR1 = 1050, // [11.0.0+] - GTSRootR2 = 1051, // [11.0.0+] - GTSRootR3 = 1052, // [11.0.0+] - GTSRootR4 = 1053, // [11.0.0+] - SecurityCommunicationRootCA = 1054, // [12.0.0+] - GlobalSignRootE4 = 1055, // [15.0.0+] - GlobalSignRootR4 = 1056, // [15.0.0+] - TTeleSecGlobalRootClass2 = 1057, // [15.0.0+] - DigiCertTLSECCP384RootG5 = 1058, // [16.0.0+] - DigiCertTLSRSA4096RootG5 = 1059, // [16.0.0+] - NintendoTempRootCAG4 = 65536, // [16.0.0+] ([19.0.0+] Removed) + thawtePrimaryRootCAG3 = 1028, // [8.0.0+] TrustedCertStatus is EnabledNotTrusted + thawtePrimaryRootCA = 1029, // [8.0.0+] TrustedCertStatus is EnabledNotTrusted + VeriSignClass3PublicPrimaryCertificationAuthorityG3 = + 1030, // [8.0.0+] TrustedCertStatus is EnabledNotTrusted + VeriSignClass3PublicPrimaryCertificationAuthorityG5 = + 1031, // [8.0.0+] TrustedCertStatus is EnabledNotTrusted + VeriSignUniversalRootCertificationAuthority = + 1032, // [8.0.0+] TrustedCertStatus is EnabledNotTrusted + DSTRootCAX3 = 1033, // [6.0.0+] + USERTrustRsaCertificationAuthority = 1034, // [10.0.3+] + ISRGRootX10 = 1035, // [10.1.0+] + USERTrustEccCertificationAuthority = 1036, // [10.1.0+] + COMODORsaCertificationAuthority = 1037, // [10.1.0+] + COMODOEccCertificationAuthority = 1038, // [10.1.0+] + AmazonRootCA2 = 1039, // [11.0.0+] + AmazonRootCA3 = 1040, // [11.0.0+] + AmazonRootCA4 = 1041, // [11.0.0+] + DigiCertAssuredIDRootG3 = 1042, // [11.0.0+] + DigiCertGlobalRootG3 = 1043, // [11.0.0+] + DigiCertTrustedRootG4 = 1044, // [11.0.0+] + EntrustRootCertificationAuthorityEC1 = 1045, // [11.0.0+] + EntrustRootCertificationAuthorityG4 = 1046, // [11.0.0+] + GlobalSignECCRootCAR4 = 1047, // [11.0.0+] + GlobalSignECCRootCAR5 = 1048, // [11.0.0+] + GlobalSignECCRootCAR6 = 1049, // [11.0.0+] + GTSRootR1 = 1050, // [11.0.0+] + GTSRootR2 = 1051, // [11.0.0+] + GTSRootR3 = 1052, // [11.0.0+] + GTSRootR4 = 1053, // [11.0.0+] + SecurityCommunicationRootCA = 1054, // [12.0.0+] + GlobalSignRootE4 = 1055, // [15.0.0+] + GlobalSignRootR4 = 1056, // [15.0.0+] + TTeleSecGlobalRootClass2 = 1057, // [15.0.0+] + DigiCertTLSECCP384RootG5 = 1058, // [16.0.0+] + DigiCertTLSRSA4096RootG5 = 1059, // [16.0.0+] + NintendoTempRootCAG4 = 65536, // [16.0.0+] ([19.0.0+] Removed) }; enum class TrustedCertStatus : s32 { diff --git a/src/core/hle/service/vi/application_display_service.cpp b/src/core/hle/service/vi/application_display_service.cpp index 289ad7073c..68f3a6de6e 100644 --- a/src/core/hle/service/vi/application_display_service.cpp +++ b/src/core/hle/service/vi/application_display_service.cpp @@ -15,8 +15,8 @@ namespace Service::VI { IApplicationDisplayService::IApplicationDisplayService(Core::System& system_, std::shared_ptr container) - : ServiceFramework{system_, "IApplicationDisplayService"}, - m_container{std::move(container)}, m_context{system, "IApplicationDisplayService"} { + : ServiceFramework{system_, "IApplicationDisplayService"}, m_container{std::move(container)}, + m_context{system, "IApplicationDisplayService"} { // clang-format off static const FunctionInfo functions[] = { {100, C<&IApplicationDisplayService::GetRelayService>, "GetRelayService"}, @@ -91,9 +91,8 @@ Result IApplicationDisplayService::OpenDisplay(Out out_display_id, DisplayN display_name[display_name.size() - 1] = '\0'; // According to switchbrew, only "Default", "External", "Edid", "Internal" and "Null" are valid - const std::array valid_names = { - "Default", "External", "Edid", "Internal", "Null" - }; + const std::array valid_names = {"Default", "External", "Edid", "Internal", + "Null"}; bool valid_name = false; for (const auto& name : valid_names) { diff --git a/src/core/hle/service/vi/conductor.cpp b/src/core/hle/service/vi/conductor.cpp index c8ce4fca04..d6c001e187 100644 --- a/src/core/hle/service/vi/conductor.cpp +++ b/src/core/hle/service/vi/conductor.cpp @@ -15,9 +15,8 @@ namespace Service::VI { Conductor::Conductor(Core::System& system, Container& container, DisplayList& displays) : m_system(system), m_container(container) { - displays.ForEachDisplay([&](Display& display) { - m_vsync_managers.insert({display.GetId(), VsyncManager{}}); - }); + displays.ForEachDisplay( + [&](Display& display) { m_vsync_managers.insert({display.GetId(), VsyncManager{}}); }); if (system.IsMulticore()) { m_event = Core::Timing::CreateEvent( diff --git a/src/core/internal_network/emu_net_state.h b/src/core/internal_network/emu_net_state.h index d16f1830a6..5cfc523d24 100644 --- a/src/core/internal_network/emu_net_state.h +++ b/src/core/internal_network/emu_net_state.h @@ -3,8 +3,8 @@ #pragma once #include -#include #include +#include namespace Network { diff --git a/src/core/internal_network/network_interface.cpp b/src/core/internal_network/network_interface.cpp index 42def7af92..8cc41e9501 100644 --- a/src/core/internal_network/network_interface.cpp +++ b/src/core/internal_network/network_interface.cpp @@ -80,13 +80,12 @@ std::vector GetAvailableNetworkInterfaces() { break; } - result.emplace_back(NetworkInterface{ - .name = Common::UTF16ToUTF8(std::wstring{a->FriendlyName}), - .ip_address = ip, - .subnet_mask = mask, - .gateway = gw, - .kind = kind - }); + result.emplace_back( + NetworkInterface{.name = Common::UTF16ToUTF8(std::wstring{a->FriendlyName}), + .ip_address = ip, + .subnet_mask = mask, + .gateway = gw, + .kind = kind}); } return result; @@ -122,11 +121,10 @@ std::vector GetAvailableNetworkInterfaces() { // On Android, we can't reliably get gateway info from /proc/net/route // Just use 0 as the gateway address result.emplace_back(NetworkInterface{ - .name{ifa->ifa_name}, - .ip_address{Common::BitCast(*ifa->ifa_addr).sin_addr}, - .subnet_mask{Common::BitCast(*ifa->ifa_netmask).sin_addr}, - .gateway{in_addr{.s_addr = 0}} - }); + .name{ifa->ifa_name}, + .ip_address{Common::BitCast(*ifa->ifa_addr).sin_addr}, + .subnet_mask{Common::BitCast(*ifa->ifa_netmask).sin_addr}, + .gateway{in_addr{.s_addr = 0}}}); #else u32 gateway{}; @@ -206,11 +204,11 @@ std::optional GetSelectedNetworkInterface() { return std::nullopt; } - #ifdef __ANDROID__ - if (selected_network_interface.empty()) { - return network_interfaces[0]; - } - #endif +#ifdef __ANDROID__ + if (selected_network_interface.empty()) { + return network_interfaces[0]; + } +#endif const auto res = std::ranges::find_if(network_interfaces, [&selected_network_interface](const auto& iface) { diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index 4a87ab53e7..478000baf9 100644 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp @@ -4,6 +4,7 @@ #include #include "common/hex_util.h" +#include "common/literals.h" #include "common/scope_exit.h" #include "core/core.h" #include "core/file_sys/content_archive.h" @@ -15,7 +16,6 @@ #include "core/loader/deconstructed_rom_directory.h" #include "core/loader/nca.h" #include "mbedtls/sha256.h" -#include "common/literals.h" namespace Loader { @@ -105,7 +105,8 @@ AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::KProcess& process, Core::S return load_result; } - LOG_INFO(Loader, "Set pointer buffer size to {:#x} bytes for ProgramID {:#018x} (Heap size: {:#x})", + LOG_INFO(Loader, + "Set pointer buffer size to {:#x} bytes for ProgramID {:#018x} (Heap size: {:#x})", process.GetPointerBufferSize(), nca->GetTitleId(), heap_size); // Register the process in the file system controller diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp index d8921e5658..ae651631d6 100644 --- a/src/core/memory/cheat_engine.cpp +++ b/src/core/memory/cheat_engine.cpp @@ -218,8 +218,8 @@ std::vector TextCheatParser::Parse(std::string_view data) const { CheatEngine::CheatEngine(System& system_, std::vector cheats_, const std::array& build_id_) - : vm{std::make_unique(system_, metadata)}, - cheats(std::move(cheats_)), core_timing{system_.CoreTiming()}, system{system_} { + : vm{std::make_unique(system_, metadata)}, cheats(std::move(cheats_)), + core_timing{system_.CoreTiming()}, system{system_} { metadata.main_nso_build_id = build_id_; } diff --git a/src/dedicated_room/yuzu_room.cpp b/src/dedicated_room/yuzu_room.cpp index 156bff62dc..2556201b93 100644 --- a/src/dedicated_room/yuzu_room.cpp +++ b/src/dedicated_room/yuzu_room.cpp @@ -190,8 +190,7 @@ static void InitializeLogging(const std::string& log_file) { } /// Application entry point -void LaunchRoom(int argc, char** argv, bool called_by_option) -{ +void LaunchRoom(int argc, char** argv, bool called_by_option) { Common::DetachedTasks detached_tasks; int option_index = 0; char* endarg; @@ -240,7 +239,8 @@ void LaunchRoom(int argc, char** argv, bool called_by_option) InitializeLogging(log_file); while (optind < argc) { - int arg = getopt_long(argc, argv, "n:d:s:p:m:w:g:u:t:a:i:l:hv", long_options, &option_index); + int arg = + getopt_long(argc, argv, "n:d:s:p:m:w:g:u:t:a:i:l:hv", long_options, &option_index); if (arg != -1) { char carg = static_cast(arg); @@ -312,8 +312,7 @@ void LaunchRoom(int argc, char** argv, bool called_by_option) "room.\nSet with --preferred-game-id id"); } if (max_members > Network::MaxConcurrentConnections || max_members < 2) { - LOG_ERROR(Network, - "max_members needs to be in the range 2 - {}!", + LOG_ERROR(Network, "max_members needs to be in the range 2 - {}!", Network::MaxConcurrentConnections); PrintHelp(argv[0]); std::exit(-1); @@ -327,9 +326,8 @@ void LaunchRoom(int argc, char** argv, bool called_by_option) std::exit(-1); } if (ban_list_file.empty()) { - LOG_ERROR(Network, - "Ban list file not set!\nThis should get set to load and save room ban " - "list.\nSet with --ban-list-file "); + LOG_ERROR(Network, "Ban list file not set!\nThis should get set to load and save room ban " + "list.\nSet with --ban-list-file "); } bool announce = true; if (token.empty() && announce) { diff --git a/src/frontend_common/firmware_manager.cpp b/src/frontend_common/firmware_manager.cpp index a180693996..97e94cf0cd 100644 --- a/src/frontend_common/firmware_manager.cpp +++ b/src/frontend_common/firmware_manager.cpp @@ -1,9 +1,9 @@ // SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include "firmware_manager.h" #include #include +#include "firmware_manager.h" #include "common/fs/fs.h" #include "common/fs/path_util.h" @@ -14,30 +14,26 @@ #include "frontend_common/content_manager.h" #ifdef ANDROID -#include -#include #include +#include +#include #endif -FirmwareManager::KeyInstallResult -FirmwareManager::InstallKeys(std::string location, std::string extension) { +FirmwareManager::KeyInstallResult FirmwareManager::InstallKeys(std::string location, + std::string extension) { LOG_INFO(Frontend, "Installing key files from {}", location); const auto keys_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::KeysDir); #ifdef ANDROID - JNIEnv *env = Common::Android::GetEnvForThread(); + JNIEnv* env = Common::Android::GetEnvForThread(); jstring jsrc = Common::Android::ToJString(env, location); jclass native = Common::Android::GetNativeLibraryClass(); jmethodID getExtension = Common::Android::GetFileExtension(); - jstring jext = static_cast(env->CallStaticObjectMethod( - native, - getExtension, - jsrc - )); + jstring jext = static_cast(env->CallStaticObjectMethod(native, getExtension, jsrc)); std::string ext = Common::Android::GetJString(env, jext); @@ -48,12 +44,7 @@ FirmwareManager::InstallKeys(std::string location, std::string extension) { jmethodID copyToStorage = Common::Android::GetCopyToStorage(); jstring jdest = Common::Android::ToJString(env, keys_dir.string() + "/"); - jboolean copyResult = env->CallStaticBooleanMethod( - native, - copyToStorage, - jsrc, - jdest - ); + jboolean copyResult = env->CallStaticBooleanMethod(native, copyToStorage, jsrc, jdest); if (!copyResult) { return ErrorFailedCopy; @@ -91,14 +82,11 @@ FirmwareManager::InstallKeys(std::string location, std::string extension) { return ErrorWrongFilename; } - for (const auto &key_file : source_key_files) { + for (const auto& key_file : source_key_files) { std::filesystem::path destination_key_file = keys_dir / key_file.filename(); - if (!std::filesystem::copy_file(key_file, - destination_key_file, + if (!std::filesystem::copy_file(key_file, destination_key_file, std::filesystem::copy_options::overwrite_existing)) { - LOG_ERROR(Frontend, - "Failed to copy file {} to {}", - key_file.string(), + LOG_ERROR(Frontend, "Failed to copy file {} to {}", key_file.string(), destination_key_file.string()); return ErrorFailedCopy; } @@ -116,7 +104,7 @@ FirmwareManager::InstallKeys(std::string location, std::string extension) { return ErrorFailedInit; } -FirmwareManager::FirmwareCheckResult FirmwareManager::VerifyFirmware(Core::System &system) { +FirmwareManager::FirmwareCheckResult FirmwareManager::VerifyFirmware(Core::System& system) { if (!CheckFirmwarePresence(system)) { return ErrorFirmwareMissing; } else { diff --git a/src/frontend_common/firmware_manager.h b/src/frontend_common/firmware_manager.h index 20f3b41478..c0e1a49220 100644 --- a/src/frontend_common/firmware_manager.h +++ b/src/frontend_common/firmware_manager.h @@ -4,23 +4,23 @@ #ifndef FIRMWARE_MANAGER_H #define FIRMWARE_MANAGER_H +#include +#include +#include +#include #include "common/common_types.h" #include "core/core.h" #include "core/file_sys/nca_metadata.h" #include "core/file_sys/registered_cache.h" #include "core/hle/service/filesystem/filesystem.h" -#include -#include -#include -#include +#include "core/hle/result.h" #include "core/hle/service/set/settings_types.h" #include "core/hle/service/set/system_settings_server.h" -#include "core/hle/result.h" namespace FirmwareManager { -static constexpr std::array KEY_INSTALL_RESULT_STRINGS = { +static constexpr std::array KEY_INSTALL_RESULT_STRINGS = { "Decryption Keys were successfully installed", "Unable to read key directory, aborting", "One or more keys failed to copy.", @@ -54,8 +54,7 @@ KeyInstallResult InstallKeys(std::string location, std::string expected_extensio * \param result The result code. * \return A string representation of the passed result code. */ -inline constexpr const char *GetKeyInstallResultString(KeyInstallResult result) -{ +inline constexpr const char* GetKeyInstallResultString(KeyInstallResult result) { return KEY_INSTALL_RESULT_STRINGS.at(static_cast(result)); } @@ -65,13 +64,11 @@ inline constexpr const char *GetKeyInstallResultString(KeyInstallResult result) * \param program_id The program ID to check. * \return Whether or not the program requires firmware to run properly. */ -inline constexpr bool GameRequiresFirmware(u64 program_id) -{ - return std::find(FIRMWARE_REQUIRED_GAMES.begin(), FIRMWARE_REQUIRED_GAMES.end(), program_id) - != FIRMWARE_REQUIRED_GAMES.end(); +inline constexpr bool GameRequiresFirmware(u64 program_id) { + return std::find(FIRMWARE_REQUIRED_GAMES.begin(), FIRMWARE_REQUIRED_GAMES.end(), program_id) != + FIRMWARE_REQUIRED_GAMES.end(); } - enum FirmwareCheckResult { FirmwareGood, ErrorFirmwareMissing, @@ -79,7 +76,7 @@ enum FirmwareCheckResult { ErrorFirmwareTooNew, }; -static constexpr std::array FIRMWARE_CHECK_STRINGS = { +static constexpr std::array FIRMWARE_CHECK_STRINGS = { "", "Firmware missing. Firmware is required to run certain games and use the Home Menu. " "Eden only works with firmware 19.0.1 and earlier.", @@ -93,8 +90,7 @@ static constexpr std::array FIRMWARE_CHECK_STRINGS = { * \param system The system to check for firmware. * \return Whether or not the system has installed firmware. */ -inline bool CheckFirmwarePresence(Core::System &system) -{ +inline bool CheckFirmwarePresence(Core::System& system) { constexpr u64 MiiEditId = static_cast(Service::AM::AppletProgramId::MiiEdit); auto bis_system = system.GetFileSystemController().GetSystemNANDContents(); @@ -116,15 +112,14 @@ inline bool CheckFirmwarePresence(Core::System &system) * \param system The system to check firmware on. * \return A result code defining the status of the system's firmware. */ -FirmwareCheckResult VerifyFirmware(Core::System &system); +FirmwareCheckResult VerifyFirmware(Core::System& system); /** * \brief Get a string representation of a result from CheckFirmwareVersion. * \param result The result code. * \return A string representation of the passed result code. */ -inline constexpr const char *GetFirmwareCheckString(FirmwareCheckResult result) -{ +inline constexpr const char* GetFirmwareCheckString(FirmwareCheckResult result) { return FIRMWARE_CHECK_STRINGS.at(static_cast(result)); } @@ -133,16 +128,14 @@ inline constexpr const char *GetFirmwareCheckString(FirmwareCheckResult result) * @param system The system to check firmware on. * @return A pair of the firmware version format and result code. */ -inline std::pair GetFirmwareVersion(Core::System &system) -{ +inline std::pair GetFirmwareVersion( + Core::System& system) { Service::Set::FirmwareVersionFormat firmware_data{}; - const auto result - = Service::Set::GetFirmwareVersionImpl(firmware_data, - system, - Service::Set::GetFirmwareVersionType::Version2); + const auto result = Service::Set::GetFirmwareVersionImpl( + firmware_data, system, Service::Set::GetFirmwareVersionType::Version2); return {firmware_data, result}; } -} +} // namespace FirmwareManager #endif // FIRMWARE_MANAGER_H diff --git a/src/hid_core/frontend/emulated_controller.cpp b/src/hid_core/frontend/emulated_controller.cpp index 5bdad4a0ad..e20800ec02 100644 --- a/src/hid_core/frontend/emulated_controller.cpp +++ b/src/hid_core/frontend/emulated_controller.cpp @@ -760,14 +760,15 @@ void EmulatedController::StartMotionCalibration() { } } -void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, Common::UUID uuid) { +void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, + Common::UUID uuid) { const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type); const auto& player = Settings::values.players.GetValue()[player_index]; - - if (index >= controller.button_values.size()) { + + if (index >= controller.button_values.size()) { return; } - + std::unique_lock lock{mutex}; bool value_changed = false; const auto new_status = TransformToButton(callback); diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp index d483cd3490..ed6c01d0af 100644 --- a/src/input_common/drivers/udp_client.cpp +++ b/src/input_common/drivers/udp_client.cpp @@ -117,7 +117,6 @@ private: boost::asio::basic_waitable_timer timer; udp::socket socket; - const u32 client_id; static constexpr std::size_t PORT_INFO_SIZE = sizeof(Message); diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 188e862d7f..1c0d5d9ed6 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp @@ -148,8 +148,8 @@ public: Common::Input::AnalogProperties properties_y_, InputEngine* input_engine_) : identifier(identifier_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), - properties_y(properties_y_), - input_engine(input_engine_), invert_axis_y{input_engine_->GetEngineName() == "sdl"} { + properties_y(properties_y_), input_engine(input_engine_), + invert_axis_y{input_engine_->GetEngineName() == "sdl"} { UpdateCallback engine_callback{[this]() { OnChange(); }}; const InputIdentifier x_input_identifier{ .identifier = identifier, diff --git a/src/network/announce_multiplayer_session.cpp b/src/network/announce_multiplayer_session.cpp index 8836524c73..dafd90413f 100644 --- a/src/network/announce_multiplayer_session.cpp +++ b/src/network/announce_multiplayer_session.cpp @@ -13,9 +13,9 @@ #include "common/settings.h" #include "network/network.h" -//#ifdef ENABLE_WEB_SERVICE +// #ifdef ENABLE_WEB_SERVICE #include "web_service/announce_room_json.h" -//#endif +// #endif namespace Core { @@ -23,13 +23,13 @@ namespace Core { static constexpr std::chrono::seconds announce_time_interval(15); AnnounceMultiplayerSession::AnnounceMultiplayerSession() { -//#ifdef ENABLE_WEB_SERVICE + // #ifdef ENABLE_WEB_SERVICE backend = std::make_unique(Settings::values.web_api_url.GetValue(), Settings::values.eden_username.GetValue(), Settings::values.eden_token.GetValue()); -//#else -// backend = std::make_unique(); -//#endif + // #else + // backend = std::make_unique(); + // #endif } WebService::WebResult AnnounceMultiplayerSession::Register() { @@ -156,11 +156,11 @@ bool AnnounceMultiplayerSession::IsRunning() const { void AnnounceMultiplayerSession::UpdateCredentials() { ASSERT_MSG(!IsRunning(), "Credentials can only be updated when session is not running"); -//#ifdef ENABLE_WEB_SERVICE + // #ifdef ENABLE_WEB_SERVICE backend = std::make_unique(Settings::values.web_api_url.GetValue(), Settings::values.eden_username.GetValue(), Settings::values.eden_token.GetValue()); -//#endif + // #endif } } // namespace Core diff --git a/src/network/packet.cpp b/src/network/packet.cpp index 0e22f1eb4d..e7fc83ed99 100644 --- a/src/network/packet.cpp +++ b/src/network/packet.cpp @@ -14,13 +14,13 @@ namespace Network { #ifndef htonll static u64 htonll(u64 x) { - return ((1 == htonl(1)) ? (x) : ((uint64_t)htonl((x)&0xFFFFFFFF) << 32) | htonl((x) >> 32)); + return ((1 == htonl(1)) ? (x) : ((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32)); } #endif #ifndef ntohll static u64 ntohll(u64 x) { - return ((1 == ntohl(1)) ? (x) : ((uint64_t)ntohl((x)&0xFFFFFFFF) << 32) | ntohl((x) >> 32)); + return ((1 == ntohl(1)) ? (x) : ((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32)); } #endif diff --git a/src/network/room.cpp b/src/network/room.cpp index 99dcf0c3b4..5fe44f4857 100644 --- a/src/network/room.cpp +++ b/src/network/room.cpp @@ -360,7 +360,7 @@ void Room::RoomImpl::HandleJoinRequest(const ENetEvent* event) { } if (verify_backend != nullptr) - member.user_data = verify_backend->LoadUserData(uid, token); + member.user_data = verify_backend->LoadUserData(uid, token); if (nickname == room_information.host_username) { member.user_data.moderator = true; diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp index 47babcdc07..e0e8942e48 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp @@ -6,8 +6,8 @@ #include "shader_recompiler/backend/glasm/emit_glasm_instructions.h" #include "shader_recompiler/backend/glasm/glasm_emit_context.h" #include "shader_recompiler/frontend/ir/value.h" -#include "shader_recompiler/runtime_info.h" #include "shader_recompiler/profile.h" +#include "shader_recompiler/runtime_info.h" #include "shader_recompiler/shader_info.h" namespace Shader::Backend::GLASM { diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp index 0ce73f289b..fd6a9c4bfb 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp @@ -35,7 +35,7 @@ Id StorageIndex(EmitContext& ctx, const IR::Value& offset, size_t element_size) } Id StoragePointer(EmitContext& ctx, const StorageTypeDefinition& type_def, - Id StorageDefinitions::*member_ptr, const IR::Value& binding, + Id StorageDefinitions::* member_ptr, const IR::Value& binding, const IR::Value& offset, size_t element_size) { if (!binding.IsImmediate()) { throw NotImplementedException("Dynamic storage buffer indexing"); diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index 5dab8b62ea..076aeb9e52 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp @@ -110,7 +110,7 @@ std::optional OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { } } -Id GetCbuf(EmitContext& ctx, Id result_type, Id UniformDefinitions::*member_ptr, u32 element_size, +Id GetCbuf(EmitContext& ctx, Id result_type, Id UniformDefinitions::* member_ptr, u32 element_size, const IR::Value& binding, const IR::Value& offset, const Id indirect_func) { Id buffer_offset; const Id uniform_type{ctx.uniform_types.*member_ptr}; @@ -427,7 +427,7 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, Id value, [[maybe_un static constexpr IR::Attribute cd7 = IR::Attribute::ClipDistance7; if (attr >= cd0 && attr <= cd7) { - const u32 idx = (u32) attr - (u32) cd0; + const u32 idx = (u32)attr - (u32)cd0; clip_distance_written.set(idx); } ctx.OpStore(output->pointer, value); @@ -556,9 +556,12 @@ Id EmitInvocationInfo(EmitContext& ctx) { switch (ctx.stage) { case Stage::TessellationControl: case Stage::TessellationEval: - return ctx.OpShiftLeftLogical(ctx.U32[1], ctx.OpLoad(ctx.U32[1], ctx.patch_vertices_in), ctx.Const(16u)); + return ctx.OpShiftLeftLogical(ctx.U32[1], ctx.OpLoad(ctx.U32[1], ctx.patch_vertices_in), + ctx.Const(16u)); case Stage::Geometry: - return ctx.OpShiftLeftLogical(ctx.U32[1], ctx.Const(InputTopologyVertices::vertices(ctx.runtime_info.input_topology)), ctx.Const(16u)); + return ctx.OpShiftLeftLogical( + ctx.U32[1], ctx.Const(InputTopologyVertices::vertices(ctx.runtime_info.input_topology)), + ctx.Const(16u)); default: LOG_WARNING(Shader, "(STUBBED) called"); return ctx.Const(0x00ff0000u); diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_convert.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_convert.cpp index 7b6e34f315..432e270a1b 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_convert.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_convert.cpp @@ -151,7 +151,7 @@ Id EmitConvertF16F32(EmitContext& ctx, Id value) { const auto result = ctx.OpFConvert(ctx.F16[1], value); const auto isOverflowing = ctx.OpIsNan(ctx.U1, result); return ctx.OpSelect(ctx.F16[1], isOverflowing, ctx.Constant(ctx.F16[1], 0), result); - //return ctx.OpFConvert(ctx.F16[1], value); + // return ctx.OpFConvert(ctx.F16[1], value); } Id EmitConvertF32F16(EmitContext& ctx, Id value) { diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp index bdcbccfde9..fb7aed28ee 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp @@ -29,7 +29,7 @@ Id StorageIndex(EmitContext& ctx, const IR::Value& offset, size_t element_size, Id StoragePointer(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, const StorageTypeDefinition& type_def, size_t element_size, - Id StorageDefinitions::*member_ptr, u32 index_offset = 0) { + Id StorageDefinitions::* member_ptr, u32 index_offset = 0) { if (!binding.IsImmediate()) { throw NotImplementedException("Dynamic storage buffer indexing"); } @@ -40,7 +40,7 @@ Id StoragePointer(EmitContext& ctx, const IR::Value& binding, const IR::Value& o Id LoadStorage(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, Id result_type, const StorageTypeDefinition& type_def, size_t element_size, - Id StorageDefinitions::*member_ptr, u32 index_offset = 0) { + Id StorageDefinitions::* member_ptr, u32 index_offset = 0) { const Id pointer{ StoragePointer(ctx, binding, offset, type_def, element_size, member_ptr, index_offset)}; return ctx.OpLoad(result_type, pointer); @@ -54,7 +54,7 @@ Id LoadStorage32(EmitContext& ctx, const IR::Value& binding, const IR::Value& of void WriteStorage(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, Id value, const StorageTypeDefinition& type_def, size_t element_size, - Id StorageDefinitions::*member_ptr, u32 index_offset = 0) { + Id StorageDefinitions::* member_ptr, u32 index_offset = 0) { const Id pointer{ StoragePointer(ctx, binding, offset, type_def, element_size, member_ptr, index_offset)}; ctx.OpStore(pointer, value); diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 388ddce2c8..9ad604fcf7 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -262,7 +262,7 @@ void Name(EmitContext& ctx, Id object, std::string_view format_str, Args&&... ar .c_str()); } -void DefineConstBuffers(EmitContext& ctx, const Info& info, Id UniformDefinitions::*member_type, +void DefineConstBuffers(EmitContext& ctx, const Info& info, Id UniformDefinitions::* member_type, u32 binding, Id type, char type_char, u32 element_size) { const Id array_type{ctx.TypeArray(type, ctx.Const(65536U / element_size))}; ctx.Decorate(array_type, spv::Decoration::ArrayStride, element_size); @@ -293,7 +293,7 @@ void DefineConstBuffers(EmitContext& ctx, const Info& info, Id UniformDefinition } void DefineSsbos(EmitContext& ctx, StorageTypeDefinition& type_def, - Id StorageDefinitions::*member_type, const Info& info, u32 binding, Id type, + Id StorageDefinitions::* member_type, const Info& info, u32 binding, Id type, u32 stride) { const Id array_type{ctx.TypeRuntimeArray(type)}; ctx.Decorate(array_type, spv::Decoration::ArrayStride, stride); @@ -1156,7 +1156,7 @@ void EmitContext::DefineConstantBufferIndirectFunctions(const Info& info) { if (!info.uses_cbuf_indirect) { return; } - const auto make_accessor{[&](Id buffer_type, Id UniformDefinitions::*member_ptr) { + const auto make_accessor{[&](Id buffer_type, Id UniformDefinitions::* member_ptr) { const Id func_type{TypeFunction(buffer_type, U32[1], U32[1])}; const Id func{OpFunction(buffer_type, spv::FunctionControlMask::MaskNone, func_type)}; const Id binding{OpFunctionParameter(U32[1])}; diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.h b/src/shader_recompiler/backend/spirv/spirv_emit_context.h index 66cdb1d3db..65da62ac9b 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.h +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.h @@ -69,7 +69,7 @@ struct UniformDefinitions { Id U32x2{}; Id U32x4{}; - constexpr static size_t NumElements(Id UniformDefinitions::*member_ptr) { + constexpr static size_t NumElements(Id UniformDefinitions::* member_ptr) { if (member_ptr == &UniformDefinitions::U8) { return 1; } @@ -98,7 +98,7 @@ struct UniformDefinitions { return 1; } - constexpr static bool IsFloat(Id UniformDefinitions::*member_ptr) { + constexpr static bool IsFloat(Id UniformDefinitions::* member_ptr) { if (member_ptr == &UniformDefinitions::F32) { return true; } diff --git a/src/shader_recompiler/frontend/maxwell/control_flow.cpp b/src/shader_recompiler/frontend/maxwell/control_flow.cpp index a2ad56cc49..b8d09d1614 100644 --- a/src/shader_recompiler/frontend/maxwell/control_flow.cpp +++ b/src/shader_recompiler/frontend/maxwell/control_flow.cpp @@ -186,8 +186,8 @@ Function::Function(ObjectPool& block_pool, Location start_address) CFG::CFG(Environment& env_, ObjectPool& block_pool_, Location start_address, bool exits_to_dispatcher_) - : env{env_}, block_pool{block_pool_}, program_start{start_address}, exits_to_dispatcher{ - exits_to_dispatcher_} { + : env{env_}, block_pool{block_pool_}, program_start{start_address}, + exits_to_dispatcher{exits_to_dispatcher_} { if (exits_to_dispatcher) { dispatch_block = block_pool.Create(Block{}); dispatch_block->begin = {}; diff --git a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp index 3c18f49982..acc54ca8bb 100644 --- a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp +++ b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp @@ -112,8 +112,8 @@ struct Statement : ListBaseHook { Statement(SetVariable, u32 id_, Statement* op_, Statement* up_) : op{op_}, id{id_}, up{up_}, type{StatementType::SetVariable} {} Statement(SetIndirectBranchVariable, IR::Reg branch_reg_, s32 branch_offset_, Statement* up_) - : branch_offset{branch_offset_}, - branch_reg{branch_reg_}, up{up_}, type{StatementType::SetIndirectBranchVariable} {} + : branch_offset{branch_offset_}, branch_reg{branch_reg_}, up{up_}, + type{StatementType::SetIndirectBranchVariable} {} Statement(Variable, u32 id_, Statement* up_) : id{id_}, up{up_}, type{StatementType::Variable} {} Statement(IndirectBranchCond, u32 location_, Statement* up_) diff --git a/src/shader_recompiler/ir_opt/texture_pass.cpp b/src/shader_recompiler/ir_opt/texture_pass.cpp index afd880526a..f198150d36 100644 --- a/src/shader_recompiler/ir_opt/texture_pass.cpp +++ b/src/shader_recompiler/ir_opt/texture_pass.cpp @@ -349,11 +349,13 @@ TextureInst MakeInst(Environment& env, IR::Block* block, IR::Inst& inst) { const std::optional track_addr{Track(inst.Arg(0), env)}; if (!track_addr) { - //throw NotImplementedException("Failed to track bindless texture constant buffer"); - addr = last_valid_addr; // TODO:xbzk: shall be dropped when Track method cover all bindless stuff + // throw NotImplementedException("Failed to track bindless texture constant buffer"); + addr = last_valid_addr; // TODO:xbzk: shall be dropped when Track method cover all + // bindless stuff } else { addr = *track_addr; - last_valid_addr = addr; // TODO:xbzk: shall be dropped when Track method cover all bindless stuff + last_valid_addr = + addr; // TODO:xbzk: shall be dropped when Track method cover all bindless stuff } } else { addr = ConstBufferAddr{ diff --git a/src/tests/common/host_memory.cpp b/src/tests/common/host_memory.cpp index cb040c942d..57268e7878 100644 --- a/src/tests/common/host_memory.cpp +++ b/src/tests/common/host_memory.cpp @@ -15,8 +15,12 @@ static constexpr auto PERMS = Common::MemoryPermission::ReadWrite; static constexpr auto HEAP = false; TEST_CASE("HostMemory: Initialize and deinitialize", "[common]") { - { HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); } - { HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); } + { + HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + } + { + HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + } } TEST_CASE("HostMemory: Simple map", "[common]") { diff --git a/src/tests/input_common/calibration_configuration_job.cpp b/src/tests/input_common/calibration_configuration_job.cpp index 8f5466253c..14d9c8e2a5 100644 --- a/src/tests/input_common/calibration_configuration_job.cpp +++ b/src/tests/input_common/calibration_configuration_job.cpp @@ -11,7 +11,6 @@ #include "input_common/drivers/udp_client.h" #include "input_common/helpers/udp_protocol.h" - class FakeCemuhookServer { public: FakeCemuhookServer() diff --git a/src/video_core/cdma_pusher.cpp b/src/video_core/cdma_pusher.cpp index 2a13594719..ab949ea0da 100644 --- a/src/video_core/cdma_pusher.cpp +++ b/src/video_core/cdma_pusher.cpp @@ -21,8 +21,8 @@ namespace Tegra { CDmaPusher::CDmaPusher(Host1x::Host1x& host1x_, s32 id) : host1x{host1x_}, memory_manager{host1x.GMMU()}, - host_processor{std::make_unique(host1x_)}, current_class{ - static_cast(id)} { + host_processor{std::make_unique(host1x_)}, + current_class{static_cast(id)} { thread = std::jthread([this](std::stop_token stop_token) { ProcessEntries(stop_token); }); } diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 0d47b032c8..5e070fa3b4 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -24,9 +24,8 @@ constexpr u32 MacroRegistersStart = 0xE00; Maxwell3D::Maxwell3D(Core::System& system_, MemoryManager& memory_manager_) : draw_manager{std::make_unique(this)}, system{system_}, - memory_manager{memory_manager_}, macro_engine{GetMacroEngine(*this)}, upload_state{ - memory_manager, - regs.upload} { + memory_manager{memory_manager_}, macro_engine{GetMacroEngine(*this)}, + upload_state{memory_manager, regs.upload} { dirty.flags.flip(); InitializeRegisterDefaults(); execution_mask.reset(); diff --git a/src/video_core/engines/puller.cpp b/src/video_core/engines/puller.cpp index 8dd34c04ab..415bac9c98 100644 --- a/src/video_core/engines/puller.cpp +++ b/src/video_core/engines/puller.cpp @@ -21,8 +21,8 @@ namespace Tegra::Engines { Puller::Puller(GPU& gpu_, MemoryManager& memory_manager_, DmaPusher& dma_pusher_, Control::ChannelState& channel_state_) - : gpu{gpu_}, memory_manager{memory_manager_}, dma_pusher{dma_pusher_}, channel_state{ - channel_state_} {} + : gpu{gpu_}, memory_manager{memory_manager_}, dma_pusher{dma_pusher_}, + channel_state{channel_state_} {} Puller::~Puller() = default; diff --git a/src/video_core/host1x/codecs/decoder.cpp b/src/video_core/host1x/codecs/decoder.cpp old mode 100755 new mode 100644 index 49a601969c..c62c11e28f --- a/src/video_core/host1x/codecs/decoder.cpp +++ b/src/video_core/host1x/codecs/decoder.cpp @@ -11,8 +11,8 @@ namespace Tegra { Decoder::Decoder(Host1x::Host1x& host1x_, s32 id_, const Host1x::NvdecCommon::NvdecRegisters& regs_, Host1x::FrameQueue& frame_queue_) - : host1x(host1x_), memory_manager{host1x.GMMU()}, regs{regs_}, id{id_}, frame_queue{ - frame_queue_} {} + : host1x(host1x_), memory_manager{host1x.GMMU()}, regs{regs_}, id{id_}, + frame_queue{frame_queue_} {} Decoder::~Decoder() = default; diff --git a/src/video_core/host1x/ffmpeg/ffmpeg.cpp b/src/video_core/host1x/ffmpeg/ffmpeg.cpp index d6eff2bdd7..cd04de544b 100644 --- a/src/video_core/host1x/ffmpeg/ffmpeg.cpp +++ b/src/video_core/host1x/ffmpeg/ffmpeg.cpp @@ -100,10 +100,12 @@ bool Decoder::SupportsDecodingOnDevice(AVPixelFormat* out_pix_fmt, AVHWDeviceTyp for (int i = 0;; i++) { const AVCodecHWConfig* config = avcodec_get_hw_config(m_codec, i); if (!config) { - LOG_DEBUG(HW_GPU, "{} decoder does not support device type {}", m_codec->name, av_hwdevice_get_type_name(type)); + LOG_DEBUG(HW_GPU, "{} decoder does not support device type {}", m_codec->name, + av_hwdevice_get_type_name(type)); break; } - if (config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX && config->device_type == type) { + if (config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX && + config->device_type == type) { LOG_INFO(HW_GPU, "Using {} GPU decoder", av_hwdevice_get_type_name(type)); *out_pix_fmt = config->pix_fmt; return true; @@ -131,7 +133,8 @@ HardwareContext::~HardwareContext() { av_buffer_unref(&m_gpu_decoder); } -bool HardwareContext::InitializeForDecoder(DecoderContext& decoder_context, const Decoder& decoder) { +bool HardwareContext::InitializeForDecoder(DecoderContext& decoder_context, + const Decoder& decoder) { const auto supported_types = GetSupportedDeviceTypes(); for (const auto type : PreferredGpuDecoders) { AVPixelFormat hw_pix_fmt; @@ -157,8 +160,10 @@ bool HardwareContext::InitializeForDecoder(DecoderContext& decoder_context, cons bool HardwareContext::InitializeWithType(AVHWDeviceType type) { av_buffer_unref(&m_gpu_decoder); - if (const int ret = av_hwdevice_ctx_create(&m_gpu_decoder, type, nullptr, nullptr, 0); ret < 0) { - LOG_DEBUG(HW_GPU, "av_hwdevice_ctx_create({}) failed: {}", av_hwdevice_get_type_name(type), AVError(ret)); + if (const int ret = av_hwdevice_ctx_create(&m_gpu_decoder, type, nullptr, nullptr, 0); + ret < 0) { + LOG_DEBUG(HW_GPU, "av_hwdevice_ctx_create({}) failed: {}", av_hwdevice_get_type_name(type), + AVError(ret)); return false; } @@ -195,7 +200,8 @@ DecoderContext::~DecoderContext() { avcodec_free_context(&m_codec_context); } -void DecoderContext::InitializeHardwareDecoder(const HardwareContext& context, AVPixelFormat hw_pix_fmt) { +void DecoderContext::InitializeHardwareDecoder(const HardwareContext& context, + AVPixelFormat hw_pix_fmt) { m_codec_context->hw_device_ctx = av_buffer_ref(context.GetBufferRef()); m_codec_context->get_format = GetGpuFormat; m_codec_context->pix_fmt = hw_pix_fmt; @@ -215,8 +221,9 @@ bool DecoderContext::OpenContext(const Decoder& decoder) { } bool DecoderContext::SendPacket(const Packet& packet) { - m_temp_frame = std::make_shared(); - if (const int ret = avcodec_send_packet(m_codec_context, packet.GetPacket()); ret < 0 && ret != AVERROR_EOF) { + m_temp_frame = std::make_shared(); + if (const int ret = avcodec_send_packet(m_codec_context, packet.GetPacket()); + ret < 0 && ret != AVERROR_EOF) { LOG_ERROR(HW_GPU, "avcodec_send_packet error: {}", AVError(ret)); return false; } @@ -224,31 +231,34 @@ bool DecoderContext::SendPacket(const Packet& packet) { } std::shared_ptr DecoderContext::ReceiveFrame() { - auto ReceiveImpl = [&](AVFrame* frame) -> bool { - if (const int ret = avcodec_receive_frame(m_codec_context, frame); ret < 0 && ret != AVERROR_EOF) { - LOG_ERROR(HW_GPU, "avcodec_receive_frame error: {}", AVError(ret)); - return false; - } - return true; - }; + auto ReceiveImpl = [&](AVFrame* frame) -> bool { + if (const int ret = avcodec_receive_frame(m_codec_context, frame); + ret < 0 && ret != AVERROR_EOF) { + LOG_ERROR(HW_GPU, "avcodec_receive_frame error: {}", AVError(ret)); + return false; + } + return true; + }; - std::shared_ptr intermediate_frame = std::make_shared(); - if (!ReceiveImpl(intermediate_frame->GetFrame())) { - return {}; - } + std::shared_ptr intermediate_frame = std::make_shared(); + if (!ReceiveImpl(intermediate_frame->GetFrame())) { + return {}; + } - const auto desc = av_pix_fmt_desc_get(intermediate_frame->GetPixelFormat()); - if (m_codec_context->hw_device_ctx && (desc && desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { - m_temp_frame->SetFormat(PreferredGpuFormat); - if (int ret = av_hwframe_transfer_data(m_temp_frame->GetFrame(), intermediate_frame->GetFrame(), 0); ret < 0) { - LOG_ERROR(HW_GPU, "av_hwframe_transfer_data error: {}", AVError(ret)); - return {}; - } - } else { - m_temp_frame = std::move(intermediate_frame); - } + const auto desc = av_pix_fmt_desc_get(intermediate_frame->GetPixelFormat()); + if (m_codec_context->hw_device_ctx && (desc && desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { + m_temp_frame->SetFormat(PreferredGpuFormat); + if (int ret = av_hwframe_transfer_data(m_temp_frame->GetFrame(), + intermediate_frame->GetFrame(), 0); + ret < 0) { + LOG_ERROR(HW_GPU, "av_hwframe_transfer_data error: {}", AVError(ret)); + return {}; + } + } else { + m_temp_frame = std::move(intermediate_frame); + } - return std::move(m_temp_frame); + return std::move(m_temp_frame); } void DecodeApi::Reset() { diff --git a/src/video_core/host1x/host1x.cpp b/src/video_core/host1x/host1x.cpp index 293bca6d79..7499ee77ec 100644 --- a/src/video_core/host1x/host1x.cpp +++ b/src/video_core/host1x/host1x.cpp @@ -9,8 +9,8 @@ namespace Tegra::Host1x { Host1x::Host1x(Core::System& system_) - : system{system_}, syncpoint_manager{}, - memory_manager(system.DeviceMemory()), gmmu_manager{system, memory_manager, 32, 0, 12}, + : system{system_}, syncpoint_manager{}, memory_manager(system.DeviceMemory()), + gmmu_manager{system, memory_manager, 32, 0, 12}, allocator{std::make_unique>(1 << 12)} {} Host1x::~Host1x() = default; diff --git a/src/video_core/host1x/vic.cpp b/src/video_core/host1x/vic.cpp index 3ad56bb80c..2d06580609 100644 --- a/src/video_core/host1x/vic.cpp +++ b/src/video_core/host1x/vic.cpp @@ -94,8 +94,8 @@ void SwizzleSurface(std::span output, u32 out_stride, std::span in } // namespace Vic::Vic(Host1x& host1x_, s32 id_, u32 syncpt, FrameQueue& frame_queue_) - : CDmaPusher{host1x_, id_}, id{id_}, syncpoint{syncpt}, - frame_queue{frame_queue_}, has_sse41{HasSSE41()} { + : CDmaPusher{host1x_, id_}, id{id_}, syncpoint{syncpt}, frame_queue{frame_queue_}, + has_sse41{HasSSE41()} { LOG_INFO(HW_GPU, "Created vic {}", id); } diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index ffafc48eff..aa60938119 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp @@ -28,8 +28,8 @@ MemoryManager::MemoryManager(Core::System& system_, MaxwellDeviceMemoryManager& split_address{split_address_}, page_bits{page_bits_}, big_page_bits{big_page_bits_}, entries{}, big_entries{}, page_table{address_space_bits, address_space_bits + page_bits - 38, page_bits != big_page_bits ? page_bits : 0}, - kind_map{PTEKind::INVALID}, unique_identifier{unique_identifier_generator.fetch_add( - 1, std::memory_order_acq_rel)}, + kind_map{PTEKind::INVALID}, + unique_identifier{unique_identifier_generator.fetch_add(1, std::memory_order_acq_rel)}, accumulator{std::make_unique()} { address_space_size = 1ULL << address_space_bits; page_size = 1ULL << page_bits; diff --git a/src/video_core/query_cache/query_stream.h b/src/video_core/query_cache/query_stream.h index 1d11b12752..2437b66d63 100644 --- a/src/video_core/query_cache/query_stream.h +++ b/src/video_core/query_cache/query_stream.h @@ -133,7 +133,6 @@ protected: } void ReleaseQuery(size_t query_id) { - if (query_id < slot_queries.size()) { old_queries.push_back(query_id); return; diff --git a/src/video_core/renderer_opengl/gl_compute_pipeline.cpp b/src/video_core/renderer_opengl/gl_compute_pipeline.cpp index d705018607..bb974bfd2b 100644 --- a/src/video_core/renderer_opengl/gl_compute_pipeline.cpp +++ b/src/video_core/renderer_opengl/gl_compute_pipeline.cpp @@ -31,8 +31,8 @@ ComputePipeline::ComputePipeline(const Device& device, TextureCache& texture_cac BufferCache& buffer_cache_, ProgramManager& program_manager_, const Shader::Info& info_, std::string code, std::vector code_v, bool force_context_flush) - : texture_cache{texture_cache_}, buffer_cache{buffer_cache_}, - program_manager{program_manager_}, info{info_} { + : texture_cache{texture_cache_}, buffer_cache{buffer_cache_}, program_manager{program_manager_}, + info{info_} { switch (device.GetShaderBackend()) { case Settings::ShaderBackend::Glsl: source_program = CreateProgram(code, GL_COMPUTE_SHADER); diff --git a/src/video_core/renderer_opengl/gl_query_cache.cpp b/src/video_core/renderer_opengl/gl_query_cache.cpp index 2147d587f7..ca00d7c3b7 100644 --- a/src/video_core/renderer_opengl/gl_query_cache.cpp +++ b/src/video_core/renderer_opengl/gl_query_cache.cpp @@ -66,9 +66,8 @@ bool QueryCache::AnyCommandQueued() const noexcept { HostCounter::HostCounter(QueryCache& cache_, std::shared_ptr dependency_, VideoCore::QueryType type_) - : HostCounterBase{std::move(dependency_)}, cache{cache_}, type{type_}, query{ - cache.AllocateQuery( - type)} { + : HostCounterBase{std::move(dependency_)}, cache{cache_}, type{type_}, + query{cache.AllocateQuery(type)} { glBeginQuery(GetTarget(type), query.handle); } diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index edf0bdd2f1..de923b3781 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp @@ -181,7 +181,8 @@ ShaderCache::ShaderCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, state_tracker{state_tracker_}, shader_notify{shader_notify_}, use_asynchronous_shaders{device.UseAsynchronousShaders()}, strict_context_required{device.StrictContextRequired()}, - optimize_spirv_output{Settings::values.optimize_spirv_output.GetValue() != Settings::SpirvOptimizeMode::Never}, + optimize_spirv_output{Settings::values.optimize_spirv_output.GetValue() != + Settings::SpirvOptimizeMode::Never}, profile{ .supported_spirv = 0x00010000, diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp index f2bf5a3228..cf10bb795c 100644 --- a/src/video_core/renderer_vulkan/blit_image.cpp +++ b/src/video_core/renderer_vulkan/blit_image.cpp @@ -7,13 +7,22 @@ #include "common/settings.h" #include "video_core/host_shaders/blit_color_float_frag_spv.h" +#include "video_core/host_shaders/convert_abgr8_srgb_to_d24s8_frag_spv.h" #include "video_core/host_shaders/convert_abgr8_to_d24s8_frag_spv.h" #include "video_core/host_shaders/convert_abgr8_to_d32f_frag_spv.h" +#include "video_core/host_shaders/convert_astc_hdr_to_rgba16f_comp_spv.h" +#include "video_core/host_shaders/convert_bc7_to_rgba8_comp_spv.h" #include "video_core/host_shaders/convert_d24s8_to_abgr8_frag_spv.h" #include "video_core/host_shaders/convert_d32f_to_abgr8_frag_spv.h" #include "video_core/host_shaders/convert_depth_to_float_frag_spv.h" #include "video_core/host_shaders/convert_float_to_depth_frag_spv.h" +#include "video_core/host_shaders/convert_rgb_to_yuv420_comp_spv.h" +#include "video_core/host_shaders/convert_rgba16f_to_rgba8_frag_spv.h" +#include "video_core/host_shaders/convert_rgba8_to_bgra8_frag_spv.h" #include "video_core/host_shaders/convert_s8d24_to_abgr8_frag_spv.h" +#include "video_core/host_shaders/convert_yuv420_to_rgb_comp_spv.h" +#include "video_core/host_shaders/dither_temporal_frag_spv.h" +#include "video_core/host_shaders/dynamic_resolution_scale_comp_spv.h" #include "video_core/host_shaders/full_screen_triangle_vert_spv.h" #include "video_core/host_shaders/vulkan_blit_depth_stencil_frag_spv.h" #include "video_core/host_shaders/vulkan_color_clear_frag_spv.h" @@ -28,15 +37,6 @@ #include "video_core/surface.h" #include "video_core/vulkan_common/vulkan_device.h" #include "video_core/vulkan_common/vulkan_wrapper.h" -#include "video_core/host_shaders/convert_abgr8_srgb_to_d24s8_frag_spv.h" -#include "video_core/host_shaders/convert_rgba8_to_bgra8_frag_spv.h" -#include "video_core/host_shaders/convert_yuv420_to_rgb_comp_spv.h" -#include "video_core/host_shaders/convert_rgb_to_yuv420_comp_spv.h" -#include "video_core/host_shaders/convert_bc7_to_rgba8_comp_spv.h" -#include "video_core/host_shaders/convert_astc_hdr_to_rgba16f_comp_spv.h" -#include "video_core/host_shaders/convert_rgba16f_to_rgba8_frag_spv.h" -#include "video_core/host_shaders/dither_temporal_frag_spv.h" -#include "video_core/host_shaders/dynamic_resolution_scale_comp_spv.h" namespace Vulkan { @@ -190,24 +190,26 @@ constexpr VkPipelineDepthStencilStateCreateInfo PIPELINE_DEPTH_STENCIL_STATE_CRE .depthCompareOp = VK_COMPARE_OP_ALWAYS, .depthBoundsTestEnable = VK_FALSE, .stencilTestEnable = VK_TRUE, - .front = VkStencilOpState{ - .failOp = VK_STENCIL_OP_REPLACE, - .passOp = VK_STENCIL_OP_REPLACE, - .depthFailOp = VK_STENCIL_OP_KEEP, - .compareOp = VK_COMPARE_OP_ALWAYS, - .compareMask = 0x0, - .writeMask = 0xFFFFFFFF, - .reference = 0x00, - }, - .back = VkStencilOpState{ - .failOp = VK_STENCIL_OP_REPLACE, - .passOp = VK_STENCIL_OP_REPLACE, - .depthFailOp = VK_STENCIL_OP_KEEP, - .compareOp = VK_COMPARE_OP_ALWAYS, - .compareMask = 0x0, - .writeMask = 0xFFFFFFFF, - .reference = 0x00, - }, + .front = + VkStencilOpState{ + .failOp = VK_STENCIL_OP_REPLACE, + .passOp = VK_STENCIL_OP_REPLACE, + .depthFailOp = VK_STENCIL_OP_KEEP, + .compareOp = VK_COMPARE_OP_ALWAYS, + .compareMask = 0x0, + .writeMask = 0xFFFFFFFF, + .reference = 0x00, + }, + .back = + VkStencilOpState{ + .failOp = VK_STENCIL_OP_REPLACE, + .passOp = VK_STENCIL_OP_REPLACE, + .depthFailOp = VK_STENCIL_OP_KEEP, + .compareOp = VK_COMPARE_OP_ALWAYS, + .compareMask = 0x0, + .writeMask = 0xFFFFFFFF, + .reference = 0x00, + }, .minDepthBounds = 0.0f, .maxDepthBounds = 0.0f, }; @@ -624,10 +626,9 @@ void BlitImageHelper::ConvertS8D24ToABGR8(const Framebuffer* dst_framebuffer, } void BlitImageHelper::ConvertABGR8SRGBToD24S8(const Framebuffer* dst_framebuffer, - const ImageView& src_image_view) { + const ImageView& src_image_view) { ConvertPipelineDepthTargetEx(convert_abgr8_srgb_to_d24s8_pipeline, - dst_framebuffer->RenderPass(), - convert_abgr8_srgb_to_d24s8_frag); + dst_framebuffer->RenderPass(), convert_abgr8_srgb_to_d24s8_frag); Convert(*convert_abgr8_srgb_to_d24s8_pipeline, dst_framebuffer, src_image_view); } @@ -1060,7 +1061,7 @@ void BlitImageHelper::ConvertPipelineDepthTargetEx(vk::Pipeline& pipeline, VkRen } void BlitImageHelper::ConvertPipeline(vk::Pipeline& pipeline, VkRenderPass renderpass, - bool is_target_depth) { + bool is_target_depth) { if (pipeline) { return; } @@ -1081,7 +1082,7 @@ void BlitImageHelper::ConvertPipeline(vk::Pipeline& pipeline, VkRenderPass rende .pMultisampleState = &PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, .pDepthStencilState = is_target_depth ? &PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO : nullptr, .pColorBlendState = is_target_depth ? &PIPELINE_COLOR_BLEND_STATE_EMPTY_CREATE_INFO - : &PIPELINE_COLOR_BLEND_STATE_GENERIC_CREATE_INFO, + : &PIPELINE_COLOR_BLEND_STATE_GENERIC_CREATE_INFO, .pDynamicState = &PIPELINE_DYNAMIC_STATE_CREATE_INFO, .layout = *one_texture_pipeline_layout, .renderPass = renderpass, @@ -1092,66 +1093,50 @@ void BlitImageHelper::ConvertPipeline(vk::Pipeline& pipeline, VkRenderPass rende } void BlitImageHelper::ConvertRGBAtoGBRA(const Framebuffer* dst_framebuffer, - const ImageView& src_image_view) { - ConvertPipeline(convert_rgba_to_bgra_pipeline, - dst_framebuffer->RenderPass(), - false); + const ImageView& src_image_view) { + ConvertPipeline(convert_rgba_to_bgra_pipeline, dst_framebuffer->RenderPass(), false); Convert(*convert_rgba_to_bgra_pipeline, dst_framebuffer, src_image_view); } void BlitImageHelper::ConvertYUV420toRGB(const Framebuffer* dst_framebuffer, - const ImageView& src_image_view) { - ConvertPipeline(convert_yuv420_to_rgb_pipeline, - dst_framebuffer->RenderPass(), - false); + const ImageView& src_image_view) { + ConvertPipeline(convert_yuv420_to_rgb_pipeline, dst_framebuffer->RenderPass(), false); Convert(*convert_yuv420_to_rgb_pipeline, dst_framebuffer, src_image_view); } void BlitImageHelper::ConvertRGBtoYUV420(const Framebuffer* dst_framebuffer, - const ImageView& src_image_view) { - ConvertPipeline(convert_rgb_to_yuv420_pipeline, - dst_framebuffer->RenderPass(), - false); + const ImageView& src_image_view) { + ConvertPipeline(convert_rgb_to_yuv420_pipeline, dst_framebuffer->RenderPass(), false); Convert(*convert_rgb_to_yuv420_pipeline, dst_framebuffer, src_image_view); } void BlitImageHelper::ConvertBC7toRGBA8(const Framebuffer* dst_framebuffer, - const ImageView& src_image_view) { - ConvertPipeline(convert_bc7_to_rgba8_pipeline, - dst_framebuffer->RenderPass(), - false); + const ImageView& src_image_view) { + ConvertPipeline(convert_bc7_to_rgba8_pipeline, dst_framebuffer->RenderPass(), false); Convert(*convert_bc7_to_rgba8_pipeline, dst_framebuffer, src_image_view); } void BlitImageHelper::ConvertASTCHDRtoRGBA16F(const Framebuffer* dst_framebuffer, - const ImageView& src_image_view) { - ConvertPipeline(convert_astc_hdr_to_rgba16f_pipeline, - dst_framebuffer->RenderPass(), - false); + const ImageView& src_image_view) { + ConvertPipeline(convert_astc_hdr_to_rgba16f_pipeline, dst_framebuffer->RenderPass(), false); Convert(*convert_astc_hdr_to_rgba16f_pipeline, dst_framebuffer, src_image_view); } void BlitImageHelper::ConvertRGBA16FtoRGBA8(const Framebuffer* dst_framebuffer, - const ImageView& src_image_view) { - ConvertPipeline(convert_rgba16f_to_rgba8_pipeline, - dst_framebuffer->RenderPass(), - false); + const ImageView& src_image_view) { + ConvertPipeline(convert_rgba16f_to_rgba8_pipeline, dst_framebuffer->RenderPass(), false); Convert(*convert_rgba16f_to_rgba8_pipeline, dst_framebuffer, src_image_view); } void BlitImageHelper::ApplyDitherTemporal(const Framebuffer* dst_framebuffer, - const ImageView& src_image_view) { - ConvertPipeline(dither_temporal_pipeline, - dst_framebuffer->RenderPass(), - false); + const ImageView& src_image_view) { + ConvertPipeline(dither_temporal_pipeline, dst_framebuffer->RenderPass(), false); Convert(*dither_temporal_pipeline, dst_framebuffer, src_image_view); } void BlitImageHelper::ApplyDynamicResolutionScale(const Framebuffer* dst_framebuffer, - const ImageView& src_image_view) { - ConvertPipeline(dynamic_resolution_scale_pipeline, - dst_framebuffer->RenderPass(), - false); + const ImageView& src_image_view) { + ConvertPipeline(dynamic_resolution_scale_pipeline, dst_framebuffer->RenderPass(), false); Convert(*dynamic_resolution_scale_pipeline, dst_framebuffer, src_image_view); } diff --git a/src/video_core/renderer_vulkan/blit_image.h b/src/video_core/renderer_vulkan/blit_image.h index 3d400be6a9..de3d53e00b 100644 --- a/src/video_core/renderer_vulkan/blit_image.h +++ b/src/video_core/renderer_vulkan/blit_image.h @@ -67,7 +67,8 @@ public: void ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); - void ConvertABGR8SRGBToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); + void ConvertABGR8SRGBToD24S8(const Framebuffer* dst_framebuffer, + const ImageView& src_image_view); void ConvertABGR8ToD32F(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); @@ -88,10 +89,12 @@ public: void ConvertYUV420toRGB(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); void ConvertRGBtoYUV420(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); void ConvertBC7toRGBA8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); - void ConvertASTCHDRtoRGBA16F(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); + void ConvertASTCHDRtoRGBA16F(const Framebuffer* dst_framebuffer, + const ImageView& src_image_view); void ConvertRGBA16FtoRGBA8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); void ApplyDitherTemporal(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); - void ApplyDynamicResolutionScale(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); + void ApplyDynamicResolutionScale(const Framebuffer* dst_framebuffer, + const ImageView& src_image_view); private: void Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer, diff --git a/src/video_core/renderer_vulkan/present/fsr.cpp b/src/video_core/renderer_vulkan/present/fsr.cpp index 3f708be704..55606deb83 100644 --- a/src/video_core/renderer_vulkan/present/fsr.cpp +++ b/src/video_core/renderer_vulkan/present/fsr.cpp @@ -24,8 +24,8 @@ using PushConstants = std::array; FSR::FSR(const Device& device, MemoryAllocator& memory_allocator, size_t image_count, VkExtent2D extent) - : m_device{device}, m_memory_allocator{memory_allocator}, - m_image_count{image_count}, m_extent{extent} { + : m_device{device}, m_memory_allocator{memory_allocator}, m_image_count{image_count}, + m_extent{extent} { CreateImages(); CreateRenderPasses(); diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index a91fba6725..4c8c3aa34f 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -102,73 +102,46 @@ Device CreateDevice(const vk::Instance& instance, const vk::InstanceDispatch& dl } RendererVulkan::RendererVulkan(Core::Frontend::EmuWindow& emu_window, - Tegra::MaxwellDeviceMemoryManager& device_memory_, - Tegra::GPU& gpu_, - std::unique_ptr context_) -try - : RendererBase(emu_window, std::move(context_)) - , device_memory(device_memory_) - , gpu(gpu_) - , library(OpenLibrary(context.get())) - , dld() - // Create raw Vulkan instance first - , instance(CreateInstance(*library, - dld, - VK_API_VERSION_1_1, - render_window.GetWindowInfo().type, - Settings::values.renderer_debug.GetValue())) - // Create debug messenger if debug is enabled - , debug_messenger(Settings::values.renderer_debug ? CreateDebugUtilsCallback(instance) - : vk::DebugUtilsMessenger{}) - // Create surface - , surface(CreateSurface(instance, render_window.GetWindowInfo())) - , device(CreateDevice(instance, dld, *surface)) - , memory_allocator(device) - , state_tracker() - , scheduler(device, state_tracker) - , swapchain(*surface, - device, - scheduler, - render_window.GetFramebufferLayout().width, - render_window.GetFramebufferLayout().height) - , present_manager(instance, - render_window, - device, - memory_allocator, - scheduler, - swapchain, + Tegra::MaxwellDeviceMemoryManager& device_memory_, Tegra::GPU& gpu_, + std::unique_ptr context_) try + : RendererBase(emu_window, std::move(context_)), device_memory(device_memory_), gpu(gpu_), + library(OpenLibrary(context.get())), dld() + // Create raw Vulkan instance first + , + instance(CreateInstance(*library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type, + Settings::values.renderer_debug.GetValue())) + // Create debug messenger if debug is enabled + , + debug_messenger(Settings::values.renderer_debug ? CreateDebugUtilsCallback(instance) + : vk::DebugUtilsMessenger{}) + // Create surface + , + surface(CreateSurface(instance, render_window.GetWindowInfo())), + device(CreateDevice(instance, dld, *surface)), memory_allocator(device), state_tracker(), + scheduler(device, state_tracker), + swapchain(*surface, device, scheduler, render_window.GetFramebufferLayout().width, + render_window.GetFramebufferLayout().height), + present_manager(instance, render_window, device, memory_allocator, scheduler, swapchain, #ifdef ANDROID - surface) - , + surface), #else - *surface) - , + *surface), #endif - blit_swapchain(device_memory, - device, - memory_allocator, - present_manager, - scheduler, - PresentFiltersForDisplay) - , blit_capture(device_memory, - device, - memory_allocator, - present_manager, - scheduler, - PresentFiltersForDisplay) - , blit_applet(device_memory, - device, - memory_allocator, - present_manager, - scheduler, - PresentFiltersForAppletCapture) - , rasterizer(render_window, gpu, device_memory, device, memory_allocator, state_tracker, scheduler) { + blit_swapchain(device_memory, device, memory_allocator, present_manager, scheduler, + PresentFiltersForDisplay), + blit_capture(device_memory, device, memory_allocator, present_manager, scheduler, + PresentFiltersForDisplay), + blit_applet(device_memory, device, memory_allocator, present_manager, scheduler, + PresentFiltersForAppletCapture), + rasterizer(render_window, gpu, device_memory, device, memory_allocator, state_tracker, + scheduler) { // Initialize RAII wrappers after creating the main objects if (Settings::values.enable_raii.GetValue()) { managed_instance = MakeManagedInstance(instance, dld); if (Settings::values.renderer_debug) { - managed_debug_messenger = MakeManagedDebugUtilsMessenger(debug_messenger, instance, dld); + managed_debug_messenger = + MakeManagedDebugUtilsMessenger(debug_messenger, instance, dld); } managed_surface = MakeManagedSurface(surface, instance, dld); } @@ -191,124 +164,118 @@ RendererVulkan::~RendererVulkan() { #ifdef __ANDROID__ class BooleanSetting { - public: -// static BooleanSetting FRAME_SKIPPING; - static BooleanSetting FRAME_INTERPOLATION; - explicit BooleanSetting(bool initial_value = false) : value(initial_value) {} +public: + // static BooleanSetting FRAME_SKIPPING; + static BooleanSetting FRAME_INTERPOLATION; + explicit BooleanSetting(bool initial_value = false) : value(initial_value) {} - [[nodiscard]] bool getBoolean() const { - return value; - } + [[nodiscard]] bool getBoolean() const { + return value; + } - void setBoolean(bool new_value) { - value = new_value; - } + void setBoolean(bool new_value) { + value = new_value; + } - private: - bool value; - }; +private: + bool value; +}; - // Initialize static members +// Initialize static members // BooleanSetting BooleanSetting::FRAME_SKIPPING(false); - BooleanSetting BooleanSetting::FRAME_INTERPOLATION(false); +BooleanSetting BooleanSetting::FRAME_INTERPOLATION(false); // extern "C" JNIEXPORT jboolean JNICALL -// Java_org_yuzu_yuzu_1emu_features_settings_model_BooleanSetting_isFrameSkippingEnabled(JNIEnv* env, jobject /* this */) { +// Java_org_yuzu_yuzu_1emu_features_settings_model_BooleanSetting_isFrameSkippingEnabled(JNIEnv* +// env, jobject /* this */) { // return static_cast(BooleanSetting::FRAME_SKIPPING.getBoolean()); // } - extern "C" JNIEXPORT jboolean JNICALL - Java_org_yuzu_yuzu_1emu_features_settings_model_BooleanSetting_isFrameInterpolationEnabled(JNIEnv* env, jobject /* this */) { - return static_cast(BooleanSetting::FRAME_INTERPOLATION.getBoolean()); +extern "C" JNIEXPORT jboolean JNICALL +Java_org_yuzu_yuzu_1emu_features_settings_model_BooleanSetting_isFrameInterpolationEnabled( + JNIEnv* env, jobject /* this */) { + return static_cast(BooleanSetting::FRAME_INTERPOLATION.getBoolean()); +} + +void RendererVulkan::InterpolateFrames(Frame* prev_frame, Frame* interpolated_frame) { + if (!prev_frame || !interpolated_frame || !prev_frame->image || !interpolated_frame->image) { + return; } - void RendererVulkan::InterpolateFrames(Frame* prev_frame, Frame* interpolated_frame) { - if (!prev_frame || !interpolated_frame || !prev_frame->image || !interpolated_frame->image) { - return; - } + const auto& framebuffer_layout = render_window.GetFramebufferLayout(); + // Fixed aggressive downscale (50%) + VkExtent2D dst_extent{.width = framebuffer_layout.width / 2, + .height = framebuffer_layout.height / 2}; - const auto& framebuffer_layout = render_window.GetFramebufferLayout(); - // Fixed aggressive downscale (50%) - VkExtent2D dst_extent{ - .width = framebuffer_layout.width / 2, - .height = framebuffer_layout.height / 2 - }; - - // Check if we need to recreate the destination frame - bool needs_recreation = false; // Only recreate when necessary - if (!interpolated_frame->image_view) { - needs_recreation = true; // Need to create initially + // Check if we need to recreate the destination frame + bool needs_recreation = false; // Only recreate when necessary + if (!interpolated_frame->image_view) { + needs_recreation = true; // Need to create initially + } else { + // Check if dimensions have changed + if (interpolated_frame->framebuffer) { + needs_recreation = (framebuffer_layout.width / 2 != dst_extent.width) || + (framebuffer_layout.height / 2 != dst_extent.height); } else { - // Check if dimensions have changed - if (interpolated_frame->framebuffer) { - needs_recreation = (framebuffer_layout.width / 2 != dst_extent.width) || - (framebuffer_layout.height / 2 != dst_extent.height); - } else { - needs_recreation = true; - } + needs_recreation = true; } - - if (needs_recreation) { - interpolated_frame->image = CreateWrappedImage(memory_allocator, dst_extent, swapchain.GetImageViewFormat()); - interpolated_frame->image_view = CreateWrappedImageView(device, interpolated_frame->image, swapchain.GetImageViewFormat()); - interpolated_frame->framebuffer = blit_swapchain.CreateFramebuffer( - Layout::FramebufferLayout{dst_extent.width, dst_extent.height}, - *interpolated_frame->image_view, - swapchain.GetImageViewFormat()); - } - - scheduler.RequestOutsideRenderPassOperationContext(); - scheduler.Record([&](vk::CommandBuffer cmdbuf) { - // Transition images to transfer layouts - TransitionImageLayout(cmdbuf, *prev_frame->image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); - TransitionImageLayout(cmdbuf, *interpolated_frame->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); - - // Perform the downscale blit - VkImageBlit blit_region{}; - blit_region.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; - blit_region.srcOffsets[0] = {0, 0, 0}; - blit_region.srcOffsets[1] = { - static_cast(framebuffer_layout.width), - static_cast(framebuffer_layout.height), - 1 - }; - blit_region.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; - blit_region.dstOffsets[0] = {0, 0, 0}; - blit_region.dstOffsets[1] = { - static_cast(dst_extent.width), - static_cast(dst_extent.height), - 1 - }; - - // Using the wrapper's BlitImage with proper parameters - cmdbuf.BlitImage( - *prev_frame->image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - *interpolated_frame->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - blit_region, VK_FILTER_NEAREST - ); - - // Transition back to general layout - TransitionImageLayout(cmdbuf, *prev_frame->image, VK_IMAGE_LAYOUT_GENERAL); - TransitionImageLayout(cmdbuf, *interpolated_frame->image, VK_IMAGE_LAYOUT_GENERAL); - }); } + + if (needs_recreation) { + interpolated_frame->image = + CreateWrappedImage(memory_allocator, dst_extent, swapchain.GetImageViewFormat()); + interpolated_frame->image_view = CreateWrappedImageView(device, interpolated_frame->image, + swapchain.GetImageViewFormat()); + interpolated_frame->framebuffer = blit_swapchain.CreateFramebuffer( + Layout::FramebufferLayout{dst_extent.width, dst_extent.height}, + *interpolated_frame->image_view, swapchain.GetImageViewFormat()); + } + + scheduler.RequestOutsideRenderPassOperationContext(); + scheduler.Record([&](vk::CommandBuffer cmdbuf) { + // Transition images to transfer layouts + TransitionImageLayout(cmdbuf, *prev_frame->image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); + TransitionImageLayout(cmdbuf, *interpolated_frame->image, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); + + // Perform the downscale blit + VkImageBlit blit_region{}; + blit_region.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; + blit_region.srcOffsets[0] = {0, 0, 0}; + blit_region.srcOffsets[1] = {static_cast(framebuffer_layout.width), + static_cast(framebuffer_layout.height), 1}; + blit_region.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; + blit_region.dstOffsets[0] = {0, 0, 0}; + blit_region.dstOffsets[1] = {static_cast(dst_extent.width), + static_cast(dst_extent.height), 1}; + + // Using the wrapper's BlitImage with proper parameters + cmdbuf.BlitImage(*prev_frame->image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + *interpolated_frame->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + blit_region, VK_FILTER_NEAREST); + + // Transition back to general layout + TransitionImageLayout(cmdbuf, *prev_frame->image, VK_IMAGE_LAYOUT_GENERAL); + TransitionImageLayout(cmdbuf, *interpolated_frame->image, VK_IMAGE_LAYOUT_GENERAL); + }); +} #endif void RendererVulkan::Composite(std::span framebuffers) { - #ifdef __ANDROID__ +#ifdef __ANDROID__ static int frame_counter = 0; static int target_fps = 60; // Target FPS (30 or 60) int frame_skip_threshold = 1; - bool frame_skipping = false; //BooleanSetting::FRAME_SKIPPING.getBoolean(); + bool frame_skipping = false; // BooleanSetting::FRAME_SKIPPING.getBoolean(); bool frame_interpolation = BooleanSetting::FRAME_INTERPOLATION.getBoolean(); - #endif +#endif if (framebuffers.empty()) { return; } - #ifdef __ANDROID__ +#ifdef __ANDROID__ if (frame_skipping) { frame_skip_threshold = (target_fps == 30) ? 2 : 2; } @@ -319,14 +286,14 @@ void RendererVulkan::Composite(std::span framebu Frame* interpolated_frame = present_manager.GetRenderFrame(); InterpolateFrames(previous_frame, interpolated_frame); blit_swapchain.DrawToFrame(rasterizer, interpolated_frame, framebuffers, - render_window.GetFramebufferLayout(), swapchain.GetImageCount(), - swapchain.GetImageViewFormat()); + render_window.GetFramebufferLayout(), + swapchain.GetImageCount(), swapchain.GetImageViewFormat()); scheduler.Flush(*interpolated_frame->render_ready); present_manager.Present(interpolated_frame); } return; } - #endif +#endif SCOPE_EXIT { render_window.OnFrameDisplayed(); diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.h b/src/video_core/renderer_vulkan/renderer_vulkan.h index c1e6d5db7f..c2e1700417 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.h +++ b/src/video_core/renderer_vulkan/renderer_vulkan.h @@ -19,8 +19,8 @@ #include "video_core/renderer_vulkan/vk_turbo_mode.h" #include "video_core/vulkan_common/vulkan_device.h" #include "video_core/vulkan_common/vulkan_memory_allocator.h" -#include "video_core/vulkan_common/vulkan_wrapper.h" #include "video_core/vulkan_common/vulkan_raii.h" +#include "video_core/vulkan_common/vulkan_wrapper.h" namespace Core::Memory { class Memory; @@ -59,7 +59,7 @@ public: private: void InterpolateFrames(Frame* prev_frame, Frame* curr_frame); - Frame* previous_frame = nullptr; // Store the previous frame for interpolation + Frame* previous_frame = nullptr; // Store the previous frame for interpolation VkCommandBuffer BeginSingleTimeCommands(); void EndSingleTimeCommands(VkCommandBuffer command_buffer); void Report() const; diff --git a/src/video_core/renderer_vulkan/vk_compute_pass.cpp b/src/video_core/renderer_vulkan/vk_compute_pass.cpp index 617f92910c..6455e5eb75 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pass.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pass.cpp @@ -531,8 +531,8 @@ ASTCDecoderPass::ASTCDecoderPass(const Device& device_, Scheduler& scheduler_, ASTC_PASS_DESCRIPTOR_UPDATE_TEMPLATE_ENTRY, ASTC_BANK_INFO, COMPUTE_PUSH_CONSTANT_RANGE, ASTC_DECODER_COMP_SPV), scheduler{scheduler_}, staging_buffer_pool{staging_buffer_pool_}, - compute_pass_descriptor_queue{compute_pass_descriptor_queue_}, memory_allocator{ - memory_allocator_} {} + compute_pass_descriptor_queue{compute_pass_descriptor_queue_}, + memory_allocator{memory_allocator_} {} ASTCDecoderPass::~ASTCDecoderPass() = default; diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp index 73e585c2b7..689c7d760c 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp @@ -31,8 +31,8 @@ ComputePipeline::ComputePipeline(const Device& device_, vk::PipelineCache& pipel PipelineStatistics* pipeline_statistics, VideoCore::ShaderNotify* shader_notify, const Shader::Info& info_, vk::ShaderModule spv_module_) - : device{device_}, - pipeline_cache(pipeline_cache_), guest_descriptor_queue{guest_descriptor_queue_}, info{info_}, + : device{device_}, pipeline_cache(pipeline_cache_), + guest_descriptor_queue{guest_descriptor_queue_}, info{info_}, spv_module(std::move(spv_module_)) { if (shader_notify) { shader_notify->MarkShaderBuilding(); diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index eb757d68f5..5898e759c8 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -355,11 +355,7 @@ bool GraphicsPipeline::ConfigureImpl(bool is_indexed) { const auto add_image{[&](const auto& desc, bool blacklist) LAMBDA_FORCEINLINE { for (u32 index = 0; index < desc.count; ++index) { const auto handle{read_handle(desc, index)}; - views[view_index++] = { - .index = handle.first, - .blacklist = blacklist, - .id = {} - }; + views[view_index++] = {.index = handle.first, .blacklist = blacklist, .id = {}}; } }}; if constexpr (Spec::has_texture_buffers) { @@ -638,14 +634,14 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { .flags = 0, .topology = input_assembly_topology, .primitiveRestartEnable = - dynamic.primitive_restart_enable != 0 && - ((input_assembly_topology != VK_PRIMITIVE_TOPOLOGY_PATCH_LIST && - device.IsTopologyListPrimitiveRestartSupported()) || - SupportsPrimitiveRestart(input_assembly_topology) || - (input_assembly_topology == VK_PRIMITIVE_TOPOLOGY_PATCH_LIST && - device.IsPatchListPrimitiveRestartSupported())) - ? VK_TRUE - : VK_FALSE, + dynamic.primitive_restart_enable != 0 && + ((input_assembly_topology != VK_PRIMITIVE_TOPOLOGY_PATCH_LIST && + device.IsTopologyListPrimitiveRestartSupported()) || + SupportsPrimitiveRestart(input_assembly_topology) || + (input_assembly_topology == VK_PRIMITIVE_TOPOLOGY_PATCH_LIST && + device.IsPatchListPrimitiveRestartSupported())) + ? VK_TRUE + : VK_FALSE, }; const VkPipelineTessellationStateCreateInfo tessellation_ci{ .sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, @@ -688,11 +684,11 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { .pNext = nullptr, .flags = 0, .depthClampEnable = - static_cast(dynamic.depth_clamp_disabled == 0 ? VK_TRUE : VK_FALSE), + static_cast(dynamic.depth_clamp_disabled == 0 ? VK_TRUE : VK_FALSE), .rasterizerDiscardEnable = - static_cast(dynamic.rasterize_enable == 0 ? VK_TRUE : VK_FALSE), + static_cast(dynamic.rasterize_enable == 0 ? VK_TRUE : VK_FALSE), .polygonMode = - MaxwellToVK::PolygonMode(FixedPipelineState::UnpackPolygonMode(key.state.polygon_mode)), + MaxwellToVK::PolygonMode(FixedPipelineState::UnpackPolygonMode(key.state.polygon_mode)), .cullMode = static_cast( dynamic.cull_enable ? MaxwellToVK::CullFace(dynamic.CullFace()) : VK_CULL_MODE_NONE), .frontFace = MaxwellToVK::FrontFace(dynamic.FrontFace()), @@ -803,8 +799,7 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { .logicOp = static_cast(dynamic.logic_op.Value()), .attachmentCount = static_cast(cb_attachments.size()), .pAttachments = cb_attachments.data(), - .blendConstants = {} - }; + .blendConstants = {}}; static_vector dynamic_states{ VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR, VK_DYNAMIC_STATE_DEPTH_BIAS, VK_DYNAMIC_STATE_BLEND_CONSTANTS, @@ -816,7 +811,8 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { static constexpr std::array extended{ VK_DYNAMIC_STATE_CULL_MODE_EXT, VK_DYNAMIC_STATE_FRONT_FACE_EXT, - //VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT, //Disabled for VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME + // VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT, + // Disabled for VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT, VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT, VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT, @@ -841,8 +837,7 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { } if (key.state.extended_dynamic_state_3_blend) { static constexpr std::array extended3{ - VK_DYNAMIC_STATE_COLOR_BLEND_ENABLE_EXT, - VK_DYNAMIC_STATE_COLOR_BLEND_EQUATION_EXT, + VK_DYNAMIC_STATE_COLOR_BLEND_ENABLE_EXT, VK_DYNAMIC_STATE_COLOR_BLEND_EQUATION_EXT, VK_DYNAMIC_STATE_COLOR_WRITE_MASK_EXT, // VK_DYNAMIC_STATE_COLOR_BLEND_ADVANCED_EXT, diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h index 7e9dbb583a..ae35381b86 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h @@ -108,7 +108,9 @@ public: template static auto MakeConfigureSpecFunc() { - return [](GraphicsPipeline* pl, bool is_indexed) { return pl->ConfigureImpl(is_indexed); }; + return [](GraphicsPipeline* pl, bool is_indexed) { + return pl->ConfigureImpl(is_indexed); + }; } void SetEngine(Tegra::Engines::Maxwell3D* maxwell3d_, Tegra::MemoryManager* gpu_memory_) { diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 66835fc1c7..587db143b0 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -314,7 +314,8 @@ PipelineCache::PipelineCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, texture_cache{texture_cache_}, shader_notify{shader_notify_}, use_asynchronous_shaders{Settings::values.use_asynchronous_shaders.GetValue()}, use_vulkan_pipeline_cache{Settings::values.use_vulkan_driver_pipeline_cache.GetValue()}, - optimize_spirv_output{Settings::values.optimize_spirv_output.GetValue() != Settings::SpirvOptimizeMode::Never}, + optimize_spirv_output{Settings::values.optimize_spirv_output.GetValue() != + Settings::SpirvOptimizeMode::Never}, workers(device.HasBrokenParallelShaderCompiling() ? 1ULL : GetTotalPipelineWorkers(), "VkPipelineBuilder"), serialization_thread(1, "VkPipelineSerialization") { @@ -408,25 +409,26 @@ PipelineCache::PipelineCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, const u8 dynamic_state = Settings::values.dyna_state.GetValue(); - LOG_INFO(Render_Vulkan, "DynamicState value is set to {}", (u32) dynamic_state); + LOG_INFO(Render_Vulkan, "DynamicState value is set to {}", (u32)dynamic_state); dynamic_features = DynamicFeatures{ - .has_extended_dynamic_state = device.IsExtExtendedDynamicStateSupported() - && dynamic_state > 0, - .has_extended_dynamic_state_2 = device.IsExtExtendedDynamicState2Supported() - && dynamic_state > 1, - .has_extended_dynamic_state_2_extra = device.IsExtExtendedDynamicState2ExtrasSupported() - && dynamic_state > 1, - .has_extended_dynamic_state_3_blend = device.IsExtExtendedDynamicState3BlendingSupported() - && dynamic_state > 2, - .has_extended_dynamic_state_3_enables = device.IsExtExtendedDynamicState3EnablesSupported() - && dynamic_state > 2, + .has_extended_dynamic_state = + device.IsExtExtendedDynamicStateSupported() && dynamic_state > 0, + .has_extended_dynamic_state_2 = + device.IsExtExtendedDynamicState2Supported() && dynamic_state > 1, + .has_extended_dynamic_state_2_extra = + device.IsExtExtendedDynamicState2ExtrasSupported() && dynamic_state > 1, + .has_extended_dynamic_state_3_blend = + device.IsExtExtendedDynamicState3BlendingSupported() && dynamic_state > 2, + .has_extended_dynamic_state_3_enables = + device.IsExtExtendedDynamicState3EnablesSupported() && dynamic_state > 2, .has_dynamic_vertex_input = device.IsExtVertexInputDynamicStateSupported(), }; LOG_INFO(Render_Vulkan, "DynamicState1: {}", dynamic_features.has_extended_dynamic_state); LOG_INFO(Render_Vulkan, "DynamicState2: {}", dynamic_features.has_extended_dynamic_state_2); - LOG_INFO(Render_Vulkan, "DynamicState3: {}", dynamic_features.has_extended_dynamic_state_3_enables); + LOG_INFO(Render_Vulkan, "DynamicState3: {}", + dynamic_features.has_extended_dynamic_state_3_enables); LOG_INFO(Render_Vulkan, "DynamicVertexInput: {}", dynamic_features.has_dynamic_vertex_input); } @@ -696,7 +698,8 @@ std::unique_ptr PipelineCache::CreateGraphicsPipeline( const auto runtime_info{MakeRuntimeInfo(programs, key, program, previous_stage)}; ConvertLegacyToGeneric(program, runtime_info); - const std::vector code{EmitSPIRV(profile, runtime_info, program, binding, this->optimize_spirv_output)}; + const std::vector code{ + EmitSPIRV(profile, runtime_info, program, binding, this->optimize_spirv_output)}; device.SaveShader(code); modules[stage_index] = BuildShader(device, code); if (device.HasDebuggingToolAttached()) { diff --git a/src/video_core/renderer_vulkan/vk_present_manager.cpp b/src/video_core/renderer_vulkan/vk_present_manager.cpp index a448dc5288..3cd875d248 100644 --- a/src/video_core/renderer_vulkan/vk_present_manager.cpp +++ b/src/video_core/renderer_vulkan/vk_present_manager.cpp @@ -96,30 +96,26 @@ bool CanBlitToSwapchain(const vk::PhysicalDevice& physical_device, VkFormat form } // Anonymous namespace PresentManager::PresentManager(const vk::Instance& instance_, - Core::Frontend::EmuWindow& render_window_, - const Device& device_, - MemoryAllocator& memory_allocator_, - Scheduler& scheduler_, + Core::Frontend::EmuWindow& render_window_, const Device& device_, + MemoryAllocator& memory_allocator_, Scheduler& scheduler_, Swapchain& swapchain_, #ifdef ANDROID vk::SurfaceKHR& surface_) #else VkSurfaceKHR_T* surface_handle_) #endif - : instance{instance_} - , render_window{render_window_} - , device{device_} - , memory_allocator{memory_allocator_} - , scheduler{scheduler_} - , swapchain{swapchain_} + : instance{instance_}, render_window{render_window_}, device{device_}, + memory_allocator{memory_allocator_}, scheduler{scheduler_}, swapchain{swapchain_} #ifdef ANDROID - , surface{surface_} + , + surface{surface_} #else - , surface_handle{surface_handle_} + , + surface_handle{surface_handle_} #endif - , blit_supported{CanBlitToSwapchain(device.GetPhysical(), swapchain.GetImageViewFormat())} - , use_present_thread{Settings::values.async_presentation.GetValue()} -{ + , + blit_supported{CanBlitToSwapchain(device.GetPhysical(), swapchain.GetImageViewFormat())}, + use_present_thread{Settings::values.async_presentation.GetValue()} { SetImageCount(); auto& dld = device.GetLogical(); diff --git a/src/video_core/renderer_vulkan/vk_present_manager.h b/src/video_core/renderer_vulkan/vk_present_manager.h index 5820280602..b62c38cf38 100644 --- a/src/video_core/renderer_vulkan/vk_present_manager.h +++ b/src/video_core/renderer_vulkan/vk_present_manager.h @@ -37,11 +37,8 @@ struct Frame { class PresentManager { public: - PresentManager(const vk::Instance& instance, - Core::Frontend::EmuWindow& render_window, - const Device& device, - MemoryAllocator& memory_allocator, - Scheduler& scheduler, + PresentManager(const vk::Instance& instance, Core::Frontend::EmuWindow& render_window, + const Device& device, MemoryAllocator& memory_allocator, Scheduler& scheduler, Swapchain& swapchain, #ifdef ANDROID vk::SurfaceKHR& surface); diff --git a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp index 72d5ec35f9..d78bdeca6b 100644 --- a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp +++ b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp @@ -49,8 +49,8 @@ size_t GetStreamBufferSize(const Device& device) { StagingBufferPool::StagingBufferPool(const Device& device_, MemoryAllocator& memory_allocator_, Scheduler& scheduler_) : device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, - stream_buffer_size{GetStreamBufferSize(device)}, region_size{stream_buffer_size / - StagingBufferPool::NUM_SYNCS} { + stream_buffer_size{GetStreamBufferSize(device)}, + region_size{stream_buffer_size / StagingBufferPool::NUM_SYNCS} { VkBufferCreateInfo stream_ci = { .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .pNext = nullptr, diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.h b/src/video_core/renderer_vulkan/vk_state_tracker.h index c7e460ce11..386dc017af 100644 --- a/src/video_core/renderer_vulkan/vk_state_tracker.h +++ b/src/video_core/renderer_vulkan/vk_state_tracker.h @@ -205,14 +205,17 @@ public: return Exchange(Dirty::RasterizerDiscardEnable, false); } - bool TouchConservativeRasterizationMode() - { + bool TouchConservativeRasterizationMode() { return Exchange(Dirty::ConservativeRasterizationMode, false); } - bool TouchLineStippleEnable() { return Exchange(Dirty::ConservativeRasterizationMode, false); } + bool TouchLineStippleEnable() { + return Exchange(Dirty::ConservativeRasterizationMode, false); + } - bool TouchDepthBiasEnable() { return Exchange(Dirty::DepthBiasEnable, false); } + bool TouchDepthBiasEnable() { + return Exchange(Dirty::DepthBiasEnable, false); + } bool TouchLogicOpEnable() { return Exchange(Dirty::LogicOpEnable, false); diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp index a002ca83a0..962a61d91c 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.cpp +++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp @@ -111,18 +111,14 @@ Swapchain::Swapchain( #else VkSurfaceKHR_T* surface_handle_, #endif - const Device& device_, - Scheduler& scheduler_, - u32 width_, - u32 height_) + const Device& device_, Scheduler& scheduler_, u32 width_, u32 height_) #ifdef ANDROID : surface(surface_) #else : surface_handle{surface_handle_} #endif - , device{device_} - , scheduler{scheduler_} -{ + , + device{device_}, scheduler{scheduler_} { #ifdef ANDROID Create(surface, width_, height_); #else @@ -138,9 +134,7 @@ void Swapchain::Create( #else VkSurfaceKHR_T* surface_handle_, #endif - u32 width_, - u32 height_) -{ + u32 width_, u32 height_) { is_outdated = false; is_suboptimal = false; width = width_; @@ -243,8 +237,8 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities) { const auto present_modes = physical_device.GetSurfacePresentModesKHR(surface_handle); #endif - has_mailbox = std::find(present_modes.begin(), present_modes.end(), VK_PRESENT_MODE_MAILBOX_KHR) - != present_modes.end(); + has_mailbox = std::find(present_modes.begin(), present_modes.end(), + VK_PRESENT_MODE_MAILBOX_KHR) != present_modes.end(); has_imm = std::find(present_modes.begin(), present_modes.end(), VK_PRESENT_MODE_IMMEDIATE_KHR) != present_modes.end(); has_fifo_relaxed = std::find(present_modes.begin(), present_modes.end(), diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 022a9ae572..649549a80c 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -1206,8 +1206,8 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im src_view.format == PixelFormat::B8G8R8A8_SRGB) { // Verify format support before conversion if (device.IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT, - VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, - FormatType::Optimal)) { + VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, + FormatType::Optimal)) { return blit_image_helper.ConvertABGR8SRGBToD24S8(dst, src_view); } else { // Fallback to regular ABGR8 conversion if sRGB not supported @@ -1328,7 +1328,7 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im } VkFormat TextureCacheRuntime::GetSupportedFormat(VkFormat requested_format, - VkFormatFeatureFlags required_features) const { + VkFormatFeatureFlags required_features) const { if (requested_format == VK_FORMAT_A8B8G8R8_SRGB_PACK32 && (required_features & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) { // Force valid depth format when sRGB requested in depth context @@ -1523,7 +1523,7 @@ Image::Image(const VideoCommon::NullImageParams& params) : VideoCommon::ImageBas Image::~Image() = default; void Image::UploadMemory(VkBuffer buffer, VkDeviceSize offset, - std::span copies) { + std::span copies) { // TODO: Move this to another API const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); if (is_rescaled) { @@ -1531,8 +1531,9 @@ void Image::UploadMemory(VkBuffer buffer, VkDeviceSize offset, } // Handle MSAA upload if necessary - /* WARNING, TODO: This code uses some hacks, besides being fundamentally ugly - since tropic didn't want to touch it for a long time, so it needs a rewrite from someone better than me at vulkan.*/ + /* WARNING, TODO: This code uses some hacks, besides being fundamentally ugly + since tropic didn't want to touch it for a long time, so it needs a rewrite from someone better + than me at vulkan.*/ if (info.num_samples > 1 && runtime->CanUploadMSAA()) { // Only use MSAA copy pass for color formats // TODO: Depth/stencil formats need special handling @@ -1552,9 +1553,11 @@ void Image::UploadMemory(VkBuffer buffer, VkDeviceSize offset, const VkBuffer src_buffer = buffer; const VkImage temp_vk_image = *temp_image; const VkImageAspectFlags vk_aspect_mask = aspect_mask; - scheduler->Record([src_buffer, temp_vk_image, vk_aspect_mask, vk_copies](vk::CommandBuffer cmdbuf) { - CopyBufferToImage(cmdbuf, src_buffer, temp_vk_image, vk_aspect_mask, false, vk_copies); - }); + scheduler->Record( + [src_buffer, temp_vk_image, vk_aspect_mask, vk_copies](vk::CommandBuffer cmdbuf) { + CopyBufferToImage(cmdbuf, src_buffer, temp_vk_image, vk_aspect_mask, false, + vk_copies); + }); // Use MSAACopyPass to convert from non-MSAA to MSAA std::vector image_copies; @@ -1591,7 +1594,8 @@ void Image::UploadMemory(VkBuffer buffer, VkDeviceSize offset, const bool is_initialized = std::exchange(initialized, true); scheduler->Record([src_buffer, vk_image, vk_aspect_mask, is_initialized, vk_copies](vk::CommandBuffer cmdbuf) { - CopyBufferToImage(cmdbuf, src_buffer, vk_image, vk_aspect_mask, is_initialized, vk_copies); + CopyBufferToImage(cmdbuf, src_buffer, vk_image, vk_aspect_mask, is_initialized, + vk_copies); }); } @@ -1616,7 +1620,7 @@ void Image::DownloadMemory(VkBuffer buffer, size_t offset, } void Image::DownloadMemory(std::span buffers_span, std::span offsets_span, - std::span copies) { + std::span copies) { const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); if (is_rescaled) { ScaleDown(); @@ -1662,8 +1666,9 @@ void Image::DownloadMemory(std::span buffers_span, std::span o } scheduler->RequestOutsideRenderPassOperationContext(); - scheduler->Record([buffers = std::move(buffers_vector), image = *temp_wrapper.original_image, - aspect_mask_ = aspect_mask, vk_copies](vk::CommandBuffer cmdbuf) { + scheduler->Record([buffers = std::move(buffers_vector), + image = *temp_wrapper.original_image, aspect_mask_ = aspect_mask, + vk_copies](vk::CommandBuffer cmdbuf) { const VkImageMemoryBarrier read_barrier{ .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .pNext = nullptr, @@ -1682,12 +1687,12 @@ void Image::DownloadMemory(std::span buffers_span, std::span o .layerCount = VK_REMAINING_ARRAY_LAYERS, }, }; - cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, - 0, read_barrier); + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, + VK_PIPELINE_STAGE_TRANSFER_BIT, 0, read_barrier); for (size_t index = 0; index < buffers.size(); index++) { - cmdbuf.CopyImageToBuffer(image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, buffers[index], - vk_copies[index]); + cmdbuf.CopyImageToBuffer(image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + buffers[index], vk_copies[index]); } const VkMemoryBarrier memory_write_barrier{ @@ -1714,8 +1719,9 @@ void Image::DownloadMemory(std::span buffers_span, std::span o .layerCount = VK_REMAINING_ARRAY_LAYERS, }, }; - cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, - 0, memory_write_barrier, nullptr, image_write_barrier); + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, memory_write_barrier, + nullptr, image_write_barrier); }); return; } @@ -1749,12 +1755,12 @@ void Image::DownloadMemory(std::span buffers_span, std::span o .layerCount = VK_REMAINING_ARRAY_LAYERS, }, }; - cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, - 0, read_barrier); + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, + VK_PIPELINE_STAGE_TRANSFER_BIT, 0, read_barrier); for (size_t index = 0; index < buffers.size(); index++) { - cmdbuf.CopyImageToBuffer(image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, buffers[index], - vk_copies[index]); + cmdbuf.CopyImageToBuffer(image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + buffers[index], vk_copies[index]); } const VkMemoryBarrier memory_write_barrier{ @@ -1781,8 +1787,9 @@ void Image::DownloadMemory(std::span buffers_span, std::span o .layerCount = VK_REMAINING_ARRAY_LAYERS, }, }; - cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, - 0, memory_write_barrier, nullptr, image_write_barrier); + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, memory_write_barrier, + nullptr, image_write_barrier); }); } diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index cd11cc8fc7..d7fb405c4c 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h @@ -113,7 +113,8 @@ public: bool IsFormatDitherable(VideoCore::Surface::PixelFormat format); bool IsFormatScalable(VideoCore::Surface::PixelFormat format); - VkFormat GetSupportedFormat(VkFormat requested_format, VkFormatFeatureFlags required_features) const; + VkFormat GetSupportedFormat(VkFormat requested_format, + VkFormatFeatureFlags required_features) const; const Device& device; Scheduler& scheduler; @@ -197,7 +198,7 @@ private: // Use a pointer to field because it is relative, so that the object can be // moved without breaking the reference. - vk::Image Image::*current_image{}; + vk::Image Image::* current_image{}; std::vector storage_image_views; VkImageAspectFlags aspect_mask = 0; diff --git a/src/video_core/renderer_vulkan/vk_texture_manager.cpp b/src/video_core/renderer_vulkan/vk_texture_manager.cpp index 003af9e6fb..07d3aa4100 100644 --- a/src/video_core/renderer_vulkan/vk_texture_manager.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_manager.cpp @@ -75,15 +75,17 @@ void TextureManager::CleanupTextureCache() { // TODO: track usage and remove unused textures [ZEP] - LOG_INFO(Render_Vulkan, "Handling texture cache cleanup, current size: {}", texture_cache.size()); + LOG_INFO(Render_Vulkan, "Handling texture cache cleanup, current size: {}", + texture_cache.size()); } void TextureManager::HandleTextureRendering(const std::string& texture_path, - std::function render_callback) { + std::function render_callback) { VkImage texture = GetTexture(texture_path); if (!IsTextureLoadedCorrectly(texture)) { - LOG_ERROR(Render_Vulkan, "Texture failed to load correctly: {}, attempting reload", texture_path); + LOG_ERROR(Render_Vulkan, "Texture failed to load correctly: {}, attempting reload", + texture_path); ReloadTexture(texture_path); texture = GetTexture(texture_path); } @@ -115,26 +117,26 @@ vk::Image TextureManager::LoadTexture(const std::string& texture_path) { vk::Image TextureManager::CreateDefaultTexture() { // Create a small default texture (1x1 pixel) to use as a fallback -// const VkExtent2D extent{1, 1}; + // const VkExtent2D extent{1, 1}; -/* // Create image - const VkImageCreateInfo image_ci{ - .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .imageType = VK_IMAGE_TYPE_2D, - .format = texture_format, - .extent = {extent.width, extent.height, 1}, - .mipLevels = 1, - .arrayLayers = 1, - .samples = VK_SAMPLE_COUNT_1_BIT, - .tiling = VK_IMAGE_TILING_OPTIMAL, - .usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, - .sharingMode = VK_SHARING_MODE_EXCLUSIVE, - .queueFamilyIndexCount = 0, - .pQueueFamilyIndices = nullptr, - .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, - }; */ + /* // Create image + const VkImageCreateInfo image_ci{ + .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, + .pNext = nullptr, + .flags = 0, + .imageType = VK_IMAGE_TYPE_2D, + .format = texture_format, + .extent = {extent.width, extent.height, 1}, + .mipLevels = 1, + .arrayLayers = 1, + .samples = VK_SAMPLE_COUNT_1_BIT, + .tiling = VK_IMAGE_TILING_OPTIMAL, + .usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, + .sharingMode = VK_SHARING_MODE_EXCLUSIVE, + .queueFamilyIndexCount = 0, + .pQueueFamilyIndices = nullptr, + .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, + }; */ // TODO: create an actual VkImage [ZEP] LOG_INFO(Render_Vulkan, "Created default fallback texture"); diff --git a/src/video_core/shader_environment.cpp b/src/video_core/shader_environment.cpp index baeb8b23a0..7b19aa265d 100644 --- a/src/video_core/shader_environment.cpp +++ b/src/video_core/shader_environment.cpp @@ -398,8 +398,8 @@ u32 GraphicsEnvironment::ReadViewportTransformState() { ComputeEnvironment::ComputeEnvironment(Tegra::Engines::KeplerCompute& kepler_compute_, Tegra::MemoryManager& gpu_memory_, GPUVAddr program_base_, u32 start_address_) - : GenericEnvironment{gpu_memory_, program_base_, start_address_}, kepler_compute{ - &kepler_compute_} { + : GenericEnvironment{gpu_memory_, program_base_, start_address_}, + kepler_compute{&kepler_compute_} { const auto& qmd{kepler_compute->launch_description}; stage = Shader::Stage::Compute; local_memory_size = qmd.local_pos_alloc + qmd.local_crs_alloc; diff --git a/src/video_core/textures/astc.cpp b/src/video_core/textures/astc.cpp index fef0be31d8..f35e00d9a5 100644 --- a/src/video_core/textures/astc.cpp +++ b/src/video_core/textures/astc.cpp @@ -924,7 +924,7 @@ static void DecodeColorValues(u32* out, std::span data, const u32* modes, co assert(false && "Unsupported trit encoding for color values!"); break; } // switch(bitlen) - } // case IntegerEncoding::Trit + } // case IntegerEncoding::Trit break; case IntegerEncoding::Quint: { @@ -968,7 +968,7 @@ static void DecodeColorValues(u32* out, std::span data, const u32* modes, co assert(false && "Unsupported quint encoding for color values!"); break; } // switch(bitlen) - } // case IntegerEncoding::Quint + } // case IntegerEncoding::Quint break; } // switch(val.encoding) @@ -1588,7 +1588,7 @@ static void DecompressBlock(std::span inBuf, const u32 blockWidth, // Reverse everything for (u32 i = 0; i < 8; i++) { // Taken from http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith64Bits -#define REVERSE_BYTE(b) (((b)*0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32 +#define REVERSE_BYTE(b) (((b) * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32 u8 a = static_cast(REVERSE_BYTE(texelWeightData[i])); u8 b = static_cast(REVERSE_BYTE(texelWeightData[15 - i])); #undef REVERSE_BYTE diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 474e420daf..e70d530443 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp @@ -290,9 +290,9 @@ std::unordered_map GetFormatProperties(vk::Physica void OverrideBcnFormats(std::unordered_map& format_properties) { // These properties are extracted from Adreno driver 512.687.0 constexpr VkFormatFeatureFlags tiling_features{ - VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_BLIT_SRC_BIT | - VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT | VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | - VK_FORMAT_FEATURE_TRANSFER_DST_BIT}; + VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_BLIT_SRC_BIT | + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT | VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | + VK_FORMAT_FEATURE_TRANSFER_DST_BIT}; constexpr VkFormatFeatureFlags buffer_features{VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT}; @@ -313,7 +313,7 @@ void OverrideBcnFormats(std::unordered_map& format #endif NvidiaArchitecture GetNvidiaArchitecture(vk::PhysicalDevice physical, - const std::set>& exts) { + const std::set>& exts) { VkPhysicalDeviceProperties2 physical_properties{}; physical_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; physical_properties.pNext = nullptr; @@ -408,7 +408,7 @@ void Device::RemoveExtensionFeatureIfUnsuitable(bool is_suitable, Feature& featu Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR surface, const vk::InstanceDispatch& dld_) : instance{instance_}, dld{dld_}, physical{physical_}, - format_properties(GetFormatProperties(physical)) { + format_properties(GetFormatProperties(physical)) { // Get suitability and device properties. const bool is_suitable = GetSuitability(surface != nullptr); @@ -445,7 +445,8 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR const void* first_next = &features2; VkDeviceDiagnosticsConfigCreateInfoNV diagnostics_nv{}; - const bool use_diagnostics_nv = Settings::values.enable_nsight_aftermath && extensions.device_diagnostics_config; + const bool use_diagnostics_nv = + Settings::values.enable_nsight_aftermath && extensions.device_diagnostics_config; if (use_diagnostics_nv) { nsight_aftermath_tracker = std::make_unique(); @@ -461,7 +462,8 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR VkPhysicalDeviceDescriptorIndexingFeaturesEXT descriptor_indexing{ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT, - .pNext = use_diagnostics_nv ? static_cast(&diagnostics_nv) : static_cast(&features2), + .pNext = use_diagnostics_nv ? static_cast(&diagnostics_nv) + : static_cast(&features2), .shaderSampledImageArrayNonUniformIndexing = VK_TRUE, .descriptorBindingPartiallyBound = VK_TRUE, .descriptorBindingVariableDescriptorCount = VK_TRUE, @@ -494,14 +496,14 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR if (is_qualcomm || is_turnip) { LOG_WARNING(Render_Vulkan, "Qualcomm and Turnip drivers have broken VK_EXT_custom_border_color"); - //RemoveExtensionFeature(extensions.custom_border_color, features.custom_border_color, - //VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); + // RemoveExtensionFeature(extensions.custom_border_color, features.custom_border_color, + // VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); } if (is_qualcomm) { LOG_WARNING(Render_Vulkan, "Qualcomm drivers have a slow VK_KHR_push_descriptor implementation"); - //RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); + // RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); #if defined(ANDROID) && defined(ARCHITECTURE_arm64) // Patch the driver to enable BCn textures. @@ -535,7 +537,8 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR } else if (arch <= NvidiaArchitecture::Arch_Volta) { if (nv_major_version < 527) { LOG_WARNING(Render_Vulkan, "Volta and older have broken VK_KHR_push_descriptor"); - //RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); + // RemoveExtension(extensions.push_descriptor, + // VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); } } if (nv_major_version >= 510) { @@ -549,9 +552,9 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR if (version < VK_MAKE_API_VERSION(0, 21, 2, 0)) { LOG_WARNING(Render_Vulkan, "RADV versions older than 21.2 have broken VK_EXT_extended_dynamic_state"); - //RemoveExtensionFeature(extensions.extended_dynamic_state, - //features.extended_dynamic_state, - //VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); + // RemoveExtensionFeature(extensions.extended_dynamic_state, + // features.extended_dynamic_state, + // VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); } } if (extensions.extended_dynamic_state2 && is_radv) { @@ -572,9 +575,9 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR // Qualcomm Adreno 7xx drivers do not properly support extended_dynamic_state2. LOG_WARNING(Render_Vulkan, "Qualcomm Adreno 7xx drivers have broken VK_EXT_extended_dynamic_state2"); - //RemoveExtensionFeature(extensions.extended_dynamic_state2, - //features.extended_dynamic_state2, - //VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME); + // RemoveExtensionFeature(extensions.extended_dynamic_state2, + // features.extended_dynamic_state2, + // VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME); } } if (extensions.extended_dynamic_state3 && is_radv) { @@ -591,7 +594,8 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR dynamic_state3_enables = true; } } - if (extensions.extended_dynamic_state3 && (is_amd_driver || driver_id == VK_DRIVER_ID_SAMSUNG_PROPRIETARY)) { + if (extensions.extended_dynamic_state3 && + (is_amd_driver || driver_id == VK_DRIVER_ID_SAMSUNG_PROPRIETARY)) { // AMD and Samsung drivers have broken extendedDynamicState3ColorBlendEquation LOG_WARNING(Render_Vulkan, "AMD and Samsung drivers have broken extendedDynamicState3ColorBlendEquation"); @@ -616,9 +620,9 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR // Qualcomm drivers do not properly support vertex_input_dynamic_state. LOG_WARNING(Render_Vulkan, "Qualcomm drivers have broken VK_EXT_vertex_input_dynamic_state"); - //RemoveExtensionFeature(extensions.vertex_input_dynamic_state, - // features.vertex_input_dynamic_state, - // VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME); + // RemoveExtensionFeature(extensions.vertex_input_dynamic_state, + // features.vertex_input_dynamic_state, + // VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME); } sets_per_pool = 64; @@ -652,9 +656,9 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR const u32 version = (properties.properties.driverVersion << 3) >> 3; if (version < VK_MAKE_API_VERSION(27, 20, 100, 0)) { LOG_WARNING(Render_Vulkan, "Intel has broken VK_EXT_vertex_input_dynamic_state"); - //RemoveExtensionFeature(extensions.vertex_input_dynamic_state, - //features.vertex_input_dynamic_state, - //VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME); + // RemoveExtensionFeature(extensions.vertex_input_dynamic_state, + // features.vertex_input_dynamic_state, + // VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME); } } if (features.shader_float16_int8.shaderFloat16 && is_intel_windows) { @@ -681,14 +685,14 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR // mesa/mesa/-/commit/ff91c5ca42bc80aa411cb3fd8f550aa6fdd16bdc LOG_WARNING(Render_Vulkan, "ANV drivers 22.3.0 to 23.1.0 have broken VK_KHR_push_descriptor"); - //RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); + // RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); } } else if (extensions.push_descriptor && is_nvidia) { const auto arch = GetNvidiaArch(); if (arch <= NvidiaArchitecture::Arch_Pascal) { LOG_WARNING(Render_Vulkan, "Pascal and older architectures have broken VK_KHR_push_descriptor"); - //RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); + // RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); } } @@ -724,30 +728,33 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR if (Settings::values.dyna_state.GetValue() == 0) { must_emulate_scaled_formats = true; - LOG_INFO(Render_Vulkan, "Dynamic state is disabled (dyna_state = 0), forcing scaled format emulation ON"); + LOG_INFO(Render_Vulkan, + "Dynamic state is disabled (dyna_state = 0), forcing scaled format emulation ON"); // Disable dynamic state 1-3 and all extensions RemoveExtensionFeature(extensions.custom_border_color, features.custom_border_color, - VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); + VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); RemoveExtensionFeature(extensions.extended_dynamic_state, features.extended_dynamic_state, - VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); + VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); RemoveExtensionFeature(extensions.extended_dynamic_state2, features.extended_dynamic_state2, - VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME); + VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME); - RemoveExtensionFeature(extensions.vertex_input_dynamic_state, features.vertex_input_dynamic_state, - VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME); + RemoveExtensionFeature(extensions.vertex_input_dynamic_state, + features.vertex_input_dynamic_state, + VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME); RemoveExtensionFeature(extensions.extended_dynamic_state3, features.extended_dynamic_state3, - VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME); + VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME); dynamic_state3_blending = false; dynamic_state3_enables = false; LOG_INFO(Render_Vulkan, "All dynamic state extensions and features have been disabled"); } else { must_emulate_scaled_formats = false; - LOG_INFO(Render_Vulkan, "Dynamic state is enabled (dyna_state = 1-3), disabling scaled format emulation"); + LOG_INFO(Render_Vulkan, + "Dynamic state is enabled (dyna_state = 1-3), disabling scaled format emulation"); } logical = vk::Device::Create(physical, queue_cis, ExtensionListForVulkan(loaded_extensions), @@ -850,9 +857,9 @@ bool Device::ComputeIsOptimalAstcSupported() const { return false; } const auto format_feature_usage{ - VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_BLIT_SRC_BIT | - VK_FORMAT_FEATURE_BLIT_DST_BIT | VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | - VK_FORMAT_FEATURE_TRANSFER_DST_BIT}; + VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_BLIT_SRC_BIT | + VK_FORMAT_FEATURE_BLIT_DST_BIT | VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | + VK_FORMAT_FEATURE_TRANSFER_DST_BIT}; for (const auto format : astc_formats) { const auto physical_format_properties{physical.GetFormatProperties(format)}; if ((physical_format_properties.optimalTilingFeatures & format_feature_usage) == 0) { @@ -999,13 +1006,13 @@ bool Device::GetSuitability(bool requires_swapchain) { #define EXTENSION(prefix, macro_name, var_name) \ if (supported_extensions.contains(VK_##prefix##_##macro_name##_EXTENSION_NAME)) { \ - loaded_extensions.insert(VK_##prefix##_##macro_name##_EXTENSION_NAME); \ - extensions.var_name = true; \ + loaded_extensions.insert(VK_##prefix##_##macro_name##_EXTENSION_NAME); \ + extensions.var_name = true; \ } #define FEATURE_EXTENSION(prefix, struct_name, macro_name, var_name) \ if (supported_extensions.contains(VK_##prefix##_##macro_name##_EXTENSION_NAME)) { \ - loaded_extensions.insert(VK_##prefix##_##macro_name##_EXTENSION_NAME); \ - extensions.var_name = true; \ + loaded_extensions.insert(VK_##prefix##_##macro_name##_EXTENSION_NAME); \ + extensions.var_name = true; \ } if (instance_version < VK_API_VERSION_1_2) { @@ -1024,13 +1031,13 @@ bool Device::GetSuitability(bool requires_swapchain) { // Some extensions are mandatory. Check those. #define CHECK_EXTENSION(extension_name) \ if (!loaded_extensions.contains(extension_name)) { \ - LOG_ERROR(Render_Vulkan, "Missing required extension {}", extension_name); \ - suitable = false; \ + LOG_ERROR(Render_Vulkan, "Missing required extension {}", extension_name); \ + suitable = false; \ } #define LOG_EXTENSION(extension_name) \ if (!loaded_extensions.contains(extension_name)) { \ - LOG_INFO(Render_Vulkan, "Device doesn't support extension {}", extension_name); \ + LOG_INFO(Render_Vulkan, "Device doesn't support extension {}", extension_name); \ } FOR_EACH_VK_RECOMMENDED_EXTENSION(LOG_EXTENSION); @@ -1067,13 +1074,13 @@ bool Device::GetSuitability(bool requires_swapchain) { // We set the structure sType explicitly here as it is zeroed by the constructor. #define FEATURE(prefix, struct_name, macro_name, var_name) \ features.var_name.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_##macro_name##_FEATURES; \ - SetNext(next, features.var_name); + SetNext(next, features.var_name); #define EXT_FEATURE(prefix, struct_name, macro_name, var_name) \ if (extensions.var_name) { \ - features.var_name.sType = \ + features.var_name.sType = \ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_##macro_name##_FEATURES_##prefix; \ - SetNext(next, features.var_name); \ + SetNext(next, features.var_name); \ } FOR_EACH_VK_FEATURE_1_1(FEATURE); @@ -1101,13 +1108,13 @@ bool Device::GetSuitability(bool requires_swapchain) { // Some features are mandatory. Check those. #define CHECK_FEATURE(feature, name) \ if (!features.feature.name) { \ - LOG_ERROR(Render_Vulkan, "Missing required feature {}", #name); \ - suitable = false; \ + LOG_ERROR(Render_Vulkan, "Missing required feature {}", #name); \ + suitable = false; \ } #define LOG_FEATURE(feature, name) \ if (!features.feature.name) { \ - LOG_INFO(Render_Vulkan, "Device doesn't support feature {}", #name); \ + LOG_INFO(Render_Vulkan, "Device doesn't support feature {}", #name); \ } FOR_EACH_VK_RECOMMENDED_FEATURE(LOG_FEATURE); @@ -1170,11 +1177,11 @@ bool Device::GetSuitability(bool requires_swapchain) { const VkPhysicalDeviceLimits& limits{properties.properties.limits}; const std::array limits_report{ - Limit{65536, limits.maxUniformBufferRange, "maxUniformBufferRange"}, - Limit{16, limits.maxViewports, "maxViewports"}, - Limit{8, limits.maxColorAttachments, "maxColorAttachments"}, - Limit{8, limits.maxClipDistances, "maxClipDistances"}, - }; + Limit{65536, limits.maxUniformBufferRange, "maxUniformBufferRange"}, + Limit{16, limits.maxViewports, "maxViewports"}, + Limit{8, limits.maxColorAttachments, "maxColorAttachments"}, + Limit{8, limits.maxClipDistances, "maxClipDistances"}, + }; for (const auto& [min, value, name] : limits_report) { if (value < min) { @@ -1236,15 +1243,13 @@ void Device::RemoveUnsuitableExtensions() { // VK_EXT_provoking_vertex if (Settings::values.provoking_vertex.GetValue()) { - extensions.provoking_vertex = features.provoking_vertex.provokingVertexLast - && features.provoking_vertex - .transformFeedbackPreservesProvokingVertex; - RemoveExtensionFeatureIfUnsuitable(extensions.provoking_vertex, - features.provoking_vertex, + extensions.provoking_vertex = + features.provoking_vertex.provokingVertexLast && + features.provoking_vertex.transformFeedbackPreservesProvokingVertex; + RemoveExtensionFeatureIfUnsuitable(extensions.provoking_vertex, features.provoking_vertex, VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME); } else { - RemoveExtensionFeature(extensions.provoking_vertex, - features.provoking_vertex, + RemoveExtensionFeature(extensions.provoking_vertex, features.provoking_vertex, VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME); } diff --git a/src/video_core/vulkan_common/vulkan_raii.h b/src/video_core/vulkan_common/vulkan_raii.h index cf5e268b68..b8ea4fde84 100644 --- a/src/video_core/vulkan_common/vulkan_raii.h +++ b/src/video_core/vulkan_common/vulkan_raii.h @@ -3,10 +3,10 @@ #pragma once -#include -#include #include +#include #include +#include #include "common/logging/log.h" @@ -27,17 +27,16 @@ public: VulkanRaii() : handle{}, deleter{}, dispatch{} {} // Constructor with handle and deleter - VulkanRaii(T handle_, DeleterFunc deleter_, const Dispatch& dispatch_, const char* resource_name = "Vulkan resource") + VulkanRaii(T handle_, DeleterFunc deleter_, const Dispatch& dispatch_, + const char* resource_name = "Vulkan resource") : handle{handle_}, deleter{std::move(deleter_)}, dispatch{dispatch_} { LOG_DEBUG(Render_Vulkan, "RAII wrapper created for {}", resource_name); } // Move constructor VulkanRaii(VulkanRaii&& other) noexcept - : handle{std::exchange(other.handle, VK_NULL_HANDLE)}, - deleter{std::move(other.deleter)}, - dispatch{other.dispatch} { - } + : handle{std::exchange(other.handle, VK_NULL_HANDLE)}, deleter{std::move(other.deleter)}, + dispatch{other.dispatch} {} // Move assignment VulkanRaii& operator=(VulkanRaii&& other) noexcept { @@ -122,14 +121,16 @@ using ManagedDescriptorSetLayout = VulkanRaii; using ManagedSemaphore = VulkanRaii; using ManagedFence = VulkanRaii; -using ManagedDebugUtilsMessenger = VulkanRaii; +using ManagedDebugUtilsMessenger = + VulkanRaii; // Helper functions to create RAII wrappers /** * Creates an RAII wrapper for a Vulkan instance */ -inline ManagedInstance MakeManagedInstance(const vk::Instance& instance, const vk::InstanceDispatch& dispatch) { +inline ManagedInstance MakeManagedInstance(const vk::Instance& instance, + const vk::InstanceDispatch& dispatch) { auto deleter = [](VkInstance handle, const vk::InstanceDispatch& dld) { dld.vkDestroyInstance(handle, nullptr); }; @@ -139,7 +140,8 @@ inline ManagedInstance MakeManagedInstance(const vk::Instance& instance, const v /** * Creates an RAII wrapper for a Vulkan device */ -inline ManagedDevice MakeManagedDevice(const vk::Device& device, const vk::DeviceDispatch& dispatch) { +inline ManagedDevice MakeManagedDevice(const vk::Device& device, + const vk::DeviceDispatch& dispatch) { auto deleter = [](VkDevice handle, const vk::DeviceDispatch& dld) { dld.vkDestroyDevice(handle, nullptr); }; @@ -149,8 +151,11 @@ inline ManagedDevice MakeManagedDevice(const vk::Device& device, const vk::Devic /** * Creates an RAII wrapper for a Vulkan surface */ -inline ManagedSurface MakeManagedSurface(const vk::SurfaceKHR& surface, const vk::Instance& instance, const vk::InstanceDispatch& dispatch) { - auto deleter = [instance_ptr = *instance](VkSurfaceKHR handle, const vk::InstanceDispatch& dld) { +inline ManagedSurface MakeManagedSurface(const vk::SurfaceKHR& surface, + const vk::Instance& instance, + const vk::InstanceDispatch& dispatch) { + auto deleter = [instance_ptr = *instance](VkSurfaceKHR handle, + const vk::InstanceDispatch& dld) { dld.vkDestroySurfaceKHR(instance_ptr, handle, nullptr); }; return ManagedSurface(*surface, deleter, dispatch, "VkSurfaceKHR"); @@ -159,10 +164,11 @@ inline ManagedSurface MakeManagedSurface(const vk::SurfaceKHR& surface, const vk /** * Creates an RAII wrapper for a Vulkan debug messenger */ -inline ManagedDebugUtilsMessenger MakeManagedDebugUtilsMessenger(const vk::DebugUtilsMessenger& messenger, - const vk::Instance& instance, - const vk::InstanceDispatch& dispatch) { - auto deleter = [instance_ptr = *instance](VkDebugUtilsMessengerEXT handle, const vk::InstanceDispatch& dld) { +inline ManagedDebugUtilsMessenger MakeManagedDebugUtilsMessenger( + const vk::DebugUtilsMessenger& messenger, const vk::Instance& instance, + const vk::InstanceDispatch& dispatch) { + auto deleter = [instance_ptr = *instance](VkDebugUtilsMessengerEXT handle, + const vk::InstanceDispatch& dld) { dld.vkDestroyDebugUtilsMessengerEXT(instance_ptr, handle, nullptr); }; return ManagedDebugUtilsMessenger(*messenger, deleter, dispatch, "VkDebugUtilsMessengerEXT"); @@ -171,7 +177,9 @@ inline ManagedDebugUtilsMessenger MakeManagedDebugUtilsMessenger(const vk::Debug /** * Creates an RAII wrapper for a Vulkan swapchain */ -inline ManagedSwapchain MakeManagedSwapchain(VkSwapchainKHR swapchain_handle, VkDevice device_handle, const vk::DeviceDispatch& dispatch) { +inline ManagedSwapchain MakeManagedSwapchain(VkSwapchainKHR swapchain_handle, + VkDevice device_handle, + const vk::DeviceDispatch& dispatch) { auto deleter = [device_handle](VkSwapchainKHR handle, const vk::DeviceDispatch& dld) { dld.vkDestroySwapchainKHR(device_handle, handle, nullptr); }; @@ -181,7 +189,8 @@ inline ManagedSwapchain MakeManagedSwapchain(VkSwapchainKHR swapchain_handle, Vk /** * Creates an RAII wrapper for a Vulkan buffer */ -inline ManagedBuffer MakeManagedBuffer(VkBuffer buffer_handle, VkDevice device_handle, const vk::DeviceDispatch& dispatch) { +inline ManagedBuffer MakeManagedBuffer(VkBuffer buffer_handle, VkDevice device_handle, + const vk::DeviceDispatch& dispatch) { auto deleter = [device_handle](VkBuffer handle, const vk::DeviceDispatch& dld) { dld.vkDestroyBuffer(device_handle, handle, nullptr); }; @@ -191,7 +200,8 @@ inline ManagedBuffer MakeManagedBuffer(VkBuffer buffer_handle, VkDevice device_h /** * Creates an RAII wrapper for a Vulkan image */ -inline ManagedImage MakeManagedImage(VkImage image_handle, VkDevice device_handle, const vk::DeviceDispatch& dispatch) { +inline ManagedImage MakeManagedImage(VkImage image_handle, VkDevice device_handle, + const vk::DeviceDispatch& dispatch) { auto deleter = [device_handle](VkImage handle, const vk::DeviceDispatch& dld) { dld.vkDestroyImage(device_handle, handle, nullptr); }; @@ -201,7 +211,8 @@ inline ManagedImage MakeManagedImage(VkImage image_handle, VkDevice device_handl /** * Creates an RAII wrapper for a Vulkan image view */ -inline ManagedImageView MakeManagedImageView(VkImageView view_handle, VkDevice device_handle, const vk::DeviceDispatch& dispatch) { +inline ManagedImageView MakeManagedImageView(VkImageView view_handle, VkDevice device_handle, + const vk::DeviceDispatch& dispatch) { auto deleter = [device_handle](VkImageView handle, const vk::DeviceDispatch& dld) { dld.vkDestroyImageView(device_handle, handle, nullptr); }; @@ -211,7 +222,8 @@ inline ManagedImageView MakeManagedImageView(VkImageView view_handle, VkDevice d /** * Creates an RAII wrapper for a Vulkan semaphore */ -inline ManagedSemaphore MakeManagedSemaphore(VkSemaphore semaphore_handle, VkDevice device_handle, const vk::DeviceDispatch& dispatch) { +inline ManagedSemaphore MakeManagedSemaphore(VkSemaphore semaphore_handle, VkDevice device_handle, + const vk::DeviceDispatch& dispatch) { auto deleter = [device_handle](VkSemaphore handle, const vk::DeviceDispatch& dld) { dld.vkDestroySemaphore(device_handle, handle, nullptr); }; @@ -221,7 +233,8 @@ inline ManagedSemaphore MakeManagedSemaphore(VkSemaphore semaphore_handle, VkDev /** * Creates an RAII wrapper for a Vulkan fence */ -inline ManagedFence MakeManagedFence(VkFence fence_handle, VkDevice device_handle, const vk::DeviceDispatch& dispatch) { +inline ManagedFence MakeManagedFence(VkFence fence_handle, VkDevice device_handle, + const vk::DeviceDispatch& dispatch) { auto deleter = [device_handle](VkFence handle, const vk::DeviceDispatch& dld) { dld.vkDestroyFence(device_handle, handle, nullptr); }; diff --git a/src/video_core/vulkan_common/vulkan_wrapper.h b/src/video_core/vulkan_common/vulkan_wrapper.h index d12a1546e5..45e2c71a05 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.h +++ b/src/video_core/vulkan_common/vulkan_wrapper.h @@ -715,8 +715,8 @@ public: explicit Buffer(VkBuffer handle_, VkDevice owner_, VmaAllocator allocator_, VmaAllocation allocation_, std::span mapped_, bool is_coherent_, const DeviceDispatch& dld_) noexcept - : handle{handle_}, owner{owner_}, allocator{allocator_}, - allocation{allocation_}, mapped{mapped_}, is_coherent{is_coherent_}, dld{&dld_} {} + : handle{handle_}, owner{owner_}, allocator{allocator_}, allocation{allocation_}, + mapped{mapped_}, is_coherent{is_coherent_}, dld{&dld_} {} Buffer() = default; Buffer(const Buffer&) = delete; @@ -724,8 +724,8 @@ public: Buffer(Buffer&& rhs) noexcept : handle{std::exchange(rhs.handle, nullptr)}, owner{rhs.owner}, allocator{rhs.allocator}, - allocation{rhs.allocation}, mapped{rhs.mapped}, - is_coherent{rhs.is_coherent}, dld{rhs.dld} {} + allocation{rhs.allocation}, mapped{rhs.mapped}, is_coherent{rhs.is_coherent}, + dld{rhs.dld} {} Buffer& operator=(Buffer&& rhs) noexcept { Release(); @@ -1437,18 +1437,16 @@ public: dld->vkCmdSetRasterizerDiscardEnableEXT(handle, enable ? VK_TRUE : VK_FALSE); } - void SetConservativeRasterizationModeEXT(VkConservativeRasterizationModeEXT mode) const noexcept - { + void SetConservativeRasterizationModeEXT( + VkConservativeRasterizationModeEXT mode) const noexcept { dld->vkCmdSetConservativeRasterizationModeEXT(handle, mode); } - void SetLineRasterizationModeEXT(VkLineRasterizationModeEXT mode) const noexcept - { + void SetLineRasterizationModeEXT(VkLineRasterizationModeEXT mode) const noexcept { dld->vkCmdSetLineRasterizationModeEXT(handle, mode); } - void SetLineStippleEnableEXT(bool enable) const noexcept - { + void SetLineStippleEnableEXT(bool enable) const noexcept { dld->vkCmdSetLineStippleEnableEXT(handle, enable ? VK_TRUE : VK_FALSE); } diff --git a/src/yuzu/about_dialog.cpp b/src/yuzu/about_dialog.cpp index 6ef3072894..f33561b25a 100644 --- a/src/yuzu/about_dialog.cpp +++ b/src/yuzu/about_dialog.cpp @@ -1,16 +1,14 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "yuzu/about_dialog.h" #include +#include #include "common/scm_rev.h" #include "ui_aboutdialog.h" -#include +#include "yuzu/about_dialog.h" AboutDialog::AboutDialog(QWidget* parent) - : QDialog(parent) - , ui{std::make_unique()} -{ + : QDialog(parent), ui{std::make_unique()} { const auto description = std::string(Common::g_build_version); const auto build_id = std::string(Common::g_build_id); @@ -21,9 +19,8 @@ AboutDialog::AboutDialog(QWidget* parent) yuzu_build = fmt::format("eden | {}", description); } - const auto override_build = fmt::format(fmt::runtime( - std::string(Common::g_title_bar_format_idle)), - build_id); + const auto override_build = + fmt::format(fmt::runtime(std::string(Common::g_title_bar_format_idle)), build_id); const auto yuzu_build_version = override_build.empty() ? yuzu_build : override_build; ui->setupUi(this); diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp index 48ce860ad7..bafb2b7c94 100644 --- a/src/yuzu/applets/qt_controller.cpp +++ b/src/yuzu/applets/qt_controller.cpp @@ -184,14 +184,15 @@ QtControllerSelectorDialog::QtControllerSelectorDialog( CheckIfParametersMet(); }); - connect(connected_controller_checkboxes[i], &QCheckBox::stateChanged, [this, i](int state) { - player_groupboxes[i]->setChecked(state == Qt::Checked); - UpdateControllerIcon(i); - UpdateControllerState(i); - UpdateLEDPattern(i); - UpdateBorderColor(i); - CheckIfParametersMet(); - }); + connect(connected_controller_checkboxes[i], &QCheckBox::checkStateChanged, + [this, i](Qt::CheckState state) { + player_groupboxes[i]->setChecked(state == Qt::Checked); + UpdateControllerIcon(i); + UpdateControllerState(i); + UpdateLEDPattern(i); + UpdateBorderColor(i); + CheckIfParametersMet(); + }); if (i == 0) { connect(emulated_controllers[i], qOverload(&QComboBox::currentIndexChanged), diff --git a/src/yuzu/applets/qt_web_browser.cpp b/src/yuzu/applets/qt_web_browser.cpp index 8245c12ba2..53e495e461 100644 --- a/src/yuzu/applets/qt_web_browser.cpp +++ b/src/yuzu/applets/qt_web_browser.cpp @@ -54,8 +54,8 @@ QtNXWebEngineView::QtNXWebEngineView(QWidget* parent, Core::System& system, : QWebEngineView(parent), input_subsystem{input_subsystem_}, url_interceptor(std::make_unique()), input_interpreter(std::make_unique(system)), - default_profile{QWebEngineProfile::defaultProfile()}, global_settings{ - default_profile->settings()} { + default_profile{QWebEngineProfile::defaultProfile()}, + global_settings{default_profile->settings()} { default_profile->setPersistentStoragePath(QString::fromStdString(Common::FS::PathToUTF8String( Common::FS::GetEdenPath(Common::FS::EdenPath::EdenDir) / "qtwebengine"))); diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 987b1462db..dd22bf1b4c 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp @@ -33,9 +33,9 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, InputCommon::InputSubsystem* input_subsystem, std::vector& vk_device_records, Core::System& system_, bool enable_web_config) - : QDialog(parent), ui{std::make_unique()}, - registry(registry_), system{system_}, builder{std::make_unique( - this, !system_.IsPoweredOn())}, + : QDialog(parent), ui{std::make_unique()}, registry(registry_), + system{system_}, + builder{std::make_unique(this, !system_.IsPoweredOn())}, applets_tab{std::make_unique(system_, nullptr, *builder, this)}, audio_tab{std::make_unique(system_, nullptr, *builder, this)}, cpu_tab{std::make_unique(system_, nullptr, *builder, this)}, @@ -43,9 +43,9 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, filesystem_tab{std::make_unique(this)}, general_tab{std::make_unique(system_, nullptr, *builder, this)}, graphics_advanced_tab{ - std::make_unique(system_, nullptr, *builder, this)}, + std::make_unique(system_, nullptr, *builder, this)}, graphics_extensions_tab{ - std::make_unique(system_, nullptr, *builder, this)}, + std::make_unique(system_, nullptr, *builder, this)}, ui_tab{std::make_unique(system_, this)}, graphics_tab{std::make_unique( system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, @@ -108,7 +108,7 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, adjustSize(); ui->selectorList->setCurrentRow(0); - // Selects the leftmost button on the bottom bar (Cancel as of writing) + // Selects the leftmost button on the bottom bar (Cancel as of writing) ui->buttonBox->setFocus(); } @@ -167,16 +167,17 @@ Q_DECLARE_METATYPE(QList); void ConfigureDialog::PopulateSelectionList() { const std::array>, 6> items{ - {{tr("General"), - {general_tab.get(), hotkeys_tab.get(), ui_tab.get(), web_tab.get(), debug_tab_tab.get()}}, - {tr("System"), - {system_tab.get(), profile_tab.get(), network_tab.get(), filesystem_tab.get(), - applets_tab.get()}}, - {tr("CPU"), {cpu_tab.get()}}, - {tr("Graphics"), {graphics_tab.get(), graphics_advanced_tab.get(), graphics_extensions_tab.get()}}, - {tr("Audio"), {audio_tab.get()}}, - {tr("Controls"), input_tab->GetSubTabs()}}, - }; + {{tr("General"), + {general_tab.get(), hotkeys_tab.get(), ui_tab.get(), web_tab.get(), debug_tab_tab.get()}}, + {tr("System"), + {system_tab.get(), profile_tab.get(), network_tab.get(), filesystem_tab.get(), + applets_tab.get()}}, + {tr("CPU"), {cpu_tab.get()}}, + {tr("Graphics"), + {graphics_tab.get(), graphics_advanced_tab.get(), graphics_extensions_tab.get()}}, + {tr("Audio"), {audio_tab.get()}}, + {tr("Controls"), input_tab->GetSubTabs()}}, + }; [[maybe_unused]] const QSignalBlocker blocker(ui->selectorList); diff --git a/src/yuzu/configuration/configure_filesystem.cpp b/src/yuzu/configuration/configure_filesystem.cpp index f25f14708b..80f8d1816d 100644 --- a/src/yuzu/configuration/configure_filesystem.cpp +++ b/src/yuzu/configuration/configure_filesystem.cpp @@ -29,9 +29,9 @@ ConfigureFilesystem::ConfigureFilesystem(QWidget* parent) connect(ui->reset_game_list_cache, &QPushButton::pressed, this, &ConfigureFilesystem::ResetMetadata); - connect(ui->gamecard_inserted, &QCheckBox::stateChanged, this, + connect(ui->gamecard_inserted, &QCheckBox::checkStateChanged, this, &ConfigureFilesystem::UpdateEnabledControls); - connect(ui->gamecard_current_game, &QCheckBox::stateChanged, this, + connect(ui->gamecard_current_game, &QCheckBox::checkStateChanged, this, &ConfigureFilesystem::UpdateEnabledControls); } diff --git a/src/yuzu/configuration/configure_graphics_extensions.cpp b/src/yuzu/configuration/configure_graphics_extensions.cpp index 61491c0ab7..070841a3d4 100644 --- a/src/yuzu/configuration/configure_graphics_extensions.cpp +++ b/src/yuzu/configuration/configure_graphics_extensions.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include -#include -#include #include +#include #include +#include #include "common/settings.h" #include "core/core.h" #include "ui_configure_graphics_extensions.h" @@ -17,7 +17,8 @@ ConfigureGraphicsExtensions::ConfigureGraphicsExtensions( const Core::System& system_, std::shared_ptr> group_, const ConfigurationShared::Builder& builder, QWidget* parent) - : Tab(group_, parent), ui{std::make_unique()}, system{system_} { + : Tab(group_, parent), ui{std::make_unique()}, + system{system_} { ui->setupUi(this); diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index 28c3baf086..b7067ef827 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp @@ -121,10 +121,11 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, &ConfigureInput::UpdateAllInputDevices); connect(player_controllers[i], &ConfigureInputPlayer::RefreshInputProfiles, this, &ConfigureInput::UpdateAllInputProfiles, Qt::QueuedConnection); - connect(connected_controller_checkboxes[i], &QCheckBox::stateChanged, [this, i](int state) { - // Keep activated controllers synced with the "Connected Controllers" checkboxes - player_controllers[i]->ConnectPlayer(state == Qt::Checked); - }); + connect(connected_controller_checkboxes[i], &QCheckBox::checkStateChanged, + [this, i](Qt::CheckState state) { + // Keep activated controllers synced with the "Connected Controllers" checkboxes + player_controllers[i]->ConnectPlayer(state == Qt::Checked); + }); // Remove/hide all the elements that exceed max_players, if applicable. if (i >= max_players) { diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp index d6c4e09ec0..b9ff58bf7b 100644 --- a/src/yuzu/configuration/configure_input_advanced.cpp +++ b/src/yuzu/configuration/configure_input_advanced.cpp @@ -74,13 +74,13 @@ ConfigureInputAdvanced::ConfigureInputAdvanced(Core::HID::HIDCore& hid_core_, QW } } - connect(ui->mouse_enabled, &QCheckBox::stateChanged, this, + connect(ui->mouse_enabled, &QCheckBox::checkStateChanged, this, &ConfigureInputAdvanced::UpdateUIEnabled); - connect(ui->debug_enabled, &QCheckBox::stateChanged, this, + connect(ui->debug_enabled, &QCheckBox::checkStateChanged, this, &ConfigureInputAdvanced::UpdateUIEnabled); - connect(ui->touchscreen_enabled, &QCheckBox::stateChanged, this, + connect(ui->touchscreen_enabled, &QCheckBox::checkStateChanged, this, &ConfigureInputAdvanced::UpdateUIEnabled); - connect(ui->enable_ring_controller, &QCheckBox::stateChanged, this, + connect(ui->enable_ring_controller, &QCheckBox::checkStateChanged, this, &ConfigureInputAdvanced::UpdateUIEnabled); connect(ui->debug_configure, &QPushButton::clicked, this, diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 12fe935e41..8e0182023b 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -293,11 +293,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i InputCommon::InputSubsystem* input_subsystem_, InputProfiles* profiles_, Core::HID::HIDCore& hid_core_, bool is_powered_on_, bool debug_) - : QWidget(parent), - ui(std::make_unique()), player_index{player_index_}, debug{debug_}, - is_powered_on{is_powered_on_}, input_subsystem{input_subsystem_}, profiles(profiles_), - timeout_timer(std::make_unique()), - poll_timer(std::make_unique()), bottom_row{bottom_row_}, hid_core{hid_core_} { + : QWidget(parent), ui(std::make_unique()), + player_index{player_index_}, debug{debug_}, is_powered_on{is_powered_on_}, + input_subsystem{input_subsystem_}, profiles(profiles_), + timeout_timer(std::make_unique()), poll_timer(std::make_unique()), + bottom_row{bottom_row_}, hid_core{hid_core_} { if (player_index == 0) { auto* emulated_controller_p1 = hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1); @@ -1214,10 +1214,8 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() { case Core::HID::NpadStyleIndex::Fullkey: case Core::HID::NpadStyleIndex::Handheld: layout_hidden = { - ui->buttonShoulderButtonsSLSRLeft, - ui->buttonShoulderButtonsSLSRRight, - ui->horizontalSpacerShoulderButtonsWidget2, - ui->horizontalSpacerShoulderButtonsWidget4, + ui->buttonShoulderButtonsSLSRLeft, ui->buttonShoulderButtonsSLSRRight, + ui->horizontalSpacerShoulderButtonsWidget2, ui->horizontalSpacerShoulderButtonsWidget4, ui->buttonMiscButtonsScreenshotGroup, }; break; diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index 031a8d4c2d..6508f032f5 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp @@ -45,8 +45,8 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::string& file_name, std::vector& vk_device_records, Core::System& system_) - : QDialog(parent), - ui(std::make_unique()), title_id{title_id_}, system{system_}, + : QDialog(parent), ui(std::make_unique()), title_id{title_id_}, + system{system_}, builder{std::make_unique(this, !system_.IsPoweredOn())}, tab_group{std::make_shared>()} { const auto file_path = std::filesystem::path(Common::FS::ToU8String(file_name)); diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index f009800d52..9b920af9e7 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp @@ -32,8 +32,8 @@ #include "core/hle/service/acc/profile_manager.h" #include "core/hle/service/filesystem/filesystem.h" #include "ui_configure_profile_manager.h" -#include "yuzu/util/limitable_input_dialog.h" #include "yuzu/configuration/configure_profile_manager.h" +#include "yuzu/util/limitable_input_dialog.h" namespace { // Same backup JPEG used by acc IProfile::GetImage if no jpeg found diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index e193b5f95b..68b1258f92 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -83,7 +83,7 @@ ConfigureSystem::ConfigureSystem(Core::System& system_, connect(combo_language, qOverload(&QComboBox::currentIndexChanged), this, locale_check); connect(combo_region, qOverload(&QComboBox::currentIndexChanged), this, locale_check); - connect(checkbox_rtc, qOverload(&QCheckBox::stateChanged), this, update_rtc_date); + connect(checkbox_rtc, qOverload(&QCheckBox::checkStateChanged), this, update_rtc_date); connect(date_rtc_offset, qOverload(&QSpinBox::valueChanged), this, update_rtc_date); connect(date_rtc, &QDateTimeEdit::dateTimeChanged, this, update_date_offset); diff --git a/src/yuzu/configuration/configure_touch_from_button.cpp b/src/yuzu/configuration/configure_touch_from_button.cpp index a6237ab72f..7810a66e97 100644 --- a/src/yuzu/configuration/configure_touch_from_button.cpp +++ b/src/yuzu/configuration/configure_touch_from_button.cpp @@ -548,9 +548,8 @@ bool TouchScreenPreview::eventFilter(QObject* obj, QEvent* event) { } const auto mouse_event = static_cast(event); if (!drag_state.active) { - drag_state.active = - (mouse_event->globalPosition().toPoint() - drag_state.start_pos).manhattanLength() >= - QApplication::startDragDistance(); + drag_state.active = (mouse_event->globalPosition().toPoint() - drag_state.start_pos) + .manhattanLength() >= QApplication::startDragDistance(); if (!drag_state.active) { break; } diff --git a/src/yuzu/configuration/configure_ui.cpp b/src/yuzu/configuration/configure_ui.cpp index 8dafee628b..0459e41fab 100644 --- a/src/yuzu/configuration/configure_ui.cpp +++ b/src/yuzu/configuration/configure_ui.cpp @@ -119,11 +119,11 @@ ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent) SetConfiguration(); // Force game list reload if any of the relevant settings are changed. - connect(ui->show_add_ons, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate); - connect(ui->show_compat, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate); - connect(ui->show_size, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate); - connect(ui->show_types, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate); - connect(ui->show_play_time, &QCheckBox::stateChanged, this, + connect(ui->show_add_ons, &QCheckBox::checkStateChanged, this, &ConfigureUi::RequestGameListUpdate); + connect(ui->show_compat, &QCheckBox::checkStateChanged, this, &ConfigureUi::RequestGameListUpdate); + connect(ui->show_size, &QCheckBox::checkStateChanged, this, &ConfigureUi::RequestGameListUpdate); + connect(ui->show_types, &QCheckBox::checkStateChanged, this, &ConfigureUi::RequestGameListUpdate); + connect(ui->show_play_time, &QCheckBox::checkStateChanged, this, &ConfigureUi::RequestGameListUpdate); connect(ui->game_icon_size_combobox, QOverload::of(&QComboBox::currentIndexChanged), this, &ConfigureUi::RequestGameListUpdate); diff --git a/src/yuzu/configuration/configure_web.cpp b/src/yuzu/configuration/configure_web.cpp index d62b5b0853..04fa6d2770 100644 --- a/src/yuzu/configuration/configure_web.cpp +++ b/src/yuzu/configuration/configure_web.cpp @@ -4,9 +4,9 @@ // SPDX-FileCopyrightText: 2017 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "yuzu/configuration/configure_web.h" #include #include +#include "yuzu/configuration/configure_web.h" #if QT_VERSION_MAJOR >= 6 #include @@ -20,24 +20,21 @@ #include "yuzu/uisettings.h" ConfigureWeb::ConfigureWeb(QWidget* parent) - : QWidget(parent) - , ui(std::make_unique()) - , m_rng{QRandomGenerator::system()} -{ + : QWidget(parent), ui(std::make_unique()), m_rng{QRandomGenerator::system()} { ui->setupUi(this); QString user_regex = QStringLiteral(".{4,20}"); QString token_regex = QStringLiteral("[a-z]{48}"); #if QT_VERSION_MAJOR >= 6 - QRegularExpressionValidator *username_validator = new QRegularExpressionValidator(this); - QRegularExpressionValidator *token_validator = new QRegularExpressionValidator(this); + QRegularExpressionValidator* username_validator = new QRegularExpressionValidator(this); + QRegularExpressionValidator* token_validator = new QRegularExpressionValidator(this); username_validator->setRegularExpression(QRegularExpression(user_regex)); token_validator->setRegularExpression(QRegularExpression(token_regex)); #else - QRegExpValidator *username_validator = new QRegExpValidator(this); - QRegExpValidator *token_validator = new QRegExpValidator(this); + QRegExpValidator* username_validator = new QRegExpValidator(this); + QRegExpValidator* token_validator = new QRegExpValidator(this); username_validator->setRegExp(QRegExp(user_regex)); token_validator->setRegExp(QRegExp(token_regex)); @@ -121,7 +118,8 @@ void ConfigureWeb::VerifyLogin() { ui->label_token_verified->setToolTip(tr("All Good", "Tooltip")); } else { ui->label_token_verified->setPixmap(failed); - ui->label_token_verified->setToolTip(tr("Must be 48 characters, and lowercase a-z", "Tooltip")); + ui->label_token_verified->setToolTip( + tr("Must be 48 characters, and lowercase a-z", "Tooltip")); } } diff --git a/src/yuzu/configuration/configure_web.h b/src/yuzu/configuration/configure_web.h index 3da7e5eccc..d2c969cc56 100644 --- a/src/yuzu/configuration/configure_web.h +++ b/src/yuzu/configuration/configure_web.h @@ -8,8 +8,8 @@ #include -#include #include +#include namespace Ui { class ConfigureWeb; @@ -32,7 +32,7 @@ private: void SetConfiguration(); std::unique_ptr ui; - QRandomGenerator *m_rng; + QRandomGenerator* m_rng; private slots: void GenerateToken(); diff --git a/src/yuzu/configuration/shared_translation.cpp b/src/yuzu/configuration/shared_translation.cpp index c743e65ae3..29c2f94fca 100644 --- a/src/yuzu/configuration/shared_translation.cpp +++ b/src/yuzu/configuration/shared_translation.cpp @@ -9,6 +9,10 @@ #include "yuzu/configuration/shared_translation.h" +#include +#include +#include +#include #include #include #include "common/settings.h" @@ -16,19 +20,14 @@ #include "common/settings_setting.h" #include "common/time_zone.h" #include "yuzu/uisettings.h" -#include -#include -#include -#include namespace ConfigurationShared { -std::unique_ptr InitializeTranslations(QWidget* parent) -{ +std::unique_ptr InitializeTranslations(QWidget* parent) { std::unique_ptr translations = std::make_unique(); const auto& tr = [parent](const char* text) -> QString { return parent->tr(text); }; -#define INSERT(SETTINGS, ID, NAME, TOOLTIP) \ +#define INSERT(SETTINGS, ID, NAME, TOOLTIP) \ translations->insert(std::pair{SETTINGS::values.ID.Id(), std::pair{(NAME), (TOOLTIP)}}) // A setting can be ignored by giving it a blank name @@ -61,56 +60,44 @@ std::unique_ptr InitializeTranslations(QWidget* parent) // Core INSERT( - Settings, - use_multi_core, - tr("Multicore CPU Emulation"), + Settings, use_multi_core, tr("Multicore CPU Emulation"), tr("This option increases CPU emulation thread use from 1 to the Switch’s maximum of 4.\n" "This is mainly a debug option and shouldn’t be disabled.")); INSERT( - Settings, - memory_layout_mode, - tr("Memory Layout"), + Settings, memory_layout_mode, tr("Memory Layout"), tr("Increases the amount of emulated RAM from the stock 4GB of the retail Switch to the " "developer kit's 8/6GB.\nIt’s doesn’t improve stability or performance and is intended " "to let big texture mods fit in emulated RAM.\nEnabling it will increase memory " "use. It is not recommended to enable unless a specific game with a texture mod needs " "it.")); INSERT(Settings, use_speed_limit, QString(), QString()); - INSERT(Settings, - speed_limit, - tr("Limit Speed Percent"), + INSERT(Settings, speed_limit, tr("Limit Speed Percent"), tr("Controls the game's maximum rendering speed, but it’s up to each game if it runs " "faster or not.\n200% for a 30 FPS game is 60 FPS, and for a " "60 FPS game it will be 120 FPS.\nDisabling it means unlocking the framerate to the " "maximum your PC can reach.")); - INSERT(Settings, - sync_core_speed, - tr("Synchronize Core Speed"), + INSERT(Settings, sync_core_speed, tr("Synchronize Core Speed"), tr("Synchronizes CPU core speed with the game's maximum rendering speed to boost FPS " "without affecting game speed (animations, physics, etc.).\n" "Compatibility varies by game; many (especially older ones) may not respond well.\n" "Can help reduce stuttering at lower framerates.")); // Cpu - INSERT(Settings, - cpu_accuracy, - tr("Accuracy:"), + INSERT(Settings, cpu_accuracy, tr("Accuracy:"), tr("This setting controls the accuracy of the emulated CPU.\nDon't change this unless " "you know what you are doing.")); INSERT(Settings, cpu_backend, tr("Backend:"), QString()); INSERT(Settings, use_fast_cpu_time, QString(), QString()); - INSERT(Settings, - fast_cpu_time, - tr("Fast CPU Time"), - tr("Overclocks the emulated CPU to remove some FPS limiters. Weaker CPUs may see reduced performance, " - "and certain games may behave improperly.\nUse Boost (1700MHz) to run at the Switch's highest native " + INSERT(Settings, fast_cpu_time, tr("Fast CPU Time"), + tr("Overclocks the emulated CPU to remove some FPS limiters. Weaker CPUs may see " + "reduced performance, " + "and certain games may behave improperly.\nUse Boost (1700MHz) to run at the " + "Switch's highest native " "clock, or Fast (2000MHz) to run at 2x clock.")); INSERT(Settings, use_custom_cpu_ticks, QString(), QString()); - INSERT(Settings, - cpu_ticks, - tr("Custom CPU Ticks"), + INSERT(Settings, cpu_ticks, tr("Custom CPU Ticks"), tr("Set a custom value of CPU ticks. Higher values can increase performance, but may " "also cause the game to freeze. A range of 77–21000 is recommended.")); INSERT(Settings, cpu_backend, tr("Backend:"), QString()); @@ -119,115 +106,79 @@ std::unique_ptr InitializeTranslations(QWidget* parent) // Cpu Unsafe INSERT( - Settings, - cpuopt_unsafe_unfuse_fma, + Settings, cpuopt_unsafe_unfuse_fma, tr("Unfuse FMA (improve performance on CPUs without FMA)"), tr("This option improves speed by reducing accuracy of fused-multiply-add instructions on " "CPUs without native FMA support.")); INSERT( - Settings, - cpuopt_unsafe_reduce_fp_error, - tr("Faster FRSQRTE and FRECPE"), + Settings, cpuopt_unsafe_reduce_fp_error, tr("Faster FRSQRTE and FRECPE"), tr("This option improves the speed of some approximate floating-point functions by using " "less accurate native approximations.")); - INSERT(Settings, - cpuopt_unsafe_ignore_standard_fpcr, + INSERT(Settings, cpuopt_unsafe_ignore_standard_fpcr, tr("Faster ASIMD instructions (32 bits only)"), tr("This option improves the speed of 32 bits ASIMD floating-point functions by running " "with incorrect rounding modes.")); - INSERT(Settings, - cpuopt_unsafe_inaccurate_nan, - tr("Inaccurate NaN handling"), + INSERT(Settings, cpuopt_unsafe_inaccurate_nan, tr("Inaccurate NaN handling"), tr("This option improves speed by removing NaN checking.\nPlease note this also reduces " "accuracy of certain floating-point instructions.")); - INSERT(Settings, - cpuopt_unsafe_fastmem_check, - tr("Disable address space checks"), + INSERT(Settings, cpuopt_unsafe_fastmem_check, tr("Disable address space checks"), tr("This option improves speed by eliminating a safety check before every memory " "read/write in guest.\nDisabling it may allow a game to read/write the emulator's " "memory.")); INSERT( - Settings, - cpuopt_unsafe_ignore_global_monitor, - tr("Ignore global monitor"), + Settings, cpuopt_unsafe_ignore_global_monitor, tr("Ignore global monitor"), tr("This option improves speed by relying only on the semantics of cmpxchg to ensure " "safety of exclusive access instructions.\nPlease note this may result in deadlocks and " "other race conditions.")); // Renderer INSERT( - Settings, - renderer_backend, - tr("API:"), + Settings, renderer_backend, tr("API:"), tr("Switches between the available graphics APIs.\nVulkan is recommended in most cases.")); - INSERT(Settings, - vulkan_device, - tr("Device:"), + INSERT(Settings, vulkan_device, tr("Device:"), tr("This setting selects the GPU to use with the Vulkan backend.")); - INSERT(Settings, - shader_backend, - tr("Shader Backend:"), + INSERT(Settings, shader_backend, tr("Shader Backend:"), tr("The shader backend to use for the OpenGL renderer.\nGLSL is the fastest in " "performance and the best in rendering accuracy.\n" "GLASM is a deprecated NVIDIA-only backend that offers much better shader building " "performance at the cost of FPS and rendering accuracy.\n" "SPIR-V compiles the fastest, but yields poor results on most GPU drivers.")); - INSERT(Settings, - resolution_setup, - tr("Resolution:"), + INSERT(Settings, resolution_setup, tr("Resolution:"), tr("Forces the game to render at a different resolution.\nHigher resolutions require " "much more VRAM and bandwidth.\n" "Options lower than 1X can cause rendering issues.")); INSERT(Settings, scaling_filter, tr("Window Adapting Filter:"), QString()); - INSERT(Settings, - fsr_sharpening_slider, - tr("FSR Sharpness:"), + INSERT(Settings, fsr_sharpening_slider, tr("FSR Sharpness:"), tr("Determines how sharpened the image will look while using FSR’s dynamic contrast.")); - INSERT(Settings, - anti_aliasing, - tr("Anti-Aliasing Method:"), + INSERT(Settings, anti_aliasing, tr("Anti-Aliasing Method:"), tr("The anti-aliasing method to use.\nSMAA offers the best quality.\nFXAA has a " "lower performance impact and can produce a better and more stable picture under " "very low resolutions.")); - INSERT(Settings, - fullscreen_mode, - tr("Fullscreen Mode:"), + INSERT(Settings, fullscreen_mode, tr("Fullscreen Mode:"), tr("The method used to render the window in fullscreen.\nBorderless offers the best " "compatibility with the on-screen keyboard that some games request for " "input.\nExclusive " "fullscreen may offer better performance and better Freesync/Gsync support.")); - INSERT(Settings, - aspect_ratio, - tr("Aspect Ratio:"), + INSERT(Settings, aspect_ratio, tr("Aspect Ratio:"), tr("Stretches the game to fit the specified aspect ratio.\nSwitch games only support " "16:9, so custom game mods are required to get other ratios.\nAlso controls the " "aspect ratio of captured screenshots.")); - INSERT(Settings, - use_disk_shader_cache, - tr("Use disk pipeline cache"), + INSERT(Settings, use_disk_shader_cache, tr("Use disk pipeline cache"), tr("Allows saving shaders to storage for faster loading on following game " "boots.\nDisabling " "it is only intended for debugging.")); - INSERT(Settings, - optimize_spirv_output, - tr("Optimize SPIRV output shader"), + INSERT(Settings, optimize_spirv_output, tr("Optimize SPIRV output shader"), tr("Runs an additional optimization pass over generated SPIRV shaders.\n" "Will increase time required for shader compilation.\nMay slightly improve " "performance.\nThis feature is experimental.")); INSERT( - Settings, - use_asynchronous_gpu_emulation, - tr("Use asynchronous GPU emulation"), + Settings, use_asynchronous_gpu_emulation, tr("Use asynchronous GPU emulation"), tr("Uses an extra CPU thread for rendering.\nThis option should always remain enabled.")); - INSERT(Settings, - nvdec_emulation, - tr("NVDEC emulation:"), + INSERT(Settings, nvdec_emulation, tr("NVDEC emulation:"), tr("Specifies how videos should be decoded.\nIt can either use the CPU or the GPU for " "decoding, or perform no decoding at all (black screen on videos).\n" "In most cases, GPU decoding provides the best performance.")); - INSERT(Settings, - accelerate_astc, - tr("ASTC Decoding Method:"), + INSERT(Settings, accelerate_astc, tr("ASTC Decoding Method:"), tr("This option controls how ASTC textures should be decoded.\n" "CPU: Use the CPU for decoding, slowest but safest method.\n" "GPU: Use the GPU's compute shaders to decode ASTC textures, recommended for most " @@ -236,29 +187,22 @@ std::unique_ptr InitializeTranslations(QWidget* parent) "eliminates ASTC decoding\nstuttering at the cost of rendering issues while the " "texture is being decoded.")); INSERT( - Settings, - astc_recompression, - tr("ASTC Recompression Method:"), + Settings, astc_recompression, tr("ASTC Recompression Method:"), tr("Almost all desktop and laptop dedicated GPUs lack support for ASTC textures, forcing " "the emulator to decompress to an intermediate format any card supports, RGBA8.\n" "This option recompresses RGBA8 to either the BC1 or BC3 format, saving VRAM but " "negatively affecting image quality.")); - INSERT(Settings, - vram_usage_mode, - tr("VRAM Usage Mode:"), + INSERT(Settings, vram_usage_mode, tr("VRAM Usage Mode:"), tr("Selects whether the emulator should prefer to conserve memory or make maximum usage " "of available video memory for performance. Has no effect on integrated graphics. " "Aggressive mode may severely impact the performance of other applications such as " "recording software.")); - INSERT(Settings, - skip_cpu_inner_invalidation, - tr("Skip CPU Inner Invalidation"), - tr("Skips certain CPU-side cache invalidations during memory updates, reducing CPU usage and " + INSERT(Settings, skip_cpu_inner_invalidation, tr("Skip CPU Inner Invalidation"), + tr("Skips certain CPU-side cache invalidations during memory updates, reducing CPU " + "usage and " "improving it's performance. This may cause glitches or crashes on some games.")); INSERT( - Settings, - vsync_mode, - tr("VSync Mode:"), + Settings, vsync_mode, tr("VSync Mode:"), tr("FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen " "refresh rate.\nFIFO Relaxed is similar to FIFO but allows tearing as it recovers from " "a slow down.\nMailbox can have lower latency than FIFO and does not tear but may drop " @@ -269,134 +213,94 @@ std::unique_ptr InitializeTranslations(QWidget* parent) INSERT(Settings, bg_blue, QString(), QString()); // Renderer (Advanced Graphics) - INSERT(Settings, - async_presentation, - tr("Enable asynchronous presentation (Vulkan only)"), + INSERT(Settings, async_presentation, tr("Enable asynchronous presentation (Vulkan only)"), tr("Slightly improves performance by moving presentation to a separate CPU thread.")); INSERT( - Settings, - renderer_force_max_clock, - tr("Force maximum clocks (Vulkan only)"), + Settings, renderer_force_max_clock, tr("Force maximum clocks (Vulkan only)"), tr("Runs work in the background while waiting for graphics commands to keep the GPU from " "lowering its clock speed.")); - INSERT(Settings, - max_anisotropy, - tr("Anisotropic Filtering:"), + INSERT(Settings, max_anisotropy, tr("Anisotropic Filtering:"), tr("Controls the quality of texture rendering at oblique angles.\nIt’s a light setting " "and safe to set at 16x on most GPUs.")); - INSERT(Settings, - gpu_accuracy, - tr("Accuracy Level:"), + INSERT(Settings, gpu_accuracy, tr("Accuracy Level:"), tr("GPU emulation accuracy.\nMost games render fine with Normal, but High is still " "required for some.\nParticles tend to only render correctly with High " "accuracy.\nExtreme should only be used for debugging.\nThis option can " "be changed while playing.\nSome games may require booting on high to render " "properly.")); - INSERT(Settings, - use_asynchronous_shaders, - tr("Use asynchronous shader building (Hack)"), + INSERT(Settings, use_asynchronous_shaders, tr("Use asynchronous shader building (Hack)"), tr("Enables asynchronous shader compilation, which may reduce shader stutter.\nThis " "feature " "is experimental.")); INSERT(Settings, use_fast_gpu_time, QString(), QString()); - INSERT(Settings, - fast_gpu_time, - tr("Fast GPU Time (Hack)"), + INSERT(Settings, fast_gpu_time, tr("Fast GPU Time (Hack)"), tr("Overclocks the emulated GPU to increase dynamic resolution and render " "distance.\nUse 128 for maximal performance and 512 for maximal graphics fidelity.")); - INSERT(Settings, - use_vulkan_driver_pipeline_cache, - tr("Use Vulkan pipeline cache"), + INSERT(Settings, use_vulkan_driver_pipeline_cache, tr("Use Vulkan pipeline cache"), tr("Enables GPU vendor-specific pipeline cache.\nThis option can improve shader loading " "time significantly in cases where the Vulkan driver does not store pipeline cache " "files internally.")); INSERT( - Settings, - enable_compute_pipelines, - tr("Enable Compute Pipelines (Intel Vulkan Only)"), + Settings, enable_compute_pipelines, tr("Enable Compute Pipelines (Intel Vulkan Only)"), tr("Enable compute pipelines, required by some games.\nThis setting only exists for Intel " "proprietary drivers, and may crash if enabled.\nCompute pipelines are always enabled " "on all other drivers.")); INSERT( - Settings, - use_reactive_flushing, - tr("Enable Reactive Flushing"), + Settings, use_reactive_flushing, tr("Enable Reactive Flushing"), tr("Uses reactive flushing instead of predictive flushing, allowing more accurate memory " "syncing.")); - INSERT(Settings, - use_video_framerate, - tr("Sync to framerate of video playback"), + INSERT(Settings, use_video_framerate, tr("Sync to framerate of video playback"), tr("Run the game at normal speed during video playback, even when the framerate is " "unlocked.")); - INSERT(Settings, - barrier_feedback_loops, - tr("Barrier feedback loops"), + INSERT(Settings, barrier_feedback_loops, tr("Barrier feedback loops"), tr("Improves rendering of transparency effects in specific games.")); // Renderer (Extensions) - INSERT(Settings, - enable_raii, - tr("RAII"), + INSERT(Settings, enable_raii, tr("RAII"), tr("A method of automatic resource management in Vulkan " "that ensures proper release of resources " "when they are no longer needed, but may cause crashes in bundled games.")); - INSERT(Settings, - dyna_state, - tr("Extended Dynamic State"), + INSERT(Settings, dyna_state, tr("Extended Dynamic State"), tr("Enables the VkExtendedDynamicState* extensions.\nHigher dynamic states will " "generally improve " "performance, but may cause issues on certain games or devices.")); - INSERT(Settings, - provoking_vertex, - tr("Provoking Vertex"), + INSERT(Settings, provoking_vertex, tr("Provoking Vertex"), tr("Improves lighting and vertex handling in certain games.\n" "Only Vulkan 1.0+ devices support this extension.")); - INSERT(Settings, - descriptor_indexing, - tr("Descriptor Indexing"), + INSERT(Settings, descriptor_indexing, tr("Descriptor Indexing"), tr("Improves texture & buffer handling and the Maxwell translation layer.\n" "Some Vulkan 1.1+ and all 1.2+ devices support this extension.")); - INSERT(Settings, - sample_shading, - tr("Sample Shading"), - tr("Allows the fragment shader to execute per sample in a multi-sampled fragment " - "instead once per fragment. Improves graphics quality at the cost of some performance.\n" - "Only Vulkan 1.1+ devices support this extension.")); + INSERT( + Settings, sample_shading, tr("Sample Shading"), + tr("Allows the fragment shader to execute per sample in a multi-sampled fragment " + "instead once per fragment. Improves graphics quality at the cost of some performance.\n" + "Only Vulkan 1.1+ devices support this extension.")); // Renderer (Debug) // System - INSERT(Settings, - rng_seed, - tr("RNG Seed"), + INSERT(Settings, rng_seed, tr("RNG Seed"), tr("Controls the seed of the random number generator.\nMainly used for speedrunning " "purposes.")); INSERT(Settings, rng_seed_enabled, QString(), QString()); INSERT(Settings, device_name, tr("Device Name"), tr("The name of the emulated Switch.")); - INSERT(Settings, - custom_rtc, - tr("Custom RTC Date:"), + INSERT(Settings, custom_rtc, tr("Custom RTC Date:"), tr("This option allows to change the emulated clock of the Switch.\n" "Can be used to manipulate time in games.")); INSERT(Settings, custom_rtc_enabled, QString(), QString()); - INSERT(Settings, - custom_rtc_offset, - QStringLiteral(" "), + INSERT(Settings, custom_rtc_offset, QStringLiteral(" "), QStringLiteral("The number of seconds from the current unix time")); - INSERT(Settings, - language_index, - tr("Language:"), + INSERT(Settings, language_index, tr("Language:"), tr("Note: this can be overridden when region setting is auto-select")); INSERT(Settings, region_index, tr("Region:"), tr("The region of the emulated Switch.")); - INSERT(Settings, time_zone_index, tr("Time Zone:"), tr("The time zone of the emulated Switch.")); + INSERT(Settings, time_zone_index, tr("Time Zone:"), + tr("The time zone of the emulated Switch.")); INSERT(Settings, sound_index, tr("Sound Output Mode:"), QString()); - INSERT(Settings, - use_docked_mode, - tr("Console Mode:"), + INSERT(Settings, use_docked_mode, tr("Console Mode:"), tr("Selects if the console is emulated in Docked or Handheld mode.\nGames will change " "their resolution, details and supported controllers and depending on this setting.\n" "Setting to Handheld can help improve performance for low end systems.")); @@ -417,32 +321,20 @@ std::unique_ptr InitializeTranslations(QWidget* parent) // Ui // Ui General - INSERT(UISettings, - select_user_on_boot, - tr("Prompt for user on game boot"), + INSERT(UISettings, select_user_on_boot, tr("Prompt for user on game boot"), tr("Ask to select a user profile on each boot, useful if multiple people use eden on " "the same PC.")); - INSERT(UISettings, - pause_when_in_background, - tr("Pause emulation when in background"), + INSERT(UISettings, pause_when_in_background, tr("Pause emulation when in background"), tr("This setting pauses eden when focusing other windows.")); - INSERT(UISettings, - confirm_before_stopping, - tr("Confirm before stopping emulation"), + INSERT(UISettings, confirm_before_stopping, tr("Confirm before stopping emulation"), tr("This setting overrides game prompts asking to confirm stopping the game.\nEnabling " "it bypasses such prompts and directly exits the emulation.")); - INSERT(UISettings, - hide_mouse, - tr("Hide mouse on inactivity"), + INSERT(UISettings, hide_mouse, tr("Hide mouse on inactivity"), tr("This setting hides the mouse after 2.5s of inactivity.")); - INSERT(UISettings, - controller_applet_disabled, - tr("Disable controller applet"), + INSERT(UISettings, controller_applet_disabled, tr("Disable controller applet"), tr("Forcibly disables the use of the controller applet by guests.\nWhen a guest " "attempts to open the controller applet, it is immediately closed.")); - INSERT(UISettings, - check_for_updates, - tr("Check for updates"), + INSERT(UISettings, check_for_updates, tr("Check for updates"), tr("Whether or not to check for updates upon startup.")); // Linux @@ -459,9 +351,9 @@ std::unique_ptr InitializeTranslations(QWidget* parent) return translations; } -std::unique_ptr ComboboxEnumeration(QWidget* parent) -{ - std::unique_ptr translations = std::make_unique(); +std::unique_ptr ComboboxEnumeration(QWidget* parent) { + std::unique_ptr translations = + std::make_unique(); const auto& tr = [&](const char* text, const char* context = "") { return parent->tr(text, context); }; diff --git a/src/yuzu/configuration/shared_widget.cpp b/src/yuzu/configuration/shared_widget.cpp index c27a4644e9..5d75daa4f5 100644 --- a/src/yuzu/configuration/shared_widget.cpp +++ b/src/yuzu/configuration/shared_widget.cpp @@ -693,13 +693,13 @@ void Widget::SetupComponent(const QString& label, std::function& load_fu } if (other_setting != nullptr) { - const auto reset = [restore_func, data_component](int state) { + const auto reset = [restore_func, data_component](Qt::CheckState state) { data_component->setEnabled(state == Qt::Checked); if (state != Qt::Checked) { restore_func(); } }; - connect(checkbox, &QCheckBox::stateChanged, reset); + connect(checkbox, &QCheckBox::checkStateChanged, reset); reset(checkbox->checkState()); } } @@ -767,8 +767,8 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati Builder::Builder(QWidget* parent_, bool runtime_lock_) : translations{InitializeTranslations(parent_)}, - combobox_translations{ComboboxEnumeration(parent_)}, parent{parent_}, runtime_lock{ - runtime_lock_} {} + combobox_translations{ComboboxEnumeration(parent_)}, parent{parent_}, + runtime_lock{runtime_lock_} {} Builder::~Builder() = default; diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 80dd90d876..fe87a90aaf 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -820,8 +820,7 @@ QStandardItemModel* GameList::GetModel() const { return item_model; } -void GameList::PopulateAsync(QVector& game_dirs, const bool cached) -{ +void GameList::PopulateAsync(QVector& game_dirs, const bool cached) { tree_view->setEnabled(false); // Update the columns in case UISettings has changed @@ -838,13 +837,8 @@ void GameList::PopulateAsync(QVector& game_dirs, const bool item_model->removeRows(0, item_model->rowCount()); search_field->clear(); - current_worker = std::make_unique(vfs, - provider, - game_dirs, - compatibility_list, - play_time_manager, - system, - cached); + current_worker = std::make_unique(vfs, provider, game_dirs, compatibility_list, + play_time_manager, system, cached); // Get events from the worker as data becomes available connect(current_worker.get(), &GameListWorker::DataAvailable, this, &GameList::WorkerEvent, @@ -873,16 +867,14 @@ const QStringList GameList::supported_file_extensions = { QStringLiteral("nso"), QStringLiteral("nro"), QStringLiteral("nca"), QStringLiteral("xci"), QStringLiteral("nsp"), QStringLiteral("kip")}; -void GameList::ForceRefreshGameDirectory() -{ +void GameList::ForceRefreshGameDirectory() { if (!UISettings::values.game_dirs.empty() && current_worker != nullptr) { LOG_INFO(Frontend, "Force-reloading game list per user request."); PopulateAsync(UISettings::values.game_dirs, false); } } -void GameList::RefreshGameDirectory() -{ +void GameList::RefreshGameDirectory() { if (!UISettings::values.game_dirs.empty() && current_worker != nullptr) { LOG_INFO(Frontend, "Change detected in the games directory. Reloading game list."); PopulateAsync(UISettings::values.game_dirs); diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index 60109769bf..a0f53f25dc 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp @@ -191,17 +191,12 @@ QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager, return out; } -QList MakeGameListEntry(const std::string& path, - const std::string& name, - const std::size_t size, - const std::vector& icon, - Loader::AppLoader& loader, - u64 program_id, +QList MakeGameListEntry(const std::string& path, const std::string& name, + const std::size_t size, const std::vector& icon, + Loader::AppLoader& loader, u64 program_id, const CompatibilityList& compatibility_list, const PlayTime::PlayTimeManager& play_time_manager, - const FileSys::PatchManager& patch, - const bool cached) -{ + const FileSys::PatchManager& patch, const bool cached) { const auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); // The game list uses this as compatibility number for untested games @@ -244,16 +239,10 @@ GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs_, QVector& game_dirs_, const CompatibilityList& compatibility_list_, const PlayTime::PlayTimeManager& play_time_manager_, - Core::System& system_, - const bool cached_) - : vfs{std::move(vfs_)} - , provider{provider_} - , game_dirs{game_dirs_} - , compatibility_list{compatibility_list_} - , play_time_manager{play_time_manager_} - , system{system_} - , cached{cached_} -{ + Core::System& system_, const bool cached_) + : vfs{std::move(vfs_)}, provider{provider_}, game_dirs{game_dirs_}, + compatibility_list{compatibility_list_}, play_time_manager{play_time_manager_}, + system{system_}, cached{cached_} { // We want the game list to manage our lifetime. setAutoDelete(false); } @@ -347,16 +336,9 @@ void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) { GetMetadataFromControlNCA(patch, *control, icon, name); } - auto entry = MakeGameListEntry(file->GetFullPath(), - name, - file->GetSize(), - icon, - *loader, - program_id, - compatibility_list, - play_time_manager, - patch, - cached); + auto entry = + MakeGameListEntry(file->GetFullPath(), name, file->GetSize(), icon, *loader, program_id, + compatibility_list, play_time_manager, patch, cached); RecordEvent([=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); }); } } @@ -431,16 +413,9 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa const FileSys::PatchManager patch{id, system.GetFileSystemController(), system.GetContentProvider()}; - auto entry = MakeGameListEntry(physical_name, - name, - Common::FS::GetSize(physical_name), - icon, - *loader, - id, - compatibility_list, - play_time_manager, - patch, - cached); + auto entry = MakeGameListEntry( + physical_name, name, Common::FS::GetSize(physical_name), icon, *loader, + id, compatibility_list, play_time_manager, patch, cached); RecordEvent( [=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); }); @@ -455,16 +430,9 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa const FileSys::PatchManager patch{program_id, system.GetFileSystemController(), system.GetContentProvider()}; - auto entry = MakeGameListEntry(physical_name, - name, - Common::FS::GetSize(physical_name), - icon, - *loader, - program_id, - compatibility_list, - play_time_manager, - patch, - cached); + auto entry = MakeGameListEntry( + physical_name, name, Common::FS::GetSize(physical_name), icon, *loader, + program_id, compatibility_list, play_time_manager, patch, cached); RecordEvent( [=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); }); diff --git a/src/yuzu/game_list_worker.h b/src/yuzu/game_list_worker.h index 0afd7c7849..ab068fd587 100644 --- a/src/yuzu/game_list_worker.h +++ b/src/yuzu/game_list_worker.h @@ -45,8 +45,7 @@ public: QVector& game_dirs_, const CompatibilityList& compatibility_list_, const PlayTime::PlayTimeManager& play_time_manager_, - Core::System& system_, - const bool cached = true); + Core::System& system_, const bool cached = true); ~GameListWorker() override; /// Starts the processing of directory tree information. diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 7e7c00ec0b..4e640d6c23 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -608,12 +608,9 @@ private: std::filesystem::path GetEdenCommand(); - void CreateShortcut(const std::string& game_path, - const u64 program_id, - const std::string& game_title, - GameListShortcutTarget target, - std::string arguments, - const bool needs_title); + void CreateShortcut(const std::string& game_path, const u64 program_id, + const std::string& game_title, GameListShortcutTarget target, + std::string arguments, const bool needs_title); void InstallFirmware(const QString& location, bool recursive = false); diff --git a/src/yuzu/migration_dialog.cpp b/src/yuzu/migration_dialog.cpp index 9cc40841e8..d7f2d6132f 100644 --- a/src/yuzu/migration_dialog.cpp +++ b/src/yuzu/migration_dialog.cpp @@ -6,11 +6,8 @@ #include #include -MigrationDialog::MigrationDialog( - QWidget *parent) - : QDialog(parent) -{ - QVBoxLayout *layout = new QVBoxLayout(this); +MigrationDialog::MigrationDialog(QWidget* parent) : QDialog(parent) { + QVBoxLayout* layout = new QVBoxLayout(this); m_text = new QLabel(this); m_boxes = new QVBoxLayout; @@ -26,23 +23,16 @@ MigrationDialog::~MigrationDialog() { m_buttons->deleteLater(); } -void MigrationDialog::setText( - const QString &text) -{ +void MigrationDialog::setText(const QString& text) { m_text->setText(text); } -void MigrationDialog::addBox( - QWidget *box) -{ +void MigrationDialog::addBox(QWidget* box) { m_boxes->addWidget(box); - } -QAbstractButton *MigrationDialog::addButton( - const QString &text, const bool reject) -{ - QAbstractButton *button = new QPushButton(this); +QAbstractButton* MigrationDialog::addButton(const QString& text, const bool reject) { + QAbstractButton* button = new QPushButton(this); button->setText(text); m_buttons->addWidget(button, 1); @@ -58,7 +48,6 @@ QAbstractButton *MigrationDialog::addButton( return button; } -QAbstractButton *MigrationDialog::clickedButton() const -{ +QAbstractButton* MigrationDialog::clickedButton() const { return m_clickedButton; } diff --git a/src/yuzu/migration_dialog.h b/src/yuzu/migration_dialog.h index 7123fd6b87..02ad17d324 100644 --- a/src/yuzu/migration_dialog.h +++ b/src/yuzu/migration_dialog.h @@ -1,30 +1,30 @@ #ifndef MIGRATION_DIALOG_H #define MIGRATION_DIALOG_H -#include -#include #include +#include #include +#include class MigrationDialog : public QDialog { Q_OBJECT public: - MigrationDialog(QWidget *parent = nullptr); + MigrationDialog(QWidget* parent = nullptr); virtual ~MigrationDialog(); - void setText(const QString &text); - void addBox(QWidget *box); - QAbstractButton *addButton(const QString &text, const bool reject = false); + void setText(const QString& text); + void addBox(QWidget* box); + QAbstractButton* addButton(const QString& text, const bool reject = false); - QAbstractButton *clickedButton() const; + QAbstractButton* clickedButton() const; private: - QLabel *m_text; - QVBoxLayout *m_boxes; - QHBoxLayout *m_buttons; + QLabel* m_text; + QVBoxLayout* m_boxes; + QHBoxLayout* m_buttons; - QAbstractButton *m_clickedButton; + QAbstractButton* m_clickedButton; }; #endif // MIGRATION_DIALOG_H diff --git a/src/yuzu/migration_worker.cpp b/src/yuzu/migration_worker.cpp index 42ec006026..8507f50a95 100644 --- a/src/yuzu/migration_worker.cpp +++ b/src/yuzu/migration_worker.cpp @@ -3,41 +3,36 @@ #include "migration_worker.h" +#include #include #include #include -#include #include #include "common/fs/path_util.h" MigrationWorker::MigrationWorker(const Emulator selected_legacy_emu_, - const bool clear_shader_cache_, - const MigrationStrategy strategy_) - : QObject() - , selected_legacy_emu(selected_legacy_emu_) - , clear_shader_cache(clear_shader_cache_) - , strategy(strategy_) -{} + const bool clear_shader_cache_, const MigrationStrategy strategy_) + : QObject(), selected_legacy_emu(selected_legacy_emu_), clear_shader_cache(clear_shader_cache_), + strategy(strategy_) {} -void MigrationWorker::process() -{ +void MigrationWorker::process() { namespace fs = std::filesystem; constexpr auto copy_options = fs::copy_options::update_existing | fs::copy_options::recursive; - const fs::path legacy_user_dir = selected_legacy_emu.get_user_dir(); + const fs::path legacy_user_dir = selected_legacy_emu.get_user_dir(); const fs::path legacy_config_dir = selected_legacy_emu.get_config_dir(); - const fs::path legacy_cache_dir = selected_legacy_emu.get_cache_dir(); + const fs::path legacy_cache_dir = selected_legacy_emu.get_cache_dir(); // TODO(crueter): Make these constexpr since they're defaulted - const fs::path eden_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::EdenDir); + const fs::path eden_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::EdenDir); const fs::path config_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir); - const fs::path cache_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::CacheDir); + const fs::path cache_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::CacheDir); const fs::path shader_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir); try { fs::remove_all(eden_dir); - } catch (fs::filesystem_error &_) { + } catch (fs::filesystem_error& _) { // ignore because linux does stupid crap sometimes. } @@ -48,7 +43,7 @@ void MigrationWorker::process() // Windows 11 has random permission nonsense to deal with. try { fs::create_directory_symlink(legacy_user_dir, eden_dir); - } catch (const fs::filesystem_error &e) { + } catch (const fs::filesystem_error& e) { emit error(tr("Linking the old directory failed. You may need to re-run with " "administrative privileges on Windows.\nOS gave error: %1") .arg(tr(e.what()))); diff --git a/src/yuzu/migration_worker.h b/src/yuzu/migration_worker.h index 4d678e7751..1653a6eab4 100644 --- a/src/yuzu/migration_worker.h +++ b/src/yuzu/migration_worker.h @@ -10,7 +10,7 @@ using namespace Common::FS; typedef struct Emulator { - const char *name; + const char* name; LegacyPath e_user_dir; LegacyPath e_config_dir; @@ -31,13 +31,16 @@ typedef struct Emulator { const std::string lower_name() const { std::string lower_name{name}; std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(), - [](unsigned char c){ return std::tolower(c); }); + [](unsigned char c) { return std::tolower(c); }); return lower_name; } } Emulator; -#define EMU(name) Emulator{#name, name##Dir, name##ConfigDir, name##CacheDir} +#define EMU(name) \ + Emulator { \ + #name, name##Dir, name##ConfigDir, name##CacheDir \ + } static constexpr std::array legacy_emus = { EMU(Citron), EMU(Sudachi), @@ -46,8 +49,7 @@ static constexpr std::array legacy_emus = { }; #undef EMU -class MigrationWorker : public QObject -{ +class MigrationWorker : public QObject { Q_OBJECT public: enum class MigrationStrategy { @@ -56,16 +58,15 @@ public: Link, }; - MigrationWorker(const Emulator selected_legacy_emu, - const bool clear_shader_cache, + MigrationWorker(const Emulator selected_legacy_emu, const bool clear_shader_cache, const MigrationStrategy strategy); public slots: void process(); signals: - void finished(const QString &success_text, const std::string &user_dir); - void error(const QString &error_message); + void finished(const QString& success_text, const std::string& user_dir); + void error(const QString& error_message); private: Emulator selected_legacy_emu; diff --git a/src/yuzu/multiplayer/host_room.cpp b/src/yuzu/multiplayer/host_room.cpp index 6471ad1632..eb7dccbe8d 100644 --- a/src/yuzu/multiplayer/host_room.cpp +++ b/src/yuzu/multiplayer/host_room.cpp @@ -34,8 +34,7 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list, std::shared_ptr session, Core::System& system_) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), - ui(std::make_unique()), - announce_multiplayer_session(session), system{system_} { + ui(std::make_unique()), announce_multiplayer_session(session), system{system_} { ui->setupUi(this); // set up validation for all of the fields diff --git a/src/yuzu/multiplayer/lobby.cpp b/src/yuzu/multiplayer/lobby.cpp index 93ff56a652..214fb8b6d0 100644 --- a/src/yuzu/multiplayer/lobby.cpp +++ b/src/yuzu/multiplayer/lobby.cpp @@ -30,8 +30,7 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list, std::shared_ptr session, Core::System& system_) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), - ui(std::make_unique()), - announce_multiplayer_session(session), system{system_} { + ui(std::make_unique()), announce_multiplayer_session(session), system{system_} { ui->setupUi(this); // setup the watcher for background connections diff --git a/src/yuzu/update_checker.cpp b/src/yuzu/update_checker.cpp index 8291987d73..d1762f5ea6 100644 --- a/src/yuzu/update_checker.cpp +++ b/src/yuzu/update_checker.cpp @@ -5,16 +5,15 @@ // SPDX-FileCopyrightText: eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include "update_checker.h" -#include "common/logging/log.h" +#include +#include #include #include #include -#include -#include +#include "common/logging/log.h" +#include "update_checker.h" -std::optional UpdateChecker::GetResponse(std::string url, std::string path) -{ +std::optional UpdateChecker::GetResponse(std::string url, std::string path) { constexpr std::size_t timeout_seconds = 15; std::unique_ptr client = std::make_unique(url); @@ -41,7 +40,8 @@ std::optional UpdateChecker::GetResponse(std::string url, std::stri const auto& response = result.value(); if (response.status >= 400) { - LOG_ERROR(Frontend, "GET to {}{} returned error status code: {}", url, path, response.status); + LOG_ERROR(Frontend, "GET to {}{} returned error status code: {}", url, path, + response.status); return {}; } if (!response.headers.contains("content-type")) { @@ -52,8 +52,7 @@ std::optional UpdateChecker::GetResponse(std::string url, std::stri return response.body; } -std::optional UpdateChecker::GetLatestRelease(bool include_prereleases) -{ +std::optional UpdateChecker::GetLatestRelease(bool include_prereleases) { constexpr auto update_check_url = "http://api.github.com"; std::string update_check_path = "/repos/eden-emulator/Releases"; try { @@ -63,16 +62,17 @@ std::optional UpdateChecker::GetLatestRelease(bool include_prerelea const auto update_check_releases_path = update_check_path + "/releases"; const auto tags_response = GetResponse(update_check_url, update_check_tags_path); - const auto releases_response = GetResponse(update_check_url, update_check_releases_path); + const auto releases_response = + GetResponse(update_check_url, update_check_releases_path); if (!tags_response || !releases_response) return {}; - const std::string latest_tag - = nlohmann::json::parse(tags_response.value()).at(0).at("name"); - const bool latest_tag_has_release = releases_response.value().find( - fmt::format("\"{}\"", latest_tag)) - != std::string::npos; + const std::string latest_tag = + nlohmann::json::parse(tags_response.value()).at(0).at("name"); + const bool latest_tag_has_release = + releases_response.value().find(fmt::format("\"{}\"", latest_tag)) != + std::string::npos; // If there is a newer tag, but that tag has no associated release, don't prompt the // user to update. @@ -95,15 +95,13 @@ std::optional UpdateChecker::GetLatestRelease(bool include_prerelea LOG_ERROR(Frontend, "Parsing JSON response from {}{} failed during update check: " "nlohmann::detail::out_of_range", - update_check_url, - update_check_path); + update_check_url, update_check_path); return {}; } catch (nlohmann::detail::type_error&) { LOG_ERROR(Frontend, "Parsing JSON response from {}{} failed during update check: " "nlohmann::detail::type_error", - update_check_url, - update_check_path); + update_check_url, update_check_path); return {}; } } diff --git a/src/yuzu/user_data_migration.cpp b/src/yuzu/user_data_migration.cpp index df6b7be434..662ae3f5bf 100644 --- a/src/yuzu/user_data_migration.cpp +++ b/src/yuzu/user_data_migration.cpp @@ -5,66 +5,65 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "user_data_migration.h" #include #include #include #include #include "common/fs/path_util.h" #include "migration_dialog.h" +#include "user_data_migration.h" // Needs to be included at the end due to https://bugreports.qt.io/browse/QTBUG-73263 +#include #include #include #include #include #include #include -#include namespace fs = std::filesystem; -UserDataMigrator::UserDataMigrator(QMainWindow *main_window) -{ +UserDataMigrator::UserDataMigrator(QMainWindow* main_window) { // NOTE: Logging is not initialized yet, do not produce logs here. // Check migration if config directory does not exist - // TODO: ProfileManager messes with us a bit here, and force-creates the /nand/system/save/8000000000000010/su/avators/profiles.dat - // file. Find a way to reorder operations and have it create after this guy runs. + // TODO: ProfileManager messes with us a bit here, and force-creates the + // /nand/system/save/8000000000000010/su/avators/profiles.dat file. Find a way to reorder + // operations and have it create after this guy runs. if (!fs::is_directory(Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir))) { ShowMigrationPrompt(main_window); } } -void UserDataMigrator::ShowMigrationPrompt(QMainWindow *main_window) -{ +void UserDataMigrator::ShowMigrationPrompt(QMainWindow* main_window) { namespace fs = std::filesystem; // define strings here for easy access - static constexpr const char *prompt_prefix_text - = "Eden has detected user data for the following emulators:"; + static constexpr const char* prompt_prefix_text = + "Eden has detected user data for the following emulators:"; - static constexpr const char *migration_prompt_message - = "Would you like to migrate your data for use in Eden?\n" - "Select the corresponding button to migrate data from that emulator.\n" - "This may take a while."; + static constexpr const char* migration_prompt_message = + "Would you like to migrate your data for use in Eden?\n" + "Select the corresponding button to migrate data from that emulator.\n" + "This may take a while."; - static constexpr const char *clear_shader_tooltip - = "Clearing shader cache is recommended for all " - "users.\nDo not uncheck unless you know what " - "you're doing."; + static constexpr const char* clear_shader_tooltip = + "Clearing shader cache is recommended for all " + "users.\nDo not uncheck unless you know what " + "you're doing."; - static constexpr const char *keep_old_data_tooltip - = "Keeps the old data directory. This is recommended if you aren't\n" - "space-constrained and want to keep separate data for the old emulator."; + static constexpr const char* keep_old_data_tooltip = + "Keeps the old data directory. This is recommended if you aren't\n" + "space-constrained and want to keep separate data for the old emulator."; - static constexpr const char *clear_old_data_tooltip - = "Deletes the old data directory.\nThis is recommended on " - "devices with space constraints."; + static constexpr const char* clear_old_data_tooltip = + "Deletes the old data directory.\nThis is recommended on " + "devices with space constraints."; - static constexpr const char *link_old_dir_tooltip - = "Creates a filesystem link between the old directory and Eden directory.\n" - "This is recommended if you want to share data between emulators."; + static constexpr const char* link_old_dir_tooltip = + "Creates a filesystem link between the old directory and Eden directory.\n" + "This is recommended if you want to share data between emulators."; // actual migration code @@ -72,23 +71,23 @@ void UserDataMigrator::ShowMigrationPrompt(QMainWindow *main_window) migration_prompt.setWindowTitle(QObject::tr("Migration")); // mutually exclusive - QButtonGroup *group = new QButtonGroup(&migration_prompt); + QButtonGroup* group = new QButtonGroup(&migration_prompt); // MACRO MADNESS -#define BUTTON(clazz, name, text, tooltip, checkState) \ - clazz *name = new clazz(&migration_prompt); \ - name->setText(QObject::tr(text)); \ - name->setToolTip(QObject::tr(tooltip)); \ - name->setChecked(checkState); \ +#define BUTTON(clazz, name, text, tooltip, checkState) \ + clazz* name = new clazz(&migration_prompt); \ + name->setText(QObject::tr(text)); \ + name->setToolTip(QObject::tr(tooltip)); \ + name->setChecked(checkState); \ migration_prompt.addBox(name); BUTTON(QCheckBox, clear_shaders, "Clear Shader Cache", clear_shader_tooltip, true) u32 id = 0; -#define RADIO(name, text, tooltip, checkState) \ - BUTTON(QRadioButton, name, text, tooltip, checkState) \ +#define RADIO(name, text, tooltip, checkState) \ + BUTTON(QRadioButton, name, text, tooltip, checkState) \ group->addButton(name, ++id); RADIO(keep_old, "Keep Old Data", keep_old_data_tooltip, true) @@ -100,7 +99,7 @@ void UserDataMigrator::ShowMigrationPrompt(QMainWindow *main_window) std::vector found{}; - for (const Emulator &emu : legacy_emus) + for (const Emulator& emu : legacy_emus) if (fs::is_directory(emu.get_user_dir())) found.emplace_back(emu); @@ -114,10 +113,10 @@ void UserDataMigrator::ShowMigrationPrompt(QMainWindow *main_window) QString prompt_text = QObject::tr(prompt_prefix_text); // natural language processing is a nightmare - for (const Emulator &emu : found) { + for (const Emulator& emu : found) { prompt_text.append(QStringLiteral("\n- %1").arg(QObject::tr(emu.name))); - QAbstractButton *button = migration_prompt.addButton(QObject::tr(emu.name)); + QAbstractButton* button = migration_prompt.addButton(QObject::tr(emu.name)); // This is cursed, but it's actually the most efficient way by a mile button->setProperty("emulator", QVariant::fromValue(emu)); @@ -131,7 +130,7 @@ void UserDataMigrator::ShowMigrationPrompt(QMainWindow *main_window) migration_prompt.exec(); - QAbstractButton *button = migration_prompt.clickedButton(); + QAbstractButton* button = migration_prompt.clickedButton(); if (button->text() == QObject::tr("No")) { return ShowMigrationCancelledMessage(main_window); @@ -153,16 +152,12 @@ void UserDataMigrator::ShowMigrationPrompt(QMainWindow *main_window) break; } - MigrateUserData(main_window, - button->property("emulator").value(), - clear_shaders->isChecked(), - strategy); + MigrateUserData(main_window, button->property("emulator").value(), + clear_shaders->isChecked(), strategy); } -void UserDataMigrator::ShowMigrationCancelledMessage(QMainWindow *main_window) -{ - QMessageBox::information(main_window, - QObject::tr("Migration"), +void UserDataMigrator::ShowMigrationCancelledMessage(QMainWindow* main_window) { + QMessageBox::information(main_window, QObject::tr("Migration"), QObject::tr("You can manually re-trigger this prompt by deleting the " "new config directory:\n%1") .arg(QString::fromStdString(Common::FS::GetEdenPathString( @@ -170,37 +165,35 @@ void UserDataMigrator::ShowMigrationCancelledMessage(QMainWindow *main_window) QMessageBox::Ok); } -void UserDataMigrator::MigrateUserData(QMainWindow *main_window, - const Emulator selected_legacy_emu, +void UserDataMigrator::MigrateUserData(QMainWindow* main_window, const Emulator selected_legacy_emu, const bool clear_shader_cache, - const MigrationWorker::MigrationStrategy strategy) -{ + const MigrationWorker::MigrationStrategy strategy) { selected_emu = selected_legacy_emu; // Create a dialog to let the user know it's migrating - QProgressDialog *progress = new QProgressDialog(main_window); + QProgressDialog* progress = new QProgressDialog(main_window); progress->setWindowTitle(QObject::tr("Migrating")); progress->setLabelText(QObject::tr("Migrating, this may take a while...")); progress->setRange(0, 0); progress->setCancelButton(nullptr); progress->setWindowModality(Qt::WindowModality::ApplicationModal); - QThread *thread = new QThread(main_window); - MigrationWorker *worker = new MigrationWorker(selected_legacy_emu, clear_shader_cache, strategy); + QThread* thread = new QThread(main_window); + MigrationWorker* worker = + new MigrationWorker(selected_legacy_emu, clear_shader_cache, strategy); worker->moveToThread(thread); thread->connect(thread, &QThread::started, worker, &MigrationWorker::process); - thread->connect(worker, &MigrationWorker::finished, progress, [=, this](const QString &success_text, const std::string &path) { - progress->close(); - QMessageBox::information(main_window, - QObject::tr("Migration"), - success_text, - QMessageBox::Ok); + thread->connect(worker, &MigrationWorker::finished, progress, + [=, this](const QString& success_text, const std::string& path) { + progress->close(); + QMessageBox::information(main_window, QObject::tr("Migration"), + success_text, QMessageBox::Ok); - migrated = true; - thread->quit(); - }); + migrated = true; + thread->quit(); + }); thread->connect(worker, &MigrationWorker::finished, worker, &QObject::deleteLater); thread->connect(thread, &QThread::finished, thread, &QObject::deleteLater); diff --git a/src/yuzu/user_data_migration.h b/src/yuzu/user_data_migration.h index 3684d14916..26085c4040 100644 --- a/src/yuzu/user_data_migration.h +++ b/src/yuzu/user_data_migration.h @@ -20,8 +20,7 @@ public: private: void ShowMigrationPrompt(QMainWindow* main_window); void ShowMigrationCancelledMessage(QMainWindow* main_window); - void MigrateUserData(QMainWindow* main_window, - const Emulator selected_legacy_emu, + void MigrateUserData(QMainWindow* main_window, const Emulator selected_legacy_emu, const bool clear_shader_cache, const MigrationWorker::MigrationStrategy strategy); }; diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index 3974e4b357..68a51997e8 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp @@ -223,12 +223,10 @@ void EmuWindow_SDL2::WaitEvent() { const u32 current_time = SDL_GetTicks(); if (current_time > last_time + 2000) { const auto results = system.GetAndResetPerfStats(); - const auto title = fmt::format("eden {} | {}-{} | FPS: {:.0f} ({:.0f}%)", - Common::g_build_fullname, - Common::g_scm_branch, - Common::g_scm_desc, - results.average_game_fps, - results.emulation_speed * 100.0); + const auto title = + fmt::format("eden {} | {}-{} | FPS: {:.0f} ({:.0f}%)", Common::g_build_fullname, + Common::g_scm_branch, Common::g_scm_desc, results.average_game_fps, + results.emulation_speed * 100.0); SDL_SetWindowTitle(render_window, title.c_str()); last_time = current_time; } diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp index f4980932ed..6557aa4060 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp @@ -18,10 +18,8 @@ EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem_, Core::System& system_, bool fullscreen) : EmuWindow_SDL2{input_subsystem_, system_} { - const std::string window_title = fmt::format("eden {} | {}-{} (Vulkan)", - Common::g_build_name, - Common::g_scm_branch, - Common::g_scm_desc); + const std::string window_title = fmt::format("eden {} | {}-{} (Vulkan)", Common::g_build_name, + Common::g_scm_branch, Common::g_scm_desc); render_window = SDL_CreateWindow(window_title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height, diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index c1d714be77..090fc667f3 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -410,9 +410,7 @@ int main(int argc, char** argv) { "While attempting to load the ROM requested, an error occurred. Please " "refer to the eden wiki for more information or the eden discord for " "additional help.\n\nError Code: {:04X}-{:04X}\nError Description: {}", - loader_id, - error_id, - static_cast(error_id)); + loader_id, error_id, static_cast(error_id)); } break; } diff --git a/src/yuzu_room_standalone/main.cpp b/src/yuzu_room_standalone/main.cpp index 3129fb9dd9..5bc3b38bfc 100644 --- a/src/yuzu_room_standalone/main.cpp +++ b/src/yuzu_room_standalone/main.cpp @@ -2,8 +2,7 @@ using namespace std; -int main() -{ +int main() { cout << "Hello World!" << endl; return 0; } diff --git a/src/yuzu_room_standalone/yuzu_room_standalone.cpp b/src/yuzu_room_standalone/yuzu_room_standalone.cpp index 3063a2962b..9baf214b6b 100644 --- a/src/yuzu_room_standalone/yuzu_room_standalone.cpp +++ b/src/yuzu_room_standalone/yuzu_room_standalone.cpp @@ -3,7 +3,6 @@ #include "dedicated_room/yuzu_room.h" -int main(int argc, char* argv[]) -{ +int main(int argc, char* argv[]) { LaunchRoom(argc, argv, false); } diff --git a/tools/clang-format.sh b/tools/clang-format.sh index 77c3c847ad..835e5b3424 100755 --- a/tools/clang-format.sh +++ b/tools/clang-format.sh @@ -1,3 +1,3 @@ #! /bin/sh -exec find src -iname *.h -o -iname *.cpp | xargs clang-format-15 -i -style=file:src/.clang-format +exec find src -iname *.h -o -iname *.cpp | xargs clang-format -i -style=file:src/.clang-format