├── .ci └── clang-format.sh ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── app-bug-report.yaml │ ├── config.yml │ ├── feature-request.yaml │ └── game-bug-report.yaml ├── linux-appimage-qt.sh ├── linux-appimage-sdl.sh ├── shadps4.png └── workflows │ ├── build.yml │ ├── scripts │ └── update_translation.sh │ └── update_translation.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CMakeSettings.json ├── CONTRIBUTING.md ├── LICENSE ├── LICENSES ├── BSD-3-Clause.txt ├── BSL-1.0.txt ├── CC0-1.0.txt ├── GPL-2.0-or-later.txt ├── MIT.txt └── OFL-1.1.txt ├── README.md ├── REUSE.toml ├── cmake ├── CMakeRC.cmake ├── FindFFmpeg.cmake ├── FindRenderDoc.cmake ├── Findcryptopp.cmake ├── Findhalf.cmake ├── Findstb.cmake └── FindxxHash.cmake ├── crowdin.yml ├── dist ├── MacOSBundleInfo.plist.in ├── net.shadps4.shadPS4.desktop ├── net.shadps4.shadPS4.metainfo.xml └── net.shadps4.shadPS4_metadata.pot ├── documents ├── Debugging │ └── Debugging.md ├── Quickstart │ ├── 2.png │ └── Quickstart.md ├── Screenshots │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ └── Linux │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ └── 5.png ├── building-linux.md ├── building-macos.md ├── building-windows.md ├── changelog.md └── patching-shader.md ├── externals ├── CMakeLists.txt ├── MoltenVK │ ├── CMakeLists.txt │ └── MoltenVK_icd.json ├── cmake-modules │ ├── GetGitRevisionDescription.cmake │ └── GetGitRevisionDescription.cmake.in ├── gcn │ ├── CMakeLists.txt │ └── include │ │ └── gcn │ │ ├── si_ci_vi_merged_offset.h │ │ └── si_ci_vi_merged_pm4_it_opcodes.h ├── renderdoc │ └── renderdoc_app.h └── stb │ └── stb_image.h ├── scripts ├── aerolib.inl ├── file_formats │ └── sfo.hexpat ├── ps4_names.txt └── ps4_names2stubs.py ├── shell.nix └── src ├── .clang-format ├── common ├── adaptive_mutex.h ├── alignment.h ├── arch.h ├── assert.cpp ├── assert.h ├── bit_field.h ├── bounded_threadsafe_queue.h ├── concepts.h ├── config.cpp ├── config.h ├── cstring.h ├── debug.h ├── decoder.cpp ├── decoder.h ├── discord_rpc_handler.cpp ├── discord_rpc_handler.h ├── div_ceil.h ├── elf_info.h ├── endian.h ├── enum.h ├── error.cpp ├── error.h ├── fixed_value.h ├── func_traits.h ├── hash.h ├── io_file.cpp ├── io_file.h ├── logging │ ├── backend.cpp │ ├── backend.h │ ├── filter.cpp │ ├── filter.h │ ├── formatter.h │ ├── log.h │ ├── log_entry.h │ ├── text_formatter.cpp │ ├── text_formatter.h │ └── types.h ├── memory_patcher.cpp ├── memory_patcher.h ├── native_clock.cpp ├── native_clock.h ├── ntapi.cpp ├── ntapi.h ├── number_utils.cpp ├── number_utils.h ├── object_pool.h ├── path_util.cpp ├── path_util.h ├── polyfill_thread.h ├── rdtsc.cpp ├── rdtsc.h ├── scm_rev.cpp.in ├── scm_rev.h ├── scope_exit.h ├── signal_context.cpp ├── signal_context.h ├── singleton.h ├── slab_heap.h ├── slot_array.h ├── slot_vector.h ├── spin_lock.cpp ├── spin_lock.h ├── stb.cpp ├── stb.h ├── string_util.cpp ├── string_util.h ├── support │ └── avdec.h ├── thread.cpp ├── thread.h ├── types.h ├── uint128.h ├── unique_function.h ├── va_ctx.h └── version.h ├── core ├── address_space.cpp ├── address_space.h ├── aerolib │ ├── aerolib.cpp │ ├── aerolib.h │ ├── aerolib.inl │ ├── stubs.cpp │ └── stubs.h ├── cpu_patches.cpp ├── cpu_patches.h ├── crypto │ ├── crypto.cpp │ ├── crypto.h │ └── keys.h ├── debug_state.cpp ├── debug_state.h ├── devices │ ├── base_device.cpp │ ├── base_device.h │ ├── console_device.cpp │ ├── console_device.h │ ├── deci_tty6_device.cpp │ ├── deci_tty6_device.h │ ├── ioccom.h │ ├── logger.cpp │ ├── logger.h │ ├── nop_device.h │ ├── random_device.cpp │ ├── random_device.h │ ├── srandom_device.cpp │ ├── srandom_device.h │ ├── urandom_device.cpp │ └── urandom_device.h ├── devtools │ ├── gcn │ │ ├── gcn_context_regs.cpp │ │ ├── gcn_op_names.cpp │ │ └── gcn_shader_regs.cpp │ ├── help.txt │ ├── layer.cpp │ ├── layer.h │ ├── options.cpp │ ├── options.h │ └── widget │ │ ├── cmd_list.cpp │ │ ├── cmd_list.h │ │ ├── common.h │ │ ├── frame_dump.cpp │ │ ├── frame_dump.h │ │ ├── frame_graph.cpp │ │ ├── frame_graph.h │ │ ├── imgui_memory_editor.h │ │ ├── memory_map.cpp │ │ ├── memory_map.h │ │ ├── reg_popup.cpp │ │ ├── reg_popup.h │ │ ├── reg_view.cpp │ │ ├── reg_view.h │ │ ├── shader_list.cpp │ │ ├── shader_list.h │ │ ├── text_editor.cpp │ │ └── text_editor.h ├── file_format │ ├── pfs.h │ ├── pkg.cpp │ ├── pkg.h │ ├── pkg_type.cpp │ ├── pkg_type.h │ ├── playgo_chunk.cpp │ ├── playgo_chunk.h │ ├── psf.cpp │ ├── psf.h │ ├── splash.cpp │ ├── splash.h │ ├── trp.cpp │ └── trp.h ├── file_sys │ ├── file.cpp │ ├── fs.cpp │ └── fs.h ├── libraries │ ├── ajm │ │ ├── ajm.cpp │ │ ├── ajm.h │ │ ├── ajm_at9.cpp │ │ ├── ajm_at9.h │ │ ├── ajm_batch.cpp │ │ ├── ajm_batch.h │ │ ├── ajm_context.cpp │ │ ├── ajm_context.h │ │ ├── ajm_error.h │ │ ├── ajm_instance.cpp │ │ ├── ajm_instance.h │ │ ├── ajm_instance_statistics.cpp │ │ ├── ajm_instance_statistics.h │ │ ├── ajm_mp3.cpp │ │ └── ajm_mp3.h │ ├── app_content │ │ ├── app_content.cpp │ │ ├── app_content.h │ │ └── app_content_error.h │ ├── audio │ │ ├── audioin.cpp │ │ ├── audioin.h │ │ ├── audioout.cpp │ │ ├── audioout.h │ │ ├── audioout_backend.h │ │ ├── audioout_error.h │ │ └── sdl_audio.cpp │ ├── audio3d │ │ ├── audio3d.cpp │ │ ├── audio3d.h │ │ ├── audio3d_error.h │ │ ├── audio3d_impl.cpp │ │ └── audio3d_impl.h │ ├── avplayer │ │ ├── avplayer.cpp │ │ ├── avplayer.h │ │ ├── avplayer_common.cpp │ │ ├── avplayer_common.h │ │ ├── avplayer_data_streamer.h │ │ ├── avplayer_error.h │ │ ├── avplayer_file_streamer.cpp │ │ ├── avplayer_file_streamer.h │ │ ├── avplayer_impl.cpp │ │ ├── avplayer_impl.h │ │ ├── avplayer_source.cpp │ │ ├── avplayer_source.h │ │ ├── avplayer_state.cpp │ │ └── avplayer_state.h │ ├── disc_map │ │ ├── disc_map.cpp │ │ ├── disc_map.h │ │ └── disc_map_codes.h │ ├── error_codes.h │ ├── fiber │ │ ├── fiber.cpp │ │ ├── fiber.h │ │ ├── fiber_context.s │ │ └── fiber_error.h │ ├── game_live_streaming │ │ ├── gamelivestreaming.cpp │ │ └── gamelivestreaming.h │ ├── gnmdriver │ │ ├── gnm_error.h │ │ ├── gnmdriver.cpp │ │ ├── gnmdriver.h │ │ └── gnmdriver_init.h │ ├── hmd │ │ ├── hmd.cpp │ │ └── hmd.h │ ├── ime │ │ ├── error_dialog.cpp │ │ ├── error_dialog.h │ │ ├── ime.cpp │ │ ├── ime.h │ │ ├── ime_common.h │ │ ├── ime_dialog.cpp │ │ ├── ime_dialog.h │ │ ├── ime_dialog_ui.cpp │ │ ├── ime_dialog_ui.h │ │ ├── ime_error.h │ │ ├── ime_ui.cpp │ │ └── ime_ui.h │ ├── jpeg │ │ ├── jpeg_error.h │ │ ├── jpegenc.cpp │ │ └── jpegenc.h │ ├── kernel │ │ ├── aio.cpp │ │ ├── aio.h │ │ ├── equeue.cpp │ │ ├── equeue.h │ │ ├── file_system.cpp │ │ ├── file_system.h │ │ ├── kernel.cpp │ │ ├── kernel.h │ │ ├── memory.cpp │ │ ├── memory.h │ │ ├── orbis_error.h │ │ ├── posix_error.h │ │ ├── process.cpp │ │ ├── process.h │ │ ├── sync │ │ │ ├── mutex.cpp │ │ │ ├── mutex.h │ │ │ └── semaphore.h │ │ ├── threads.cpp │ │ ├── threads.h │ │ ├── threads │ │ │ ├── condvar.cpp │ │ │ ├── event_flag.cpp │ │ │ ├── exception.cpp │ │ │ ├── exception.h │ │ │ ├── mutex.cpp │ │ │ ├── pthread.cpp │ │ │ ├── pthread.h │ │ │ ├── pthread_attr.cpp │ │ │ ├── pthread_clean.cpp │ │ │ ├── pthread_spec.cpp │ │ │ ├── rwlock.cpp │ │ │ ├── semaphore.cpp │ │ │ ├── sleepq.cpp │ │ │ ├── sleepq.h │ │ │ ├── stack.cpp │ │ │ ├── tcb.cpp │ │ │ ├── thread_state.cpp │ │ │ └── thread_state.h │ │ ├── time.cpp │ │ └── time.h │ ├── libc_internal │ │ ├── libc_internal.cpp │ │ ├── libc_internal.h │ │ ├── libc_internal_io.cpp │ │ ├── libc_internal_io.h │ │ ├── libc_internal_math.cpp │ │ ├── libc_internal_math.h │ │ ├── libc_internal_memory.cpp │ │ ├── libc_internal_memory.h │ │ ├── libc_internal_str.cpp │ │ ├── libc_internal_str.h │ │ └── printf.h │ ├── libpng │ │ ├── pngdec.cpp │ │ ├── pngdec.h │ │ └── pngdec_error.h │ ├── libs.cpp │ ├── libs.h │ ├── mouse │ │ ├── mouse.cpp │ │ └── mouse.h │ ├── move │ │ ├── move.cpp │ │ └── move.h │ ├── network │ │ ├── http.cpp │ │ ├── http.h │ │ ├── http2.cpp │ │ ├── http2.h │ │ ├── http_error.h │ │ ├── net.cpp │ │ ├── net.h │ │ ├── net_ctl_codes.h │ │ ├── net_ctl_obj.cpp │ │ ├── net_ctl_obj.h │ │ ├── net_obj.cpp │ │ ├── net_obj.h │ │ ├── netctl.cpp │ │ ├── netctl.h │ │ ├── ssl.cpp │ │ ├── ssl.h │ │ ├── ssl2.cpp │ │ └── ssl2.h │ ├── ngs2 │ │ ├── ngs2.cpp │ │ ├── ngs2.h │ │ ├── ngs2_error.h │ │ ├── ngs2_impl.cpp │ │ └── ngs2_impl.h │ ├── np_common │ │ ├── np_common.cpp │ │ ├── np_common.h │ │ └── np_common_error.h │ ├── np_manager │ │ ├── np_manager.cpp │ │ ├── np_manager.h │ │ └── np_manager_error.h │ ├── np_party │ │ ├── np_party.cpp │ │ └── np_party.h │ ├── np_score │ │ ├── np_score.cpp │ │ └── np_score.h │ ├── np_trophy │ │ ├── np_trophy.cpp │ │ ├── np_trophy.h │ │ ├── np_trophy_error.h │ │ ├── trophy_ui.cpp │ │ └── trophy_ui.h │ ├── np_web_api │ │ ├── np_web_api.cpp │ │ └── np_web_api.h │ ├── pad │ │ ├── pad.cpp │ │ ├── pad.h │ │ └── pad_errors.h │ ├── playgo │ │ ├── playgo.cpp │ │ ├── playgo.h │ │ ├── playgo_dialog.cpp │ │ ├── playgo_dialog.h │ │ └── playgo_types.h │ ├── random │ │ ├── random.cpp │ │ ├── random.h │ │ └── random_error.h │ ├── razor_cpu │ │ ├── razor_cpu.cpp │ │ └── razor_cpu.h │ ├── remote_play │ │ ├── remoteplay.cpp │ │ └── remoteplay.h │ ├── rtc │ │ ├── rtc.cpp │ │ ├── rtc.h │ │ └── rtc_error.h │ ├── save_data │ │ ├── dialog │ │ │ ├── savedatadialog.cpp │ │ │ ├── savedatadialog.h │ │ │ ├── savedatadialog_ui.cpp │ │ │ └── savedatadialog_ui.h │ │ ├── save_backup.cpp │ │ ├── save_backup.h │ │ ├── save_instance.cpp │ │ ├── save_instance.h │ │ ├── save_memory.cpp │ │ ├── save_memory.h │ │ ├── savedata.cpp │ │ └── savedata.h │ ├── screenshot │ │ ├── screenshot.cpp │ │ └── screenshot.h │ ├── share_play │ │ ├── shareplay.cpp │ │ └── shareplay.h │ ├── system │ │ ├── commondialog.cpp │ │ ├── commondialog.h │ │ ├── msgdialog.cpp │ │ ├── msgdialog.h │ │ ├── msgdialog_ui.cpp │ │ ├── msgdialog_ui.h │ │ ├── posix.cpp │ │ ├── posix.h │ │ ├── sysmodule.cpp │ │ ├── sysmodule.h │ │ ├── system_error.h │ │ ├── systemservice.cpp │ │ ├── systemservice.h │ │ ├── systemservice_error.h │ │ ├── userservice.cpp │ │ ├── userservice.h │ │ └── userservice_error.h │ ├── usbd │ │ ├── usbd.cpp │ │ └── usbd.h │ ├── videodec │ │ ├── videodec.cpp │ │ ├── videodec.h │ │ ├── videodec2.cpp │ │ ├── videodec2.h │ │ ├── videodec2_avc.h │ │ ├── videodec2_impl.cpp │ │ ├── videodec2_impl.h │ │ ├── videodec_error.h │ │ ├── videodec_impl.cpp │ │ └── videodec_impl.h │ ├── videoout │ │ ├── buffer.h │ │ ├── driver.cpp │ │ ├── driver.h │ │ ├── video_out.cpp │ │ ├── video_out.h │ │ └── videoout_error.h │ ├── web_browser_dialog │ │ ├── webbrowserdialog.cpp │ │ └── webbrowserdialog.h │ └── zlib │ │ ├── zlib.cpp │ │ ├── zlib_error.h │ │ └── zlib_sce.h ├── linker.cpp ├── linker.h ├── loader.cpp ├── loader.h ├── loader │ ├── dwarf.cpp │ ├── dwarf.h │ ├── elf.cpp │ ├── elf.h │ ├── symbols_resolver.cpp │ └── symbols_resolver.h ├── memory.cpp ├── memory.h ├── module.cpp ├── module.h ├── platform.h ├── signals.cpp ├── signals.h ├── thread.cpp ├── thread.h ├── tls.cpp └── tls.h ├── emulator.cpp ├── emulator.h ├── images ├── KBM.png ├── about_icon.png ├── bronze.png ├── controller_icon.png ├── discord.png ├── dump_icon.png ├── exit_icon.png ├── file_icon.png ├── flag_china.png ├── flag_eu.png ├── flag_jp.png ├── flag_unk.png ├── flag_us.png ├── flag_world.png ├── folder_icon.png ├── github.png ├── gold.png ├── grid_icon.png ├── iconsize_icon.png ├── keyboard_icon.png ├── ko-fi.png ├── list_icon.png ├── list_mode_icon.png ├── net.shadps4.shadPS4.svg ├── pause_icon.png ├── platinum.png ├── play_icon.png ├── ps4_controller.png ├── refresh_icon.png ├── settings_icon.png ├── shadPS4.icns ├── shadps4.ico ├── silver.png ├── stop_icon.png ├── themes_icon.png ├── update_icon.png ├── utils_icon.png ├── website.png └── youtube.png ├── imgui ├── imgui_config.h ├── imgui_layer.h ├── imgui_std.h ├── imgui_texture.h └── renderer │ ├── CMakeLists.txt │ ├── fonts │ ├── NotoSansJP-Regular.ttf │ └── ProggyVector-Regular.ttf │ ├── imgui_core.cpp │ ├── imgui_core.h │ ├── imgui_impl_sdl3.cpp │ ├── imgui_impl_sdl3.h │ ├── imgui_impl_vulkan.cpp │ ├── imgui_impl_vulkan.h │ ├── texture_manager.cpp │ └── texture_manager.h ├── input ├── controller.cpp ├── controller.h ├── input_handler.cpp ├── input_handler.h ├── input_mouse.cpp └── input_mouse.h ├── main.cpp ├── qt_gui ├── about_dialog.cpp ├── about_dialog.h ├── about_dialog.ui ├── background_music_player.cpp ├── background_music_player.h ├── cheats_patches.cpp ├── cheats_patches.h ├── check_update.cpp ├── check_update.h ├── compatibility_info.cpp ├── compatibility_info.h ├── control_settings.cpp ├── control_settings.h ├── control_settings.ui ├── elf_viewer.cpp ├── elf_viewer.h ├── game_grid_frame.cpp ├── game_grid_frame.h ├── game_info.cpp ├── game_info.h ├── game_install_dialog.cpp ├── game_install_dialog.h ├── game_list_frame.cpp ├── game_list_frame.h ├── game_list_utils.h ├── gui_context_menus.h ├── install_dir_select.cpp ├── install_dir_select.h ├── kbm_config_dialog.cpp ├── kbm_config_dialog.h ├── kbm_gui.cpp ├── kbm_gui.h ├── kbm_gui.ui ├── kbm_help_dialog.cpp ├── kbm_help_dialog.h ├── main.cpp ├── main_window.cpp ├── main_window.h ├── main_window_themes.cpp ├── main_window_themes.h ├── main_window_ui.h ├── pkg_viewer.cpp ├── pkg_viewer.h ├── settings_dialog.cpp ├── settings_dialog.h ├── settings_dialog.ui ├── translations │ ├── ar_SA.ts │ ├── da_DK.ts │ ├── de_DE.ts │ ├── el_GR.ts │ ├── en_US.ts │ ├── es_ES.ts │ ├── fa_IR.ts │ ├── fi_FI.ts │ ├── fr_FR.ts │ ├── hu_HU.ts │ ├── id_ID.ts │ ├── it_IT.ts │ ├── ja_JP.ts │ ├── ko_KR.ts │ ├── lt_LT.ts │ ├── nb_NO.ts │ ├── nl_NL.ts │ ├── pl_PL.ts │ ├── pt_BR.ts │ ├── pt_PT.ts │ ├── ro_RO.ts │ ├── ru_RU.ts │ ├── sq_AL.ts │ ├── sv_SE.ts │ ├── tr_TR.ts │ ├── uk_UA.ts │ ├── update_translation.sh │ ├── vi_VN.ts │ ├── zh_CN.ts │ └── zh_TW.ts ├── trophy_viewer.cpp └── trophy_viewer.h ├── sdl_window.cpp ├── sdl_window.h ├── shader_recompiler ├── backend │ ├── bindings.h │ └── spirv │ │ ├── emit_spirv.cpp │ │ ├── emit_spirv.h │ │ ├── emit_spirv_atomic.cpp │ │ ├── emit_spirv_barriers.cpp │ │ ├── emit_spirv_bitwise_conversion.cpp │ │ ├── emit_spirv_composite.cpp │ │ ├── emit_spirv_context_get_set.cpp │ │ ├── emit_spirv_convert.cpp │ │ ├── emit_spirv_floating_point.cpp │ │ ├── emit_spirv_image.cpp │ │ ├── emit_spirv_instructions.h │ │ ├── emit_spirv_integer.cpp │ │ ├── emit_spirv_logical.cpp │ │ ├── emit_spirv_quad_rect.cpp │ │ ├── emit_spirv_quad_rect.h │ │ ├── emit_spirv_select.cpp │ │ ├── emit_spirv_shared_memory.cpp │ │ ├── emit_spirv_special.cpp │ │ ├── emit_spirv_undefined.cpp │ │ ├── emit_spirv_warp.cpp │ │ ├── spirv_emit_context.cpp │ │ └── spirv_emit_context.h ├── exception.h ├── frontend │ ├── control_flow_graph.cpp │ ├── control_flow_graph.h │ ├── copy_shader.cpp │ ├── copy_shader.h │ ├── decode.cpp │ ├── decode.h │ ├── fetch_shader.cpp │ ├── fetch_shader.h │ ├── format.cpp │ ├── instruction.cpp │ ├── instruction.h │ ├── opcodes.h │ ├── structured_control_flow.cpp │ ├── structured_control_flow.h │ ├── tessellation.h │ └── translate │ │ ├── data_share.cpp │ │ ├── export.cpp │ │ ├── scalar_alu.cpp │ │ ├── scalar_flow.cpp │ │ ├── scalar_memory.cpp │ │ ├── translate.cpp │ │ ├── translate.h │ │ ├── vector_alu.cpp │ │ ├── vector_interpolation.cpp │ │ └── vector_memory.cpp ├── info.h ├── ir │ ├── abstract_syntax_list.h │ ├── attribute.cpp │ ├── attribute.h │ ├── basic_block.cpp │ ├── basic_block.h │ ├── breadth_first_search.h │ ├── condition.h │ ├── debug_print.h │ ├── ir_emitter.cpp │ ├── ir_emitter.h │ ├── microinstruction.cpp │ ├── opcodes.cpp │ ├── opcodes.h │ ├── opcodes.inc │ ├── passes │ │ ├── constant_propagation_pass.cpp │ │ ├── constant_propogation.h │ │ ├── dead_code_elimination_pass.cpp │ │ ├── flatten_extended_userdata_pass.cpp │ │ ├── hull_shader_transform.cpp │ │ ├── identity_removal_pass.cpp │ │ ├── ir_passes.h │ │ ├── lower_buffer_format_to_raw.cpp │ │ ├── resource_tracking_pass.cpp │ │ ├── ring_access_elimination.cpp │ │ ├── shader_info_collection_pass.cpp │ │ ├── shared_memory_barrier_pass.cpp │ │ ├── shared_memory_to_storage_pass.cpp │ │ ├── srt.h │ │ └── ssa_rewrite_pass.cpp │ ├── patch.cpp │ ├── patch.h │ ├── pattern_matching.h │ ├── post_order.cpp │ ├── post_order.h │ ├── program.cpp │ ├── program.h │ ├── reg.h │ ├── reinterpret.h │ ├── srt_gvn_table.h │ ├── type.cpp │ ├── type.h │ ├── value.cpp │ └── value.h ├── params.h ├── profile.h ├── recompiler.cpp ├── recompiler.h ├── runtime_info.h └── specialization.h ├── shadps4.qrc ├── shadps4.rc └── video_core ├── amdgpu ├── default_context.cpp ├── liverpool.cpp ├── liverpool.h ├── pixel_format.cpp ├── pixel_format.h ├── pm4_cmds.h ├── pm4_opcodes.h ├── resource.h └── types.h ├── buffer_cache ├── buffer.cpp ├── buffer.h ├── buffer_cache.cpp ├── buffer_cache.h ├── memory_tracker_base.h ├── range_set.h └── word_manager.h ├── host_shaders ├── CMakeLists.txt ├── StringShaderHeader.cmake ├── detilers │ ├── display_micro_64bpp.comp │ ├── macro_32bpp.comp │ ├── macro_64bpp.comp │ ├── macro_8bpp.comp │ ├── micro_128bpp.comp │ ├── micro_16bpp.comp │ ├── micro_32bpp.comp │ ├── micro_64bpp.comp │ └── micro_8bpp.comp ├── fs_tri.vert ├── post_process.frag └── source_shader.h.in ├── multi_level_page_table.h ├── page_manager.cpp ├── page_manager.h ├── renderdoc.cpp ├── renderdoc.h ├── renderer_vulkan ├── liverpool_to_vk.cpp ├── liverpool_to_vk.h ├── vk_common.cpp ├── vk_common.h ├── vk_compute_pipeline.cpp ├── vk_compute_pipeline.h ├── vk_graphics_pipeline.cpp ├── vk_graphics_pipeline.h ├── vk_instance.cpp ├── vk_instance.h ├── vk_master_semaphore.cpp ├── vk_master_semaphore.h ├── vk_pipeline_cache.cpp ├── vk_pipeline_cache.h ├── vk_pipeline_common.cpp ├── vk_pipeline_common.h ├── vk_platform.cpp ├── vk_platform.h ├── vk_presenter.cpp ├── vk_presenter.h ├── vk_rasterizer.cpp ├── vk_rasterizer.h ├── vk_resource_pool.cpp ├── vk_resource_pool.h ├── vk_scheduler.cpp ├── vk_scheduler.h ├── vk_shader_hle.cpp ├── vk_shader_hle.h ├── vk_shader_util.cpp ├── vk_shader_util.h ├── vk_swapchain.cpp └── vk_swapchain.h └── texture_cache ├── host_compatibility.h ├── image.cpp ├── image.h ├── image_info.cpp ├── image_info.h ├── image_view.cpp ├── image_view.h ├── sampler.cpp ├── sampler.h ├── texture_cache.cpp ├── texture_cache.h ├── tile.h ├── tile_manager.cpp ├── tile_manager.h └── types.h /.ci/clang-format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | 3 | # SPDX-FileCopyrightText: 2023 Citra Emulator Project 4 | # SPDX-License-Identifier: GPL-2.0-or-later 5 | 6 | if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .ci* dist/*.desktop \ 7 | dist/*.svg dist/*.xml; then 8 | echo Trailing whitespace found, aborting 9 | exit 1 10 | fi 11 | 12 | # Default clang-format points to default 3.5 version one 13 | CLANG_FORMAT=clang-format-19 14 | $CLANG_FORMAT --version 15 | 16 | if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then 17 | # Get list of every file modified in this pull request 18 | files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $COMMIT_RANGE | grep '^src/[^.]*[.]\(cpp\|h\)$' || true)" 19 | else 20 | # Check everything for branch pushes 21 | files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')" 22 | fi 23 | 24 | # Turn off tracing for this because it's too verbose 25 | set +x 26 | 27 | for f in $files_to_lint; do 28 | d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true) 29 | if ! [ -z "$d" ]; then 30 | echo "!!! $f not compliant to coding style, here is the fix:" 31 | echo "$d" 32 | fail=1 33 | fi 34 | done 35 | 36 | set -x 37 | 38 | if [ "$fail" = 1 ]; then 39 | exit 1 40 | fi 41 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | ko_fi: shadps4 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | # SPDX-License-Identifier: GPL-2.0-or-later 3 | blank_issues_enabled: false 4 | contact_links: 5 | - name: Discord 6 | url: https://discord.gg/bFJxfftGW6 7 | about: Get direct support and hang out with us 8 | - name: Wiki 9 | url: https://github.com/shadps4-emu/shadPS4/wiki 10 | about: Information, guides, etc. 11 | -------------------------------------------------------------------------------- /.github/linux-appimage-sdl.sh: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project 2 | # SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #!/bin/bash 5 | 6 | if [[ -z $GITHUB_WORKSPACE ]]; then 7 | GITHUB_WORKSPACE="${PWD%/*}" 8 | fi 9 | 10 | # Prepare Tools for building the AppImage 11 | wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage 12 | wget -q https://github.com/linuxdeploy/linuxdeploy-plugin-checkrt/releases/download/continuous/linuxdeploy-plugin-checkrt-x86_64.sh 13 | 14 | chmod a+x linuxdeploy-x86_64.AppImage 15 | chmod a+x linuxdeploy-plugin-checkrt-x86_64.sh 16 | 17 | # Build AppImage 18 | ./linuxdeploy-x86_64.AppImage --appdir AppDir 19 | ./linuxdeploy-plugin-checkrt-x86_64.sh --appdir AppDir 20 | ./linuxdeploy-x86_64.AppImage --appdir AppDir -d "$GITHUB_WORKSPACE"/dist/net.shadps4.shadPS4.desktop -e "$GITHUB_WORKSPACE"/build/shadps4 -i "$GITHUB_WORKSPACE"/src/images/net.shadps4.shadPS4.svg --output appimage 21 | mv shadPS4-x86_64.AppImage Shadps4-sdl.AppImage 22 | -------------------------------------------------------------------------------- /.github/shadps4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/.github/shadps4.png -------------------------------------------------------------------------------- /.github/workflows/scripts/update_translation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | sudo apt-get -y install qt6-l10n-tools python3 6 | 7 | SCRIPT_PATH="src/qt_gui/translations/update_translation.sh" 8 | 9 | chmod +x "$SCRIPT_PATH" 10 | 11 | PATH=/usr/lib/qt6/bin:$PATH "$SCRIPT_PATH" -------------------------------------------------------------------------------- /.github/workflows/update_translation.yml: -------------------------------------------------------------------------------- 1 | name: Update Translation 2 | 3 | on: 4 | schedule: 5 | - cron: "0 0 * * *" # Every day at 12am UTC. 6 | workflow_dispatch: # As well as manually. 7 | 8 | jobs: 9 | update: 10 | if: github.repository == 'shadps4-emu/shadPS4' 11 | name: "Update Translation" 12 | runs-on: ubuntu-22.04 13 | steps: 14 | - uses: actions/checkout@v4 15 | 16 | - name: Set execution permissions for the script 17 | run: chmod +x ./.github/workflows/scripts/update_translation.sh 18 | 19 | - name: Update Base Translation 20 | run: ./.github/workflows/scripts/update_translation.sh 21 | 22 | - name: Create Pull Request 23 | uses: peter-evans/create-pull-request@v7 24 | with: 25 | token: ${{ secrets.SHADPS4_TOKEN_REPO }} 26 | title: "Qt GUI: Update Translation" 27 | commit-message: "[ci skip] Qt GUI: Update Translation." 28 | body: "Daily update of translation sources." 29 | branch: update-translation 30 | delete-branch: true 31 | -------------------------------------------------------------------------------- /CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x64-Clang-Release", 5 | "generator": "Ninja", 6 | "configurationType": "Release", 7 | "buildRoot": "${projectDir}\\Build\\${name}", 8 | "installRoot": "${projectDir}\\Install\\${name}", 9 | "cmakeCommandArgs": "", 10 | "buildCommandArgs": "", 11 | "ctestCommandArgs": "", 12 | "inheritEnvironments": [ "clang_cl_x64_x64" ], 13 | "intelliSenseMode": "windows-clang-x64" 14 | }, 15 | { 16 | "name": "x64-Clang-Debug", 17 | "generator": "Ninja", 18 | "configurationType": "Debug", 19 | "buildRoot": "${projectDir}\\Build\\${name}", 20 | "installRoot": "${projectDir}\\Install\\${name}", 21 | "cmakeCommandArgs": "", 22 | "buildCommandArgs": "", 23 | "ctestCommandArgs": "", 24 | "inheritEnvironments": [ "clang_cl_x64_x64" ], 25 | "intelliSenseMode": "windows-clang-x64" 26 | }, 27 | { 28 | "name": "x64-Clang-RelWithDebInfo", 29 | "generator": "Ninja", 30 | "configurationType": "RelWithDebInfo", 31 | "buildRoot": "${projectDir}\\Build\\${name}", 32 | "installRoot": "${projectDir}\\Install\\${name}", 33 | "cmakeCommandArgs": "", 34 | "buildCommandArgs": "", 35 | "ctestCommandArgs": "", 36 | "inheritEnvironments": [ "clang_cl_x64_x64" ], 37 | "intelliSenseMode": "windows-clang-x64" 38 | } 39 | ] 40 | } -------------------------------------------------------------------------------- /LICENSES/BSD-3-Clause.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) . 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /LICENSES/BSL-1.0.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: 4 | 5 | The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /cmake/FindFFmpeg.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | # SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | find_package(PkgConfig QUIET) 5 | pkg_check_modules(FFMPEG QUIET IMPORTED_TARGET libavcodec libavfilter libavformat libavutil libswresample libswscale) 6 | 7 | find_file(FFMPEG_VERSION_FILE libavutil/ffversion.h HINTS "${FFMPEG_libavutil_INCLUDEDIR}") 8 | if (FFMPEG_VERSION_FILE) 9 | file(STRINGS "${FFMPEG_VERSION_FILE}" FFMPEG_VERSION_LINE REGEX "FFMPEG_VERSION") 10 | string(REGEX MATCH "[0-9.]+" FFMPEG_VERSION "${FFMPEG_VERSION_LINE}") 11 | unset(FFMPEG_VERSION_LINE) 12 | unset(FFMPEG_VERSION_FILE) 13 | endif() 14 | 15 | include(FindPackageHandleStandardArgs) 16 | find_package_handle_standard_args(FFmpeg 17 | REQUIRED_VARS FFMPEG_LINK_LIBRARIES 18 | VERSION_VAR FFMPEG_VERSION 19 | ) 20 | 21 | if (FFmpeg_FOUND AND NOT TARGET FFmpeg::ffmpeg) 22 | add_library(FFmpeg::ffmpeg ALIAS PkgConfig::FFMPEG) 23 | endif() 24 | -------------------------------------------------------------------------------- /cmake/FindRenderDoc.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | # SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | find_path(RENDERDOC_INCLUDE_DIR renderdoc_app.h) 5 | 6 | if (RENDERDOC_INCLUDE_DIR AND EXISTS "${RENDERDOC_INCLUDE_DIR}/renderdoc_app.h") 7 | file(STRINGS "${RENDERDOC_INCLUDE_DIR}/renderdoc_app.h" RENDERDOC_VERSION_LINE REGEX "typedef struct RENDERDOC_API") 8 | string(REGEX REPLACE ".*typedef struct RENDERDOC_API_([0-9]+)_([0-9]+)_([0-9]+).*" "\\1.\\2.\\3" RENDERDOC_VERSION "${RENDERDOC_VERSION_LINE}") 9 | unset(RENDERDOC_VERSION_LINE) 10 | endif() 11 | 12 | include(FindPackageHandleStandardArgs) 13 | find_package_handle_standard_args(RenderDoc 14 | REQUIRED_VARS RENDERDOC_INCLUDE_DIR 15 | VERSION_VAR RENDERDOC_VERSION 16 | ) 17 | 18 | if (RenderDoc_FOUND AND NOT TARGET RenderDoc::API) 19 | add_library(RenderDoc::API INTERFACE IMPORTED) 20 | set_target_properties(RenderDoc::API PROPERTIES 21 | INTERFACE_INCLUDE_DIRECTORIES "${RENDERDOC_INCLUDE_DIR}" 22 | ) 23 | endif() 24 | 25 | mark_as_advanced(RENDERDOC_INCLUDE_DIR) 26 | -------------------------------------------------------------------------------- /cmake/Findcryptopp.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | # SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | find_package(PkgConfig QUIET) 5 | pkg_search_module(CRYPTOPP QUIET IMPORTED_TARGET libcryptopp) 6 | 7 | include(FindPackageHandleStandardArgs) 8 | find_package_handle_standard_args(cryptopp 9 | REQUIRED_VARS CRYPTOPP_LINK_LIBRARIES 10 | VERSION_VAR CRYPTOPP_VERSION 11 | ) 12 | 13 | if (cryptopp_FOUND AND NOT TARGET cryptopp::cryptopp) 14 | add_library(cryptopp::cryptopp ALIAS PkgConfig::CRYPTOPP) 15 | endif() 16 | -------------------------------------------------------------------------------- /cmake/Findhalf.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | # SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | find_path(half_INCLUDE_DIR NAMES half.hpp PATH_SUFFIXES half) 5 | 6 | if (half_INCLUDE_DIR) 7 | file(STRINGS "${half_INCLUDE_DIR}/half.hpp" _ver_line 8 | REGEX "^// Version [0-9.]+$" 9 | LIMIT_COUNT 1 10 | ) 11 | string(REGEX MATCH "[0-9.]+" half_VERSION "${_ver_line}") 12 | unset(_ver_line) 13 | endif() 14 | 15 | include(FindPackageHandleStandardArgs) 16 | find_package_handle_standard_args(half 17 | REQUIRED_VARS half_INCLUDE_DIR 18 | VERSION_VAR half_VERSION 19 | ) 20 | 21 | if (half_FOUND AND NOT TARGET half::half) 22 | add_library(half::half INTERFACE IMPORTED) 23 | set_target_properties(half::half PROPERTIES 24 | INTERFACE_INCLUDE_DIRECTORIES "${half_INCLUDE_DIR}" 25 | ) 26 | endif() 27 | 28 | mark_as_advanced(half_INCLUDE_DIR) 29 | -------------------------------------------------------------------------------- /cmake/Findstb.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | # SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | find_path(stb_image_INCLUDE_DIR stb_image.h PATH_SUFFIXES stb) 5 | 6 | include(FindPackageHandleStandardArgs) 7 | find_package_handle_standard_args(stb 8 | REQUIRED_VARS stb_image_INCLUDE_DIR 9 | ) 10 | 11 | if (stb_FOUND AND NOT TARGET stb::headers) 12 | add_library(stb::headers INTERFACE IMPORTED) 13 | set_property(TARGET stb::headers PROPERTY 14 | INTERFACE_INCLUDE_DIRECTORIES 15 | "${stb_image_INCLUDE_DIR}" 16 | ) 17 | endif() 18 | 19 | mark_as_advanced(stb_image_INCLUDE_DIR) 20 | -------------------------------------------------------------------------------- /cmake/FindxxHash.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | # SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | find_package(PkgConfig QUIET) 5 | pkg_search_module(XXHASH QUIET IMPORTED_TARGET libxxhash) 6 | 7 | include(FindPackageHandleStandardArgs) 8 | find_package_handle_standard_args(xxHash 9 | REQUIRED_VARS XXHASH_LINK_LIBRARIES 10 | VERSION_VAR XXHASH_VERSION 11 | ) 12 | 13 | if (xxHash_FOUND AND NOT TARGET xxHash::xxhash) 14 | add_library(xxHash::xxhash ALIAS PkgConfig::XXHASH) 15 | endif() 16 | -------------------------------------------------------------------------------- /crowdin.yml: -------------------------------------------------------------------------------- 1 | files: 2 | - source: /src/qt_gui/translations/en_US.ts 3 | translation: /%original_path%/%locale_with_underscore%.ts 4 | -------------------------------------------------------------------------------- /dist/MacOSBundleInfo.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleInfoDictionaryVersion 6 | 6.0 7 | CFBundlePackageType 8 | APPL 9 | 10 | CFBundleName 11 | shadps4 12 | CFBundleIdentifier 13 | com.shadps4-emu.shadps4 14 | CFBundleExecutable 15 | shadps4 16 | 17 | CFBundleVersion 18 | 1.0.0 19 | CFBundleShortVersionString 20 | ${MACOSX_BUNDLE_SHORT_VERSION_STRING} 21 | 22 | LSMinimumSystemVersion 23 | ${CMAKE_OSX_DEPLOYMENT_TARGET} 24 | LSApplicationCategoryType 25 | public.app-category.games 26 | GCSupportsGameMode 27 | 28 | 29 | NSHumanReadableCopyright 30 | 31 | 32 | CFBundleIconFile 33 | ${MACOSX_BUNDLE_ICON_FILE} 34 | 35 | CFBundleDevelopmentRegion 36 | en 37 | CFBundleAllowMixedLocalizations 38 | 39 | 40 | NSPrincipalClass 41 | NSApplication 42 | 43 | NSSupportsAutomaticGraphicsSwitching 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /dist/net.shadps4.shadPS4.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=shadPS4 3 | Exec=shadps4 4 | Terminal=false 5 | Type=Application 6 | Icon=net.shadps4.shadPS4 7 | Comment=PlayStation 4 emulator 8 | Categories=Game;Emulator; 9 | StartupWMClass=shadps4; 10 | -------------------------------------------------------------------------------- /documents/Quickstart/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/documents/Quickstart/2.png -------------------------------------------------------------------------------- /documents/Screenshots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/documents/Screenshots/1.png -------------------------------------------------------------------------------- /documents/Screenshots/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/documents/Screenshots/2.png -------------------------------------------------------------------------------- /documents/Screenshots/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/documents/Screenshots/3.png -------------------------------------------------------------------------------- /documents/Screenshots/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/documents/Screenshots/4.png -------------------------------------------------------------------------------- /documents/Screenshots/Linux/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/documents/Screenshots/Linux/1.png -------------------------------------------------------------------------------- /documents/Screenshots/Linux/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/documents/Screenshots/Linux/2.png -------------------------------------------------------------------------------- /documents/Screenshots/Linux/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/documents/Screenshots/Linux/3.png -------------------------------------------------------------------------------- /documents/Screenshots/Linux/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/documents/Screenshots/Linux/4.png -------------------------------------------------------------------------------- /documents/Screenshots/Linux/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/documents/Screenshots/Linux/5.png -------------------------------------------------------------------------------- /documents/patching-shader.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | ### Install Vulkan SDK and \*ensure `spirv-cross` and `glslc` are in PATH\*. 7 | 8 | 1. Enable `dumpShaders` in config.toml 9 | 10 | 2. Run `spirv-cross -V fs_0x000000.spv --output fs_0x000000.glsl` to decompile the SPIR-V IR to GLSL. 11 | 12 | 3. Edit the GLSL file as you wish 13 | 14 | 4. To compile back to SPIR-V, run (change the _**-fshader-stage**_ to correct stage): 15 | `glslc --target-env=vulkan1.3 --target-spv=spv1.6 -fshader-stage=frag fs_0x000000.glsl -o fs_0x000000.spv` 16 | 17 | 5. Put the updated .spv file to `shader/patch` folder with the same name as the original shader 18 | 19 | 6. Enable `patchShaders` in config.toml -------------------------------------------------------------------------------- /externals/MoltenVK/MoltenVK_icd.json: -------------------------------------------------------------------------------- 1 | { 2 | "file_format_version": "1.0.0", 3 | "ICD": { 4 | "library_path": "../../../Frameworks/libMoltenVK.dylib", 5 | "api_version": "1.2.0", 6 | "is_portability_driver": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /externals/cmake-modules/GetGitRevisionDescription.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Internal file for GetGitRevisionDescription.cmake 3 | # 4 | # Requires CMake 2.6 or newer (uses the 'function' command) 5 | # 6 | # Original Author: 7 | # 2009-2010 Ryan Pavlik 8 | # http://academic.cleardefinition.com 9 | # Iowa State University HCI Graduate Program/VRAC 10 | # 11 | # Copyright Iowa State University 2009-2010. 12 | # Distributed under the Boost Software License, Version 1.0. 13 | # (See accompanying file LICENSE_1_0.txt or copy at 14 | # http://www.boost.org/LICENSE_1_0.txt) 15 | 16 | set(HEAD_HASH) 17 | 18 | file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) 19 | 20 | string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) 21 | if(HEAD_CONTENTS MATCHES "ref") 22 | # named branch 23 | string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") 24 | if(EXISTS "@GIT_DIR@/${HEAD_REF}") 25 | configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 26 | elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}") 27 | configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 28 | set(HEAD_HASH "${HEAD_REF}") 29 | endif() 30 | else() 31 | # detached HEAD 32 | configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) 33 | endif() 34 | 35 | if(NOT HEAD_HASH) 36 | if(EXISTS "@GIT_DATA@/head-ref") 37 | file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) 38 | string(STRIP "${HEAD_HASH}" HEAD_HASH) 39 | else() 40 | set(HEAD_HASH "Unknown") 41 | endif() 42 | endif() 43 | -------------------------------------------------------------------------------- /externals/gcn/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | # SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | project(gcn LANGUAGES CXX) 5 | 6 | add_library(gcn INTERFACE) 7 | target_sources(gcn PRIVATE 8 | "include/gcn/si_ci_vi_merged_offset.h" 9 | "include/gcn/si_ci_vi_merged_pm4_it_opcodes.h" 10 | ) 11 | 12 | target_include_directories(gcn INTERFACE include) 13 | -------------------------------------------------------------------------------- /scripts/file_formats/sfo.hexpat: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | import std.io; 5 | import std.sys; 6 | 7 | struct Header { 8 | u32 magic; 9 | u32 version; 10 | u32 key_table_offset; 11 | u32 data_table_offset; 12 | u32 index_table_entries; 13 | }; 14 | 15 | struct KeyEntry { 16 | char name[]; 17 | } [[inline]]; 18 | 19 | struct DataEntry { 20 | if (fmt == 0x0404) { 21 | u32 int_value; 22 | } else if(fmt == 0x0004) { 23 | char bin_value[size]; 24 | } else if(fmt == 0x0204) { 25 | char str_value[size]; 26 | } else { 27 | std::warning("unknown fmt type"); 28 | } 29 | } [[inline]]; 30 | 31 | struct IndexEntry { 32 | u16 key_offset; 33 | u16 param_fmt; 34 | u32 param_len; 35 | u32 param_max_len; 36 | u32 data_offset; 37 | }; 38 | 39 | struct Entry { 40 | u64 begin = $; 41 | IndexEntry index; 42 | KeyEntry key @ KeyTableOffset + index.key_offset; 43 | DataEntry data @ DataTableOffset + index.data_offset; 44 | u8 data_empty[index.param_max_len - index.param_len] @ DataTableOffset + index.data_offset + index.param_len; 45 | $ = begin + sizeof(IndexEntry); 46 | }; 47 | 48 | Header header @ 0; 49 | std::assert(header.magic == 0x46535000, "Miss match magic"); 50 | std::assert(header.version == 0x00000101, "Miss match version"); 51 | 52 | Entry list[header.index_table_entries] @ 0x14; -------------------------------------------------------------------------------- /scripts/ps4_names2stubs.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | # SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | # Helper script that generates stub implementation of all known nids + lookup tables 5 | # for shadps4 6 | 7 | import sys, os 8 | import struct 9 | #from hashlib import sha1 10 | import hashlib 11 | from base64 import b64encode as base64enc 12 | from binascii import unhexlify as uhx 13 | 14 | #ref https://github.com/SocraticBliss/ps4_name2nid_plugin 15 | #ref derived from https://github.com/zecoxao/sce_symbols.git 16 | 17 | # needs ps4_names.txt (see: https://github.com/zecoxao/sce_symbols.git for full list) 18 | # generates "stubs.inl" to include in Core\PS4\Util 19 | 20 | NEW_NIDS = {} 21 | NAMES = 'ps4_names.txt' 22 | 23 | def name2nid(name): 24 | symbol = hashlib.sha1(name.encode() + uhx('518D64A635DED8C1E6B039B1C3E55230')).digest() 25 | id = struct.unpack(' 8 | #endif 9 | 10 | namespace Common { 11 | 12 | #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP 13 | class AdaptiveMutex { 14 | public: 15 | void lock() { 16 | pthread_mutex_lock(&mutex); 17 | } 18 | void unlock() { 19 | pthread_mutex_unlock(&mutex); 20 | } 21 | 22 | private: 23 | pthread_mutex_t mutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP; 24 | }; 25 | #endif // PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP 26 | 27 | } // namespace Common 28 | -------------------------------------------------------------------------------- /src/common/alignment.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2014 Jannik Vogel 2 | // SPDX-License-Identifier: CC0-1.0 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace Common { 10 | 11 | template 12 | [[nodiscard]] constexpr T AlignUp(T value, std::size_t size) { 13 | static_assert(std::is_unsigned_v, "T must be an unsigned value."); 14 | auto mod{static_cast(value % size)}; 15 | value -= mod; 16 | return static_cast(mod == T{0} ? value : value + size); 17 | } 18 | 19 | template 20 | [[nodiscard]] constexpr T AlignDown(T value, std::size_t size) { 21 | static_assert(std::is_unsigned_v, "T must be an unsigned value."); 22 | return static_cast(value - value % size); 23 | } 24 | 25 | template 26 | requires std::is_integral_v 27 | [[nodiscard]] constexpr bool IsAligned(T value, std::size_t alignment) { 28 | return (value & (alignment - 1)) == 0; 29 | } 30 | 31 | template 32 | requires std::is_integral_v 33 | [[nodiscard]] constexpr bool Is16KBAligned(T value) { 34 | return (value & 0x3FFF) == 0; 35 | } 36 | 37 | template 38 | requires std::is_integral_v 39 | [[nodiscard]] constexpr bool Is64KBAligned(T value) { 40 | return (value & 0xFFFF) == 0; 41 | } 42 | 43 | template 44 | requires std::is_integral_v 45 | [[nodiscard]] constexpr bool Is2MBAligned(T value) { 46 | return (value & 0x1FFFFF) == 0; 47 | } 48 | 49 | } // namespace Common 50 | -------------------------------------------------------------------------------- /src/common/arch.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #if defined(__x86_64__) || defined(_M_X64) 7 | #define ARCH_X86_64 1 8 | #elif defined(__aarch64__) || defined(_M_ARM64) 9 | #define ARCH_ARM64 1 10 | #endif 11 | -------------------------------------------------------------------------------- /src/common/assert.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "common/arch.h" 5 | #include "common/assert.h" 6 | #include "common/logging/backend.h" 7 | 8 | #if defined(ARCH_X86_64) 9 | #define Crash() __asm__ __volatile__("int $3") 10 | #elif defined(ARCH_ARM64) 11 | #define Crash() __asm__ __volatile__("brk 0") 12 | #else 13 | #error "Missing Crash() implementation for target CPU architecture." 14 | #endif 15 | 16 | void assert_fail_impl() { 17 | Common::Log::Stop(); 18 | std::fflush(stdout); 19 | Crash(); 20 | } 21 | 22 | [[noreturn]] void unreachable_impl() { 23 | Common::Log::Stop(); 24 | std::fflush(stdout); 25 | Crash(); 26 | throw std::runtime_error("Unreachable code"); 27 | } 28 | 29 | void assert_fail_debug_msg(const char* msg) { 30 | LOG_CRITICAL(Debug, "Assertion Failed!\n{}", msg); 31 | assert_fail_impl(); 32 | } 33 | -------------------------------------------------------------------------------- /src/common/concepts.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace Common { 11 | 12 | // Check if type satisfies the ContiguousContainer named requirement. 13 | template 14 | concept IsContiguousContainer = std::contiguous_iterator; 15 | 16 | template 17 | concept DerivedFrom = std::derived_from; 18 | 19 | // TODO: Replace with std::convertible_to when libc++ implements it. 20 | template 21 | concept ConvertibleTo = std::is_convertible_v; 22 | 23 | // No equivalents in the stdlib 24 | 25 | template 26 | concept IsArithmetic = std::is_arithmetic_v; 27 | 28 | template 29 | concept IsIntegral = std::is_integral_v; 30 | 31 | } // namespace Common 32 | -------------------------------------------------------------------------------- /src/common/decoder.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "common/singleton.h" 8 | #include "common/types.h" 9 | 10 | namespace Common { 11 | 12 | class DecoderImpl { 13 | public: 14 | DecoderImpl(); 15 | ~DecoderImpl(); 16 | 17 | std::string disassembleInst(ZydisDecodedInstruction& inst, ZydisDecodedOperand* operands, 18 | u64 address); 19 | void printInst(ZydisDecodedInstruction& inst, ZydisDecodedOperand* operands, u64 address); 20 | void printInstruction(void* code, u64 address); 21 | ZyanStatus decodeInstruction(ZydisDecodedInstruction& inst, ZydisDecodedOperand* operands, 22 | void* data, u64 size = 15); 23 | 24 | private: 25 | ZydisDecoder m_decoder; 26 | ZydisFormatter m_formatter; 27 | }; 28 | 29 | using Decoder = Common::Singleton; 30 | 31 | } // namespace Common 32 | -------------------------------------------------------------------------------- /src/common/discord_rpc_handler.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace DiscordRPCHandler { 11 | 12 | enum class RPCStatus { 13 | Idling, 14 | Playing, 15 | }; 16 | 17 | class RPC { 18 | std::uint64_t startTimestamp; 19 | bool rpcEnabled = false; 20 | RPCStatus status; 21 | 22 | public: 23 | void init(); 24 | void setStatusIdling(); 25 | void setStatusPlaying(const std::string& game_name, const std::string& game_id); 26 | void shutdown(); 27 | bool getRPCEnabled(); 28 | }; 29 | 30 | } // namespace DiscordRPCHandler 31 | -------------------------------------------------------------------------------- /src/common/div_ceil.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace Common { 10 | 11 | /// Ceiled integer division. 12 | template 13 | requires std::is_integral_v && std::is_unsigned_v 14 | [[nodiscard]] constexpr N DivCeil(N number, D divisor) { 15 | return static_cast((static_cast(number) + divisor - 1) / divisor); 16 | } 17 | 18 | /// Ceiled integer division with logarithmic divisor in base 2 19 | template 20 | requires std::is_integral_v && std::is_unsigned_v 21 | [[nodiscard]] constexpr N DivCeilLog2(N value, D alignment_log2) { 22 | return static_cast((static_cast(value) + (D(1) << alignment_log2) - 1) >> alignment_log2); 23 | } 24 | 25 | } // namespace Common 26 | -------------------------------------------------------------------------------- /src/common/error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2013 Dolphin Emulator Project 2 | // SPDX-FileCopyrightText: 2014 Citra Emulator Project 3 | // SPDX-License-Identifier: GPL-2.0-or-later 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace Common { 10 | 11 | // Generic function to get last error message. 12 | // Call directly after the command or use the error num. 13 | // This function might change the error code. 14 | // Defined in error.cpp. 15 | [[nodiscard]] std::string GetLastErrorMsg(); 16 | 17 | // Like GetLastErrorMsg(), but passing an explicit error code. 18 | // Defined in error.cpp. 19 | [[nodiscard]] std::string NativeErrorToString(int e); 20 | 21 | } // namespace Common 22 | -------------------------------------------------------------------------------- /src/common/fixed_value.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | /** 7 | * @brief A template class that encapsulates a fixed, compile-time constant value. 8 | * 9 | * @tparam T The type of the value. 10 | * @tparam Value The fixed value of type T. 11 | * 12 | * This class provides a way to encapsulate a value that is constant and known at compile-time. 13 | * The value is stored as a private member and cannot be changed. Any attempt to assign a new 14 | * value to an object of this class will reset it to the fixed value. 15 | */ 16 | template 17 | class FixedValue { 18 | T m_value{Value}; 19 | 20 | public: 21 | constexpr FixedValue() = default; 22 | 23 | constexpr explicit(false) operator T() const { 24 | return m_value; 25 | } 26 | 27 | FixedValue& operator=(const T&) { 28 | m_value = Value; 29 | return *this; 30 | } 31 | FixedValue& operator=(T&&) noexcept { 32 | m_value = {Value}; 33 | return *this; 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /src/common/func_traits.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace Common { 9 | 10 | template 11 | struct FuncTraits {}; 12 | 13 | template 14 | struct FuncTraits { 15 | using ReturnType = ReturnType_; 16 | 17 | static constexpr size_t NUM_ARGS = sizeof...(Args); 18 | 19 | template 20 | using ArgType = std::tuple_element_t>; 21 | }; 22 | 23 | template 24 | struct LambdaTraits : LambdaTraits::operator())> {}; 25 | 26 | template 27 | struct LambdaTraits { 28 | template 29 | using ArgType = std::tuple_element_t>; 30 | 31 | static constexpr size_t NUM_ARGS{sizeof...(Args)}; 32 | }; 33 | 34 | } // namespace Common 35 | -------------------------------------------------------------------------------- /src/common/hash.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | [[nodiscard]] inline u64 HashCombine(const u64 seed, const u64 hash) { 9 | return seed ^ (hash + 0x9e3779b9 + (seed << 12) + (seed >> 4)); 10 | } 11 | 12 | [[nodiscard]] inline u32 HashCombine(const u32 seed, const u32 hash) { 13 | return seed ^ (hash + 0x9e3779b9 + (seed << 6) + (seed >> 2)); 14 | } -------------------------------------------------------------------------------- /src/common/logging/backend.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2014 Citra Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "common/logging/filter.h" 8 | 9 | namespace Common::Log { 10 | 11 | class Filter; 12 | 13 | /// Initializes the logging system. This should be the first thing called in main. 14 | void Initialize(std::string_view log_file = ""); 15 | 16 | bool IsActive(); 17 | 18 | /// Starts the logging threads. 19 | void Start(); 20 | 21 | /// Explictily stops the logger thread and flushes the buffers 22 | void Stop(); 23 | 24 | /// The global filter will prevent any messages from even being processed if they are filtered. 25 | void SetGlobalFilter(const Filter& filter); 26 | 27 | void SetColorConsoleBackendEnabled(bool enabled); 28 | 29 | } // namespace Common::Log 30 | -------------------------------------------------------------------------------- /src/common/logging/formatter.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2014 Citra Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | // Adapted from https://github.com/fmtlib/fmt/issues/2704 10 | // a generic formatter for enum classes 11 | #if FMT_VERSION >= 80100 12 | template 13 | struct fmt::formatter, char>> 14 | : formatter> { 15 | template 16 | auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) { 17 | return fmt::formatter>::format( 18 | static_cast>(value), ctx); 19 | } 20 | }; 21 | #endif 22 | 23 | namespace fmt { 24 | template 25 | struct UTF { 26 | T data; 27 | 28 | explicit UTF(const std::u8string_view view) { 29 | data = view.empty() ? T{} : T{(const char*)&view.front(), (const char*)&view.back() + 1}; 30 | } 31 | 32 | explicit UTF(const std::u8string& str) : UTF(std::u8string_view{str}) {} 33 | }; 34 | } // namespace fmt 35 | 36 | template <> 37 | struct fmt::formatter, char> : formatter { 38 | template 39 | auto format(const UTF& wrapper, FormatContext& ctx) const { 40 | return formatter::format(wrapper.data, ctx); 41 | } 42 | }; -------------------------------------------------------------------------------- /src/common/logging/log_entry.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2014 Citra Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include "common/logging/types.h" 9 | 10 | namespace Common::Log { 11 | 12 | /** 13 | * A log entry. Log entries are store in a structured format to permit more varied output 14 | * formatting on different frontends, as well as facilitating filtering and aggregation. 15 | */ 16 | struct Entry { 17 | std::chrono::microseconds timestamp; 18 | Class log_class{}; 19 | Level log_level{}; 20 | const char* filename = nullptr; 21 | u32 line_num = 0; 22 | std::string function; 23 | std::string message; 24 | }; 25 | 26 | } // namespace Common::Log 27 | -------------------------------------------------------------------------------- /src/common/logging/text_formatter.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2014 Citra Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace Common::Log { 9 | 10 | struct Entry; 11 | 12 | /// Formats a log entry into the provided text buffer. 13 | std::string FormatLogMessage(const Entry& entry); 14 | 15 | /// Formats and prints a log entry to stderr. 16 | void PrintMessage(const Entry& entry); 17 | 18 | /// Prints the same message as `PrintMessage`, but colored according to the severity level. 19 | void PrintColoredMessage(const Entry& entry); 20 | 21 | } // namespace Common::Log 22 | -------------------------------------------------------------------------------- /src/common/memory_patcher.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | 9 | namespace MemoryPatcher { 10 | 11 | extern uintptr_t g_eboot_address; 12 | extern uint64_t g_eboot_image_size; 13 | extern std::string g_game_serial; 14 | extern std::string patchFile; 15 | 16 | enum PatchMask : uint8_t { 17 | None, 18 | Mask, 19 | Mask_Jump32, 20 | }; 21 | 22 | struct patchInfo { 23 | std::string gameSerial; 24 | std::string modNameStr; 25 | std::string offsetStr; 26 | std::string valueStr; 27 | bool isOffset; 28 | bool littleEndian; 29 | PatchMask patchMask; 30 | int maskOffset; 31 | }; 32 | 33 | extern std::vector pending_patches; 34 | 35 | std::string convertValueToHex(const std::string type, const std::string valueStr); 36 | 37 | void OnGameLoaded(); 38 | void AddPatchToQueue(patchInfo patchToAdd); 39 | void ApplyPendingPatches(); 40 | 41 | void PatchMemory(std::string modNameStr, std::string offsetStr, std::string valueStr, 42 | std::string targetStr, std::string sizeStr, bool isOffset, bool littleEndian, 43 | PatchMask patchMask = PatchMask::None, int maskOffset = 0); 44 | 45 | static std::vector PatternToByte(const std::string& pattern); 46 | uintptr_t PatternScan(const std::string& signature); 47 | 48 | } // namespace MemoryPatcher -------------------------------------------------------------------------------- /src/common/native_clock.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "common/native_clock.h" 5 | #include "common/rdtsc.h" 6 | #include "common/uint128.h" 7 | 8 | namespace Common { 9 | 10 | NativeClock::NativeClock() 11 | : rdtsc_frequency{EstimateRDTSCFrequency()}, 12 | ns_rdtsc_factor{GetFixedPoint64Factor(std::nano::den, rdtsc_frequency)}, 13 | us_rdtsc_factor{GetFixedPoint64Factor(std::micro::den, rdtsc_frequency)}, 14 | ms_rdtsc_factor{GetFixedPoint64Factor(std::milli::den, rdtsc_frequency)} {} 15 | 16 | u64 NativeClock::GetTimeNS(u64 base_ptc /*= 0*/) const { 17 | return MultiplyHigh(GetUptime() - base_ptc, ns_rdtsc_factor); 18 | } 19 | 20 | u64 NativeClock::GetTimeUS(u64 base_ptc /*= 0*/) const { 21 | return MultiplyHigh(GetUptime() - base_ptc, us_rdtsc_factor); 22 | } 23 | 24 | u64 NativeClock::GetTimeMS(u64 base_ptc /*= 0*/) const { 25 | return MultiplyHigh(GetUptime() - base_ptc, ms_rdtsc_factor); 26 | } 27 | 28 | u64 NativeClock::GetUptime() const { 29 | return FencedRDTSC(); 30 | } 31 | 32 | } // namespace Common 33 | -------------------------------------------------------------------------------- /src/common/native_clock.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "common/types.h" 8 | 9 | namespace Common { 10 | 11 | class NativeClock final { 12 | public: 13 | explicit NativeClock(); 14 | 15 | u64 GetTscFrequency() const { 16 | return rdtsc_frequency; 17 | } 18 | 19 | u64 GetTimeNS(u64 base_ptc = 0) const; 20 | u64 GetTimeUS(u64 base_ptc = 0) const; 21 | u64 GetTimeMS(u64 base_ptc = 0) const; 22 | u64 GetUptime() const; 23 | 24 | private: 25 | u64 rdtsc_frequency; 26 | u64 ns_rdtsc_factor; 27 | u64 us_rdtsc_factor; 28 | u64 ms_rdtsc_factor; 29 | }; 30 | 31 | } // namespace Common 32 | -------------------------------------------------------------------------------- /src/common/ntapi.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #ifdef _WIN32 5 | 6 | #include "ntapi.h" 7 | 8 | NtClose_t NtClose = nullptr; 9 | NtSetInformationFile_t NtSetInformationFile = nullptr; 10 | NtCreateThread_t NtCreateThread = nullptr; 11 | NtTerminateThread_t NtTerminateThread = nullptr; 12 | NtQueueApcThreadEx_t NtQueueApcThreadEx = nullptr; 13 | 14 | namespace Common::NtApi { 15 | 16 | void Initialize() { 17 | HMODULE nt_handle = GetModuleHandleA("ntdll.dll"); 18 | 19 | // http://stackoverflow.com/a/31411628/4725495 20 | NtClose = (NtClose_t)GetProcAddress(nt_handle, "NtClose"); 21 | NtSetInformationFile = 22 | (NtSetInformationFile_t)GetProcAddress(nt_handle, "NtSetInformationFile"); 23 | NtCreateThread = (NtCreateThread_t)GetProcAddress(nt_handle, "NtCreateThread"); 24 | NtTerminateThread = (NtTerminateThread_t)GetProcAddress(nt_handle, "NtTerminateThread"); 25 | NtQueueApcThreadEx = (NtQueueApcThreadEx_t)GetProcAddress(nt_handle, "NtQueueApcThreadEx"); 26 | } 27 | 28 | } // namespace Common::NtApi 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/common/number_utils.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace NumberUtils { 9 | 10 | float Uf11ToF32(u16 val); 11 | float Uf10ToF32(u16 val); 12 | float Uf16ToF32(u16 val); 13 | float U2ToUnorm(u8 val); 14 | float S2ToSnorm(s8 val); 15 | float U4ToUnorm(u8 val); 16 | float S4ToSnorm(s8 val); 17 | float U5ToUnorm(u8 val); 18 | float S5ToSnorm(s8 val); 19 | float U6ToUnorm(u8 val); 20 | float S6ToSnorm(s8 val); 21 | float U8ToUnorm(u8 val); 22 | float S8ToSnorm(s8 val); 23 | float U10ToUnorm(u16 val); 24 | float S10ToSnorm(s16 val); 25 | float U16ToUnorm(u16 val); 26 | float S16ToSnorm(s16 val); 27 | 28 | } // namespace NumberUtils 29 | -------------------------------------------------------------------------------- /src/common/rdtsc.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/arch.h" 7 | 8 | #ifdef _MSC_VER 9 | #include 10 | #endif 11 | 12 | #include "common/types.h" 13 | 14 | namespace Common { 15 | 16 | #ifdef _MSC_VER 17 | __forceinline static u64 FencedRDTSC() { 18 | #ifdef ARCH_X86_64 19 | _mm_lfence(); 20 | _ReadWriteBarrier(); 21 | const u64 result = __rdtsc(); 22 | _mm_lfence(); 23 | _ReadWriteBarrier(); 24 | return result; 25 | #else 26 | #error "Missing FencedRDTSC() implementation for target CPU architecture." 27 | #endif 28 | } 29 | #else 30 | static inline u64 FencedRDTSC() { 31 | #ifdef ARCH_X86_64 32 | u64 eax; 33 | u64 edx; 34 | asm volatile("lfence\n\t" 35 | "rdtsc\n\t" 36 | "lfence\n\t" 37 | : "=a"(eax), "=d"(edx)); 38 | return (edx << 32) | eax; 39 | #elif defined(ARCH_ARM64) 40 | u64 ret; 41 | asm volatile("isb\n\t" 42 | "mrs %0, cntvct_el0\n\t" 43 | "isb\n\t" 44 | : "=r"(ret)::"memory"); 45 | return ret; 46 | #else 47 | #error "Missing FencedRDTSC() implementation for target CPU architecture." 48 | #endif 49 | } 50 | #endif 51 | 52 | u64 EstimateRDTSCFrequency(); 53 | 54 | } // namespace Common 55 | -------------------------------------------------------------------------------- /src/common/scm_rev.cpp.in: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "common/scm_rev.h" 5 | 6 | #define GIT_REV "@GIT_REV@" 7 | #define GIT_BRANCH "@GIT_BRANCH@" 8 | #define GIT_DESC "@GIT_DESC@" 9 | #define GIT_REMOTE_NAME "@GIT_REMOTE_NAME@" 10 | #define GIT_REMOTE_URL "@GIT_REMOTE_URL@" 11 | #define BUILD_DATE "@BUILD_DATE@" 12 | 13 | namespace Common { 14 | 15 | const char g_scm_rev[] = GIT_REV; 16 | const char g_scm_branch[] = GIT_BRANCH; 17 | const char g_scm_desc[] = GIT_DESC; 18 | const char g_scm_remote_name[] = GIT_REMOTE_NAME; 19 | const char g_scm_remote_url[] = GIT_REMOTE_URL; 20 | const char g_scm_date[] = BUILD_DATE; 21 | 22 | } // namespace 23 | 24 | -------------------------------------------------------------------------------- /src/common/scm_rev.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | namespace Common { 7 | 8 | extern const char g_scm_rev[]; 9 | extern const char g_scm_branch[]; 10 | extern const char g_scm_desc[]; 11 | extern const char g_scm_remote_name[]; 12 | extern const char g_scm_remote_url[]; 13 | extern const char g_scm_date[]; 14 | 15 | } // namespace Common 16 | -------------------------------------------------------------------------------- /src/common/signal_context.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Common { 9 | 10 | void* GetXmmPointer(void* ctx, u8 index); 11 | 12 | void* GetRip(void* ctx); 13 | 14 | void IncrementRip(void* ctx, u64 length); 15 | 16 | bool IsWriteError(void* ctx); 17 | 18 | } // namespace Common -------------------------------------------------------------------------------- /src/common/singleton.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace Common { 9 | 10 | template 11 | class Singleton { 12 | public: 13 | static T* Instance() { 14 | if (!m_instance) { 15 | m_instance = std::make_unique(); 16 | } 17 | return m_instance.get(); 18 | } 19 | 20 | protected: 21 | Singleton(); 22 | ~Singleton(); 23 | 24 | private: 25 | static inline std::unique_ptr m_instance{}; 26 | }; 27 | 28 | } // namespace Common 29 | -------------------------------------------------------------------------------- /src/common/spin_lock.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "common/spin_lock.h" 5 | 6 | #if _MSC_VER 7 | #include 8 | #if _M_AMD64 9 | #define __x86_64__ 1 10 | #endif 11 | #if _M_ARM64 12 | #define __aarch64__ 1 13 | #endif 14 | #else 15 | #if __x86_64__ 16 | #include 17 | #endif 18 | #endif 19 | 20 | namespace { 21 | 22 | void ThreadPause() { 23 | #if __x86_64__ 24 | _mm_pause(); 25 | #elif __aarch64__ && _MSC_VER 26 | __yield(); 27 | #elif __aarch64__ 28 | asm("yield"); 29 | #endif 30 | } 31 | 32 | } // Anonymous namespace 33 | 34 | namespace Common { 35 | 36 | void SpinLock::lock() { 37 | while (lck.test_and_set(std::memory_order_acquire)) { 38 | ThreadPause(); 39 | } 40 | } 41 | 42 | void SpinLock::unlock() { 43 | lck.clear(std::memory_order_release); 44 | } 45 | 46 | bool SpinLock::try_lock() { 47 | if (lck.test_and_set(std::memory_order_acquire)) { 48 | return false; 49 | } 50 | return true; 51 | } 52 | 53 | } // namespace Common 54 | -------------------------------------------------------------------------------- /src/common/spin_lock.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace Common { 9 | 10 | /** 11 | * SpinLock class 12 | * a lock similar to mutex that forces a thread to spin wait instead calling the 13 | * supervisor. Should be used on short sequences of code. 14 | */ 15 | class SpinLock { 16 | public: 17 | SpinLock() = default; 18 | 19 | SpinLock(const SpinLock&) = delete; 20 | SpinLock& operator=(const SpinLock&) = delete; 21 | 22 | SpinLock(SpinLock&&) = delete; 23 | SpinLock& operator=(SpinLock&&) = delete; 24 | 25 | void lock(); 26 | void unlock(); 27 | [[nodiscard]] bool try_lock(); 28 | 29 | private: 30 | std::atomic_flag lck = ATOMIC_FLAG_INIT; 31 | }; 32 | 33 | } // namespace Common 34 | -------------------------------------------------------------------------------- /src/common/stb.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #define STB_IMAGE_IMPLEMENTATION 5 | #define STBI_ONLY_PNG 6 | #define STBI_NO_STDIO 7 | #include "common/stb.h" 8 | -------------------------------------------------------------------------------- /src/common/stb.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | -------------------------------------------------------------------------------- /src/common/string_util.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2013 Dolphin Emulator Project 2 | // SPDX-FileCopyrightText: 2014 Citra Emulator Project 3 | // SPDX-License-Identifier: GPL-2.0-or-later 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | namespace Common { 11 | 12 | /// Make a string lowercase 13 | [[nodiscard]] std::string ToLower(std::string_view str); 14 | 15 | void ToLowerInPlace(std::string& str); 16 | 17 | std::vector SplitString(const std::string& str, char delimiter); 18 | 19 | std::string_view U8stringToString(std::u8string_view u8str); 20 | 21 | #ifdef _WIN32 22 | [[nodiscard]] std::string UTF16ToUTF8(std::wstring_view input); 23 | [[nodiscard]] std::wstring UTF8ToUTF16W(std::string_view str); 24 | #endif 25 | 26 | } // namespace Common 27 | -------------------------------------------------------------------------------- /src/common/support/avdec.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | // support header file for libav 7 | 8 | // The av_err2str macro in libavutil/error.h does not play nice with C++ 9 | #ifdef av_err2str 10 | #undef av_err2str 11 | #include 12 | av_always_inline std::string av_err2string(int errnum) { 13 | char errbuf[AV_ERROR_MAX_STRING_SIZE]; 14 | return av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, errnum); 15 | } 16 | #define av_err2str(err) av_err2string(err).c_str() 17 | #endif // av_err2str 18 | -------------------------------------------------------------------------------- /src/common/thread.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2013 Dolphin Emulator Project 2 | // SPDX-FileCopyrightText: 2014 Citra Emulator Project 3 | // SPDX-License-Identifier: GPL-2.0-or-later 4 | 5 | #pragma once 6 | 7 | #include 8 | #include "common/types.h" 9 | 10 | namespace Common { 11 | 12 | enum class ThreadPriority : u32 { 13 | Low = 0, 14 | Normal = 1, 15 | High = 2, 16 | VeryHigh = 3, 17 | Critical = 4, 18 | }; 19 | 20 | void SetCurrentThreadRealtime(std::chrono::nanoseconds period_ns); 21 | 22 | void SetCurrentThreadPriority(ThreadPriority new_priority); 23 | 24 | void SetCurrentThreadName(const char* name); 25 | 26 | void SetThreadName(void* thread, const char* name); 27 | 28 | class AccurateTimer { 29 | std::chrono::nanoseconds target_interval{}; 30 | std::chrono::nanoseconds total_wait{}; 31 | 32 | std::chrono::high_resolution_clock::time_point start_time; 33 | 34 | public: 35 | explicit AccurateTimer(std::chrono::nanoseconds target_interval); 36 | 37 | void Start(); 38 | 39 | void End(); 40 | 41 | std::chrono::nanoseconds GetTotalWait() const { 42 | return total_wait; 43 | } 44 | }; 45 | 46 | } // namespace Common 47 | -------------------------------------------------------------------------------- /src/common/types.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | using s8 = std::int8_t; 10 | using s16 = std::int16_t; 11 | using s32 = std::int32_t; 12 | using s64 = std::int64_t; 13 | 14 | using u8 = std::uint8_t; 15 | using u16 = std::uint16_t; 16 | using u32 = std::uint32_t; 17 | using u64 = std::uint64_t; 18 | 19 | using f32 = float; 20 | using f64 = double; 21 | 22 | using u128 = std::array; 23 | static_assert(sizeof(u128) == 16, "u128 must be 128 bits wide"); 24 | 25 | using VAddr = uintptr_t; 26 | using PAddr = uintptr_t; 27 | 28 | #define PS4_SYSV_ABI __attribute__((sysv_abi)) 29 | 30 | // UDLs for memory size values 31 | constexpr unsigned long long operator""_KB(unsigned long long x) { 32 | return 1024ULL * x; 33 | } 34 | constexpr unsigned long long operator""_MB(unsigned long long x) { 35 | return 1024_KB * x; 36 | } 37 | constexpr unsigned long long operator""_GB(unsigned long long x) { 38 | return 1024_MB * x; 39 | } 40 | -------------------------------------------------------------------------------- /src/common/version.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace Common { 10 | 11 | constexpr char VERSION[] = "0.6.1 WIP"; 12 | constexpr bool isRelease = false; 13 | 14 | } // namespace Common 15 | -------------------------------------------------------------------------------- /src/core/aerolib/aerolib.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include 5 | #include "common/types.h" 6 | #include "core/aerolib/aerolib.h" 7 | 8 | namespace Core::AeroLib { 9 | 10 | // Use a direct table here + binary search as contents are static 11 | static constexpr NidEntry NIDS[] = { 12 | #define STUB(nid, name) {nid, #name}, 13 | #include "aerolib.inl" 14 | #undef STUB 15 | }; 16 | 17 | const NidEntry* FindByNid(const char* nid) { 18 | s64 l = 0; 19 | s64 r = sizeof(NIDS) / sizeof(NIDS[0]) - 1; 20 | 21 | while (l <= r) { 22 | const size_t m = l + (r - l) / 2; 23 | const int cmp = std::strcmp(NIDS[m].nid, nid); 24 | if (cmp == 0) { 25 | return &NIDS[m]; 26 | } else if (cmp < 0) { 27 | l = m + 1; 28 | } else { 29 | r = m - 1; 30 | } 31 | } 32 | return nullptr; 33 | } 34 | 35 | } // namespace Core::AeroLib 36 | -------------------------------------------------------------------------------- /src/core/aerolib/aerolib.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace Core::AeroLib { 9 | 10 | struct NidEntry { 11 | const char* nid; 12 | const char* name; 13 | }; 14 | 15 | const NidEntry* FindByNid(const char* nid); 16 | 17 | } // namespace Core::AeroLib 18 | -------------------------------------------------------------------------------- /src/core/aerolib/stubs.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::AeroLib { 9 | 10 | u64 UnresolvedStub(); 11 | 12 | u64 GetStub(const char* nid); 13 | 14 | } // namespace Core::AeroLib 15 | -------------------------------------------------------------------------------- /src/core/cpu_patches.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core { 9 | 10 | /// Initializes a stack for the current thread for use by patch implementations. 11 | void InitializeThreadPatchStack(); 12 | 13 | /// Cleans up the patch stack for the current thread. 14 | void CleanupThreadPatchStack(); 15 | 16 | /// Registers a module for patching, providing an area to generate trampoline code. 17 | void RegisterPatchModule(void* module_ptr, u64 module_size, void* trampoline_area_ptr, 18 | u64 trampoline_area_size); 19 | 20 | /// Applies CPU patches that need to be done before beginning executions. 21 | void PrePatchInstructions(u64 segment_addr, u64 segment_size); 22 | 23 | } // namespace Core 24 | -------------------------------------------------------------------------------- /src/core/devices/base_device.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "base_device.h" 5 | 6 | namespace Core::Devices { 7 | 8 | BaseDevice::BaseDevice() = default; 9 | 10 | BaseDevice::~BaseDevice() = default; 11 | 12 | } // namespace Core::Devices -------------------------------------------------------------------------------- /src/core/devices/console_device.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | #include 6 | #include "base_device.h" 7 | 8 | namespace Core::Devices { 9 | 10 | class ConsoleDevice final : BaseDevice { 11 | u32 handle; 12 | 13 | public: 14 | static std::shared_ptr Create(u32 handle, const char*, int, u16); 15 | explicit ConsoleDevice(u32 handle) : handle(handle) {} 16 | 17 | ~ConsoleDevice() override = default; 18 | 19 | int ioctl(u64 cmd, Common::VaCtx* args) override; 20 | s64 write(const void* buf, size_t nbytes) override; 21 | size_t readv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) override; 22 | size_t writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) override; 23 | s64 preadv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) override; 24 | s64 lseek(s64 offset, int whence) override; 25 | s64 read(void* buf, size_t nbytes) override; 26 | int fstat(Libraries::Kernel::OrbisKernelStat* sb) override; 27 | s32 fsync() override; 28 | int ftruncate(s64 length) override; 29 | int getdents(void* buf, u32 nbytes, s64* basep) override; 30 | s64 pwrite(const void* buf, size_t nbytes, u64 offset) override; 31 | }; 32 | 33 | } // namespace Core::Devices -------------------------------------------------------------------------------- /src/core/devices/deci_tty6_device.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | #include 6 | #include "base_device.h" 7 | 8 | namespace Core::Devices { 9 | 10 | class DeciTty6Device final : BaseDevice { 11 | u32 handle; 12 | 13 | public: 14 | static std::shared_ptr Create(u32 handle, const char*, int, u16); 15 | explicit DeciTty6Device(u32 handle) : handle(handle) {} 16 | 17 | ~DeciTty6Device() override = default; 18 | 19 | int ioctl(u64 cmd, Common::VaCtx* args) override; 20 | s64 write(const void* buf, size_t nbytes) override; 21 | size_t readv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) override; 22 | size_t writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) override; 23 | s64 preadv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) override; 24 | s64 lseek(s64 offset, int whence) override; 25 | s64 read(void* buf, size_t nbytes) override; 26 | int fstat(Libraries::Kernel::OrbisKernelStat* sb) override; 27 | s32 fsync() override; 28 | int ftruncate(s64 length) override; 29 | int getdents(void* buf, u32 nbytes, s64* basep) override; 30 | s64 pwrite(const void* buf, size_t nbytes, u64 offset) override; 31 | }; 32 | 33 | } // namespace Core::Devices -------------------------------------------------------------------------------- /src/core/devices/logger.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "base_device.h" 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace Core::Devices { 13 | 14 | class Logger final : BaseDevice { 15 | std::string prefix; 16 | bool is_err; 17 | 18 | std::recursive_mutex mtx; 19 | std::vector buffer; 20 | 21 | public: 22 | explicit Logger(std::string prefix, bool is_err); 23 | 24 | ~Logger() override; 25 | 26 | s64 write(const void* buf, size_t nbytes) override; 27 | size_t writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) override; 28 | s64 pwrite(const void* buf, size_t nbytes, u64 offset) override; 29 | 30 | s32 fsync() override; 31 | 32 | private: 33 | void log(const char* buf, size_t nbytes); 34 | void log_flush(); 35 | }; 36 | 37 | } // namespace Core::Devices 38 | -------------------------------------------------------------------------------- /src/core/devices/random_device.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | #include 6 | #include "base_device.h" 7 | 8 | namespace Core::Devices { 9 | 10 | class RandomDevice final : BaseDevice { 11 | u32 handle; 12 | 13 | public: 14 | static std::shared_ptr Create(u32 handle, const char*, int, u16); 15 | explicit RandomDevice(u32 handle) : handle(handle) {} 16 | 17 | ~RandomDevice() override = default; 18 | 19 | int ioctl(u64 cmd, Common::VaCtx* args) override; 20 | s64 write(const void* buf, size_t nbytes) override; 21 | size_t readv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) override; 22 | size_t writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) override; 23 | s64 preadv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) override; 24 | s64 lseek(s64 offset, int whence) override; 25 | s64 read(void* buf, size_t nbytes) override; 26 | int fstat(Libraries::Kernel::OrbisKernelStat* sb) override; 27 | s32 fsync() override; 28 | int ftruncate(s64 length) override; 29 | int getdents(void* buf, u32 nbytes, s64* basep) override; 30 | s64 pwrite(const void* buf, size_t nbytes, u64 offset) override; 31 | }; 32 | 33 | } // namespace Core::Devices -------------------------------------------------------------------------------- /src/core/devices/srandom_device.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | #include 6 | #include "base_device.h" 7 | 8 | namespace Core::Devices { 9 | 10 | class SRandomDevice final : BaseDevice { 11 | u32 handle; 12 | 13 | public: 14 | static std::shared_ptr Create(u32 handle, const char*, int, u16); 15 | explicit SRandomDevice(u32 handle) : handle(handle) {} 16 | 17 | ~SRandomDevice() override = default; 18 | 19 | int ioctl(u64 cmd, Common::VaCtx* args) override; 20 | s64 write(const void* buf, size_t nbytes) override; 21 | size_t readv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) override; 22 | size_t writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) override; 23 | s64 preadv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) override; 24 | s64 lseek(s64 offset, int whence) override; 25 | s64 read(void* buf, size_t nbytes) override; 26 | int fstat(Libraries::Kernel::OrbisKernelStat* sb) override; 27 | s32 fsync() override; 28 | int ftruncate(s64 length) override; 29 | int getdents(void* buf, u32 nbytes, s64* basep) override; 30 | s64 pwrite(const void* buf, size_t nbytes, u64 offset) override; 31 | }; 32 | 33 | } // namespace Core::Devices -------------------------------------------------------------------------------- /src/core/devices/urandom_device.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | #include 6 | #include "base_device.h" 7 | 8 | namespace Core::Devices { 9 | 10 | class URandomDevice final : BaseDevice { 11 | u32 handle; 12 | 13 | public: 14 | static std::shared_ptr Create(u32 handle, const char*, int, u16); 15 | explicit URandomDevice(u32 handle) : handle(handle) {} 16 | 17 | ~URandomDevice() override = default; 18 | 19 | int ioctl(u64 cmd, Common::VaCtx* args) override; 20 | s64 write(const void* buf, size_t nbytes) override; 21 | size_t readv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) override; 22 | size_t writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) override; 23 | s64 preadv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) override; 24 | s64 lseek(s64 offset, int whence) override; 25 | s64 read(void* buf, size_t nbytes) override; 26 | int fstat(Libraries::Kernel::OrbisKernelStat* sb) override; 27 | s32 fsync() override; 28 | int ftruncate(s64 length) override; 29 | int getdents(void* buf, u32 nbytes, s64* basep) override; 30 | s64 pwrite(const void* buf, size_t nbytes, u64 offset) override; 31 | }; 32 | 33 | } // namespace Core::Devices -------------------------------------------------------------------------------- /src/core/devtools/help.txt: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | R"( 4 | * If you hold shift, you can move the window without docking it. 5 | * You don't need to close every window you open. When a parent window is closed, all its children will be closed too. 6 | * If you want to inspect or compare more than 1 frame dump without undocking, there's a option to keep showing opened popups even when in hide/minimize the frame dump window. 7 | * To use the disassembly viewer, you need to set up a cli to use a external disassembler and use "{src}" as a placeholder for the source code file, e.g. dis.exe --some-opt "{src}" 8 | )" -------------------------------------------------------------------------------- /src/core/devtools/layer.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "imgui/imgui_layer.h" 7 | 8 | namespace Core::Devtools { 9 | 10 | class Layer final : public ImGui::Layer { 11 | 12 | static void DrawMenuBar(); 13 | 14 | static void DrawAdvanced(); 15 | 16 | static void DrawSimple(); 17 | 18 | public: 19 | static void SetupSettings(); 20 | 21 | void Draw() override; 22 | }; 23 | 24 | } // namespace Core::Devtools 25 | -------------------------------------------------------------------------------- /src/core/devtools/options.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include 5 | 6 | #include "options.h" 7 | 8 | namespace Core::Devtools { 9 | 10 | TOptions Options; 11 | 12 | void LoadOptionsConfig(const char* line) { 13 | char str[512]; 14 | int i; 15 | if (sscanf(line, "disassembler_cli_isa=%511[^\n]", str) == 1) { 16 | Options.disassembler_cli_isa = str; 17 | return; 18 | } 19 | if (sscanf(line, "disassembler_cli_spv=%511[^\n]", str) == 1) { 20 | Options.disassembler_cli_spv = str; 21 | return; 22 | } 23 | if (sscanf(line, "frame_dump_render_on_collapse=%d", &i) == 1) { 24 | Options.frame_dump_render_on_collapse = i != 0; 25 | return; 26 | } 27 | } 28 | 29 | void SerializeOptionsConfig(ImGuiTextBuffer* buf) { 30 | buf->appendf("disassembler_cli_isa=%s\n", Options.disassembler_cli_isa.c_str()); 31 | buf->appendf("disassembler_cli_spv=%s\n", Options.disassembler_cli_spv.c_str()); 32 | buf->appendf("frame_dump_render_on_collapse=%d\n", Options.frame_dump_render_on_collapse); 33 | } 34 | 35 | } // namespace Core::Devtools 36 | -------------------------------------------------------------------------------- /src/core/devtools/options.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | struct ImGuiTextBuffer; 9 | 10 | namespace Core::Devtools { 11 | 12 | struct TOptions { 13 | std::string disassembler_cli_isa{"clrxdisasm --raw {src}"}; 14 | std::string disassembler_cli_spv{"spirv-cross -V {src}"}; 15 | bool frame_dump_render_on_collapse{false}; 16 | }; 17 | 18 | extern TOptions Options; 19 | 20 | void LoadOptionsConfig(const char* line); 21 | void SerializeOptionsConfig(ImGuiTextBuffer* buf); 22 | 23 | } // namespace Core::Devtools 24 | -------------------------------------------------------------------------------- /src/core/devtools/widget/frame_dump.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include "cmd_list.h" 10 | #include "core/debug_state.h" 11 | 12 | namespace Core::Devtools::Widget { 13 | 14 | class CmdListViewer; 15 | 16 | class FrameDumpViewer { 17 | friend class CmdListViewer; 18 | 19 | std::shared_ptr frame_dump; 20 | int id; 21 | 22 | std::vector cmd_list_viewer; 23 | std::array has_queue_type; 24 | 25 | DebugStateType::QueueType selected_queue_type; 26 | s32 selected_submit_num; 27 | s32 selected_queue_num2; 28 | s32 selected_cmd = -1; 29 | 30 | CmdListFilter filter; 31 | 32 | public: 33 | bool is_open = true; 34 | 35 | explicit FrameDumpViewer(const DebugStateType::FrameDump& frame_dump); 36 | 37 | ~FrameDumpViewer(); 38 | 39 | void Draw(); 40 | }; 41 | 42 | } // namespace Core::Devtools::Widget -------------------------------------------------------------------------------- /src/core/devtools/widget/frame_graph.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Devtools::Widget { 9 | 10 | class FrameGraph { 11 | static constexpr u32 FRAME_BUFFER_SIZE = 1024; 12 | struct FrameInfo { 13 | u32 num; 14 | float delta; 15 | }; 16 | 17 | std::array frame_list{}; 18 | 19 | float deltaTime{}; 20 | float frameRate{}; 21 | 22 | void DrawFrameGraph(); 23 | 24 | public: 25 | bool is_open = true; 26 | 27 | void Draw(); 28 | 29 | void AddFrame(u32 num, float delta) { 30 | frame_list[num % FRAME_BUFFER_SIZE] = FrameInfo{num, delta}; 31 | } 32 | }; 33 | 34 | } // namespace Core::Devtools::Widget -------------------------------------------------------------------------------- /src/core/devtools/widget/memory_map.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/memory.h" 7 | 8 | namespace Core::Devtools::Widget { 9 | 10 | class MemoryMapViewer { 11 | struct Iterator { 12 | bool is_vma; 13 | struct { 14 | MemoryManager::DMemMap::iterator it; 15 | MemoryManager::DMemMap::iterator end; 16 | } dmem; 17 | struct { 18 | MemoryManager::VMAMap::iterator it; 19 | MemoryManager::VMAMap::iterator end; 20 | } vma; 21 | 22 | bool DrawLine(); 23 | }; 24 | 25 | bool showing_vma = true; 26 | 27 | public: 28 | bool open = false; 29 | 30 | void Draw(); 31 | }; 32 | 33 | } // namespace Core::Devtools::Widget 34 | -------------------------------------------------------------------------------- /src/core/devtools/widget/reg_popup.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include "common/types.h" 11 | #include "video_core/renderer_vulkan/liverpool_to_vk.h" 12 | 13 | namespace Core::Devtools::Widget { 14 | 15 | class RegPopup { 16 | int id; 17 | ImGuiWindowFlags flags{ImGuiWindowFlags_NoSavedSettings}; 18 | 19 | using DepthBuffer = std::tuple; 20 | 21 | ImVec2 last_pos; 22 | std::variant data; 23 | std::string title{}; 24 | 25 | static void DrawColorBuffer(const AmdGpu::Liverpool::ColorBuffer& buffer); 26 | 27 | static void DrawDepthBuffer(const DepthBuffer& depth_data); 28 | 29 | public: 30 | bool open = false; 31 | bool moved = false; 32 | 33 | RegPopup(); 34 | 35 | void SetData(const std::string& base_title, AmdGpu::Liverpool::ColorBuffer color_buffer, 36 | u32 cb_id); 37 | 38 | void SetData(const std::string& base_title, AmdGpu::Liverpool::DepthBuffer depth_buffer, 39 | AmdGpu::Liverpool::DepthControl depth_control); 40 | 41 | void SetPos(ImVec2 pos, bool auto_resize = false); 42 | 43 | void Draw(); 44 | }; 45 | 46 | } // namespace Core::Devtools::Widget 47 | -------------------------------------------------------------------------------- /src/core/devtools/widget/reg_view.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | #include "core/debug_state.h" 6 | #include "imgui_memory_editor.h" 7 | #include "reg_popup.h" 8 | #include "text_editor.h" 9 | 10 | namespace Core::Devtools::Widget { 11 | 12 | struct ShaderCache { 13 | MemoryEditor hex_view; 14 | TextEditor dis_view; 15 | Vulkan::Liverpool::UserData user_data; 16 | }; 17 | 18 | class RegView { 19 | int id; 20 | 21 | std::string title; 22 | DebugStateType::RegDump data; 23 | u32 batch_id{~0u}; 24 | ImVec2 last_pos; 25 | 26 | std::unordered_map shader_decomp; 27 | int selected_shader{-1}; 28 | RegPopup default_reg_popup; 29 | int last_selected_cb{-1}; 30 | std::vector extra_reg_popup; 31 | 32 | bool show_registers{true}; 33 | bool show_user_data{true}; 34 | bool show_disassembly{true}; 35 | 36 | void ProcessShader(int shader_id); 37 | 38 | void SelectShader(int shader_id); 39 | 40 | void DrawComputeRegs(); 41 | 42 | void DrawGraphicsRegs(); 43 | 44 | public: 45 | bool open = false; 46 | bool moved = false; 47 | 48 | RegView(); 49 | 50 | void SetData(DebugStateType::RegDump data, const std::string& base_title, u32 batch_id); 51 | 52 | void SetPos(ImVec2 pos); 53 | 54 | void Draw(); 55 | }; 56 | 57 | } // namespace Core::Devtools::Widget -------------------------------------------------------------------------------- /src/core/devtools/widget/shader_list.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/debug_state.h" 7 | #include "text_editor.h" 8 | 9 | #include 10 | 11 | namespace Core::Devtools::Widget { 12 | 13 | class ShaderList { 14 | struct Selection { 15 | explicit Selection(int index); 16 | ~Selection(); 17 | Selection(const Selection& other) = delete; 18 | Selection(Selection&& other) noexcept; 19 | Selection& operator=(Selection other); 20 | 21 | void ReloadShader(DebugStateType::ShaderDump& value); 22 | 23 | bool DrawShader(DebugStateType::ShaderDump& value); 24 | 25 | int index{-1}; 26 | std::unique_ptr isa_editor{}; 27 | std::unique_ptr glsl_editor{}; 28 | bool open = true; 29 | bool showing_bin = false; 30 | 31 | std::filesystem::path patch_path; 32 | std::filesystem::path patch_bin_path; 33 | }; 34 | 35 | std::vector open_shaders{}; 36 | 37 | char search_box[128]{}; 38 | 39 | public: 40 | bool open = false; 41 | 42 | void Draw(); 43 | }; 44 | 45 | } // namespace Core::Devtools::Widget -------------------------------------------------------------------------------- /src/core/file_format/pkg_type.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "common/types.h" 8 | 9 | /// Retrieves the PKG entry name from its type identifier. 10 | std::string_view GetEntryNameByType(u32 type); 11 | -------------------------------------------------------------------------------- /src/core/file_format/splash.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include 5 | 6 | #include "common/assert.h" 7 | #include "common/io_file.h" 8 | #include "common/stb.h" 9 | #include "splash.h" 10 | 11 | bool Splash::Open(const std::filesystem::path& filepath) { 12 | ASSERT_MSG(filepath.extension().string() == ".png", "Unexpected file format passed"); 13 | 14 | Common::FS::IOFile file(filepath, Common::FS::FileAccessMode::Read); 15 | if (!file.IsOpen()) { 16 | return false; 17 | } 18 | 19 | std::vector png_file{}; 20 | const auto png_size = file.GetSize(); 21 | png_file.resize(png_size); 22 | file.Seek(0); 23 | file.Read(png_file); 24 | 25 | auto* img_mem = stbi_load_from_memory(png_file.data(), png_file.size(), 26 | reinterpret_cast(&img_info.width), 27 | reinterpret_cast(&img_info.height), 28 | reinterpret_cast(&img_info.num_channels), 4); 29 | if (!img_mem) { 30 | return false; 31 | } 32 | 33 | const auto img_size = img_info.GetSizeBytes(); 34 | img_data.resize(img_size); 35 | std::memcpy(img_data.data(), img_mem, img_size); 36 | stbi_image_free(img_mem); 37 | return true; 38 | } 39 | -------------------------------------------------------------------------------- /src/core/file_format/splash.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include "common/types.h" 10 | 11 | class Splash { 12 | public: 13 | struct ImageInfo { 14 | u32 width; 15 | u32 height; 16 | u32 num_channels; 17 | 18 | u32 GetSizeBytes() const { 19 | return width * height * 4; // we always forcing rgba8 for simplicity 20 | } 21 | }; 22 | 23 | Splash() = default; 24 | ~Splash() = default; 25 | 26 | bool Open(const std::filesystem::path& filepath); 27 | [[nodiscard]] bool IsLoaded() const { 28 | return img_data.size(); 29 | } 30 | 31 | const auto& GetImageData() const { 32 | return img_data; 33 | } 34 | 35 | ImageInfo GetImageInfo() const { 36 | return img_info; 37 | } 38 | 39 | private: 40 | ImageInfo img_info{}; 41 | std::vector img_data{}; 42 | }; 43 | -------------------------------------------------------------------------------- /src/core/file_format/trp.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "common/endian.h" 8 | #include "common/io_file.h" 9 | #include "common/types.h" 10 | #include "core/crypto/crypto.h" 11 | 12 | struct TrpHeader { 13 | u32_be magic; // (0xDCA24D00) 14 | u32_be version; 15 | u64_be file_size; // size of full trp file 16 | u32_be entry_num; // num entries 17 | u32_be entry_size; // size of entry 18 | u32_be dev_flag; // 1: dev 19 | unsigned char digest[20]; // sha1 hash 20 | u32_be key_index; // 3031300? 21 | unsigned char padding[44]; 22 | }; 23 | 24 | struct TrpEntry { 25 | char entry_name[32]; 26 | u64_be entry_pos; 27 | u64_be entry_len; 28 | u32_be flag; // 3 = CONFIG/ESFM , 0 = PNG 29 | unsigned char padding[12]; 30 | }; 31 | 32 | class TRP { 33 | public: 34 | TRP(); 35 | ~TRP(); 36 | bool Extract(const std::filesystem::path& trophyPath, const std::string titleId); 37 | void GetNPcommID(const std::filesystem::path& trophyPath, int index); 38 | 39 | private: 40 | Crypto crypto; 41 | std::vector NPcommID = std::vector(12); 42 | std::array np_comm_id{}; 43 | std::array esfmIv{}; 44 | std::filesystem::path trpFilesPath; 45 | static constexpr int iv_len = 16; 46 | }; -------------------------------------------------------------------------------- /src/core/libraries/ajm/ajm_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | constexpr int ORBIS_AJM_ERROR_UNKNOWN = 0x80930001; 7 | constexpr int ORBIS_AJM_ERROR_INVALID_CONTEXT = 0x80930002; 8 | constexpr int ORBIS_AJM_ERROR_INVALID_INSTANCE = 0x80930003; 9 | constexpr int ORBIS_AJM_ERROR_INVALID_BATCH = 0x80930004; 10 | constexpr int ORBIS_AJM_ERROR_INVALID_PARAMETER = 0x80930005; 11 | constexpr int ORBIS_AJM_ERROR_OUT_OF_MEMORY = 0x80930006; 12 | constexpr int ORBIS_AJM_ERROR_OUT_OF_RESOURCES = 0x80930007; 13 | constexpr int ORBIS_AJM_ERROR_CODEC_NOT_SUPPORTED = 0x80930008; 14 | constexpr int ORBIS_AJM_ERROR_CODEC_ALREADY_REGISTERED = 0x80930009; 15 | constexpr int ORBIS_AJM_ERROR_CODEC_NOT_REGISTERED = 0x8093000A; 16 | constexpr int ORBIS_AJM_ERROR_WRONG_REVISION_FLAG = 0x8093000B; 17 | constexpr int ORBIS_AJM_ERROR_FLAG_NOT_SUPPORTED = 0x8093000C; 18 | constexpr int ORBIS_AJM_ERROR_BUSY = 0x8093000D; 19 | constexpr int ORBIS_AJM_ERROR_BAD_PRIORITY = 0x8093000E; 20 | constexpr int ORBIS_AJM_ERROR_IN_PROGRESS = 0x8093000F; 21 | constexpr int ORBIS_AJM_ERROR_RETRY = 0x80930010; 22 | constexpr int ORBIS_AJM_ERROR_MALFORMED_BATCH = 0x80930011; 23 | constexpr int ORBIS_AJM_ERROR_JOB_CREATION = 0x80930012; 24 | constexpr int ORBIS_AJM_ERROR_INVALID_OPCODE = 0x80930013; 25 | constexpr int ORBIS_AJM_ERROR_PRIORITY_VIOLATION = 0x80930014; 26 | constexpr int ORBIS_AJM_ERROR_BUFFER_TOO_BIG = 0x80930015; 27 | constexpr int ORBIS_AJM_ERROR_INVALID_ADDRESS = 0x80930016; 28 | constexpr int ORBIS_AJM_ERROR_CANCELLED = 0x80930017; 29 | -------------------------------------------------------------------------------- /src/core/libraries/ajm/ajm_instance_statistics.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "core/libraries/ajm/ajm.h" 5 | #include "core/libraries/ajm/ajm_instance_statistics.h" 6 | 7 | namespace Libraries::Ajm { 8 | 9 | void AjmInstanceStatistics::ExecuteJob(AjmJob& job) { 10 | if (job.output.p_engine) { 11 | job.output.p_engine->usage_batch = 0.01; 12 | const auto ic = job.input.statistics_engine_parameters->interval_count; 13 | for (u32 idx = 0; idx < ic; ++idx) { 14 | job.output.p_engine->usage_interval[idx] = 0.01; 15 | } 16 | } 17 | if (job.output.p_engine_per_codec) { 18 | job.output.p_engine_per_codec->codec_count = 1; 19 | job.output.p_engine_per_codec->codec_id[0] = static_cast(AjmCodecType::At9Dec); 20 | job.output.p_engine_per_codec->codec_percentage[0] = 0.01; 21 | } 22 | if (job.output.p_memory) { 23 | job.output.p_memory->instance_free = 0x400000; 24 | job.output.p_memory->buffer_free = 0x400000; 25 | job.output.p_memory->batch_size = 0x4200; 26 | job.output.p_memory->input_size = 0x2000; 27 | job.output.p_memory->output_size = 0x2000; 28 | job.output.p_memory->small_size = 0x200; 29 | } 30 | } 31 | 32 | AjmInstanceStatistics& AjmInstanceStatistics::Getinstance() { 33 | static AjmInstanceStatistics instance; 34 | return instance; 35 | } 36 | 37 | } // namespace Libraries::Ajm 38 | -------------------------------------------------------------------------------- /src/core/libraries/ajm/ajm_instance_statistics.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/libraries/ajm/ajm_batch.h" 7 | 8 | namespace Libraries::Ajm { 9 | 10 | class AjmInstanceStatistics { 11 | public: 12 | void ExecuteJob(AjmJob& job); 13 | 14 | static AjmInstanceStatistics& Getinstance(); 15 | }; 16 | 17 | } // namespace Libraries::Ajm 18 | -------------------------------------------------------------------------------- /src/core/libraries/app_content/app_content_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/libraries/error_codes.h" 7 | 8 | // AppContent library 9 | constexpr int ORBIS_APP_CONTENT_ERROR_PARAMETER = 0x80D90002; 10 | constexpr int ORBIS_APP_CONTENT_ERROR_DRM_NO_ENTITLEMENT = 0x80D90007; 11 | constexpr int ORBIS_APP_CONTENT_ERROR_NOT_FOUND = 0x80D90005; 12 | -------------------------------------------------------------------------------- /src/core/libraries/audio/audioout_backend.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | namespace Libraries::AudioOut { 7 | 8 | struct PortOut; 9 | 10 | class PortBackend { 11 | public: 12 | virtual ~PortBackend() = default; 13 | 14 | /// Guaranteed to be called in intervals of at least port buffer time, 15 | /// with size equal to port buffer size. 16 | virtual void Output(void* ptr) = 0; 17 | 18 | virtual void SetVolume(const std::array& ch_volumes) = 0; 19 | }; 20 | 21 | class AudioOutBackend { 22 | public: 23 | AudioOutBackend() = default; 24 | virtual ~AudioOutBackend() = default; 25 | 26 | virtual std::unique_ptr Open(PortOut& port) = 0; 27 | }; 28 | 29 | class SDLAudioOut final : public AudioOutBackend { 30 | public: 31 | std::unique_ptr Open(PortOut& port) override; 32 | }; 33 | 34 | } // namespace Libraries::AudioOut 35 | -------------------------------------------------------------------------------- /src/core/libraries/audio3d/audio3d_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/libraries/error_codes.h" 7 | 8 | constexpr int ORBIS_AUDIO3D_ERROR_UNKNOWN = 0x80EA0001; 9 | constexpr int ORBIS_AUDIO3D_ERROR_INVALID_PORT = 0x80EA0002; 10 | constexpr int ORBIS_AUDIO3D_ERROR_INVALID_OBJECT = 0x80EA0003; 11 | constexpr int ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER = 0x80EA0004; 12 | constexpr int ORBIS_AUDIO3D_ERROR_OUT_OF_MEMORY = 0x80EA0005; 13 | constexpr int ORBIS_AUDIO3D_ERROR_OUT_OF_RESOURCES = 0x80EA0006; 14 | constexpr int ORBIS_AUDIO3D_ERROR_NOT_READY = 0x80EA0007; 15 | constexpr int ORBIS_AUDIO3D_ERROR_NOT_SUPPORTED = 0x80EA0008; 16 | -------------------------------------------------------------------------------- /src/core/libraries/audio3d/audio3d_impl.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "audio3d_error.h" 5 | #include "audio3d_impl.h" 6 | 7 | #include "common/logging/log.h" 8 | #include "core/libraries/error_codes.h" 9 | #include "core/libraries/kernel/kernel.h" 10 | 11 | using namespace Libraries::Kernel; 12 | 13 | namespace Libraries::Audio3d {} // namespace Libraries::Audio3d 14 | -------------------------------------------------------------------------------- /src/core/libraries/audio3d/audio3d_impl.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "audio3d.h" 7 | 8 | namespace Libraries::Audio3d { 9 | 10 | class Audio3d { 11 | public: 12 | private: 13 | using OrbisAudio3dPluginId = u32; 14 | }; 15 | 16 | } // namespace Libraries::Audio3d 17 | -------------------------------------------------------------------------------- /src/core/libraries/avplayer/avplayer_data_streamer.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "avplayer.h" 7 | 8 | #include "common/types.h" 9 | 10 | #include 11 | 12 | struct AVIOContext; 13 | 14 | namespace Libraries::AvPlayer { 15 | 16 | class IDataStreamer { 17 | public: 18 | virtual ~IDataStreamer() = default; 19 | virtual bool Init(std::string_view path) = 0; 20 | virtual AVIOContext* GetContext() = 0; 21 | }; 22 | 23 | } // namespace Libraries::AvPlayer 24 | -------------------------------------------------------------------------------- /src/core/libraries/avplayer/avplayer_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/libraries/error_codes.h" 7 | 8 | // AvPlayer library 9 | constexpr int ORBIS_AVPLAYER_ERROR_INVALID_PARAMS = 0x806A0001; 10 | constexpr int ORBIS_AVPLAYER_ERROR_OPERATION_FAILED = 0x806A0002; 11 | constexpr int ORBIS_AVPLAYER_ERROR_NO_MEMORY = 0x806A0003; 12 | constexpr int ORBIS_AVPLAYER_ERROR_NOT_SUPPORTED = 0x806A0004; 13 | constexpr int ORBIS_AVPLAYER_ERROR_WAR_FILE_NONINTERLEAVED = 0x806A00A0; 14 | constexpr int ORBIS_AVPLAYER_ERROR_WAR_LOOPING_BACK = 0x806A00A1; 15 | constexpr int ORBIS_AVPLAYER_ERROR_WAR_JUMP_COMPLETE = 0x806A00A3; 16 | constexpr int ORBIS_AVPLAYER_ERROR_INFO_MARLIN_ENCRY = 0x806A00B0; 17 | constexpr int ORBIS_AVPLAYER_ERROR_INFO_PLAYREADY_ENCRY = 0x806A00B4; 18 | constexpr int ORBIS_AVPLAYER_ERROR_INFO_AES_ENCRY = 0x806A00B5; 19 | constexpr int ORBIS_AVPLAYER_ERROR_INFO_OTHER_ENCRY = 0x806A00BF; 20 | -------------------------------------------------------------------------------- /src/core/libraries/avplayer/avplayer_file_streamer.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "core/libraries/avplayer/avplayer.h" 8 | #include "core/libraries/avplayer/avplayer_data_streamer.h" 9 | 10 | struct AVIOContext; 11 | 12 | namespace Libraries::AvPlayer { 13 | 14 | class AvPlayerFileStreamer : public IDataStreamer { 15 | public: 16 | AvPlayerFileStreamer(const SceAvPlayerFileReplacement& file_replacement); 17 | ~AvPlayerFileStreamer(); 18 | 19 | bool Init(std::string_view path) override; 20 | 21 | AVIOContext* GetContext() override { 22 | return m_avio_context; 23 | } 24 | 25 | private: 26 | static s32 ReadPacket(void* opaque, u8* buffer, s32 size); 27 | static s64 Seek(void* opaque, s64 buffer, int whence); 28 | 29 | SceAvPlayerFileReplacement m_file_replacement; 30 | 31 | int m_fd = -1; 32 | u64 m_position{}; 33 | u64 m_file_size{}; 34 | AVIOContext* m_avio_context{}; 35 | }; 36 | 37 | } // namespace Libraries::AvPlayer 38 | -------------------------------------------------------------------------------- /src/core/libraries/disc_map/disc_map.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | namespace Libraries::DiscMap { 12 | 13 | int PS4_SYSV_ABI sceDiscMapGetPackageSize(); 14 | int PS4_SYSV_ABI sceDiscMapIsRequestOnHDD(); 15 | int PS4_SYSV_ABI Func_7C980FFB0AA27E7A(); 16 | int PS4_SYSV_ABI Func_8A828CAEE7EDD5E9(); 17 | int PS4_SYSV_ABI Func_E7EBCE96E92F91F8(); 18 | 19 | void RegisterlibSceDiscMap(Core::Loader::SymbolsResolver* sym); 20 | } // namespace Libraries::DiscMap -------------------------------------------------------------------------------- /src/core/libraries/disc_map/disc_map_codes.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | constexpr int ORBIS_DISC_MAP_ERROR_INVALID_ARGUMENT = 0x81100001; 7 | constexpr int ORBIS_DISC_MAP_ERROR_LOCATION_NOT_MAPPED = 0x81100002; 8 | constexpr int ORBIS_DISC_MAP_ERROR_FILE_NOT_FOUND = 0x81100003; 9 | constexpr int ORBIS_DISC_MAP_ERROR_NO_BITMAP_INFO = 0x81100004; 10 | constexpr int ORBIS_DISC_MAP_ERROR_FATAL = 0x811000FF; 11 | -------------------------------------------------------------------------------- /src/core/libraries/error_codes.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | // Generic 7 | constexpr int ORBIS_OK = 0x00000000; 8 | constexpr int ORBIS_FAIL = 0xFFFFFFFF; 9 | -------------------------------------------------------------------------------- /src/core/libraries/fiber/fiber_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/libraries/error_codes.h" 7 | 8 | // Fiber library 9 | constexpr int ORBIS_FIBER_ERROR_NULL = 0x80590001; 10 | constexpr int ORBIS_FIBER_ERROR_ALIGNMENT = 0x80590002; 11 | constexpr int ORBIS_FIBER_ERROR_RANGE = 0x80590003; 12 | constexpr int ORBIS_FIBER_ERROR_INVALID = 0x80590004; 13 | constexpr int ORBIS_FIBER_ERROR_PERMISSION = 0x80590005; 14 | constexpr int ORBIS_FIBER_ERROR_STATE = 0x80590006; 15 | -------------------------------------------------------------------------------- /src/core/libraries/ime/error_dialog.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | #include "core/libraries/system/commondialog.h" 8 | 9 | namespace Core::Loader { 10 | class SymbolsResolver; 11 | } 12 | namespace Libraries::ErrorDialog { 13 | 14 | using OrbisUserServiceUserId = s32; 15 | 16 | struct Param; 17 | 18 | CommonDialog::Error PS4_SYSV_ABI sceErrorDialogClose(); 19 | CommonDialog::Status PS4_SYSV_ABI sceErrorDialogGetStatus(); 20 | CommonDialog::Error PS4_SYSV_ABI sceErrorDialogInitialize(); 21 | CommonDialog::Error PS4_SYSV_ABI sceErrorDialogOpen(const Param* param); 22 | int PS4_SYSV_ABI sceErrorDialogOpenDetail(); 23 | int PS4_SYSV_ABI sceErrorDialogOpenWithReport(); 24 | CommonDialog::Error PS4_SYSV_ABI sceErrorDialogTerminate(); 25 | CommonDialog::Status PS4_SYSV_ABI sceErrorDialogUpdateStatus(); 26 | 27 | void RegisterlibSceErrorDialog(Core::Loader::SymbolsResolver* sym); 28 | } // namespace Libraries::ErrorDialog -------------------------------------------------------------------------------- /src/core/libraries/jpeg/jpeg_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | constexpr int ORBIS_JPEG_ENC_ERROR_INVALID_ADDR = 0x80650101; 7 | constexpr int ORBIS_JPEG_ENC_ERROR_INVALID_SIZE = 0x80650102; 8 | constexpr int ORBIS_JPEG_ENC_ERROR_INVALID_PARAM = 0x80650103; 9 | constexpr int ORBIS_JPEG_ENC_ERROR_INVALID_HANDLE = 0x80650104; 10 | -------------------------------------------------------------------------------- /src/core/libraries/kernel/aio.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "common/types.h" 13 | 14 | namespace Core::Loader { 15 | class SymbolsResolver; 16 | } 17 | 18 | namespace Libraries::Kernel { 19 | 20 | enum AioState { 21 | ORBIS_KERNEL_AIO_STATE_SUBMITTED = 1, 22 | ORBIS_KERNEL_AIO_STATE_PROCESSING = 2, 23 | ORBIS_KERNEL_AIO_STATE_COMPLETED = 3, 24 | ORBIS_KERNEL_AIO_STATE_ABORTED = 4 25 | }; 26 | 27 | struct OrbisKernelAioResult { 28 | s64 returnValue; 29 | u32 state; 30 | }; 31 | 32 | typedef s32 OrbisKernelAioSubmitId; 33 | 34 | struct OrbisKernelAioRWRequest { 35 | s64 offset; 36 | s64 nbyte; 37 | void* buf; 38 | OrbisKernelAioResult* result; 39 | s32 fd; 40 | }; 41 | 42 | void RegisterAio(Core::Loader::SymbolsResolver* sym); 43 | } // namespace Libraries::Kernel -------------------------------------------------------------------------------- /src/core/libraries/kernel/process.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | 12 | namespace Libraries::Kernel { 13 | 14 | int PS4_SYSV_ABI sceKernelIsNeoMode(); 15 | 16 | int PS4_SYSV_ABI sceKernelGetCompiledSdkVersion(int* ver); 17 | 18 | void RegisterProcess(Core::Loader::SymbolsResolver* sym); 19 | 20 | } // namespace Libraries::Kernel 21 | -------------------------------------------------------------------------------- /src/core/libraries/kernel/sync/mutex.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "mutex.h" 5 | 6 | #include "common/assert.h" 7 | 8 | namespace Libraries::Kernel { 9 | 10 | TimedMutex::TimedMutex() { 11 | #ifdef _WIN64 12 | mtx = CreateMutex(nullptr, false, nullptr); 13 | ASSERT(mtx); 14 | #endif 15 | } 16 | 17 | TimedMutex::~TimedMutex() { 18 | #ifdef _WIN64 19 | CloseHandle(mtx); 20 | #endif 21 | } 22 | 23 | void TimedMutex::lock() { 24 | #ifdef _WIN64 25 | for (;;) { 26 | u64 res = WaitForSingleObjectEx(mtx, INFINITE, true); 27 | if (res == WAIT_OBJECT_0) { 28 | return; 29 | } 30 | } 31 | #else 32 | mtx.lock(); 33 | #endif 34 | } 35 | 36 | bool TimedMutex::try_lock() { 37 | #ifdef _WIN64 38 | return WaitForSingleObjectEx(mtx, 0, true) == WAIT_OBJECT_0; 39 | #else 40 | return mtx.try_lock(); 41 | #endif 42 | } 43 | 44 | void TimedMutex::unlock() { 45 | #ifdef _WIN64 46 | ReleaseMutex(mtx); 47 | #else 48 | mtx.unlock(); 49 | #endif 50 | } 51 | 52 | } // namespace Libraries::Kernel -------------------------------------------------------------------------------- /src/core/libraries/kernel/threads.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "core/libraries/kernel/kernel.h" 5 | #include "core/libraries/kernel/threads.h" 6 | #include "core/libraries/kernel/threads/pthread.h" 7 | 8 | namespace Libraries::Kernel { 9 | 10 | void RegisterThreads(Core::Loader::SymbolsResolver* sym) { 11 | RegisterMutex(sym); 12 | RegisterCond(sym); 13 | RegisterRwlock(sym); 14 | RegisterSemaphore(sym); 15 | RegisterSpec(sym); 16 | RegisterThreadAttr(sym); 17 | RegisterThread(sym); 18 | RegisterRtld(sym); 19 | RegisterPthreadClean(sym); 20 | } 21 | 22 | } // namespace Libraries::Kernel 23 | -------------------------------------------------------------------------------- /src/core/libraries/kernel/threads/sleepq.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Libraries::Kernel { 9 | 10 | struct Pthread; 11 | struct SleepQueue; 12 | 13 | using ListBaseHook = 14 | boost::intrusive::list_base_hook>; 15 | 16 | using SleepqList = boost::intrusive::list>; 17 | 18 | struct SleepQueue : public ListBaseHook { 19 | std::forward_list sq_blocked; 20 | SleepqList sq_freeq; 21 | void* sq_wchan; 22 | int sq_type; 23 | }; 24 | 25 | void SleepqLock(void* wchan); 26 | 27 | void SleepqUnlock(void* wchan); 28 | 29 | SleepQueue* SleepqLookup(void* wchan); 30 | 31 | void SleepqAdd(void* wchan, Pthread* td); 32 | 33 | int SleepqRemove(SleepQueue* sq, Pthread* td); 34 | 35 | void SleepqDrop(SleepQueue* sq, void (*callback)(Pthread*, void*), void* arg); 36 | 37 | } // namespace Libraries::Kernel 38 | -------------------------------------------------------------------------------- /src/core/libraries/libc_internal/libc_internal.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include 5 | #include "common/assert.h" 6 | #include "common/logging/log.h" 7 | #include "core/libraries/error_codes.h" 8 | #include "core/libraries/libs.h" 9 | #include "libc_internal.h" 10 | #include "libc_internal_io.h" 11 | #include "libc_internal_math.h" 12 | #include "libc_internal_memory.h" 13 | #include "libc_internal_str.h" 14 | #include "printf.h" 15 | 16 | namespace Libraries::LibcInternal { 17 | 18 | void RegisterlibSceLibcInternal(Core::Loader::SymbolsResolver* sym) { 19 | RegisterlibSceLibcInternalMath(sym); 20 | RegisterlibSceLibcInternalStr(sym); 21 | RegisterlibSceLibcInternalMemory(sym); 22 | RegisterlibSceLibcInternalIo(sym); 23 | } 24 | } // namespace Libraries::LibcInternal -------------------------------------------------------------------------------- /src/core/libraries/libc_internal/libc_internal.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | 12 | namespace Libraries::LibcInternal { 13 | 14 | // I won't manage definitons of 3000+ functions, and they don't need to be accessed externally, 15 | // so everything is just in the .cpp file 16 | 17 | void RegisterlibSceLibcInternal(Core::Loader::SymbolsResolver* sym); 18 | } // namespace Libraries::LibcInternal -------------------------------------------------------------------------------- /src/core/libraries/libc_internal/libc_internal_io.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include "common/assert.h" 9 | #include "common/logging/log.h" 10 | #include "core/libraries/error_codes.h" 11 | #include "core/libraries/libs.h" 12 | #include "libc_internal_io.h" 13 | #include "printf.h" 14 | 15 | namespace Libraries::LibcInternal { 16 | int PS4_SYSV_ABI internal_snprintf(char* s, size_t n, VA_ARGS) { 17 | VA_CTX(ctx); 18 | return snprintf_ctx(s, n, &ctx); 19 | } 20 | void RegisterlibSceLibcInternalIo(Core::Loader::SymbolsResolver* sym) { 21 | LIB_FUNCTION("eLdDw6l0-bU", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1, 22 | internal_snprintf); 23 | } 24 | } // namespace Libraries::LibcInternal -------------------------------------------------------------------------------- /src/core/libraries/libc_internal/libc_internal_io.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | 12 | namespace Libraries::LibcInternal { 13 | void RegisterlibSceLibcInternalIo(Core::Loader::SymbolsResolver* sym); 14 | } // namespace Libraries::LibcInternal -------------------------------------------------------------------------------- /src/core/libraries/libc_internal/libc_internal_math.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | 12 | namespace Libraries::LibcInternal { 13 | void RegisterlibSceLibcInternalMath(Core::Loader::SymbolsResolver* sym); 14 | } // namespace Libraries::LibcInternal -------------------------------------------------------------------------------- /src/core/libraries/libc_internal/libc_internal_memory.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | 12 | namespace Libraries::LibcInternal { 13 | void RegisterlibSceLibcInternalMemory(Core::Loader::SymbolsResolver* sym); 14 | } // namespace Libraries::LibcInternal -------------------------------------------------------------------------------- /src/core/libraries/libc_internal/libc_internal_str.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | 12 | namespace Libraries::LibcInternal { 13 | void RegisterlibSceLibcInternalStr(Core::Loader::SymbolsResolver* sym); 14 | } // namespace Libraries::LibcInternal -------------------------------------------------------------------------------- /src/core/libraries/libpng/pngdec_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/libraries/error_codes.h" 7 | 8 | // PngDec library 9 | constexpr int ORBIS_PNG_DEC_ERROR_INVALID_ADDR = 0x80690001; 10 | constexpr int ORBIS_PNG_DEC_ERROR_INVALID_SIZE = 0x80690002; 11 | constexpr int ORBIS_PNG_DEC_ERROR_INVALID_PARAM = 0x80690003; 12 | constexpr int ORBIS_PNG_DEC_ERROR_INVALID_HANDLE = 0x80690004; 13 | constexpr int ORBIS_PNG_DEC_ERROR_INVALID_WORK_MEMORY = 0x80690005; 14 | constexpr int ORBIS_PNG_DEC_ERROR_INVALID_DATA = 0x80690010; 15 | constexpr int ORBIS_PNG_DEC_ERROR_UNSUPPORT_DATA = 0x80690011; 16 | constexpr int ORBIS_PNG_DEC_ERROR_DECODE_ERROR = 0x80690012; 17 | constexpr int ORBIS_PNG_DEC_ERROR_FATAL = 0x80690020; 18 | -------------------------------------------------------------------------------- /src/core/libraries/mouse/mouse.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | #include "common/types.h" 6 | 7 | namespace Core::Loader { 8 | class SymbolsResolver; 9 | } 10 | 11 | namespace Libraries::Mouse { 12 | 13 | int PS4_SYSV_ABI sceMouseClose(); 14 | int PS4_SYSV_ABI sceMouseConnectPort(); 15 | int PS4_SYSV_ABI sceMouseDebugGetDeviceId(); 16 | int PS4_SYSV_ABI sceMouseDeviceOpen(); 17 | int PS4_SYSV_ABI sceMouseDisconnectDevice(); 18 | int PS4_SYSV_ABI sceMouseDisconnectPort(); 19 | int PS4_SYSV_ABI sceMouseGetDeviceInfo(); 20 | int PS4_SYSV_ABI sceMouseInit(); 21 | int PS4_SYSV_ABI sceMouseMbusInit(); 22 | int PS4_SYSV_ABI sceMouseOpen(); 23 | int PS4_SYSV_ABI sceMouseRead(); 24 | int PS4_SYSV_ABI sceMouseSetHandType(); 25 | int PS4_SYSV_ABI sceMouseSetPointerSpeed(); 26 | int PS4_SYSV_ABI sceMouseSetProcessPrivilege(); 27 | 28 | void RegisterlibSceMouse(Core::Loader::SymbolsResolver* sym); 29 | } // namespace Libraries::Mouse -------------------------------------------------------------------------------- /src/core/libraries/move/move.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "common/logging/log.h" 5 | #include "core/libraries/error_codes.h" 6 | #include "core/libraries/libs.h" 7 | #include "move.h" 8 | 9 | namespace Libraries::Move { 10 | 11 | int PS4_SYSV_ABI sceMoveOpen() { 12 | LOG_ERROR(Lib_Move, "(STUBBED) called"); 13 | return ORBIS_FAIL; 14 | } 15 | 16 | int PS4_SYSV_ABI sceMoveGetDeviceInfo() { 17 | LOG_ERROR(Lib_Move, "(STUBBED) called"); 18 | return ORBIS_OK; 19 | } 20 | 21 | int PS4_SYSV_ABI sceMoveReadStateRecent() { 22 | LOG_TRACE(Lib_Move, "(STUBBED) called"); 23 | return ORBIS_OK; 24 | } 25 | 26 | int PS4_SYSV_ABI sceMoveTerm() { 27 | LOG_ERROR(Lib_Move, "(STUBBED) called"); 28 | return ORBIS_OK; 29 | } 30 | 31 | int PS4_SYSV_ABI sceMoveInit() { 32 | LOG_ERROR(Lib_Move, "(STUBBED) called"); 33 | return ORBIS_OK; 34 | } 35 | 36 | void RegisterlibSceMove(Core::Loader::SymbolsResolver* sym) { 37 | LIB_FUNCTION("HzC60MfjJxU", "libSceMove", 1, "libSceMove", 1, 1, sceMoveOpen); 38 | LIB_FUNCTION("GWXTyxs4QbE", "libSceMove", 1, "libSceMove", 1, 1, sceMoveGetDeviceInfo); 39 | LIB_FUNCTION("f2bcpK6kJfg", "libSceMove", 1, "libSceMove", 1, 1, sceMoveReadStateRecent); 40 | LIB_FUNCTION("tsZi60H4ypY", "libSceMove", 1, "libSceMove", 1, 1, sceMoveTerm); 41 | LIB_FUNCTION("j1ITE-EoJmE", "libSceMove", 1, "libSceMove", 1, 1, sceMoveInit); 42 | }; 43 | 44 | } // namespace Libraries::Move -------------------------------------------------------------------------------- /src/core/libraries/move/move.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | 12 | namespace Libraries::Move { 13 | 14 | int PS4_SYSV_ABI sceMoveOpen(); 15 | int PS4_SYSV_ABI sceMoveGetDeviceInfo(); 16 | int PS4_SYSV_ABI sceMoveReadStateRecent(); 17 | int PS4_SYSV_ABI sceMoveTerm(); 18 | int PS4_SYSV_ABI sceMoveInit(); 19 | 20 | void RegisterlibSceMove(Core::Loader::SymbolsResolver* sym); 21 | } // namespace Libraries::Move -------------------------------------------------------------------------------- /src/core/libraries/network/net_ctl_obj.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "common/types.h" 8 | 9 | namespace Libraries::NetCtl { 10 | 11 | using OrbisNetCtlCallback = PS4_SYSV_ABI void (*)(int eventType, void* arg); 12 | using OrbisNetCtlCallbackForNpToolkit = PS4_SYSV_ABI void (*)(int eventType, void* arg); 13 | 14 | struct NetCtlCallback { 15 | OrbisNetCtlCallback func; 16 | void* arg; 17 | }; 18 | 19 | struct NetCtlCallbackForNpToolkit { 20 | OrbisNetCtlCallbackForNpToolkit func; 21 | void* arg; 22 | }; 23 | 24 | class NetCtlInternal { 25 | public: 26 | explicit NetCtlInternal(); 27 | ~NetCtlInternal(); 28 | 29 | s32 RegisterCallback(OrbisNetCtlCallback func, void* arg); 30 | s32 RegisterNpToolkitCallback(OrbisNetCtlCallbackForNpToolkit func, void* arg); 31 | void CheckCallback(); 32 | void CheckNpToolkitCallback(); 33 | 34 | public: 35 | std::array nptool_callbacks{}; 36 | std::array callbacks{}; 37 | std::mutex m_mutex; 38 | }; 39 | } // namespace Libraries::NetCtl 40 | -------------------------------------------------------------------------------- /src/core/libraries/network/net_obj.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/core/libraries/network/net_obj.cpp -------------------------------------------------------------------------------- /src/core/libraries/network/net_obj.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/core/libraries/network/net_obj.h -------------------------------------------------------------------------------- /src/core/libraries/network/ssl2.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | 12 | namespace Libraries::Ssl2 { 13 | void RegisterlibSceSsl2(Core::Loader::SymbolsResolver* sym); 14 | } // namespace Libraries::Ssl2 -------------------------------------------------------------------------------- /src/core/libraries/ngs2/ngs2_impl.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "ngs2.h" 7 | 8 | namespace Libraries::Ngs2 { 9 | 10 | class Ngs2 { 11 | public: 12 | s32 ReportInvalid(Ngs2Handle* handle, u32 handle_type) const; 13 | s32 HandleSetup(Ngs2Handle* handle, void* data, std::atomic* atomic, u32 type, u32 flags); 14 | s32 HandleCleanup(Ngs2Handle* handle, u32 hType, void* dataOut); 15 | s32 HandleEnter(Ngs2Handle* handle, u32 hType, Ngs2Handle* handleOut); 16 | s32 HandleLeave(Ngs2Handle* handle); 17 | s32 StackBufferOpen(StackBuffer* buf, void* base_addr, size_t size, void** stackTop, 18 | bool verify); 19 | s32 StackBufferClose(StackBuffer* buf, size_t* usedSize); 20 | s32 SystemSetupCore(StackBuffer* buf, SystemOptions* options, Ngs2Handle** sysOut); 21 | 22 | private: 23 | }; 24 | 25 | } // namespace Libraries::Ngs2 26 | -------------------------------------------------------------------------------- /src/core/libraries/np_common/np_common_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/libraries/error_codes.h" 7 | 8 | constexpr int ORBIS_NP_ERROR_INVALID_ARGUMENT = 0x80550003; 9 | constexpr int ORBIS_NP_UTIL_ERROR_NOT_MATCH = 0x80550609; -------------------------------------------------------------------------------- /src/core/libraries/np_manager/np_manager_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/libraries/error_codes.h" 7 | 8 | constexpr int ORBIS_NP_ERROR_INVALID_ARGUMENT = 0x80550003; 9 | constexpr int ORBIS_NP_ERROR_SIGNED_OUT = 0x80550006; -------------------------------------------------------------------------------- /src/core/libraries/np_trophy/trophy_ui.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "common/fixed_value.h" 11 | #include "common/types.h" 12 | #include "core/libraries/np_trophy/np_trophy.h" 13 | #include "imgui/imgui_layer.h" 14 | #include "imgui/imgui_texture.h" 15 | 16 | namespace Libraries::NpTrophy { 17 | 18 | class TrophyUI final : public ImGui::Layer { 19 | public: 20 | TrophyUI(const std::filesystem::path& trophyIconPath, const std::string& trophyName, 21 | const std::string_view& rarity); 22 | ~TrophyUI() override; 23 | 24 | void Finish(); 25 | 26 | void Draw() override; 27 | 28 | private: 29 | std::string trophy_name; 30 | std::string_view trophy_type; 31 | ImGui::RefCountedTexture trophy_icon; 32 | ImGui::RefCountedTexture trophy_type_icon; 33 | }; 34 | 35 | struct TrophyInfo { 36 | std::filesystem::path trophy_icon_path; 37 | std::string trophy_name; 38 | std::string_view trophy_type; 39 | }; 40 | 41 | void AddTrophyToQueue(const std::filesystem::path& trophyIconPath, const std::string& trophyName, 42 | const std::string_view& rarity); 43 | 44 | }; // namespace Libraries::NpTrophy 45 | -------------------------------------------------------------------------------- /src/core/libraries/pad/pad_errors.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/libraries/error_codes.h" 7 | 8 | // Pad library 9 | constexpr int ORBIS_PAD_ERROR_INVALID_ARG = 0x80920001; 10 | constexpr int ORBIS_PAD_ERROR_INVALID_PORT = 0x80920002; 11 | constexpr int ORBIS_PAD_ERROR_INVALID_HANDLE = 0x80920003; 12 | constexpr int ORBIS_PAD_ERROR_ALREADY_OPENED = 0x80920004; 13 | constexpr int ORBIS_PAD_ERROR_NOT_INITIALIZED = 0x80920005; 14 | constexpr int ORBIS_PAD_ERROR_INVALID_LIGHTBAR_SETTING = 0x80920006; 15 | constexpr int ORBIS_PAD_ERROR_DEVICE_NOT_CONNECTED = 0x80920007; 16 | constexpr int ORBIS_PAD_ERROR_DEVICE_NO_HANDLE = 0x80920008; 17 | constexpr int ORBIS_PAD_ERROR_FATAL = 0x809200FF; 18 | constexpr int ORBIS_PAD_ERROR_NOT_PERMITTED = 0x80920101; 19 | constexpr int ORBIS_PAD_ERROR_INVALID_BUFFER_LENGTH = 0x80920102; 20 | constexpr int ORBIS_PAD_ERROR_INVALID_REPORT_LENGTH = 0x80920103; 21 | constexpr int ORBIS_PAD_ERROR_INVALID_REPORT_ID = 0x80920104; 22 | constexpr int ORBIS_PAD_ERROR_SEND_AGAIN = 0x80920105; 23 | -------------------------------------------------------------------------------- /src/core/libraries/playgo/playgo_dialog.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | #include "core/libraries/system/commondialog.h" 8 | 9 | namespace Core::Loader { 10 | class SymbolsResolver; 11 | } 12 | 13 | namespace Libraries::PlayGo::Dialog { 14 | 15 | struct OrbisPlayGoDialogParam { 16 | CommonDialog::BaseParam baseParam; 17 | s32 size; 18 | u8 unk[0x30]; 19 | }; 20 | static_assert(sizeof(OrbisPlayGoDialogParam) == 0x68); 21 | 22 | struct OrbisPlayGoDialogResult { 23 | u8 unk1[0x4]; 24 | CommonDialog::Result result; 25 | u8 unk2[0x20]; 26 | }; 27 | static_assert(sizeof(OrbisPlayGoDialogResult) == 0x28); 28 | 29 | CommonDialog::Error PS4_SYSV_ABI scePlayGoDialogClose(); 30 | CommonDialog::Error PS4_SYSV_ABI scePlayGoDialogGetResult(OrbisPlayGoDialogResult* result); 31 | CommonDialog::Status PS4_SYSV_ABI scePlayGoDialogGetStatus(); 32 | CommonDialog::Error PS4_SYSV_ABI scePlayGoDialogInitialize(); 33 | CommonDialog::Error PS4_SYSV_ABI scePlayGoDialogOpen(const OrbisPlayGoDialogParam* param); 34 | CommonDialog::Error PS4_SYSV_ABI scePlayGoDialogTerminate(); 35 | CommonDialog::Status PS4_SYSV_ABI scePlayGoDialogUpdateStatus(); 36 | 37 | void RegisterlibScePlayGoDialog(Core::Loader::SymbolsResolver* sym); 38 | } // namespace Libraries::PlayGo::Dialog 39 | -------------------------------------------------------------------------------- /src/core/libraries/random/random.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "random.h" 5 | #include "random_error.h" 6 | 7 | #include "common/logging/log.h" 8 | #include "core/libraries/error_codes.h" 9 | #include "core/libraries/libs.h" 10 | 11 | namespace Libraries::Random { 12 | 13 | s32 PS4_SYSV_ABI sceRandomGetRandomNumber(u8* buf, std::size_t size) { 14 | LOG_TRACE(Lib_Random, "called"); 15 | if (size > SCE_RANDOM_MAX_SIZE) { 16 | return SCE_RANDOM_ERROR_INVALID; 17 | } 18 | 19 | for (auto i = 0; i < size; ++i) { 20 | buf[i] = std::rand() & 0xFF; 21 | } 22 | return ORBIS_OK; 23 | } 24 | 25 | void RegisterlibSceRandom(Core::Loader::SymbolsResolver* sym) { 26 | LIB_FUNCTION("PI7jIZj4pcE", "libSceRandom", 1, "libSceRandom", 1, 1, sceRandomGetRandomNumber); 27 | }; 28 | 29 | } // namespace Libraries::Random 30 | -------------------------------------------------------------------------------- /src/core/libraries/random/random.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | 12 | namespace Libraries::Random { 13 | 14 | constexpr s32 SCE_RANDOM_MAX_SIZE = 64; 15 | 16 | s32 PS4_SYSV_ABI sceRandomGetRandomNumber(u8* buf, std::size_t size); 17 | 18 | void RegisterlibSceRandom(Core::Loader::SymbolsResolver* sym); 19 | 20 | } // namespace Libraries::Random 21 | -------------------------------------------------------------------------------- /src/core/libraries/random/random_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | constexpr int SCE_RANDOM_ERROR_INVALID = 0x817C0016; 7 | constexpr int SCE_RANDOM_ERROR_OUT_OF_RESOURCES = 0x817C001C; 8 | constexpr int SCE_RANDOM_ERROR_FATAL = 0x817C00FF; -------------------------------------------------------------------------------- /src/core/libraries/razor_cpu/razor_cpu.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | #include 9 | #include 10 | 11 | namespace Core::Loader { 12 | class SymbolsResolver; 13 | } 14 | 15 | namespace Libraries::RazorCpu { 16 | void RegisterlibSceRazorCpu(Core::Loader::SymbolsResolver* sym); 17 | } // namespace Libraries::RazorCpu -------------------------------------------------------------------------------- /src/core/libraries/save_data/dialog/savedatadialog.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | #include "core/libraries/system/commondialog.h" 8 | 9 | namespace Core::Loader { 10 | class SymbolsResolver; 11 | } 12 | 13 | namespace Libraries::SaveData::Dialog { 14 | 15 | struct OrbisSaveDataDialogParam; 16 | struct OrbisSaveDataDialogResult; 17 | enum class OrbisSaveDataDialogProgressBarTarget : u32; 18 | 19 | CommonDialog::Error PS4_SYSV_ABI sceSaveDataDialogClose(); 20 | CommonDialog::Error PS4_SYSV_ABI sceSaveDataDialogGetResult(OrbisSaveDataDialogResult* result); 21 | CommonDialog::Status PS4_SYSV_ABI sceSaveDataDialogGetStatus(); 22 | CommonDialog::Error PS4_SYSV_ABI sceSaveDataDialogInitialize(); 23 | s32 PS4_SYSV_ABI sceSaveDataDialogIsReadyToDisplay(); 24 | CommonDialog::Error PS4_SYSV_ABI sceSaveDataDialogOpen(const OrbisSaveDataDialogParam* param); 25 | CommonDialog::Error PS4_SYSV_ABI 26 | sceSaveDataDialogProgressBarInc(OrbisSaveDataDialogProgressBarTarget target, u32 delta); 27 | CommonDialog::Error PS4_SYSV_ABI 28 | sceSaveDataDialogProgressBarSetValue(OrbisSaveDataDialogProgressBarTarget target, u32 rate); 29 | CommonDialog::Error PS4_SYSV_ABI sceSaveDataDialogTerminate(); 30 | CommonDialog::Status PS4_SYSV_ABI sceSaveDataDialogUpdateStatus(); 31 | 32 | void RegisterlibSceSaveDataDialog(Core::Loader::SymbolsResolver* sym); 33 | } // namespace Libraries::SaveData::Dialog 34 | -------------------------------------------------------------------------------- /src/core/libraries/save_data/save_memory.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "save_backup.h" 8 | 9 | class PSF; 10 | 11 | namespace Libraries::SaveData { 12 | using OrbisUserServiceUserId = s32; 13 | } 14 | 15 | namespace Libraries::SaveData::SaveMemory { 16 | 17 | void PersistMemory(u32 slot_id, bool lock = true); 18 | 19 | [[nodiscard]] std::string GetSaveDir(u32 slot_id); 20 | 21 | [[nodiscard]] std::filesystem::path GetSavePath(OrbisUserServiceUserId user_id, u32 slot_id, 22 | std::string_view game_serial); 23 | 24 | // returns the size of the save memory if exists 25 | size_t SetupSaveMemory(OrbisUserServiceUserId user_id, u32 slot_id, std::string_view game_serial); 26 | 27 | // Write the icon. Set buf to null to read the standard icon. 28 | void SetIcon(u32 slot_id, void* buf = nullptr, size_t buf_size = 0); 29 | 30 | [[nodiscard]] bool IsSaveMemoryInitialized(u32 slot_id); 31 | 32 | [[nodiscard]] PSF& GetParamSFO(u32 slot_id); 33 | 34 | [[nodiscard]] std::vector GetIcon(u32 slot_id); 35 | 36 | // Save now or wait for the background thread to save 37 | void SaveSFO(u32 slot_id); 38 | 39 | void ReadMemory(u32 slot_id, void* buf, size_t buf_size, int64_t offset); 40 | 41 | void WriteMemory(u32 slot_id, void* buf, size_t buf_size, int64_t offset); 42 | 43 | } // namespace Libraries::SaveData::SaveMemory -------------------------------------------------------------------------------- /src/core/libraries/screenshot/screenshot.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | 12 | namespace Libraries::ScreenShot { 13 | 14 | int PS4_SYSV_ABI _Z5dummyv(); 15 | int PS4_SYSV_ABI sceScreenShotCapture(); 16 | int PS4_SYSV_ABI sceScreenShotDisable(); 17 | int PS4_SYSV_ABI sceScreenShotDisableNotification(); 18 | int PS4_SYSV_ABI sceScreenShotEnable(); 19 | int PS4_SYSV_ABI sceScreenShotEnableNotification(); 20 | int PS4_SYSV_ABI sceScreenShotGetAppInfo(); 21 | int PS4_SYSV_ABI sceScreenShotGetDrcParam(); 22 | int PS4_SYSV_ABI sceScreenShotIsDisabled(); 23 | int PS4_SYSV_ABI sceScreenShotIsVshScreenCaptureDisabled(); 24 | int PS4_SYSV_ABI sceScreenShotSetOverlayImage(); 25 | int PS4_SYSV_ABI sceScreenShotSetOverlayImageWithOrigin(); 26 | int PS4_SYSV_ABI sceScreenShotSetParam(); 27 | int PS4_SYSV_ABI sceScreenShotSetDrcParam(); 28 | 29 | void RegisterlibSceScreenShot(Core::Loader::SymbolsResolver* sym); 30 | } // namespace Libraries::ScreenShot -------------------------------------------------------------------------------- /src/core/libraries/system/msgdialog.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/libraries/system/commondialog.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | 12 | namespace Libraries::MsgDialog { 13 | 14 | struct DialogResult; 15 | struct OrbisParam; 16 | enum class OrbisMsgDialogProgressBarTarget : u32; 17 | 18 | CommonDialog::Error PS4_SYSV_ABI sceMsgDialogClose(); 19 | CommonDialog::Error PS4_SYSV_ABI sceMsgDialogGetResult(DialogResult* result); 20 | CommonDialog::Status PS4_SYSV_ABI sceMsgDialogGetStatus(); 21 | CommonDialog::Error PS4_SYSV_ABI sceMsgDialogInitialize(); 22 | CommonDialog::Error PS4_SYSV_ABI sceMsgDialogOpen(const OrbisParam* param); 23 | CommonDialog::Error PS4_SYSV_ABI sceMsgDialogProgressBarInc(OrbisMsgDialogProgressBarTarget, 24 | u32 delta); 25 | CommonDialog::Error PS4_SYSV_ABI sceMsgDialogProgressBarSetMsg(OrbisMsgDialogProgressBarTarget, 26 | const char* msg); 27 | CommonDialog::Error PS4_SYSV_ABI sceMsgDialogProgressBarSetValue(OrbisMsgDialogProgressBarTarget, 28 | u32 value); 29 | CommonDialog::Error PS4_SYSV_ABI sceMsgDialogTerminate(); 30 | CommonDialog::Status PS4_SYSV_ABI sceMsgDialogUpdateStatus(); 31 | 32 | void RegisterlibSceMsgDialog(Core::Loader::SymbolsResolver* sym); 33 | } // namespace Libraries::MsgDialog 34 | -------------------------------------------------------------------------------- /src/core/libraries/system/posix.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "core/libraries/system/posix.h" 5 | 6 | namespace Libraries::Posix { 7 | 8 | void Registerlibsceposix(Core::Loader::SymbolsResolver* sym) {} 9 | 10 | } // namespace Libraries::Posix 11 | -------------------------------------------------------------------------------- /src/core/libraries/system/posix.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | namespace Core::Loader { 7 | class SymbolsResolver; 8 | } 9 | 10 | namespace Libraries::Posix { 11 | void Registerlibsceposix(Core::Loader::SymbolsResolver* sym); 12 | } // namespace Libraries::Posix 13 | -------------------------------------------------------------------------------- /src/core/libraries/system/system_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | constexpr int ORBIS_SYSMODULE_INVALID_ID = 0x805A1000; 7 | constexpr int ORBIS_SYSMODULE_NOT_LOADED = 0x805A1001; 8 | constexpr int ORBIS_SYSMODULE_LOCK_FAILED = 0x805A10FF; -------------------------------------------------------------------------------- /src/core/libraries/system/systemservice_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/libraries/error_codes.h" 7 | 8 | // SystemService library 9 | constexpr int ORBIS_SYSTEM_SERVICE_ERROR_PARAMETER = 0x80A10003; 10 | constexpr int ORBIS_SYSTEM_SERVICE_ERROR_NO_EVENT = 0x80A10004; 11 | -------------------------------------------------------------------------------- /src/core/libraries/system/userservice_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/libraries/error_codes.h" 7 | 8 | // UserService library 9 | constexpr int ORBIS_USER_SERVICE_ERROR_INTERNAL = 0x80960001; 10 | constexpr int ORBIS_USER_SERVICE_ERROR_NOT_INITIALIZED = 0x80960002; 11 | constexpr int ORBIS_USER_SERVICE_ERROR_ALREADY_INITIALIZED = 0x80960003; 12 | constexpr int ORBIS_USER_SERVICE_ERROR_NO_MEMORY = 0x80960004; 13 | constexpr int ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT = 0x80960005; 14 | constexpr int ORBIS_USER_SERVICE_ERROR_OPERATION_NOT_SUPPORTED = 0x80960006; 15 | constexpr int ORBIS_USER_SERVICE_ERROR_NO_EVENT = 0x80960007; 16 | constexpr int ORBIS_USER_SERVICE_ERROR_NOT_LOGGED_IN = 0x80960009; 17 | constexpr int ORBIS_USER_SERVICE_ERROR_BUFFER_TOO_SHORT = 0x8096000A; 18 | -------------------------------------------------------------------------------- /src/core/libraries/videodec/videodec2_avc.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Libraries::Vdec2 { 9 | 10 | struct OrbisVideodec2AvcPictureInfo { 11 | u64 thisSize; 12 | 13 | bool isValid; 14 | 15 | u64 ptsData; 16 | u64 dtsData; 17 | u64 attachedData; 18 | 19 | u8 idrPictureflag; 20 | 21 | u8 profile_idc; 22 | u8 level_idc; 23 | u32 pic_width_in_mbs_minus1; 24 | u32 pic_height_in_map_units_minus1; 25 | u8 frame_mbs_only_flag; 26 | 27 | u8 frame_cropping_flag; 28 | u32 frameCropLeftOffset; 29 | u32 frameCropRightOffset; 30 | u32 frameCropTopOffset; 31 | u32 frameCropBottomOffset; 32 | 33 | u8 aspect_ratio_info_present_flag; 34 | u8 aspect_ratio_idc; 35 | u16 sar_width; 36 | u16 sar_height; 37 | 38 | u8 video_signal_type_present_flag; 39 | u8 video_format; 40 | u8 video_full_range_flag; 41 | u8 colour_description_present_flag; 42 | u8 colour_primaries; 43 | u8 transfer_characteristics; 44 | u8 matrix_coefficients; 45 | 46 | u8 timing_info_present_flag; 47 | u32 num_units_in_tick; 48 | u32 time_scale; 49 | u8 fixed_frame_rate_flag; 50 | 51 | u8 bitstream_restriction_flag; 52 | u8 max_dec_frame_buffering; 53 | 54 | u8 pic_struct_present_flag; 55 | u8 pic_struct; 56 | u8 field_pic_flag; 57 | u8 bottom_field_flag; 58 | }; 59 | 60 | } // namespace Libraries::Vdec2 -------------------------------------------------------------------------------- /src/core/libraries/videodec/videodec2_impl.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include "videodec2.h" 9 | 10 | extern "C" { 11 | #include 12 | #include 13 | #include 14 | } 15 | 16 | namespace Libraries::Vdec2 { 17 | 18 | extern std::vector gPictureInfos; 19 | 20 | class VdecDecoder { 21 | public: 22 | VdecDecoder(const OrbisVideodec2DecoderConfigInfo& configInfo, 23 | const OrbisVideodec2DecoderMemoryInfo& memoryInfo); 24 | ~VdecDecoder(); 25 | 26 | s32 Decode(const OrbisVideodec2InputData& inputData, OrbisVideodec2FrameBuffer& frameBuffer, 27 | OrbisVideodec2OutputInfo& outputInfo); 28 | s32 Flush(OrbisVideodec2FrameBuffer& frameBuffer, OrbisVideodec2OutputInfo& outputInfo); 29 | s32 Reset(); 30 | 31 | private: 32 | AVFrame* ConvertNV12Frame(AVFrame& frame); 33 | 34 | private: 35 | AVCodecContext* mCodecContext = nullptr; 36 | SwsContext* mSwsContext = nullptr; 37 | }; 38 | 39 | } // namespace Libraries::Vdec2 -------------------------------------------------------------------------------- /src/core/libraries/videodec/videodec_impl.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include "videodec.h" 9 | 10 | extern "C" { 11 | #include 12 | #include 13 | #include 14 | } 15 | 16 | namespace Libraries::Videodec { 17 | 18 | class VdecDecoder { 19 | public: 20 | VdecDecoder(const OrbisVideodecConfigInfo& pCfgInfoIn, 21 | const OrbisVideodecResourceInfo& pRsrcInfoIn); 22 | ~VdecDecoder(); 23 | s32 Decode(const OrbisVideodecInputData& pInputDataIn, 24 | OrbisVideodecFrameBuffer& pFrameBufferInOut, 25 | OrbisVideodecPictureInfo& pPictureInfoOut); 26 | s32 Flush(OrbisVideodecFrameBuffer& pFrameBufferInOut, 27 | OrbisVideodecPictureInfo& pPictureInfoOut); 28 | s32 Reset(); 29 | 30 | private: 31 | AVFrame* ConvertNV12Frame(AVFrame& frame); 32 | 33 | private: 34 | AVCodecContext* mCodecContext = nullptr; 35 | SwsContext* mSwsContext = nullptr; 36 | }; 37 | 38 | } // namespace Libraries::Videodec -------------------------------------------------------------------------------- /src/core/libraries/web_browser_dialog/webbrowserdialog.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | 12 | namespace Libraries::WebBrowserDialog { 13 | 14 | s32 PS4_SYSV_ABI sceWebBrowserDialogClose(); 15 | s32 PS4_SYSV_ABI sceWebBrowserDialogGetEvent(); 16 | s32 PS4_SYSV_ABI sceWebBrowserDialogGetResult(); 17 | s32 PS4_SYSV_ABI sceWebBrowserDialogGetStatus(); 18 | s32 PS4_SYSV_ABI sceWebBrowserDialogInitialize(); 19 | s32 PS4_SYSV_ABI sceWebBrowserDialogNavigate(); 20 | s32 PS4_SYSV_ABI sceWebBrowserDialogOpen(); 21 | s32 PS4_SYSV_ABI sceWebBrowserDialogOpenForPredeterminedContent(); 22 | s32 PS4_SYSV_ABI sceWebBrowserDialogResetCookie(); 23 | s32 PS4_SYSV_ABI sceWebBrowserDialogSetCookie(); 24 | s32 PS4_SYSV_ABI sceWebBrowserDialogSetZoom(); 25 | s32 PS4_SYSV_ABI sceWebBrowserDialogTerminate(); 26 | s32 PS4_SYSV_ABI sceWebBrowserDialogUpdateStatus(); 27 | s32 PS4_SYSV_ABI Func_F2BE042771625F8C(); 28 | 29 | void RegisterlibSceWebBrowserDialog(Core::Loader::SymbolsResolver* sym); 30 | } // namespace Libraries::WebBrowserDialog -------------------------------------------------------------------------------- /src/core/libraries/zlib/zlib_error.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "core/libraries/error_codes.h" 7 | 8 | // Zlib library 9 | constexpr int ORBIS_ZLIB_ERROR_NOT_FOUND = 0x81120002; 10 | constexpr int ORBIS_ZLIB_ERROR_BUSY = 0x8112000B; 11 | constexpr int ORBIS_ZLIB_ERROR_FAULT = 0x8112000E; 12 | constexpr int ORBIS_ZLIB_ERROR_INVALID = 0x81120016; 13 | constexpr int ORBIS_ZLIB_ERROR_NOSPACE = 0x8112001C; 14 | constexpr int ORBIS_ZLIB_ERROR_NOT_SUPPORTED = 0x81120025; 15 | constexpr int ORBIS_ZLIB_ERROR_TIMEDOUT = 0x81120027; 16 | constexpr int ORBIS_ZLIB_ERROR_NOT_INITIALIZED = 0x81120032; 17 | constexpr int ORBIS_ZLIB_ERROR_ALREADY_INITIALIZED = 0x81120033; 18 | constexpr int ORBIS_ZLIB_ERROR_FATAL = 0x811200FF; 19 | -------------------------------------------------------------------------------- /src/core/libraries/zlib/zlib_sce.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Core::Loader { 9 | class SymbolsResolver; 10 | } 11 | namespace Libraries::Zlib { 12 | 13 | s32 PS4_SYSV_ABI sceZlibInitialize(const void* buffer, u32 length); 14 | s32 PS4_SYSV_ABI sceZlibInflate(const void* src, u32 src_len, void* dst, u32 dst_len, 15 | u64* request_id); 16 | s32 PS4_SYSV_ABI sceZlibWaitForDone(u64* request_id, const u32* timeout); 17 | s32 PS4_SYSV_ABI sceZlibGetResult(u64 request_id, u32* dst_length, s32* status); 18 | s32 PS4_SYSV_ABI sceZlibFinalize(); 19 | 20 | void RegisterlibSceZlib(Core::Loader::SymbolsResolver* sym); 21 | } // namespace Libraries::Zlib -------------------------------------------------------------------------------- /src/core/loader.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "common/io_file.h" 5 | #include "common/types.h" 6 | #include "loader.h" 7 | 8 | namespace Loader { 9 | 10 | FileTypes DetectFileType(const std::filesystem::path& filepath) { 11 | // No file loaded 12 | if (filepath.empty()) { 13 | return FileTypes::Unknown; 14 | } 15 | Common::FS::IOFile file; 16 | file.Open(filepath, Common::FS::FileAccessMode::Read); 17 | file.Seek(0); 18 | u32 magic; 19 | file.Read(magic); 20 | file.Close(); 21 | switch (magic) { 22 | case PkgMagic: 23 | return FileTypes::Pkg; 24 | } 25 | return FileTypes::Unknown; 26 | } 27 | 28 | } // namespace Loader 29 | -------------------------------------------------------------------------------- /src/core/loader.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace Loader { 9 | 10 | constexpr static u32 PkgMagic = 0x544e437f; 11 | 12 | enum class FileTypes { 13 | Unknown, 14 | Pkg, 15 | }; 16 | 17 | FileTypes DetectFileType(const std::filesystem::path& filepath); 18 | } // namespace Loader 19 | -------------------------------------------------------------------------------- /src/core/loader/dwarf.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (C) 2001-2024 Free Software Foundation, Inc. 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Dwarf { 9 | 10 | enum { 11 | DW_EH_PE_ptr = 0x00, 12 | DW_EH_PE_uleb128 = 0x01, 13 | DW_EH_PE_udata2 = 0x02, 14 | DW_EH_PE_udata4 = 0x03, 15 | DW_EH_PE_udata8 = 0x04, 16 | DW_EH_PE_signed = 0x08, 17 | DW_EH_PE_sleb128 = 0x09, 18 | DW_EH_PE_sdata2 = 0x0A, 19 | DW_EH_PE_sdata4 = 0x0B, 20 | DW_EH_PE_sdata8 = 0x0C, 21 | DW_EH_PE_absptr = 0x00, 22 | DW_EH_PE_pcrel = 0x10, 23 | DW_EH_PE_textrel = 0x20, 24 | DW_EH_PE_datarel = 0x30, 25 | DW_EH_PE_funcrel = 0x40, 26 | DW_EH_PE_aligned = 0x50, 27 | DW_EH_PE_indirect = 0x80, 28 | DW_EH_PE_omit = 0xFF 29 | }; 30 | 31 | /// Information encoded in the EH frame header. 32 | struct EHHeaderInfo { 33 | uintptr_t eh_frame_ptr; 34 | size_t fde_count; 35 | uintptr_t table; 36 | u8 table_enc; 37 | }; 38 | 39 | bool DecodeEHHdr(uintptr_t ehHdrStart, uintptr_t ehHdrEnd, EHHeaderInfo& ehHdrInfo); 40 | 41 | } // namespace Dwarf 42 | -------------------------------------------------------------------------------- /src/core/thread.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Libraries::Kernel { 9 | struct PthreadAttr; 10 | } // namespace Libraries::Kernel 11 | 12 | namespace Core { 13 | 14 | using ThreadFunc = void (*)(void*); 15 | using PthreadFunc = void* (*)(void*); 16 | 17 | class NativeThread { 18 | public: 19 | NativeThread(); 20 | ~NativeThread(); 21 | 22 | int Create(ThreadFunc func, void* arg, const ::Libraries::Kernel::PthreadAttr* attr); 23 | void Exit(); 24 | 25 | void Initialize(); 26 | 27 | uintptr_t GetHandle() { 28 | return reinterpret_cast(native_handle); 29 | } 30 | 31 | u64 GetTid() { 32 | return tid; 33 | } 34 | 35 | private: 36 | #ifdef _WIN64 37 | void* native_handle; 38 | #else 39 | uintptr_t native_handle; 40 | void* sig_stack_ptr; 41 | #endif 42 | u64 tid; 43 | }; 44 | 45 | } // namespace Core -------------------------------------------------------------------------------- /src/core/tls.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Xbyak { 9 | class CodeGenerator; 10 | } 11 | 12 | namespace Libraries::Fiber { 13 | struct OrbisFiberContext; 14 | } 15 | 16 | namespace Core { 17 | 18 | union DtvEntry { 19 | std::size_t counter; 20 | u8* pointer; 21 | }; 22 | 23 | struct Tcb { 24 | Tcb* tcb_self; 25 | DtvEntry* tcb_dtv; 26 | void* tcb_thread; 27 | ::Libraries::Fiber::OrbisFiberContext* tcb_fiber; 28 | }; 29 | 30 | #ifdef _WIN32 31 | /// Gets the thread local storage key for the TCB block. 32 | u32 GetTcbKey(); 33 | #endif 34 | 35 | /// Sets the data pointer to the TCB block. 36 | void SetTcbBase(void* image_address); 37 | 38 | /// Retrieves Tcb structure for the calling thread. 39 | Tcb* GetTcbBase(); 40 | 41 | /// Makes sure TLS is initialized for the thread before entering guest. 42 | void EnsureThreadInitialized(); 43 | 44 | template 45 | ReturnType ExecuteGuest(PS4_SYSV_ABI ReturnType (*func)(FuncArgs...), CallArgs&&... args) { 46 | EnsureThreadInitialized(); 47 | return func(std::forward(args)...); 48 | } 49 | 50 | } // namespace Core 51 | -------------------------------------------------------------------------------- /src/emulator.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include "common/singleton.h" 10 | #include "core/linker.h" 11 | #include "input/controller.h" 12 | #include "sdl_window.h" 13 | 14 | namespace Core { 15 | 16 | using HLEInitDef = void (*)(Core::Loader::SymbolsResolver* sym); 17 | 18 | struct SysModules { 19 | std::string_view module_name; 20 | HLEInitDef callback; 21 | }; 22 | 23 | class Emulator { 24 | public: 25 | Emulator(); 26 | ~Emulator(); 27 | 28 | void Run(const std::filesystem::path& file, const std::vector args = {}); 29 | void UpdatePlayTime(const std::string& serial); 30 | 31 | private: 32 | void LoadSystemModules(const std::string& game_serial); 33 | 34 | Core::MemoryManager* memory; 35 | Input::GameController* controller; 36 | Core::Linker* linker; 37 | std::unique_ptr window; 38 | std::chrono::steady_clock::time_point start_time; 39 | }; 40 | 41 | } // namespace Core 42 | -------------------------------------------------------------------------------- /src/images/KBM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/KBM.png -------------------------------------------------------------------------------- /src/images/about_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/about_icon.png -------------------------------------------------------------------------------- /src/images/bronze.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/bronze.png -------------------------------------------------------------------------------- /src/images/controller_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/controller_icon.png -------------------------------------------------------------------------------- /src/images/discord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/discord.png -------------------------------------------------------------------------------- /src/images/dump_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/dump_icon.png -------------------------------------------------------------------------------- /src/images/exit_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/exit_icon.png -------------------------------------------------------------------------------- /src/images/file_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/file_icon.png -------------------------------------------------------------------------------- /src/images/flag_china.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/flag_china.png -------------------------------------------------------------------------------- /src/images/flag_eu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/flag_eu.png -------------------------------------------------------------------------------- /src/images/flag_jp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/flag_jp.png -------------------------------------------------------------------------------- /src/images/flag_unk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/flag_unk.png -------------------------------------------------------------------------------- /src/images/flag_us.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/flag_us.png -------------------------------------------------------------------------------- /src/images/flag_world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/flag_world.png -------------------------------------------------------------------------------- /src/images/folder_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/folder_icon.png -------------------------------------------------------------------------------- /src/images/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/github.png -------------------------------------------------------------------------------- /src/images/gold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/gold.png -------------------------------------------------------------------------------- /src/images/grid_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/grid_icon.png -------------------------------------------------------------------------------- /src/images/iconsize_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/iconsize_icon.png -------------------------------------------------------------------------------- /src/images/keyboard_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/keyboard_icon.png -------------------------------------------------------------------------------- /src/images/ko-fi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/ko-fi.png -------------------------------------------------------------------------------- /src/images/list_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/list_icon.png -------------------------------------------------------------------------------- /src/images/list_mode_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/list_mode_icon.png -------------------------------------------------------------------------------- /src/images/pause_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/pause_icon.png -------------------------------------------------------------------------------- /src/images/platinum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/platinum.png -------------------------------------------------------------------------------- /src/images/play_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/play_icon.png -------------------------------------------------------------------------------- /src/images/ps4_controller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/ps4_controller.png -------------------------------------------------------------------------------- /src/images/refresh_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/refresh_icon.png -------------------------------------------------------------------------------- /src/images/settings_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/settings_icon.png -------------------------------------------------------------------------------- /src/images/shadPS4.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/shadPS4.icns -------------------------------------------------------------------------------- /src/images/shadps4.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/shadps4.ico -------------------------------------------------------------------------------- /src/images/silver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/silver.png -------------------------------------------------------------------------------- /src/images/stop_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/stop_icon.png -------------------------------------------------------------------------------- /src/images/themes_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/themes_icon.png -------------------------------------------------------------------------------- /src/images/update_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/update_icon.png -------------------------------------------------------------------------------- /src/images/utils_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/utils_icon.png -------------------------------------------------------------------------------- /src/images/website.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/website.png -------------------------------------------------------------------------------- /src/images/youtube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/images/youtube.png -------------------------------------------------------------------------------- /src/imgui/imgui_layer.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | namespace ImGui { 7 | 8 | class Layer { 9 | public: 10 | virtual ~Layer() = default; 11 | static void AddLayer(Layer* layer); 12 | static void RemoveLayer(Layer* layer); 13 | 14 | virtual void Draw() = 0; 15 | }; 16 | 17 | } // namespace ImGui -------------------------------------------------------------------------------- /src/imgui/imgui_texture.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace ImGui { 10 | 11 | namespace Core::TextureManager { 12 | struct Inner; 13 | } // namespace Core::TextureManager 14 | 15 | class RefCountedTexture { 16 | Core::TextureManager::Inner* inner; 17 | 18 | explicit RefCountedTexture(Core::TextureManager::Inner* inner); 19 | 20 | public: 21 | struct Image { 22 | ImTextureID im_id; 23 | u32 width; 24 | u32 height; 25 | }; 26 | 27 | static RefCountedTexture DecodePngTexture(std::vector data); 28 | 29 | static RefCountedTexture DecodePngFile(std::filesystem::path path); 30 | 31 | RefCountedTexture(); 32 | 33 | RefCountedTexture(const RefCountedTexture& other); 34 | RefCountedTexture(RefCountedTexture&& other) noexcept; 35 | RefCountedTexture& operator=(const RefCountedTexture& other); 36 | RefCountedTexture& operator=(RefCountedTexture&& other) noexcept; 37 | 38 | virtual ~RefCountedTexture(); 39 | 40 | [[nodiscard]] Image GetTexture() const; 41 | 42 | explicit(false) operator bool() const; 43 | }; 44 | 45 | }; // namespace ImGui -------------------------------------------------------------------------------- /src/imgui/renderer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | # SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | project(ImGui_Resources) 5 | 6 | add_executable(Dear_ImGui_FontEmbed ${CMAKE_SOURCE_DIR}/externals/dear_imgui/misc/fonts/binary_to_compressed_c.cpp) 7 | 8 | set(FONT_LIST 9 | NotoSansJP-Regular.ttf 10 | ProggyVector-Regular.ttf 11 | ) 12 | 13 | set(OutputList "") 14 | FOREACH (FONT_FILE ${FONT_LIST}) 15 | string(REGEX REPLACE "-" "_" fontname ${FONT_FILE}) 16 | string(TOLOWER ${fontname} fontname) 17 | string(REGEX REPLACE ".ttf" "" fontname_cpp ${fontname}) 18 | set(fontname_cpp "imgui_font_${fontname_cpp}") 19 | 20 | MESSAGE(STATUS "Embedding font ${FONT_FILE}") 21 | set(OUTPUT "generated_fonts/imgui_fonts/${fontname}") 22 | add_custom_command( 23 | OUTPUT "${OUTPUT}.g.cpp" 24 | COMMAND ${CMAKE_COMMAND} -E make_directory "generated_fonts/imgui_fonts" 25 | COMMAND $ -nostatic "${CMAKE_CURRENT_SOURCE_DIR}/fonts/${FONT_FILE}" ${fontname_cpp} > "${OUTPUT}.g.cpp" 26 | DEPENDS Dear_ImGui_FontEmbed "fonts/${FONT_FILE}" 27 | USES_TERMINAL 28 | ) 29 | list(APPEND OutputList "${OUTPUT}.g.cpp") 30 | ENDFOREACH () 31 | 32 | add_library(ImGui_Resources STATIC ${OutputList}) 33 | set(IMGUI_RESOURCES_INCLUDE ${CMAKE_CURRENT_BINARY_DIR}/generated_fonts PARENT_SCOPE) 34 | -------------------------------------------------------------------------------- /src/imgui/renderer/fonts/NotoSansJP-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/imgui/renderer/fonts/NotoSansJP-Regular.ttf -------------------------------------------------------------------------------- /src/imgui/renderer/fonts/ProggyVector-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tersonous/shandroidPS4/dc52cfb9bc59b99710a827526dd5a5e4d865b3ce/src/imgui/renderer/fonts/ProggyVector-Regular.ttf -------------------------------------------------------------------------------- /src/imgui/renderer/imgui_core.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include "video_core/renderer_vulkan/vk_instance.h" 9 | #include "vulkan/vulkan_handles.hpp" 10 | 11 | union SDL_Event; 12 | 13 | namespace Vulkan { 14 | struct Frame; 15 | } 16 | 17 | namespace ImGui::Core { 18 | 19 | void Initialize(const Vulkan::Instance& instance, const Frontend::WindowSDL& window, 20 | u32 image_count, vk::Format surface_format, 21 | const vk::AllocationCallbacks* allocator = nullptr); 22 | 23 | void OnResize(); 24 | 25 | void OnSurfaceFormatChange(vk::Format surface_format); 26 | 27 | void Shutdown(const vk::Device& device); 28 | 29 | bool ProcessEvent(SDL_Event* event); 30 | 31 | ImGuiID NewFrame(bool is_reusing_frame = false); 32 | 33 | void Render(const vk::CommandBuffer& cmdbuf, const vk::ImageView& image_view, 34 | const vk::Extent2D& extent); 35 | 36 | bool MustKeepDrawing(); // Force the emulator redraw 37 | 38 | } // namespace ImGui::Core 39 | -------------------------------------------------------------------------------- /src/imgui/renderer/imgui_impl_sdl3.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | // Based on imgui_impl_sdl3.h from Dear ImGui repository 5 | 6 | #pragma once 7 | 8 | struct SDL_Window; 9 | struct SDL_Renderer; 10 | struct SDL_Gamepad; 11 | typedef union SDL_Event SDL_Event; 12 | 13 | namespace ImGui::Sdl { 14 | 15 | bool Init(SDL_Window* window); 16 | void Shutdown(); 17 | void NewFrame(bool is_reusing); 18 | bool ProcessEvent(const SDL_Event* event); 19 | void OnResize(); 20 | 21 | // Gamepad selection automatically starts in AutoFirst mode, picking first available SDL_Gamepad. 22 | // You may override this. When using manual mode, caller is responsible for opening/closing gamepad. 23 | enum GamepadMode { 24 | ImGui_ImplSDL3_GamepadMode_AutoFirst, 25 | ImGui_ImplSDL3_GamepadMode_AutoAll, 26 | ImGui_ImplSDL3_GamepadMode_Manual 27 | }; 28 | void SetGamepadMode(GamepadMode mode, SDL_Gamepad** manual_gamepads_array = NULL, 29 | int manual_gamepads_count = -1); 30 | 31 | }; // namespace ImGui::Sdl 32 | -------------------------------------------------------------------------------- /src/imgui/renderer/texture_manager.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include "common/types.h" 10 | #include "imgui/imgui_texture.h" 11 | 12 | namespace vk { 13 | class CommandBuffer; 14 | } 15 | 16 | namespace ImGui::Core::TextureManager { 17 | 18 | struct Inner; 19 | 20 | void StartWorker(); 21 | 22 | void StopWorker(); 23 | 24 | void DecodePngTexture(std::vector data, Inner* core); 25 | 26 | void DecodePngFile(std::filesystem::path path, Inner* core); 27 | 28 | void Submit(); 29 | 30 | }; // namespace ImGui::Core::TextureManager -------------------------------------------------------------------------------- /src/input/input_mouse.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "SDL3/SDL.h" 7 | #include "common/types.h" 8 | 9 | namespace Input { 10 | 11 | void ToggleMouseEnabled(); 12 | void SetMouseToJoystick(int joystick); 13 | void SetMouseParams(float mouse_deadzone_offset, float mouse_speed, float mouse_speed_offset); 14 | 15 | // Polls the mouse for changes, and simulates joystick movement from it. 16 | Uint32 MousePolling(void* param, Uint32 id, Uint32 interval); 17 | 18 | } // namespace Input 19 | -------------------------------------------------------------------------------- /src/qt_gui/about_dialog.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace Ui { 13 | class AboutDialog; 14 | } 15 | 16 | class AboutDialog : public QDialog { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit AboutDialog(QWidget* parent = nullptr); 21 | ~AboutDialog(); 22 | bool eventFilter(QObject* obj, QEvent* event); 23 | 24 | private: 25 | Ui::AboutDialog* ui; 26 | 27 | void preloadImages(); 28 | void updateImagesForCurrentTheme(); 29 | void applyHoverEffect(QLabel* label); 30 | void removeHoverEffect(QLabel* label); 31 | 32 | bool isDarkTheme() const; 33 | 34 | QPixmap originalImages[5]; 35 | QPixmap invertedImages[5]; 36 | }; 37 | -------------------------------------------------------------------------------- /src/qt_gui/background_music_player.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "background_music_player.h" 5 | 6 | BackgroundMusicPlayer::BackgroundMusicPlayer(QObject* parent) : QObject(parent) { 7 | m_mediaPlayer = new QMediaPlayer(this); 8 | m_audioOutput = new QAudioOutput(this); 9 | m_mediaPlayer->setAudioOutput(m_audioOutput); 10 | } 11 | 12 | void BackgroundMusicPlayer::setVolume(int volume) { 13 | float linearVolume = QAudio::convertVolume(volume / 100.0f, QAudio::LogarithmicVolumeScale, 14 | QAudio::LinearVolumeScale); 15 | m_audioOutput->setVolume(linearVolume); 16 | } 17 | 18 | void BackgroundMusicPlayer::playMusic(const QString& snd0path, bool loops) { 19 | if (snd0path.isEmpty()) { 20 | stopMusic(); 21 | return; 22 | } 23 | const auto newMusic = QUrl::fromLocalFile(snd0path); 24 | if (m_mediaPlayer->playbackState() == QMediaPlayer::PlayingState && 25 | m_currentMusic == newMusic) { 26 | // already playing the correct music 27 | return; 28 | } 29 | 30 | if (loops) { 31 | m_mediaPlayer->setLoops(QMediaPlayer::Infinite); 32 | } else { 33 | m_mediaPlayer->setLoops(1); 34 | } 35 | 36 | m_currentMusic = newMusic; 37 | m_mediaPlayer->setSource(newMusic); 38 | m_mediaPlayer->play(); 39 | } 40 | 41 | void BackgroundMusicPlayer::stopMusic() { 42 | m_mediaPlayer->stop(); 43 | m_mediaPlayer->setSource(QUrl("")); 44 | } 45 | -------------------------------------------------------------------------------- /src/qt_gui/background_music_player.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | class BackgroundMusicPlayer : public QObject { 11 | Q_OBJECT 12 | 13 | public: 14 | static BackgroundMusicPlayer& getInstance() { 15 | static BackgroundMusicPlayer instance; 16 | return instance; 17 | } 18 | 19 | void setVolume(int volume); 20 | void playMusic(const QString& snd0path, bool loops = true); 21 | void stopMusic(); 22 | 23 | private: 24 | BackgroundMusicPlayer(QObject* parent = nullptr); 25 | 26 | QMediaPlayer* m_mediaPlayer; 27 | QAudioOutput* m_audioOutput; 28 | QUrl m_currentMusic; 29 | }; 30 | -------------------------------------------------------------------------------- /src/qt_gui/check_update.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #ifndef CHECKUPDATE_H 5 | #define CHECKUPDATE_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class CheckUpdate : public QDialog { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit CheckUpdate(const bool showMessage, QWidget* parent = nullptr); 17 | ~CheckUpdate(); 18 | 19 | private slots: 20 | void CheckForUpdates(const bool showMessage); 21 | void DownloadUpdate(const QString& url); 22 | void Install(); 23 | 24 | private: 25 | void setupUI(const QString& downloadUrl, const QString& latestDate, const QString& latestRev, 26 | const QString& currentDate, const QString& currentRev); 27 | 28 | void requestChangelog(const QString& currentRev, const QString& latestRev, 29 | const QString& downloadUrl, const QString& latestDate, 30 | const QString& currentDate); 31 | 32 | QCheckBox* autoUpdateCheckBox; 33 | QPushButton* yesButton; 34 | QPushButton* noButton; 35 | QString updateDownloadUrl; 36 | 37 | QNetworkAccessManager* networkManager; 38 | }; 39 | 40 | #endif // CHECKUPDATE_H 41 | -------------------------------------------------------------------------------- /src/qt_gui/game_install_dialog.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include "common/config.h" 9 | #include "common/path_util.h" 10 | 11 | class QLineEdit; 12 | 13 | class GameInstallDialog final : public QDialog { 14 | Q_OBJECT 15 | public: 16 | GameInstallDialog(); 17 | ~GameInstallDialog(); 18 | 19 | private slots: 20 | void BrowseGamesDirectory(); 21 | void BrowseAddonsDirectory(); 22 | 23 | private: 24 | QWidget* SetupGamesDirectory(); 25 | QWidget* SetupAddonsDirectory(); 26 | QWidget* SetupDialogActions(); 27 | void Save(); 28 | 29 | private: 30 | QLineEdit* m_gamesDirectory; 31 | QLineEdit* m_addonsDirectory; 32 | }; -------------------------------------------------------------------------------- /src/qt_gui/install_dir_select.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include "common/config.h" 10 | #include "common/path_util.h" 11 | 12 | class QLineEdit; 13 | 14 | class InstallDirSelect final : public QDialog { 15 | Q_OBJECT 16 | 17 | public: 18 | InstallDirSelect(); 19 | ~InstallDirSelect(); 20 | 21 | std::filesystem::path getSelectedDirectory() { 22 | return selected_dir; 23 | } 24 | 25 | bool useForAllQueued() { 26 | return use_for_all_queued; 27 | } 28 | 29 | bool deleteFileOnInstall() { 30 | return delete_file_on_install; 31 | } 32 | 33 | private: 34 | QWidget* SetupInstallDirList(); 35 | QWidget* SetupDialogActions(); 36 | void setSelectedDirectory(QListWidgetItem* item); 37 | void setDeleteFileOnInstall(bool enabled); 38 | void setUseForAllQueued(bool enabled); 39 | std::filesystem::path selected_dir; 40 | bool delete_file_on_install = false; 41 | bool use_for_all_queued = false; 42 | }; 43 | -------------------------------------------------------------------------------- /src/qt_gui/kbm_config_dialog.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include "string" 10 | 11 | class EditorDialog : public QDialog { 12 | Q_OBJECT // Necessary for using Qt's meta-object system (signals/slots) 13 | public : explicit EditorDialog(QWidget* parent = nullptr); // Constructor 14 | 15 | protected: 16 | void closeEvent(QCloseEvent* event) override; // Override close event 17 | void keyPressEvent(QKeyEvent* event) override; 18 | 19 | private: 20 | QPlainTextEdit* editor; // Editor widget for the config file 21 | QFont editorFont; // To handle the text size 22 | QString originalConfig; // Starting config string 23 | std::string gameId; 24 | 25 | QComboBox* gameComboBox; // Combo box for selecting game configurations 26 | 27 | void loadFile(QString game); // Function to load the config file 28 | void saveFile(QString game); // Function to save the config file 29 | void loadInstalledGames(); // Helper to populate gameComboBox 30 | bool hasUnsavedChanges(); // Checks for unsaved changes 31 | 32 | private slots: 33 | void onSaveClicked(); // Save button slot 34 | void onCancelClicked(); // Slot for handling cancel button 35 | void onHelpClicked(); // Slot for handling help button 36 | void onResetToDefaultClicked(); 37 | void onGameSelectionChanged(const QString& game); // Slot for game selection changes 38 | }; 39 | -------------------------------------------------------------------------------- /src/qt_gui/main_window_themes.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | enum class Theme : int { Dark, Light, Green, Blue, Violet, Gruvbox, TokyoNight, Oled }; 11 | 12 | class WindowThemes : public QObject { 13 | Q_OBJECT 14 | public Q_SLOTS: 15 | void SetWindowTheme(Theme theme, QLineEdit* mw_searchbar); 16 | }; 17 | -------------------------------------------------------------------------------- /src/qt_gui/translations/update_translation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}") 4 | 5 | OPTS="-tr-function-alias QT_TRANSLATE_NOOP+=TRANSLATE,QT_TRANSLATE_NOOP+=TRANSLATE_SV,QT_TRANSLATE_NOOP+=TRANSLATE_STR,QT_TRANSLATE_NOOP+=TRANSLATE_FS,QT_TRANSLATE_N_NOOP3+=TRANSLATE_FMT,QT_TRANSLATE_NOOP+=TRANSLATE_NOOP,translate+=TRANSLATE_PLURAL_STR,translate+=TRANSLATE_PLURAL_FS -no-obsolete" 6 | SRCDIRS=$(realpath "$SCRIPTDIR/..")/\ $(realpath "$SCRIPTDIR/../..")/ 7 | OUTDIR=$(realpath "$SCRIPTDIR") 8 | 9 | lupdate $SRCDIRS $OPTS -locations none -source-language en_US -ts "$OUTDIR/en_US.ts" 10 | 11 | if ! head -n 2 "$OUTDIR/en_US.ts" | grep -q "SPDX-FileCopyrightText"; then 12 | sed -i '2i\' "$OUTDIR/en_US.ts" 13 | fi 14 | -------------------------------------------------------------------------------- /src/shader_recompiler/backend/bindings.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Shader::Backend { 9 | 10 | struct Bindings { 11 | u32 unified{}; 12 | u32 buffer{}; 13 | u32 user_data{}; 14 | 15 | auto operator<=>(const Bindings&) const = default; 16 | }; 17 | 18 | } // namespace Shader::Backend 19 | -------------------------------------------------------------------------------- /src/shader_recompiler/backend/spirv/emit_spirv.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "shader_recompiler/backend/bindings.h" 8 | #include "shader_recompiler/ir/program.h" 9 | #include "shader_recompiler/profile.h" 10 | 11 | namespace Shader::Backend::SPIRV { 12 | 13 | [[nodiscard]] std::vector EmitSPIRV(const Profile& profile, const RuntimeInfo& runtime_info, 14 | const IR::Program& program, Bindings& binding); 15 | 16 | } // namespace Shader::Backend::SPIRV 17 | -------------------------------------------------------------------------------- /src/shader_recompiler/backend/spirv/emit_spirv_logical.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "shader_recompiler/backend/spirv/emit_spirv_instructions.h" 5 | #include "shader_recompiler/backend/spirv/spirv_emit_context.h" 6 | 7 | namespace Shader::Backend::SPIRV { 8 | 9 | Id EmitLogicalOr(EmitContext& ctx, Id a, Id b) { 10 | return ctx.OpLogicalOr(ctx.U1[1], a, b); 11 | } 12 | 13 | Id EmitLogicalAnd(EmitContext& ctx, Id a, Id b) { 14 | return ctx.OpLogicalAnd(ctx.U1[1], a, b); 15 | } 16 | 17 | Id EmitLogicalXor(EmitContext& ctx, Id a, Id b) { 18 | return ctx.OpLogicalNotEqual(ctx.U1[1], a, b); 19 | } 20 | 21 | Id EmitLogicalNot(EmitContext& ctx, Id value) { 22 | return ctx.OpLogicalNot(ctx.U1[1], value); 23 | } 24 | 25 | } // namespace Shader::Backend::SPIRV 26 | -------------------------------------------------------------------------------- /src/shader_recompiler/backend/spirv/emit_spirv_quad_rect.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "common/types.h" 8 | 9 | namespace Shader { 10 | struct FragmentRuntimeInfo; 11 | } 12 | 13 | namespace Shader::Backend::SPIRV { 14 | 15 | enum class AuxShaderType : u32 { 16 | RectListTCS, 17 | QuadListTCS, 18 | PassthroughTES, 19 | }; 20 | 21 | [[nodiscard]] std::vector EmitAuxilaryTessShader(AuxShaderType type, 22 | const FragmentRuntimeInfo& fs_info); 23 | 24 | } // namespace Shader::Backend::SPIRV 25 | -------------------------------------------------------------------------------- /src/shader_recompiler/backend/spirv/emit_spirv_undefined.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "shader_recompiler/backend/spirv/emit_spirv_instructions.h" 5 | #include "shader_recompiler/backend/spirv/spirv_emit_context.h" 6 | 7 | namespace Shader::Backend::SPIRV { 8 | 9 | Id EmitUndefU1(EmitContext& ctx) { 10 | return ctx.OpUndef(ctx.U1[1]); 11 | } 12 | 13 | Id EmitUndefU8(EmitContext&) { 14 | UNREACHABLE_MSG("SPIR-V Instruction"); 15 | } 16 | 17 | Id EmitUndefU16(EmitContext&) { 18 | UNREACHABLE_MSG("SPIR-V Instruction"); 19 | } 20 | 21 | Id EmitUndefU32(EmitContext& ctx) { 22 | return ctx.OpUndef(ctx.U32[1]); 23 | } 24 | 25 | Id EmitUndefU64(EmitContext&) { 26 | UNREACHABLE_MSG("SPIR-V Instruction"); 27 | } 28 | 29 | } // namespace Shader::Backend::SPIRV 30 | -------------------------------------------------------------------------------- /src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "shader_recompiler/backend/spirv/emit_spirv_instructions.h" 5 | #include "shader_recompiler/backend/spirv/spirv_emit_context.h" 6 | 7 | namespace Shader::Backend::SPIRV { 8 | 9 | Id SubgroupScope(EmitContext& ctx) { 10 | return ctx.ConstU32(static_cast(spv::Scope::Subgroup)); 11 | } 12 | 13 | Id EmitWarpId(EmitContext& ctx) { 14 | UNREACHABLE(); 15 | } 16 | 17 | Id EmitLaneId(EmitContext& ctx) { 18 | return ctx.OpLoad(ctx.U32[1], ctx.subgroup_local_invocation_id); 19 | } 20 | 21 | Id EmitQuadShuffle(EmitContext& ctx, Id value, Id index) { 22 | return ctx.OpGroupNonUniformQuadBroadcast(ctx.U32[1], SubgroupScope(ctx), value, index); 23 | } 24 | 25 | Id EmitReadFirstLane(EmitContext& ctx, Id value) { 26 | return ctx.OpGroupNonUniformBroadcastFirst(ctx.U32[1], SubgroupScope(ctx), value); 27 | } 28 | 29 | Id EmitReadLane(EmitContext& ctx, Id value, u32 lane) { 30 | return ctx.OpGroupNonUniformBroadcast(ctx.U32[1], SubgroupScope(ctx), value, 31 | ctx.ConstU32(lane)); 32 | } 33 | 34 | Id EmitWriteLane(EmitContext& ctx, Id value, Id write_value, u32 lane) { 35 | return ctx.u32_zero_value; 36 | } 37 | 38 | } // namespace Shader::Backend::SPIRV 39 | -------------------------------------------------------------------------------- /src/shader_recompiler/frontend/copy_shader.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include "common/types.h" 10 | #include "shader_recompiler/ir/attribute.h" 11 | 12 | namespace Shader { 13 | 14 | struct CopyShaderData { 15 | std::unordered_map> attr_map; 16 | u32 num_attrs{0}; 17 | }; 18 | 19 | CopyShaderData ParseCopyShader(std::span code); 20 | 21 | } // namespace Shader 22 | -------------------------------------------------------------------------------- /src/shader_recompiler/frontend/structured_control_flow.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "shader_recompiler/frontend/control_flow_graph.h" 7 | #include "shader_recompiler/ir/abstract_syntax_list.h" 8 | #include "shader_recompiler/ir/basic_block.h" 9 | #include "shader_recompiler/ir/value.h" 10 | 11 | namespace Shader { 12 | struct Info; 13 | struct Profile; 14 | struct RuntimeInfo; 15 | } // namespace Shader 16 | 17 | namespace Shader::Gcn { 18 | 19 | [[nodiscard]] IR::AbstractSyntaxList BuildASL(Common::ObjectPool& inst_pool, 20 | Common::ObjectPool& block_pool, CFG& cfg, 21 | Info& info, const RuntimeInfo& runtime_info, 22 | const Profile& profile); 23 | 24 | } // namespace Shader::Gcn 25 | -------------------------------------------------------------------------------- /src/shader_recompiler/frontend/tessellation.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Shader { 9 | 10 | struct TessellationDataConstantBuffer { 11 | u32 ls_stride; 12 | u32 hs_cp_stride; // HullStateConstants::m_cpStride != 0 ? HullStateConstants::m_cpStride : 13 | // ls_stride 14 | u32 num_patches; // num patches submitted in threadgroup 15 | u32 hs_output_base; // HullStateConstants::m_numInputCP::m_cpStride != 0 ? 16 | // HullStateConstants::m_numInputCP * ls_stride * num_patches : 0 17 | // basically 0 when passthrough 18 | u32 patch_const_size; // 16 * num_patch_attrs 19 | u32 patch_const_base; // hs_output_base + patch_output_size 20 | u32 patch_output_size; // output_cp_stride * num_output_cp_per_patch 21 | f32 off_chip_tessellation_factor_threshold; 22 | u32 first_edge_tess_factor_index; 23 | }; 24 | 25 | // Assign names to dword fields of TessellationDataConstantBuffer 26 | enum class TessConstantAttribute : u32 { 27 | LsStride, 28 | HsCpStride, 29 | HsNumPatch, 30 | HsOutputBase, 31 | PatchConstSize, 32 | PatchConstBase, 33 | PatchOutputSize, 34 | OffChipTessellationFactorThreshold, 35 | FirstEdgeTessFactorIndex, 36 | }; 37 | 38 | } // namespace Shader -------------------------------------------------------------------------------- /src/shader_recompiler/frontend/translate/vector_interpolation.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "shader_recompiler/frontend/translate/translate.h" 5 | 6 | namespace Shader::Gcn { 7 | 8 | void Translator::EmitVectorInterpolation(const GcnInst& inst) { 9 | switch (inst.opcode) { 10 | // VINTRP 11 | case Opcode::V_INTERP_P1_F32: 12 | return; 13 | case Opcode::V_INTERP_P2_F32: 14 | return V_INTERP_P2_F32(inst); 15 | case Opcode::V_INTERP_MOV_F32: 16 | return V_INTERP_MOV_F32(inst); 17 | default: 18 | LogMissingOpcode(inst); 19 | } 20 | } 21 | 22 | // VINTRP 23 | 24 | void Translator::V_INTERP_P2_F32(const GcnInst& inst) { 25 | auto& attr = runtime_info.fs_info.inputs.at(inst.control.vintrp.attr); 26 | const IR::Attribute attrib{IR::Attribute::Param0 + attr.param_index}; 27 | SetDst(inst.dst[0], ir.GetAttribute(attrib, inst.control.vintrp.chan)); 28 | } 29 | 30 | void Translator::V_INTERP_MOV_F32(const GcnInst& inst) { 31 | auto& attr = runtime_info.fs_info.inputs.at(inst.control.vintrp.attr); 32 | const IR::Attribute attrib{IR::Attribute::Param0 + attr.param_index}; 33 | SetDst(inst.dst[0], ir.GetAttribute(attrib, inst.control.vintrp.chan)); 34 | } 35 | 36 | } // namespace Shader::Gcn 37 | -------------------------------------------------------------------------------- /src/shader_recompiler/ir/abstract_syntax_list.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "shader_recompiler/ir/value.h" 8 | 9 | namespace Shader::IR { 10 | 11 | class Block; 12 | 13 | struct AbstractSyntaxNode { 14 | enum class Type { 15 | Block, 16 | If, 17 | EndIf, 18 | Loop, 19 | Repeat, 20 | Break, 21 | Return, 22 | Unreachable, 23 | }; 24 | union Data { 25 | Block* block; 26 | struct { 27 | U1 cond; 28 | Block* body; 29 | Block* merge; 30 | } if_node; 31 | struct { 32 | Block* merge; 33 | } end_if; 34 | struct { 35 | Block* body; 36 | Block* continue_block; 37 | Block* merge; 38 | } loop; 39 | struct { 40 | U1 cond; 41 | Block* loop_header; 42 | Block* merge; 43 | } repeat; 44 | struct { 45 | U1 cond; 46 | Block* merge; 47 | Block* skip; 48 | } break_node; 49 | }; 50 | 51 | Data data{}; 52 | Type type{}; 53 | }; 54 | using AbstractSyntaxList = std::vector; 55 | 56 | } // namespace Shader::IR 57 | -------------------------------------------------------------------------------- /src/shader_recompiler/ir/condition.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "common/types.h" 8 | 9 | namespace Shader::IR { 10 | 11 | enum class Condition : u32 { 12 | False, 13 | True, 14 | Scc0, 15 | Scc1, 16 | Vccz, 17 | Vccnz, 18 | Execz, 19 | Execnz, 20 | }; 21 | 22 | constexpr std::string_view NameOf(Condition condition) { 23 | switch (condition) { 24 | case Condition::False: 25 | return "False"; 26 | case Condition::True: 27 | return "True"; 28 | case Condition::Scc0: 29 | return "Scc0"; 30 | case Condition::Scc1: 31 | return "Scc1"; 32 | case Condition::Vccz: 33 | return "Vccz"; 34 | case Condition::Vccnz: 35 | return "Vccnz"; 36 | case Condition::Execz: 37 | return "Execz"; 38 | case Condition::Execnz: 39 | return "Execnz"; 40 | } 41 | } 42 | 43 | } // namespace Shader::IR 44 | 45 | template <> 46 | struct fmt::formatter : formatter { 47 | auto format(const Shader::IR::Condition cond, format_context& ctx) const { 48 | return formatter::format(NameOf(cond), ctx); 49 | } 50 | }; 51 | -------------------------------------------------------------------------------- /src/shader_recompiler/ir/debug_print.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "common/bit_field.h" 5 | #include "shader_recompiler/ir/opcodes.h" 6 | #include "src/common/types.h" 7 | 8 | #pragma once 9 | 10 | namespace Shader::IR { 11 | 12 | constexpr size_t DEBUGPRINT_NUM_FORMAT_ARGS = NumArgsOf(IR::Opcode::DebugPrint) - 1; 13 | 14 | union DebugPrintFlags { 15 | u32 raw; 16 | // For now, only flag is the number of variadic format args actually used 17 | // So bitfield not really needed 18 | BitField<0, 32, u32> num_args; 19 | }; 20 | 21 | } // namespace Shader::IR -------------------------------------------------------------------------------- /src/shader_recompiler/ir/opcodes.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "shader_recompiler/ir/opcodes.h" 5 | 6 | namespace Shader::IR { 7 | 8 | std::string_view NameOf(Opcode op) { 9 | return Detail::META_TABLE[static_cast(op)].name; 10 | } 11 | 12 | } // namespace Shader::IR 13 | -------------------------------------------------------------------------------- /src/shader_recompiler/ir/passes/constant_propogation.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once -------------------------------------------------------------------------------- /src/shader_recompiler/ir/passes/dead_code_elimination_pass.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "shader_recompiler/ir/program.h" 5 | 6 | namespace Shader::Optimization { 7 | 8 | void DeadCodeEliminationPass(IR::Program& program) { 9 | // We iterate over the instructions in reverse order. 10 | // This is because removing an instruction reduces the number of uses for earlier instructions. 11 | for (IR::Block* const block : program.post_order_blocks) { 12 | auto it{block->end()}; 13 | while (it != block->begin()) { 14 | --it; 15 | if (!it->HasUses() && !it->MayHaveSideEffects()) { 16 | it->Invalidate(); 17 | it = block->Instructions().erase(it); 18 | } 19 | } 20 | } 21 | } 22 | 23 | } // namespace Shader::Optimization 24 | -------------------------------------------------------------------------------- /src/shader_recompiler/ir/passes/identity_removal_pass.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include 5 | #include "shader_recompiler/ir/program.h" 6 | 7 | namespace Shader::Optimization { 8 | 9 | void IdentityRemovalPass(IR::BlockList& program) { 10 | std::vector to_invalidate; 11 | for (IR::Block* const block : program) { 12 | for (auto inst = block->begin(); inst != block->end();) { 13 | const size_t num_args{inst->NumArgs()}; 14 | for (size_t i = 0; i < num_args; ++i) { 15 | IR::Value arg; 16 | while ((arg = inst->Arg(i)).IsIdentity()) { 17 | inst->SetArg(i, arg.Inst()->Arg(0)); 18 | } 19 | } 20 | if (inst->GetOpcode() == IR::Opcode::Identity || 21 | inst->GetOpcode() == IR::Opcode::Void) { 22 | to_invalidate.push_back(&*inst); 23 | inst = block->Instructions().erase(inst); 24 | } else { 25 | ++inst; 26 | } 27 | } 28 | } 29 | for (IR::Inst* const inst : to_invalidate) { 30 | inst->Invalidate(); 31 | } 32 | } 33 | 34 | } // namespace Shader::Optimization 35 | -------------------------------------------------------------------------------- /src/shader_recompiler/ir/passes/ir_passes.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "shader_recompiler/ir/basic_block.h" 7 | #include "shader_recompiler/ir/program.h" 8 | 9 | namespace Shader { 10 | struct Profile; 11 | } 12 | 13 | namespace Shader::Optimization { 14 | 15 | void SsaRewritePass(IR::BlockList& program); 16 | void IdentityRemovalPass(IR::BlockList& program); 17 | void DeadCodeEliminationPass(IR::Program& program); 18 | void ConstantPropagationPass(IR::BlockList& program); 19 | void FlattenExtendedUserdataPass(IR::Program& program); 20 | void ResourceTrackingPass(IR::Program& program); 21 | void CollectShaderInfoPass(IR::Program& program); 22 | void LowerBufferFormatToRaw(IR::Program& program); 23 | void RingAccessElimination(const IR::Program& program, const RuntimeInfo& runtime_info, 24 | Stage stage); 25 | void TessellationPreprocess(IR::Program& program, RuntimeInfo& runtime_info); 26 | void HullShaderTransform(IR::Program& program, RuntimeInfo& runtime_info); 27 | void DomainShaderTransform(IR::Program& program, RuntimeInfo& runtime_info); 28 | void SharedMemoryBarrierPass(IR::Program& program, const RuntimeInfo& runtime_info, 29 | const Profile& profile); 30 | void SharedMemoryToStoragePass(IR::Program& program, const RuntimeInfo& runtime_info, 31 | const Profile& profile); 32 | 33 | } // namespace Shader::Optimization 34 | -------------------------------------------------------------------------------- /src/shader_recompiler/ir/passes/srt.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include "common/types.h" 9 | 10 | namespace Shader { 11 | 12 | using PFN_SrtWalker = void PS4_SYSV_ABI (*)(const u32* /*user_data*/, u32* /*flat_dst*/); 13 | 14 | struct PersistentSrtInfo { 15 | // Special case when fetch shader uses step rates. 16 | struct SrtSharpReservation { 17 | u32 sgpr_base; 18 | u32 dword_offset; 19 | u32 num_dwords; 20 | }; 21 | 22 | PFN_SrtWalker walker_func{}; 23 | boost::container::small_vector srt_reservations; 24 | u32 flattened_bufsize_dw = 16; // NumUserDataRegs 25 | 26 | // Special case for fetch shaders because we don't generate IR to read from step rate buffers, 27 | // so we won't see usage with GetUserData/ReadConst. 28 | // Reserve space in the flattened buffer for a sharp ahead of time 29 | u32 ReserveSharp(u32 sgpr_base, u32 dword_offset, u32 num_dwords) { 30 | u32 rv = flattened_bufsize_dw; 31 | srt_reservations.emplace_back(sgpr_base, dword_offset, num_dwords); 32 | flattened_bufsize_dw += num_dwords; 33 | return rv; 34 | } 35 | }; 36 | 37 | } // namespace Shader -------------------------------------------------------------------------------- /src/shader_recompiler/ir/patch.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "shader_recompiler/ir/patch.h" 5 | 6 | namespace Shader::IR { 7 | 8 | std::string NameOf(Patch patch) { 9 | switch (patch) { 10 | case Patch::TessellationLodLeft: 11 | return "TessellationLodLeft"; 12 | case Patch::TessellationLodTop: 13 | return "TessellationLodTop"; 14 | case Patch::TessellationLodRight: 15 | return "TessellationLodRight"; 16 | case Patch::TessellationLodBottom: 17 | return "TessellationLodBottom"; 18 | case Patch::TessellationLodInteriorU: 19 | return "TessellationLodInteriorU"; 20 | case Patch::TessellationLodInteriorV: 21 | return "TessellationLodInteriorV"; 22 | default: 23 | const u32 index = u32(patch) - u32(Patch::Component0); 24 | return fmt::format("Component{}", index); 25 | } 26 | } 27 | 28 | } // namespace Shader::IR 29 | -------------------------------------------------------------------------------- /src/shader_recompiler/ir/post_order.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include 5 | #include 6 | #include 7 | #include "shader_recompiler/ir/post_order.h" 8 | 9 | namespace Shader::IR { 10 | 11 | BlockList PostOrder(const AbstractSyntaxNode& root) { 12 | boost::container::small_vector block_stack; 13 | boost::container::flat_set visited; 14 | BlockList post_order_blocks; 15 | 16 | if (root.type != AbstractSyntaxNode::Type::Block) { 17 | UNREACHABLE_MSG("First node in abstract syntax list root is not a block"); 18 | } 19 | Block* const first_block{root.data.block}; 20 | visited.insert(first_block); 21 | block_stack.push_back(first_block); 22 | 23 | while (!block_stack.empty()) { 24 | Block* const block = block_stack.back(); 25 | const auto visit = [&](Block* branch) { 26 | if (!visited.insert(branch).second) { 27 | return false; 28 | } 29 | // Calling push_back twice is faster than insert on MSVC 30 | block_stack.push_back(block); 31 | block_stack.push_back(branch); 32 | return true; 33 | }; 34 | block_stack.pop_back(); 35 | if (std::ranges::none_of(block->ImmSuccessors(), visit)) { 36 | post_order_blocks.push_back(block); 37 | } 38 | } 39 | return post_order_blocks; 40 | } 41 | 42 | } // namespace Shader::IR 43 | -------------------------------------------------------------------------------- /src/shader_recompiler/ir/post_order.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "shader_recompiler/ir/abstract_syntax_list.h" 7 | #include "shader_recompiler/ir/basic_block.h" 8 | 9 | namespace Shader::IR { 10 | 11 | BlockList PostOrder(const AbstractSyntaxNode& root); 12 | 13 | } // namespace Shader::IR 14 | -------------------------------------------------------------------------------- /src/shader_recompiler/ir/program.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "shader_recompiler/ir/basic_block.h" 10 | #include "shader_recompiler/ir/program.h" 11 | #include "shader_recompiler/ir/value.h" 12 | 13 | namespace Shader::IR { 14 | 15 | std::string DumpProgram(const Program& program) { 16 | size_t index{0}; 17 | std::map inst_to_index; 18 | std::map block_to_index; 19 | 20 | for (const IR::Block* const block : program.blocks) { 21 | block_to_index.emplace(block, index); 22 | ++index; 23 | } 24 | std::string ret; 25 | for (const auto& block : program.blocks) { 26 | ret += IR::DumpBlock(*block, block_to_index, inst_to_index, index) + '\n'; 27 | } 28 | return ret; 29 | } 30 | 31 | } // namespace Shader::IR 32 | -------------------------------------------------------------------------------- /src/shader_recompiler/ir/program.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "shader_recompiler/frontend/instruction.h" 8 | #include "shader_recompiler/info.h" 9 | #include "shader_recompiler/ir/abstract_syntax_list.h" 10 | #include "shader_recompiler/ir/basic_block.h" 11 | 12 | namespace Shader::IR { 13 | 14 | struct Program { 15 | explicit Program(Info& info_) : info{info_} {} 16 | 17 | AbstractSyntaxList syntax_list; 18 | BlockList blocks; 19 | BlockList post_order_blocks; 20 | std::vector ins_list; 21 | Info& info; 22 | }; 23 | 24 | [[nodiscard]] std::string DumpProgram(const Program& program); 25 | 26 | } // namespace Shader::IR 27 | -------------------------------------------------------------------------------- /src/shader_recompiler/ir/type.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include 5 | #include 6 | #include "shader_recompiler/ir/type.h" 7 | 8 | namespace Shader::IR { 9 | 10 | std::string NameOf(Type type) { 11 | static constexpr std::array names{ 12 | "Opaque", "ScalarReg", "VectorReg", "Attribute", "Patch", "U1", "U8", 13 | "U16", "U32", "U64", "F16", "F32", "F64", "U32x2", 14 | "U32x3", "U32x4", "F16x2", "F16x3", "F16x4", "F32x2", "F32x3", 15 | "F32x4", "F64x2", "F64x3", "F64x4", "StringLiteral"}; 16 | const size_t bits{static_cast(type)}; 17 | if (bits == 0) { 18 | return "Void"; 19 | } 20 | std::string result; 21 | for (size_t i = 0; i < names.size(); i++) { 22 | if ((bits & (size_t{1} << i)) != 0) { 23 | if (!result.empty()) { 24 | result += '|'; 25 | } 26 | result += names[i]; 27 | } 28 | } 29 | return result; 30 | } 31 | 32 | bool AreTypesCompatible(Type lhs, Type rhs) noexcept { 33 | return lhs == rhs || lhs == Type::Opaque || rhs == Type::Opaque; 34 | } 35 | 36 | } // namespace Shader::IR 37 | -------------------------------------------------------------------------------- /src/shader_recompiler/ir/type.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include "common/enum.h" 9 | 10 | namespace Shader::IR { 11 | 12 | enum class Type { 13 | Void = 0, 14 | Opaque = 1 << 0, 15 | ScalarReg = 1 << 1, 16 | VectorReg = 1 << 2, 17 | Attribute = 1 << 3, 18 | Patch = 1 << 4, 19 | U1 = 1 << 5, 20 | U8 = 1 << 6, 21 | U16 = 1 << 7, 22 | U32 = 1 << 8, 23 | U64 = 1 << 9, 24 | F16 = 1 << 10, 25 | F32 = 1 << 11, 26 | F64 = 1 << 12, 27 | U32x2 = 1 << 13, 28 | U32x3 = 1 << 14, 29 | U32x4 = 1 << 15, 30 | F16x2 = 1 << 16, 31 | F16x3 = 1 << 17, 32 | F16x4 = 1 << 18, 33 | F32x2 = 1 << 19, 34 | F32x3 = 1 << 20, 35 | F32x4 = 1 << 21, 36 | F64x2 = 1 << 22, 37 | F64x3 = 1 << 23, 38 | F64x4 = 1 << 24, 39 | StringLiteral = 1 << 25, 40 | }; 41 | DECLARE_ENUM_FLAG_OPERATORS(Type) 42 | 43 | [[nodiscard]] std::string NameOf(Type type); 44 | 45 | [[nodiscard]] bool AreTypesCompatible(Type lhs, Type rhs) noexcept; 46 | 47 | } // namespace Shader::IR 48 | 49 | template <> 50 | struct fmt::formatter { 51 | constexpr auto parse(format_parse_context& ctx) { 52 | return ctx.begin(); 53 | } 54 | auto format(Shader::IR::Type type, format_context& ctx) const { 55 | return fmt::format_to(ctx.out(), "{}", Shader::IR::NameOf(type)); 56 | } 57 | }; 58 | -------------------------------------------------------------------------------- /src/shader_recompiler/params.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "common/types.h" 8 | 9 | namespace Shader { 10 | 11 | /** 12 | * Compilation parameters used to identify and locate a guest shader program. 13 | */ 14 | struct ShaderParams { 15 | static constexpr u32 NumShaderUserData = 16; 16 | 17 | std::span user_data; 18 | std::span code; 19 | u64 hash; 20 | 21 | VAddr Base() const noexcept { 22 | return reinterpret_cast(code.data()); 23 | } 24 | }; 25 | 26 | } // namespace Shader 27 | -------------------------------------------------------------------------------- /src/shader_recompiler/profile.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/types.h" 7 | 8 | namespace Shader { 9 | 10 | struct Profile { 11 | u32 supported_spirv{0x00010000}; 12 | u32 subgroup_size{}; 13 | bool unified_descriptor_binding{}; 14 | bool support_descriptor_aliasing{}; 15 | bool support_int8{}; 16 | bool support_int16{}; 17 | bool support_int64{}; 18 | bool support_vertex_instance_id{}; 19 | bool support_float_controls{}; 20 | bool support_separate_denorm_behavior{}; 21 | bool support_separate_rounding_mode{}; 22 | bool support_fp32_denorm_preserve{}; 23 | bool support_fp32_denorm_flush{}; 24 | bool support_fp32_round_to_zero{}; 25 | bool support_explicit_workgroup_layout{}; 26 | bool support_legacy_vertex_attributes{}; 27 | bool supports_image_load_store_lod{}; 28 | bool supports_native_cube_calc{}; 29 | bool supports_robust_buffer_access{}; 30 | bool has_broken_spirv_clamp{}; 31 | bool lower_left_origin_mode{}; 32 | bool needs_manual_interpolation{}; 33 | bool needs_lds_barriers{}; 34 | u64 min_ssbo_alignment{}; 35 | u64 max_ubo_size{}; 36 | u32 max_viewport_width{}; 37 | u32 max_viewport_height{}; 38 | u32 max_shared_memory_size{}; 39 | }; 40 | 41 | } // namespace Shader 42 | -------------------------------------------------------------------------------- /src/shader_recompiler/recompiler.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "common/object_pool.h" 7 | #include "shader_recompiler/ir/basic_block.h" 8 | #include "shader_recompiler/ir/program.h" 9 | 10 | namespace Shader { 11 | 12 | struct Profile; 13 | struct RuntimeInfo; 14 | 15 | struct Pools { 16 | static constexpr u32 InstPoolSize = 8192; 17 | static constexpr u32 BlockPoolSize = 32; 18 | 19 | Common::ObjectPool inst_pool; 20 | Common::ObjectPool block_pool; 21 | 22 | explicit Pools() : inst_pool{InstPoolSize}, block_pool{BlockPoolSize} {} 23 | 24 | void ReleaseContents() { 25 | inst_pool.ReleaseContents(); 26 | block_pool.ReleaseContents(); 27 | } 28 | }; 29 | 30 | [[nodiscard]] IR::Program TranslateProgram(std::span code, Pools& pools, Info& info, 31 | RuntimeInfo& runtime_info, const Profile& profile); 32 | 33 | } // namespace Shader 34 | -------------------------------------------------------------------------------- /src/shadps4.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/shadps4.ico 4 | images/about_icon.png 5 | images/dump_icon.png 6 | images/play_icon.png 7 | images/pause_icon.png 8 | images/stop_icon.png 9 | images/utils_icon.png 10 | images/file_icon.png 11 | images/folder_icon.png 12 | images/themes_icon.png 13 | images/iconsize_icon.png 14 | images/list_icon.png 15 | images/grid_icon.png 16 | images/exit_icon.png 17 | images/settings_icon.png 18 | images/controller_icon.png 19 | images/refresh_icon.png 20 | images/update_icon.png 21 | images/list_mode_icon.png 22 | images/flag_jp.png 23 | images/flag_eu.png 24 | images/flag_unk.png 25 | images/flag_us.png 26 | images/flag_world.png 27 | images/flag_china.png 28 | images/github.png 29 | images/discord.png 30 | images/ko-fi.png 31 | images/youtube.png 32 | images/website.png 33 | images/ps4_controller.png 34 | images/keyboard_icon.png 35 | images/KBM.png 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/shadps4.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON "images/shadps4.ico" -------------------------------------------------------------------------------- /src/video_core/host_shaders/StringShaderHeader.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2020 yuzu Emulator Project 2 | # SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | set(SOURCE_FILE ${CMAKE_ARGV3}) 5 | set(HEADER_FILE ${CMAKE_ARGV4}) 6 | set(INPUT_FILE ${CMAKE_ARGV5}) 7 | 8 | get_filename_component(CONTENTS_NAME ${SOURCE_FILE} NAME) 9 | string(REPLACE "." "_" CONTENTS_NAME ${CONTENTS_NAME}) 10 | string(TOUPPER ${CONTENTS_NAME} CONTENTS_NAME) 11 | 12 | FILE(READ ${SOURCE_FILE} line_contents) 13 | 14 | # Replace double quotes with single quotes, 15 | # as double quotes will be used to wrap the lines 16 | STRING(REGEX REPLACE "\"" "'" line_contents "${line_contents}") 17 | 18 | # CMake separates list elements with semicolons, but semicolons 19 | # are used extensively in the shader code. 20 | # Replace with a temporary marker, to be reverted later. 21 | STRING(REGEX REPLACE ";" "{{SEMICOLON}}" line_contents "${line_contents}") 22 | 23 | # Make every line an individual element in the CMake list. 24 | STRING(REGEX REPLACE "\n" ";" line_contents "${line_contents}") 25 | 26 | # Build the shader string, wrapping each line in double quotes. 27 | foreach(line IN LISTS line_contents) 28 | string(CONCAT CONTENTS "${CONTENTS}" \"${line}\\n\"\n) 29 | endforeach() 30 | 31 | # Revert the original semicolons in the source. 32 | STRING(REGEX REPLACE "{{SEMICOLON}}" ";" CONTENTS "${CONTENTS}") 33 | 34 | get_filename_component(OUTPUT_DIR ${HEADER_FILE} DIRECTORY) 35 | make_directory(${OUTPUT_DIR}) 36 | configure_file(${INPUT_FILE} ${HEADER_FILE} @ONLY) 37 | -------------------------------------------------------------------------------- /src/video_core/host_shaders/fs_tri.vert: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #version 450 5 | 6 | layout(location = 0) out vec2 uv; 7 | 8 | void main() { 9 | vec2 pos = vec2( 10 | float((gl_VertexIndex & 1u) << 2u), 11 | float((gl_VertexIndex & 2u) << 1u) 12 | ); 13 | gl_Position = vec4(pos - vec2(1.0, 1.0), 0.0, 1.0); 14 | uv = pos * 0.5; 15 | } 16 | -------------------------------------------------------------------------------- /src/video_core/host_shaders/post_process.frag: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #version 450 5 | 6 | layout (location = 0) in vec2 uv; 7 | layout (location = 0) out vec4 color; 8 | 9 | layout (binding = 0) uniform sampler2D texSampler; 10 | 11 | layout(push_constant) uniform settings { 12 | float gamma; 13 | bool hdr; 14 | } pp; 15 | 16 | const float cutoff = 0.0031308, a = 1.055, b = 0.055, d = 12.92; 17 | vec3 gamma(vec3 rgb) { 18 | return mix( 19 | a * pow(rgb, vec3(1.0 / (2.4 + 1.0 - pp.gamma))) - b, 20 | d * rgb / pp.gamma, 21 | lessThan(rgb, vec3(cutoff)) 22 | ); 23 | } 24 | 25 | void main() { 26 | vec4 color_linear = texture(texSampler, uv); 27 | if (pp.hdr) { 28 | color = color_linear; 29 | } else { 30 | color = vec4(gamma(color_linear.rgb), color_linear.a); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/video_core/host_shaders/source_shader.h.in: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2022 Citra Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace HostShaders { 9 | 10 | constexpr std::string_view @CONTENTS_NAME@ = { 11 | @CONTENTS@ 12 | }; 13 | 14 | } // namespace HostShaders 15 | -------------------------------------------------------------------------------- /src/video_core/page_manager.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #ifdef __linux__ 9 | #include "common/adaptive_mutex.h" 10 | #endif 11 | #include "common/spin_lock.h" 12 | #include "common/types.h" 13 | 14 | namespace Vulkan { 15 | class Rasterizer; 16 | } 17 | 18 | namespace VideoCore { 19 | 20 | class PageManager { 21 | public: 22 | explicit PageManager(Vulkan::Rasterizer* rasterizer); 23 | ~PageManager(); 24 | 25 | /// Register a range of mapped gpu memory. 26 | void OnGpuMap(VAddr address, size_t size); 27 | 28 | /// Unregister a range of gpu memory that was unmapped. 29 | void OnGpuUnmap(VAddr address, size_t size); 30 | 31 | /// Increase/decrease the number of surface in pages touching the specified region 32 | void UpdatePagesCachedCount(VAddr addr, u64 size, s32 delta); 33 | 34 | static VAddr GetPageAddr(VAddr addr); 35 | static VAddr GetNextPageAddr(VAddr addr); 36 | 37 | private: 38 | struct Impl; 39 | std::unique_ptr impl; 40 | Vulkan::Rasterizer* rasterizer; 41 | boost::icl::interval_map cached_pages; 42 | #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP 43 | Common::AdaptiveMutex lock; 44 | #else 45 | Common::SpinLock lock; 46 | #endif 47 | }; 48 | 49 | } // namespace VideoCore 50 | -------------------------------------------------------------------------------- /src/video_core/renderdoc.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace VideoCore { 9 | 10 | /// Loads renderdoc dynamic library module. 11 | void LoadRenderDoc(); 12 | 13 | /// Begins a capture if a renderdoc instance is attached. 14 | void StartCapture(); 15 | 16 | /// Ends current renderdoc capture. 17 | void EndCapture(); 18 | 19 | /// Triggers capturing process. 20 | void TriggerCapture(); 21 | 22 | /// Sets output directory for captures 23 | void SetOutputDir(const std::filesystem::path& path, const std::string& prefix); 24 | 25 | } // namespace VideoCore 26 | -------------------------------------------------------------------------------- /src/video_core/renderer_vulkan/vk_common.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #include "video_core/renderer_vulkan/vk_common.h" 5 | 6 | // Implement vma functions 7 | #define VMA_IMPLEMENTATION 8 | #pragma clang diagnostic push 9 | #pragma clang diagnostic ignored "-Wnullability-completeness" 10 | #include 11 | #pragma clang diagnostic pop 12 | 13 | // Store the dispatch loader here 14 | VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE 15 | -------------------------------------------------------------------------------- /src/video_core/renderer_vulkan/vk_common.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | // Include vulkan-hpp header 7 | #define VK_ENABLE_BETA_EXTENSIONS 8 | #define VK_NO_PROTOTYPES 9 | #define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1 10 | #define VULKAN_HPP_NO_CONSTRUCTORS 11 | #define VULKAN_HPP_NO_STRUCT_SETTERS 12 | #define VULKAN_HPP_HAS_SPACESHIP_OPERATOR 13 | #define VULKAN_HPP_NO_EXCEPTIONS 14 | // Define assert-on-result to nothing to instead return the result for our handling. 15 | #define VULKAN_HPP_ASSERT_ON_RESULT 16 | 17 | #pragma clang diagnostic push 18 | #pragma clang diagnostic ignored "-Wunused-value" 19 | #include 20 | #pragma clang diagnostic pop 21 | 22 | #define VMA_STATIC_VULKAN_FUNCTIONS 0 23 | #define VMA_DYNAMIC_VULKAN_FUNCTIONS 1 24 | -------------------------------------------------------------------------------- /src/video_core/renderer_vulkan/vk_shader_hle.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "video_core/amdgpu/liverpool.h" 7 | 8 | namespace Shader { 9 | struct Info; 10 | } 11 | 12 | namespace Vulkan { 13 | 14 | class Rasterizer; 15 | 16 | /// Attempts to execute a shader using HLE if possible. 17 | bool ExecuteShaderHLE(const Shader::Info& info, const AmdGpu::Liverpool::Regs& regs, 18 | const AmdGpu::Liverpool::ComputeProgram& cs_program, Rasterizer& rasterizer); 19 | 20 | } // namespace Vulkan 21 | -------------------------------------------------------------------------------- /src/video_core/renderer_vulkan/vk_shader_util.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include "common/types.h" 9 | #include "video_core/renderer_vulkan/vk_common.h" 10 | 11 | namespace Vulkan { 12 | 13 | /** 14 | * @brief Creates a vulkan shader module from GLSL by converting it to SPIR-V using glslang. 15 | * @param code The string containing GLSL code. 16 | * @param stage The pipeline stage the shader will be used in. 17 | * @param device The vulkan device handle. 18 | */ 19 | vk::ShaderModule Compile(std::string_view code, vk::ShaderStageFlagBits stage, vk::Device device); 20 | 21 | /** 22 | * @brief Creates a vulkan shader module from SPIR-V bytecode. 23 | * @param code The SPIR-V bytecode data. 24 | * @param device The vulkan device handle 25 | */ 26 | vk::ShaderModule CompileSPV(std::span code, vk::Device device); 27 | 28 | } // namespace Vulkan 29 | -------------------------------------------------------------------------------- /src/video_core/texture_cache/sampler.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project 2 | // SPDX-License-Identifier: GPL-2.0-or-later 3 | 4 | #pragma once 5 | 6 | #include "video_core/amdgpu/resource.h" 7 | #include "video_core/renderer_vulkan/vk_common.h" 8 | 9 | namespace Vulkan { 10 | class Instance; 11 | } 12 | 13 | namespace VideoCore { 14 | 15 | class Sampler { 16 | public: 17 | explicit Sampler(const Vulkan::Instance& instance, const AmdGpu::Sampler& sampler); 18 | ~Sampler(); 19 | 20 | Sampler(const Sampler&) = delete; 21 | Sampler& operator=(const Sampler&) = delete; 22 | 23 | Sampler(Sampler&&) = default; 24 | Sampler& operator=(Sampler&&) = default; 25 | 26 | vk::Sampler Handle() const noexcept { 27 | return *handle; 28 | } 29 | 30 | private: 31 | vk::UniqueSampler handle; 32 | }; 33 | 34 | } // namespace VideoCore 35 | --------------------------------------------------------------------------------