Compare commits

...

413 Commits

Author SHA1 Message Date
psucien 4182740384 Don't load `sync2` ext if `nv_checkpoints` isn't used 2024-08-31 00:10:47 +02:00
psucien ca1613258f
video_core: added support for indirect draws (#678)
* video_core: added support for indirect draws

* barriers simplified
2024-08-30 22:59:56 +02:00
georgemoralis 3d375a28eb
Merge pull request #671 from Xphalnos/main
Reorganization of includes (Part 2)
2024-08-30 22:10:49 +03:00
jnack 69d4fecdfe
Allow graphics/compute shader list for skipping (#674)
* Allow graphics/compute shader list for skipping

* nintendo ultra 64 + formatting

* indentation..

* allow empty array in ShouldSkipShader

* simpler check for skip hashes
2024-08-30 21:51:20 +03:00
Xphalnos 7886761476 Reorganization of includes (Part 2) 2024-08-30 15:48:21 +02:00
squidbus 6080066f75
vulkan: Few fixes for MoltenVK (#670)
* vulkan: Use SPIR-V 1.5 when Vulkan version is 1.2

* vulkan: Fix Format2_10_10_10 mismap
2024-08-30 16:40:39 +03:00
georgemoralis f1fe6b9f96
Merge pull request #668 from squidbus/fix-patch-stack
Initialize patch stack before thread TLS.
2024-08-30 14:58:34 +03:00
squidbus 6e552aac6a Initialize patch stack before thread TLS. 2024-08-30 04:43:11 -07:00
adjonesey 0f87d1e3d4 Remove from_compute check in texture cache invalidation (#665)
* Remove from_compute check in texture cache invalidation (hack)

* Remove from_compute parameter

---------

Co-authored-by: Adam Jones <a.c.jones@outlook.com>
2024-08-30 13:01:59 +03:00
georgemoralis 68fa5e292f
Merge pull request #666 from bigol83/patch-3
Update Italian translation
2024-08-30 12:39:30 +03:00
bigol83 bdfff5e8ea
Update it.ts 2024-08-30 11:01:48 +02:00
georgemoralis cdd193d5b1
Merge pull request #638 from squidbus/f16c
Add patches for F16C instructions under Rosetta 2.
2024-08-30 11:16:21 +03:00
georgemoralis 30ab2b7f71
Merge pull request #658 from DanielSvoboda/main
fix tr
2024-08-30 11:15:09 +03:00
DanielSvoboda f2b6843f9d fix tr 2024-08-29 23:11:20 -03:00
squidbus a17150960f Add patches for F16C instructions under Rosetta 2. 2024-08-29 17:31:25 -07:00
Grégoire Hage 1651db24fe
Implement S_XNOR_B64 (#654) 2024-08-30 02:43:12 +03:00
IndecisiveTurtle 6bf42aa985 vk_graphics_pipeline: Fix texel buffer offset 2024-08-30 01:09:39 +03:00
georgemoralis 8d41695e74
Merge pull request #651 from LeDragoX/pt-br-update-1
Update PT-BR localization
2024-08-30 01:08:07 +03:00
IndecisiveTurtle cb5190e31a vk_graphics_pipeline: Fix copy paste error 2024-08-30 00:59:12 +03:00
IndecisiveTurtle cf706f8cc7 buffer: Don't leak texel buffers, blacklist stream buffer with texel buffers 2024-08-30 00:26:08 +03:00
IndecisiveTurtle 6fbbe3d79b translator: Add missed flow instruction 2024-08-30 00:26:01 +03:00
IndecisiveTurtle fab390b860 spirv: More correct texel buffer usage 2024-08-30 00:25:56 +03:00
Plínio Larrubia 5a96ac1a4f
Update PT-BR translation
- Support DLC texts
- Fixed some errors on Cheats (Trapaças) translation
2024-08-29 18:22:36 -03:00
georgemoralis ac2fa103fa
Merge pull request #649 from f1amy/ru-translation-fixes
ru DLC translation and translation fixes
2024-08-29 23:47:47 +03:00
georgemoralis 7e7854346d
Merge pull request #650 from DanielSvoboda/main
Fix creation files.json in 'Download All Patches'
2024-08-29 23:47:25 +03:00
DanielSvoboda 751f6f9bab Fix creation files.json in 'Download ALL' 2024-08-29 17:26:06 -03:00
Flamy 1c835a1aa4
ru DLC translation and translation fixes 2024-08-29 23:59:52 +05:00
georgemoralis 07c8c28000
Merge pull request #647 from DanielSvoboda/main
fix tr cheats_patches.cpp
2024-08-29 19:44:04 +03:00
TheTurtle 66e96dd944
video_core: Account of runtime state changes when compiling shaders (#575)
* video_core: Compile shader permutations

* spirv: Only specific storage image format for atomics

* ir: Avoid cube coord patching for storage image

* spirv: Fix default attributes

* data_share: Add more instructions

* video_core: Query storage flag with runtime state

* kernel: Use std::list for semaphore

* video_core: Use texture buffers for untyped format load/store

* buffer_cache: Limit view usage

* vk_pipeline_cache: Fix invalid iterator

* image_view: Reduce log spam when alpha=1 in storage swizzle

* video_core: More features and proper spirv feature detection

* video_core: Attempt no2 for specialization

* spirv: Remove conflict

* vk_shader_cache: Small cleanup
2024-08-29 19:29:54 +03:00
DanielSvoboda aef7498c49
fix tr cheats_patches.cpp
the 2 words were not being translated
2024-08-29 13:21:58 -03:00
georgemoralis 790d19e59b
Merge pull request #646 from kiwidoggie/patch-1
Add /hostapp support
2024-08-29 17:03:35 +03:00
georgemoralis 3ae18c9073
Merge pull request #645 from mavethee/dlc-polish-localization
DLCs - Polish localization
2024-08-29 17:02:55 +03:00
georgemoralis 83e343f77e
Merge pull request #637 from shadps4-emu/amdgpu/indirect_dispatch
video_core: added support for indirect dispatches (gfx only)
2024-08-29 17:02:37 +03:00
kiwipuppeh 81eb3a4d14
Add /hostapp support
In the case of certain games, such as Battlefield 4 (CUSA00110), the local pathing will resolve to /hostapp instead of /app0, which works fine on PS4, but was failing to resolve to any meaningful mount in shadPS4, this corrects this issue when running from eboot.bin directly.
2024-08-29 08:22:19 -04:00
Marcin Mitura 37786e06c2 DLCs - Polish localization
Translates strings introduced in #596.
2024-08-29 13:27:11 +02:00
psucien 9d349a1308 video_core: added support for indirect dispatches (gfx only) 2024-08-29 12:32:37 +02:00
bigol83 c997490645
DLC Italian translation (#644) 2024-08-29 13:31:48 +03:00
bigol83 600c5079ce
Cheats/patches Italian translation (#642)
* Update it.ts

* Update it.ts
2024-08-29 13:11:17 +03:00
Dzmitry Dubrova 8827c72a1c
Add DLC support (#596)
* fs/core: Add DLC support

* fs/core: Fix extraction paths

* Fix DLC mounting

* gui: Add translations
2024-08-29 12:55:40 +03:00
¥IGA e1382b43c8
Update French translation (#641) 2024-08-29 10:02:36 +03:00
DanielSvoboda 614a23b369
Cheats/Patches (#493)
* Cheats/Patches

Adds the possibility of applying cheats/patches according to the specific game serial+version

The logic for adding modifications has not yet been implemented!

Interface based on issues/372 https://github.com/shadps4-emu/shadPS4/issues/372

[X]Front-end
[]Back-end

Create a synchronized fork of the cheats/patches repository

* Clang Format

* separate files

The code has been separated into separate files as suggested by georgemoralis.
Added the Patch tab, which has not been implemented yet.
Added the 'applyCheat' area to apply the modification, not implemented yet...
And added LOG_INFO.

* reuse

* initial implementation of cheat functionality

* Update cheats_patches.cpp

sets all added buttons to the size of the largest button.
and fixes some aesthetic issues.

* move eboot_address to module.h

fixes the non-qt builds and makes more sense to be there anyway

* Patchs menu and fixes

adds the possibility to download Patches, it does not modify the memory yet.
and some other fixes

* MemoryPatcher namespace, activate cheats on start

* format

* initial patch implementation

* format

* format again...

* convertValueToHex

* Fixes

Choosing which cheat file to use.
And some other fixes

* fix bytes16, bytes32, bytes64 type patches

If a patch is any of these types we convert it from little endian to big endian

* format

* format again :(

* Implement pattern scanning for mask type patches

* add check to stop patches applying to wrong game

previously if you added a patch to a game, but closed the window and opened a different game it would still try to apply the patch, this is now fixed

* format

* Fix 'Hint' 0x400000 |  and Author

* Management |save checkbox | shadps4 repository

MENU - Cheats/Patches Management (implementing Patches)
save patches checkbox
add shadps4 repository

* Load saved patches, miscellaneous fixes

* Fix an issue with mask patches not being saved

* format + remove debug log

* multiple patches | TR translation for cheats/patches

* clang

* ENABLE_QT_GUI

* OK

* move memory_patcher to qt_gui

* clang

* add cheats hu_HU

* fix log

* Remove the item from the patchesListView if no patches were added (the game has patches, but not for the current version)

---------

Co-authored-by: CrazyBloo <CrazyBloo@users.noreply.github.com>
2024-08-29 07:18:50 +03:00
georgemoralis a6a9fff666
Merge pull request #636 from CyntexMore/main
Added HU translation
2024-08-29 00:08:51 +03:00
psucien 3fbb68048e
shader_recompiler: frontend: `SOPC` and `SOPK` handling separated; more cmp opcodes (#634) 2024-08-28 22:27:47 +02:00
CyntexMore 55be97bca3 feat(translation): hu_HU translated 2024-08-28 22:15:03 +02:00
georgemoralis d2e4a200fb
Merge pull request #631 from Emulator-Team-2/Fix
Misc fixes
2024-08-28 22:26:50 +03:00
georgemoralis a291800418
Merge pull request #632 from bigol83/patch-2
Update Italian translation
2024-08-28 21:13:47 +03:00
bigol83 365e17f64e
Update it.ts 2024-08-28 19:14:33 +02:00
Emulator-Team-2 af18728962
clang-format fix 2024-08-28 18:45:32 +02:00
Emulator-Team-2 6f938a10ce
added data_format=3 and num_format=4 2024-08-28 18:12:59 +02:00
Emulator-Team-2 08036d2b49
added data_format=36 and num_format=9 2024-08-28 18:10:23 +02:00
georgemoralis e57d55e6e9
Merge pull request #624 from Exhigh/savedata-fix-4
savedata: Add another missed case in saveDataMount
2024-08-28 18:07:50 +03:00
georgemoralis 163019e3dc
Merge pull request #629 from counter185/gamepad-tp-and-reconnect
Auto reconnect controllers + touchpad functionality
2024-08-28 18:03:13 +03:00
counter185 bc661039c5 get rid of one space 2024-08-28 14:25:07 +02:00
counter185 2e2f3bb2c6 clang format 2024-08-28 14:22:59 +02:00
counter185 89bdd3bba2 it's actually 1920x941 2024-08-28 14:15:01 +02:00
counter185 15fc267f0d Update controller.h 2024-08-28 13:58:37 +02:00
counter185 0b24ac6991 actually get rid of that comment 2024-08-28 13:56:49 +02:00
counter185 698dade864 * 2024-08-28 13:53:07 +02:00
counter185 4e6e90dfb9 add touchpad support, auto reconnect 2024-08-28 13:48:50 +02:00
georgemoralis be49871c68
Merge pull request #618 from vertver/main
video_core: Added copyGPUCmdBuffers option
2024-08-28 14:00:26 +03:00
squidbus 905d49fd96
memory: Fixes for direct memory allocation. (#615)
* memory: Size direct memory based on requested flexible memory.

* memory: Guard against OrbisProcParam without an OrbisKernelMemParam.

* memory: Account for alignment in direct memory suitability checks and add more debugging.
2024-08-28 13:42:53 +03:00
georgemoralis dcc4762c7e
Merge pull request #628 from squidbus/pkg-fix
crypto: Fix deallocation of key data while in use.
2024-08-28 13:42:01 +03:00
squidbus 4a6ce1e0d6 crypto: Fix deallocation of key data while in use. 2024-08-28 03:39:51 -07:00
georgemoralis 878fac7f94
Merge pull request #626 from InvoxiPlayGames/special-pad
pad: add support for configurable special pad class
2024-08-28 13:24:37 +03:00
squidbus da966bedfd
kernel: Reimplement POSIX semaphores using std::counting_semaphore. (#600) 2024-08-28 13:13:33 +03:00
Vinicius Rangel 8192eaa668
video_core: re-enable culling (#551) 2024-08-28 13:11:55 +03:00
0xsegf4ult 9f4e55a8e7
shader_recompiler: constant propagation bitwise operations + S_CMPK_EQ_U32 fix (#613)
* rebase on main branch impl of V_LSHL_B64

* remove V_LSHR_B64

* fix S_CMPK_EQ_u32

* fix conflicts

* fix broken merge

* remove duplicate cases

* remove duplicate declaration
2024-08-28 13:10:21 +03:00
InvoxiPlayGames 9d59ea06c7 clang-format fix: scePadOpenExt 2024-08-28 11:10:20 +01:00
tGecko 990da7edcc
DOCS: Correct and expand windows build instructions (#617)
* correct and expand windows build instructions

* fix numbering

* remove instructions to clone a different branch
2024-08-28 13:10:04 +03:00
InvoxiPlayGames 550cf0188d return proper error code for scePadOpen failure 2024-08-28 10:51:30 +01:00
InvoxiPlayGames 79e86a39fc add support for configurable special pad type 2024-08-28 10:27:51 +01:00
Anton Kovalev dfb30ea955 Use pair of spans instead of references in copy command buffers function 2024-08-28 11:24:15 +02:00
Random c37679154e
Handle PM4 type-2 packets (#556)
* video_core: handle PM4 type-2 packets

* video_core: rewrite pm4 comand type handling into a switch statement
2024-08-28 09:53:27 +02:00
Anton Kovalev 87ccfdfbbd Fixed type on function 2024-08-28 09:42:31 +02:00
Exhigh ed42db47af savedata: Add another missed case in saveDataMount
This should potentially fix Deadpool (CUSA03528) #554.
2024-08-28 08:52:20 +04:00
Anton Kovalev 1a02efbd15 clang-format style fix 2024-08-28 05:42:48 +02:00
georgemoralis e4254ebdaa
Merge pull request #605 from SolidStateDj/add-toggle-fullscreen
Add a toggle fullscreen button
2024-08-28 06:32:21 +03:00
georgemoralis e65bf19118
Merge pull request #620 from GermanAizek/fixes
crypto: added destructors and fixed direct memleaks
2024-08-28 06:31:07 +03:00
Semenov Herman 860b935054 crypto: added destructors fix memleak FakeKeyset, DebugRifKeyset, PkgDerivedKey3Keyset 2024-08-28 01:32:14 +03:00
Anton Kovalev 3842993a43 Use input dcb and ccb instead of copy 2024-08-28 00:21:12 +02:00
Anton Kovalev 3d46a5d492 Do not shrink buffer's size on submit 2024-08-27 23:33:24 +02:00
Anton Kovalev 595b845df0 clang-format fix 2024-08-27 23:31:04 +02:00
Anton Kovalev 659e7a4675 video_core: Added copyGPUCmdBuffers option 2024-08-27 23:16:14 +02:00
psucien 3eb47226d9 libraries: kernel: fix `scePthreadMutexattrSettype` error value return 2024-08-27 22:25:46 +02:00
psucien 371d1d009a Added missing headers and 2D MSAA image type 2024-08-27 19:17:23 +02:00
Lizardy 59b651be07
[Libs] Error Codes (#612)
* ngs2: all errors w/ official names

* ajm errors

* gnm errors

* random errors

* clang

* random error

* linux

---------

Co-authored-by: microsoftv <6063922+microsoftv@users.noreply.github.com>
2024-08-27 15:53:38 +03:00
Grégoire Hage 288db9a0cf
Implement V_LSHL_B64 (#608) 2024-08-27 14:15:32 +03:00
georgemoralis 62f165a7e4
Merge pull request #610 from vladmikhalin/avplayer-handle-init-errors
AvPlayer: Handle Initialization errors
2024-08-27 09:59:19 +03:00
Vladislav Mikhalin 2d354a095a AvPlayer: Handle Initialization errors 2024-08-27 09:32:42 +03:00
SolidStateDj 7ecc1d3be0 Add a toggle fullscreen button
Assigns F11 as the key for toggling fullscreen.
2024-08-26 18:27:31 -04:00
psucien af4356bfe1 shader_recompiler: fix for pattern detection in `TryDisableAnisoLod0`
Also fix for forgotten log message params.
2024-08-26 23:49:36 +02:00
psucien 3e94b533b6
libraries: kernel: skip for protection op; processing logic fixes (#602) 2024-08-26 23:14:22 +02:00
georgemoralis 287c3a4ab1
Merge pull request #599 from Exhigh/savedata-fix-3
savedata: Handle another missed case in saveDataMount
2024-08-27 00:02:41 +03:00
Exhigh 7c7d04133e savedata: Handle another missed case in saveDataMount
This should potentially fix (CUSA01019) - The Walking Dead: The Complete First Season.
2024-08-26 19:34:35 +04:00
Plínio Larrubia ad8373095a
fix typo in LOG_INFO (#559)
fix: file name typo constant_propogation_pass.cpp

fix typo from 'symbol_vitrual_addr' variable

fix typo in emit_spirv_context_get_set.cpp

fix typo from constant_propagation_pass.cpp in CMakeLists

fix typo in these some config.cpp functions
- setSliderPosition
- setSliderPositionGrid
- getSliderPosition
- getSliderPositionGrid

fix typo inside src\core\aerolib\stubs.cpp

fix typo in a comment from src\core\file_format\pkg.cpp

fix typo inside src\core\file_sys\fs.cpp + fs.h
- NeedsCaseInsensiveSearch -> NeedsCaseInsensitiveSearch

fix 2 function typos: sceAppContentAddcontEnqueueDownloadByEntitlemetId and sceAppContentAddcontMountByEntitlemetId

fix typo on comment inside src\core\libraries\kernel\file_system.cpp

fix typo on src\core\libraries\videoout\driver.cpp

fix typo in src\core\memory.cpp

fix typo from comment in src\qt_gui\game_list_utils.h

fix typo in src\video_core\amdgpu\liverpool.h
- window_offset_disble to window_offset_disable

fix typo from comments in src\video_core\host_shaders\detile_m32x1.comp + detile_m32x2.comp
- subotimal -> suboptimal

fix typo from comment in src\video_core\renderer_vulkan\renderer_vulkan.cpp
- dimentions -> dimensions

fix typo from enum in src\common\debug.h and other files
- MarkersPallete -> MarkersPalette

fix last typo in src\video_core\amdgpu\pm4_opcodes.h
- PremableCntl -> PreambleCntl
2024-08-26 15:22:11 +03:00
Lizardy aae6e5be73
shader_recompiler: BUFFER_ATOMIC_SWAP Opcode (#566)
* shader_recompiler: BUFFER_ATOMIC_SWAP Opcode

* clang

* follow 32 convention

---------

Co-authored-by: microsoftv <6063922+microsoftv@users.noreply.github.com>
2024-08-26 15:21:20 +03:00
Batu cd6b5abccf
added tr language support (#587) 2024-08-26 13:20:53 +03:00
Plínio Larrubia 6520f3ca17
feat: add pt_BR translation (#584)
* feat: add pt_BR translation
- Made by @LeDragoX
- Revised by @gabsF

* fix: change translation string 'Mostrar Tela Inicial' to 'Mostrar Splash Inicial'
2024-08-26 13:20:40 +03:00
Cristóbal Martí Méndez d3b6b17c75
Add spanish translation (#583)
* Add spanish transalation

* Update es_ES.ts
2024-08-26 13:20:26 +03:00
Marcin Mitura 0b5616c493
Polish localization (#580)
Initial polish localization for shadPS4
2024-08-26 13:20:12 +03:00
georgemoralis 3627393707
Merge pull request #593 from shadps4-emu/fix/better_timings
libraries: kernel: fix for inaccurate `sceKernelGetProcessTime`
2024-08-26 10:56:54 +03:00
nishinji 6e340bcdc1
Fix ja_JP.ts (#594)
* Fix ja_JP.ts

* a
2024-08-26 10:56:11 +03:00
psucien 78e24852f8 libraries: kernel: fix for inaccurate `sceKernelGetProcessTime` 2024-08-26 08:54:38 +02:00
georgemoralis 7f6d08a3c8
Merge pull request #589 from greggameplayer/feature/TBUFFER_STORE_FORMAT_XY
Implement missing TBUFFER_STORE_FORMAT_XY
2024-08-26 09:40:40 +03:00
nishinji 7aa8cf992f
Add Japanese translation (#591) 2024-08-26 09:39:49 +03:00
¥IGA e16aa2a012
Update French tranlations (#592) 2024-08-26 09:39:24 +03:00
greggameplayer 86870e7c8d Implement TBUFFER_STORE_FORMAT_XY 2024-08-26 03:39:38 +02:00
Daniel R. fae0c0ae85
core/kernel: Miscellaneous memory fixes (#557)
* core/libraries/kernel: Fix inaccurate direct memory size

* core/memory: Fix available dmem query on non-free dmem areas

* core/kernel: return ENOMEM if memory area size is zero

* core/kernel: Fix returns on `sceKernelAvailableDirectMemorySize`

* core/memory: Remove unneeded size alignment
2024-08-26 04:14:21 +03:00
Yury 5d7407dc7d
Add ru translation (#579) 2024-08-26 03:22:30 +03:00
bigol83 bcc3a10557
Add Italian translation (#585)
* Update it.ts

* Update it.ts
2024-08-26 03:22:07 +03:00
psucien 6fd4264b5d video_core: vk_rasterizer: fix for crash on markers with nullGpu 2024-08-25 22:24:10 +02:00
DanielSvoboda 2a737d0800
V_NOP | PfpSyncMe | S_CMPK_EQ_U32 (#426)
* V_NOP

V_NOP = Do nothing

* PfpSyncMe

PfpSyncMe ensures that all previous commands are completed before continuing.
'break' should be enough for now

* S_CMPK_EQ_U32

S_CMPK_EQ_U32
SCC = (D.u == SIMM16)

* S_CMPK_EQ_U32

* OperandField::Undefined:

* Update translate.cpp

remove  OperandField::Undefined:

* Update image_view.cpp

[Render.Vulkan] <Error> image_view.cpp:ImageViewInfo:109: Storage image (num_comps = 4) requires swizzling [BGRA]
format 43 dst_sel 3886

* Update liverpool_to_vk.cpp

* S_CMPK_EQ_U32

* S_CMPK_EQ_U32
2024-08-25 22:07:46 +02:00
psucien b687ae5e34
GnmDriver: Clear context support (#567)
* gnmdriver: added support for gpu context reset

* shader_recompiler: minor validation fixes

* shader_recompiler: added `V_CMPX_GT_I32`

* shader_recompiler: fix for crash on inline sampler access

* compilation warnings and dead code elimination

* amdgpu: fix for registers addressing

* libraries: videoout: reduce logging pressure

* shader_recompiler: fix for devergence scope detection
2024-08-25 23:01:05 +03:00
georgemoralis c2ddfe51e1
Merge pull request #569 from CyntexMore/main
Added fancy formating to the README and made some texts "better"
2024-08-25 17:27:53 +03:00
georgemoralis abc7f55c06
Merge pull request #572 from dima-xd/qt_translations
gui: Implement gui translations
2024-08-25 17:24:55 +03:00
Dzmitry Dubrova 26b5661dea ci: Fix linux-qt CI 2024-08-25 16:03:25 +03:00
SaynedBread 6a87c37aeb
docs: Removed misinformation 2024-08-25 14:37:17 +02:00
SaynedBread 5664d45305
docs: Updated Status 2024-08-25 14:12:16 +02:00
Dzmitry Dubrova 21ce86003b Merge branch 'qt_translations' of https://github.com/dima-xd/shadPS4 into qt_translations 2024-08-25 13:59:51 +03:00
Dzmitry Dubrova 83b43363fa ci: Fix CI 2024-08-25 13:59:22 +03:00
¥IGA e603165e2b
Implement French translation 2024-08-25 13:31:45 +03:00
Dzmitry Dubrova 7766a653d5 ci: Add LinguistTools to CIs 2024-08-25 13:18:46 +03:00
Dzmitry Dubrova 3f445eca40 gui: Implement gui translations 2024-08-25 12:17:54 +03:00
SaynedBread 41a93dcae4
docs: Added some fancy Markdown formating to the README 2024-08-25 02:54:46 +02:00
SaynedBread 1e90f45941
docs: Added some fancy Markdown formating to the README 2024-08-25 02:53:13 +02:00
TheTurtle c79b10edc1
video_core: Bloodborne stabilization pt1 (#543)
* shader_recompiler: Writelane elimination pass + null image fix

* spirv: Implement image derivatives

* texture_cache: Reduce page bit size

* clang format

* slot_vector: Back to debug assert

* vk_graphics_pipeline: Handle null tsharp

* spirv: Revert some change

* vk_instance: Support primitive restart on list topology

* page_manager: Adjust windows exception handler

* clang format

* Remove subres tracking

* Will be done separately
2024-08-24 22:51:47 +03:00
Vinicius Rangel 9e4fc17e6c
shader_recompiler: handle fetch shader address offsets (#538)
* shader_recompiler: handle fetch shader address offsets

parse index & offset sgpr from fetch shader and propagate them to vkBindVertexBuffers

* shader_recompiler: fix fetch_shader when offset is not present

* video_core: propagate index/offset SGPRs to vkCmdDraw instead of offsetting the buffer address

* video_core: add vertex_offset to non-indexed draw calls

renamed fetch offset fields
2024-08-24 17:36:40 +02:00
georgemoralis 208575d392
Merge pull request #560 from vladmikhalin/avplayer-and-texture-cache-fixes
Fixed video dimensions alignment and image cache
2024-08-24 17:24:36 +03:00
georgemoralis 8b0fd59149
Merge pull request #558 from Exhigh/savedata-fix-2
savedata: Add another missing case to saveDataMount
2024-08-24 17:14:10 +03:00
Vladislav Mikhalin 41dec15869 Fixed video dimensions alignment and image cache 2024-08-24 16:59:30 +03:00
Exhigh 6a84f6e188 savedata: Add another missing case to saveDataMount
This helps Five Nights at Freddy's: Sister Location (CUSA17983) boot and is playable.
Fixes issue #554
2024-08-24 17:48:39 +04:00
Herman Semenov 243fd0be78
core,shader_recompiler: align structures for 64-bit platforms (#447)
Decreased sizes:
 * TextureDefinition 32 bytes -> 24 bytes
 * PortOut 72 bytes -> 64 bytes
 * Request 48 bytes -> 40 bytes
 * WindowSystemInfo 32 bytes -> 24 bytes
2024-08-24 16:18:12 +03:00
Random fc745ee767
Fix a few issues with the intel anv vulkan driver from mesa (#514)
* add fallback format for d16UnormS8Uint which is not supported by intel

* fix depth/stencil buffer creation issues causing asserts in intel driver
2024-08-24 14:50:46 +02:00
psucien 2c540fbecb
Merge pull request #497 from xezrunner/xezrunner/cfg-msb-fix
shader_recompiler: fix BranchTarget sign flip for sopp.simm
2024-08-24 11:39:10 +02:00
georgemoralis 0b3a88cf22
Merge pull request #550 from richarm4/patch-1
Fix typo in CONTRIBUTING.md comment
2024-08-24 10:06:09 +03:00
Matthew Wells 0ed4614464
Fix typo in CONTRIBUTING.md comment
"intitialize" -> "initialize"
2024-08-23 18:29:00 -07:00
georgemoralis 9852f95c58
Merge pull request #547 from GermanAizek/fix2
Fixed invalid set public exponent Crypto::DebugRifKeyset_init()
2024-08-23 22:41:15 +03:00
georgemoralis df03783948
Merge pull request #546 from abouvier/cmake-compat
cmake: fix version constraints
2024-08-23 22:40:12 +03:00
¥IGA 0c5b91e1fb
Warnings fixes (#541)
* Warnings fixes

* Warnings fixes
2024-08-23 22:38:55 +03:00
Herman Semenov a0774c0e87 Fixed invalid set public exponent Crypto::DebugRifKeyset_init() 2024-08-23 22:04:55 +03:00
Alexandre Bouvier a71d0d8dbb cmake: fix version constraints 2024-08-23 19:40:11 +02:00
georgemoralis fda2fdae69
Merge pull request #544 from Exhigh/Savedata-Fix
savedata: Handle missed case in saveDataMount
2024-08-23 20:05:52 +03:00
Exhigh 6545b09b74 savedata: Handle missed case in saveDataMount
This should help P5D get past the intro.

P.S:  The game requires Fiber and USBD modules to boot.
2024-08-23 16:27:03 +04:00
georgemoralis bce3a9c9e7
Merge pull request #530 from Xphalnos/main
Lot of small fixes
2024-08-22 21:54:20 +03:00
georgemoralis 3310fd9a1f
Merge pull request #531 from shadps4-emu/pad_fix
possible R2/L2 fix
2024-08-22 19:58:43 +03:00
georgemoralis 3e8d7c2040 possible R2/L2 fix 2024-08-22 19:43:45 +03:00
Xphalnos d4be3dbb31 Lot of small fixes 2024-08-22 18:01:30 +02:00
georgemoralis 83bcced16c
Merge pull request #502 from Borchev/ROMappedFileWorkaround
Workaround for readonly memory mapping of files issue
2024-08-22 13:49:19 +03:00
georgemoralis 746559658c
Merge pull request #525 from shadps4-emu/libc_removal
HLE libc removal
2024-08-22 11:59:56 +03:00
georgemoralis 12a65e3fb8 LLE libc removal 2024-08-22 11:24:31 +03:00
georgemoralis 834a25fa2b
Merge pull request #521 from GermanAizek/fix
Added const reference params if possible, removed less 16 size
2024-08-22 10:18:02 +03:00
Herman Semenov aed9a737d6 Added const reference params if possible, removed less 16 size 2024-08-22 02:56:01 +03:00
Aiden Turner ca4b520272
Added logging for debugging configs (#518)
* added logging for config file

* forgot a setting

* fixed bloated settings logging.

* fixed compile error
2024-08-22 01:52:08 +03:00
Vladislav Mikhalin 79680c50c0
Misc fixes (#517)
* Misc fixes

* Removed the skip for draw calls without RTs

* Remove Srgb image stores to rework later
2024-08-21 23:54:23 +03:00
georgemoralis dfd305ff77
Update Debugging.md
fixed reuse
2024-08-21 22:16:03 +03:00
Sebastian Kassai ba0a6ab038
Expand documentation on configuration and debugging (#513)
* documents: more info on config.toml

* documents: add Debugging

* documents: link to Debugging in README

* documents: link to main branch for Debugging

Once it's merged, it should link properly.
Quickstart already exists in main.

* documents: remove "troubleshooting" from Debugging

Not entirely relevant.

* documents: elaborate on a few points with stack traces

* documents: formatting, indentation fixup

* documents: remove unnecessary indent

* documents: fix some inline code blocks + misc

* documents: move the technical jargon out of Quickstart

* documents: improve configuration sections

Simplified the Quickstart config listing, added more technical info to the Debugging listing.

* documents: link quickstart config link to proper section

* documents: something ate my hash symbol

* documents: use *:Critical for log silencing example

* documents: add note about Start Without Debugging

* documents: use correct CUSA code in example
2024-08-21 22:13:06 +03:00
georgemoralis 132ca9c5a8
Merge pull request #506 from squidbus/macos-translocation
Untranslocate app bundle path if needed on macOS.
2024-08-21 18:13:08 +03:00
georgemoralis 3426ad8cc0
Merge pull request #511 from dima-xd/sample
avplayer: Fix data returned by sceAvPlayerGetAudioData
2024-08-21 16:53:01 +03:00
Dzmitry Dubrova 6d0d2eaa59 avplayer: Fix sceAvPlayerGetAudioData 2024-08-21 14:37:34 +03:00
squidbus 9275b0966e Untranslocate app bundle path if needed on macOS. 2024-08-21 03:06:10 -07:00
Borchev fc300b5265 Fix unmapping bug 2024-08-20 20:07:32 -07:00
Borchev 6596fe091c Workaround for readonly memory mapping of files issue 2024-08-20 16:10:38 -07:00
georgemoralis 958db559c6
Merge pull request #495 from jdpatdiscord/main
Allow builds on MSYS2 & improve Windows build steps documentation
2024-08-21 02:08:40 +03:00
TheTurtle 3f9c86ad33
vk_pipeline_cache: Avoid recompiling new shaders on each new PL (#480)
* cfg: Add one more divergence case

* Seen in RDR shaders

* renderer_vulkan: Reduce number of compiled shaders

* vk_pipeline_cache: Remove some unnecessary checks
2024-08-21 02:00:24 +03:00
Lizardy 32cb3649d3
rtc errors (#485)
* rtc errors

* add system libs to cmakelists

* this.[func]

* fix errors

* declaration

* log handle addr

* missed

---------

Co-authored-by: microsoftv <6063922+microsoftv@users.noreply.github.com>
2024-08-21 00:47:17 +03:00
xezrunner 42c4d8353a Fix control.sopp.simm flipping sign in CFG label generation
This used to cause a fatal crash that would prevent Amplitude [CUSA02480] from booting beyond initialization.

A conditional true label would get an address starting with 0xffff...., which wasn't realistic with the given shader.

The multiplication by 4 causes the value to have its MSB set due to the smaller type.
2024-08-20 22:48:28 +02:00
jdp_ 6080649b7c Merge branch 'main' of https://github.com/jdpatdiscord/shadPS4 2024-08-20 14:28:34 -04:00
jdp_ 34a1339a2b Allow builds on MSYS2 & improve Windows build steps documentation 2024-08-20 14:27:26 -04:00
jdp_ e070dab2f0 Allow builds on MSYS2 & improve Windows build steps documentation 2024-08-20 12:26:35 -04:00
kotn3l c60bfbe2a5
Set game window size based on the config (in windowed mode) (#481)
* Set windowed mode size based on config

* fix formatting oops

* emulator.cpp clang format fix (hopefully?)

* formatting fix for real
2024-08-20 15:39:56 +03:00
georgemoralis 95c89ca6a9
Merge pull request #375 from notgonnaleo/main
qt_gui: Added feature to toggle (show/hide) game list view
2024-08-20 11:47:00 +03:00
georgemoralis 8d90e6d997
Merge pull request #475 from bax-cz/main
PlayGo: basic implementation, credits to red-prig
2024-08-20 11:43:37 +03:00
bax-cz 0b3356bd1a linux build fix 2024-08-20 09:28:07 +02:00
bax-cz 8f7b3c2e8c clang: fixed formatting 2024-08-19 20:40:23 +02:00
Random 09da94b7b2
fix gcc compilation error in vk_graphics_pipeline.cpp (#477)
gcc fails to infer the type of the two parts of a ternary expression whose types are different but both contain an implicit cast operator to the same type
2024-08-19 18:45:42 +03:00
¥IGA 9d45b99171
Adding icons to categories (#479) 2024-08-19 18:42:23 +03:00
Dzmitry Dubrova 1f416134e7
Add messages to asserts (#476) 2024-08-19 15:29:13 +03:00
bax-cz 516a3e7104 PlayGo: basic implementation, credits to red-prig 2024-08-19 13:14:14 +02:00
Lizardy 138c9ce787
[WIP] libSceNgs2 (#439)
* init ngs2

* clang

* ngs2 HLE for missing LLE

* clang

* clang

* orbis ngs2 error codes

* resolve, error codes, ngs2_impl

* clang

* clang

* mac atomic

* clang

* mac

* clang

---------

Co-authored-by: microsoftv <6063922+microsoftv@users.noreply.github.com>
2024-08-19 10:03:05 +03:00
georgemoralis 360b7e1d71
Merge pull request #471 from DanielSvoboda/Copy_submenu
Copy info - submenu
2024-08-19 09:45:44 +03:00
DanielSvoboda d5e978c6f2
Copy submenu 2024-08-19 01:25:15 -03:00
georgemoralis 09b71a9a3f
Merge pull request #466 from DanielSvoboda/alphabetical-order-console-language
Alphabetical order console language
2024-08-18 23:37:34 +03:00
DanielSvoboda c58ad6d3b5
alphabetical order console language 2024-08-18 17:24:41 -03:00
DanielSvoboda c9a502b31a
alphabetical order console language 2024-08-18 17:24:35 -03:00
georgemoralis 5551c61000
Merge pull request #463 from Xphalnos/main
Misc changes
2024-08-18 22:26:53 +03:00
DanielSvoboda ed96a9fb8e
alphabetical order console language 2024-08-18 16:15:06 -03:00
DanielSvoboda 5891900c6e
alphabetical order console language 2024-08-18 16:04:48 -03:00
Vladislav Mikhalin 1c898d0842
Fix stencil buffer not being used (#464) 2024-08-18 20:37:29 +03:00
Xphalnos 70576035b0 Misc changes 2024-08-18 17:56:29 +02:00
Lizardy 63938ba8dd
shader_recompiler: BUFFER_ATOMIC & DS_* Opcodes (#428)
* BUFFER_ATOMIC | DS_MINMAX_U32

- Emission of BufferAtomicU32
- Addition of Buffer opcodes to IR
- Translator for BUFFER_ATOMIC Opcode
- Translators for DS_MAXMIN_U32 Opcodes

* Clang Format & UNREACHABLE_MSG

* clang

* no crash on compile

* clang

* Shared Atomics

* reuse

* rm vscode

* resolve

* opcodes

* side effects

* attempt fix shader comp

* failed attempt to fix

* clang

* do correct vdata set (still fails)

* clang

* fixed BUFFER_ATOMIC_ADD, DS_ADD_U32 fails

* data share should work

* clang

* resource tracking for buffer atomic

* clang

* distinguish RTN opcodes

* clean IsBufferInstruction

---------

Co-authored-by: microsoftv <6063922+microsoftv@users.noreply.github.com>
2024-08-17 22:06:06 +03:00
¥IGA 3be2e4b2b8
About Window (#458) 2024-08-17 19:13:37 +03:00
georgemoralis ecf7f36763
Merge pull request #455 from Xphalnos/main
Qt-GUI: Improvements (Part 2)
2024-08-17 10:58:11 +03:00
georgemoralis 43e92bb987
Merge pull request #456 from StevenMiller123/sem_fix
Improve posix_sem functions
2024-08-17 10:57:19 +03:00
Xphalnos 73adc3ed1b Logger update 2024-08-17 08:22:31 +02:00
Stephen Miller 2935ca0fef clang-format fix 2024-08-16 17:22:06 -05:00
Stephen Miller 9fce6f7c01 Add SetPosixErrno function
I used a switch statement for future proofing, as some codes differ between Windows, Mac, Linux, or Orbis. Right now I've only added the codes that should be possible to encounter.
2024-08-16 17:20:21 -05:00
Stephen Miller 93f14e8ae9 Might fix clang-format? 2024-08-16 15:10:20 -05:00
Stephen Miller 6510af90be another clang-format fix 2024-08-16 15:07:19 -05:00
Stephen Miller f36440dc09 clang-format fix 2024-08-16 14:55:55 -05:00
Stephen Miller 786db80742 Improve posix_sem functions
Use ErrSceToPosix to update g_posix_errno appropriately after sem function calls.
2024-08-16 14:33:48 -05:00
Xphalnos 558fcf6597 Reduce window size 2024-08-16 19:48:18 +02:00
Dzmitry Dubrova dcb057dd7f
misc changes, part ?/? (#441)
* gui: add option to boot a game by choosing elf file

* core: some small implementations

* fs: implement open func

* add some validations

* spirv: add image format

* video_core: add eR16Uint to formats
2024-08-16 20:16:15 +03:00
Dzmitry Dubrova 9e810b7524
core: Some small pad stubs (#424)
* core: Some small pad stubs

* core: handle scePadSetLightBar wrong lightbar setting
2024-08-16 20:11:55 +03:00
TheTurtle 1d1c88ad31
control_flow_graph: Initial divergence handling (#434)
* control_flow_graph: Initial divergence handling

* cfg: Handle additional case

* spirv: Handle tgid enable bits

* clang format

* spirv: Use proper format

* translator: Add more instructions
2024-08-16 20:05:37 +03:00
Vinicius Rangel ff33b00c3a
gpu: primitive_restart bit check typo (#454) 2024-08-16 20:03:19 +03:00
Alexandre Bouvier 154771cca5
cmake: prefer system renderdoc library (#452) 2024-08-16 19:49:32 +03:00
Vinicius Rangel 444cdfbba5
gpu: check right register for primitive restart index (#453)
@red-prig suggestion

Not sure if it is possible to have trash in the register (maybe if primitive restart is toggled off), but just to make sure.
2024-08-16 19:49:15 +03:00
Alexandre Bouvier ad60ae1d40
cmake: prefer system ffmpeg library (#451) 2024-08-16 18:56:47 +03:00
Herman Semenov c1fb5d5bca
core,shader_recompiler: added const ref filesystem::path and removed if type size less 16 (#446) 2024-08-16 11:36:05 +03:00
georgemoralis 3197ad336e
Merge pull request #400 from vladmikhalin/basic-av-player
Basic AvPlayer implementation
2024-08-16 11:17:56 +03:00
Xphalnos 910e96c420 Qt-GUI: Improvements 2024-08-16 09:45:59 +02:00
Vladislav Mikhalin 23dddca1f0 last minute fixes 2024-08-16 10:30:48 +03:00
georgemoralis 5c70adc6ab
Merge pull request #449 from squidbus/libc++
Enable -fexperimental-library when using clang libc++
2024-08-16 10:28:03 +03:00
squidbus 62741434db Enable -fexperimental-library when using clang libc++ 2024-08-15 23:22:38 -07:00
Vladislav Mikhalin b3ef959b25 Fixed threading, migrated to CVs, added looping 2024-08-15 22:02:04 +03:00
Vladislav Mikhalin 5c4ac98d49 fixing build on linux and mac 2024-08-15 22:00:51 +03:00
Vladislav Mikhalin 0d6e8e227a Fixed some sound and threading issues.
Details:
* Switched SDL audio mutex to RW lock. This fixes games that continiously call SetVolume in a different thread (like Ghostbusters)
* Added contition to buffer audio packets independent of video packets. This fixes choppy audio across many games.
* Increased the number of audio frame buffers from 2 to 4. Just in case.
* Migrated to std::jthread and std::mutex from pthreads.
* Fixed a race condition with joins on avplayer close that caused a crash.
2024-08-15 22:00:51 +03:00
Vladislav Mikhalin e33ff10212 Added some logs, fixed some crashes, fixed align. 2024-08-15 22:00:51 +03:00
Vladislav Mikhalin b5c69189e5 avplayer WIP 2024-08-15 22:00:51 +03:00
georgemoralis e96e66eedd starting 0.2.1 2024-08-15 19:58:18 +03:00
georgemoralis da9b26fa1e tagged 0.2.0 release 2024-08-15 19:41:42 +03:00
psucien d32e584839 libraries: vide_out: redundant assert removed 2024-08-15 17:41:53 +02:00
¥IGA 0b1d7839a3
Qt-GUI: Cleaning the option menu (#443) 2024-08-15 17:49:13 +03:00
Vinicius Rangel d45563f92c
gpu: handle primitive restart index register (#438) 2024-08-15 15:43:27 +03:00
¥IGA a0fb47b0ab
Qt-GUI: Adding User Name selection (#440)
* Qt-GUI: Adding User Name selection

* fix

* fix 2

* fix 3 (thanks Poly)

* Change the username emplacement
2024-08-15 15:06:09 +03:00
¥IGA 8c77d4dde6
Ability to change username (#432) 2024-08-15 12:33:10 +03:00
psucien 9adc638220
shader_recompiler: basic implementation of `BUFFER_STORE_FORMAT_` (#431)
* shader_recompiler: basic implementation of buffer store w\ fmt conversion

* added `Format16` dfmt
2024-08-15 00:15:07 +02:00
Dzmitry Dubrova 6f4e1a47b9
core: misc changes (#430)
* core: misc changes

* video_core: add some formats for detiling

* clang format
2024-08-14 20:37:05 +02:00
Stephen Miller 5f963772a0
scePthreadAttrSetstack implementation (#391)
* scePthreadAttrSetstack implementation

Used by Final Fantasy XV

* Address Comments

Verify parameters before calling the pthread_attr_setstack function.
Swap uses of SCE prefix with ORBIS prefix.

* Quick fix

Addresses the newest review and appears to fix issues caused in games by my previous commit.
2024-08-14 18:43:00 +02:00
TheTurtle d332a5e611
spirv: Simplify shared memory handling (#427)
* spirv: Simplify shared memory handling

* spirv: Ignore clip plane

* spirv: Fix image offsets

* ir_pass: Implement shared memory lowering pass

* NVIDIA doesn't like using shared mem in fragment shader and softlocks driver

* spirv: Add log for ignoring pos1
2024-08-14 19:01:17 +03:00
georgemoralis 4b11dabd9e
Merge pull request #429 from polybiusproxy/memory-vq
core/memory: Fix error on virtual queries of reserved regions
2024-08-14 17:16:46 +03:00
Daniel R. 6cc4a682fd
core/memory: Fix error on virtual queries of reserved regions 2024-08-14 15:34:17 +02:00
psucien 27cb218584
video_core: CPU flip relay (#415)
* video_core: cpu flip is propagated via gpu thread now

* tentative fix for cpu flips racing

* libraries: videoout: better flip status handling
2024-08-14 11:36:11 +02:00
Samuel Fontes ad3b6c793c
qt-gui: Added GPU device selection functionality (#399)
* qt-gui: Added GPU device selection functionality

* Getting list of GPU only when application starts

* Fixed formatting

* Fixed formatting

* Fixed formatting

* Added warning when GPU doesn't support API version.

* Changed Unsupported Vulkan Version warning

* Removed unused size checking on GetPhysicalDevices

The method is only being called once so this doesn't make sense. It was some left over of me trying to get this done some other way.

* Fix formatting

* Fix formatting

* SettingsDialog: Passing physical devices as span

* Fixed formatting
2024-08-14 00:21:06 +03:00
TheTurtle d8b9d82ffa
video_core: Various fixes (#423)
* video_core: Various fixes

* clang format
2024-08-13 20:05:10 +03:00
counter185 bb159eafb9
Basic gamepad support through SDL (#407)
* Add basic gamepad support through SDL

* lightbar, vibration, code style changes

* okay fine

* one day clang format will finally pass
2024-08-13 12:54:08 +03:00
squidbus d1a033b6af
Fix some Vulkan validation errors on macOS. (#420) 2024-08-13 10:30:47 +03:00
TheTurtle 1fb0da9b89
video_core: Crucial buffer cache fixes + proper GPU clears (#414)
* translator: Use templates for stronger type guarantees

* spirv: Define buffer offsets upfront

* Saves a lot of shader instructions

* buffer_cache: Use dynamic vertex input when available

* Fixes issues when games like dark souls rebind vertex buffers with different stride

* externals: Update boost

* spirv: Use runtime array for ssbos

* ssbos can be large and typically their size will vary, especially in generic copy/clear cs shaders

* fs: Lock when doing case insensitive search

* Dark Souls does fs lookups from different threads

* texture_cache: More precise invalidation from compute

* Fixes unrelated render targets being cleared

* texture_cache: Use hashes for protect gpu modified images from reupload

* translator: Treat V_CNDMASK as float

* Sometimes it can have input modifiers. Worst this will cause is some extra calls to uintBitsToFloat and opposite. But most often this is used as float anyway

* translator: Small optimization for V_SAD_U32

* Fix review

* clang format
2024-08-13 09:21:48 +03:00
Vinicius Rangel dfcfd62d4f
spirv: fix image sample lod/clamp/offset translation (#402)
* spirv: fix image sample lod/clamp translation

* spirv: fix image sample offsets

* fix ImageSample opcodes & offset emission
2024-08-13 09:12:38 +03:00
Lizardy 5eecd089ab
thread_management.cpp: Various Mandatory Threading Fixes | Resolve #398 (#394)
* Handle empty mutex attribute

- scePthreadMutexInit did not return default when the mutex attributes were empty, now it does

* fix conditional unsafety

* Update thread_management.cpp

fix deref

* accurate heap api

- modified HeapAPI to a struct with preset function fields
- utilized the full array parameter passed to _sceKernelRtldSetApplicationHeapAPI

* fallback to std malloc

* clang format

* Declare all HeapAPI replacement functions

- calloc, realloc, memalign, reallocalign, malloc_stats, malloc_stats_fast, malloc_usable_size
- posix_memalign corrected parameters

* resolve suggestions

- `using` definition replacement for AppHeapAPI
- linux uses heap_malloc, windows uses std::malloc

---------

Co-authored-by: microsoftv <6063922+microsoftv@users.noreply.github.com>
2024-08-13 09:08:03 +03:00
Borchev 18f1799280
Add partial unmap support (#322)
* Add partial unmap support

* undo accidental whitespace removal

* Fix assertions

* Adjust Reserve and Free functions for partial unmapping
2024-08-13 09:05:30 +03:00
psucien a8b6a55559
Merge pull request #419 from squidbus/macos-fix
Enable VK_EXT_robustness2 nullDescriptor only if supported.
2024-08-13 00:15:48 +02:00
squidbus 284035d3e2 Enable VK_EXT_robustness2 nullDescriptor only if supported. 2024-08-12 14:52:46 -07:00
psucien a15a93997c unlink sync2 if not present (tentative fix for #418) 2024-08-12 22:52:21 +02:00
psucien 2ba3221fc9 fix for Linux compilation (#416) 2024-08-12 20:10:42 +02:00
psucien 3d0fdf11f0
Build stabilization (#413)
* shader_recompiler: fix for float convert and debug asserts

* libraries: kernel: correct return code on invalid semaphore

* amdgpu: additional case for cb extents retrieval heuristic

* removed redundant check in assert

* amdgpu: fix for linear tiling mode detection fin color buffers

* texture_cache: fix for unexpected scheduler flushes by detiler

* renderer_vulkan: missing depth barrier

* texture_cache: missed slices in rt view; + detiler format
2024-08-12 17:23:01 +03:00
psucien ace39957ef
Video Core: debug tools (#412)
* video_core: better use of rdoc markers

* renderer_vulkan: added gpu assisted validation

* renderer_vulkan: make nv_checkpoints operational

* video_core: unified Vulkan objects names
2024-08-12 13:46:45 +02:00
psucien 3e2d4d6b79
Gnmdriver: More functions (#410)
* libraries: gnmdriver: added `sceGnmGetGpuCoreClockFrequency`

* libraries: gnmdriver: `sceGnmSetVgtControl` added

* amdgpu: gpuclock64 in write eop packet
2024-08-12 13:29:57 +02:00
georgemoralis 834e3a500e added a fix for audio (seems that some games calls sceAudioOutInit twice) Thanks Roamic for tracing this! 2024-08-11 13:16:50 +03:00
georgemoralis 924e9de97a
Merge pull request #390 from dima-xd/qt_settings_dialog
gui: Implement settings dialog
2024-08-10 20:59:32 +03:00
Dzmitry Dubrova 3163cd135b gui: Add console language to settings 2024-08-09 18:28:50 +03:00
Dzmitry Dubrova 96fb00d411 gui: Implement settings dialog 2024-08-09 17:28:16 +03:00
Leonardo 14947232a7
Fixed coding style again on the if brackets 2024-08-09 09:24:14 -03:00
georgemoralis ea4ae56f4d
Merge pull request #368 from shadps4-emu/subupdatesAndFixes
Submodules updates + misc fixes
2024-08-09 13:31:57 +03:00
georgemoralis 54b20e2938 update submodules for some neccesary sdl addons 2024-08-09 13:04:00 +03:00
georgemoralis 61a6f633fd mount temp dir 2024-08-09 12:56:03 +03:00
georgemoralis d81dbc5b5b console language is better name 2024-08-09 12:24:42 +03:00
georgemoralis 425e5491a8 added setting for change language
(reference to https://github.com/shadps4-emu/shadPS4/wiki/PS4-Modules#supported-languages for values)
2024-08-09 11:58:42 +03:00
Leonardo 0d56be629b Removed else that duplicated while commiting the typo fixes 2024-08-08 18:33:06 -03:00
Leonardo 4375e6fa3a Fixed if else formatting 2024-08-08 18:30:58 -03:00
georgemoralis 250b2e4969 small playgo adjustments 2024-08-09 00:02:26 +03:00
georgemoralis 6a2e09a1df update submodules (possible mac fix?) 2024-08-09 00:02:25 +03:00
georgemoralis 3ef69cae5e some pad fixes (fixing metal slug 3 and risk of rain) 2024-08-09 00:02:25 +03:00
georgemoralis 7b7d1cb26f added missing NIDs in thread management 2024-08-09 00:02:25 +03:00
georgemoralis a83ac4c05e removed duplicate libSceJson2.sprx loading 2024-08-09 00:02:25 +03:00
georgemoralis 816700d34d fixed to scePadGetControllerInformation , (fixes CUSA04892 - power rangers multi user issue) 2024-08-09 00:02:25 +03:00
georgemoralis 4ffb812e94 more linux fix? 2024-08-09 00:02:25 +03:00
georgemoralis 13331cdda9 linux fix? 2024-08-09 00:02:25 +03:00
georgemoralis 5a68224a13 update submodules , fixed sdl update , rewrote config with new toml11 v4 2024-08-09 00:02:24 +03:00
SleepingSnakezzz ab56665d4b
Update latest build instructions.md (#385)
Expands on the existing instructions for more clarity.
2024-08-08 23:43:21 +03:00
Stephen Miller 48c58d5ce0
Kernel-Related Fixes (#386)
* Fix OrbisKernelBatchMapEntry struct

UE4 games and GTA V cause the BatchMap offset to overflow on Windows. Changing the type fixes this, and doesn't seem to cause any regressions on Windows or Linux.

* Implement posix_sem_trywait

Grand Theft Auto V needs this.

* Add missing scePthreadAttrGetdetachstate NID

Noticed this missing NID while testing games.
2024-08-08 23:42:51 +03:00
georgemoralis 3943d13871
Merge pull request #382 from shadps4-emu/smallrevert
revert some sdl switches
2024-08-08 22:55:00 +03:00
georgemoralis c96854f1f1
Merge pull request #381 from SamuelFontes/issues/361
361: Game directory window appears every time
2024-08-08 22:33:42 +03:00
georgemoralis e5087877ae revert some sdl switches 2024-08-08 22:31:14 +03:00
georgemoralis 14e56e267a
Merge pull request #380 from SamuelFontes/bugfix/refresh_game_list_after_path_change
qt_gui: Refreshing game list after install directory change
2024-08-08 22:25:14 +03:00
SamuelFontes 564b2f6310 361: Game directory window appears every time
qt_gui: When a command line argument is passed to the GUI version, it will always prompt to change the game directory. This happens because the "user" folder is created on the elf or eboot.bin location.
This change will ignore the game install directory configuration at startup when an command line argument is passed.
Since if a game was passed, it should start automatically as this is the expected behaviour.
2024-08-08 16:14:35 -03:00
SamuelFontes 7e5cc6162c qt_gui: Refreshing game list after install directory change
The game list wasn't being refreshed automaticly after a manual directory change on the QT GUI,  now the RefreshGameTable will be called after the GameInstallDialog is executed.
2024-08-08 15:57:43 -03:00
georgemoralis 81be8f270f
Merge pull request #379 from ElBread3/dbc-game
qt_gui: Added double-click game icon to start game
2024-08-08 21:51:17 +03:00
ElBread3 351f2e1073 double click to open games 2024-08-08 13:23:44 -05:00
Xphalnos 254b9ffb50
Workflows cleanup + misc fixes (#371)
* Workflows cleanup

* clang-format

* SDL3: Disabling unnecessary options

* Revert CMakeLists.txt changes
2024-08-08 18:19:44 +03:00
IndecisiveTurtle 3fd2abdd5b vk_graphics_pipeline: Fix regression 2024-08-08 17:01:03 +03:00
TheTurtle 341034fc30
filter: Add random library 2024-08-08 15:44:05 +03:00
TheTurtle 381ba8c7a5
video_core: Implement guest buffer manager (#373)
* video_core: Introduce buffer cache

* video_core: Use multi level page table for caches

* renderer_vulkan: Remove unused stream buffer

* fix build

* oops forgot optimize off
2024-08-08 15:02:10 +03:00
Leonardo ddec111da6 qt_gui: Added feature to toggle (show/hide) game list view
"Show Game List" button originally didn't have any action assigned to it, so this PR is supposed to implement the change that would make sense to it (even though I don't think anyone would be using this too much.)
2024-08-08 00:23:54 -03:00
TheTurtle 159be2c7f4
video_core: Minor fixes (#366)
* data_share: Fix DS instruction

* vk_graphics_pipeline: Fix unnecessary invalidate

* spirv: Remove subgroup id

* vector_alu: Simplify mbcnt pattern

* shader_recompiler: More instructions

* clang format

* kernel: Fix cond memory leak and reduce spam

* liverpool: Print error on exception

* build fix
2024-08-05 13:45:28 +03:00
DanielSvoboda cdff4af38d
add-SurfaceFormat (#365)
[Debug] <Critical> liverpool_to_vk.cpp:SurfaceFormat:395: Unreachable code!

CUSA24620
Unknown data_format=7 and num_format=7

CUSA03082
Unknown data_format=2 and num_format=4

CUSA19345
Unknown data_format=34 and num_format=7

CUSA02411
Unknown data_format=1 and num_format=9

A duplicate was also removed.
2024-08-04 22:17:34 +02:00
DanielSvoboda 7308864537
SampleCountFlagBits::e16 - GetGpuClock64 (#360)
* SampleCountFlagBits::e16

* GpuClock64

* GpuClock64

* Update pm4_cmds.h

* Update pm4_cmds.h
2024-08-04 15:49:43 +02:00
Xphalnos 21462523de
Minor Qt GUI update (#363)
* Minor Qt GUI update

* Update gui_context_menus.h

* Update gui_context_menus.h

* Update game_info.cpp
2024-08-04 16:07:10 +03:00
Alexandre Bouvier 6d0a763145
reuse: fix license for externals (#358) 2024-08-02 15:57:16 +03:00
georgemoralis 9f2e73c1fd
Merge pull request #356 from squidbus/macos-icon
Add macOS icon.
2024-08-01 08:42:44 +03:00
georgemoralis 305224650a
Merge pull request #352 from Xphalnos/main
Better logo for shadPS4
2024-08-01 08:42:24 +03:00
squidbus be829389ea Add new icons file to reuse config. 2024-07-31 19:40:25 -07:00
squidbus 56b362bb24 Add macOS icon. 2024-07-31 19:37:55 -07:00
georgemoralis 54e831746d
Merge pull request #355 from shadps4-emu/git_version
Added Git version info
2024-08-01 02:16:34 +03:00
georgemoralis bd48e24c32 print git info to log as well 2024-08-01 01:11:58 +03:00
georgemoralis 62e501f31f print git info in windows title 2024-08-01 00:56:10 +03:00
Xphalnos a4e46c4362 Merge branch 'main' of https://github.com/Xphalnos/shadPS4 2024-07-31 18:15:09 +02:00
Xphalnos 9968d03b90 Better logo for shadPS4 2024-07-31 18:14:22 +02:00
georgemoralis 0ac9f8ffa4
Merge pull request #346 from shadps4-emu/savedata_1
SaveData Fixes
2024-07-31 17:34:44 +03:00
georgemoralis a121e8e76a
Merge pull request #351 from Xphalnos/main
Adding macOS to readme + minor changes
2024-07-31 14:52:22 +03:00
Xphalnos 205c0b961b Adding macOS to readme + minor changes 2024-07-31 13:43:30 +02:00
Dzmitry Dubrova 0fe766db6c
core: Implement sceRandomGetRandomNumber (#350) 2024-07-31 14:01:22 +03:00
Xphalnos a7f2f09a44
Reorganization of includes (#348)
* Reorganization of includes

* fix
2024-07-31 13:25:55 +03:00
raziel1000 413402600b missing eR8Srgb 2024-07-31 02:07:02 -06:00
raziel1000 ec1335911b added data_format=1 and num_format=9 2024-07-31 01:24:44 -06:00
raziel1000 51c89a9958 added data_format=10 and num_format=5 2024-07-31 00:32:50 -06:00
raziel1000 d017bab21e Kernel: added sceKernelConvertLocaltimeToUtc 2024-07-31 00:21:23 -06:00
raziel1000 d7acb93d6f - Implemented sceSaveDataSetParam and sceSaveDataGetParam
- Fixed sceSaveDataDirNameSearch
2024-07-30 22:55:58 -06:00
TheTurtle a7c9bfa5c5
shader_recompiler: Small instruction parsing refactor/bugfixes (#340)
* translator: Implemtn f32 to f16 convert

* shader_recompiler: Add bit instructions

* shader_recompiler: More data share instructions

* shader_recompiler: Remove exec contexts, fix S_MOV_B64

* shader_recompiler: Split instruction parsing into categories

* shader_recompiler: Better BFS search

* shader_recompiler: Constant propagation pass for cmp_class_f32

* shader_recompiler: Partial readfirstlane implementation

* shader_recompiler: Stub readlane/writelane only for non-compute

* hack: Fix swizzle on RDR

* Will properly fix this when merging this

* clang format

* address_space: Bump user area size to full

* shader_recompiler: V_INTERP_MOV_F32

* Should work the same as spirv will emit flat decoration on demand

* kernel: Add MAP_OP_MAP_FLEXIBLE

* image_view: Attempt to apply storage swizzle on format

* vk_scheduler: Barrier attachments on renderpass end

* clang format

* liverpool: cs state backup

* shader_recompiler: More instructions and formats

* vector_alu: Proper V_MBCNT_U32_B32

* shader_recompiler: Port some dark souls things

* file_system: Implement sceKernelRename

* more formats

* clang format

* resource_tracking_pass: Back to assert

* translate: Tracedata

* kernel: Remove tracy lock

* Solves random crashes in Dark Souls

* code: Review comments
2024-07-30 23:32:40 +02:00
georgemoralis ac6dc20c3b
Merge pull request #343 from Borchev/AddPthreadGetStackSizeThunk
Add pthread_attr_getstacksize thunk
2024-07-30 23:36:39 +03:00
Xphalnos b3525d7f79
Don't download unnecessary DLLs (#341) 2024-07-30 22:41:31 +03:00
Borchev 361271826e
Fix SearchFree function bug (#339) 2024-07-30 22:40:42 +03:00
Borchev 867f38fe13 Add pthread_attr_getstacksize thunk 2024-07-30 12:37:05 -07:00
georgemoralis c1d01709be
kernel: Implement sceKernelSetVirtualRangeName (#338)
* Fix in searchFree should fix #337

* clang format fix

* sceKernelSetVirtualRangeName implementation

* improved vaddr conversion

* updated VirtualQuery to include name too

* unmap also removed name thanks @red_prig

* fixed copy...
2024-07-29 19:08:06 +03:00
georgemoralis 9b1092c995
Merge pull request #336 from squidbus/sem-polyfill
Add sem_timedwait polyfill for macOS.
2024-07-29 07:56:18 +03:00
squidbus 43d60a8ac9 Add sem_timedwait polyfill for macOS. 2024-07-28 16:42:33 -07:00
psucien aa795f5c59
Merge pull request #335 from VasylBaran/apple_detiler_artifacts_fixup
Fixup for detiler artifacts on macOS
2024-07-28 21:42:05 +02:00
Vasyl Baran 3e6af54ea3 Fixup for detiler artifacts on macOS 2024-07-28 22:21:18 +03:00
Dzmitry Dubrova aa7c8ca2b6
Implement some pthread calls (#332) 2024-07-28 18:43:44 +03:00
DanielSvoboda fb145342ce
log improvement ThrowInvalidType (#330)
* log improvement ThrowInvalidType

* log improvement ThrowInvalidType
2024-07-28 18:42:54 +03:00
psucien 30198d5ffc
Surface management rework (2/3) (#329)
* texture_cache: interface refactoring

* a bit of fixes and improvements

* texture_cache: macro tile extents for bpp 128

* texture_cache: detiler: prefer host memory for large buffers upload
2024-07-28 17:20:42 +02:00
TheTurtle 0d6edaa0a0
Move presentation to separate thread/improve sync (#303)
* video_out: Move presentation to separate thread

* liverpool: Better sync for CPU flips

* driver: Make flip blocking

* videoout: Proper flip rate and vblank management

* config: Add vblank divider option

* clang format

* videoout: added `sceVideoOutWaitVblank`

* clang format

* vk_scheduler: Silly merge conflict

* externals: Add renderdoc API

* clang format

* reuse

* rdoc: manual capture trigger

* clang fmt

---------

Co-authored-by: psucien <168137814+psucien@users.noreply.github.com>
2024-07-28 15:54:09 +02:00
Vinicius Rangel 361412031c
fix tls patch on windows (#328)
* fix tls patch on windows

based on TlsGetValue in kernel32.dll

* fix tls patch on windows for expansion slots
2024-07-27 20:16:21 +03:00
Vinicius Rangel 680192a0c4
64 bits OP, impl V_ADDC_U32 & V_MAD_U64_U32 (#310)
* impl V_ADDC_U32 & V_MAD_U64_U32

* shader recompiler: add 64 bits version to get register / GetSrc

* fix V_ADDC_U32 carry

* shader recompiler: removed automatic conversion to force_flt in GetSRc

* shader recompiler: auto cast between u32 and u64 during ssa pass

* shader recompiler: fix SetVectorReg64 & standardize switches-case

* shader translate: fix overflow detection in V_ADD_I32

use vcc lo instead of vcc thread bit

* shader recompiler: more 64-bit work

- removed bit_size parameter from Get[Scalar/Vector]Register
- add BitwiseOr64
- add SetDst64 as a replacement for SetScalarReg64 & SetVectorReg64
- add GetSrc64 for 64-bit value

* shader recompiler: add V_MAD_U64_U32 vcc output

- add V_MAD_U64_U32 vcc output
- ILessThan for 64-bits

* shader recompiler: removed unnecessary changes & missing consts

* shader_recompiler: Add s64 type in constant propagation
2024-07-27 17:23:59 +03:00
TheTurtle d84b4adc83
semaphore: Yet another race condition fix (#327) 2024-07-27 17:18:18 +03:00
georgemoralis b7c3ff932b
Merge pull request #325 from DanielSvoboda/BUFFER_STORE_DWORDX2
BUFFER_STORE_DWORDX2
2024-07-26 13:17:16 +03:00
georgemoralis 14e78591e8
Merge pull request #320 from shadps4-emu/miscFixes7
Misc Fixes 7
2024-07-26 13:14:04 +03:00
raziel1000 600a13c38f fs: added /download0 mount
fs: get rid of double slashes
2024-07-26 08:07:22 -06:00
georgemoralis 2841eba538 added /dev/urandom 2024-07-26 08:50:39 +03:00
georgemoralis a4912b8245 commented sem_timedwait for linux untill @squidbus fix it 2024-07-26 08:16:32 +03:00
georgemoralis 64d305faeb cleanup memory_management 2024-07-26 08:08:47 +03:00
raziel1000 a11ac5a687 ... 2024-07-26 07:59:55 +03:00
raziel1000 fa76a723ad Applied feedback from @raphaelthegreat 2024-07-26 07:59:35 +03:00
georgemoralis b62836d29f forgot a file 2024-07-26 07:53:46 +03:00
georgemoralis b4916ef2ca some fixup to playgo , makes Worms go further 2024-07-26 07:53:45 +03:00
raziel1000 a475b38e5f - fixed sceAppContentTemporaryDataMount2 2024-07-26 07:53:19 +03:00
raziel1000 f35518d527 sdl window: Added game title (serial, title and app_ver) 2024-07-26 07:53:18 +03:00
raziel1000 f29293c9fb thread_management: some pthread functions 2024-07-26 07:53:18 +03:00
raziel1000 02d4af27df save_data: fix/accuracy for saveDataMem functions 2024-07-26 07:53:18 +03:00
DanielSvoboda b2ba84aa11
BUFFER_STORE_DWORDX2 2024-07-26 00:25:29 -03:00
TheTurtle a2cd1669b6
memory: Cleanups and refactors (#324)
* memory: Various fixes

* Added (Partial) sceKernelBatchMap/sceKernelBatchMap2

* memory: Rename and implement batch unmap

* memory: Remove uneeded assert

* memory: Commonize free search routine

* memory: Contains check is inclusive

* memory: Address some alignment issues

* clang format

---------

Co-authored-by: raziel1000 <ckraziel@gmail.com>
2024-07-25 23:01:12 +03:00
georgemoralis bc28ed66e8
Merge pull request #323 from shadps4-emu/win-fix
address_space: Fix windows placeholder mapping
2024-07-25 12:15:25 +03:00
georgemoralis 8fa6a8c036 clang fix 2024-07-25 11:59:39 +03:00
IndecisiveTurtle 8bb6c0ddf0 address_space: Fix windows placeholder mapping 2024-07-24 22:59:56 +03:00
Younes 1d6a42c39a
Merge pull request #319 from DanielSvoboda/fixed--patch-version-is-older
Fixed the button- PKG patch version is older
2024-07-23 23:17:26 -06:00
DanielSvoboda de6f703d7d
I fixed the button, PKG patch version is older
I fixed the button, PKG patch version is older
2024-07-23 19:21:54 -03:00
squidbus de3864dba7
Install x86_64 MoltenVK from Homebrew. (#318) 2024-07-23 22:17:50 +03:00
georgemoralis 0691e316e0
Merge pull request #317 from VasylBaran/fix_macos_build_molten_vk
Fix macOS builds
2024-07-23 20:26:48 +03:00
VasylBaran 4e81d91f88 Install molten-vk using brew (vs getching it directly with url) to fix macOS build 2024-07-23 20:24:35 +03:00
Foxi f593204729
Update CONTRIBUTING.md (#316)
Syntax highlighting for the example code
2024-07-23 18:56:31 +03:00
georgemoralis 7f990ea90d
Merge pull request #314 from squidbus/game-data-path
Replace remaining uses of `QDir::currentPath() / "user"` with `GetUserPath(UserDir)`.
2024-07-22 18:27:34 +03:00
squidbus 54b5900498 Replace remaining uses of QDir::currentPath() / user with UserDir. 2024-07-21 14:01:10 -07:00
georgemoralis 062ee9e092 one more memory fix 2024-07-21 23:16:46 +03:00
georgemoralis fe9b07da54 memory fix 2024-07-21 23:14:40 +03:00
georgemoralis 36ec7a1a43
Merge pull request #312 from Borchev/main
Add sceKernelGetDirectMemoryType, update sceKernelReserveVirtualRange
2024-07-21 22:52:50 +03:00
squidbus 70708fc69b Allocate more system reserved space on macOS and document restrictions. 2024-07-21 22:36:12 +03:00
squidbus 615f4e770f Support RIP relative memory operands in patched instructions. 2024-07-21 22:36:12 +03:00
squidbus 088130863b Update MoltenVK to 1.2.10 2024-07-21 22:36:12 +03:00
squidbus 43c0f313f2 Fix user data path on macOS. 2024-07-21 22:36:12 +03:00
squidbus 225ca3ac5b Update format list for rebase and sort and remove duplicates. 2024-07-21 22:36:12 +03:00
squidbus cf03743631 Restore old keybindings for Windows and Linux. 2024-07-21 22:36:12 +03:00
squidbus 426d82d07b Only use date library on macOS. 2024-07-21 22:36:12 +03:00
squidbus b557de2c62 Make sure only system managed region can be moved on Windows. 2024-07-21 22:36:12 +03:00
squidbus 26e0fc6ad5 Only patch BMI1 instructions under Rosetta 2. 2024-07-21 22:36:12 +03:00
squidbus fadf03909c Add a few missing used formats from detiling. 2024-07-21 22:36:12 +03:00
squidbus 3e84d2b76c Define tessellation_factors_ring_addr relative to end of system reserved area. 2024-07-21 22:36:12 +03:00
squidbus e2adbd75c3 Reduce system reserved space to 0x700000000 and map fixed on macOS. 2024-07-21 22:36:12 +03:00
squidbus f943ce2710 Address review comments around memory and patches. 2024-07-21 22:36:12 +03:00
squidbus b3d97dcd89 Make sure system managed memory is in correct location on macOS. 2024-07-21 22:36:12 +03:00
squidbus 685b0bfd5e Fix missing logging on memory manager initalization. 2024-07-21 22:36:12 +03:00
squidbus 4fd3af995e Change format list from vector to array/span. 2024-07-21 22:36:12 +03:00
squidbus 68e1a6a596 Tidy up Vulkan extension list. 2024-07-21 22:36:12 +03:00
squidbus e06039d727 Set minimum macOS target to 11 and fix compile errors. 2024-07-21 22:36:12 +03:00
squidbus 35bbbb1bd9 Add GitHub Actions workflows for macOS. 2024-07-21 22:36:12 +03:00
squidbus a4fd0d6386 Remap SDL face buttons to be usable without a keypad. 2024-07-21 22:36:12 +03:00
squidbus 175ffe8ce3 Add fallback system for unsupported pixel formats. 2024-07-21 22:36:12 +03:00
squidbus 35d629a730 Downgrade Vulkan requirement to 1.2 with extensions. 2024-07-21 22:36:12 +03:00
squidbus d9231b239c Migrate TLS patches to new patching system. 2024-07-21 22:36:12 +03:00
squidbus 6a6d5bad42 Fix one-off bug with user data registers. 2024-07-21 22:36:12 +03:00
squidbus 66fa29059c Add initial macOS support. 2024-07-21 22:36:12 +03:00
Borchev 5419212088 Fix formatting 2024-07-21 12:35:01 -07:00
Borchev f556f85279 Add sceKernelGetDirectMemoryType and update sceKernelReserveVirtualRange to search for free region when virtual_addr==0 2024-07-21 11:29:24 -07:00
TheTurtle 36d528743a
vk_scheduler: Fix pending op check 2024-07-21 17:41:46 +03:00
TheTurtle 403a5a57b1
vk_scheduler: Add api for defering operations (#311) 2024-07-21 15:42:32 +03:00
psucien 64459f1a76
Surface management rework (1/3) (#307)
* amdgpu: proper CB and DB sizes calculation; minor refactoring

* texture_cache: separate file for image_info

* texture_cache: image guest address moved into image info

* texture_cache: surface size calculation

* shader_recompiler: fixed sin/cos

Thanks to red_pring and gandalfthewhite0173

* initial preparations for subresources upload

* review comments
2024-07-20 12:51:21 +03:00
psucien 2b52a17845 externals: Tracy updated to 0.11 2024-07-20 11:30:55 +02:00
TheTurtle bfe3322977
spirv: Address some regressions in buffer loads (#304)
* spirv: Use correct index

* spirv: Fix indices during buffer load

* clang-format fix

* spirv: Index can be const

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2024-07-19 19:36:07 +03:00
georgemoralis 60b1aa62a3
Merge pull request #281 from shadps4-emu/miscFixes6
Misc Fixes (forgot the number)
2024-07-19 16:35:19 +03:00
georgemoralis fcc931956e submodules updated 2024-07-19 09:02:36 +03:00
georgemoralis d00a2465d5 update fixes for winpthreads 2024-07-19 08:50:55 +03:00
Vladislav Mikhalin d0d7ef06e8
Fixed buffer_store_* regression (#302) 2024-07-18 21:04:12 +03:00
georgemoralis c578ccc435 load every available prx from sce_module folder of game 2024-07-18 18:34:08 +03:00
georgemoralis 250bfbb494
Update liverpool_to_vk.cpp 2024-07-18 18:19:46 +03:00
georgemoralis 25e95c959a
Merge branch 'main' into miscFixes6 2024-07-18 18:18:10 +03:00
Dzmitry Dubrova 485d4fd0fb
kernel: Implement posix_pthread_once (#297)
* kernel: Implement posix_pthread_once

* Fix clang format
2024-07-17 23:34:22 +03:00
georgemoralis 384ea359ed
Merge pull request #300 from shadps4-emu/regression-fix
code: Fixup some regressions
2024-07-17 20:40:23 +03:00
georgemoralis 0ed9ea5b85 force imedialog to input "shadps4" as name . That way we can pass games that want username . temp solution till imgui dialog prepared 2024-07-17 20:32:14 +03:00
georgemoralis 439c0be9a6 clang format fix 2024-07-17 17:57:54 +03:00
IndecisiveTurtle 1208661d64 Remove bc6 2024-07-17 17:06:09 +03:00
IndecisiveTurtle cd009cfec6 shader_recompiler: Normal gathers 2024-07-17 16:49:45 +03:00
IndecisiveTurtle 53fb73e95f rasterizer: Bump staging to 1GB
* Less chances of crashing
2024-07-17 16:22:04 +03:00
IndecisiveTurtle fcbaec51df liverpool_to_vk: Add more surface formats 2024-07-17 16:19:08 +03:00
IndecisiveTurtle 01dc7f5bfc Add comments 2024-07-17 15:52:40 +03:00
IndecisiveTurtle b89941fbd9 emulator: Add libSceUlt too 2024-07-17 15:44:20 +03:00
IndecisiveTurtle 0408d8596d emulator: Add libSceFiber and simplify logic 2024-07-17 15:37:32 +03:00
IndecisiveTurtle b6f011c8f6 event_queue: Add clear flag to events and don't return error 2024-07-17 14:50:26 +03:00
IndecisiveTurtle c64694c673 gnmdriver: Fix incorrect trailing nop insertion in indirect draws 2024-07-17 14:48:30 +03:00
IndecisiveTurtle 815ce11d2b fs: Defeat games with double slashes 2024-07-17 14:46:37 +03:00
raziel1000 02cba0100d Some functions called by Stardew Valley 2024-07-14 23:23:11 +03:00
georgemoralis 056dcf52ca initial ime dialog handling 2024-07-14 23:23:10 +03:00
georgemoralis b07bbecab4 replace unreachable with default return in sceKernelClockGettime 2024-07-14 23:23:10 +03:00
georgemoralis 4de9d9cf0d dataformat used by DMC4 2024-07-14 23:23:10 +03:00
raziel1000 ecad6cd1a7 - sceSaveDataDirNameSearch wip, needs testing and more work. 2024-07-14 23:23:10 +03:00
371 changed files with 43091 additions and 8038 deletions

View File

@ -19,8 +19,12 @@ chmod a+x linuxdeploy-x86_64.AppImage
chmod a+x linuxdeploy-plugin-qt-x86_64.AppImage chmod a+x linuxdeploy-plugin-qt-x86_64.AppImage
chmod a+x linuxdeploy-plugin-checkrt-x86_64.sh chmod a+x linuxdeploy-plugin-checkrt-x86_64.sh
# Build AppImage # Build AppImage
./linuxdeploy-x86_64.AppImage --appdir AppDir ./linuxdeploy-x86_64.AppImage --appdir AppDir
./linuxdeploy-plugin-checkrt-x86_64.sh --appdir AppDir ./linuxdeploy-plugin-checkrt-x86_64.sh --appdir AppDir
cp -a "$GITHUB_WORKSPACE/build/translations" AppDir/usr/bin
./linuxdeploy-x86_64.AppImage --appdir AppDir -d "$GITHUB_WORKSPACE"/.github/shadps4.desktop -e "$GITHUB_WORKSPACE"/build/shadps4 -i "$GITHUB_WORKSPACE"/.github/shadps4.png --plugin qt --output appimage ./linuxdeploy-x86_64.AppImage --appdir AppDir -d "$GITHUB_WORKSPACE"/.github/shadps4.desktop -e "$GITHUB_WORKSPACE"/build/shadps4 -i "$GITHUB_WORKSPACE"/.github/shadps4.png --plugin qt --output appimage
mv Shadps4-x86_64.AppImage Shadps4-qt.AppImage mv Shadps4-x86_64.AppImage Shadps4-qt.AppImage

BIN
.github/shadps4.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 KiB

After

Width:  |  Height:  |  Size: 130 KiB

View File

@ -10,7 +10,6 @@ on:
branches: [ "main" ] branches: [ "main" ]
env: env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release BUILD_TYPE: Release
jobs: jobs:
@ -19,12 +18,12 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Fetch submodules with:
run: git submodule update --init --recursive submodules: recursive
- name: Install misc packages - name: Install misc packages
run: > run: >
sudo apt-get update && sudo apt install libx11-dev libxext-dev libwayland-dev libfuse2 clang build-essential qt6-base-dev sudo apt-get update && sudo apt install libx11-dev libxext-dev libwayland-dev libfuse2 clang build-essential qt6-base-dev qt6-tools-dev
- name: Configure CMake - name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_QT_GUI=ON run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_QT_GUI=ON

View File

@ -8,10 +8,8 @@ on:
branches: [ "main" ] branches: [ "main" ]
pull_request: pull_request:
branches: [ "main" ] branches: [ "main" ]
workflow_dispatch:
env: env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release BUILD_TYPE: Release
jobs: jobs:

61
.github/workflows/macos-qt.yml vendored Normal file
View File

@ -0,0 +1,61 @@
# SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
name: macOS-Qt
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
BUILD_TYPE: Release
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup latest Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest
- name: Install MoltenVK
run: |
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
arch -x86_64 /usr/local/bin/brew install molten-vk
- name: Setup Qt
uses: jurplel/install-qt-action@v4
with:
version: 6.7.2
host: mac
target: desktop
arch: clang_64
archives: qtbase qttools
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_ARCHITECTURES=x86_64 -DENABLE_QT_GUI=ON
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(sysctl -n hw.ncpu)
- name: Package
run: |
mkdir upload
mv ${{github.workspace}}/build/shadps4.app upload
mv ${{github.workspace}}/build/translations upload
macdeployqt upload/shadps4.app
tar cf shadps4-macos-qt.tar.gz -C upload .
- name: Upload executable
uses: actions/upload-artifact@v4
with:
name: shadps4-macos-qt
path: shadps4-macos-qt.tar.gz

52
.github/workflows/macos.yml vendored Normal file
View File

@ -0,0 +1,52 @@
# SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
name: macOS
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
BUILD_TYPE: Release
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup latest Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest
- name: Install MoltenVK
run: |
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
arch -x86_64 /usr/local/bin/brew install molten-vk
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_ARCHITECTURES=x86_64
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(sysctl -n hw.ncpu)
- name: Package
run: |
mkdir upload
mv ${{github.workspace}}/build/shadps4 upload
cp $(arch -x86_64 /usr/local/bin/brew --prefix)/opt/molten-vk/lib/libMoltenVK.dylib upload
install_name_tool -add_rpath "@loader_path" upload/shadps4
tar cf shadps4-macos-sdl.tar.gz -C upload .
- name: Upload executable
uses: actions/upload-artifact@v4
with:
name: shadps4-macos-sdl
path: shadps4-macos-sdl.tar.gz

View File

@ -10,12 +10,8 @@ on:
branches: [ "main" ] branches: [ "main" ]
env: env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release BUILD_TYPE: Release
permissions:
contents: read
jobs: jobs:
build: build:
runs-on: windows-latest runs-on: windows-latest
@ -28,22 +24,23 @@ jobs:
- name: Setup Qt - name: Setup Qt
uses: jurplel/install-qt-action@v4 uses: jurplel/install-qt-action@v4
with: with:
arch: win64_msvc2019_64
version: 6.7.2 version: 6.7.2
host: windows
target: desktop
arch: win64_msvc2019_64
archives: qtbase qttools
- name: Configure CMake - name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -T ClangCL -DENABLE_QT_GUI=ON run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -T ClangCL -DENABLE_QT_GUI=ON
- name: Build - name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel
- name: Deploy - name: Deploy
run: | run: |
mkdir upload mkdir upload
move build/Release/shadPS4.exe upload move build/Release/shadPS4.exe upload
move build/translations upload
windeployqt --dir upload upload/shadPS4.exe windeployqt --dir upload upload/shadPS4.exe
- name: Upload executable - name: Upload executable

View File

@ -10,12 +10,8 @@ on:
branches: [ "main" ] branches: [ "main" ]
env: env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release BUILD_TYPE: Release
permissions:
contents: read
jobs: jobs:
build: build:
runs-on: windows-latest runs-on: windows-latest
@ -25,16 +21,14 @@ jobs:
submodules: recursive submodules: recursive
- name: Configure CMake - name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -T ClangCL run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -T ClangCL
- name: Build - name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel
- name: Upload a Build Artifact
- name: Upload executable
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: shadps4-win64 name: shadps4-win64-sdl
# A file, directory or wildcard pattern that describes what to upload
path: | path: |
${{github.workspace}}/build/Release/shadPS4.exe ${{github.workspace}}/build/Release/shadPS4.exe

1
.gitignore vendored
View File

@ -408,3 +408,4 @@ FodyWeavers.xsd
/emulator/eboot.bin /emulator/eboot.bin
/out/* /out/*
/third-party/out/* /third-party/out/*
/src/common/scm_rev.cpp

33
.gitmodules vendored
View File

@ -1,60 +1,87 @@
[submodule "externals/discord-rpc"]
path = externals/discord-rpc
url = https://github.com/shadps4-emu/ext-discord-rpc.git
[submodule "externals/cryptopp-cmake"] [submodule "externals/cryptopp-cmake"]
path = externals/cryptopp-cmake path = externals/cryptopp-cmake
url = https://github.com/shadps4-emu/ext-cryptopp-cmake.git url = https://github.com/shadps4-emu/ext-cryptopp-cmake.git
shallow = true
[submodule "externals/cryptopp"] [submodule "externals/cryptopp"]
path = externals/cryptopp path = externals/cryptopp
url = https://github.com/shadps4-emu/ext-cryptopp.git url = https://github.com/shadps4-emu/ext-cryptopp.git
shallow = true
[submodule "externals/cryptoppwin"] [submodule "externals/cryptoppwin"]
path = externals/cryptoppwin path = externals/cryptoppwin
url = https://github.com/shadps4-emu/ext-cryptoppwin.git url = https://github.com/shadps4-emu/ext-cryptoppwin.git
shallow = true
[submodule "externals/zlib-ng"] [submodule "externals/zlib-ng"]
path = externals/zlib-ng path = externals/zlib-ng
url = https://github.com/shadps4-emu/ext-zlib-ng.git url = https://github.com/shadps4-emu/ext-zlib-ng.git
shallow = true
[submodule "externals/sdl3"] [submodule "externals/sdl3"]
path = externals/sdl3 path = externals/sdl3
url = https://github.com/shadps4-emu/ext-SDL.git url = https://github.com/shadps4-emu/ext-SDL.git
shallow = true
[submodule "externals/fmt"] [submodule "externals/fmt"]
path = externals/fmt path = externals/fmt
url = https://github.com/shadps4-emu/ext-fmt.git url = https://github.com/shadps4-emu/ext-fmt.git
shallow = true
[submodule "externals/vulkan-headers"] [submodule "externals/vulkan-headers"]
path = externals/vulkan-headers path = externals/vulkan-headers
url = https://github.com/KhronosGroup/Vulkan-Headers.git url = https://github.com/KhronosGroup/Vulkan-Headers.git
shallow = true
[submodule "externals/vma"] [submodule "externals/vma"]
path = externals/vma path = externals/vma
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
shallow = true
[submodule "externals/glslang"] [submodule "externals/glslang"]
path = externals/glslang path = externals/glslang
url = https://github.com/KhronosGroup/glslang.git url = https://github.com/KhronosGroup/glslang.git
shallow = true
[submodule "externals/robin-map"] [submodule "externals/robin-map"]
path = externals/robin-map path = externals/robin-map
url = https://github.com/Tessil/robin-map.git url = https://github.com/Tessil/robin-map.git
shallow = true
[submodule "externals/xbyak"] [submodule "externals/xbyak"]
path = externals/xbyak path = externals/xbyak
url = https://github.com/herumi/xbyak.git url = https://github.com/herumi/xbyak.git
shallow = true
[submodule "externals/winpthreads"] [submodule "externals/winpthreads"]
path = externals/winpthreads path = externals/winpthreads
url = https://github.com/shadps4-emu/winpthreads.git url = https://github.com/shadps4-emu/winpthreads.git
shallow = true
[submodule "externals/magic_enum"] [submodule "externals/magic_enum"]
path = externals/magic_enum path = externals/magic_enum
url = https://github.com/Neargye/magic_enum.git url = https://github.com/Neargye/magic_enum.git
shallow = true
[submodule "externals/toml11"] [submodule "externals/toml11"]
path = externals/toml11 path = externals/toml11
url = https://github.com/ToruNiina/toml11.git url = https://github.com/ToruNiina/toml11.git
shallow = true
[submodule "externals/zydis"] [submodule "externals/zydis"]
path = externals/zydis path = externals/zydis
url = https://github.com/zyantific/zydis.git url = https://github.com/zyantific/zydis.git
shallow = true
[submodule "externals/sirit"] [submodule "externals/sirit"]
path = externals/sirit path = externals/sirit
url = https://github.com/shadps4-emu/sirit.git url = https://github.com/shadps4-emu/sirit.git
shallow = true
[submodule "externals/xxhash"] [submodule "externals/xxhash"]
path = externals/xxhash path = externals/xxhash
url = https://github.com/Cyan4973/xxHash.git url = https://github.com/Cyan4973/xxHash.git
shallow = true
[submodule "externals/tracy"] [submodule "externals/tracy"]
path = externals/tracy path = externals/tracy
url = https://github.com/shadps4-emu/tracy.git url = https://github.com/shadps4-emu/tracy.git
shallow = true
[submodule "externals/ext-boost"] [submodule "externals/ext-boost"]
path = externals/ext-boost path = externals/ext-boost
url = https://github.com/shadps4-emu/ext-boost.git url = https://github.com/shadps4-emu/ext-boost.git
shallow = true
[submodule "externals/date"]
path = externals/date
url = https://github.com/HowardHinnant/date.git
shallow = true
[submodule "externals/ffmpeg-core"]
path = externals/ffmpeg-core
url = https://github.com/shadps4-emu/ext-ffmpeg-core.git
shallow = true
[submodule "externals/half"]
path = externals/half
url = https://github.com/ROCm/half.git

View File

@ -14,9 +14,8 @@ Files: CMakeSettings.json
documents/Screenshots/Sonic Mania.png documents/Screenshots/Sonic Mania.png
documents/Screenshots/Undertale.png documents/Screenshots/Undertale.png
documents/Screenshots/We are DOOMED.png documents/Screenshots/We are DOOMED.png
externals/stb_image.h
externals/tracy/*
scripts/ps4_names.txt scripts/ps4_names.txt
src/images/about_icon.png
src/images/controller_icon.png src/images/controller_icon.png
src/images/exit_icon.png src/images/exit_icon.png
src/images/file_icon.png src/images/file_icon.png
@ -36,9 +35,26 @@ Files: CMakeSettings.json
src/images/refresh_icon.png src/images/refresh_icon.png
src/images/settings_icon.png src/images/settings_icon.png
src/images/stop_icon.png src/images/stop_icon.png
src/images/shadPS4.icns
src/images/shadps4.ico src/images/shadps4.ico
src/images/themes_icon.png src/images/themes_icon.png
src/shadps4.qrc src/shadps4.qrc
src/shadps4.rc src/shadps4.rc
Copyright: shadPS4 Emulator Project Copyright: shadPS4 Emulator Project
License: GPL-2.0-or-later License: GPL-2.0-or-later
Files: externals/cmake-modules/*
Copyright: 2009-2010 Iowa State University
License: BSL-1.0
Files: externals/renderdoc/*
Copyright: 2019-2024 Baldur Karlsson
License: MIT
Files: externals/stb_image.h
Copyright: 2017 Sean Barrett
License: MIT
Files: externals/tracy/*
Copyright: 2017-2024 Bartosz Taudul <wolf@nereid.pl>
License: BSD-3-Clause

View File

@ -6,6 +6,11 @@ cmake_minimum_required(VERSION 3.16.3)
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_STANDARD_REQUIRED True)
if(APPLE)
enable_language(OBJC)
set(CMAKE_OSX_DEPLOYMENT_TARGET 11)
endif()
if (NOT CMAKE_BUILD_TYPE) if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
endif() endif()
@ -14,12 +19,11 @@ project(shadPS4)
option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF) option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF)
# This function should be passed a list of all files in a target. It will automatically generate # This function should be passed a list of all files in a target. It will automatically generate file groups
# file groups following the directory hierarchy, so that the layout of the files in IDEs matches the # following the directory hierarchy, so that the layout of the files in IDEs matches the one in the filesystem.
# one in the filesystem.
function(create_target_directory_groups target_name) function(create_target_directory_groups target_name)
# Place any files that aren't in the source list in a separate group so that they don't get in
# the way. # Place any files that aren't in the source list in a separate group so that they don't get in the way.
source_group("Other Files" REGULAR_EXPRESSION ".") source_group("Other Files" REGULAR_EXPRESSION ".")
get_target_property(target_sources "${target_name}" SOURCES) get_target_property(target_sources "${target_name}" SOURCES)
@ -34,14 +38,6 @@ endfunction()
# Setup a custom clang-format target (if clang-format can be found) that will run # Setup a custom clang-format target (if clang-format can be found) that will run
# against all the src files. This should be used before making a pull request. # against all the src files. This should be used before making a pull request.
# =======================================================================
set(CLANG_FORMAT_POSTFIX "-17")
find_program(CLANG_FORMAT
NAMES clang-format${CLANG_FORMAT_POSTFIX}
clang-format
PATHS ${PROJECT_BINARY_DIR}/externals)
if (CLANG_FORMAT) if (CLANG_FORMAT)
set(SRCS ${PROJECT_SOURCE_DIR}/src) set(SRCS ${PROJECT_SOURCE_DIR}/src)
set(CCOMMENT "Running clang format against all the .h and .cpp files in src/") set(CCOMMENT "Running clang format against all the .h and .cpp files in src/")
@ -60,28 +56,80 @@ endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# generate git revision information
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules/")
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REF_SPEC GIT_REV)
git_describe(GIT_DESC --always --long --dirty)
git_branch_name(GIT_BRANCH)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp" @ONLY)
find_package(Boost 1.84.0 CONFIG) find_package(Boost 1.84.0 CONFIG)
find_package(cryptopp 8.9.0 MODULE) find_package(FFmpeg 5.1.2 MODULE)
find_package(fmt 10.2.1 CONFIG) find_package(fmt 10.2.0 CONFIG)
find_package(glslang 14.2.0 CONFIG) find_package(glslang 14.2.0 CONFIG)
find_package(magic_enum 0.9.6 CONFIG) find_package(magic_enum 0.9.6 CONFIG)
find_package(RenderDoc 1.6.0 MODULE)
find_package(SDL3 3.1.2 CONFIG) find_package(SDL3 3.1.2 CONFIG)
find_package(toml11 3.8.1 CONFIG) find_package(toml11 4.2.0 CONFIG)
find_package(tsl-robin-map 1.3.0 CONFIG) find_package(tsl-robin-map 1.3.0 CONFIG)
find_package(VulkanHeaders 1.3.289 CONFIG) find_package(VulkanHeaders 1.3.289 CONFIG)
find_package(VulkanMemoryAllocator 3.1.0 CONFIG) find_package(VulkanMemoryAllocator 3.1.0 CONFIG)
find_package(xbyak 7.07 CONFIG) find_package(xbyak 7.07 CONFIG)
find_package(xxHash 0.8.2 MODULE) find_package(xxHash 0.8.2 MODULE)
find_package(zlib-ng 2.2.0 MODULE) find_package(zlib-ng 2.1.7 MODULE)
find_package(Zydis 4.1.0 CONFIG) find_package(Zydis 5.0.0 CONFIG)
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR NOT MSVC)
find_package(cryptopp 8.9.0 MODULE)
endif()
if (APPLE)
find_package(date 3.0.1 CONFIG)
endif()
# Note: Windows always has these functions through winpthreads
include(CheckSymbolExists)
check_symbol_exists(pthread_mutex_timedlock "pthread.h" HAVE_PTHREAD_MUTEX_TIMEDLOCK)
if(HAVE_PTHREAD_MUTEX_TIMEDLOCK OR WIN32)
add_compile_options(-DHAVE_PTHREAD_MUTEX_TIMEDLOCK)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# libc++ requires -fexperimental-library to enable std::jthread and std::stop_token support.
include(CheckCXXSymbolExists)
check_cxx_symbol_exists(_LIBCPP_VERSION version LIBCPP)
if(LIBCPP)
add_compile_options(-fexperimental-library)
endif()
endif()
add_subdirectory(externals) add_subdirectory(externals)
include_directories(src) include_directories(src)
if(ENABLE_QT_GUI) if(ENABLE_QT_GUI)
find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent) find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent LinguistTools Network)
qt_standard_project_setup() qt_standard_project_setup()
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(QT_TRANSLATIONS "${PROJECT_SOURCE_DIR}/src/qt_gui/translations")
file(GLOB_RECURSE TRANSLATIONS_TS ${QT_TRANSLATIONS}/*.ts)
set_source_files_properties(${TRANSLATIONS_TS} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations")
qt_add_translation(TRANSLATIONS_QM ${TRANSLATIONS_TS})
set(TRANSLATIONS_QRC ${CMAKE_CURRENT_BINARY_DIR}/translations/translations.qrc)
file(WRITE ${TRANSLATIONS_QRC} "<RCC><qresource prefix=\"translations\">\n")
foreach (QM ${TRANSLATIONS_QM})
get_filename_component(QM_FILE ${QM} NAME)
file(APPEND ${TRANSLATIONS_QRC} "<file>${QM_FILE}</file>\n")
endforeach (QM)
file(APPEND ${TRANSLATIONS_QRC} "</qresource></RCC>")
qt_add_resources(TRANSLATIONS ${TRANSLATIONS_QRC})
endif() endif()
set(AUDIO_CORE src/audio_core/sdl_audio.cpp set(AUDIO_CORE src/audio_core/sdl_audio.cpp
@ -94,10 +142,13 @@ set(AUDIO_LIB src/core/libraries/audio/audioin.cpp
src/core/libraries/audio/audioout.h src/core/libraries/audio/audioout.h
src/core/libraries/ajm/ajm.cpp src/core/libraries/ajm/ajm.cpp
src/core/libraries/ajm/ajm.h src/core/libraries/ajm/ajm.h
src/core/libraries/ngs2/ngs2.cpp
src/core/libraries/ngs2/ngs2.h
) )
set(GNM_LIB src/core/libraries/gnmdriver/gnmdriver.cpp set(GNM_LIB src/core/libraries/gnmdriver/gnmdriver.cpp
src/core/libraries/gnmdriver/gnmdriver.h src/core/libraries/gnmdriver/gnmdriver.h
src/core/libraries/gnmdriver/gnm_error.h
) )
set(KERNEL_LIB set(KERNEL_LIB
@ -158,11 +209,28 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
src/core/libraries/app_content/app_content.h src/core/libraries/app_content/app_content.h
src/core/libraries/rtc/rtc.cpp src/core/libraries/rtc/rtc.cpp
src/core/libraries/rtc/rtc.h src/core/libraries/rtc/rtc.h
src/core/libraries/rtc/rtc_error.h
src/core/libraries/disc_map/disc_map.cpp src/core/libraries/disc_map/disc_map.cpp
src/core/libraries/disc_map/disc_map.h src/core/libraries/disc_map/disc_map.h
src/core/libraries/disc_map/disc_map_codes.h src/core/libraries/disc_map/disc_map_codes.h
src/core/libraries/avplayer/avplayer_common.cpp
src/core/libraries/avplayer/avplayer_common.h
src/core/libraries/avplayer/avplayer_file_streamer.cpp
src/core/libraries/avplayer/avplayer_file_streamer.h
src/core/libraries/avplayer/avplayer_impl.cpp
src/core/libraries/avplayer/avplayer_impl.h
src/core/libraries/avplayer/avplayer_source.cpp
src/core/libraries/avplayer/avplayer_source.h
src/core/libraries/avplayer/avplayer_state.cpp
src/core/libraries/avplayer/avplayer_state.h
src/core/libraries/avplayer/avplayer.cpp src/core/libraries/avplayer/avplayer.cpp
src/core/libraries/avplayer/avplayer.h src/core/libraries/avplayer/avplayer.h
src/core/libraries/ngs2/ngs2.cpp
src/core/libraries/ngs2/ngs2.h
src/core/libraries/ngs2/ngs2_error.h
src/core/libraries/ngs2/ngs2_impl.cpp
src/core/libraries/ngs2/ngs2_impl.h
src/core/libraries/ajm/ajm_error.h
) )
set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h
@ -172,21 +240,7 @@ set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h
src/core/libraries/videoout/video_out.h src/core/libraries/videoout/video_out.h
) )
set(LIBC_SOURCES src/core/libraries/libc/libc.cpp set(LIBC_SOURCES src/core/libraries/libc_internal/libc_internal.cpp
src/core/libraries/libc/libc.h
src/core/libraries/libc/printf.h
src/core/libraries/libc/va_ctx.h
src/core/libraries/libc/libc_cxa.cpp
src/core/libraries/libc/libc_cxa.h
src/core/libraries/libc/libc_stdio.cpp
src/core/libraries/libc/libc_stdio.h
src/core/libraries/libc/libc_math.cpp
src/core/libraries/libc/libc_math.h
src/core/libraries/libc/libc_string.cpp
src/core/libraries/libc/libc_string.h
src/core/libraries/libc/libc_stdlib.cpp
src/core/libraries/libc/libc_stdlib.h
src/core/libraries/libc_internal/libc_internal.cpp
src/core/libraries/libc_internal/libc_internal.h src/core/libraries/libc_internal/libc_internal.h
) )
@ -210,6 +264,11 @@ set(PLAYGO_LIB src/core/libraries/playgo/playgo.cpp
src/core/libraries/playgo/playgo_types.h src/core/libraries/playgo/playgo_types.h
) )
set(RANDOM_LIB src/core/libraries/random/random.cpp
src/core/libraries/random/random.h
src/core/libraries/random/random_error.h
)
set(USBD_LIB src/core/libraries/usbd/usbd.cpp set(USBD_LIB src/core/libraries/usbd/usbd.cpp
src/core/libraries/usbd/usbd.h src/core/libraries/usbd/usbd.h
) )
@ -221,6 +280,7 @@ set(NP_LIBS src/core/libraries/np_manager/np_manager.cpp
src/core/libraries/np_trophy/np_trophy.cpp src/core/libraries/np_trophy/np_trophy.cpp
src/core/libraries/np_trophy/np_trophy.h src/core/libraries/np_trophy/np_trophy.h
) )
set(MISC_LIBS src/core/libraries/screenshot/screenshot.cpp set(MISC_LIBS src/core/libraries/screenshot/screenshot.cpp
src/core/libraries/screenshot/screenshot.h src/core/libraries/screenshot/screenshot.h
) )
@ -258,6 +318,7 @@ set(COMMON src/common/logging/backend.cpp
src/common/native_clock.h src/common/native_clock.h
src/common/path_util.cpp src/common/path_util.cpp
src/common/path_util.h src/common/path_util.h
src/common/object_pool.h
src/common/polyfill_thread.h src/common/polyfill_thread.h
src/common/rdtsc.cpp src/common/rdtsc.cpp
src/common/rdtsc.h src/common/rdtsc.h
@ -269,9 +330,12 @@ set(COMMON src/common/logging/backend.cpp
src/common/thread.h src/common/thread.h
src/common/types.h src/common/types.h
src/common/uint128.h src/common/uint128.h
src/common/unique_function.h
src/common/version.h src/common/version.h
src/common/ntapi.h src/common/ntapi.h
src/common/ntapi.cpp src/common/ntapi.cpp
src/common/scm_rev.cpp
src/common/scm_rev.h
) )
set(CORE src/core/aerolib/stubs.cpp set(CORE src/core/aerolib/stubs.cpp
@ -280,6 +344,8 @@ set(CORE src/core/aerolib/stubs.cpp
src/core/aerolib/aerolib.h src/core/aerolib/aerolib.h
src/core/address_space.cpp src/core/address_space.cpp
src/core/address_space.h src/core/address_space.h
src/core/cpu_patches.cpp
src/core/cpu_patches.h
src/core/crypto/crypto.cpp src/core/crypto/crypto.cpp
src/core/crypto/crypto.h src/core/crypto/crypto.h
src/core/crypto/keys.h src/core/crypto/keys.h
@ -290,6 +356,8 @@ set(CORE src/core/aerolib/stubs.cpp
src/core/file_format/pkg_type.h src/core/file_format/pkg_type.h
src/core/file_format/psf.cpp src/core/file_format/psf.cpp
src/core/file_format/psf.h src/core/file_format/psf.h
src/core/file_format/playgo_chunk.cpp
src/core/file_format/playgo_chunk.h
src/core/file_format/trp.cpp src/core/file_format/trp.cpp
src/core/file_format/trp.h src/core/file_format/trp.h
src/core/file_format/splash.h src/core/file_format/splash.h
@ -318,6 +386,7 @@ set(CORE src/core/aerolib/stubs.cpp
${NP_LIBS} ${NP_LIBS}
${PNG_LIB} ${PNG_LIB}
${PLAYGO_LIB} ${PLAYGO_LIB}
${RANDOM_LIB}
${USBD_LIB} ${USBD_LIB}
${MISC_LIBS} ${MISC_LIBS}
${DIALOGS_LIB} ${DIALOGS_LIB}
@ -335,7 +404,6 @@ set(CORE src/core/aerolib/stubs.cpp
) )
set(SHADER_RECOMPILER src/shader_recompiler/exception.h set(SHADER_RECOMPILER src/shader_recompiler/exception.h
src/shader_recompiler/object_pool.h
src/shader_recompiler/profile.h src/shader_recompiler/profile.h
src/shader_recompiler/recompiler.cpp src/shader_recompiler/recompiler.cpp
src/shader_recompiler/recompiler.h src/shader_recompiler/recompiler.h
@ -362,7 +430,6 @@ set(SHADER_RECOMPILER src/shader_recompiler/exception.h
src/shader_recompiler/backend/spirv/spirv_emit_context.h src/shader_recompiler/backend/spirv/spirv_emit_context.h
src/shader_recompiler/frontend/translate/data_share.cpp src/shader_recompiler/frontend/translate/data_share.cpp
src/shader_recompiler/frontend/translate/export.cpp src/shader_recompiler/frontend/translate/export.cpp
src/shader_recompiler/frontend/translate/flat_memory.cpp
src/shader_recompiler/frontend/translate/scalar_alu.cpp src/shader_recompiler/frontend/translate/scalar_alu.cpp
src/shader_recompiler/frontend/translate/scalar_memory.cpp src/shader_recompiler/frontend/translate/scalar_memory.cpp
src/shader_recompiler/frontend/translate/translate.cpp src/shader_recompiler/frontend/translate/translate.cpp
@ -382,10 +449,11 @@ set(SHADER_RECOMPILER src/shader_recompiler/exception.h
src/shader_recompiler/frontend/opcodes.h src/shader_recompiler/frontend/opcodes.h
src/shader_recompiler/frontend/structured_control_flow.cpp src/shader_recompiler/frontend/structured_control_flow.cpp
src/shader_recompiler/frontend/structured_control_flow.h src/shader_recompiler/frontend/structured_control_flow.h
src/shader_recompiler/ir/passes/constant_propogation_pass.cpp src/shader_recompiler/ir/passes/constant_propagation_pass.cpp
src/shader_recompiler/ir/passes/dead_code_elimination_pass.cpp src/shader_recompiler/ir/passes/dead_code_elimination_pass.cpp
src/shader_recompiler/ir/passes/identity_removal_pass.cpp src/shader_recompiler/ir/passes/identity_removal_pass.cpp
src/shader_recompiler/ir/passes/ir_passes.h src/shader_recompiler/ir/passes/ir_passes.h
src/shader_recompiler/ir/passes/lower_shared_mem_to_registers.cpp
src/shader_recompiler/ir/passes/resource_tracking_pass.cpp src/shader_recompiler/ir/passes/resource_tracking_pass.cpp
src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp
src/shader_recompiler/ir/passes/ssa_rewrite_pass.cpp src/shader_recompiler/ir/passes/ssa_rewrite_pass.cpp
@ -419,6 +487,14 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp
src/video_core/amdgpu/pm4_cmds.h src/video_core/amdgpu/pm4_cmds.h
src/video_core/amdgpu/pm4_opcodes.h src/video_core/amdgpu/pm4_opcodes.h
src/video_core/amdgpu/resource.h src/video_core/amdgpu/resource.h
src/video_core/amdgpu/default_context.cpp
src/video_core/buffer_cache/buffer.cpp
src/video_core/buffer_cache/buffer.h
src/video_core/buffer_cache/buffer_cache.cpp
src/video_core/buffer_cache/buffer_cache.h
src/video_core/buffer_cache/memory_tracker_base.h
src/video_core/buffer_cache/range_set.h
src/video_core/buffer_cache/word_manager.h
src/video_core/renderer_vulkan/liverpool_to_vk.cpp src/video_core/renderer_vulkan/liverpool_to_vk.cpp
src/video_core/renderer_vulkan/liverpool_to_vk.h src/video_core/renderer_vulkan/liverpool_to_vk.h
src/video_core/renderer_vulkan/renderer_vulkan.cpp src/video_core/renderer_vulkan/renderer_vulkan.cpp
@ -445,14 +521,16 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp
src/video_core/renderer_vulkan/vk_resource_pool.h src/video_core/renderer_vulkan/vk_resource_pool.h
src/video_core/renderer_vulkan/vk_scheduler.cpp src/video_core/renderer_vulkan/vk_scheduler.cpp
src/video_core/renderer_vulkan/vk_scheduler.h src/video_core/renderer_vulkan/vk_scheduler.h
src/video_core/renderer_vulkan/vk_shader_cache.cpp
src/video_core/renderer_vulkan/vk_shader_cache.h
src/video_core/renderer_vulkan/vk_shader_util.cpp src/video_core/renderer_vulkan/vk_shader_util.cpp
src/video_core/renderer_vulkan/vk_shader_util.h src/video_core/renderer_vulkan/vk_shader_util.h
src/video_core/renderer_vulkan/vk_stream_buffer.cpp
src/video_core/renderer_vulkan/vk_stream_buffer.h
src/video_core/renderer_vulkan/vk_swapchain.cpp src/video_core/renderer_vulkan/vk_swapchain.cpp
src/video_core/renderer_vulkan/vk_swapchain.h src/video_core/renderer_vulkan/vk_swapchain.h
src/video_core/texture_cache/image.cpp src/video_core/texture_cache/image.cpp
src/video_core/texture_cache/image.h src/video_core/texture_cache/image.h
src/video_core/texture_cache/image_info.cpp
src/video_core/texture_cache/image_info.h
src/video_core/texture_cache/image_view.cpp src/video_core/texture_cache/image_view.cpp
src/video_core/texture_cache/image_view.h src/video_core/texture_cache/image_view.h
src/video_core/texture_cache/sampler.cpp src/video_core/texture_cache/sampler.cpp
@ -462,6 +540,11 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp
src/video_core/texture_cache/tile_manager.cpp src/video_core/texture_cache/tile_manager.cpp
src/video_core/texture_cache/tile_manager.h src/video_core/texture_cache/tile_manager.h
src/video_core/texture_cache/types.h src/video_core/texture_cache/types.h
src/video_core/page_manager.cpp
src/video_core/page_manager.h
src/video_core/multi_level_page_table.h
src/video_core/renderdoc.cpp
src/video_core/renderdoc.h
) )
set(INPUT src/input/controller.cpp set(INPUT src/input/controller.cpp
@ -474,12 +557,18 @@ set(EMULATOR src/emulator.cpp
src/sdl_window.cpp src/sdl_window.cpp
) )
# the above is shared in sdl and qt version (TODO share them all) # The above is shared in SDL and Qt version (TODO share them all)
if(ENABLE_QT_GUI) if(ENABLE_QT_GUI)
qt_add_resources(RESOURCE_FILES src/shadps4.qrc) qt_add_resources(RESOURCE_FILES src/shadps4.qrc)
set(QT_GUI set(QT_GUI src/qt_gui/about_dialog.cpp
src/qt_gui/about_dialog.h
src/qt_gui/about_dialog.ui
src/qt_gui/cheats_patches.cpp
src/qt_gui/cheats_patches.h
src/qt_gui/memory_patcher.cpp
src/qt_gui/memory_patcher.h
src/qt_gui/main_window_ui.h src/qt_gui/main_window_ui.h
src/qt_gui/main_window.cpp src/qt_gui/main_window.cpp
src/qt_gui/main_window.h src/qt_gui/main_window.h
@ -501,9 +590,13 @@ set(QT_GUI
src/qt_gui/elf_viewer.h src/qt_gui/elf_viewer.h
src/qt_gui/main_window_themes.cpp src/qt_gui/main_window_themes.cpp
src/qt_gui/main_window_themes.h src/qt_gui/main_window_themes.h
src/qt_gui/settings_dialog.cpp
src/qt_gui/settings_dialog.h
src/qt_gui/settings_dialog.ui
src/qt_gui/main.cpp src/qt_gui/main.cpp
${EMULATOR} ${EMULATOR}
${RESOURCE_FILES} ${RESOURCE_FILES}
${TRANSLATIONS}
) )
endif() endif()
@ -517,6 +610,7 @@ if (ENABLE_QT_GUI)
${SHADER_RECOMPILER} ${SHADER_RECOMPILER}
${VIDEO_CORE} ${VIDEO_CORE}
${EMULATOR} ${EMULATOR}
src/images/shadPS4.icns
) )
else() else()
add_executable(shadps4 add_executable(shadps4
@ -537,9 +631,24 @@ endif()
create_target_directory_groups(shadps4) create_target_directory_groups(shadps4)
target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient) target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient RenderDoc::API FFmpeg::ffmpeg)
target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::SPIRV glslang::glslang SDL3::SDL3) target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::SPIRV glslang::glslang SDL3::SDL3)
if (APPLE)
# Reserve system-managed memory space.
target_link_options(shadps4 PRIVATE -Wl,-no_pie,-no_fixup_chains,-no_huge,-pagezero_size,0x400000,-segaddr,GUEST_SYSTEM,0x400000,-image_base,0x10000000000)
# Link MoltenVK for Vulkan support
find_library(MOLTENVK MoltenVK REQUIRED)
target_link_libraries(shadps4 PRIVATE ${MOLTENVK})
# Replacement for std::chrono::time_zone
target_link_libraries(shadps4 PRIVATE date::date-tz)
# Half float conversions for F16C patches
target_link_libraries(shadps4 PRIVATE half)
endif()
if (NOT ENABLE_QT_GUI) if (NOT ENABLE_QT_GUI)
target_link_libraries(shadps4 PRIVATE SDL3::SDL3) target_link_libraries(shadps4 PRIVATE SDL3::SDL3)
endif() endif()
@ -551,27 +660,45 @@ else()
endif() endif()
if (ENABLE_QT_GUI) if (ENABLE_QT_GUI)
target_link_libraries(shadps4 PRIVATE Qt6::Widgets Qt6::Concurrent) target_link_libraries(shadps4 PRIVATE Qt6::Widgets Qt6::Concurrent Qt6::Network)
add_definitions(-DENABLE_QT_GUI)
endif() endif()
if (WIN32) if (WIN32)
target_link_libraries(shadps4 PRIVATE mincore winpthreads clang_rt.builtins-x86_64.lib) target_link_libraries(shadps4 PRIVATE mincore winpthreads)
if (MSVC)
# MSVC likes putting opinions on what people can use, disable:
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
endif()
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN) add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
if (MSVC) if (MSVC)
# Needed for conflicts with time.h of windows.h # Needed for conflicts with time.h of windows.h
add_definitions(-D_TIMESPEC_DEFINED) add_definitions(-D_TIMESPEC_DEFINED)
endif() endif()
# Target Windows 10 RS5 # Target Windows 10 RS5
add_definitions(-DNTDDI_VERSION=0x0A000006 -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00) add_definitions(-DNTDDI_VERSION=0x0A000006 -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00)
# Increase stack commit area
target_link_options(shadps4 PRIVATE /STACK:0x200000,0x200000) if (MSVC)
target_link_libraries(shadps4 PRIVATE clang_rt.builtins-x86_64.lib)
endif()
# Disable ASLR so we can reserve the user area # Disable ASLR so we can reserve the user area
if (MSVC) if (MSVC)
target_link_options(shadps4 PRIVATE /DYNAMICBASE:NO) target_link_options(shadps4 PRIVATE /DYNAMICBASE:NO)
else() else()
target_link_options(shadps4 PRIVATE -Wl,--disable-dynamicbase) target_link_options(shadps4 PRIVATE -Wl,--disable-dynamicbase)
endif() endif()
# Increase stack commit area (Needed, otherwise there are crashes)
if (MSVC)
target_link_options(shadps4 PRIVATE /STACK:0x200000,0x200000)
else()
target_link_options(shadps4 PRIVATE -Wl,--stack,2097152)
endif()
endif() endif()
if (WIN32) if (WIN32)
@ -592,5 +719,9 @@ target_include_directories(shadps4 PRIVATE ${HOST_SHADERS_INCLUDE})
if (ENABLE_QT_GUI) if (ENABLE_QT_GUI)
set_target_properties(shadps4 PROPERTIES set_target_properties(shadps4 PROPERTIES
# WIN32_EXECUTABLE ON # WIN32_EXECUTABLE ON
MACOSX_BUNDLE ON) MACOSX_BUNDLE ON
MACOSX_BUNDLE_ICON_FILE shadPS4.icns)
set_source_files_properties(src/images/shadPS4.icns PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
endif() endif()

View File

@ -31,7 +31,7 @@ Follow the indentation/whitespace style shown below. Do not use tabs, use 4-spac
* For doc-comments (Doxygen comments), use /// if it's a single line, else use the /** */ style featured in the example. Start the text on the second line, not the first containing /**. * For doc-comments (Doxygen comments), use /// if it's a single line, else use the /** */ style featured in the example. Start the text on the second line, not the first containing /**.
* For items that are both defined and declared in two separate files, put the doc-comment only next to the associated declaration. (In a header file, usually.) Otherwise, put it next to the implementation. Never duplicate doc-comments in both places. * For items that are both defined and declared in two separate files, put the doc-comment only next to the associated declaration. (In a header file, usually.) Otherwise, put it next to the implementation. Never duplicate doc-comments in both places.
``` ```c++
// Includes should be sorted lexicographically // Includes should be sorted lexicographically
// STD includes first // STD includes first
#include <array> #include <array>
@ -69,7 +69,7 @@ enum class SomeEnum {
* Note that the asterisks are indented by one space to align to the first line. * Note that the asterisks are indented by one space to align to the first line.
*/ */
struct Position { struct Position {
// Always intitialize member variables! // Always initialize member variables!
int x{}; int x{};
int y{}; int y{};
}; };

7
LICENSES/BSL-1.0.txt Normal file
View File

@ -0,0 +1,7 @@
Boost Software License - Version 1.0 - August 17th, 2003
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:
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.
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.

View File

@ -32,27 +32,30 @@ SPDX-License-Identifier: GPL-2.0-or-later
<img src="https://github.com/shadps4-emu/shadPS4/blob/main/documents/Screenshots/We are DOOMED.png" width="400"> <img src="https://github.com/shadps4-emu/shadPS4/blob/main/documents/Screenshots/We are DOOMED.png" width="400">
</p> </p>
# shadPS4 # General information
shadPS4 is an early PS4 emulator for Windows and Linux written in C++ shadPS4 is an early **PlayStation 4** emulator for **Windows**, **Linux** and **macOS** written in C++.
If you encounter problems or have doubts, do not hesitate to look at the [**Quickstart**](https://github.com/shadps4-emu/shadPS4/blob/main/documents/Quickstart/Quickstart.md). If you encounter problems or have doubts, do not hesitate to look at the [**Quickstart**](https://github.com/shadps4-emu/shadPS4/blob/main/documents/Quickstart/Quickstart.md).
To verify that a game works, you can look at [**shadPS4 Game Compatibility**](https://github.com/shadps4-emu/shadps4-game-compatibility). To verify that a game works, you can look at [**shadPS4 Game Compatibility**](https://github.com/shadps4-emu/shadps4-game-compatibility).
To discuss shadPS4 development or suggest ideas, join the [**Discord server**](https://discord.gg/MyZRaBngxA). To discuss shadPS4 development, suggest ideas or to ask for help, join our [**Discord server**](https://discord.gg/MyZRaBngxA).
Check us on [**X (twitter)**](https://x.com/shadps4) or on our [**website**](https://shadps4.net/). To get the latest news, go to our [**X (Twitter)**](https://x.com/shadps4) or our [**website**](https://shadps4.net/).
# Status # Status
In development, small games are working like [**Sonic Mania**](https://www.youtube.com/watch?v=AAHoNzhHyCU), [**Undertale**](https://youtu.be/5zIvdy65Ro4), [**Dysmantle**](https://youtu.be/b9xzhLBdESE) and others... > [!IMPORTANT]
> shadPS4 is early in developement, don't expect a flawless experience.
# Why? Currently, the emulator successfully runs small games like [**Sonic Mania**](https://www.youtube.com/watch?v=AAHoNzhHyCU), [**Undertale**](https://youtu.be/5zIvdy65Ro4) and it can even *somewhat* run [**Bloodborne**](https://www.youtube.com/watch?v=wC6s0avpQRE).
The project started as a fun project. Due to limited free time, it will probably take a while before shadPS4 is able to run anything decent, but we're trying to make small, regular commits. # Why
# Build This project began as a fun project. Given our limited free time, it may take some time before shadPS4 can run more complex games, but we're committed to making small, regular updates.
# Building
## Windows ## Windows
@ -62,21 +65,45 @@ Check the build instructions for [**Windows**](https://github.com/shadps4-emu/sh
Check the build instructions for [**Linux**](https://github.com/shadps4-emu/shadPS4/blob/main/documents/building-linux.md). Check the build instructions for [**Linux**](https://github.com/shadps4-emu/shadPS4/blob/main/documents/building-linux.md).
## Build status ## Building status
<details>
<summary><b>Windows</b></summary>
| Windows | Build status | | Windows | Build status |
|--------|------------| |--------|--------|
|Windows SDL Build|[![Windows-sdl](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows.yml) |Windows SDL Build|[![Windows-sdl](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows.yml)
|Windows Qt Build|[![Windows-qt](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows-qt.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows-qt.yml) |Windows Qt Build|[![Windows-qt](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows-qt.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows-qt.yml)
</details>
<details>
<summary><b>Linux</b></summary>
| Linux | Build status | | Linux | Build status |
|--------|------------| |--------|--------|
|Linux SDL Build|[![Linux-sdl](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux.yml) |Linux SDL Build|[![Linux-sdl](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux.yml)
|Linux Qt Build|[![Linux-qt](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux-qt.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux-qt.yml) |Linux Qt Build|[![Linux-qt](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux-qt.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux-qt.yml)
</details>
# Keyboard Mapping <details>
<summary><b>macOS</b></summary>
| Controller button | Keyboard | | macOS | Build status |
|--------|--------|
|macOS SDL Build|[![macOS-sdl](https://github.com/shadps4-emu/shadPS4/actions/workflows/macos.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/macos.yml)
|macOS Qt Build|[![macOS-qt](https://github.com/shadps4-emu/shadPS4/actions/workflows/macos-qt.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/macos-qt.yml)
</details>
# Debugging and reporting issues
For more information on how to test, debug and report issues with the emulator or games, read the [Debugging documentation](https://github.com/shadps4-emu/shadPS4/blob/main/documents/Debugging/Debugging.md).
# Keyboard mapping
> [!NOTE]
> Xbox and DualShock controllers work out of the box.
| Controller button | Keyboard equivelant |
|-------------|-------------| |-------------|-------------|
LEFT AXIS UP | W | LEFT AXIS UP | W |
LEFT AXIS DOWN | S | LEFT AXIS DOWN | S |
@ -123,7 +150,7 @@ Open a PR and we'll check it :)
# Contributors # Contributors
<a href="https://github.com/shadps4-emu/shadPS4/graphs/contributors"> <a href="https://github.com/shadps4-emu/shadPS4/graphs/contributors">
<img src="https://contrib.rocks/image?repo=shadps4-emu/shadPS4&max=15" /> <img src="https://contrib.rocks/image?repo=shadps4-emu/shadPS4&max=15">
</a> </a>
# Sister Projects # Sister Projects

23
cmake/FindFFmpeg.cmake Normal file
View File

@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
find_package(PkgConfig QUIET)
pkg_check_modules(FFMPEG QUIET IMPORTED_TARGET libavcodec libavfilter libavformat libavutil libswresample libswscale)
find_file(FFMPEG_VERSION_FILE libavutil/ffversion.h HINTS "${FFMPEG_libavutil_INCLUDEDIR}")
if (FFMPEG_VERSION_FILE)
file(STRINGS "${FFMPEG_VERSION_FILE}" FFMPEG_VERSION_LINE REGEX "FFMPEG_VERSION")
string(REGEX MATCH "[0-9.]+" FFMPEG_VERSION "${FFMPEG_VERSION_LINE}")
unset(FFMPEG_VERSION_LINE)
unset(FFMPEG_VERSION_FILE)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFmpeg
REQUIRED_VARS FFMPEG_LINK_LIBRARIES
VERSION_VAR FFMPEG_VERSION
)
if (FFmpeg_FOUND AND NOT TARGET FFmpeg::ffmpeg)
add_library(FFmpeg::ffmpeg ALIAS PkgConfig::FFMPEG)
endif()

25
cmake/FindRenderDoc.cmake Normal file
View File

@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
find_path(RENDERDOC_INCLUDE_DIR renderdoc_app.h)
if (RENDERDOC_INCLUDE_DIR AND EXISTS "${RENDERDOC_INCLUDE_DIR}/renderdoc_app.h")
file(STRINGS "${RENDERDOC_INCLUDE_DIR}/renderdoc_app.h" RENDERDOC_VERSION_LINE REGEX "typedef struct RENDERDOC_API")
string(REGEX REPLACE ".*typedef struct RENDERDOC_API_([0-9]+)_([0-9]+)_([0-9]+).*" "\\1.\\2.\\3" RENDERDOC_VERSION "${RENDERDOC_VERSION_LINE}")
unset(RENDERDOC_VERSION_LINE)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(RenderDoc
REQUIRED_VARS RENDERDOC_INCLUDE_DIR
VERSION_VAR RENDERDOC_VERSION
)
if (RenderDoc_FOUND AND NOT TARGET RenderDoc::API)
add_library(RenderDoc::API INTERFACE IMPORTED)
set_target_properties(RenderDoc::API PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${RENDERDOC_INCLUDE_DIR}"
)
endif()
mark_as_advanced(RENDERDOC_INCLUDE_DIR)

View File

@ -0,0 +1,156 @@
<!--
SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project
SPDX-License-Identifier: GPL-2.0-or-later
-->
# Debugging and reporting issues about shadPS4 and games
This document covers information about debugging, troubleshooting and reporting developer-side issues related to shadPS4 and games.
## Setup
This section will guide you through setting up tools for debugging the emulator. This list will likely expand as more tools and platforms receive consistent setups.
<details>
<summary>Windows and Visual Studio</summary>
Make sure you have the project set up for building on Windows with Visual Studio and CMake: [Build shadPS4 for Windows
](https://github.com/shadps4-emu/shadPS4/blob/main/documents/building-windows.md)
1. Open the project folder in Visual Studio **as a folder**. _Do not run `cmake ..` or other commands that set up the project._
2. In the Solution Explorer, click the **Switch between solutions and available views** button.\
![image](https://github.com/user-attachments/assets/4e2be2b1-ba5a-4451-9ab2-f4ecf246213d)
3. Double-click on **CMake Targets View**.\
![image](https://github.com/user-attachments/assets/5ce7cf90-cd61-4cfa-bef5-645909827290)
4. Under **shadPS4 Project**, right-click on the **shadps4 (executable)** solution and click **Set as Startup Item**. This will let you start and debug shadPS4 using the VS debug buttons, as well as the default F5 shortcut.\
![image](https://github.com/user-attachments/assets/34c7c047-28a3-499f-be8f-df781134d104)
5. Right-click the **shadps4 (executable)** solution once more and click **Add debug configuration**.
6. Add an `"args: []"` section into the first `configurations` entry.\
List your game path as an argument, as if you were launching the non-GUI emulator from the command line.
![image](https://github.com/user-attachments/assets/8c7c3e69-f38f-4d6b-bdfd-4f1c41c50be7)
7. Set the appropriate CMake configuration for debugging or testing.
- For debugging the emulator and games within it, select `x64-Clang-Debug`.
- For testing the emulator with compiler optimizations as a release build, it is recommended to select `x64-Clang-RelWithDebInfo`,
as debug symbols will still be generated in case you encounter release configuration-exclusive bugs/errors.
![image](https://github.com/user-attachments/assets/0d975f7a-7bea-4f89-87ef-5d685bea4381)
Launch and debug the emulator through **Debug > Start Debugging** (F5 by default), or **Debug > Start Without Debugging** (Ctrl+F5 by default) when testing games for performance.
</details>
## Configuration
You can configure the emulator by editing the `config.toml` file found in the `user` folder created after starting the application.
<details>
<summary>Some configuration entries worth changing</summary>
- `[General]`
- `logType`: Configures logging synchronization (`sync`/`async`)
- By default, the emulator logs messages asynchronously for better performance. Some log messages may end up being received out-of-order.
- It can be beneficial to set this to `sync` in order for the log to accurately maintain message order, at the cost of performance.
- When communicating about issues with games and the log messages aren't clear due to potentially confusing order, set this to `sync` and send that log as well.
- `logFilter`: Sets the logging category for various logging classes.
- Format: `<class>:<level> ...`
- Multiple classes can be set by separating them with a space. (example: `Render:Warning Debug:Critical Lib.Pad:Error`)
- Sub-classes can be specified in the same format as seen in the console/log (such as `Core.Linker`).
- All classes and sub-classes can be set by specifying a `*` symbol. (example: `Kernel.*:Critical`)
- Valid log levels: `Trace, Debug, Info, Warning, Error, Critical` - in this order, setting a level silences all levels preceding it and logs every level after it.
- Examples:
- If the log is being spammed with messages coming from Lib.Pad, you can use `Lib.Pad:Critical` to only log critical-level messages.
- If you'd like to mute everything, but still want to receive messages from Vulkan rendering: `*:Critical Render.Vulkan:Info`
- `Fullscreen`: Display the game in a full screen borderless window.
- `[GPU]`
- `dumpShaders`: Dump shaders that are loaded by the emulator. Dump path: `../user/shader/dumps`
- `nullGpu`: Disables rendering.
- `screenWidth` and `screenHeight`: Configures the game window width and height.
- `[Vulkan]`
- `validation`-related settings: Use when debugging Vulkan.
- `rdocEnable`: Automatically hook RenderDoc when installed. Useful for debugging shaders and game rendering.
- `rdocMarkersEnable`: Enable automatic RenderDoc event annotation
- `[LLE]`
- `libc`: Use LLE with `libc`.
</details>
## Quick analysis
This section will provide some preliminary steps to take and tips on what to do when you encounter scenarios that require debugging.
<details open>
<summary>When a game crashes and breaks in the debugger</summary>
1. Analyze the log
- A console will open by default when you launch the emulator. It shows the same log messages that go into the log file found at `<emulator executable>/user/log/shad_log.txt`.
- It is recommended that you start analyzing the log bottom-up first:
- Are there any critical or error-level messages at the end of the log that would point to a reason for the game crashing?
- Do any of the last few messages contain information about the game loading files?
- Did the game window draw anything on-screen?
- Continue analyzing the log from the start to see other errors (such as with initialization, memory mapping, linker errors etc.)
2. Analyze the stack trace
- When the emulator is launched through a debugger, it will **break** when an exception or violation is encountered.\
_(**breaking** in this context means pausing execution of the program before it continues or stops altogether.
Breaks can be intentional as well - these are set with various kinds of **breakpoints**.)_
- Default setups of most debuggers include a **Stack trace** window/panel that lists the functions the program has called before breaking.
- The stack trace entries can be navigated to and will show the relevant function, as well as switch to the state that the program was in at the time of execution.\
Use the **Locals** and **Watch** windows to investigate variables and other code in these contexts.
3. Identify the reason for the crash
- **Logs aren't always accurate in determining the reason for a crash.**\
Some log entries are reported as errors but may not be fatal for the execution to stop. `Critical` entries are most likely to be the cause for crashes.
- Pinpoint the area of the emulator where the crash occured\
If the stack trace ends with functions that are relevant to rendering, it is safe to assume that the issue is with **rendering**.\
Similarly, if a crash is in a library responsible for playing videos, your issue can be narrowed down to the scope of video playback in the emulator.
- **⚠ Some crashes are intentional**
- If you identify **Access violations for writing operations** where the function is (or in cases of game libraries, _looks like_ it is) copying memory,
it most likely is an **intentional exception** meant to catch game data being written by the game.
This is used by the emulator developers to identify procedures that have to do with game data changing.
- Debugging tools usually include an option to not break on certain types of exceptions. **Exclude access violations and other intentional exceptions when debugging to skip these exceptions.**
- You can also identify such cases if the game works in Release builds of the emulator. These intentional exceptions are development-time only.
- Attempt to **Continue** and observe whether the stack trace and/or variables and registers change when you encounter exceptions.
</details>
## Reporting and communicating about issues
When communicating with the project about game-specific issues, specify an **uniquely identifable game name** along with its `CUSA-xxxxx` code that is specific to the region/variant of the game you're testing.\
The version number is also important to add at least in the description, especially if you can verify that the game behaves differently across versions.\
Accurately identifying games will help other developers that own that game recognize your issue by its title and jump in to help test and debug it.
- Examples of good naming schemes:
- Amplitude (2016) `CUSA02480`
- Rock Band 4 (`CUSA02084`) v1.0
- inFamous: Second Son \[`CUSA-00004`\]
- Examples of unideal naming schemes:
- _The Witness_
- _GTA 5_
- _Watch Dogs_
- If your issue is small or you aren't sure whether you have properly identified something, [join the Discord server](https://discord.gg/MyZRaBngxA) and use the #development channel
to concisely explain the issue, as well as any findings you currently have.
- It is recommended that you check the [game compatibility issue tracker](https://github.com/shadps4-emu/shadps4-game-compatibility/issues) and post very short summaries of progress changes there,
(such as the game now booting into the menu or getting in-game) for organizational and status update purposes.
- ⚠ **Do not post theoretical, unproven game-specific issues in the emulator issue tracker that you cannot verify and locate in the emulator source code as being a bug.**\
Do, however, add information about the game you experienced the issue in, so that it can be tested in a reproducible environment.
- Good example: "_Crash in `Shader::Gcn::CFG::EmitBlocks()`, out of bounds list access_" -> _issue description shares stack trace, points to code in the repository and provides relevant information_
- Bad example: "_Amplitude crashes on boot, access violation_" -> _issue description reiterates title, focuses on the game instead of the emulator and refuses to elaborate_

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

View File

@ -37,13 +37,18 @@ SPDX-License-Identifier: GPL-2.0-or-later
- Windows 10 or Ubuntu 22.04 - Windows 10 or Ubuntu 22.04
## Have the latest WIP version ## How to run the latest Work-in-Progress builds of ShadPS4
When you go to Github Release, you have the latest major versions (e.g. v0.0.3), but if you want to have the latest Work-In-Progress version, you can go to Actions on Github to download it (Please note a Github account is required to be able to download). 1. Go to <https://github.com/shadps4-emu/shadPS4/actions> and make sure you are logged into your GitHub account (important!)
2. On the left side of the page, select your operating system of choice (the "**qt**" versions have a user interface, which is probably the one you want. The others are SDL versions, which can only be run via command line). ![image](https://github.com/user-attachments/assets/43f01bbf-236c-4d6d-98ac-f5a5badd4ce8)
<img src="https://github.com/shadps4-emu/shadPS4/blob/main/documents/Quickstart/1.png" width="800"></a> 3. In the workflow list, select the latest entry with a green :white_check_mark: icon in front of it. (or the latest entry for whatever pull request you wish to test). ![image](https://github.com/user-attachments/assets/6365f407-867c-44ae-bf00-944f8d84a349)
After downloading the version suitable for you (Windows or Linux), you must unzip the file and then you can run it. Please note, there are two versions for each platform, a Qt version with user interface and one without (SDL Builds). 4. On the bottom of this page, select the name of the file, and it should start downloading. (If there is no file here, double check that you are indeed logged into a GitHub account, and that there is a green :white_check_mark: icon. ![image](https://github.com/user-attachments/assets/97924500-3911-4f90-ab63-ffae7e52700b)
5. Once downloaded, extract to its own folder, and run ShadPS4's executable from the extracted folder.
6. Upon first launch, ShadPS4 will prompt you to select a folder to store your installed games in. Select "Browse" and then select a folder that ShadPS4 can use to install your PKG files to.
## Install PKG files ## Install PKG files
@ -53,4 +58,24 @@ To install PKG files (game and updates), you will need the Qt application (with
## Configure the emulator ## Configure the emulator
You can configure the emulator in the "user" folder (created after the first start of the application) then in the "config.toml" file. Here you can find lots of parameters to set with True or False. You can configure the emulator by editing the `config.toml` file found in the `user` folder created after starting the application.\
Some settings may be related to more technical development and debugging. For more information on those, see [Debugging](https://github.com/shadps4-emu/shadPS4/blob/main/documents/Debugging/Debugging.md#configuration).
Here's a list of configuration entries that are worth changing:
- `[General]`
- `Fullscreen`: Display the game in a full screen borderless window.
- `logType`: Configures logging synchronization (`sync`/`async`)
- It can be beneficial to set this to `sync` in order for the log to accurately maintain message order, at the cost of performance.
- Use when sending logs to developers. See more about [reporting issues](https://github.com/shadps4-emu/shadPS4/blob/main/documents/Debugging/Debugging.md#reporting-and-communicating-about-issues).
- `logFilter`: Sets the logging category for various logging classes.
- Format: `<class>:<level> ...`, `<class.*>:<level> <*:level> ...`
- Valid log levels: `Trace, Debug, Info, Warning, Error, Critical` - in this order, setting a level silences all levels preceding it and logs every level after it.
- Examples:
- If the log is being spammed with messages coming from Lib.Pad, you can use `Lib.Pad:Critical` to only log critical-level messages.
- If you'd like to mute everything, but still want to receive messages from Vulkan rendering: `*:Error Render.Vulkan:Info`
- `[GPU]`
- `screenWidth` and `screenHeight`: Configures the game window width and height.

View File

@ -5,21 +5,96 @@ SPDX-License-Identifier: GPL-2.0-or-later
# Build shadPS4 for Windows # Build shadPS4 for Windows
## Download Visual Studio Community 2022 This tutorial reads as if you have none of the prerequisites already installed. If you do, just ignore the steps regarding installation.
If you are building to contribute to the project, please omit `--depth 1` from the git invokations.
Download link: [**Visual Studio 2022**](https://visualstudio.microsoft.com/vs/) Note: **ARM64 is not supported!** As of writing, it will not build nor run. The instructions with respect to ARM64 are for developers only.
## Requirements ## Option 1: Visual Studio 2022
### From Visual Studio Community ### (Prerequisite) Download the Community edition from [**Visual Studio 2022**](https://visualstudio.microsoft.com/vs/)
- Desktop development with C++ Once you are within the installer:
1. Select `Desktop development with C++`
2. Go to "Individual Components" tab
3. Search and select `C++ Clang Compiler for Windows` and `MSBuild support for LLVM`
4. Continue the installation
### From individual components tab install ### (Prerequisite) Download [**Qt**](https://doc.qt.io/qt-6/get-and-install-qt.html)
- C++ Clang Compiler for Windows (17.0.3) Beware, this requires you to create a Qt account. If you do not want to do this, please follow the MSYS2/MinGW compilation method instead.
- MSBuild support for LLVM (Clang-cl) toolset
- ## Compiling 1. Under the current, non beta version of Qt (at the time of writing 6.7.2), select the option `MSVC 2019 64-bit` or similar.
If you are on Windows on ARM / Qualcomm Snapdragon Elite X, select `MSVC 2019 ARM64` instead.
- Open Visual Studio Community and select the **x64-Clang-Release**, **x64-Clang-Debug** or **x64-Clang-RelWithDebInfo**. It should compile just fine. Go through the installation normally. If you know what you are doing, you may unselect individual components that eat up too much disk space.
2. Download and install [Qt Visual Studio Tools](https://marketplace.visualstudio.com/items?itemName=TheQtCompany.QtVisualStudioTools2022)
Once you are finished, you will have to configure Qt within Visual Studio:
1. Tools -> Options -> Qt -> Versions
2. Add a new Qt version and navigate it to the correct folder. Should look like so: `C:\Qt\6.7.2\msvc2019_64`
3. Enable the default checkmark on the new version you just created.
### (Prerequisite) Download [**Git for Windows**](https://git-scm.com/download/win)
Go through the Git for Windows installation as normal
### Cloning the source code
1. Open Git for Windows, navigate to a place where you want to store the shadPS4 source code folder
2. Clone the repository by running
`git clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4`
### Compiling with Visual Studio GUI
1. Open up Visual Studio, select `Open a local folder` and select the folder with the shadPS4 source code. The folder should contain `CMakeLists.txt`
2. Change x64-Clang-Debug to x64-Clang-Release if you want a regular, non-debug build.
3. If you want to build shadPS4 with the Qt Gui:
1. Click x64-Clang-Release and select "Manage Configurations"
2. Look for "CMake command arguments" and add to the text field
`-DENABLE_QT_GUI=ON -DCMAKE_PREFIX_PATH=C:\Qt\6.7.2\msvc2019_64`
(Change Qt path if you've installed it to non-default path)
3. Press CTRL+S to save and wait a moment for CMake generation
4. Change the project to build to shadps4.exe
5. Build -> Build All
Your shadps4.exe will be in `c:\path\to\source\Build\x64-Clang-Release\`
To automatically populate the necessary files to run shadPS4.exe, run in a command prompt or terminal:
`C:\Qt\6.7.2\msvc2019_64\bin\windeployqt.exe c:\path\to\shadps4.exe`
(Change Qt path if you've installed it to non-default path)
## Option 2: MSYS2/MinGW
### (Prerequisite) Download [**MSYS2**](https://www.msys2.org/)
Go through the MSYS2 installation as normal
If you are building to distribute, please omit `-DCMAKE_CXX_FLAGS="-O2 -march=native"` within the build configuration step.
Normal x86-based computers, follow:
1. Open "MSYS2 MINGW64" from your new applications
2. Run `pacman -Syu`, let it complete;
3. Run `pacman -S --needed git mingw-w64-x86_64-binutils mingw-w64-x86_64-clang mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-qt6-base`
4. Run `git clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4`
5. Run `cd shadPS4`
6. Run `cmake -S . -B build -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_FLAGS="-O2 -march=native"`
7. Run `cmake --build build`
8. To run the finished product, run `./build/shadPS4.exe`
ARM64-based computers, follow:
1. Open "MSYS2 CLANGARM64" from your new applications
2. Run `pacman -Syu`, let it complete;
3. Run `pacman -S --needed git mingw-w64-clang-aarch64-binutils mingw-w64-clang-aarch64-clang mingw-w64-clang-aarch64-cmake mingw-w64-clang-aarch64-ninja mingw-w64-clang-aarch64-qt6-base`
4. Run `git clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4`
5. Run `cd shadPS4`
6. Run `cmake -S . -B build -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_FLAGS="-O2 -march=native"`
7. Run `cmake --build build`
8. To run the finished product, run `./build/shadPS4.exe`
## Note on MSYS2 builds
These builds may not be easily copyable to people who do not also have a MSYS2 installation.
If you want to distribute these builds, you need to copy over the correct DLLs into a distribution folder.
In order to run them, you must be within the MSYS2 shell environment.

View File

@ -1,3 +1,15 @@
v0.2.0 15/08/2024 - codename validptr
=================
- Adding macOS support
- Big shader recompiler improvements
- Core improvements
- GUI improvements
v0.1.0 01/07/2024 - codename madturtle
=================
- Added a shader recompiler, with this we have a lot of games that starts to work
- Rewrote a big part of core
v0.0.3 23/03/2024 - codename salad v0.0.3 23/03/2024 - codename salad
================= =================
- Switching to std::thread - Switching to std::thread
@ -12,21 +24,21 @@ v0.0.3 23/03/2024 - codename salad
- Initial TLS work - Initial TLS work
- New logging implementation - New logging implementation
- Some functions implemented for userService, systemService - Some functions implemented for userService, systemService
-Added sceAudioOut module and output using sdl audio - Added sceAudioOut module and output using SDL audio
v0.0.2 21/10/2023 v0.0.2 21/10/2023
================= =================
-using cstdint header in variable types - Using cstdint header in variable types
- run_main_entry: Rewrite in asm for stack setup - run_main_entry: Rewrite in asm for stack setup
-printf libc implementation for work with sysv_abi - Printf libc implementation for work with sysv_abi
-initial pad emulation (only digital pad atm) - Initial pad emulation (only digital pad atm)
- Implemented sceVideoOutIsFlipPending - Implemented sceVideoOutIsFlipPending
- Added auto stubs, now unsupported hle function will resolve as empty stubs - Added auto stubs, now unsupported hle function will resolve as empty stubs
- Rewrote libc_cxa functions - Rewrote libc_cxa functions
- Libc implementations ( _ZdlPv,_Znwm,rand,_Fsin,qsort,free,strncpy,memmove,atan2f,pow,_Sin) - Libc implementations ( _ZdlPv,_Znwm,rand,_Fsin,qsort,free,strncpy,memmove,atan2f,pow,_Sin)
-ET_SCE_DYNAMIC behaves as valid for execution now. - ET_SCE_DYNAMIC behaves as valid for execution now
-Initial FileSystem work (not yet usable). - Initial FileSystem work (not yet usable)
v0.0.1 29/09/2023 v0.0.1 29/09/2023
================= =================
First public release . Everything is new First public release. Everything is new.

View File

@ -1,35 +0,0 @@
shadPS4 - A PS4 emulator
=========================
1. Intro
2. Current status
3. Contributors
4. Greetings
1.Intro
=======
shadPS4 is a Play Station 4 emulator for Windows and Linux. Although atm it can't run a lot of stuff, we are working torwards to make it more compatible.
2.Current status
================
shadPS4 is a HLE emulator. Currently on a small amount of functions is emulated, which is one of the reasons compatibility is low.
3.Contributors
==============
- georgemoralis
- raphaelthegreat
- skmp
- wheremyfoodat
4.Greetings
===========
I would like to thank the following people for helping me so far, with coding or moral support.
- wheremyfoodat - or @rodakinos for believed me
- paris - or OFFTKP for not believing me and that made me a better coder :D
- skmp - or kornilios for being good old friend
- PandaBad - our beloved stalker
- emufan4568 - for advices
- velocity - for talking 1-2 times per year on discord server. We miss you velocity
- probably more, will include in the next readme :D

View File

@ -25,11 +25,6 @@ if (NOT TARGET fmt::fmt)
add_subdirectory(fmt) add_subdirectory(fmt)
endif() endif()
# Discord-RPC
set(BUILD_EXAMPLES OFF CACHE BOOL "")
add_subdirectory(discord-rpc)
target_include_directories(discord-rpc INTERFACE ./discord-rpc/include)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND MSVC) if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND MSVC)
# If it is clang and MSVC we will add a static lib # If it is clang and MSVC we will add a static lib
# CryptoPP # CryptoPP
@ -47,6 +42,12 @@ else()
endif() endif()
endif() endif()
if (NOT TARGET FFmpeg::ffmpeg)
set(ARCHITECTURE "x86_64")
add_subdirectory(ffmpeg-core)
add_library(FFmpeg::ffmpeg ALIAS ffmpeg)
endif()
# Zlib-Ng # Zlib-Ng
if (NOT TARGET zlib-ng::zlib) if (NOT TARGET zlib-ng::zlib)
set(ZLIB_ENABLE_TESTS OFF) set(ZLIB_ENABLE_TESTS OFF)
@ -74,6 +75,13 @@ if (NOT TARGET GPUOpen::VulkanMemoryAllocator)
add_subdirectory(vma) add_subdirectory(vma)
endif() endif()
# RenderDoc
if (NOT TARGET RenderDoc::API)
add_library(renderdoc INTERFACE)
target_include_directories(renderdoc SYSTEM INTERFACE ./renderdoc)
add_library(RenderDoc::API ALIAS renderdoc)
endif()
# glslang # glslang
if (NOT TARGET glslang::glslang) if (NOT TARGET glslang::glslang)
set(SKIP_GLSLANG_INSTALL ON CACHE BOOL "") set(SKIP_GLSLANG_INSTALL ON CACHE BOOL "")
@ -134,10 +142,29 @@ if (WIN32)
target_compile_options(sirit PUBLIC "-Wno-error=unused-command-line-argument") target_compile_options(sirit PUBLIC "-Wno-error=unused-command-line-argument")
endif() endif()
if (APPLE)
# half
add_library(half INTERFACE)
target_include_directories(half INTERFACE half/include)
# date
if (NOT TARGET date::date-tz)
option(BUILD_TZ_LIB "" ON)
option(USE_SYSTEM_TZ_DB "" ON)
add_subdirectory(date)
endif()
endif()
# Tracy # Tracy
option(TRACY_ENABLE "" ON) option(TRACY_ENABLE "" ON)
option(TRACY_NO_CRASH_HANDLER "" ON) # Otherwise texture cache exceptions will be treaten as a crash option(TRACY_NO_CRASH_HANDLER "" ON) # Otherwise texture cache exceptions will be treaten as a crash
option(TRACY_ON_DEMAND "" ON) option(TRACY_ON_DEMAND "" ON)
option(TRACY_NO_FRAME_IMAGE "" ON) option(TRACY_NO_FRAME_IMAGE "" ON)
option(TRACY_FIBERS "" ON) # For AmdGpu frontend profiling option(TRACY_FIBERS "" ON) # For AmdGpu frontend profiling
option(TRACY_NO_SYSTEM_TRACING "" ON)
option(TRACY_NO_CALLSTACK "" ON)
option(TRACY_NO_CODE_TRANSFER "" ON)
option(TRACY_NO_SAMPLING "" ON)
option(TRACY_ONLY_LOCALHOST "" ON)
option(TRACY_NO_CONTEXT_SWITCH "" ON)
add_subdirectory(tracy) add_subdirectory(tracy)

View File

@ -0,0 +1,158 @@
# - Returns a version string from Git
#
# These functions force a re-configure on each git commit so that you can
# trust the values of the variables in your build system.
#
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
#
# Returns the refspec and sha hash of the current head revision
#
# git_describe(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the source tree, and adjusting
# the output so that it tests false if an error occurs.
#
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe --exact-match on the source tree,
# and adjusting the output so that it tests false if there was no exact
# matching tag.
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(__get_git_revision_description)
return()
endif()
set(__get_git_revision_description YES)
# We must run the following at "include" time, not at function call time,
# to find the path to this module rather than the path to a calling list file
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
function(get_git_head_revision _refspecvar _hashvar)
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
# We have reached the root directory, we are not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
endif()
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
endwhile()
# check if this is a submodule
if(NOT IS_DIRECTORY ${GIT_DIR})
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
endif()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")
file(MAKE_DIRECTORY "${GIT_DATA}")
endif()
if(NOT EXISTS "${GIT_DIR}/HEAD")
return()
endif()
set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
"${GIT_DATA}/grabRef.cmake"
@ONLY)
include("${GIT_DATA}/grabRef.cmake")
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
endfunction()
function(git_branch_name _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
execute_process(COMMAND
"${GIT_EXECUTABLE}"
rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
#get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
#if(NOT hash)
# set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
# return()
#endif()
# TODO sanitize
#if((${ARGN}" MATCHES "&&") OR
# (ARGN MATCHES "||") OR
# (ARGN MATCHES "\\;"))
# message("Please report the following error to the project!")
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
#endif()
#message(STATUS "Arguments to execute_process: ${ARGN}")
execute_process(COMMAND
"${GIT_EXECUTABLE}"
describe
${hash}
${ARGN}
WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN})
set(${_var} "${out}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,42 @@
#
# Internal file for GetGitRevisionDescription.cmake
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
set(HEAD_HASH)
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
if(HEAD_CONTENTS MATCHES "ref")
# named branch
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
set(HEAD_HASH "${HEAD_REF}")
endif()
else()
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
endif()
if(NOT HEAD_HASH)
if(EXISTS "@GIT_DATA@/head-ref")
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
else()
set(HEAD_HASH "Unknown")
endif()
endif()

1
externals/date vendored Submodule

@ -0,0 +1 @@
Subproject commit 1ead6715dec030d340a316c927c877a3c4e5a00c

@ -1 +0,0 @@
Subproject commit 4ec218155d73bcb8022f8f7ca72305d801f84beb

2
externals/ext-boost vendored

@ -1 +1 @@
Subproject commit 147b2de7734f5dc3b9aeb1f4135ae15fcd44b9d7 Subproject commit a04136add1e469f46d8ae8d3e8307779240a5c53

1
externals/ffmpeg-core vendored Submodule

@ -0,0 +1 @@
Subproject commit e30b7d7fe228bfb3f6e41ce1040b44a15eb7d5e0

2
externals/fmt vendored

@ -1 +1 @@
Subproject commit a96259701e1d16e2f8c8299c668e863ec0ac0119 Subproject commit c98518351efd5a46f5d448e947e0b7242d197d07

2
externals/glslang vendored

@ -1 +1 @@
Subproject commit 5939e32b87487fa9c72ab336ebfcc5ae26d9ab6d Subproject commit 12cbda959b6df2af119a76a73ff906c2bed36884

1
externals/half vendored Submodule

@ -0,0 +1 @@
Subproject commit 1ddada225144cac0de8f6b5c0dd9acffd99a2e68

@ -1 +1 @@
Subproject commit ec1adc5763f684e0f32888b157bfc0b86021b8e9 Subproject commit dae6bbf16c363e9ead4e628a47fdb02956a634f3

741
externals/renderdoc/renderdoc_app.h vendored Normal file
View File

@ -0,0 +1,741 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2019-2024 Baldur Karlsson
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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.
******************************************************************************/
#pragma once
//////////////////////////////////////////////////////////////////////////////////////////////////
//
// Documentation for the API is available at https://renderdoc.org/docs/in_application_api.html
//
#if !defined(RENDERDOC_NO_STDINT)
#include <stdint.h>
#endif
#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
#define RENDERDOC_CC __cdecl
#elif defined(__linux__) || defined(__FreeBSD__)
#define RENDERDOC_CC
#elif defined(__APPLE__)
#define RENDERDOC_CC
#else
#error "Unknown platform"
#endif
#ifdef __cplusplus
extern "C" {
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////
// Constants not used directly in below API
// This is a GUID/magic value used for when applications pass a path where shader debug
// information can be found to match up with a stripped shader.
// the define can be used like so: const GUID RENDERDOC_ShaderDebugMagicValue =
// RENDERDOC_ShaderDebugMagicValue_value
#define RENDERDOC_ShaderDebugMagicValue_struct \
{ \
0xeab25520, 0x6670, 0x4865, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff \
}
// as an alternative when you want a byte array (assuming x86 endianness):
#define RENDERDOC_ShaderDebugMagicValue_bytearray \
{ \
0x20, 0x55, 0xb2, 0xea, 0x70, 0x66, 0x65, 0x48, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff \
}
// truncated version when only a uint64_t is available (e.g. Vulkan tags):
#define RENDERDOC_ShaderDebugMagicValue_truncated 0x48656670eab25520ULL
//////////////////////////////////////////////////////////////////////////////////////////////////
// RenderDoc capture options
//
typedef enum RENDERDOC_CaptureOption
{
// Allow the application to enable vsync
//
// Default - enabled
//
// 1 - The application can enable or disable vsync at will
// 0 - vsync is force disabled
eRENDERDOC_Option_AllowVSync = 0,
// Allow the application to enable fullscreen
//
// Default - enabled
//
// 1 - The application can enable or disable fullscreen at will
// 0 - fullscreen is force disabled
eRENDERDOC_Option_AllowFullscreen = 1,
// Record API debugging events and messages
//
// Default - disabled
//
// 1 - Enable built-in API debugging features and records the results into
// the capture, which is matched up with events on replay
// 0 - no API debugging is forcibly enabled
eRENDERDOC_Option_APIValidation = 2,
eRENDERDOC_Option_DebugDeviceMode = 2, // deprecated name of this enum
// Capture CPU callstacks for API events
//
// Default - disabled
//
// 1 - Enables capturing of callstacks
// 0 - no callstacks are captured
eRENDERDOC_Option_CaptureCallstacks = 3,
// When capturing CPU callstacks, only capture them from actions.
// This option does nothing without the above option being enabled
//
// Default - disabled
//
// 1 - Only captures callstacks for actions.
// Ignored if CaptureCallstacks is disabled
// 0 - Callstacks, if enabled, are captured for every event.
eRENDERDOC_Option_CaptureCallstacksOnlyDraws = 4,
eRENDERDOC_Option_CaptureCallstacksOnlyActions = 4,
// Specify a delay in seconds to wait for a debugger to attach, after
// creating or injecting into a process, before continuing to allow it to run.
//
// 0 indicates no delay, and the process will run immediately after injection
//
// Default - 0 seconds
//
eRENDERDOC_Option_DelayForDebugger = 5,
// Verify buffer access. This includes checking the memory returned by a Map() call to
// detect any out-of-bounds modification, as well as initialising buffers with undefined contents
// to a marker value to catch use of uninitialised memory.
//
// NOTE: This option is only valid for OpenGL and D3D11. Explicit APIs such as D3D12 and Vulkan do
// not do the same kind of interception & checking and undefined contents are really undefined.
//
// Default - disabled
//
// 1 - Verify buffer access
// 0 - No verification is performed, and overwriting bounds may cause crashes or corruption in
// RenderDoc.
eRENDERDOC_Option_VerifyBufferAccess = 6,
// The old name for eRENDERDOC_Option_VerifyBufferAccess was eRENDERDOC_Option_VerifyMapWrites.
// This option now controls the filling of uninitialised buffers with 0xdddddddd which was
// previously always enabled
eRENDERDOC_Option_VerifyMapWrites = eRENDERDOC_Option_VerifyBufferAccess,
// Hooks any system API calls that create child processes, and injects
// RenderDoc into them recursively with the same options.
//
// Default - disabled
//
// 1 - Hooks into spawned child processes
// 0 - Child processes are not hooked by RenderDoc
eRENDERDOC_Option_HookIntoChildren = 7,
// By default RenderDoc only includes resources in the final capture necessary
// for that frame, this allows you to override that behaviour.
//
// Default - disabled
//
// 1 - all live resources at the time of capture are included in the capture
// and available for inspection
// 0 - only the resources referenced by the captured frame are included
eRENDERDOC_Option_RefAllResources = 8,
// **NOTE**: As of RenderDoc v1.1 this option has been deprecated. Setting or
// getting it will be ignored, to allow compatibility with older versions.
// In v1.1 the option acts as if it's always enabled.
//
// By default RenderDoc skips saving initial states for resources where the
// previous contents don't appear to be used, assuming that writes before
// reads indicate previous contents aren't used.
//
// Default - disabled
//
// 1 - initial contents at the start of each captured frame are saved, even if
// they are later overwritten or cleared before being used.
// 0 - unless a read is detected, initial contents will not be saved and will
// appear as black or empty data.
eRENDERDOC_Option_SaveAllInitials = 9,
// In APIs that allow for the recording of command lists to be replayed later,
// RenderDoc may choose to not capture command lists before a frame capture is
// triggered, to reduce overheads. This means any command lists recorded once
// and replayed many times will not be available and may cause a failure to
// capture.
//
// NOTE: This is only true for APIs where multithreading is difficult or
// discouraged. Newer APIs like Vulkan and D3D12 will ignore this option
// and always capture all command lists since the API is heavily oriented
// around it and the overheads have been reduced by API design.
//
// 1 - All command lists are captured from the start of the application
// 0 - Command lists are only captured if their recording begins during
// the period when a frame capture is in progress.
eRENDERDOC_Option_CaptureAllCmdLists = 10,
// Mute API debugging output when the API validation mode option is enabled
//
// Default - enabled
//
// 1 - Mute any API debug messages from being displayed or passed through
// 0 - API debugging is displayed as normal
eRENDERDOC_Option_DebugOutputMute = 11,
// Option to allow vendor extensions to be used even when they may be
// incompatible with RenderDoc and cause corrupted replays or crashes.
//
// Default - inactive
//
// No values are documented, this option should only be used when absolutely
// necessary as directed by a RenderDoc developer.
eRENDERDOC_Option_AllowUnsupportedVendorExtensions = 12,
// Define a soft memory limit which some APIs may aim to keep overhead under where
// possible. Anything above this limit will where possible be saved directly to disk during
// capture.
// This will cause increased disk space use (which may cause a capture to fail if disk space is
// exhausted) as well as slower capture times.
//
// Not all memory allocations may be deferred like this so it is not a guarantee of a memory
// limit.
//
// Units are in MBs, suggested values would range from 200MB to 1000MB.
//
// Default - 0 Megabytes
eRENDERDOC_Option_SoftMemoryLimit = 13,
} RENDERDOC_CaptureOption;
// Sets an option that controls how RenderDoc behaves on capture.
//
// Returns 1 if the option and value are valid
// Returns 0 if either is invalid and the option is unchanged
typedef int(RENDERDOC_CC *pRENDERDOC_SetCaptureOptionU32)(RENDERDOC_CaptureOption opt, uint32_t val);
typedef int(RENDERDOC_CC *pRENDERDOC_SetCaptureOptionF32)(RENDERDOC_CaptureOption opt, float val);
// Gets the current value of an option as a uint32_t
//
// If the option is invalid, 0xffffffff is returned
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetCaptureOptionU32)(RENDERDOC_CaptureOption opt);
// Gets the current value of an option as a float
//
// If the option is invalid, -FLT_MAX is returned
typedef float(RENDERDOC_CC *pRENDERDOC_GetCaptureOptionF32)(RENDERDOC_CaptureOption opt);
typedef enum RENDERDOC_InputButton
{
// '0' - '9' matches ASCII values
eRENDERDOC_Key_0 = 0x30,
eRENDERDOC_Key_1 = 0x31,
eRENDERDOC_Key_2 = 0x32,
eRENDERDOC_Key_3 = 0x33,
eRENDERDOC_Key_4 = 0x34,
eRENDERDOC_Key_5 = 0x35,
eRENDERDOC_Key_6 = 0x36,
eRENDERDOC_Key_7 = 0x37,
eRENDERDOC_Key_8 = 0x38,
eRENDERDOC_Key_9 = 0x39,
// 'A' - 'Z' matches ASCII values
eRENDERDOC_Key_A = 0x41,
eRENDERDOC_Key_B = 0x42,
eRENDERDOC_Key_C = 0x43,
eRENDERDOC_Key_D = 0x44,
eRENDERDOC_Key_E = 0x45,
eRENDERDOC_Key_F = 0x46,
eRENDERDOC_Key_G = 0x47,
eRENDERDOC_Key_H = 0x48,
eRENDERDOC_Key_I = 0x49,
eRENDERDOC_Key_J = 0x4A,
eRENDERDOC_Key_K = 0x4B,
eRENDERDOC_Key_L = 0x4C,
eRENDERDOC_Key_M = 0x4D,
eRENDERDOC_Key_N = 0x4E,
eRENDERDOC_Key_O = 0x4F,
eRENDERDOC_Key_P = 0x50,
eRENDERDOC_Key_Q = 0x51,
eRENDERDOC_Key_R = 0x52,
eRENDERDOC_Key_S = 0x53,
eRENDERDOC_Key_T = 0x54,
eRENDERDOC_Key_U = 0x55,
eRENDERDOC_Key_V = 0x56,
eRENDERDOC_Key_W = 0x57,
eRENDERDOC_Key_X = 0x58,
eRENDERDOC_Key_Y = 0x59,
eRENDERDOC_Key_Z = 0x5A,
// leave the rest of the ASCII range free
// in case we want to use it later
eRENDERDOC_Key_NonPrintable = 0x100,
eRENDERDOC_Key_Divide,
eRENDERDOC_Key_Multiply,
eRENDERDOC_Key_Subtract,
eRENDERDOC_Key_Plus,
eRENDERDOC_Key_F1,
eRENDERDOC_Key_F2,
eRENDERDOC_Key_F3,
eRENDERDOC_Key_F4,
eRENDERDOC_Key_F5,
eRENDERDOC_Key_F6,
eRENDERDOC_Key_F7,
eRENDERDOC_Key_F8,
eRENDERDOC_Key_F9,
eRENDERDOC_Key_F10,
eRENDERDOC_Key_F11,
eRENDERDOC_Key_F12,
eRENDERDOC_Key_Home,
eRENDERDOC_Key_End,
eRENDERDOC_Key_Insert,
eRENDERDOC_Key_Delete,
eRENDERDOC_Key_PageUp,
eRENDERDOC_Key_PageDn,
eRENDERDOC_Key_Backspace,
eRENDERDOC_Key_Tab,
eRENDERDOC_Key_PrtScrn,
eRENDERDOC_Key_Pause,
eRENDERDOC_Key_Max,
} RENDERDOC_InputButton;
// Sets which key or keys can be used to toggle focus between multiple windows
//
// If keys is NULL or num is 0, toggle keys will be disabled
typedef void(RENDERDOC_CC *pRENDERDOC_SetFocusToggleKeys)(RENDERDOC_InputButton *keys, int num);
// Sets which key or keys can be used to capture the next frame
//
// If keys is NULL or num is 0, captures keys will be disabled
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureKeys)(RENDERDOC_InputButton *keys, int num);
typedef enum RENDERDOC_OverlayBits
{
// This single bit controls whether the overlay is enabled or disabled globally
eRENDERDOC_Overlay_Enabled = 0x1,
// Show the average framerate over several seconds as well as min/max
eRENDERDOC_Overlay_FrameRate = 0x2,
// Show the current frame number
eRENDERDOC_Overlay_FrameNumber = 0x4,
// Show a list of recent captures, and how many captures have been made
eRENDERDOC_Overlay_CaptureList = 0x8,
// Default values for the overlay mask
eRENDERDOC_Overlay_Default = (eRENDERDOC_Overlay_Enabled | eRENDERDOC_Overlay_FrameRate |
eRENDERDOC_Overlay_FrameNumber | eRENDERDOC_Overlay_CaptureList),
// Enable all bits
eRENDERDOC_Overlay_All = ~0U,
// Disable all bits
eRENDERDOC_Overlay_None = 0,
} RENDERDOC_OverlayBits;
// returns the overlay bits that have been set
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetOverlayBits)();
// sets the overlay bits with an and & or mask
typedef void(RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or);
// this function will attempt to remove RenderDoc's hooks in the application.
//
// Note: that this can only work correctly if done immediately after
// the module is loaded, before any API work happens. RenderDoc will remove its
// injected hooks and shut down. Behaviour is undefined if this is called
// after any API functions have been called, and there is still no guarantee of
// success.
typedef void(RENDERDOC_CC *pRENDERDOC_RemoveHooks)();
// DEPRECATED: compatibility for code compiled against pre-1.4.1 headers.
typedef pRENDERDOC_RemoveHooks pRENDERDOC_Shutdown;
// This function will unload RenderDoc's crash handler.
//
// If you use your own crash handler and don't want RenderDoc's handler to
// intercede, you can call this function to unload it and any unhandled
// exceptions will pass to the next handler.
typedef void(RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)();
// Sets the capture file path template
//
// pathtemplate is a UTF-8 string that gives a template for how captures will be named
// and where they will be saved.
//
// Any extension is stripped off the path, and captures are saved in the directory
// specified, and named with the filename and the frame number appended. If the
// directory does not exist it will be created, including any parent directories.
//
// If pathtemplate is NULL, the template will remain unchanged
//
// Example:
//
// SetCaptureFilePathTemplate("my_captures/example");
//
// Capture #1 -> my_captures/example_frame123.rdc
// Capture #2 -> my_captures/example_frame456.rdc
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureFilePathTemplate)(const char *pathtemplate);
// returns the current capture path template, see SetCaptureFileTemplate above, as a UTF-8 string
typedef const char *(RENDERDOC_CC *pRENDERDOC_GetCaptureFilePathTemplate)();
// DEPRECATED: compatibility for code compiled against pre-1.1.2 headers.
typedef pRENDERDOC_SetCaptureFilePathTemplate pRENDERDOC_SetLogFilePathTemplate;
typedef pRENDERDOC_GetCaptureFilePathTemplate pRENDERDOC_GetLogFilePathTemplate;
// returns the number of captures that have been made
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetNumCaptures)();
// This function returns the details of a capture, by index. New captures are added
// to the end of the list.
//
// filename will be filled with the absolute path to the capture file, as a UTF-8 string
// pathlength will be written with the length in bytes of the filename string
// timestamp will be written with the time of the capture, in seconds since the Unix epoch
//
// Any of the parameters can be NULL and they'll be skipped.
//
// The function will return 1 if the capture index is valid, or 0 if the index is invalid
// If the index is invalid, the values will be unchanged
//
// Note: when captures are deleted in the UI they will remain in this list, so the
// capture path may not exist anymore.
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetCapture)(uint32_t idx, char *filename,
uint32_t *pathlength, uint64_t *timestamp);
// Sets the comments associated with a capture file. These comments are displayed in the
// UI program when opening.
//
// filePath should be a path to the capture file to add comments to. If set to NULL or ""
// the most recent capture file created made will be used instead.
// comments should be a NULL-terminated UTF-8 string to add as comments.
//
// Any existing comments will be overwritten.
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureFileComments)(const char *filePath,
const char *comments);
// returns 1 if the RenderDoc UI is connected to this application, 0 otherwise
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsTargetControlConnected)();
// DEPRECATED: compatibility for code compiled against pre-1.1.1 headers.
// This was renamed to IsTargetControlConnected in API 1.1.1, the old typedef is kept here for
// backwards compatibility with old code, it is castable either way since it's ABI compatible
// as the same function pointer type.
typedef pRENDERDOC_IsTargetControlConnected pRENDERDOC_IsRemoteAccessConnected;
// This function will launch the Replay UI associated with the RenderDoc library injected
// into the running application.
//
// if connectTargetControl is 1, the Replay UI will be launched with a command line parameter
// to connect to this application
// cmdline is the rest of the command line, as a UTF-8 string. E.g. a captures to open
// if cmdline is NULL, the command line will be empty.
//
// returns the PID of the replay UI if successful, 0 if not successful.
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_LaunchReplayUI)(uint32_t connectTargetControl,
const char *cmdline);
// RenderDoc can return a higher version than requested if it's backwards compatible,
// this function returns the actual version returned. If a parameter is NULL, it will be
// ignored and the others will be filled out.
typedef void(RENDERDOC_CC *pRENDERDOC_GetAPIVersion)(int *major, int *minor, int *patch);
// Requests that the replay UI show itself (if hidden or not the current top window). This can be
// used in conjunction with IsTargetControlConnected and LaunchReplayUI to intelligently handle
// showing the UI after making a capture.
//
// This will return 1 if the request was successfully passed on, though it's not guaranteed that
// the UI will be on top in all cases depending on OS rules. It will return 0 if there is no current
// target control connection to make such a request, or if there was another error
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_ShowReplayUI)();
//////////////////////////////////////////////////////////////////////////
// Capturing functions
//
// A device pointer is a pointer to the API's root handle.
//
// This would be an ID3D11Device, HGLRC/GLXContext, ID3D12Device, etc
typedef void *RENDERDOC_DevicePointer;
// A window handle is the OS's native window handle
//
// This would be an HWND, GLXDrawable, etc
typedef void *RENDERDOC_WindowHandle;
// A helper macro for Vulkan, where the device handle cannot be used directly.
//
// Passing the VkInstance to this macro will return the RENDERDOC_DevicePointer to use.
//
// Specifically, the value needed is the dispatch table pointer, which sits as the first
// pointer-sized object in the memory pointed to by the VkInstance. Thus we cast to a void** and
// indirect once.
#define RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(inst) (*((void **)(inst)))
// This sets the RenderDoc in-app overlay in the API/window pair as 'active' and it will
// respond to keypresses. Neither parameter can be NULL
typedef void(RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
// capture the next frame on whichever window and API is currently considered active
typedef void(RENDERDOC_CC *pRENDERDOC_TriggerCapture)();
// capture the next N frames on whichever window and API is currently considered active
typedef void(RENDERDOC_CC *pRENDERDOC_TriggerMultiFrameCapture)(uint32_t numFrames);
// When choosing either a device pointer or a window handle to capture, you can pass NULL.
// Passing NULL specifies a 'wildcard' match against anything. This allows you to specify
// any API rendering to a specific window, or a specific API instance rendering to any window,
// or in the simplest case of one window and one API, you can just pass NULL for both.
//
// In either case, if there are two or more possible matching (device,window) pairs it
// is undefined which one will be captured.
//
// Note: for headless rendering you can pass NULL for the window handle and either specify
// a device pointer or leave it NULL as above.
// Immediately starts capturing API calls on the specified device pointer and window handle.
//
// If there is no matching thing to capture (e.g. no supported API has been initialised),
// this will do nothing.
//
// The results are undefined (including crashes) if two captures are started overlapping,
// even on separate devices and/oror windows.
typedef void(RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
// Returns whether or not a frame capture is currently ongoing anywhere.
//
// This will return 1 if a capture is ongoing, and 0 if there is no capture running
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsFrameCapturing)();
// Ends capturing immediately.
//
// This will return 1 if the capture succeeded, and 0 if there was an error capturing.
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
// Ends capturing immediately and discard any data stored without saving to disk.
//
// This will return 1 if the capture was discarded, and 0 if there was an error or no capture
// was in progress
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_DiscardFrameCapture)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
// Only valid to be called between a call to StartFrameCapture and EndFrameCapture. Gives a custom
// title to the capture produced which will be displayed in the UI.
//
// If multiple captures are ongoing, this title will be applied to the first capture to end after
// this call. The second capture to end will have no title, unless this function is called again.
//
// Calling this function has no effect if no capture is currently running, and if it is called
// multiple times only the last title will be used.
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureTitle)(const char *title);
//////////////////////////////////////////////////////////////////////////////////////////////////
// RenderDoc API versions
//
// RenderDoc uses semantic versioning (http://semver.org/).
//
// MAJOR version is incremented when incompatible API changes happen.
// MINOR version is incremented when functionality is added in a backwards-compatible manner.
// PATCH version is incremented when backwards-compatible bug fixes happen.
//
// Note that this means the API returned can be higher than the one you might have requested.
// e.g. if you are running against a newer RenderDoc that supports 1.0.1, it will be returned
// instead of 1.0.0. You can check this with the GetAPIVersion entry point
typedef enum RENDERDOC_Version
{
eRENDERDOC_API_Version_1_0_0 = 10000, // RENDERDOC_API_1_0_0 = 1 00 00
eRENDERDOC_API_Version_1_0_1 = 10001, // RENDERDOC_API_1_0_1 = 1 00 01
eRENDERDOC_API_Version_1_0_2 = 10002, // RENDERDOC_API_1_0_2 = 1 00 02
eRENDERDOC_API_Version_1_1_0 = 10100, // RENDERDOC_API_1_1_0 = 1 01 00
eRENDERDOC_API_Version_1_1_1 = 10101, // RENDERDOC_API_1_1_1 = 1 01 01
eRENDERDOC_API_Version_1_1_2 = 10102, // RENDERDOC_API_1_1_2 = 1 01 02
eRENDERDOC_API_Version_1_2_0 = 10200, // RENDERDOC_API_1_2_0 = 1 02 00
eRENDERDOC_API_Version_1_3_0 = 10300, // RENDERDOC_API_1_3_0 = 1 03 00
eRENDERDOC_API_Version_1_4_0 = 10400, // RENDERDOC_API_1_4_0 = 1 04 00
eRENDERDOC_API_Version_1_4_1 = 10401, // RENDERDOC_API_1_4_1 = 1 04 01
eRENDERDOC_API_Version_1_4_2 = 10402, // RENDERDOC_API_1_4_2 = 1 04 02
eRENDERDOC_API_Version_1_5_0 = 10500, // RENDERDOC_API_1_5_0 = 1 05 00
eRENDERDOC_API_Version_1_6_0 = 10600, // RENDERDOC_API_1_6_0 = 1 06 00
} RENDERDOC_Version;
// API version changelog:
//
// 1.0.0 - initial release
// 1.0.1 - Bugfix: IsFrameCapturing() was returning false for captures that were triggered
// by keypress or TriggerCapture, instead of Start/EndFrameCapture.
// 1.0.2 - Refactor: Renamed eRENDERDOC_Option_DebugDeviceMode to eRENDERDOC_Option_APIValidation
// 1.1.0 - Add feature: TriggerMultiFrameCapture(). Backwards compatible with 1.0.x since the new
// function pointer is added to the end of the struct, the original layout is identical
// 1.1.1 - Refactor: Renamed remote access to target control (to better disambiguate from remote
// replay/remote server concept in replay UI)
// 1.1.2 - Refactor: Renamed "log file" in function names to just capture, to clarify that these
// are captures and not debug logging files. This is the first API version in the v1.0
// branch.
// 1.2.0 - Added feature: SetCaptureFileComments() to add comments to a capture file that will be
// displayed in the UI program on load.
// 1.3.0 - Added feature: New capture option eRENDERDOC_Option_AllowUnsupportedVendorExtensions
// which allows users to opt-in to allowing unsupported vendor extensions to function.
// Should be used at the user's own risk.
// Refactor: Renamed eRENDERDOC_Option_VerifyMapWrites to
// eRENDERDOC_Option_VerifyBufferAccess, which now also controls initialisation to
// 0xdddddddd of uninitialised buffer contents.
// 1.4.0 - Added feature: DiscardFrameCapture() to discard a frame capture in progress and stop
// capturing without saving anything to disk.
// 1.4.1 - Refactor: Renamed Shutdown to RemoveHooks to better clarify what is happening
// 1.4.2 - Refactor: Renamed 'draws' to 'actions' in callstack capture option.
// 1.5.0 - Added feature: ShowReplayUI() to request that the replay UI show itself if connected
// 1.6.0 - Added feature: SetCaptureTitle() which can be used to set a title for a
// capture made with StartFrameCapture() or EndFrameCapture()
typedef struct RENDERDOC_API_1_6_0
{
pRENDERDOC_GetAPIVersion GetAPIVersion;
pRENDERDOC_SetCaptureOptionU32 SetCaptureOptionU32;
pRENDERDOC_SetCaptureOptionF32 SetCaptureOptionF32;
pRENDERDOC_GetCaptureOptionU32 GetCaptureOptionU32;
pRENDERDOC_GetCaptureOptionF32 GetCaptureOptionF32;
pRENDERDOC_SetFocusToggleKeys SetFocusToggleKeys;
pRENDERDOC_SetCaptureKeys SetCaptureKeys;
pRENDERDOC_GetOverlayBits GetOverlayBits;
pRENDERDOC_MaskOverlayBits MaskOverlayBits;
// Shutdown was renamed to RemoveHooks in 1.4.1.
// These unions allow old code to continue compiling without changes
union
{
pRENDERDOC_Shutdown Shutdown;
pRENDERDOC_RemoveHooks RemoveHooks;
};
pRENDERDOC_UnloadCrashHandler UnloadCrashHandler;
// Get/SetLogFilePathTemplate was renamed to Get/SetCaptureFilePathTemplate in 1.1.2.
// These unions allow old code to continue compiling without changes
union
{
// deprecated name
pRENDERDOC_SetLogFilePathTemplate SetLogFilePathTemplate;
// current name
pRENDERDOC_SetCaptureFilePathTemplate SetCaptureFilePathTemplate;
};
union
{
// deprecated name
pRENDERDOC_GetLogFilePathTemplate GetLogFilePathTemplate;
// current name
pRENDERDOC_GetCaptureFilePathTemplate GetCaptureFilePathTemplate;
};
pRENDERDOC_GetNumCaptures GetNumCaptures;
pRENDERDOC_GetCapture GetCapture;
pRENDERDOC_TriggerCapture TriggerCapture;
// IsRemoteAccessConnected was renamed to IsTargetControlConnected in 1.1.1.
// This union allows old code to continue compiling without changes
union
{
// deprecated name
pRENDERDOC_IsRemoteAccessConnected IsRemoteAccessConnected;
// current name
pRENDERDOC_IsTargetControlConnected IsTargetControlConnected;
};
pRENDERDOC_LaunchReplayUI LaunchReplayUI;
pRENDERDOC_SetActiveWindow SetActiveWindow;
pRENDERDOC_StartFrameCapture StartFrameCapture;
pRENDERDOC_IsFrameCapturing IsFrameCapturing;
pRENDERDOC_EndFrameCapture EndFrameCapture;
// new function in 1.1.0
pRENDERDOC_TriggerMultiFrameCapture TriggerMultiFrameCapture;
// new function in 1.2.0
pRENDERDOC_SetCaptureFileComments SetCaptureFileComments;
// new function in 1.4.0
pRENDERDOC_DiscardFrameCapture DiscardFrameCapture;
// new function in 1.5.0
pRENDERDOC_ShowReplayUI ShowReplayUI;
// new function in 1.6.0
pRENDERDOC_SetCaptureTitle SetCaptureTitle;
} RENDERDOC_API_1_6_0;
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_0_0;
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_0_1;
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_0_2;
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_1_0;
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_1_1;
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_1_2;
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_2_0;
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_3_0;
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_4_0;
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_4_1;
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_4_2;
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_5_0;
//////////////////////////////////////////////////////////////////////////////////////////////////
// RenderDoc API entry point
//
// This entry point can be obtained via GetProcAddress/dlsym if RenderDoc is available.
//
// The name is the same as the typedef - "RENDERDOC_GetAPI"
//
// This function is not thread safe, and should not be called on multiple threads at once.
// Ideally, call this once as early as possible in your application's startup, before doing
// any API work, since some configuration functionality etc has to be done also before
// initialising any APIs.
//
// Parameters:
// version is a single value from the RENDERDOC_Version above.
//
// outAPIPointers will be filled out with a pointer to the corresponding struct of function
// pointers.
//
// Returns:
// 1 - if the outAPIPointers has been filled with a pointer to the API struct requested
// 0 - if the requested version is not supported or the arguments are invalid.
//
typedef int(RENDERDOC_CC *pRENDERDOC_GetAPI)(RENDERDOC_Version version, void **outAPIPointers);
#ifdef __cplusplus
} // extern "C"
#endif

2
externals/robin-map vendored

@ -1 +1 @@
Subproject commit 1115dad3ffa0994e3f43b693d9b9cc99944c64c1 Subproject commit 2c48a1a50203bbaf1e3d0d64c5d726d56f8d3bb3

2
externals/sdl3 vendored

@ -1 +1 @@
Subproject commit f9a06c20ed85fb1d6754fc2280d6183382217910 Subproject commit 4cc3410dce50cefce98d3cf3cf1bc8eca83b862a

2
externals/sirit vendored

@ -1 +1 @@
Subproject commit 8db09231c448b913ae905d5237ce2eca46e3fe87 Subproject commit 37090c74cc6e680f2bc334cac8fd182f7634a1f6

2
externals/toml11 vendored

@ -1 +1 @@
Subproject commit b389bbc4ebf90fa2fe7651de3046fb19f661ba3c Subproject commit 4b740127230472779c4a4d71e1a75aaa3a367a2d

2
externals/tracy vendored

@ -1 +1 @@
Subproject commit c6d779d78508514102fbe1b8eb28bda10d95bb2a Subproject commit b8061982cad0210b649541016c88ff5faa90733c

2
externals/vma vendored

@ -1 +1 @@
Subproject commit 257138b8f5686ae84491a3df9f90a77d5660c3bd Subproject commit e1bdbca9baf4d682fb6066b380f4aa4a7bdbb58a

@ -1 +1 @@
Subproject commit 190d2cb24e90e5bf2bec0a75604a9b3586485b6d Subproject commit d205aff40b4e15d4c568523ee6a26f85138126d9

@ -1 +1 @@
Subproject commit d937b60055aaea313422672ebd5cc8bfa87a1682 Subproject commit f00c973a6ab2a23573708568b8ef4acc20a9d36b

2
externals/xbyak vendored

@ -1 +1 @@
Subproject commit aabb091ae37068498751fd58202a9854408ecb0e Subproject commit ccdf68421bc8eb85693f573080fc0a5faad862db

2
externals/xxhash vendored

@ -1 +1 @@
Subproject commit 805c00b68fa754200ada0c207ffeaa7a4409377c Subproject commit dbea33e47e7c0fe0b7c8592cd931c7430c1f130d

2
externals/zydis vendored

@ -1 +1 @@
Subproject commit 5a68f639e4f01604cc7bfc8d313f583a8137e3d3 Subproject commit bd73bc03b0aacaa89c9c203b9b43cd08f1b1843b

View File

@ -114108,7 +114108,7 @@ STUB(
_ZN3sce2Np9CppWebApi6Common12IntrusivePtrINS1_7Matches2V124RequestCompetitiveResultEE7add_refEv) _ZN3sce2Np9CppWebApi6Common12IntrusivePtrINS1_7Matches2V124RequestCompetitiveResultEE7add_refEv)
STUB("efPahl2FufA", STUB("efPahl2FufA",
_ZN3sce2Np9CppWebApi30CommunicationRestrictionStatus2V35Error8fromJsonERKNS_4Json5ValueE) _ZN3sce2Np9CppWebApi30CommunicationRestrictionStatus2V35Error8fromJsonERKNS_4Json5ValueE)
STUB("efX3lrPwdKA", sceAppContentAddcontMountByEntitlemetId) STUB("efX3lrPwdKA", sceAppContentAddcontMountByEntitlementId)
STUB("efXnxYFN5oE", _ZNSt11range_errorD0Ev) STUB("efXnxYFN5oE", _ZNSt11range_errorD0Ev)
STUB("efcwuDLsAM0", _ZThn120_NK7WebCore16HTMLMediaElement5mutedEv) STUB("efcwuDLsAM0", _ZThn120_NK7WebCore16HTMLMediaElement5mutedEv)
STUB("efhGArzWdxE", _ZN7bmalloc6IsoTLS15s_didInitializeE) STUB("efhGArzWdxE", _ZN7bmalloc6IsoTLS15s_didInitializeE)
@ -129493,7 +129493,7 @@ STUB(
STUB("kJlYH5uMAWI", sceNetResolverDestroy) STUB("kJlYH5uMAWI", sceNetResolverDestroy)
STUB("kJmdxo4uM+8", STUB("kJmdxo4uM+8",
_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE5_InitERKSt8_Locinfo) _ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE5_InitERKSt8_Locinfo)
STUB("kJmjt81mXKQ", sceAppContentAddcontEnqueueDownloadByEntitlemetId) STUB("kJmjt81mXKQ", sceAppContentAddcontEnqueueDownloadByEntitlementId)
STUB( STUB(
"kJoY9lMIFzY", "kJoY9lMIFzY",
_ZN3sce2Np9CppWebApi6Common8IteratorINS2_12IntrusivePtrINS1_21AdvancedPlayerProfile2V138MatchCompletionRateDisconnectedMetricsEEEEmmEi) _ZN3sce2Np9CppWebApi6Common8IteratorINS2_12IntrusivePtrINS1_21AdvancedPlayerProfile2V138MatchCompletionRateDisconnectedMetricsEEEEmmEi)

View File

@ -80897,10 +80897,10 @@ sceAppCheckerExecute
sceAppCheckerExecuteEx sceAppCheckerExecuteEx
sceAppContentAddcontDelete sceAppContentAddcontDelete
sceAppContentAddcontEnqueueDownload sceAppContentAddcontEnqueueDownload
sceAppContentAddcontEnqueueDownloadByEntitlemetId sceAppContentAddcontEnqueueDownloadByEntitlementId
sceAppContentAddcontEnqueueDownloadSp sceAppContentAddcontEnqueueDownloadSp
sceAppContentAddcontMount sceAppContentAddcontMount
sceAppContentAddcontMountByEntitlemetId sceAppContentAddcontMountByEntitlementId
sceAppContentAddcontShrink sceAppContentAddcontShrink
sceAppContentAddcontUnmount sceAppContentAddcontUnmount
sceAppContentAppParamGetInt sceAppContentAppParamGetInt

View File

@ -1,19 +1,23 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "sdl_audio.h"
#include "common/assert.h"
#include "core/libraries/error_codes.h"
#include <SDL3/SDL_audio.h> #include <SDL3/SDL_audio.h>
#include <SDL3/SDL_init.h> #include <SDL3/SDL_init.h>
#include <SDL3/SDL_timer.h> #include <SDL3/SDL_timer.h>
#include <common/assert.h>
#include <core/libraries/error_codes.h> #include <mutex> // std::unique_lock
#include "sdl_audio.h"
namespace Audio { namespace Audio {
int SDLAudio::AudioOutOpen(int type, u32 samples_num, u32 freq, int SDLAudio::AudioOutOpen(int type, u32 samples_num, u32 freq,
Libraries::AudioOut::OrbisAudioOutParamFormat format) { Libraries::AudioOut::OrbisAudioOutParamFormat format) {
using Libraries::AudioOut::OrbisAudioOutParamFormat; using Libraries::AudioOut::OrbisAudioOutParamFormat;
std::scoped_lock lock{m_mutex}; std::unique_lock lock{m_mutex};
for (int id = 0; id < portsOut.size(); id++) { for (int id = 0; id < portsOut.size(); id++) {
auto& port = portsOut[id]; auto& port = portsOut[id];
if (!port.isOpen) { if (!port.isOpen) {
@ -88,7 +92,7 @@ int SDLAudio::AudioOutOpen(int type, u32 samples_num, u32 freq,
} }
s32 SDLAudio::AudioOutOutput(s32 handle, const void* ptr) { s32 SDLAudio::AudioOutOutput(s32 handle, const void* ptr) {
std::scoped_lock lock{m_mutex}; std::shared_lock lock{m_mutex};
auto& port = portsOut[handle - 1]; auto& port = portsOut[handle - 1];
if (!port.isOpen) { if (!port.isOpen) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT; return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
@ -100,7 +104,7 @@ s32 SDLAudio::AudioOutOutput(s32 handle, const void* ptr) {
int result = SDL_PutAudioStreamData(port.stream, ptr, int result = SDL_PutAudioStreamData(port.stream, ptr,
port.samples_num * port.sample_size * port.channels_num); port.samples_num * port.sample_size * port.channels_num);
// TODO find a correct value 8192 is estimated // TODO find a correct value 8192 is estimated
while (SDL_GetAudioStreamAvailable(port.stream) > 8192) { while (SDL_GetAudioStreamAvailable(port.stream) > 65536) {
SDL_Delay(0); SDL_Delay(0);
} }
@ -109,7 +113,7 @@ s32 SDLAudio::AudioOutOutput(s32 handle, const void* ptr) {
bool SDLAudio::AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume) { bool SDLAudio::AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume) {
using Libraries::AudioOut::OrbisAudioOutParamFormat; using Libraries::AudioOut::OrbisAudioOutParamFormat;
std::scoped_lock lock{m_mutex}; std::shared_lock lock{m_mutex};
auto& port = portsOut[handle - 1]; auto& port = portsOut[handle - 1];
if (!port.isOpen) { if (!port.isOpen) {
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT; return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
@ -147,7 +151,7 @@ bool SDLAudio::AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume) {
} }
bool SDLAudio::AudioOutGetStatus(s32 handle, int* type, int* channels_num) { bool SDLAudio::AudioOutGetStatus(s32 handle, int* type, int* channels_num) {
std::scoped_lock lock{m_mutex}; std::shared_lock lock{m_mutex};
auto& port = portsOut[handle - 1]; auto& port = portsOut[handle - 1];
*type = port.type; *type = port.type;
*channels_num = port.channels_num; *channels_num = port.channels_num;

View File

@ -3,7 +3,7 @@
#pragma once #pragma once
#include <mutex> #include <shared_mutex>
#include <SDL3/SDL_audio.h> #include <SDL3/SDL_audio.h>
#include "core/libraries/audio/audioout.h" #include "core/libraries/audio/audioout.h"
@ -22,17 +22,17 @@ public:
private: private:
struct PortOut { struct PortOut {
bool isOpen = false; SDL_AudioStream* stream = nullptr;
int type = 0;
u32 samples_num = 0; u32 samples_num = 0;
u8 sample_size = 0;
u32 freq = 0; u32 freq = 0;
u32 format = -1; u32 format = -1;
int type = 0;
int channels_num = 0; int channels_num = 0;
int volume[8] = {}; int volume[8] = {};
SDL_AudioStream* stream = nullptr; u8 sample_size = 0;
bool isOpen = false;
}; };
std::mutex m_mutex; std::shared_mutex m_mutex;
std::array<PortOut, 22> portsOut; // main up to 8 ports , BGM 1 port , voice up to 4 ports , std::array<PortOut, 22> portsOut; // main up to 8 ports , BGM 1 port , voice up to 4 ports ,
// personal up to 4 ports , padspk up to 5 ports , aux 1 port // personal up to 4 ports , padspk up to 5 ports , aux 1 port
}; };

View File

@ -15,15 +15,22 @@ static u32 screenWidth = 1280;
static u32 screenHeight = 720; static u32 screenHeight = 720;
static s32 gpuId = -1; // Vulkan physical device index. Set to negative for auto select static s32 gpuId = -1; // Vulkan physical device index. Set to negative for auto select
static std::string logFilter; static std::string logFilter;
static std::string logType = "sync"; static std::string logType = "async";
static std::string userName = "shadPS4";
static bool useSpecialPad = false;
static int specialPadClass = 1;
static bool isDebugDump = false; static bool isDebugDump = false;
static bool isLibc = true;
static bool isShowSplash = false; static bool isShowSplash = false;
static bool isNullGpu = false; static bool isNullGpu = false;
static bool shouldCopyGPUBuffers = false;
static bool shouldDumpShaders = false; static bool shouldDumpShaders = false;
static bool shouldDumpPM4 = false; static bool shouldDumpPM4 = false;
static u32 vblankDivider = 1;
static bool vkValidation = false; static bool vkValidation = false;
static bool vkValidationSync = false; static bool vkValidationSync = false;
static bool vkValidationGpu = false;
static bool rdocEnable = false;
static bool rdocMarkersEnable = false;
// Gui // Gui
std::string settings_install_dir = ""; std::string settings_install_dir = "";
u32 main_window_geometry_x = 400; u32 main_window_geometry_x = 400;
@ -41,10 +48,9 @@ u32 m_window_size_H = 720;
std::vector<std::string> m_pkg_viewer; std::vector<std::string> m_pkg_viewer;
std::vector<std::string> m_elf_viewer; std::vector<std::string> m_elf_viewer;
std::vector<std::string> m_recent_files; std::vector<std::string> m_recent_files;
std::string emulator_language = "en";
bool isLleLibc() { // Settings
return isLibc; u32 m_language = 1; // english
}
bool isNeoMode() { bool isNeoMode() {
return isNeo; return isNeo;
@ -74,6 +80,18 @@ std::string getLogType() {
return logType; return logType;
} }
std::string getUserName() {
return userName;
}
bool getUseSpecialPad() {
return useSpecialPad;
}
int getSpecialPadClass() {
return specialPadClass;
}
bool debugDump() { bool debugDump() {
return isDebugDump; return isDebugDump;
} }
@ -86,6 +104,10 @@ bool nullGpu() {
return isNullGpu; return isNullGpu;
} }
bool copyGPUCmdBuffers() {
return shouldCopyGPUBuffers;
}
bool dumpShaders() { bool dumpShaders() {
return shouldDumpShaders; return shouldDumpShaders;
} }
@ -94,6 +116,18 @@ bool dumpPM4() {
return shouldDumpPM4; return shouldDumpPM4;
} }
bool isRdocEnabled() {
return rdocEnable;
}
bool isMarkersEnabled() {
return rdocMarkersEnable;
}
u32 vblankDiv() {
return vblankDivider;
}
bool vkValidationEnabled() { bool vkValidationEnabled() {
return vkValidation; return vkValidation;
} }
@ -102,6 +136,94 @@ bool vkValidationSyncEnabled() {
return vkValidationSync; return vkValidationSync;
} }
bool vkValidationGpuEnabled() {
return vkValidationGpu;
}
void setGpuId(s32 selectedGpuId) {
gpuId = selectedGpuId;
}
void setScreenWidth(u32 width) {
screenWidth = width;
}
void setScreenHeight(u32 height) {
screenHeight = height;
}
void setDebugDump(bool enable) {
isDebugDump = enable;
}
void setShowSplash(bool enable) {
isShowSplash = enable;
}
void setNullGpu(bool enable) {
isNullGpu = enable;
}
void setCopyGPUCmdBuffers(bool enable) {
shouldCopyGPUBuffers = enable;
}
void setDumpShaders(bool enable) {
shouldDumpShaders = enable;
}
void setDumpPM4(bool enable) {
shouldDumpPM4 = enable;
}
void setVkValidation(bool enable) {
vkValidation = enable;
}
void setVkSyncValidation(bool enable) {
vkValidationSync = enable;
}
void setRdocEnabled(bool enable) {
rdocEnable = enable;
}
void setVblankDiv(u32 value) {
vblankDivider = value;
}
void setFullscreenMode(bool enable) {
isFullscreen = enable;
}
void setLanguage(u32 language) {
m_language = language;
}
void setNeoMode(bool enable) {
isNeo = enable;
}
void setLogType(const std::string& type) {
logType = type;
}
void setLogFilter(const std::string& type) {
logFilter = type;
}
void setUserName(const std::string& type) {
userName = type;
}
void setUseSpecialPad(bool use) {
useSpecialPad = use;
}
void setSpecialPadClass(int type) {
specialPadClass = type;
}
void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) { void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) {
main_window_geometry_x = x; main_window_geometry_x = x;
main_window_geometry_y = y; main_window_geometry_y = y;
@ -120,10 +242,10 @@ void setIconSize(u32 size) {
void setIconSizeGrid(u32 size) { void setIconSizeGrid(u32 size) {
m_icon_size_grid = size; m_icon_size_grid = size;
} }
void setSliderPositon(u32 pos) { void setSliderPosition(u32 pos) {
m_slider_pos = pos; m_slider_pos = pos;
} }
void setSliderPositonGrid(u32 pos) { void setSliderPositionGrid(u32 pos) {
m_slider_pos_grid = pos; m_slider_pos_grid = pos;
} }
void setTableMode(u32 mode) { void setTableMode(u32 mode) {
@ -135,19 +257,23 @@ void setMainWindowWidth(u32 width) {
void setMainWindowHeight(u32 height) { void setMainWindowHeight(u32 height) {
m_window_size_H = height; m_window_size_H = height;
} }
void setPkgViewer(std::vector<std::string> pkgList) { void setPkgViewer(const std::vector<std::string>& pkgList) {
m_pkg_viewer.resize(pkgList.size()); m_pkg_viewer.resize(pkgList.size());
m_pkg_viewer = pkgList; m_pkg_viewer = pkgList;
} }
void setElfViewer(std::vector<std::string> elfList) { void setElfViewer(const std::vector<std::string>& elfList) {
m_elf_viewer.resize(elfList.size()); m_elf_viewer.resize(elfList.size());
m_elf_viewer = elfList; m_elf_viewer = elfList;
} }
void setRecentFiles(std::vector<std::string> recentFiles) { void setRecentFiles(const std::vector<std::string>& recentFiles) {
m_recent_files.resize(recentFiles.size()); m_recent_files.resize(recentFiles.size());
m_recent_files = recentFiles; m_recent_files = recentFiles;
} }
void setEmulatorLanguage(std::string language) {
emulator_language = language;
}
u32 getMainWindowGeometryX() { u32 getMainWindowGeometryX() {
return main_window_geometry_x; return main_window_geometry_x;
} }
@ -172,10 +298,10 @@ u32 getIconSize() {
u32 getIconSizeGrid() { u32 getIconSizeGrid() {
return m_icon_size_grid; return m_icon_size_grid;
} }
u32 getSliderPositon() { u32 getSliderPosition() {
return m_slider_pos; return m_slider_pos;
} }
u32 getSliderPositonGrid() { u32 getSliderPositionGrid() {
return m_slider_pos_grid; return m_slider_pos_grid;
} }
u32 getTableMode() { u32 getTableMode() {
@ -197,6 +323,13 @@ std::vector<std::string> getRecentFiles() {
return m_recent_files; return m_recent_files;
} }
std::string getEmulatorLanguage() {
return emulator_language;
}
u32 GetLanguage() {
return m_language;
}
void load(const std::filesystem::path& path) { void load(const std::filesystem::path& path) {
// If the configuration file does not exist, create it and return // If the configuration file does not exist, create it and return
std::error_code error; std::error_code error;
@ -213,88 +346,88 @@ void load(const std::filesystem::path& path) {
fmt::print("Got exception trying to load config file. Exception: {}\n", ex.what()); fmt::print("Got exception trying to load config file. Exception: {}\n", ex.what());
return; return;
} }
if (data.contains("General")) { if (data.contains("General")) {
auto generalResult = toml::expect<toml::value>(data.at("General")); const toml::value& general = data.at("General");
if (generalResult.is_ok()) {
auto general = generalResult.unwrap();
isNeo = toml::find_or<toml::boolean>(general, "isPS4Pro", false); isNeo = toml::find_or<bool>(general, "isPS4Pro", false);
isFullscreen = toml::find_or<toml::boolean>(general, "Fullscreen", true); isFullscreen = toml::find_or<bool>(general, "Fullscreen", false);
logFilter = toml::find_or<toml::string>(general, "logFilter", ""); logFilter = toml::find_or<std::string>(general, "logFilter", "");
logType = toml::find_or<toml::string>(general, "logType", "sync"); logType = toml::find_or<std::string>(general, "logType", "sync");
isShowSplash = toml::find_or<toml::boolean>(general, "showSplash", true); userName = toml::find_or<std::string>(general, "userName", "shadPS4");
isShowSplash = toml::find_or<bool>(general, "showSplash", true);
} }
if (data.contains("Input")) {
const toml::value& input = data.at("Input");
useSpecialPad = toml::find_or<bool>(input, "useSpecialPad", false);
specialPadClass = toml::find_or<int>(input, "specialPadClass", 1);
} }
if (data.contains("GPU")) { if (data.contains("GPU")) {
auto gpuResult = toml::expect<toml::value>(data.at("GPU")); const toml::value& gpu = data.at("GPU");
if (gpuResult.is_ok()) {
auto gpu = gpuResult.unwrap();
screenWidth = toml::find_or<toml::integer>(gpu, "screenWidth", screenWidth); screenWidth = toml::find_or<int>(gpu, "screenWidth", screenWidth);
screenHeight = toml::find_or<toml::integer>(gpu, "screenHeight", screenHeight); screenHeight = toml::find_or<int>(gpu, "screenHeight", screenHeight);
gpuId = toml::find_or<toml::integer>(gpu, "gpuId", 0); isNullGpu = toml::find_or<bool>(gpu, "nullGpu", false);
isNullGpu = toml::find_or<toml::boolean>(gpu, "nullGpu", false); shouldCopyGPUBuffers = toml::find_or<bool>(gpu, "copyGPUBuffers", false);
shouldDumpShaders = toml::find_or<toml::boolean>(gpu, "dumpShaders", false); shouldDumpShaders = toml::find_or<bool>(gpu, "dumpShaders", false);
shouldDumpPM4 = toml::find_or<toml::boolean>(gpu, "dumpPM4", false); shouldDumpPM4 = toml::find_or<bool>(gpu, "dumpPM4", false);
} vblankDivider = toml::find_or<int>(gpu, "vblankDivider", 1);
} }
if (data.contains("Vulkan")) { if (data.contains("Vulkan")) {
const auto vkResult = toml::expect<toml::value>(data.at("Vulkan")); const toml::value& vk = data.at("Vulkan");
if (vkResult.is_ok()) {
auto vk = vkResult.unwrap();
vkValidation = toml::find_or<toml::boolean>(vk, "validation", true); gpuId = toml::find_or<int>(vk, "gpuId", -1);
vkValidationSync = toml::find_or<toml::boolean>(vk, "validation_sync", true); vkValidation = toml::find_or<bool>(vk, "validation", false);
} vkValidationSync = toml::find_or<bool>(vk, "validation_sync", false);
vkValidationGpu = toml::find_or<bool>(vk, "validation_gpu", true);
rdocEnable = toml::find_or<bool>(vk, "rdocEnable", false);
rdocMarkersEnable = toml::find_or<bool>(vk, "rdocMarkersEnable", false);
} }
if (data.contains("Debug")) { if (data.contains("Debug")) {
auto debugResult = toml::expect<toml::value>(data.at("Debug")); const toml::value& debug = data.at("Debug");
if (debugResult.is_ok()) {
auto debug = debugResult.unwrap();
isDebugDump = toml::find_or<toml::boolean>(debug, "DebugDump", false); isDebugDump = toml::find_or<bool>(debug, "DebugDump", false);
} }
}
if (data.contains("LLE")) {
auto lleResult = toml::expect<toml::value>(data.at("LLE"));
if (lleResult.is_ok()) {
auto lle = lleResult.unwrap();
isLibc = toml::find_or<toml::boolean>(lle, "libc", true);
}
}
if (data.contains("GUI")) { if (data.contains("GUI")) {
auto guiResult = toml::expect<toml::value>(data.at("GUI")); const toml::value& gui = data.at("GUI");
if (guiResult.is_ok()) {
auto gui = guiResult.unwrap();
m_icon_size = toml::find_or<toml::integer>(gui, "iconSize", 0); m_icon_size = toml::find_or<int>(gui, "iconSize", 0);
m_icon_size_grid = toml::find_or<toml::integer>(gui, "iconSizeGrid", 0); m_icon_size_grid = toml::find_or<int>(gui, "iconSizeGrid", 0);
m_slider_pos = toml::find_or<toml::integer>(gui, "sliderPos", 0); m_slider_pos = toml::find_or<int>(gui, "sliderPos", 0);
m_slider_pos_grid = toml::find_or<toml::integer>(gui, "sliderPosGrid", 0); m_slider_pos_grid = toml::find_or<int>(gui, "sliderPosGrid", 0);
mw_themes = toml::find_or<toml::integer>(gui, "theme", 0); mw_themes = toml::find_or<int>(gui, "theme", 0);
m_window_size_W = toml::find_or<toml::integer>(gui, "mw_width", 0); m_window_size_W = toml::find_or<int>(gui, "mw_width", 0);
m_window_size_H = toml::find_or<toml::integer>(gui, "mw_height", 0); m_window_size_H = toml::find_or<int>(gui, "mw_height", 0);
settings_install_dir = toml::find_or<toml::string>(gui, "installDir", ""); settings_install_dir = toml::find_or<std::string>(gui, "installDir", "");
main_window_geometry_x = toml::find_or<toml::integer>(gui, "geometry_x", 0); main_window_geometry_x = toml::find_or<int>(gui, "geometry_x", 0);
main_window_geometry_y = toml::find_or<toml::integer>(gui, "geometry_y", 0); main_window_geometry_y = toml::find_or<int>(gui, "geometry_y", 0);
main_window_geometry_w = toml::find_or<toml::integer>(gui, "geometry_w", 0); main_window_geometry_w = toml::find_or<int>(gui, "geometry_w", 0);
main_window_geometry_h = toml::find_or<toml::integer>(gui, "geometry_h", 0); main_window_geometry_h = toml::find_or<int>(gui, "geometry_h", 0);
m_pkg_viewer = toml::find_or<std::vector<std::string>>(gui, "pkgDirs", {}); m_pkg_viewer = toml::find_or<std::vector<std::string>>(gui, "pkgDirs", {});
m_elf_viewer = toml::find_or<std::vector<std::string>>(gui, "elfDirs", {}); m_elf_viewer = toml::find_or<std::vector<std::string>>(gui, "elfDirs", {});
m_recent_files = toml::find_or<std::vector<std::string>>(gui, "recentFiles", {}); m_recent_files = toml::find_or<std::vector<std::string>>(gui, "recentFiles", {});
m_table_mode = toml::find_or<toml::integer>(gui, "gameTableMode", 0); m_table_mode = toml::find_or<int>(gui, "gameTableMode", 0);
emulator_language = toml::find_or<std::string>(gui, "emulatorLanguage", "en");
} }
if (data.contains("Settings")) {
const toml::value& settings = data.at("Settings");
m_language = toml::find_or<int>(settings, "consoleLanguage", 1);
} }
} }
void save(const std::filesystem::path& path) { void save(const std::filesystem::path& path) {
toml::basic_value<toml::preserve_comments> data; toml::value data;
std::error_code error; std::error_code error;
if (std::filesystem::exists(path, error)) { if (std::filesystem::exists(path, error)) {
try { try {
data = toml::parse<toml::preserve_comments>(path); data = toml::parse(path);
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
fmt::print("Exception trying to parse config file. Exception: {}\n", ex.what()); fmt::print("Exception trying to parse config file. Exception: {}\n", ex.what());
return; return;
@ -311,17 +444,24 @@ void save(const std::filesystem::path& path) {
data["General"]["Fullscreen"] = isFullscreen; data["General"]["Fullscreen"] = isFullscreen;
data["General"]["logFilter"] = logFilter; data["General"]["logFilter"] = logFilter;
data["General"]["logType"] = logType; data["General"]["logType"] = logType;
data["General"]["userName"] = userName;
data["General"]["showSplash"] = isShowSplash; data["General"]["showSplash"] = isShowSplash;
data["GPU"]["gpuId"] = gpuId; data["Input"]["useSpecialPad"] = useSpecialPad;
data["Input"]["specialPadClass"] = specialPadClass;
data["GPU"]["screenWidth"] = screenWidth; data["GPU"]["screenWidth"] = screenWidth;
data["GPU"]["screenHeight"] = screenHeight; data["GPU"]["screenHeight"] = screenHeight;
data["GPU"]["nullGpu"] = isNullGpu; data["GPU"]["nullGpu"] = isNullGpu;
data["GPU"]["copyGPUBuffers"] = shouldCopyGPUBuffers;
data["GPU"]["dumpShaders"] = shouldDumpShaders; data["GPU"]["dumpShaders"] = shouldDumpShaders;
data["GPU"]["dumpPM4"] = shouldDumpPM4; data["GPU"]["dumpPM4"] = shouldDumpPM4;
data["GPU"]["vblankDivider"] = vblankDivider;
data["Vulkan"]["gpuId"] = gpuId;
data["Vulkan"]["validation"] = vkValidation; data["Vulkan"]["validation"] = vkValidation;
data["Vulkan"]["validation_sync"] = vkValidationSync; data["Vulkan"]["validation_sync"] = vkValidationSync;
data["Vulkan"]["validation_gpu"] = vkValidationGpu;
data["Vulkan"]["rdocEnable"] = rdocEnable;
data["Vulkan"]["rdocMarkersEnable"] = rdocMarkersEnable;
data["Debug"]["DebugDump"] = isDebugDump; data["Debug"]["DebugDump"] = isDebugDump;
data["LLE"]["libc"] = isLibc;
data["GUI"]["theme"] = mw_themes; data["GUI"]["theme"] = mw_themes;
data["GUI"]["iconSize"] = m_icon_size; data["GUI"]["iconSize"] = m_icon_size;
data["GUI"]["sliderPos"] = m_slider_pos; data["GUI"]["sliderPos"] = m_slider_pos;
@ -338,9 +478,36 @@ void save(const std::filesystem::path& path) {
data["GUI"]["pkgDirs"] = m_pkg_viewer; data["GUI"]["pkgDirs"] = m_pkg_viewer;
data["GUI"]["elfDirs"] = m_elf_viewer; data["GUI"]["elfDirs"] = m_elf_viewer;
data["GUI"]["recentFiles"] = m_recent_files; data["GUI"]["recentFiles"] = m_recent_files;
data["GUI"]["emulatorLanguage"] = emulator_language;
data["Settings"]["consoleLanguage"] = m_language;
std::ofstream file(path, std::ios::out); std::ofstream file(path, std::ios::out);
file << data; file << data;
file.close(); file.close();
} }
void setDefaultValues() {
isNeo = false;
isFullscreen = false;
screenWidth = 1280;
screenHeight = 720;
logFilter = "";
logType = "async";
userName = "shadPS4";
useSpecialPad = false;
specialPadClass = 1;
isDebugDump = false;
isShowSplash = false;
isNullGpu = false;
shouldDumpShaders = false;
shouldDumpPM4 = false;
vblankDivider = 1;
vkValidation = false;
rdocEnable = false;
emulator_language = "en";
m_language = 1;
gpuId = -1;
}
} // namespace Config } // namespace Config

View File

@ -15,20 +15,53 @@ bool isNeoMode();
bool isFullscreenMode(); bool isFullscreenMode();
std::string getLogFilter(); std::string getLogFilter();
std::string getLogType(); std::string getLogType();
std::string getUserName();
bool getUseSpecialPad();
int getSpecialPadClass();
u32 getScreenWidth(); u32 getScreenWidth();
u32 getScreenHeight(); u32 getScreenHeight();
s32 getGpuId(); s32 getGpuId();
bool debugDump(); bool debugDump();
bool isLleLibc();
bool showSplash(); bool showSplash();
bool nullGpu(); bool nullGpu();
bool copyGPUCmdBuffers();
bool dumpShaders(); bool dumpShaders();
bool dumpPM4(); bool dumpPM4();
bool isRdocEnabled();
bool isMarkersEnabled();
u32 vblankDiv();
void setDebugDump(bool enable);
void setShowSplash(bool enable);
void setNullGpu(bool enable);
void setCopyGPUCmdBuffers(bool enable);
void setDumpShaders(bool enable);
void setDumpPM4(bool enable);
void setVblankDiv(u32 value);
void setGpuId(s32 selectedGpuId);
void setScreenWidth(u32 width);
void setScreenHeight(u32 height);
void setFullscreenMode(bool enable);
void setLanguage(u32 language);
void setNeoMode(bool enable);
void setUserName(const std::string& type);
void setUseSpecialPad(bool use);
void setSpecialPadClass(int type);
void setLogType(const std::string& type);
void setLogFilter(const std::string& type);
void setVkValidation(bool enable);
void setVkSyncValidation(bool enable);
void setRdocEnabled(bool enable);
bool vkValidationEnabled(); bool vkValidationEnabled();
bool vkValidationSyncEnabled(); bool vkValidationSyncEnabled();
bool vkValidationGpuEnabled();
// Gui // Gui
void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h); void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h);
@ -36,14 +69,15 @@ void setGameInstallDir(const std::string& dir);
void setMainWindowTheme(u32 theme); void setMainWindowTheme(u32 theme);
void setIconSize(u32 size); void setIconSize(u32 size);
void setIconSizeGrid(u32 size); void setIconSizeGrid(u32 size);
void setSliderPositon(u32 pos); void setSliderPosition(u32 pos);
void setSliderPositonGrid(u32 pos); void setSliderPositionGrid(u32 pos);
void setTableMode(u32 mode); void setTableMode(u32 mode);
void setMainWindowWidth(u32 width); void setMainWindowWidth(u32 width);
void setMainWindowHeight(u32 height); void setMainWindowHeight(u32 height);
void setPkgViewer(std::vector<std::string> pkgList); void setPkgViewer(const std::vector<std::string>& pkgList);
void setElfViewer(std::vector<std::string> elfList); void setElfViewer(const std::vector<std::string>& elfList);
void setRecentFiles(std::vector<std::string> recentFiles); void setRecentFiles(const std::vector<std::string>& recentFiles);
void setEmulatorLanguage(std::string language);
u32 getMainWindowGeometryX(); u32 getMainWindowGeometryX();
u32 getMainWindowGeometryY(); u32 getMainWindowGeometryY();
@ -53,13 +87,18 @@ std::string getGameInstallDir();
u32 getMainWindowTheme(); u32 getMainWindowTheme();
u32 getIconSize(); u32 getIconSize();
u32 getIconSizeGrid(); u32 getIconSizeGrid();
u32 getSliderPositon(); u32 getSliderPosition();
u32 getSliderPositonGrid(); u32 getSliderPositionGrid();
u32 getTableMode(); u32 getTableMode();
u32 getMainWindowWidth(); u32 getMainWindowWidth();
u32 getMainWindowHeight(); u32 getMainWindowHeight();
std::vector<std::string> getPkgViewer(); std::vector<std::string> getPkgViewer();
std::vector<std::string> getElfViewer(); std::vector<std::string> getElfViewer();
std::vector<std::string> getRecentFiles(); std::vector<std::string> getRecentFiles();
std::string getEmulatorLanguage();
void setDefaultValues();
// settings
u32 GetLanguage();
}; // namespace Config }; // namespace Config

View File

@ -29,7 +29,7 @@ static inline bool IsProfilerConnected() {
#define TRACK_ALLOC(ptr, size, pool) TracyAllocN(std::bit_cast<void*>(ptr), (size), (pool)) #define TRACK_ALLOC(ptr, size, pool) TracyAllocN(std::bit_cast<void*>(ptr), (size), (pool))
#define TRACK_FREE(ptr, pool) TracyFreeN(std::bit_cast<void*>(ptr), (pool)) #define TRACK_FREE(ptr, pool) TracyFreeN(std::bit_cast<void*>(ptr), (pool))
enum MarkersPallete : int { enum MarkersPalette : int {
EmulatorMarkerColor = 0x264653, EmulatorMarkerColor = 0x264653,
RendererMarkerColor = 0x2a9d8f, RendererMarkerColor = 0x2a9d8f,
HleMarkerColor = 0xe9c46a, HleMarkerColor = 0xe9c46a,

View File

@ -217,7 +217,7 @@ void IOFile::Close() {
file = nullptr; file = nullptr;
#ifdef _WIN64 #ifdef _WIN64
if (file_mapping) { if (file_mapping && file_access_mode == FileAccessMode::ReadWrite) {
CloseHandle(std::bit_cast<HANDLE>(file_mapping)); CloseHandle(std::bit_cast<HANDLE>(file_mapping));
} }
#endif #endif
@ -259,8 +259,7 @@ uintptr_t IOFile::GetFileMapping() {
mapping = CreateFileMapping2(hfile, NULL, FILE_MAP_WRITE, PAGE_READWRITE, SEC_COMMIT, 0, mapping = CreateFileMapping2(hfile, NULL, FILE_MAP_WRITE, PAGE_READWRITE, SEC_COMMIT, 0,
NULL, NULL, 0); NULL, NULL, 0);
} else { } else {
mapping = CreateFileMapping2(hfile, NULL, FILE_MAP_READ, PAGE_READONLY, SEC_COMMIT, 0, NULL, mapping = hfile;
NULL, 0);
} }
file_mapping = std::bit_cast<uintptr_t>(mapping); file_mapping = std::bit_cast<uintptr_t>(mapping);

View File

@ -207,9 +207,9 @@ public:
message_queue.EmplaceWait(entry); message_queue.EmplaceWait(entry);
} else { } else {
ForEachBackend([&entry](auto& backend) { backend.Write(entry); }); ForEachBackend([&entry](auto& backend) { backend.Write(entry); });
}
std::fflush(stdout); std::fflush(stdout);
} }
}
private: private:
Impl(const std::filesystem::path& file_backend_filename, const Filter& filter_) Impl(const std::filesystem::path& file_backend_filename, const Filter& filter_)

View File

@ -106,11 +106,13 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
SUB(Lib, DiscMap) \ SUB(Lib, DiscMap) \
SUB(Lib, Png) \ SUB(Lib, Png) \
SUB(Lib, PlayGo) \ SUB(Lib, PlayGo) \
SUB(Lib, Random) \
SUB(Lib, Usbd) \ SUB(Lib, Usbd) \
SUB(Lib, Ajm) \ SUB(Lib, Ajm) \
SUB(Lib, ErrorDialog) \ SUB(Lib, ErrorDialog) \
SUB(Lib, ImeDialog) \ SUB(Lib, ImeDialog) \
SUB(Lib, AvPlayer) \ SUB(Lib, AvPlayer) \
SUB(Lib, Ngs2) \
CLS(Frontend) \ CLS(Frontend) \
CLS(Render) \ CLS(Render) \
SUB(Render, Vulkan) \ SUB(Render, Vulkan) \

View File

@ -73,11 +73,13 @@ enum class Class : u8 {
Lib_DiscMap, ///< The LibSceDiscMap implementation. Lib_DiscMap, ///< The LibSceDiscMap implementation.
Lib_Png, ///< The LibScePng implementation. Lib_Png, ///< The LibScePng implementation.
Lib_PlayGo, ///< The LibScePlayGo implementation. Lib_PlayGo, ///< The LibScePlayGo implementation.
Lib_Random, ///< The libSceRandom implementation.
Lib_Usbd, ///< The LibSceUsbd implementation. Lib_Usbd, ///< The LibSceUsbd implementation.
Lib_Ajm, ///< The LibSceAjm implementation. Lib_Ajm, ///< The LibSceAjm implementation.
Lib_ErrorDialog, ///< The LibSceErrorDialog implementation. Lib_ErrorDialog, ///< The LibSceErrorDialog implementation.
Lib_ImeDialog, ///< The LibSceImeDialog implementation. Lib_ImeDialog, ///< The LibSceImeDialog implementation.
Lib_AvPlayer, ///< The LibSceAvPlayer implementation. Lib_AvPlayer, ///< The LibSceAvPlayer implementation.
Lib_Ngs2, ///< The LibSceNgs2 implementation.
Frontend, ///< Emulator UI Frontend, ///< Emulator UI
Render, ///< Video Core Render, ///< Video Core
Render_Vulkan, ///< Vulkan backend Render_Vulkan, ///< Vulkan backend

View File

@ -18,16 +18,16 @@ NativeClock::NativeClock()
us_rdtsc_factor{GetFixedPoint64Factor(std::micro::den, rdtsc_frequency)}, us_rdtsc_factor{GetFixedPoint64Factor(std::micro::den, rdtsc_frequency)},
ms_rdtsc_factor{GetFixedPoint64Factor(std::milli::den, rdtsc_frequency)} {} ms_rdtsc_factor{GetFixedPoint64Factor(std::milli::den, rdtsc_frequency)} {}
u64 NativeClock::GetTimeNS() const { u64 NativeClock::GetTimeNS(u64 base_ptc /*= 0*/) const {
return MultiplyHigh(GetUptime(), ns_rdtsc_factor); return MultiplyHigh(GetUptime() - base_ptc, ns_rdtsc_factor);
} }
u64 NativeClock::GetTimeUS() const { u64 NativeClock::GetTimeUS(u64 base_ptc /*= 0*/) const {
return MultiplyHigh(GetUptime(), us_rdtsc_factor); return MultiplyHigh(GetUptime() - base_ptc, us_rdtsc_factor);
} }
u64 NativeClock::GetTimeMS() const { u64 NativeClock::GetTimeMS(u64 base_ptc /*= 0*/) const {
return MultiplyHigh(GetUptime(), ms_rdtsc_factor); return MultiplyHigh(GetUptime() - base_ptc, ms_rdtsc_factor);
} }
u64 NativeClock::GetUptime() const { u64 NativeClock::GetUptime() const {

View File

@ -16,9 +16,9 @@ public:
return rdtsc_frequency; return rdtsc_frequency;
} }
u64 GetTimeNS() const; u64 GetTimeNS(u64 base_ptc = 0) const;
u64 GetTimeUS() const; u64 GetTimeUS(u64 base_ptc = 0) const;
u64 GetTimeMS() const; u64 GetTimeMS(u64 base_ptc = 0) const;
u64 GetUptime() const; u64 GetUptime() const;
u64 GetProcessTimeUS() const; u64 GetProcessTimeUS() const;

View File

@ -8,7 +8,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
namespace Shader { namespace Common {
template <typename T> template <typename T>
requires std::is_destructible_v<T> requires std::is_destructible_v<T>
@ -104,4 +104,4 @@ private:
size_t new_chunk_size{}; size_t new_chunk_size{};
}; };
} // namespace Shader } // namespace Common

View File

@ -4,6 +4,13 @@
#include <unordered_map> #include <unordered_map>
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/path_util.h" #include "common/path_util.h"
#include "common/scope_exit.h"
#ifdef __APPLE__
#include <CoreFoundation/CFBundle.h>
#include <dlfcn.h>
#include <sys/param.h>
#endif
#ifndef MAX_PATH #ifndef MAX_PATH
#ifdef _WIN32 #ifdef _WIN32
@ -19,7 +26,65 @@ namespace Common::FS {
namespace fs = std::filesystem; namespace fs = std::filesystem;
#ifdef __APPLE__
using IsTranslocatedURLFunc = Boolean (*)(CFURLRef path, bool* isTranslocated,
CFErrorRef* __nullable error);
using CreateOriginalPathForURLFunc = CFURLRef __nullable (*)(CFURLRef translocatedPath,
CFErrorRef* __nullable error);
static CFURLRef UntranslocateBundlePath(const CFURLRef bundle_path) {
if (void* security_handle =
dlopen("/System/Library/Frameworks/Security.framework/Security", RTLD_LAZY)) {
SCOPE_EXIT {
dlclose(security_handle);
};
const auto IsTranslocatedURL = reinterpret_cast<IsTranslocatedURLFunc>(
dlsym(security_handle, "SecTranslocateIsTranslocatedURL"));
const auto CreateOriginalPathForURL = reinterpret_cast<CreateOriginalPathForURLFunc>(
dlsym(security_handle, "SecTranslocateCreateOriginalPathForURL"));
bool is_translocated = false;
if (IsTranslocatedURL && CreateOriginalPathForURL &&
IsTranslocatedURL(bundle_path, &is_translocated, nullptr) && is_translocated) {
return CreateOriginalPathForURL(bundle_path, nullptr);
}
}
return nullptr;
}
static std::filesystem::path GetBundleParentDirectory() {
if (CFBundleRef bundle_ref = CFBundleGetMainBundle()) {
if (CFURLRef bundle_url_ref = CFBundleCopyBundleURL(bundle_ref)) {
SCOPE_EXIT {
CFRelease(bundle_url_ref);
};
CFURLRef untranslocated_url_ref = UntranslocateBundlePath(bundle_url_ref);
SCOPE_EXIT {
if (untranslocated_url_ref) {
CFRelease(untranslocated_url_ref);
}
};
char app_bundle_path[MAXPATHLEN];
if (CFURLGetFileSystemRepresentation(
untranslocated_url_ref ? untranslocated_url_ref : bundle_url_ref, true,
reinterpret_cast<u8*>(app_bundle_path), sizeof(app_bundle_path))) {
std::filesystem::path bundle_path{app_bundle_path};
return bundle_path.parent_path();
}
}
}
return std::filesystem::current_path();
}
#endif
static auto UserPaths = [] { static auto UserPaths = [] {
#ifdef __APPLE__
std::filesystem::current_path(GetBundleParentDirectory());
#endif
std::unordered_map<PathType, fs::path> paths; std::unordered_map<PathType, fs::path> paths;
const auto user_dir = std::filesystem::current_path() / PORTABLE_DIR; const auto user_dir = std::filesystem::current_path() / PORTABLE_DIR;
@ -37,6 +102,11 @@ static auto UserPaths = [] {
create_path(PathType::GameDataDir, user_dir / GAMEDATA_DIR); create_path(PathType::GameDataDir, user_dir / GAMEDATA_DIR);
create_path(PathType::TempDataDir, user_dir / TEMPDATA_DIR); create_path(PathType::TempDataDir, user_dir / TEMPDATA_DIR);
create_path(PathType::SysModuleDir, user_dir / SYSMODULES_DIR); create_path(PathType::SysModuleDir, user_dir / SYSMODULES_DIR);
create_path(PathType::DownloadDir, user_dir / DOWNLOAD_DIR);
create_path(PathType::CapturesDir, user_dir / CAPTURES_DIR);
create_path(PathType::CheatsDir, user_dir / CHEATS_DIR);
create_path(PathType::PatchesDir, user_dir / PATCHES_DIR);
create_path(PathType::AddonsDir, user_dir / ADDONS_DIR);
return paths; return paths;
}(); }();

View File

@ -18,6 +18,11 @@ enum class PathType {
TempDataDir, // Where game temp data is stored. TempDataDir, // Where game temp data is stored.
GameDataDir, // Where game data is stored. GameDataDir, // Where game data is stored.
SysModuleDir, // Where system modules are stored. SysModuleDir, // Where system modules are stored.
DownloadDir, // Where downloads/temp files are stored.
CapturesDir, // Where rdoc captures are stored.
CheatsDir, // Where cheats are stored.
PatchesDir, // Where patches are stored.
AddonsDir, // Where additional content is stored.
}; };
constexpr auto PORTABLE_DIR = "user"; constexpr auto PORTABLE_DIR = "user";
@ -31,6 +36,11 @@ constexpr auto SAVEDATA_DIR = "savedata";
constexpr auto GAMEDATA_DIR = "data"; constexpr auto GAMEDATA_DIR = "data";
constexpr auto TEMPDATA_DIR = "temp"; constexpr auto TEMPDATA_DIR = "temp";
constexpr auto SYSMODULES_DIR = "sys_modules"; constexpr auto SYSMODULES_DIR = "sys_modules";
constexpr auto DOWNLOAD_DIR = "download";
constexpr auto CAPTURES_DIR = "captures";
constexpr auto CHEATS_DIR = "cheats";
constexpr auto PATCHES_DIR = "patches";
constexpr auto ADDONS_DIR = "addcont";
// Filenames // Filenames
constexpr auto LOG_FILE = "shad_log.txt"; constexpr auto LOG_FILE = "shad_log.txt";

17
src/common/scm_rev.cpp.in Normal file
View File

@ -0,0 +1,17 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/scm_rev.h"
#define GIT_REV "@GIT_REV@"
#define GIT_BRANCH "@GIT_BRANCH@"
#define GIT_DESC "@GIT_DESC@"
namespace Common {
const char g_scm_rev[] = GIT_REV;
const char g_scm_branch[] = GIT_BRANCH;
const char g_scm_desc[] = GIT_DESC;
} // namespace

12
src/common/scm_rev.h Normal file
View File

@ -0,0 +1,12 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
namespace Common {
extern const char g_scm_rev[];
extern const char g_scm_branch[];
extern const char g_scm_desc[];
} // namespace Common

View File

@ -28,9 +28,13 @@ struct SlotId {
template <class T> template <class T>
class SlotVector { class SlotVector {
constexpr static std::size_t InitialCapacity = 1024; constexpr static std::size_t InitialCapacity = 2048;
public: public:
SlotVector() {
Reserve(InitialCapacity);
}
~SlotVector() noexcept { ~SlotVector() noexcept {
std::size_t index = 0; std::size_t index = 0;
for (u64 bits : stored_bitset) { for (u64 bits : stored_bitset) {
@ -67,19 +71,6 @@ public:
return SlotId{index}; return SlotId{index};
} }
template <typename... Args>
[[nodiscard]] SlotId swap_and_insert(SlotId existing_id, Args&&... args) noexcept {
const u32 index = FreeValueIndex();
T& existing_value = values[existing_id.index].object;
new (&values[index].object) T(std::move(existing_value));
existing_value.~T();
new (&values[existing_id.index].object) T(std::forward<Args>(args)...);
SetStorageBit(index);
return SlotId{index};
}
void erase(SlotId id) noexcept { void erase(SlotId id) noexcept {
values[id.index].object.~T(); values[id.index].object.~T();
free_list.push_back(id.index); free_list.push_back(id.index);
@ -151,7 +142,8 @@ private:
const std::size_t old_free_size = free_list.size(); const std::size_t old_free_size = free_list.size();
free_list.resize(old_free_size + (new_capacity - values_capacity)); free_list.resize(old_free_size + (new_capacity - values_capacity));
std::iota(free_list.begin() + old_free_size, free_list.end(), const std::size_t new_free_size = free_list.size();
std::iota(free_list.rbegin(), free_list.rbegin() + new_free_size - old_free_size,
static_cast<u32>(values_capacity)); static_cast<u32>(values_capacity));
delete[] values; delete[] values;

View File

@ -9,6 +9,7 @@
#include "common/thread.h" #include "common/thread.h"
#ifdef __APPLE__ #ifdef __APPLE__
#include <mach/mach.h> #include <mach/mach.h>
#include <pthread.h>
#elif defined(_WIN32) #elif defined(_WIN32)
#include <windows.h> #include <windows.h>
#include "common/string_util.h" #include "common/string_util.h"

View File

@ -94,7 +94,7 @@ namespace Common {
// This function divides a u128 by a u32 value and produces two u64 values: // This function divides a u128 by a u32 value and produces two u64 values:
// the result of division and the remainder // the result of division and the remainder
[[nodiscard]] static inline std::pair<u64, u64> Divide128On32(u128 dividend, u32 divisor) { [[nodiscard]] static inline std::pair<u64, u64> Divide128On32(const u128& dividend, u32 divisor) {
u64 remainder = dividend[0] % divisor; u64 remainder = dividend[0] % divisor;
u64 accum = dividend[0] / divisor; u64 accum = dividend[0] / divisor;
if (dividend[1] == 0) if (dividend[1] == 0)

61
src/common/unique_function.h Executable file
View File

@ -0,0 +1,61 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
#include <utility>
namespace Common {
/// General purpose function wrapper similar to std::function.
/// Unlike std::function, the captured values don't have to be copyable.
/// This class can be moved but not copied.
template <typename ResultType, typename... Args>
class UniqueFunction {
class CallableBase {
public:
virtual ~CallableBase() = default;
virtual ResultType operator()(Args&&...) = 0;
};
template <typename Functor>
class Callable final : public CallableBase {
public:
Callable(Functor&& functor_) : functor{std::move(functor_)} {}
~Callable() override = default;
ResultType operator()(Args&&... args) override {
return functor(std::forward<Args>(args)...);
}
private:
Functor functor;
};
public:
UniqueFunction() = default;
template <typename Functor>
UniqueFunction(Functor&& functor)
: callable{std::make_unique<Callable<Functor>>(std::move(functor))} {}
UniqueFunction& operator=(UniqueFunction&& rhs) noexcept = default;
UniqueFunction(UniqueFunction&& rhs) noexcept = default;
UniqueFunction& operator=(const UniqueFunction&) = delete;
UniqueFunction(const UniqueFunction&) = delete;
ResultType operator()(Args&&... args) const {
return (*callable)(std::forward<Args>(args)...);
}
explicit operator bool() const noexcept {
return static_cast<bool>(callable);
}
private:
std::unique_ptr<CallableBase> callable;
};
} // namespace Common

View File

@ -8,6 +8,7 @@
namespace Common { namespace Common {
constexpr char VERSION[] = "0.1.1 WIP"; constexpr char VERSION[] = "0.2.1 WIP";
constexpr bool isRelease = false;
} // namespace Common } // namespace Common

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <boost/icl/separate_interval_set.hpp> #include <boost/icl/separate_interval_set.hpp>
#include "common/alignment.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/error.h" #include "common/error.h"
#include "core/address_space.h" #include "core/address_space.h"
@ -15,6 +16,11 @@
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif
#ifdef __APPLE__
// Reserve space for the system address space using a zerofill section.
asm(".zerofill GUEST_SYSTEM,GUEST_SYSTEM,__guest_system,0xFBFC00000");
#endif
namespace Core { namespace Core {
static constexpr size_t BackingSize = SCE_KERNEL_MAIN_DMEM_SIZE; static constexpr size_t BackingSize = SCE_KERNEL_MAIN_DMEM_SIZE;
@ -52,24 +58,48 @@ struct AddressSpace::Impl {
// to a reasonable amount. // to a reasonable amount.
static constexpr size_t ReductionOnFail = 1_GB; static constexpr size_t ReductionOnFail = 1_GB;
static constexpr size_t MaxReductions = 10; static constexpr size_t MaxReductions = 10;
virtual_size = SystemSize + UserSize + ReductionOnFail;
for (u32 i = 0; i < MaxReductions && !virtual_base; i++) { size_t reduction = 0;
virtual_size -= ReductionOnFail; size_t virtual_size = SystemManagedSize + SystemReservedSize + UserSize;
virtual_base = static_cast<u8*>(VirtualAlloc2(process, NULL, virtual_size, for (u32 i = 0; i < MaxReductions; i++) {
virtual_base = static_cast<u8*>(VirtualAlloc2(process, NULL, virtual_size - reduction,
MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
PAGE_NOACCESS, &param, 1)); PAGE_NOACCESS, &param, 1));
if (virtual_base) {
break;
}
reduction += ReductionOnFail;
} }
ASSERT_MSG(virtual_base, "Unable to reserve virtual address space!"); ASSERT_MSG(virtual_base, "Unable to reserve virtual address space!");
// Take the reduction off of the system managed area, and leave the others unchanged.
system_managed_base = virtual_base;
system_managed_size = SystemManagedSize - reduction;
system_reserved_base = reinterpret_cast<u8*>(SYSTEM_RESERVED_MIN);
system_reserved_size = SystemReservedSize;
user_base = reinterpret_cast<u8*>(USER_MIN);
user_size = UserSize;
LOG_INFO(Kernel_Vmm, "System managed virtual memory region: {} - {}",
fmt::ptr(system_managed_base),
fmt::ptr(system_managed_base + system_managed_size - 1));
LOG_INFO(Kernel_Vmm, "System reserved virtual memory region: {} - {}",
fmt::ptr(system_reserved_base),
fmt::ptr(system_reserved_base + system_reserved_size - 1));
LOG_INFO(Kernel_Vmm, "User virtual memory region: {} - {}", fmt::ptr(user_base),
fmt::ptr(user_base + user_size - 1));
// Initializer placeholder tracker // Initializer placeholder tracker
const uintptr_t virtual_addr = reinterpret_cast<uintptr_t>(virtual_base); const uintptr_t system_managed_addr = reinterpret_cast<uintptr_t>(system_managed_base);
placeholders.insert({virtual_addr, virtual_addr + virtual_size}); const uintptr_t system_reserved_addr = reinterpret_cast<uintptr_t>(system_reserved_base);
const uintptr_t user_addr = reinterpret_cast<uintptr_t>(user_base);
placeholders.insert({system_managed_addr, virtual_size - reduction});
// Allocate backing file that represents the total physical memory. // Allocate backing file that represents the total physical memory.
backing_handle = backing_handle =
CreateFileMapping2(INVALID_HANDLE_VALUE, nullptr, FILE_MAP_WRITE | FILE_MAP_READ, CreateFileMapping2(INVALID_HANDLE_VALUE, nullptr, FILE_MAP_WRITE | FILE_MAP_READ,
PAGE_READWRITE, SEC_COMMIT, BackingSize, nullptr, nullptr, 0); PAGE_READWRITE, SEC_COMMIT, BackingSize, nullptr, nullptr, 0);
ASSERT(backing_handle); ASSERT_MSG(backing_handle, "{}", Common::GetLastErrorMsg());
// Allocate a virtual memory for the backing file map as placeholder // Allocate a virtual memory for the backing file map as placeholder
backing_base = static_cast<u8*>(VirtualAlloc2(process, nullptr, BackingSize, backing_base = static_cast<u8*>(VirtualAlloc2(process, nullptr, BackingSize,
MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
@ -77,7 +107,7 @@ struct AddressSpace::Impl {
// Map backing placeholder. This will commit the pages // Map backing placeholder. This will commit the pages
void* const ret = MapViewOfFile3(backing_handle, process, backing_base, 0, BackingSize, void* const ret = MapViewOfFile3(backing_handle, process, backing_base, 0, BackingSize,
MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, nullptr, 0); MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, nullptr, 0);
ASSERT(ret == backing_base); ASSERT_MSG(ret == backing_base, "{}", Common::GetLastErrorMsg());
} }
~Impl() { ~Impl() {
@ -100,9 +130,10 @@ struct AddressSpace::Impl {
} }
void* Map(VAddr virtual_addr, PAddr phys_addr, size_t size, ULONG prot, uintptr_t fd = 0) { void* Map(VAddr virtual_addr, PAddr phys_addr, size_t size, ULONG prot, uintptr_t fd = 0) {
const size_t aligned_size = Common::AlignUp(size, 16_KB);
const auto it = placeholders.find(virtual_addr); const auto it = placeholders.find(virtual_addr);
ASSERT_MSG(it != placeholders.end(), "Cannot map already mapped region"); ASSERT_MSG(it != placeholders.end(), "Cannot map already mapped region");
ASSERT_MSG(virtual_addr >= it->lower() && virtual_addr + size <= it->upper(), ASSERT_MSG(virtual_addr >= it->lower() && virtual_addr + aligned_size <= it->upper(),
"Map range must be fully contained in a placeholder"); "Map range must be fully contained in a placeholder");
// Windows only allows splitting a placeholder into two. // Windows only allows splitting a placeholder into two.
@ -111,7 +142,7 @@ struct AddressSpace::Impl {
// one at the start and at the end. // one at the start and at the end.
const VAddr placeholder_start = it->lower(); const VAddr placeholder_start = it->lower();
const VAddr placeholder_end = it->upper(); const VAddr placeholder_end = it->upper();
const VAddr virtual_end = virtual_addr + size; const VAddr virtual_end = virtual_addr + aligned_size;
// If the placeholder doesn't exactly start at virtual_addr, split it at the start. // If the placeholder doesn't exactly start at virtual_addr, split it at the start.
if (placeholder_start != virtual_addr) { if (placeholder_start != virtual_addr) {
@ -132,11 +163,23 @@ struct AddressSpace::Impl {
void* ptr = nullptr; void* ptr = nullptr;
if (phys_addr != -1) { if (phys_addr != -1) {
HANDLE backing = fd ? reinterpret_cast<HANDLE>(fd) : backing_handle; HANDLE backing = fd ? reinterpret_cast<HANDLE>(fd) : backing_handle;
ptr = MapViewOfFile3(backing, process, reinterpret_cast<PVOID>(virtual_addr), phys_addr, if (fd && prot == PAGE_READONLY) {
size, MEM_REPLACE_PLACEHOLDER, prot, nullptr, 0); DWORD resultvar;
ptr = VirtualAlloc2(process, reinterpret_cast<PVOID>(virtual_addr), aligned_size,
MEM_RESERVE | MEM_COMMIT | MEM_REPLACE_PLACEHOLDER,
PAGE_READWRITE, nullptr, 0);
bool ret = ReadFile(backing, ptr, size, &resultvar, NULL);
ASSERT_MSG(ret, "ReadFile failed. {}", Common::GetLastErrorMsg());
ret = VirtualProtect(ptr, size, prot, &resultvar);
ASSERT_MSG(ret, "VirtualProtect failed. {}", Common::GetLastErrorMsg());
} else {
ptr = MapViewOfFile3(backing, process, reinterpret_cast<PVOID>(virtual_addr),
phys_addr, aligned_size, MEM_REPLACE_PLACEHOLDER, prot,
nullptr, 0);
}
} else { } else {
ptr = ptr =
VirtualAlloc2(process, reinterpret_cast<PVOID>(virtual_addr), size, VirtualAlloc2(process, reinterpret_cast<PVOID>(virtual_addr), aligned_size,
MEM_RESERVE | MEM_COMMIT | MEM_REPLACE_PLACEHOLDER, prot, nullptr, 0); MEM_RESERVE | MEM_COMMIT | MEM_REPLACE_PLACEHOLDER, prot, nullptr, 0);
} }
ASSERT_MSG(ptr, "{}", Common::GetLastErrorMsg()); ASSERT_MSG(ptr, "{}", Common::GetLastErrorMsg());
@ -215,7 +258,12 @@ struct AddressSpace::Impl {
HANDLE backing_handle{}; HANDLE backing_handle{};
u8* backing_base{}; u8* backing_base{};
u8* virtual_base{}; u8* virtual_base{};
size_t virtual_size{}; u8* system_managed_base{};
size_t system_managed_size{};
u8* system_reserved_base{};
size_t system_reserved_size{};
u8* user_base{};
size_t user_size{};
boost::icl::separate_interval_set<uintptr_t> placeholders; boost::icl::separate_interval_set<uintptr_t> placeholders;
}; };
#else #else
@ -244,15 +292,67 @@ enum PosixPageProtection {
struct AddressSpace::Impl { struct AddressSpace::Impl {
Impl() { Impl() {
// Allocate virtual address placeholder for our address space. // Allocate virtual address placeholder for our address space.
void* hint_address = reinterpret_cast<void*>(SYSTEM_MANAGED_MIN); system_managed_size = SystemManagedSize;
virtual_size = SystemSize + UserSize; system_reserved_size = SystemReservedSize;
virtual_base = reinterpret_cast<u8*>( user_size = UserSize;
mmap(hint_address, virtual_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_FIXED, -1, 0)); constexpr int protection_flags = PROT_READ | PROT_WRITE;
if (virtual_base == MAP_FAILED) { constexpr int base_map_flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE;
#ifdef __APPLE__
// On ARM64 Macs, we run into limitations due to the commpage from 0xFC0000000 - 0xFFFFFFFFF
// and the GPU carveout region from 0x1000000000 - 0x6FFFFFFFFF. We can allocate the system
// managed region, as well as system reserved if reduced in size slightly, but we cannot map
// the user region where we want, so we must let the OS put it wherever possible and hope
// the game won't rely on its location.
system_managed_base = reinterpret_cast<u8*>(
mmap(reinterpret_cast<void*>(SYSTEM_MANAGED_MIN), system_managed_size, protection_flags,
base_map_flags | MAP_FIXED, -1, 0));
system_reserved_base = reinterpret_cast<u8*>(
mmap(reinterpret_cast<void*>(SYSTEM_RESERVED_MIN), system_reserved_size,
protection_flags, base_map_flags | MAP_FIXED, -1, 0));
// Cannot guarantee enough space for these areas at the desired addresses, so not MAP_FIXED.
user_base = reinterpret_cast<u8*>(mmap(reinterpret_cast<void*>(USER_MIN), user_size,
protection_flags, base_map_flags, -1, 0));
#else
const auto virtual_size = system_managed_size + system_reserved_size + user_size;
const auto virtual_base =
reinterpret_cast<u8*>(mmap(reinterpret_cast<void*>(SYSTEM_MANAGED_MIN), virtual_size,
protection_flags, base_map_flags | MAP_FIXED, -1, 0));
system_managed_base = virtual_base;
system_reserved_base = reinterpret_cast<u8*>(SYSTEM_RESERVED_MIN);
user_base = reinterpret_cast<u8*>(USER_MIN);
#endif
if (system_managed_base == MAP_FAILED || system_reserved_base == MAP_FAILED ||
user_base == MAP_FAILED) {
LOG_CRITICAL(Kernel_Vmm, "mmap failed: {}", strerror(errno)); LOG_CRITICAL(Kernel_Vmm, "mmap failed: {}", strerror(errno));
throw std::bad_alloc{}; throw std::bad_alloc{};
} }
LOG_INFO(Kernel_Vmm, "System managed virtual memory region: {} - {}",
fmt::ptr(system_managed_base),
fmt::ptr(system_managed_base + system_managed_size - 1));
LOG_INFO(Kernel_Vmm, "System reserved virtual memory region: {} - {}",
fmt::ptr(system_reserved_base),
fmt::ptr(system_reserved_base + system_reserved_size - 1));
LOG_INFO(Kernel_Vmm, "User virtual memory region: {} - {}", fmt::ptr(user_base),
fmt::ptr(user_base + user_size - 1));
const VAddr system_managed_addr = reinterpret_cast<VAddr>(system_managed_base);
const VAddr system_reserved_addr = reinterpret_cast<VAddr>(system_managed_base);
const VAddr user_addr = reinterpret_cast<VAddr>(user_base);
m_free_regions.insert({system_managed_addr, system_managed_addr + system_managed_size});
m_free_regions.insert({system_reserved_addr, system_reserved_addr + system_reserved_size});
m_free_regions.insert({user_addr, user_addr + user_size});
#ifdef __APPLE__
const auto shm_path = fmt::format("/BackingDmem{}", getpid());
backing_fd = shm_open(shm_path.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600);
if (backing_fd < 0) {
LOG_CRITICAL(Kernel_Vmm, "shm_open failed: {}", strerror(errno));
throw std::bad_alloc{};
}
shm_unlink(shm_path.c_str());
#else
madvise(virtual_base, virtual_size, MADV_HUGEPAGE); madvise(virtual_base, virtual_size, MADV_HUGEPAGE);
backing_fd = memfd_create("BackingDmem", 0); backing_fd = memfd_create("BackingDmem", 0);
@ -260,6 +360,7 @@ struct AddressSpace::Impl {
LOG_CRITICAL(Kernel_Vmm, "memfd_create failed: {}", strerror(errno)); LOG_CRITICAL(Kernel_Vmm, "memfd_create failed: {}", strerror(errno));
throw std::bad_alloc{}; throw std::bad_alloc{};
} }
#endif
// Defined to extend the file with zeros // Defined to extend the file with zeros
int ret = ftruncate(backing_fd, BackingSize); int ret = ftruncate(backing_fd, BackingSize);
@ -276,9 +377,6 @@ struct AddressSpace::Impl {
LOG_CRITICAL(Kernel_Vmm, "mmap failed: {}", strerror(errno)); LOG_CRITICAL(Kernel_Vmm, "mmap failed: {}", strerror(errno));
throw std::bad_alloc{}; throw std::bad_alloc{};
} }
const VAddr start_addr = reinterpret_cast<VAddr>(virtual_base);
m_free_regions.insert({start_addr, start_addr + virtual_size});
} }
void* Map(VAddr virtual_addr, PAddr phys_addr, size_t size, PosixPageProtection prot, void* Map(VAddr virtual_addr, PAddr phys_addr, size_t size, PosixPageProtection prot,
@ -331,16 +429,24 @@ struct AddressSpace::Impl {
int backing_fd; int backing_fd;
u8* backing_base{}; u8* backing_base{};
u8* virtual_base{}; u8* system_managed_base{};
size_t virtual_size{}; size_t system_managed_size{};
u8* system_reserved_base{};
size_t system_reserved_size{};
u8* user_base{};
size_t user_size{};
boost::icl::interval_set<VAddr> m_free_regions; boost::icl::interval_set<VAddr> m_free_regions;
}; };
#endif #endif
AddressSpace::AddressSpace() : impl{std::make_unique<Impl>()} { AddressSpace::AddressSpace() : impl{std::make_unique<Impl>()} {
virtual_base = impl->virtual_base;
backing_base = impl->backing_base; backing_base = impl->backing_base;
virtual_size = impl->virtual_size; system_managed_base = impl->system_managed_base;
system_managed_size = impl->system_managed_size;
system_reserved_base = impl->system_reserved_base;
system_reserved_size = impl->system_reserved_size;
user_base = impl->user_base;
user_size = impl->user_size;
} }
AddressSpace::~AddressSpace() = default; AddressSpace::~AddressSpace() = default;
@ -362,8 +468,28 @@ void* AddressSpace::MapFile(VAddr virtual_addr, size_t size, size_t offset, u32
#endif #endif
} }
void AddressSpace::Unmap(VAddr virtual_addr, size_t size, bool has_backing) { void AddressSpace::Unmap(VAddr virtual_addr, size_t size, VAddr start_in_vma, VAddr end_in_vma,
return impl->Unmap(virtual_addr, size, has_backing); PAddr phys_base, bool is_exec, bool has_backing, bool readonly_file) {
#ifdef _WIN32
// There does not appear to be comparable support for partial unmapping on Windows.
// Unfortunately, a least one title was found to require this. The workaround is to unmap
// the entire allocation and remap the portions outside of the requested unmapping range.
impl->Unmap(virtual_addr, size, has_backing && !readonly_file);
// TODO: Determine if any titles require partial unmapping support for flexible allocations.
ASSERT_MSG(has_backing || (start_in_vma == 0 && end_in_vma == size),
"Partial unmapping of flexible allocations is not supported");
if (start_in_vma != 0) {
Map(virtual_addr, start_in_vma, 0, phys_base, is_exec);
}
if (end_in_vma != size) {
Map(virtual_addr + end_in_vma, size - end_in_vma, 0, phys_base + end_in_vma, is_exec);
}
#else
impl->Unmap(virtual_addr + start_in_vma, end_in_vma - start_in_vma, has_backing);
#endif
} }
void AddressSpace::Protect(VAddr virtual_addr, size_t size, MemoryPermission perms) { void AddressSpace::Protect(VAddr virtual_addr, size_t size, MemoryPermission perms) {

View File

@ -18,18 +18,23 @@ enum class MemoryPermission : u32 {
}; };
DECLARE_ENUM_FLAG_OPERATORS(MemoryPermission) DECLARE_ENUM_FLAG_OPERATORS(MemoryPermission)
constexpr VAddr SYSTEM_RESERVED = 0x800000000ULL;
constexpr VAddr CODE_BASE_OFFSET = 0x100000000ULL; constexpr VAddr CODE_BASE_OFFSET = 0x100000000ULL;
constexpr VAddr SYSTEM_MANAGED_MIN = 0x00000400000ULL; constexpr VAddr SYSTEM_MANAGED_MIN = 0x00000400000ULL;
constexpr VAddr SYSTEM_MANAGED_MAX = 0x07FFFFBFFFULL; constexpr VAddr SYSTEM_MANAGED_MAX = 0x07FFFFBFFFULL;
constexpr VAddr SYSTEM_RESERVED_MIN = 0x07FFFFC000ULL;
#ifdef __APPLE__
// Can only comfortably reserve the first 0x7C0000000 of system reserved space.
constexpr VAddr SYSTEM_RESERVED_MAX = 0xFBFFFFFFFULL;
#else
constexpr VAddr SYSTEM_RESERVED_MAX = 0xFFFFFFFFFULL;
#endif
constexpr VAddr USER_MIN = 0x1000000000ULL; constexpr VAddr USER_MIN = 0x1000000000ULL;
constexpr VAddr USER_MAX = 0xFBFFFFFFFFULL; constexpr VAddr USER_MAX = 0xFBFFFFFFFFULL;
// User area size is normally larger than this. However games are unlikely to map to high static constexpr size_t SystemManagedSize = SYSTEM_MANAGED_MAX - SYSTEM_MANAGED_MIN + 1;
// regions of that area, so by default we allocate a smaller virtual address space (about 1/4th). static constexpr size_t SystemReservedSize = SYSTEM_RESERVED_MAX - SYSTEM_RESERVED_MIN + 1;
// to save space on page tables. static constexpr size_t UserSize = 1ULL << 40;
static constexpr size_t UserSize = 1ULL << 39;
static constexpr size_t SystemSize = USER_MIN - SYSTEM_MANAGED_MIN;
/** /**
* Represents the user virtual address space backed by a dmem memory block * Represents the user virtual address space backed by a dmem memory block
@ -39,14 +44,34 @@ public:
explicit AddressSpace(); explicit AddressSpace();
~AddressSpace(); ~AddressSpace();
[[nodiscard]] VAddr VirtualBase() noexcept { [[nodiscard]] VAddr SystemManagedVirtualBase() noexcept {
return reinterpret_cast<VAddr>(virtual_base); return reinterpret_cast<VAddr>(system_managed_base);
} }
[[nodiscard]] const u8* VirtualBase() const noexcept { [[nodiscard]] const u8* SystemManagedVirtualBase() const noexcept {
return virtual_base; return system_managed_base;
} }
[[nodiscard]] size_t VirtualSize() const noexcept { [[nodiscard]] size_t SystemManagedVirtualSize() const noexcept {
return virtual_size; return system_managed_size;
}
[[nodiscard]] VAddr SystemReservedVirtualBase() noexcept {
return reinterpret_cast<VAddr>(system_reserved_base);
}
[[nodiscard]] const u8* SystemReservedVirtualBase() const noexcept {
return system_reserved_base;
}
[[nodiscard]] size_t SystemReservedVirtualSize() const noexcept {
return system_reserved_size;
}
[[nodiscard]] VAddr UserVirtualBase() noexcept {
return reinterpret_cast<VAddr>(user_base);
}
[[nodiscard]] const u8* UserVirtualBase() const noexcept {
return user_base;
}
[[nodiscard]] size_t UserVirtualSize() const noexcept {
return user_size;
} }
/** /**
@ -66,7 +91,8 @@ public:
void* MapFile(VAddr virtual_addr, size_t size, size_t offset, u32 prot, uintptr_t fd); void* MapFile(VAddr virtual_addr, size_t size, size_t offset, u32 prot, uintptr_t fd);
/// Unmaps specified virtual memory area. /// Unmaps specified virtual memory area.
void Unmap(VAddr virtual_addr, size_t size, bool has_backing); void Unmap(VAddr virtual_addr, size_t size, VAddr start_in_vma, VAddr end_in_vma,
PAddr phys_base, bool is_exec, bool has_backing, bool readonly_file);
void Protect(VAddr virtual_addr, size_t size, MemoryPermission perms); void Protect(VAddr virtual_addr, size_t size, MemoryPermission perms);
@ -74,8 +100,12 @@ private:
struct Impl; struct Impl;
std::unique_ptr<Impl> impl; std::unique_ptr<Impl> impl;
u8* backing_base{}; u8* backing_base{};
u8* virtual_base{}; u8* system_managed_base{};
size_t virtual_size{}; size_t system_managed_size{};
u8* system_reserved_base{};
size_t system_reserved_size{};
u8* user_base{};
size_t user_size{};
}; };
} // namespace Core } // namespace Core

View File

@ -114108,7 +114108,7 @@ STUB(
_ZN3sce2Np9CppWebApi6Common12IntrusivePtrINS1_7Matches2V124RequestCompetitiveResultEE7add_refEv) _ZN3sce2Np9CppWebApi6Common12IntrusivePtrINS1_7Matches2V124RequestCompetitiveResultEE7add_refEv)
STUB("efPahl2FufA", STUB("efPahl2FufA",
_ZN3sce2Np9CppWebApi30CommunicationRestrictionStatus2V35Error8fromJsonERKNS_4Json5ValueE) _ZN3sce2Np9CppWebApi30CommunicationRestrictionStatus2V35Error8fromJsonERKNS_4Json5ValueE)
STUB("efX3lrPwdKA", sceAppContentAddcontMountByEntitlemetId) STUB("efX3lrPwdKA", sceAppContentAddcontMountByEntitlementId)
STUB("efXnxYFN5oE", _ZNSt11range_errorD0Ev) STUB("efXnxYFN5oE", _ZNSt11range_errorD0Ev)
STUB("efcwuDLsAM0", _ZThn120_NK7WebCore16HTMLMediaElement5mutedEv) STUB("efcwuDLsAM0", _ZThn120_NK7WebCore16HTMLMediaElement5mutedEv)
STUB("efhGArzWdxE", _ZN7bmalloc6IsoTLS15s_didInitializeE) STUB("efhGArzWdxE", _ZN7bmalloc6IsoTLS15s_didInitializeE)
@ -129493,7 +129493,7 @@ STUB(
STUB("kJlYH5uMAWI", sceNetResolverDestroy) STUB("kJlYH5uMAWI", sceNetResolverDestroy)
STUB("kJmdxo4uM+8", STUB("kJmdxo4uM+8",
_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE5_InitERKSt8_Locinfo) _ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE5_InitERKSt8_Locinfo)
STUB("kJmjt81mXKQ", sceAppContentAddcontEnqueueDownloadByEntitlemetId) STUB("kJmjt81mXKQ", sceAppContentAddcontEnqueueDownloadByEntitlementId)
STUB( STUB(
"kJoY9lMIFzY", "kJoY9lMIFzY",
_ZN3sce2Np9CppWebApi6Common8IteratorINS2_12IntrusivePtrINS1_21AdvancedPlayerProfile2V138MatchCompletionRateDisconnectedMetricsEEEEmmEi) _ZN3sce2Np9CppWebApi6Common8IteratorINS2_12IntrusivePtrINS1_21AdvancedPlayerProfile2V138MatchCompletionRateDisconnectedMetricsEEEEmmEi)

View File

@ -13,7 +13,7 @@ namespace Core::AeroLib {
// on lookup, setting up the nid_entry they are matched with // on lookup, setting up the nid_entry they are matched with
// //
// If it runs out of stubs with name information, it will return // If it runs out of stubs with name information, it will return
// a default implemetnation without function name details // a default implementation without function name details
// Up to 512, larger values lead to more resolve stub slots // Up to 512, larger values lead to more resolve stub slots
// and to longer compile / CI times // and to longer compile / CI times

640
src/core/cpu_patches.cpp Normal file
View File

@ -0,0 +1,640 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <memory>
#include <mutex>
#include <Zydis/Zydis.h>
#include <xbyak/xbyak.h>
#include "common/assert.h"
#include "common/types.h"
#include "core/tls.h"
#include "cpu_patches.h"
#ifdef _WIN32
#include <windows.h>
#else
#include <pthread.h>
#ifdef __APPLE__
#include <half.hpp>
#include <sys/sysctl.h>
#endif
#endif
using namespace Xbyak::util;
namespace Core {
static Xbyak::Reg ZydisToXbyakRegister(const ZydisRegister reg) {
if (reg >= ZYDIS_REGISTER_EAX && reg <= ZYDIS_REGISTER_R15D) {
return Xbyak::Reg32(reg - ZYDIS_REGISTER_EAX + Xbyak::Operand::EAX);
}
if (reg >= ZYDIS_REGISTER_RAX && reg <= ZYDIS_REGISTER_R15) {
return Xbyak::Reg64(reg - ZYDIS_REGISTER_RAX + Xbyak::Operand::RAX);
}
if (reg >= ZYDIS_REGISTER_XMM0 && reg <= ZYDIS_REGISTER_XMM31) {
return Xbyak::Xmm(reg - ZYDIS_REGISTER_XMM0 + xmm0.getIdx());
}
if (reg >= ZYDIS_REGISTER_YMM0 && reg <= ZYDIS_REGISTER_YMM31) {
return Xbyak::Ymm(reg - ZYDIS_REGISTER_YMM0 + ymm0.getIdx());
}
UNREACHABLE_MSG("Unsupported register: {}", static_cast<u32>(reg));
}
static Xbyak::Reg ZydisToXbyakRegisterOperand(const ZydisDecodedOperand& operand) {
ASSERT_MSG(operand.type == ZYDIS_OPERAND_TYPE_REGISTER,
"Expected register operand, got type: {}", static_cast<u32>(operand.type));
return ZydisToXbyakRegister(operand.reg.value);
}
static Xbyak::Address ZydisToXbyakMemoryOperand(const ZydisDecodedOperand& operand) {
ASSERT_MSG(operand.type == ZYDIS_OPERAND_TYPE_MEMORY, "Expected memory operand, got type: {}",
static_cast<u32>(operand.type));
if (operand.mem.base == ZYDIS_REGISTER_RIP) {
return ptr[rip + operand.mem.disp.value];
}
Xbyak::RegExp expression{};
if (operand.mem.base != ZYDIS_REGISTER_NONE) {
expression = expression + ZydisToXbyakRegister(operand.mem.base);
}
if (operand.mem.index != ZYDIS_REGISTER_NONE) {
if (operand.mem.scale != 0) {
expression = expression + ZydisToXbyakRegister(operand.mem.index) * operand.mem.scale;
} else {
expression = expression + ZydisToXbyakRegister(operand.mem.index);
}
}
if (operand.mem.disp.size != 0 && operand.mem.disp.value != 0) {
expression = expression + operand.mem.disp.value;
}
return ptr[expression];
}
static u64 ZydisToXbyakImmediateOperand(const ZydisDecodedOperand& operand) {
ASSERT_MSG(operand.type == ZYDIS_OPERAND_TYPE_IMMEDIATE,
"Expected immediate operand, got type: {}", static_cast<u32>(operand.type));
return operand.imm.value.u;
}
static std::unique_ptr<Xbyak::Operand> ZydisToXbyakOperand(const ZydisDecodedOperand& operand) {
switch (operand.type) {
case ZYDIS_OPERAND_TYPE_REGISTER: {
return std::make_unique<Xbyak::Reg>(ZydisToXbyakRegisterOperand(operand));
}
case ZYDIS_OPERAND_TYPE_MEMORY: {
return std::make_unique<Xbyak::Address>(ZydisToXbyakMemoryOperand(operand));
}
default:
UNREACHABLE_MSG("Unsupported operand type: {}", static_cast<u32>(operand.type));
}
}
static bool OperandUsesRegister(const Xbyak::Operand* operand, int index) {
if (operand->isREG()) {
return operand->getIdx() == index;
}
if (operand->isMEM()) {
const Xbyak::RegExp& reg_exp = operand->getAddress().getRegExp();
return reg_exp.getBase().getIdx() == index || reg_exp.getIndex().getIdx() == index;
}
UNREACHABLE_MSG("Unsupported operand kind: {}", static_cast<u32>(operand->getKind()));
}
static bool IsRegisterAllocated(
const std::initializer_list<const Xbyak::Operand*>& allocated_registers, const int index) {
return std::ranges::find_if(allocated_registers.begin(), allocated_registers.end(),
[index](const Xbyak::Operand* operand) {
return OperandUsesRegister(operand, index);
}) != allocated_registers.end();
}
static Xbyak::Reg AllocateScratchRegister(
const std::initializer_list<const Xbyak::Operand*> allocated_registers, const u32 bits) {
for (int index = Xbyak::Operand::R8; index <= Xbyak::Operand::R15; index++) {
if (!IsRegisterAllocated(allocated_registers, index)) {
return Xbyak::Reg32e(index, static_cast<int>(bits));
}
}
UNREACHABLE_MSG("Out of scratch registers!");
}
#ifdef __APPLE__
static pthread_key_t stack_pointer_slot;
static pthread_key_t patch_stack_slot;
static std::once_flag patch_context_slots_init_flag;
static_assert(sizeof(void*) == sizeof(u64),
"Cannot fit a register inside a thread local storage slot.");
static void InitializePatchContextSlots() {
ASSERT_MSG(pthread_key_create(&stack_pointer_slot, nullptr) == 0,
"Unable to allocate thread-local register for stack pointer.");
ASSERT_MSG(pthread_key_create(&patch_stack_slot, nullptr) == 0,
"Unable to allocate thread-local register for patch stack.");
}
void InitializeThreadPatchStack() {
std::call_once(patch_context_slots_init_flag, InitializePatchContextSlots);
const auto* patch_stack = std::malloc(0x1000);
pthread_setspecific(patch_stack_slot, patch_stack);
}
void CleanupThreadPatchStack() {
std::call_once(patch_context_slots_init_flag, InitializePatchContextSlots);
auto* patch_stack = pthread_getspecific(patch_stack_slot);
if (patch_stack != nullptr) {
std::free(patch_stack);
pthread_setspecific(patch_stack_slot, nullptr);
}
}
/// Saves the stack pointer to thread local storage and loads the patch stack.
static void SaveStack(Xbyak::CodeGenerator& c) {
std::call_once(patch_context_slots_init_flag, InitializePatchContextSlots);
// Save stack pointer and load patch stack.
c.putSeg(gs);
c.mov(qword[reinterpret_cast<void*>(stack_pointer_slot * sizeof(void*))], rsp);
c.putSeg(gs);
c.mov(rsp, qword[reinterpret_cast<void*>(patch_stack_slot * sizeof(void*))]);
}
/// Restores the stack pointer from thread local storage.
static void RestoreStack(Xbyak::CodeGenerator& c) {
std::call_once(patch_context_slots_init_flag, InitializePatchContextSlots);
// Save patch stack pointer and load original stack.
c.putSeg(gs);
c.mov(qword[reinterpret_cast<void*>(patch_stack_slot * sizeof(void*))], rsp);
c.putSeg(gs);
c.mov(rsp, qword[reinterpret_cast<void*>(stack_pointer_slot * sizeof(void*))]);
}
#else
// These utilities are not implemented as we can't save anything to thread local storage without
// temporary registers.
void InitializeThreadPatchStack() {
// No-op
}
void CleanupThreadPatchStack() {
// No-op
}
/// Saves the stack pointer to thread local storage and loads the patch stack.
static void SaveStack(Xbyak::CodeGenerator& c) {
UNIMPLEMENTED();
}
/// Restores the stack pointer from thread local storage.
static void RestoreStack(Xbyak::CodeGenerator& c) {
UNIMPLEMENTED();
}
#endif
/// Switches to the patch stack, saves registers, and restores the original stack.
static void SaveRegisters(Xbyak::CodeGenerator& c, const std::initializer_list<Xbyak::Reg> regs) {
SaveStack(c);
for (const auto& reg : regs) {
c.push(reg.cvt64());
}
RestoreStack(c);
}
/// Switches to the patch stack, restores registers, and restores the original stack.
static void RestoreRegisters(Xbyak::CodeGenerator& c,
const std::initializer_list<Xbyak::Reg> regs) {
SaveStack(c);
for (const auto& reg : regs) {
c.pop(reg.cvt64());
}
RestoreStack(c);
}
/// Switches to the patch stack and stores all registers.
static void SaveContext(Xbyak::CodeGenerator& c) {
SaveStack(c);
for (int reg = Xbyak::Operand::RAX; reg <= Xbyak::Operand::R15; reg++) {
c.push(Xbyak::Reg64(reg));
}
for (int reg = 0; reg <= 7; reg++) {
c.sub(rsp, 32);
c.vmovdqu(ptr[rsp], Xbyak::Ymm(reg));
}
}
/// Restores all registers and restores the original stack.
/// If the destination is a register, it is not restored to preserve the output.
static void RestoreContext(Xbyak::CodeGenerator& c, const Xbyak::Operand& dst) {
for (int reg = 7; reg >= 0; reg--) {
if ((!dst.isXMM() && !dst.isYMM()) || dst.getIdx() != reg) {
c.vmovdqu(Xbyak::Ymm(reg), ptr[rsp]);
}
c.add(rsp, 32);
}
for (int reg = Xbyak::Operand::R15; reg >= Xbyak::Operand::RAX; reg--) {
if (!dst.isREG() || dst.getIdx() != reg) {
c.pop(Xbyak::Reg64(reg));
} else {
c.add(rsp, 4);
}
}
RestoreStack(c);
}
#ifdef __APPLE__
static void GenerateANDN(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
const auto src1 = ZydisToXbyakRegisterOperand(operands[1]);
const auto src2 = ZydisToXbyakOperand(operands[2]);
const auto scratch = AllocateScratchRegister({&dst, &src1, src2.get()}, dst.getBit());
SaveRegisters(c, {scratch});
c.mov(scratch, src1);
c.not_(scratch);
c.and_(scratch, *src2);
c.mov(dst, scratch);
RestoreRegisters(c, {scratch});
}
static void GenerateBEXTR(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
const auto src = ZydisToXbyakOperand(operands[1]);
const auto start_len = ZydisToXbyakRegisterOperand(operands[2]);
const Xbyak::Reg32e shift(Xbyak::Operand::RCX, static_cast<int>(start_len.getBit()));
const auto scratch1 =
AllocateScratchRegister({&dst, src.get(), &start_len, &shift}, dst.getBit());
const auto scratch2 =
AllocateScratchRegister({&dst, src.get(), &start_len, &shift, &scratch1}, dst.getBit());
if (dst.getIdx() == shift.getIdx()) {
SaveRegisters(c, {scratch1, scratch2});
} else {
SaveRegisters(c, {scratch1, scratch2, shift});
}
c.mov(scratch1, *src);
if (shift.getIdx() != start_len.getIdx()) {
c.mov(shift, start_len);
}
c.shr(scratch1, shift.cvt8());
c.shr(shift, 8);
c.mov(scratch2, 1);
c.shl(scratch2, shift.cvt8());
c.dec(scratch2);
c.mov(dst, scratch1);
c.and_(dst, scratch2);
if (dst.getIdx() == shift.getIdx()) {
RestoreRegisters(c, {scratch2, scratch1});
} else {
RestoreRegisters(c, {shift, scratch2, scratch1});
}
}
static void GenerateBLSI(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
const auto src = ZydisToXbyakOperand(operands[1]);
const auto scratch = AllocateScratchRegister({&dst, src.get()}, dst.getBit());
SaveRegisters(c, {scratch});
c.mov(scratch, *src);
c.neg(scratch);
c.and_(scratch, *src);
c.mov(dst, scratch);
RestoreRegisters(c, {scratch});
}
static void GenerateBLSMSK(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
const auto src = ZydisToXbyakOperand(operands[1]);
const auto scratch = AllocateScratchRegister({&dst, src.get()}, dst.getBit());
SaveRegisters(c, {scratch});
c.mov(scratch, *src);
c.dec(scratch);
c.xor_(scratch, *src);
c.mov(dst, scratch);
RestoreRegisters(c, {scratch});
}
static void GenerateBLSR(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
const auto src = ZydisToXbyakOperand(operands[1]);
const auto scratch = AllocateScratchRegister({&dst, src.get()}, dst.getBit());
SaveRegisters(c, {scratch});
c.mov(scratch, *src);
c.dec(scratch);
c.and_(scratch, *src);
c.mov(dst, scratch);
RestoreRegisters(c, {scratch});
}
static __attribute__((sysv_abi)) void PerformVCVTPH2PS(float* out, const half_float::half* in,
const u32 count) {
for (u32 i = 0; i < count; i++) {
out[i] = half_float::half_cast<float>(in[i]);
}
}
static void GenerateVCVTPH2PS(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
const auto src = ZydisToXbyakOperand(operands[1]);
const auto float_count = dst.getBit() / 32;
const auto byte_count = float_count * 4;
SaveContext(c);
// Allocate stack space for outputs and load into first parameter.
c.sub(rsp, byte_count);
c.mov(rdi, rsp);
if (src->isXMM()) {
// Allocate stack space for inputs and load into second parameter.
c.sub(rsp, byte_count);
c.mov(rsi, rsp);
// Move input to the allocated space.
c.movdqu(ptr[rsp], *reinterpret_cast<Xbyak::Xmm*>(src.get()));
} else {
c.lea(rsi, src->getAddress());
}
// Load float count into third parameter.
c.mov(rdx, float_count);
c.mov(rax, reinterpret_cast<u64>(PerformVCVTPH2PS));
c.call(rax);
if (src->isXMM()) {
// Clean up after inputs space.
c.add(rsp, byte_count);
}
// Load outputs into destination register and clean up space.
if (dst.isYMM()) {
c.vmovdqu(*reinterpret_cast<const Xbyak::Ymm*>(&dst), ptr[rsp]);
} else {
c.movdqu(*reinterpret_cast<const Xbyak::Xmm*>(&dst), ptr[rsp]);
}
c.add(rsp, byte_count);
RestoreContext(c, dst);
}
using SingleToHalfFloatConverter = half_float::half (*)(float);
static const SingleToHalfFloatConverter SingleToHalfFloatConverters[4] = {
half_float::half_cast<half_float::half, std::round_to_nearest, float>,
half_float::half_cast<half_float::half, std::round_toward_neg_infinity, float>,
half_float::half_cast<half_float::half, std::round_toward_infinity, float>,
half_float::half_cast<half_float::half, std::round_toward_zero, float>,
};
static __attribute__((sysv_abi)) void PerformVCVTPS2PH(half_float::half* out, const float* in,
const u32 count, const u8 rounding_mode) {
const auto conversion_func = SingleToHalfFloatConverters[rounding_mode];
for (u32 i = 0; i < count; i++) {
out[i] = conversion_func(in[i]);
}
}
static void GenerateVCVTPS2PH(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
const auto dst = ZydisToXbyakOperand(operands[0]);
const auto src = ZydisToXbyakRegisterOperand(operands[1]);
const auto ctrl = ZydisToXbyakImmediateOperand(operands[2]);
const auto float_count = src.getBit() / 32;
const auto byte_count = float_count * 4;
SaveContext(c);
if (dst->isXMM()) {
// Allocate stack space for outputs and load into first parameter.
c.sub(rsp, byte_count);
c.mov(rdi, rsp);
} else {
c.lea(rdi, dst->getAddress());
}
// Allocate stack space for inputs and load into second parameter.
c.sub(rsp, byte_count);
c.mov(rsi, rsp);
// Move input to the allocated space.
if (src.isYMM()) {
c.vmovdqu(ptr[rsp], *reinterpret_cast<const Xbyak::Ymm*>(&src));
} else {
c.movdqu(ptr[rsp], *reinterpret_cast<const Xbyak::Xmm*>(&src));
}
// Load float count into third parameter.
c.mov(rdx, float_count);
// Load rounding mode into fourth parameter.
if (ctrl & 4) {
// Load from MXCSR.RC.
c.stmxcsr(ptr[rsp - 4]);
c.mov(rcx, ptr[rsp - 4]);
c.shr(rcx, 13);
c.and_(rcx, 3);
} else {
c.mov(rcx, ctrl & 3);
}
c.mov(rax, reinterpret_cast<u64>(PerformVCVTPS2PH));
c.call(rax);
// Clean up after inputs space.
c.add(rsp, byte_count);
if (dst->isXMM()) {
// Load outputs into destination register and clean up space.
c.movdqu(*reinterpret_cast<Xbyak::Xmm*>(dst.get()), ptr[rsp]);
c.add(rsp, byte_count);
}
RestoreContext(c, *dst);
}
static bool FilterRosetta2Only(const ZydisDecodedOperand*) {
int ret = 0;
size_t size = sizeof(ret);
if (sysctlbyname("sysctl.proc_translated", &ret, &size, nullptr, 0) != 0) {
return false;
}
return ret;
}
#endif // __APPLE__
static bool FilterTcbAccess(const ZydisDecodedOperand* operands) {
const auto& dst_op = operands[0];
const auto& src_op = operands[1];
// Patch only 'mov (64-bit register), fs:[0]'
return src_op.type == ZYDIS_OPERAND_TYPE_MEMORY && src_op.mem.segment == ZYDIS_REGISTER_FS &&
src_op.mem.base == ZYDIS_REGISTER_NONE && src_op.mem.index == ZYDIS_REGISTER_NONE &&
src_op.mem.disp.value == 0 && dst_op.reg.value >= ZYDIS_REGISTER_RAX &&
dst_op.reg.value <= ZYDIS_REGISTER_R15;
}
static void GenerateTcbAccess(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
const auto slot = GetTcbKey();
#if defined(_WIN32)
// The following logic is based on the Kernel32.dll asm of TlsGetValue
static constexpr u32 TlsSlotsOffset = 0x1480;
static constexpr u32 TlsExpansionSlotsOffset = 0x1780;
static constexpr u32 TlsMinimumAvailable = 64;
// Load the pointer to the table of TLS slots.
c.putSeg(gs);
if (slot < TlsMinimumAvailable) {
// Load the pointer to TLS slots.
c.mov(dst, ptr[reinterpret_cast<void*>(TlsSlotsOffset + slot * sizeof(LPVOID))]);
} else {
const u32 tls_index = slot - TlsMinimumAvailable;
// Load the pointer to the table of TLS expansion slots.
c.mov(dst, ptr[reinterpret_cast<void*>(TlsExpansionSlotsOffset)]);
// Load the pointer to our buffer.
c.mov(dst, qword[dst + tls_index * sizeof(LPVOID)]);
}
#elif defined(__APPLE__)
// The following logic is based on the Darwin implementation of _os_tsd_get_direct, used by
// pthread_getspecific https://github.com/apple/darwin-xnu/blob/main/libsyscall/os/tsd.h#L89-L96
c.putSeg(gs);
c.mov(dst, qword[reinterpret_cast<void*>(slot * sizeof(void*))]);
#else
const auto src = ZydisToXbyakMemoryOperand(operands[1]);
// Replace fs read with gs read.
c.putSeg(gs);
c.mov(dst, src);
#endif
}
using PatchFilter = bool (*)(const ZydisDecodedOperand*);
using InstructionGenerator = void (*)(const ZydisDecodedOperand*, Xbyak::CodeGenerator&);
struct PatchInfo {
/// Filter for more granular patch conditions past just the instruction mnemonic.
PatchFilter filter;
/// Generator for the patch/trampoline.
InstructionGenerator generator;
/// Whether to use a trampoline for this patch.
bool trampoline;
};
static const std::unordered_map<ZydisMnemonic, PatchInfo> Patches = {
#if defined(_WIN32) || defined(__APPLE__)
// Windows and Apple need a trampoline.
{ZYDIS_MNEMONIC_MOV, {FilterTcbAccess, GenerateTcbAccess, true}},
#else
{ZYDIS_MNEMONIC_MOV, {FilterTcbAccess, GenerateTcbAccess, false}},
#endif
#ifdef __APPLE__
// Patches for instruction sets not supported by Rosetta 2.
// BMI1
{ZYDIS_MNEMONIC_ANDN, {FilterRosetta2Only, GenerateANDN, true}},
{ZYDIS_MNEMONIC_BEXTR, {FilterRosetta2Only, GenerateBEXTR, true}},
{ZYDIS_MNEMONIC_BLSI, {FilterRosetta2Only, GenerateBLSI, true}},
{ZYDIS_MNEMONIC_BLSMSK, {FilterRosetta2Only, GenerateBLSMSK, true}},
{ZYDIS_MNEMONIC_BLSR, {FilterRosetta2Only, GenerateBLSR, true}},
// F16C
{ZYDIS_MNEMONIC_VCVTPH2PS, {FilterRosetta2Only, GenerateVCVTPH2PS, true}},
{ZYDIS_MNEMONIC_VCVTPS2PH, {FilterRosetta2Only, GenerateVCVTPS2PH, true}},
#endif
};
void PatchInstructions(u64 segment_addr, u64 segment_size, Xbyak::CodeGenerator& c) {
if (Patches.empty()) {
// Nothing to patch on this platform.
return;
}
ZydisDecoder instr_decoder;
ZydisDecodedInstruction instruction;
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT];
ZydisDecoderInit(&instr_decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_STACK_WIDTH_64);
u8* code = reinterpret_cast<u8*>(segment_addr);
u8* end = code + segment_size;
while (code < end) {
ZyanStatus status =
ZydisDecoderDecodeFull(&instr_decoder, code, end - code, &instruction, operands);
if (!ZYAN_SUCCESS(status)) {
code++;
continue;
}
if (Patches.contains(instruction.mnemonic)) {
auto patch_info = Patches.at(instruction.mnemonic);
if (patch_info.filter(operands)) {
auto patch_gen = Xbyak::CodeGenerator(instruction.length, code);
if (patch_info.trampoline) {
const auto trampoline_ptr = c.getCurr();
patch_info.generator(operands, c);
// Return to the following instruction at the end of the trampoline.
c.jmp(code + instruction.length);
// Replace instruction with near jump to the trampoline.
patch_gen.jmp(trampoline_ptr, Xbyak::CodeGenerator::LabelType::T_NEAR);
} else {
patch_info.generator(operands, patch_gen);
}
const auto patch_size = patch_gen.getCurr() - code;
if (patch_size > 0) {
ASSERT_MSG(instruction.length >= patch_size,
"Instruction {} with length {} is too short to replace at: {}",
ZydisMnemonicGetString(instruction.mnemonic), instruction.length,
fmt::ptr(code));
// Fill remaining space with nops.
patch_gen.nop(instruction.length - patch_size);
LOG_DEBUG(Core, "Patched instruction '{}' at: {}",
ZydisMnemonicGetString(instruction.mnemonic), fmt::ptr(code));
}
}
}
code += instruction.length;
}
}
} // namespace Core

21
src/core/cpu_patches.h Normal file
View File

@ -0,0 +1,21 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
namespace Xbyak {
class CodeGenerator;
}
namespace Core {
/// Initializes a stack for the current thread for use by patch implementations.
void InitializeThreadPatchStack();
/// Cleans up the patch stack for the current thread.
void CleanupThreadPatchStack();
/// Patches CPU instructions that cannot run as-is on the host.
void PatchInstructions(u64 segment_addr, u64 segment_size, Xbyak::CodeGenerator& c);
} // namespace Core

View File

@ -6,18 +6,18 @@
CryptoPP::RSA::PrivateKey Crypto::key_pkg_derived_key3_keyset_init() { CryptoPP::RSA::PrivateKey Crypto::key_pkg_derived_key3_keyset_init() {
CryptoPP::InvertibleRSAFunction params; CryptoPP::InvertibleRSAFunction params;
params.SetPrime1(CryptoPP::Integer(pkg_derived_key3_keyset.Prime1, 0x80)); params.SetPrime1(CryptoPP::Integer(PkgDerivedKey3Keyset::Prime1, 0x80));
params.SetPrime2(CryptoPP::Integer(pkg_derived_key3_keyset.Prime2, 0x80)); params.SetPrime2(CryptoPP::Integer(PkgDerivedKey3Keyset::Prime2, 0x80));
params.SetPublicExponent(CryptoPP::Integer(pkg_derived_key3_keyset.PublicExponent, 4)); params.SetPublicExponent(CryptoPP::Integer(PkgDerivedKey3Keyset::PublicExponent, 4));
params.SetPrivateExponent(CryptoPP::Integer(pkg_derived_key3_keyset.PrivateExponent, 0x100)); params.SetPrivateExponent(CryptoPP::Integer(PkgDerivedKey3Keyset::PrivateExponent, 0x100));
params.SetModPrime1PrivateExponent(CryptoPP::Integer(pkg_derived_key3_keyset.Exponent1, 0x80)); params.SetModPrime1PrivateExponent(CryptoPP::Integer(PkgDerivedKey3Keyset::Exponent1, 0x80));
params.SetModPrime2PrivateExponent(CryptoPP::Integer(pkg_derived_key3_keyset.Exponent2, 0x80)); params.SetModPrime2PrivateExponent(CryptoPP::Integer(PkgDerivedKey3Keyset::Exponent2, 0x80));
params.SetModulus(CryptoPP::Integer(pkg_derived_key3_keyset.Modulus, 0x100)); params.SetModulus(CryptoPP::Integer(PkgDerivedKey3Keyset::Modulus, 0x100));
params.SetMultiplicativeInverseOfPrime2ModPrime1( params.SetMultiplicativeInverseOfPrime2ModPrime1(
CryptoPP::Integer(pkg_derived_key3_keyset.Coefficient, 0x80)); CryptoPP::Integer(PkgDerivedKey3Keyset::Coefficient, 0x80));
CryptoPP::RSA::PrivateKey privateKey(params); CryptoPP::RSA::PrivateKey privateKey(params);
@ -26,18 +26,18 @@ CryptoPP::RSA::PrivateKey Crypto::key_pkg_derived_key3_keyset_init() {
CryptoPP::RSA::PrivateKey Crypto::FakeKeyset_keyset_init() { CryptoPP::RSA::PrivateKey Crypto::FakeKeyset_keyset_init() {
CryptoPP::InvertibleRSAFunction params; CryptoPP::InvertibleRSAFunction params;
params.SetPrime1(CryptoPP::Integer(FakeKeyset_keyset.Prime1, 0x80)); params.SetPrime1(CryptoPP::Integer(FakeKeyset::Prime1, 0x80));
params.SetPrime2(CryptoPP::Integer(FakeKeyset_keyset.Prime2, 0x80)); params.SetPrime2(CryptoPP::Integer(FakeKeyset::Prime2, 0x80));
params.SetPublicExponent(CryptoPP::Integer(FakeKeyset_keyset.PublicExponent, 4)); params.SetPublicExponent(CryptoPP::Integer(FakeKeyset::PublicExponent, 4));
params.SetPrivateExponent(CryptoPP::Integer(FakeKeyset_keyset.PrivateExponent, 0x100)); params.SetPrivateExponent(CryptoPP::Integer(FakeKeyset::PrivateExponent, 0x100));
params.SetModPrime1PrivateExponent(CryptoPP::Integer(FakeKeyset_keyset.Exponent1, 0x80)); params.SetModPrime1PrivateExponent(CryptoPP::Integer(FakeKeyset::Exponent1, 0x80));
params.SetModPrime2PrivateExponent(CryptoPP::Integer(FakeKeyset_keyset.Exponent2, 0x80)); params.SetModPrime2PrivateExponent(CryptoPP::Integer(FakeKeyset::Exponent2, 0x80));
params.SetModulus(CryptoPP::Integer(FakeKeyset_keyset.Modulus, 0x100)); params.SetModulus(CryptoPP::Integer(FakeKeyset::Modulus, 0x100));
params.SetMultiplicativeInverseOfPrime2ModPrime1( params.SetMultiplicativeInverseOfPrime2ModPrime1(
CryptoPP::Integer(FakeKeyset_keyset.Coefficient, 0x80)); CryptoPP::Integer(FakeKeyset::Coefficient, 0x80));
CryptoPP::RSA::PrivateKey privateKey(params); CryptoPP::RSA::PrivateKey privateKey(params);
@ -46,25 +46,22 @@ CryptoPP::RSA::PrivateKey Crypto::FakeKeyset_keyset_init() {
CryptoPP::RSA::PrivateKey Crypto::DebugRifKeyset_init() { CryptoPP::RSA::PrivateKey Crypto::DebugRifKeyset_init() {
CryptoPP::InvertibleRSAFunction params; CryptoPP::InvertibleRSAFunction params;
params.SetPrime1( params.SetPrime1(CryptoPP::Integer(DebugRifKeyset::Prime1, sizeof(DebugRifKeyset::Prime1)));
CryptoPP::Integer(DebugRifKeyset_keyset.Prime1, sizeof(DebugRifKeyset_keyset.Prime1))); params.SetPrime2(CryptoPP::Integer(DebugRifKeyset::Prime2, sizeof(DebugRifKeyset::Prime2)));
params.SetPrime2(
CryptoPP::Integer(DebugRifKeyset_keyset.Prime2, sizeof(DebugRifKeyset_keyset.Prime2)));
params.SetPublicExponent(CryptoPP::Integer(DebugRifKeyset_keyset.PrivateExponent, params.SetPublicExponent(
sizeof(DebugRifKeyset_keyset.PrivateExponent))); CryptoPP::Integer(DebugRifKeyset::PublicExponent, sizeof(DebugRifKeyset::PublicExponent)));
params.SetPrivateExponent(CryptoPP::Integer(DebugRifKeyset_keyset.PrivateExponent, params.SetPrivateExponent(CryptoPP::Integer(DebugRifKeyset::PrivateExponent,
sizeof(DebugRifKeyset_keyset.PrivateExponent))); sizeof(DebugRifKeyset::PrivateExponent)));
params.SetModPrime1PrivateExponent(CryptoPP::Integer(DebugRifKeyset_keyset.Exponent1, params.SetModPrime1PrivateExponent(
sizeof(DebugRifKeyset_keyset.Exponent1))); CryptoPP::Integer(DebugRifKeyset::Exponent1, sizeof(DebugRifKeyset::Exponent1)));
params.SetModPrime2PrivateExponent(CryptoPP::Integer(DebugRifKeyset_keyset.Exponent2, params.SetModPrime2PrivateExponent(
sizeof(DebugRifKeyset_keyset.Exponent2))); CryptoPP::Integer(DebugRifKeyset::Exponent2, sizeof(DebugRifKeyset::Exponent2)));
params.SetModulus( params.SetModulus(CryptoPP::Integer(DebugRifKeyset::Modulus, sizeof(DebugRifKeyset::Modulus)));
CryptoPP::Integer(DebugRifKeyset_keyset.Modulus, sizeof(DebugRifKeyset_keyset.Modulus))); params.SetMultiplicativeInverseOfPrime2ModPrime1(
params.SetMultiplicativeInverseOfPrime2ModPrime1(CryptoPP::Integer( CryptoPP::Integer(DebugRifKeyset::Coefficient, sizeof(DebugRifKeyset::Coefficient)));
DebugRifKeyset_keyset.Coefficient, sizeof(DebugRifKeyset_keyset.Coefficient)));
CryptoPP::RSA::PrivateKey privateKey(params); CryptoPP::RSA::PrivateKey privateKey(params);

View File

@ -17,10 +17,6 @@
class Crypto { class Crypto {
public: public:
PkgDerivedKey3Keyset pkg_derived_key3_keyset;
FakeKeyset FakeKeyset_keyset;
DebugRifKeyset DebugRifKeyset_keyset;
CryptoPP::RSA::PrivateKey key_pkg_derived_key3_keyset_init(); CryptoPP::RSA::PrivateKey key_pkg_derived_key3_keyset_init();
CryptoPP::RSA::PrivateKey FakeKeyset_keyset_init(); CryptoPP::RSA::PrivateKey FakeKeyset_keyset_init();
CryptoPP::RSA::PrivateKey DebugRifKeyset_init(); CryptoPP::RSA::PrivateKey DebugRifKeyset_init();

View File

@ -7,384 +7,299 @@
class FakeKeyset { class FakeKeyset {
public: public:
// Constructor // Constructor
const CryptoPP::byte* Exponent1; static constexpr CryptoPP::byte Exponent1[] = {
0x6D, 0x48, 0xE0, 0x54, 0x40, 0x25, 0xC8, 0x41, 0x29, 0x52, 0x42, 0x27, 0xEB, 0xD2, 0xC7,
0xAB, 0x6B, 0x9C, 0x27, 0x0A, 0xB4, 0x1F, 0x94, 0x4E, 0xFA, 0x42, 0x1D, 0xB7, 0xBC, 0xB9,
0xAE, 0xBC, 0x04, 0x6F, 0x75, 0x8F, 0x10, 0x5F, 0x89, 0xAC, 0xAB, 0x9C, 0xD2, 0xFA, 0xE6,
0xA4, 0x13, 0x83, 0x68, 0xD4, 0x56, 0x38, 0xFE, 0xE5, 0x2B, 0x78, 0x44, 0x9C, 0x34, 0xE6,
0x5A, 0xA0, 0xBE, 0x05, 0x70, 0xAD, 0x15, 0xC3, 0x2D, 0x31, 0xAC, 0x97, 0x5D, 0x88, 0xFC,
0xC1, 0x62, 0x3D, 0xE2, 0xED, 0x11, 0xDB, 0xB6, 0x9E, 0xFC, 0x5A, 0x5A, 0x03, 0xF6, 0xCF,
0x08, 0xD4, 0x5D, 0x90, 0xC9, 0x2A, 0xB9, 0x9B, 0xCF, 0xC8, 0x1A, 0x65, 0xF3, 0x5B, 0xE8,
0x7F, 0xCF, 0xA5, 0xA6, 0x4C, 0x5C, 0x2A, 0x12, 0x0F, 0x92, 0xA5, 0xE3, 0xF0, 0x17, 0x1E,
0x9A, 0x97, 0x45, 0x86, 0xFD, 0xDB, 0x54, 0x25};
// exponent2 = d mod (q - 1) // exponent2 = d mod (q - 1)
const CryptoPP::byte* Exponent2; static constexpr CryptoPP::byte Exponent2[] = {
0x2A, 0x51, 0xCE, 0x02, 0x44, 0x28, 0x50, 0xE8, 0x30, 0x20, 0x7C, 0x9C, 0x55, 0xBF, 0x60,
0x39, 0xBC, 0xD1, 0xF0, 0xE7, 0x68, 0xF8, 0x08, 0x5B, 0x61, 0x1F, 0xA7, 0xBF, 0xD0, 0xE8,
0x8B, 0xB5, 0xB1, 0xD5, 0xD9, 0x16, 0xAC, 0x75, 0x0C, 0x6D, 0xF2, 0xE0, 0xB5, 0x97, 0x75,
0xD2, 0x68, 0x16, 0x1F, 0x00, 0x7D, 0x8B, 0x17, 0xE8, 0x78, 0x48, 0x41, 0x71, 0x2B, 0x18,
0x96, 0x80, 0x11, 0xDB, 0x68, 0x39, 0x9C, 0xD6, 0xE0, 0x72, 0x42, 0x86, 0xF0, 0x1B, 0x16,
0x0D, 0x3E, 0x12, 0x94, 0x3D, 0x25, 0xA8, 0xA9, 0x30, 0x9E, 0x54, 0x5A, 0xD6, 0x36, 0x6C,
0xD6, 0x8C, 0x20, 0x62, 0x8F, 0xA1, 0x6B, 0x1F, 0x7C, 0x6D, 0xB2, 0xB1, 0xC1, 0x2E, 0xAD,
0x36, 0x02, 0x9C, 0x3A, 0xCA, 0x2F, 0x09, 0xD2, 0x45, 0x9E, 0xEB, 0xF2, 0xBC, 0x6C, 0xAA,
0x3B, 0x3E, 0x90, 0xBC, 0x38, 0x67, 0x35, 0x4D};
// e // e
const CryptoPP::byte* PublicExponent; static constexpr CryptoPP::byte PublicExponent[] = {0, 1, 0, 1};
// (InverseQ)(q) = 1 mod p // (InverseQ)(q) = 1 mod p
const CryptoPP::byte* Coefficient; static constexpr CryptoPP::byte Coefficient[] = {
0x0B, 0x67, 0x1C, 0x0D, 0x6C, 0x57, 0xD3, 0xE7, 0x05, 0x65, 0x94, 0x31, 0x56, 0x55, 0xFD,
0x28, 0x08, 0xFA, 0x05, 0x8A, 0xCC, 0x55, 0x39, 0x61, 0x97, 0x63, 0xA0, 0x16, 0x27, 0x3D,
0xED, 0xC1, 0x16, 0x40, 0x2A, 0x12, 0xEA, 0x6F, 0xD9, 0xD8, 0x58, 0x56, 0xA8, 0x56, 0x8B,
0x0D, 0x38, 0x5E, 0x1E, 0x80, 0x3B, 0x5F, 0x40, 0x80, 0x6F, 0x62, 0x4F, 0x28, 0xA2, 0x69,
0xF3, 0xD3, 0xF7, 0xFD, 0xB2, 0xC3, 0x52, 0x43, 0x20, 0x92, 0x9D, 0x97, 0x8D, 0xA0, 0x15,
0x07, 0x15, 0x6E, 0xA4, 0x0D, 0x56, 0xD3, 0x37, 0x1A, 0xC4, 0x9E, 0xDF, 0x02, 0x49, 0xB8,
0x0A, 0x84, 0x62, 0xF5, 0xFA, 0xB9, 0x3F, 0xA4, 0x09, 0x76, 0xCC, 0xAA, 0xB9, 0x9B, 0xA6,
0x4F, 0xC1, 0x6A, 0x64, 0xCE, 0xD8, 0x77, 0xAB, 0x4B, 0xF9, 0xA0, 0xAE, 0xDA, 0xF1, 0x67,
0x87, 0x7C, 0x98, 0x5C, 0x7E, 0xB8, 0x73, 0xF5};
// n = p * q // n = p * q
const CryptoPP::byte* Modulus; static constexpr CryptoPP::byte Modulus[] = {
0xC6, 0xCF, 0x71, 0xE7, 0xE5, 0x9A, 0xF0, 0xD1, 0x2A, 0x2C, 0x45, 0x8B, 0xF9, 0x2A, 0x0E,
0xC1, 0x43, 0x05, 0x8B, 0xC3, 0x71, 0x17, 0x80, 0x1D, 0xCD, 0x49, 0x7D, 0xDE, 0x35, 0x9D,
0x25, 0x9B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x34, 0xC0, 0x05, 0xE5, 0x8D, 0xEF, 0x24, 0x67, 0xFF, 0x93, 0x40,
0xCF, 0x2D, 0x62, 0xA2, 0xA0, 0x50, 0xB1, 0xF1, 0x3A, 0xA8, 0x3D, 0xFD, 0x80, 0xD1, 0xF9,
0xB8, 0x05, 0x22, 0xAF, 0xC8, 0x35, 0x45, 0x90, 0x58, 0x8E, 0xE3, 0x3A, 0x7C, 0xBD, 0x3E,
0x27};
// p // p
const CryptoPP::byte* Prime1; static constexpr CryptoPP::byte Prime1[] = {
0xFE, 0xF6, 0xBF, 0x1D, 0x69, 0xAB, 0x16, 0x25, 0x08, 0x47, 0x55, 0x6B, 0x86, 0xE4, 0x35,
0x88, 0x72, 0x2A, 0xB1, 0x3D, 0xF8, 0xB6, 0x44, 0xCA, 0xB3, 0xAB, 0x19, 0xD1, 0x04, 0x24,
0x28, 0x0A, 0x74, 0x55, 0xB8, 0x15, 0x45, 0x09, 0xCC, 0x13, 0x1C, 0xF2, 0xBA, 0x37, 0xA9,
0x03, 0x90, 0x8F, 0x02, 0x10, 0xFF, 0x25, 0x79, 0x86, 0xCC, 0x18, 0x50, 0x9A, 0x10, 0x5F,
0x5B, 0x4C, 0x1C, 0x4E, 0xB0, 0xA7, 0xE3, 0x59, 0xB1, 0x2D, 0xA0, 0xC6, 0xB0, 0x20, 0x2C,
0x21, 0x33, 0x12, 0xB3, 0xAF, 0x72, 0x34, 0x83, 0xCD, 0x52, 0x2F, 0xAF, 0x0F, 0x20, 0x5A,
0x1B, 0xC0, 0xE2, 0xA3, 0x76, 0x34, 0x0F, 0xD7, 0xFC, 0xC1, 0x41, 0xC9, 0xF9, 0x79, 0x40,
0x17, 0x42, 0x21, 0x3E, 0x9D, 0xFD, 0xC7, 0xC1, 0x50, 0xDE, 0x44, 0x5A, 0xC9, 0x31, 0x89,
0x6A, 0x78, 0x05, 0xBE, 0x65, 0xB4, 0xE8, 0x2D};
// q // q
const CryptoPP::byte* Prime2; static constexpr CryptoPP::byte Prime2[] = {
const CryptoPP::byte* PrivateExponent; 0xC7, 0x9E, 0x47, 0x58, 0x00, 0x7D, 0x62, 0x82, 0xB0, 0xD2, 0x22, 0x81, 0xD4, 0xA8, 0x97,
0x1B, 0x79, 0x0C, 0x3A, 0xB0, 0xD7, 0xC9, 0x30, 0xE3, 0xC3, 0x53, 0x8E, 0x57, 0xEF, 0xF0,
// Constructor 0x9B, 0x9F, 0xB3, 0x90, 0x52, 0xC6, 0x94, 0x22, 0x36, 0xAA, 0xE6, 0x4A, 0x5F, 0x72, 0x1D,
FakeKeyset() { 0x70, 0xE8, 0x76, 0x58, 0xC8, 0xB2, 0x91, 0xCE, 0x9C, 0xC3, 0xE9, 0x09, 0x7F, 0x2E, 0x47,
// Initialize PrivateExponent 0x97, 0xCC, 0x90, 0x39, 0x15, 0x35, 0x31, 0xDE, 0x1F, 0x0C, 0x8C, 0x0D, 0xC1, 0xC2, 0x92,
PrivateExponent = new CryptoPP::byte[0x100]{ 0xBE, 0x97, 0xBF, 0x2F, 0x91, 0xA1, 0x8C, 0x7D, 0x50, 0xA8, 0x21, 0x2F, 0xD7, 0xA2, 0x9A,
0x7F, 0x76, 0xCD, 0x0E, 0xE2, 0xD4, 0xDE, 0x05, 0x1C, 0xC6, 0xD9, 0xA8, 0x0E, 0x8D, 0x7E, 0xB5, 0xA7, 0x2A, 0x90, 0x02, 0xD9, 0xF3, 0x3D, 0xD1, 0xEB, 0xB8, 0xE0, 0x5A, 0x79,
0xFA, 0x7B, 0xCA, 0x1E, 0xAA, 0x27, 0x1A, 0x40, 0xF8, 0xF1, 0x22, 0x87, 0x35, 0xDD, 0x9E, 0x7D, 0x8D, 0xCA, 0x18, 0x6D, 0xBD, 0x9E, 0xA1, 0x80, 0x28, 0x6B, 0x2A, 0xFE, 0x51,
0xDB, 0xFD, 0xEE, 0xF8, 0xC2, 0xBC, 0xBD, 0x01, 0xFB, 0x8B, 0xE2, 0x3E, 0x63, 0xB2, 0x24, 0x9B, 0x6F, 0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xAC, 0x78, 0xBB, 0x0E, 0x1A, 0x27, 0x43, 0xB5,
0x85, 0x99, 0x90, 0x79, 0x96, 0x1A, 0xD7, 0xF5, 0x4D, 0x1F, 0x37, 0x83, 0x40, 0x4A, 0x71, 0x67, 0xAF, 0xF4, 0xAB, 0x48, 0x46, 0x93, 0x73, 0xD0, 0x42, 0xAB, 0x93, 0x63, 0xE5,
0xEC, 0x39, 0x37, 0xA6, 0x80, 0x92, 0x7D, 0xC5, 0x80, 0xC7, 0xD6, 0x6F, 0xFE, 0x8A, 0x6C, 0x9A, 0xDE, 0x50, 0x24, 0xC0, 0x23, 0x7D, 0x99, 0x79, 0x3F, 0x22, 0x07, 0xE0, 0xC1,
0x79, 0x89, 0xC6, 0xB1}; 0x48, 0x56, 0x1B, 0xDF, 0x83, 0x09, 0x12, 0xB4, 0x2D, 0x45, 0x6B, 0xC9, 0xC0, 0x68, 0x85,
0x99, 0x90, 0x79, 0x96, 0x1A, 0xD7, 0xF5, 0x4D, 0x1F, 0x37, 0x83, 0x40, 0x4A, 0xEC, 0x39,
// Initialize Exponent1 0x37, 0xA6, 0x80, 0x92, 0x7D, 0xC5, 0x80, 0xC7, 0xD6, 0x6F, 0xFE, 0x8A, 0x79, 0x89, 0xC6,
Exponent1 = new CryptoPP::byte[0x80]{ 0xB1};
0x6D, 0x48, 0xE0, 0x54, 0x40, 0x25, 0xC8, 0x41, 0x29, 0x52, 0x42, 0x27, 0xEB,
0xD2, 0xC7, 0xAB, 0x6B, 0x9C, 0x27, 0x0A, 0xB4, 0x1F, 0x94, 0x4E, 0xFA, 0x42,
0x1D, 0xB7, 0xBC, 0xB9, 0xAE, 0xBC, 0x04, 0x6F, 0x75, 0x8F, 0x10, 0x5F, 0x89,
0xAC, 0xAB, 0x9C, 0xD2, 0xFA, 0xE6, 0xA4, 0x13, 0x83, 0x68, 0xD4, 0x56, 0x38,
0xFE, 0xE5, 0x2B, 0x78, 0x44, 0x9C, 0x34, 0xE6, 0x5A, 0xA0, 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, 0xD2, 0x45, 0x9E, 0xEB, 0xF2,
0xBC, 0x6C, 0xAA, 0x3B, 0x3E, 0x90, 0xBC, 0x38, 0x67, 0x35, 0x4D};
PublicExponent = new CryptoPP::byte[4]{0, 1, 0, 1};
Coefficient = new CryptoPP::byte[0x80]{
0x0B, 0x67, 0x1C, 0x0D, 0x6C, 0x57, 0xD3, 0xE7, 0x05, 0x65, 0x94, 0x31, 0x56,
0x55, 0xFD, 0x28, 0x08, 0xFA, 0x05, 0x8A, 0xCC, 0x55, 0x39, 0x61, 0x97, 0x63,
0xA0, 0x16, 0x27, 0x3D, 0xED, 0xC1, 0x16, 0x40, 0x2A, 0x12, 0xEA, 0x6F, 0xD9,
0xD8, 0x58, 0x56, 0xA8, 0x56, 0x8B, 0x0D, 0x38, 0x5E, 0x1E, 0x80, 0x3B, 0x5F,
0x40, 0x80, 0x6F, 0x62, 0x4F, 0x28, 0xA2, 0x69, 0xF3, 0xD3, 0xF7, 0xFD, 0xB2,
0xC3, 0x52, 0x43, 0x20, 0x92, 0x9D, 0x97, 0x8D, 0xA0, 0x15, 0x07, 0x15, 0x6E,
0xA4, 0x0D, 0x56, 0xD3, 0x37, 0x1A, 0xC4, 0x9E, 0xDF, 0x02, 0x49, 0xB8, 0x0A,
0x84, 0x62, 0xF5, 0xFA, 0xB9, 0x3F, 0xA4, 0x09, 0x76, 0xCC, 0xAA, 0xB9, 0x9B,
0xA6, 0x4F, 0xC1, 0x6A, 0x64, 0xCE, 0xD8, 0x77, 0xAB, 0x4B, 0xF9, 0xA0, 0xAE,
0xDA, 0xF1, 0x67, 0x87, 0x7C, 0x98, 0x5C, 0x7E, 0xB8, 0x73, 0xF5};
Modulus = new CryptoPP::byte[0x100]{
0xC6, 0xCF, 0x71, 0xE7, 0xE5, 0x9A, 0xF0, 0xD1, 0x2A, 0x2C, 0x45, 0x8B, 0xF9, 0x2A,
0x0E, 0xC1, 0x43, 0x05, 0x8B, 0xC3, 0x71, 0x17, 0x80, 0x1D, 0x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byte[0x80]{
0xC7, 0x9E, 0x47, 0x58, 0x00, 0x7D, 0x62, 0x82, 0xB0, 0xD2, 0x22, 0x81, 0xD4,
0xA8, 0x97, 0x1B, 0x79, 0x0C, 0x3A, 0xB0, 0xD7, 0xC9, 0x30, 0xE3, 0xC3, 0x53,
0x8E, 0x57, 0xEF, 0xF0, 0x9B, 0x9F, 0xB3, 0x90, 0x52, 0xC6, 0x94, 0x22, 0x36,
0xAA, 0xE6, 0x4A, 0x5F, 0x72, 0x1D, 0x70, 0xE8, 0x76, 0x58, 0xC8, 0xB2, 0x91,
0xCE, 0x9C, 0xC3, 0xE9, 0x09, 0x7F, 0x2E, 0x47, 0x97, 0xCC, 0x90, 0x39, 0x15,
0x35, 0x31, 0xDE, 0x1F, 0x0C, 0x8C, 0x0D, 0xC1, 0xC2, 0x92, 0xBE, 0x97, 0xBF,
0x2F, 0x91, 0xA1, 0x8C, 0x7D, 0x50, 0xA8, 0x21, 0x2F, 0xD7, 0xA2, 0x9A, 0x7E,
0xB5, 0xA7, 0x2A, 0x90, 0x02, 0xD9, 0xF3, 0x3D, 0xD1, 0xEB, 0xB8, 0xE0, 0x5A,
0x79, 0x9E, 0x7D, 0x8D, 0xCA, 0x18, 0x6D, 0xBD, 0x9E, 0xA1, 0x80, 0x28, 0x6B,
0x2A, 0xFE, 0x51, 0x24, 0x9B, 0x6F, 0x4D, 0x84, 0x77, 0x80, 0x23};
};
}; };
class DebugRifKeyset { class DebugRifKeyset {
public: public:
// Constructor
// std::uint8_t* PrivateExponent; // std::uint8_t* PrivateExponent;
const CryptoPP::byte* Exponent1; static constexpr CryptoPP::byte Exponent1[] = {
0xCD, 0x9A, 0x61, 0xB0, 0xB8, 0xD5, 0xB4, 0xE4, 0xE4, 0xF6, 0xAB, 0xF7, 0x27, 0xB7, 0x56,
0x59, 0x6B, 0xB9, 0x11, 0xE7, 0xF4, 0x83, 0xAF, 0xB9, 0x73, 0x99, 0x7F, 0x49, 0xA2, 0x9C,
0xF0, 0xB5, 0x6D, 0x37, 0x82, 0x14, 0x15, 0xF1, 0x04, 0x8A, 0xD4, 0x8E, 0xEB, 0x2E, 0x1F,
0xE2, 0x81, 0xA9, 0x62, 0x6E, 0xB1, 0x68, 0x75, 0x62, 0xF3, 0x0F, 0xFE, 0xD4, 0x91, 0x87,
0x98, 0x78, 0xBF, 0x26, 0xB5, 0x07, 0x58, 0xD0, 0xEE, 0x3F, 0x21, 0xE8, 0xC8, 0x0F, 0x5F,
0xFA, 0x1C, 0x64, 0x74, 0x49, 0x52, 0xEB, 0xE7, 0xEE, 0xDE, 0xBA, 0x23, 0x26, 0x4A, 0xF6,
0x9C, 0x1A, 0x09, 0x3F, 0xB9, 0x0B, 0x36, 0x26, 0x1A, 0xBE, 0xA9, 0x76, 0xE6, 0xF2, 0x69,
0xDE, 0xFF, 0xAF, 0xCC, 0x0C, 0x9A, 0x66, 0x03, 0x86, 0x0A, 0x1F, 0x49, 0xA4, 0x10, 0xB6,
0xBC, 0xC3, 0x7C, 0x88, 0xE8, 0xCE, 0x4B, 0xD9};
// exponent2 = d mod (q - 1) // exponent2 = d mod (q - 1)
const CryptoPP::byte* Exponent2; static constexpr CryptoPP::byte Exponent2[] = {
0xB3, 0x73, 0xA3, 0x59, 0xE6, 0x97, 0xC0, 0xAB, 0x3B, 0x68, 0xFC, 0x39, 0xAC, 0xDB, 0x44,
0xB1, 0xB4, 0x9E, 0x35, 0x4D, 0xBE, 0xC5, 0x36, 0x69, 0x6C, 0x3D, 0xC5, 0xFC, 0xFE, 0x4B,
0x2F, 0xDC, 0x86, 0x80, 0x46, 0x96, 0x40, 0x1A, 0x0D, 0x6E, 0xFA, 0x8C, 0xE0, 0x47, 0x91,
0xAC, 0xAD, 0x95, 0x2B, 0x8E, 0x1F, 0xF2, 0x0A, 0x45, 0xF8, 0x29, 0x95, 0x70, 0xC6, 0x88,
0x5F, 0x71, 0x03, 0x99, 0x79, 0xBC, 0x84, 0x71, 0xBD, 0xE8, 0x84, 0x8C, 0x0E, 0xD4, 0x7B,
0x30, 0x74, 0x57, 0x1A, 0x95, 0xE7, 0x90, 0x19, 0x8D, 0xAD, 0x8B, 0x4C, 0x4E, 0xC3, 0xE7,
0x6B, 0x23, 0x86, 0x01, 0xEE, 0x9B, 0xE0, 0x2F, 0x15, 0xA2, 0x2C, 0x4C, 0x39, 0xD3, 0xDF,
0x9C, 0x39, 0x01, 0xF1, 0x8C, 0x44, 0x4A, 0x15, 0x44, 0xDC, 0x51, 0xF7, 0x22, 0xD7, 0x7F,
0x41, 0x7F, 0x68, 0xFA, 0xEE, 0x56, 0xE8, 0x05};
// e // e
const CryptoPP::byte* PublicExponent; static constexpr CryptoPP::byte PublicExponent[] = {0x00, 0x01, 0x00, 0x01};
// (InverseQ)(q) = 1 mod p // (InverseQ)(q) = 1 mod p
const CryptoPP::byte* Coefficient; static constexpr CryptoPP::byte Coefficient[] = {
0xC0, 0x32, 0x43, 0xD3, 0x8C, 0x3D, 0xB4, 0xD2, 0x48, 0x8C, 0x42, 0x41, 0x24, 0x94, 0x6C,
0x80, 0xC9, 0xC1, 0x79, 0x36, 0x7F, 0xAC, 0xC3, 0xFF, 0x6A, 0x25, 0xEB, 0x2C, 0xFB, 0xD4,
0x2B, 0xA0, 0xEB, 0xFE, 0x25, 0xE9, 0xC6, 0x77, 0xCE, 0xFE, 0x2D, 0x23, 0xFE, 0xD0, 0xF4,
0x0F, 0xD9, 0x7E, 0xD5, 0xA5, 0x7D, 0x1F, 0xC0, 0xE8, 0xE8, 0xEC, 0x80, 0x5B, 0xC7, 0xFD,
0xE2, 0xBD, 0x94, 0xA6, 0x2B, 0xDD, 0x6A, 0x60, 0x45, 0x54, 0xAB, 0xCA, 0x42, 0x9C, 0x6A,
0x6C, 0xBF, 0x3C, 0x84, 0xF9, 0xA5, 0x0E, 0x63, 0x0C, 0x51, 0x58, 0x62, 0x6D, 0x5A, 0xB7,
0x3C, 0x3F, 0x49, 0x1A, 0xD0, 0x93, 0xB8, 0x4F, 0x1A, 0x6C, 0x5F, 0xC5, 0xE5, 0xA9, 0x75,
0xD4, 0x86, 0x9E, 0xDF, 0x87, 0x0F, 0x27, 0xB0, 0x26, 0x78, 0x4E, 0xFB, 0xC1, 0x8A, 0x4A,
0x24, 0x3F, 0x7F, 0x8F, 0x9A, 0x12, 0x51, 0xCB};
// n = p * q // n = p * q
const CryptoPP::byte* Modulus; static constexpr CryptoPP::byte Modulus[] = {
0xC2, 0xD2, 0x44, 0xBC, 0xDD, 0x84, 0x3F, 0xD9, 0xC5, 0x22, 0xAF, 0xF7, 0xFC, 0x88, 0x8A,
0x33, 0x80, 0xED, 0x8E, 0xE2, 0xCC, 0x81, 0xF7, 0xEC, 0xF8, 0x1C, 0x79, 0xBF, 0x02, 0xBB,
0x12, 0x8E, 0x61, 0x68, 0x29, 0x1B, 0x15, 0xB6, 0x5E, 0xC6, 0xF8, 0xBF, 0x5A, 0xE0, 0x3B,
0x6A, 0x6C, 0xD9, 0xD6, 0xF5, 0x75, 0xAB, 0xA0, 0x6F, 0x34, 0x81, 0x34, 0x9A, 0x5B, 0xAD,
0xED, 0x31, 0xE3, 0xC6, 0xEA, 0x1A, 0xD1, 0x13, 0x22, 0xBB, 0xB3, 0xDA, 0xB3, 0xB2, 0x53,
0xBD, 0x45, 0x79, 0x87, 0xAD, 0x0A, 0x01, 0x72, 0x18, 0x10, 0x29, 0x49, 0xF4, 0x41, 0x7F,
0xD6, 0x47, 0x0C, 0x72, 0x92, 0x9E, 0xE9, 0xBB, 0x95, 0xA9, 0x5D, 0x79, 0xEB, 0xE4, 0x30,
0x76, 0x90, 0x45, 0x4B, 0x9D, 0x9C, 0xCF, 0x92, 0x03, 0x60, 0x8C, 0x4B, 0x6C, 0xB3, 0x7A,
0x3A, 0x05, 0x39, 0xA0, 0x66, 0xA9, 0x35, 0xCF, 0xB9, 0xFA, 0xAD, 0x9C, 0xAB, 0xEB, 0xE4,
0x6A, 0x8C, 0xE9, 0x3B, 0xCC, 0x72, 0x12, 0x62, 0x63, 0xBD, 0x80, 0xC4, 0xEE, 0x37, 0x2B,
0x32, 0x03, 0xA3, 0x09, 0xF7, 0xA0, 0x61, 0x57, 0xAD, 0x0D, 0xCF, 0x15, 0x98, 0x9E, 0x4E,
0x49, 0xF8, 0xB5, 0xA3, 0x5C, 0x27, 0xEE, 0x45, 0x04, 0xEA, 0xE4, 0x4B, 0xBC, 0x8F, 0x87,
0xED, 0x19, 0x1E, 0x46, 0x75, 0x63, 0xC4, 0x5B, 0xD5, 0xBC, 0x09, 0x2F, 0x02, 0x73, 0x19,
0x3C, 0x58, 0x55, 0x49, 0x66, 0x4C, 0x11, 0xEC, 0x0F, 0x09, 0xFA, 0xA5, 0x56, 0x0A, 0x5A,
0x63, 0x56, 0xAD, 0xA0, 0x0D, 0x86, 0x08, 0xC1, 0xE6, 0xB6, 0x13, 0x22, 0x49, 0x2F, 0x7C,
0xDB, 0x4C, 0x56, 0x97, 0x0E, 0xC2, 0xD9, 0x2E, 0x87, 0xBC, 0x0E, 0x67, 0xC0, 0x1B, 0x58,
0xBC, 0x64, 0x2B, 0xC2, 0x6E, 0xE2, 0x93, 0x2E, 0xB5, 0x6B, 0x70, 0xA4, 0x42, 0x9F, 0x64,
0xC1};
// p // p
const CryptoPP::byte* Prime1; static constexpr CryptoPP::byte Prime1[] = {
0xE5, 0x62, 0xE1, 0x7F, 0x9F, 0x86, 0x08, 0xE2, 0x61, 0xD3, 0xD0, 0x42, 0xE2, 0xC4, 0xB6,
0xA8, 0x51, 0x09, 0x19, 0x14, 0xA4, 0x3A, 0x11, 0x4C, 0x33, 0xA5, 0x9C, 0x01, 0x5E, 0x34,
0xB6, 0x3F, 0x02, 0x1A, 0xCA, 0x47, 0xF1, 0x4F, 0x3B, 0x35, 0x2A, 0x07, 0x20, 0xEC, 0xD8,
0xC1, 0x15, 0xD9, 0xCA, 0x03, 0x4F, 0xB8, 0xE8, 0x09, 0x73, 0x3F, 0x85, 0xB7, 0x41, 0xD5,
0x51, 0x3E, 0x7B, 0xE3, 0x53, 0x2B, 0x48, 0x8B, 0x8E, 0xCB, 0xBA, 0xF7, 0xE0, 0x60, 0xF5,
0x35, 0x0E, 0x6F, 0xB0, 0xD9, 0x2A, 0x99, 0xD0, 0xFF, 0x60, 0x14, 0xED, 0x40, 0xEA, 0xF8,
0xD7, 0x0B, 0xC3, 0x8D, 0x8C, 0xE8, 0x81, 0xB3, 0x75, 0x93, 0x15, 0xB3, 0x7D, 0xF6, 0x39,
0x60, 0x1A, 0x00, 0xE7, 0xC3, 0x27, 0xAD, 0xA4, 0x33, 0xD5, 0x3E, 0xA4, 0x35, 0x48, 0x6F,
0x22, 0xEF, 0x5D, 0xDD, 0x7D, 0x7B, 0x61, 0x05};
// q // q
const CryptoPP::byte* Prime2; static constexpr CryptoPP::byte Prime2[] = {
const CryptoPP::byte* PrivateExponent; 0xD9, 0x6C, 0xC2, 0x0C, 0xF7, 0xAE, 0xD1, 0xF3, 0x3B, 0x3B, 0x49, 0x1E, 0x9F, 0x12, 0x9C,
0xA1, 0x78, 0x1F, 0x35, 0x1D, 0x98, 0x26, 0x13, 0x71, 0xF9, 0x09, 0xFD, 0xF0, 0xAD, 0x38,
// Constructor 0x55, 0xB7, 0xEE, 0x61, 0x04, 0x72, 0x51, 0x87, 0x2E, 0x05, 0x84, 0xB1, 0x1D, 0x0C, 0x0D,
DebugRifKeyset() { 0xDB, 0xD4, 0x25, 0x3E, 0x26, 0xED, 0xEA, 0xB8, 0xF7, 0x49, 0xFE, 0xA2, 0x94, 0xE6, 0xF2,
// Initialize PrivateExponent 0x08, 0x92, 0xA7, 0x85, 0xF5, 0x30, 0xB9, 0x84, 0x22, 0xBF, 0xCA, 0xF0, 0x5F, 0xCB, 0x31,
PrivateExponent = new CryptoPP::byte[0x100]{ 0x20, 0x34, 0x49, 0x16, 0x76, 0x34, 0xCC, 0x7A, 0xCB, 0x96, 0xFE, 0x78, 0x7A, 0x41, 0xFE,
0x01, 0x61, 0xAD, 0xD8, 0x9C, 0x06, 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 0xDE, 0x5E, 0xA8, 0x6E, 0x3E, 0x87, 0xEC, 0x44, 0xD2, 0x69, 0xC6,
0x54, 0x91, 0x6B, 0x5E, 0x13, 0x8A, 0x03, 0x87, 0x05, 0x31, 0x8D};
};
}; };
class PkgDerivedKey3Keyset { class PkgDerivedKey3Keyset {
public: public:
// PkgDerivedKey3Keyset();
//~PkgDerivedKey3Keyset();
// Constructor
// std::uint8_t* PrivateExponent; // std::uint8_t* PrivateExponent;
const CryptoPP::byte* Exponent1; static constexpr CryptoPP::byte Exponent1[] = {
0x52, 0xCC, 0x2D, 0xA0, 0x9C, 0x9E, 0x75, 0xE7, 0x28, 0xEE, 0x3D, 0xDE, 0xE3, 0x45, 0xD1,
0x4F, 0x94, 0x1C, 0xCC, 0xC8, 0x87, 0x29, 0x45, 0x3B, 0x8D, 0x6E, 0xAB, 0x6E, 0x2A, 0xA7,
0xC7, 0x15, 0x43, 0xA3, 0x04, 0x8F, 0x90, 0x5F, 0xEB, 0xF3, 0x38, 0x4A, 0x77, 0xFA, 0x36,
0xB7, 0x15, 0x76, 0xB6, 0x01, 0x1A, 0x8E, 0x25, 0x87, 0x82, 0xF1, 0x55, 0xD8, 0xC6, 0x43,
0x2A, 0xC0, 0xE5, 0x98, 0xC9, 0x32, 0xD1, 0x94, 0x6F, 0xD9, 0x01, 0xBA, 0x06, 0x81, 0xE0,
0x6D, 0x88, 0xF2, 0x24, 0x2A, 0x25, 0x01, 0x64, 0x5C, 0xBF, 0xF2, 0xD9, 0x99, 0x67, 0x3E,
0xF6, 0x72, 0xEE, 0xE4, 0xE2, 0x33, 0x5C, 0xF8, 0x00, 0x40, 0xE3, 0x2A, 0x9A, 0xF4, 0x3D,
0x22, 0x86, 0x44, 0x3C, 0xFB, 0x0A, 0xA5, 0x7C, 0x3F, 0xCC, 0xF5, 0xF1, 0x16, 0xC4, 0xAC,
0x88, 0xB4, 0xDE, 0x62, 0x94, 0x92, 0x6A, 0x13};
// exponent2 = d mod (q - 1) // exponent2 = d mod (q - 1)
const CryptoPP::byte* Exponent2; static constexpr CryptoPP::byte Exponent2[] = {
0x7C, 0x9D, 0xAD, 0x39, 0xE0, 0xD5, 0x60, 0x14, 0x94, 0x48, 0x19, 0x7F, 0x88, 0x95, 0xD5,
0x8B, 0x80, 0xAD, 0x85, 0x8A, 0x4B, 0x77, 0x37, 0x85, 0xD0, 0x77, 0xBB, 0xBF, 0x89, 0x71,
0x4A, 0x72, 0xCB, 0x72, 0x68, 0x38, 0xEC, 0x02, 0xC6, 0x7D, 0xC6, 0x44, 0x06, 0x33, 0x51,
0x1C, 0xC0, 0xFF, 0x95, 0x8F, 0x0D, 0x75, 0xDC, 0x25, 0xBB, 0x0B, 0x73, 0x91, 0xA9, 0x6D,
0x42, 0xD8, 0x03, 0xB7, 0x68, 0xD4, 0x1E, 0x75, 0x62, 0xA3, 0x70, 0x35, 0x79, 0x78, 0x00,
0xC8, 0xF5, 0xEF, 0x15, 0xB9, 0xFC, 0x4E, 0x47, 0x5A, 0xC8, 0x70, 0x70, 0x5B, 0x52, 0x98,
0xC0, 0xC2, 0x58, 0x4A, 0x70, 0x96, 0xCC, 0xB8, 0x10, 0xE1, 0x2F, 0x78, 0x8B, 0x2B, 0xA1,
0x7F, 0xF9, 0xAC, 0xDE, 0xF0, 0xBB, 0x2B, 0xE2, 0x66, 0xE3, 0x22, 0x92, 0x31, 0x21, 0x57,
0x92, 0xC4, 0xB8, 0xF2, 0x3E, 0x76, 0x20, 0x37};
// e // e
const CryptoPP::byte* PublicExponent; static constexpr CryptoPP::byte PublicExponent[] = {0, 1, 0, 1};
// (InverseQ)(q) = 1 mod p // (InverseQ)(q) = 1 mod p
const CryptoPP::byte* Coefficient; static constexpr CryptoPP::byte Coefficient[] = {
0x45, 0x97, 0x55, 0xD4, 0x22, 0x08, 0x5E, 0xF3, 0x5C, 0xB4, 0x05, 0x7A, 0xFD, 0xAA, 0x42,
0x42, 0xAD, 0x9A, 0x8C, 0xA0, 0x6C, 0xBB, 0x1D, 0x68, 0x54, 0x54, 0x6E, 0x3E, 0x32, 0xE3,
0x53, 0x73, 0x76, 0xF1, 0x3E, 0x01, 0xEA, 0xD3, 0xCF, 0xEB, 0xEB, 0x23, 0x3E, 0xC0, 0xBE,
0xCE, 0xEC, 0x2C, 0x89, 0x5F, 0xA8, 0x27, 0x3A, 0x4C, 0xB7, 0xE6, 0x74, 0xBC, 0x45, 0x4C,
0x26, 0xC8, 0x25, 0xFF, 0x34, 0x63, 0x25, 0x37, 0xE1, 0x48, 0x10, 0xC1, 0x93, 0xA6, 0xAF,
0xEB, 0xBA, 0xE3, 0xA2, 0xF1, 0x3D, 0xEF, 0x63, 0xD8, 0xF4, 0xFD, 0xD3, 0xEE, 0xE2, 0x5D,
0xE9, 0x33, 0xCC, 0xAD, 0xBA, 0x75, 0x5C, 0x85, 0xAF, 0xCE, 0xA9, 0x3D, 0xD1, 0xA2, 0x17,
0xF3, 0xF6, 0x98, 0xB3, 0x50, 0x8E, 0x5E, 0xF6, 0xEB, 0x02, 0x8E, 0xA1, 0x62, 0xA7, 0xD6,
0x2C, 0xEC, 0x91, 0xFF, 0x15, 0x40, 0xD2, 0xE3};
// n = p * q // n = p * q
const CryptoPP::byte* Modulus; static constexpr CryptoPP::byte Modulus[] = {
0xd2, 0x12, 0xfc, 0x33, 0x5f, 0x6d, 0xdb, 0x83, 0x16, 0x09, 0x62, 0x8b, 0x03, 0x56, 0x27,
0x37, 0x82, 0xd4, 0x77, 0x85, 0x35, 0x29, 0x39, 0x2d, 0x52, 0x6b, 0x8c, 0x4c, 0x8c, 0xfb,
0x06, 0xc1, 0x84, 0x5b, 0xe7, 0xd4, 0xf7, 0xbc, 0xd2, 0x4e, 0x62, 0x45, 0xcd, 0x2a, 0xbb,
0xd7, 0x77, 0x76, 0x45, 0x36, 0x55, 0x27, 0x3f, 0xb3, 0xf5, 0xf9, 0x8e, 0xda, 0x4b, 0xef,
0xaa, 0x59, 0xae, 0xb3, 0x9b, 0xea, 0x54, 0x98,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, 0xf9, 0xc9, 0xa3,
0xc1};
// p // p
const CryptoPP::byte* Prime1; static constexpr CryptoPP::byte Prime1[] = {
0xF9, 0x67, 0xAD, 0x99, 0x12, 0x31, 0x0C, 0x56, 0xA2, 0x2E, 0x16, 0x1C, 0x46, 0xB3, 0x4D,
0x5B, 0x43, 0xBE, 0x42, 0xA2, 0xF6, 0x86, 0x96, 0x80, 0x42, 0xC3, 0xC7, 0x3F, 0xC3, 0x42,
0xF5, 0x87, 0x49, 0x33, 0x9F, 0x07, 0x5D, 0x6E, 0x2C, 0x04, 0xFD, 0xE3, 0xE1, 0xB2, 0xAE,
0x0A, 0x0C, 0xF0, 0xC7, 0xA6, 0x1C, 0xA1, 0x63, 0x50, 0xC8, 0x09, 0x9C, 0x51, 0x24, 0x52,
0x6C, 0x5E, 0x5E, 0xBD, 0x1E, 0x27, 0x06, 0xBB, 0xBC, 0x9E, 0x94, 0xE1, 0x35, 0xD4, 0x6D,
0xB3, 0xCB, 0x3C, 0x68, 0xDD, 0x68, 0xB3, 0xFE, 0x6C, 0xCB, 0x8D, 0x82, 0x20, 0x76, 0x23,
0x63, 0xB7, 0xE9, 0x68, 0x10, 0x01, 0x4E, 0xDC, 0xBA, 0x27, 0x5D, 0x01, 0xC1, 0x2D, 0x80,
0x5E, 0x2B, 0xAF, 0x82, 0x6B, 0xD8, 0x84, 0xB6, 0x10, 0x52, 0x86, 0xA7, 0x89, 0x8E, 0xAE,
0x9A, 0xE2, 0x89, 0xC6, 0xF7, 0xD5, 0x87, 0xFB};
// q // q
const CryptoPP::byte* Prime2; static constexpr CryptoPP::byte Prime2[] = {
const CryptoPP::byte* PrivateExponent; 0xD7, 0xA1, 0x0F, 0x9A, 0x8B, 0xF2, 0xC9, 0x11, 0x95, 0x32, 0x9A, 0x8C, 0xF0, 0xD9, 0x40,
0x47, 0xF5, 0x68, 0xA0, 0x0D, 0xBD, 0xC1, 0xFC, 0x43, 0x2F, 0x65, 0xF9, 0xC3, 0x61, 0x0F,
PkgDerivedKey3Keyset() { 0x25, 0x77, 0x54, 0xAD, 0xD7, 0x58, 0xAC, 0x84, 0x40, 0x60, 0x8D, 0x3F, 0xF3, 0x65, 0x89,
0x75, 0xB5, 0xC6, 0x2C, 0x51, 0x1A, 0x2F, 0x1F, 0x22, 0xE4, 0x43, 0x11, 0x54, 0xBE, 0xC9,
Prime1 = new CryptoPP::byte[0x80]{ 0xB4, 0xC7, 0xB5, 0x1B, 0x05, 0x0B, 0xBC, 0x56, 0x9A, 0xCD, 0x4A, 0xD9, 0x73, 0x68, 0x5E,
0xF9, 0x67, 0xAD, 0x99, 0x12, 0x31, 0x0C, 0x56, 0xA2, 0x2E, 0x16, 0x1C, 0x46, 0x5C, 0xFB, 0x92, 0xB7, 0x8B, 0x0D, 0xFF, 0xF5, 0x07, 0xCA, 0xB4, 0xC8, 0x9B, 0x96, 0x3C,
0xB3, 0x4D, 0x5B, 0x43, 0xBE, 0x42, 0xA2, 0xF6, 0x86, 0x96, 0x80, 0x42, 0xC3, 0x07, 0x9E, 0x3E, 0x6B, 0x2A, 0x11, 0xF2, 0x8A, 0xB1, 0x8A, 0xD7, 0x2E, 0x1B, 0xA5, 0x53,
0xC7, 0x3F, 0xC3, 0x42, 0xF5, 0x87, 0x49, 0x33, 0x9F, 0x07, 0x5D, 0x6E, 0x2C, 0x24, 0x06, 0xED, 0x50, 0xB8, 0x90, 0x67, 0xB1, 0xE2, 0x41, 0xC6, 0x92, 0x01, 0xEE, 0x10,
0x04, 0xFD, 0xE3, 0xE1, 0xB2, 0xAE, 0x0A, 0x0C, 0xF0, 0xC7, 0xA6, 0x1C, 0xA1, 0xF0, 0x61, 0xBB, 0xFB, 0xB2, 0x7D, 0x4A, 0x73};
0x63, 0x50, 0xC8, 0x09, 0x9C, 0x51, 0x24, 0x52, 0x6C, 0x5E, 0x5E, 0xBD, 0x1E, static constexpr CryptoPP::byte PrivateExponent[] = {
0x27, 0x06, 0xBB, 0xBC, 0x9E, 0x94, 0xE1, 0x35,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0x95, 0x19, 0x32, 0xed, 0xe8, 0x90, 0x56, 0x0d, 0x65, 0xc1, 0xaa,
0x78, 0xc6, 0x2e, 0x54, 0xfd, 0x5f, 0x54, 0xa1, 0xf6, 0x7e, 0xe5, 0xe0, 0x5f, 0x61,
0xc1, 0x20, 0xb4, 0xb9, 0xb4, 0x33, 0x08, 0x70, 0xe4, 0xdf, 0x89, 0x56, 0xed, 0x01,
0x29, 0x46, 0x77, 0x5f, 0x8c, 0xb8, 0xa9, 0xf5, 0x1e, 0x2e, 0xb3, 0xb9, 0xbf, 0xe0,
0x09, 0xb7, 0x8d, 0x28, 0xd4, 0xa6, 0xc3, 0xb8, 0x1e, 0x1f, 0x07, 0xeb, 0xb4, 0x12,
0x0b, 0x95, 0xb8, 0x85, 0x30, 0xfd, 0xdc, 0x39, 0x13, 0xd0, 0x7c, 0xdc, 0x8f, 0xed,
0xf9, 0xc9, 0xa3, 0xc1};
PublicExponent = new CryptoPP::byte[4]{0, 1, 0, 1};
};
}; };

View File

@ -67,15 +67,19 @@ bool PKG::Open(const std::filesystem::path& filepath) {
file.Seek(0x47); // skip first 7 characters of content_id file.Seek(0x47); // skip first 7 characters of content_id
file.Read(pkgTitleID); file.Read(pkgTitleID);
file.Seek(0);
pkg.resize(pkgheader.pkg_promote_size);
file.Read(pkg);
u32 offset = pkgheader.pkg_table_entry_offset; u32 offset = pkgheader.pkg_table_entry_offset;
u32 n_files = pkgheader.pkg_table_entry_count; u32 n_files = pkgheader.pkg_table_entry_count;
file.Seek(offset);
for (int i = 0; i < n_files; i++) { for (int i = 0; i < n_files; i++) {
PKGEntry entry; PKGEntry entry{};
std::memcpy(&entry, &pkg[offset + i * 0x20], sizeof(entry)); file.Read(entry.id);
file.Read(entry.filename_offset);
file.Read(entry.flags1);
file.Read(entry.flags2);
file.Read(entry.offset);
file.Read(entry.size);
file.Seek(8, Common::FS::SeekOrigin::CurrentPosition);
// Try to figure out the name // Try to figure out the name
const auto name = GetEntryNameByType(entry.id); const auto name = GetEntryNameByType(entry.id);
@ -113,9 +117,6 @@ bool PKG::Extract(const std::filesystem::path& filepath, const std::filesystem::
failreason = "Content size is bigger than pkg size"; failreason = "Content size is bigger than pkg size";
return false; return false;
} }
file.Seek(0);
pkg.resize(pkgheader.pkg_promote_size);
file.Read(pkg);
u32 offset = pkgheader.pkg_table_entry_offset; u32 offset = pkgheader.pkg_table_entry_offset;
u32 n_files = pkgheader.pkg_table_entry_count; u32 n_files = pkgheader.pkg_table_entry_count;
@ -126,9 +127,18 @@ bool PKG::Extract(const std::filesystem::path& filepath, const std::filesystem::
std::array<std::array<u8, 256>, 7> key1; std::array<std::array<u8, 256>, 7> key1;
std::array<u8, 256> imgkeydata; std::array<u8, 256> imgkeydata;
file.Seek(offset);
for (int i = 0; i < n_files; i++) { for (int i = 0; i < n_files; i++) {
PKGEntry entry; PKGEntry entry{};
std::memcpy(&entry, &pkg[offset + i * 0x20], sizeof(entry)); file.Read(entry.id);
file.Read(entry.filename_offset);
file.Read(entry.flags1);
file.Read(entry.flags2);
file.Read(entry.offset);
file.Read(entry.size);
file.Seek(8, Common::FS::SeekOrigin::CurrentPosition);
auto currentPos = file.Tell();
// Try to figure out the name // Try to figure out the name
const auto name = GetEntryNameByType(entry.id); const auto name = GetEntryNameByType(entry.id);
@ -139,8 +149,15 @@ bool PKG::Extract(const std::filesystem::path& filepath, const std::filesystem::
// Just print with id // Just print with id
Common::FS::IOFile out(extract_path / "sce_sys" / std::to_string(entry.id), Common::FS::IOFile out(extract_path / "sce_sys" / std::to_string(entry.id),
Common::FS::FileAccessMode::Write); Common::FS::FileAccessMode::Write);
out.WriteRaw<u8>(pkg.data() + entry.offset, entry.size); file.Seek(entry.offset);
std::vector<u8> data;
data.resize(entry.size);
file.ReadRaw<u8>(data.data(), entry.size);
out.WriteRaw<u8>(data.data(), entry.size);
out.Close(); out.Close();
file.Seek(currentPos);
continue; continue;
} }
@ -178,14 +195,25 @@ bool PKG::Extract(const std::filesystem::path& filepath, const std::filesystem::
} }
Common::FS::IOFile out(extract_path / "sce_sys" / name, Common::FS::FileAccessMode::Write); Common::FS::IOFile out(extract_path / "sce_sys" / name, Common::FS::FileAccessMode::Write);
out.WriteRaw<u8>(pkg.data() + entry.offset, entry.size); file.Seek(entry.offset);
std::vector<u8> data;
data.resize(entry.size);
file.ReadRaw<u8>(data.data(), entry.size);
out.WriteRaw<u8>(data.data(), entry.size);
out.Close(); out.Close();
// Decrypt Np stuff and overwrite. // Decrypt Np stuff and overwrite.
if (entry.id == 0x400 || entry.id == 0x401 || entry.id == 0x402 || if (entry.id == 0x400 || entry.id == 0x401 || entry.id == 0x402 ||
entry.id == 0x403) { // somehow 0x401 is not decrypting entry.id == 0x403) { // somehow 0x401 is not decrypting
decNp.resize(entry.size); decNp.resize(entry.size);
std::span<u8> cipherNp(pkg.data() + entry.offset, entry.size); file.Seek(entry.offset);
std::vector<u8> data;
data.resize(entry.size);
file.ReadRaw<u8>(data.data(), entry.size);
std::span<u8> cipherNp(data.data(), entry.size);
std::array<u8, 64> concatenated_ivkey_dk3_; std::array<u8, 64> concatenated_ivkey_dk3_;
std::memcpy(concatenated_ivkey_dk3_.data(), &entry, sizeof(entry)); std::memcpy(concatenated_ivkey_dk3_.data(), &entry, sizeof(entry));
std::memcpy(concatenated_ivkey_dk3_.data() + sizeof(entry), dk3_.data(), sizeof(dk3_)); std::memcpy(concatenated_ivkey_dk3_.data() + sizeof(entry), dk3_.data(), sizeof(dk3_));
@ -197,6 +225,8 @@ bool PKG::Extract(const std::filesystem::path& filepath, const std::filesystem::
out.Write(decNp); out.Write(decNp);
out.Close(); out.Close();
} }
file.Seek(currentPos);
} }
// Extract trophy files // Extract trophy files
@ -214,6 +244,9 @@ bool PKG::Extract(const std::filesystem::path& filepath, const std::filesystem::
PKG::crypto.PfsGenCryptoKey(ekpfsKey, seed, dataKey, tweakKey); PKG::crypto.PfsGenCryptoKey(ekpfsKey, seed, dataKey, tweakKey);
const u32 length = pkgheader.pfs_cache_size * 0x2; // Seems to be ok. const u32 length = pkgheader.pfs_cache_size * 0x2; // Seems to be ok.
int num_blocks = 0;
std::vector<u8> pfsc(length);
if (length != 0) {
// Read encrypted pfs_image // Read encrypted pfs_image
std::vector<u8> pfs_encrypted(length); std::vector<u8> pfs_encrypted(length);
file.Seek(pkgheader.pfs_image_offset); file.Seek(pkgheader.pfs_image_offset);
@ -225,18 +258,18 @@ bool PKG::Extract(const std::filesystem::path& filepath, const std::filesystem::
// Retrieve PFSC from decrypted pfs_image. // Retrieve PFSC from decrypted pfs_image.
pfsc_offset = GetPFSCOffset(pfs_decrypted); pfsc_offset = GetPFSCOffset(pfs_decrypted);
std::vector<u8> pfsc(length);
std::memcpy(pfsc.data(), pfs_decrypted.data() + pfsc_offset, length - pfsc_offset); std::memcpy(pfsc.data(), pfs_decrypted.data() + pfsc_offset, length - pfsc_offset);
PFSCHdr pfsChdr; PFSCHdr pfsChdr;
std::memcpy(&pfsChdr, pfsc.data(), sizeof(pfsChdr)); std::memcpy(&pfsChdr, pfsc.data(), sizeof(pfsChdr));
const int num_blocks = (int)(pfsChdr.data_length / pfsChdr.block_sz2); num_blocks = (int)(pfsChdr.data_length / pfsChdr.block_sz2);
sectorMap.resize(num_blocks + 1); // 8 bytes, need extra 1 to get the last offset. sectorMap.resize(num_blocks + 1); // 8 bytes, need extra 1 to get the last offset.
for (int i = 0; i < num_blocks + 1; i++) { for (int i = 0; i < num_blocks + 1; i++) {
std::memcpy(&sectorMap[i], pfsc.data() + pfsChdr.block_offsets + i * 8, 8); std::memcpy(&sectorMap[i], pfsc.data() + pfsChdr.block_offsets + i * 8, 8);
} }
}
u32 ent_size = 0; u32 ent_size = 0;
u32 ndinode = 0; u32 ndinode = 0;
@ -279,8 +312,8 @@ bool PKG::Extract(const std::filesystem::path& filepath, const std::filesystem::
} }
} }
// let's deal with the root/uroot enteries here. // let's deal with the root/uroot entries here.
// Sometimes it's more than 2 enteries (Tomb Raider Remastered) // Sometimes it's more than 2 entries (Tomb Raider Remastered)
const std::string_view flat_path_table(&decompressedData[0x10], 15); const std::string_view flat_path_table(&decompressedData[0x10], 15);
if (flat_path_table == "flat_path_table") { if (flat_path_table == "flat_path_table") {
uroot_reached = true; uroot_reached = true;
@ -296,7 +329,15 @@ bool PKG::Extract(const std::filesystem::path& filepath, const std::filesystem::
} else { } else {
// Set the the folder according to the current inode. // Set the the folder according to the current inode.
// Can be 2 or more (rarely) // Can be 2 or more (rarely)
extractPaths[ndinode_counter] = extract_path.parent_path() / GetTitleID(); auto parent_path = extract_path.parent_path();
auto title_id = GetTitleID();
if (parent_path.filename() != title_id) {
extractPaths[ndinode_counter] = parent_path / title_id;
} else {
// DLCs path has different structure
extractPaths[ndinode_counter] = extract_path;
}
uroot_reached = false; uroot_reached = false;
break; break;
} }
@ -350,7 +391,7 @@ bool PKG::Extract(const std::filesystem::path& filepath, const std::filesystem::
return true; return true;
} }
void PKG::ExtractFiles(const int& index) { void PKG::ExtractFiles(const int index) {
int inode_number = fsTable[index].inode; int inode_number = fsTable[index].inode;
int inode_type = fsTable[index].type; int inode_type = fsTable[index].type;
std::string inode_name = fsTable[index].name; std::string inode_name = fsTable[index].name;

View File

@ -104,7 +104,7 @@ public:
~PKG(); ~PKG();
bool Open(const std::filesystem::path& filepath); bool Open(const std::filesystem::path& filepath);
void ExtractFiles(const int& index); void ExtractFiles(const int index);
bool Extract(const std::filesystem::path& filepath, const std::filesystem::path& extract, bool Extract(const std::filesystem::path& filepath, const std::filesystem::path& extract,
std::string& failreason); std::string& failreason);
@ -149,7 +149,6 @@ public:
private: private:
Crypto crypto; Crypto crypto;
TRP trp; TRP trp;
std::vector<u8> pkg;
u64 pkgSize = 0; u64 pkgSize = 0;
char pkgTitleID[9]; char pkgTitleID[9];
PKGHeader pkgheader; PKGHeader pkgheader;

View File

@ -0,0 +1,75 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "playgo_chunk.h"
bool PlaygoFile::Open(const std::filesystem::path& filepath) {
Common::FS::IOFile file(filepath, Common::FS::FileAccessMode::Read);
if (file.IsOpen()) {
file.Read(playgoHeader);
if (LoadChunks(file)) {
return true;
}
}
return false;
}
bool PlaygoFile::LoadChunks(const Common::FS::IOFile& file) {
if (file.IsOpen()) {
if (playgoHeader.magic == PLAYGO_MAGIC) {
bool ret = true;
std::string chunk_attrs_data, chunk_mchunks_data, chunk_labels_data, mchunk_attrs_data;
ret = ret && load_chunk_data(file, playgoHeader.chunk_attrs, chunk_attrs_data);
ret = ret && load_chunk_data(file, playgoHeader.chunk_mchunks, chunk_mchunks_data);
ret = ret && load_chunk_data(file, playgoHeader.chunk_labels, chunk_labels_data);
ret = ret && load_chunk_data(file, playgoHeader.mchunk_attrs, mchunk_attrs_data);
if (ret) {
chunks.resize(playgoHeader.chunk_count);
auto chunk_attrs =
reinterpret_cast<playgo_chunk_attr_entry_t*>(&chunk_attrs_data[0]);
auto chunk_mchunks = reinterpret_cast<u16*>(&chunk_mchunks_data[0]);
auto chunk_labels = reinterpret_cast<char*>(&chunk_labels_data[0]);
auto mchunk_attrs =
reinterpret_cast<playgo_mchunk_attr_entry_t*>(&mchunk_attrs_data[0]);
for (u16 i = 0; i < playgoHeader.chunk_count; i++) {
chunks[i].req_locus = chunk_attrs[i].req_locus;
chunks[i].language_mask = chunk_attrs[i].language_mask;
chunks[i].label_name = std::string(chunk_labels + chunk_attrs[i].label_offset);
u64 total_size = 0;
u16 mchunk_count = chunk_attrs[i].mchunk_count;
if (mchunk_count != 0) {
auto mchunks = reinterpret_cast<u16*>(
((u8*)chunk_mchunks + chunk_attrs[i].mchunks_offset));
for (u16 j = 0; j < mchunk_count; j++) {
u16 mchunk_id = mchunks[j];
total_size += mchunk_attrs[mchunk_id].size.size;
}
}
chunks[i].total_size = total_size;
}
}
return ret;
}
}
return false;
}
bool PlaygoFile::load_chunk_data(const Common::FS::IOFile& file, const chunk_t chunk,
std::string& data) {
if (file.IsOpen()) {
if (file.Seek(chunk.offset)) {
data.resize(chunk.length);
if (data.size() == chunk.length) {
file.ReadRaw<char>(&data[0], chunk.length);
return true;
}
}
}
return false;
}

View File

@ -0,0 +1,131 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <filesystem>
#include <mutex>
#include <vector>
#include "common/io_file.h"
#include "core/libraries/playgo/playgo_types.h"
constexpr u32 PLAYGO_MAGIC = 0x6F676C70;
struct chunk_t {
u32 offset;
u32 length;
} __attribute__((packed));
struct PlaygoHeader {
u32 magic;
u16 version_major;
u16 version_minor;
u16 image_count; // [0;1]
u16 chunk_count; // [0;1000]
u16 mchunk_count; // [0;8000]
u16 scenario_count; // [0;32]
u32 file_size;
u16 default_scenario_id;
u16 attrib;
u32 sdk_version;
u16 disc_count; // [0;2] (if equals to 0 then disc count = 1)
u16 layer_bmp;
u8 reserved[32];
char content_id[128];
chunk_t chunk_attrs; // [0;32000]
chunk_t chunk_mchunks;
chunk_t chunk_labels; // [0;16000]
chunk_t mchunk_attrs; // [0;12800]
chunk_t scenario_attrs; // [0;1024]
chunk_t scenario_chunks;
chunk_t scenario_labels;
chunk_t inner_mchunk_attrs; // [0;12800]
} __attribute__((packed));
struct playgo_scenario_attr_entry_t {
u8 _type;
u8 _unk[19];
u16 initial_chunk_count;
u16 chunk_count;
u32 chunks_offset; //<-scenario_chunks
u32 label_offset; //<-scenario_labels
} __attribute__((packed));
struct image_disc_layer_no_t {
u8 layer_no : 2;
u8 disc_no : 2;
u8 image_no : 4;
} __attribute__((packed));
struct playgo_chunk_attr_entry_t {
u8 flag;
image_disc_layer_no_t image_disc_layer_no;
u8 req_locus;
u8 unk[11];
u16 mchunk_count;
u64 language_mask;
u32 mchunks_offset; //<-chunk_mchunks
u32 label_offset; //<-chunk_labels
} __attribute__((packed));
struct playgo_chunk_loc_t {
u64 offset : 48;
u64 _align1 : 8;
u64 image_no : 4;
u64 _align2 : 4;
} __attribute__((packed));
struct playgo_chunk_size_t {
u64 size : 48;
u64 _align : 16;
} __attribute__((packed));
struct playgo_mchunk_attr_entry_t {
playgo_chunk_loc_t loc;
playgo_chunk_size_t size;
} __attribute__((packed));
struct PlaygoChunk {
u64 req_locus;
u64 language_mask;
u64 total_size;
std::string label_name;
};
class PlaygoFile {
public:
bool initialized;
OrbisPlayGoHandle handle;
OrbisPlayGoChunkId id;
OrbisPlayGoLocus locus;
OrbisPlayGoInstallSpeed speed;
s64 speed_tick;
OrbisPlayGoEta eta;
OrbisPlayGoLanguageMask langMask;
std::vector<PlaygoChunk> chunks;
public:
PlaygoFile()
: initialized(false), handle(0), id(0), locus(0), speed(ORBIS_PLAYGO_INSTALL_SPEED_TRICKLE),
speed_tick(0), eta(0), langMask(0), playgoHeader{0} {}
~PlaygoFile() = default;
bool Open(const std::filesystem::path& filepath);
bool LoadChunks(const Common::FS::IOFile& file);
PlaygoHeader& GetPlaygoHeader() {
return playgoHeader;
}
std::mutex& GetSpeedMutex() {
return speed_mutex;
}
private:
bool load_chunk_data(const Common::FS::IOFile& file, const chunk_t chunk, std::string& data);
private:
PlaygoHeader playgoHeader;
std::mutex speed_mutex;
};

View File

@ -9,7 +9,7 @@ PSF::PSF() = default;
PSF::~PSF() = default; PSF::~PSF() = default;
bool PSF::open(const std::string& filepath, std::vector<u8> psfBuffer) { bool PSF::open(const std::string& filepath, const std::vector<u8>& psfBuffer) {
if (!psfBuffer.empty()) { if (!psfBuffer.empty()) {
psf.resize(psfBuffer.size()); psf.resize(psfBuffer.size());
psf = psfBuffer; psf = psfBuffer;

View File

@ -35,7 +35,7 @@ public:
PSF(); PSF();
~PSF(); ~PSF();
bool open(const std::string& filepath, std::vector<u8> psfBuffer); bool open(const std::string& filepath, const std::vector<u8>& psfBuffer);
std::string GetString(const std::string& key); std::string GetString(const std::string& key);
u32 GetInteger(const std::string& key); u32 GetInteger(const std::string& key);

View File

@ -6,7 +6,7 @@
TRP::TRP() = default; TRP::TRP() = default;
TRP::~TRP() = default; TRP::~TRP() = default;
void TRP::GetNPcommID(std::filesystem::path trophyPath, int index) { void TRP::GetNPcommID(const std::filesystem::path& trophyPath, int index) {
std::filesystem::path trpPath = trophyPath / "sce_sys/npbind.dat"; std::filesystem::path trpPath = trophyPath / "sce_sys/npbind.dat";
Common::FS::IOFile npbindFile(trpPath, Common::FS::FileAccessMode::Read); Common::FS::IOFile npbindFile(trpPath, Common::FS::FileAccessMode::Read);
if (!npbindFile.IsOpen()) { if (!npbindFile.IsOpen()) {
@ -27,7 +27,7 @@ static void removePadding(std::vector<u8>& vec) {
} }
} }
bool TRP::Extract(std::filesystem::path trophyPath) { bool TRP::Extract(const std::filesystem::path& trophyPath) {
std::string title = trophyPath.filename().string(); std::string title = trophyPath.filename().string();
std::filesystem::path gameSysDir = trophyPath / "sce_sys/trophy/"; std::filesystem::path gameSysDir = trophyPath / "sce_sys/trophy/";
if (!std::filesystem::exists(gameSysDir)) { if (!std::filesystem::exists(gameSysDir)) {

View File

@ -33,8 +33,8 @@ class TRP {
public: public:
TRP(); TRP();
~TRP(); ~TRP();
bool Extract(std::filesystem::path trophyPath); bool Extract(const std::filesystem::path& trophyPath);
void GetNPcommID(std::filesystem::path trophyPath, int index); void GetNPcommID(const std::filesystem::path& trophyPath, int index);
private: private:
Crypto crypto; Crypto crypto;

View File

@ -25,27 +25,36 @@ void MntPoints::UnmountAll() {
m_mnt_pairs.clear(); m_mnt_pairs.clear();
} }
std::filesystem::path MntPoints::GetHostPath(const std::string& guest_directory) { std::filesystem::path MntPoints::GetHostPath(std::string_view guest_directory) {
const MntPair* mount = GetMount(guest_directory); // Evil games like Turok2 pass double slashes e.g /app0//game.kpf
std::string corrected_path(guest_directory);
size_t pos = corrected_path.find("//");
while (pos != std::string::npos) {
corrected_path.replace(pos, 2, "/");
pos = corrected_path.find("//", pos + 1);
}
const MntPair* mount = GetMount(corrected_path);
if (!mount) { if (!mount) {
return guest_directory; return "";
} }
// Nothing to do if getting the mount itself. // Nothing to do if getting the mount itself.
if (guest_directory == mount->mount) { if (corrected_path == mount->mount) {
return mount->host_path; return mount->host_path;
} }
// Remove device (e.g /app0) from path to retrieve relative path. // Remove device (e.g /app0) from path to retrieve relative path.
const u32 pos = mount->mount.size() + 1; pos = mount->mount.size() + 1;
const auto rel_path = std::string_view(guest_directory).substr(pos); const auto rel_path = std::string_view(corrected_path).substr(pos);
const auto host_path = mount->host_path / rel_path; const auto host_path = mount->host_path / rel_path;
if (!NeedsCaseInsensiveSearch) { if (!NeedsCaseInsensitiveSearch) {
return host_path; return host_path;
} }
// If the path does not exist attempt to verify this. // If the path does not exist attempt to verify this.
// Retrieve parent path until we find one that exists. // Retrieve parent path until we find one that exists.
std::scoped_lock lk{m_mutex};
path_parts.clear(); path_parts.clear();
auto current_path = host_path; auto current_path = host_path;
while (!std::filesystem::exists(current_path)) { while (!std::filesystem::exists(current_path)) {
@ -62,7 +71,7 @@ std::filesystem::path MntPoints::GetHostPath(const std::string& guest_directory)
// exist in filesystem but in different case. // exist in filesystem but in different case.
auto guest_path = current_path; auto guest_path = current_path;
while (!path_parts.empty()) { while (!path_parts.empty()) {
const auto& part = path_parts.back(); const auto part = path_parts.back();
const auto add_match = [&](const auto& host_part) { const auto add_match = [&](const auto& host_part) {
current_path /= host_part; current_path /= host_part;
guest_path /= part; guest_path /= part;

View File

@ -14,9 +14,9 @@ namespace Core::FileSys {
class MntPoints { class MntPoints {
#ifdef _WIN64 #ifdef _WIN64
static constexpr bool NeedsCaseInsensiveSearch = false; static constexpr bool NeedsCaseInsensitiveSearch = false;
#else #else
static constexpr bool NeedsCaseInsensiveSearch = true; static constexpr bool NeedsCaseInsensitiveSearch = true;
#endif #endif
public: public:
struct MntPair { struct MntPair {
@ -31,7 +31,7 @@ public:
void Unmount(const std::filesystem::path& host_folder, const std::string& guest_folder); void Unmount(const std::filesystem::path& host_folder, const std::string& guest_folder);
void UnmountAll(); void UnmountAll();
std::filesystem::path GetHostPath(const std::string& guest_directory); std::filesystem::path GetHostPath(std::string_view guest_directory);
const MntPair* GetMount(const std::string& guest_path) { const MntPair* GetMount(const std::string& guest_path) {
const auto it = std::ranges::find_if( const auto it = std::ranges::find_if(

View File

@ -1,9 +1,10 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
// Generated By moduleGenerator #include "ajm.h"
#include "ajm_error.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/libraries/ajm/ajm.h"
#include "core/libraries/error_codes.h" #include "core/libraries/error_codes.h"
#include "core/libraries/libs.h" #include "core/libraries/libs.h"

View File

@ -0,0 +1,28 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
constexpr int ORBIS_AJM_ERROR_UNKNOWN = 0x80930001;
constexpr int ORBIS_AJM_ERROR_INVALID_CONTEXT = 0x80930002;
constexpr int ORBIS_AJM_ERROR_INVALID_INSTANCE = 0x80930003;
constexpr int ORBIS_AJM_ERROR_INVALID_BATCH = 0x80930004;
constexpr int ORBIS_AJM_ERROR_INVALID_PARAMETER = 0x80930005;
constexpr int ORBIS_AJM_ERROR_OUT_OF_MEMORY = 0x80930006;
constexpr int ORBIS_AJM_ERROR_OUT_OF_RESOURCES = 0x80930007;
constexpr int ORBIS_AJM_ERROR_CODEC_NOT_SUPPORTED = 0x80930008;
constexpr int ORBIS_AJM_ERROR_CODEC_ALREADY_REGISTERED = 0x80930009;
constexpr int ORBIS_AJM_ERROR_CODEC_NOT_REGISTERED = 0x8093000A;
constexpr int ORBIS_AJM_ERROR_WRONG_REVISION_FLAG = 0x8093000B;
constexpr int ORBIS_AJM_ERROR_FLAG_NOT_SUPPORTED = 0x8093000C;
constexpr int ORBIS_AJM_ERROR_BUSY = 0x8093000D;
constexpr int ORBIS_AJM_ERROR_BAD_PRIORITY = 0x8093000E;
constexpr int ORBIS_AJM_ERROR_IN_PROGRESS = 0x8093000F;
constexpr int ORBIS_AJM_ERROR_RETRY = 0x80930010;
constexpr int ORBIS_AJM_ERROR_MALFORMED_BATCH = 0x80930011;
constexpr int ORBIS_AJM_ERROR_JOB_CREATION = 0x80930012;
constexpr int ORBIS_AJM_ERROR_INVALID_OPCODE = 0x80930013;
constexpr int ORBIS_AJM_ERROR_PRIORITY_VIOLATION = 0x80930014;
constexpr int ORBIS_AJM_ERROR_BUFFER_TOO_BIG = 0x80930015;
constexpr int ORBIS_AJM_ERROR_INVALID_ADDRESS = 0x80930016;
constexpr int ORBIS_AJM_ERROR_CANCELLED = 0x80930017;

View File

@ -1,20 +1,38 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
// Generated By moduleGenerator
#include <cmath> #include <cmath>
#include <common/path_util.h>
#include <common/singleton.h>
#include <core/file_format/psf.h>
#include <core/file_sys/fs.h>
#include "app_content.h" #include "app_content.h"
#include "common/io_file.h" #include "common/io_file.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/path_util.h"
#include "common/singleton.h"
#include "common/string_util.h"
#include "core/file_format/psf.h"
#include "core/file_sys/fs.h"
#include "core/libraries/error_codes.h" #include "core/libraries/error_codes.h"
#include "core/libraries/libs.h" #include "core/libraries/libs.h"
namespace Libraries::AppContent { namespace Libraries::AppContent {
int32_t addcont_count = 0;
struct AddContInfo {
char entitlementLabel[ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE];
OrbisAppContentAddcontDownloadStatus status;
OrbisAppContentGetEntitlementKey key;
};
std::array<AddContInfo, ORBIS_APP_CONTENT_INFO_LIST_MAX_SIZE> addcont_info = {{
{"0000000000000000",
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED,
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00}},
}};
std::string title_id;
int PS4_SYSV_ABI _Z5dummyv() { int PS4_SYSV_ABI _Z5dummyv() {
LOG_ERROR(Lib_AppContent, "(STUBBED) called"); LOG_ERROR(Lib_AppContent, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;
@ -35,11 +53,33 @@ int PS4_SYSV_ABI sceAppContentAddcontEnqueueDownloadSp() {
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceAppContentAddcontMount() { int PS4_SYSV_ABI sceAppContentAddcontMount(u32 service_label,
LOG_ERROR(Lib_AppContent, "(STUBBED) called"); const OrbisNpUnifiedEntitlementLabel* entitlement_label,
OrbisAppContentMountPoint* mount_point) {
LOG_INFO(Lib_AppContent, "called");
const auto& mount_dir = Common::FS::GetUserPath(Common::FS::PathType::AddonsDir) / title_id /
entitlement_label->data;
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
for (int i = 0; i < addcont_count; i++) {
if (strncmp(entitlement_label->data, addcont_info[i].entitlementLabel,
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
continue;
}
if (addcont_info[i].status != ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED) {
return ORBIS_APP_CONTENT_ERROR_NOT_FOUND;
}
snprintf(mount_point->data, ORBIS_APP_CONTENT_MOUNTPOINT_DATA_MAXSIZE, "/addcont%d", i);
mnt->Mount(mount_dir, mount_point->data);
return ORBIS_OK; return ORBIS_OK;
} }
return ORBIS_APP_CONTENT_ERROR_NOT_FOUND;
}
int PS4_SYSV_ABI sceAppContentAddcontShrink() { int PS4_SYSV_ABI sceAppContentAddcontShrink() {
LOG_ERROR(Lib_AppContent, "(STUBBED) called"); LOG_ERROR(Lib_AppContent, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;
@ -124,24 +164,82 @@ int PS4_SYSV_ABI sceAppContentGetAddcontDownloadProgress() {
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceAppContentGetAddcontInfo() { int PS4_SYSV_ABI sceAppContentGetAddcontInfo(u32 service_label,
LOG_ERROR(Lib_AppContent, "(STUBBED) called"); const OrbisNpUnifiedEntitlementLabel* entitlementLabel,
OrbisAppContentAddcontInfo* info) {
LOG_INFO(Lib_AppContent, "called");
if (entitlementLabel == nullptr || info == nullptr) {
return ORBIS_APP_CONTENT_ERROR_PARAMETER;
}
for (auto i = 0; i < addcont_count; i++) {
if (strncmp(entitlementLabel->data, addcont_info[i].entitlementLabel,
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
continue;
}
LOG_INFO(Lib_AppContent, "found DLC {}", entitlementLabel->data);
strncpy(info->entitlement_label.data, addcont_info[i].entitlementLabel,
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE);
info->status = addcont_info[i].status;
return ORBIS_OK; return ORBIS_OK;
} }
return ORBIS_APP_CONTENT_ERROR_DRM_NO_ENTITLEMENT;
}
int PS4_SYSV_ABI sceAppContentGetAddcontInfoList(u32 service_label, int PS4_SYSV_ABI sceAppContentGetAddcontInfoList(u32 service_label,
OrbisAppContentAddcontInfo* list, u32 list_num, OrbisAppContentAddcontInfo* list, u32 list_num,
u32* hit_num) { u32* hit_num) {
*hit_num = 0; LOG_INFO(Lib_AppContent, "called");
LOG_ERROR(Lib_AppContent, "(DUMMY) called");
if (list_num == 0 || list == nullptr) {
if (hit_num == nullptr) {
return ORBIS_APP_CONTENT_ERROR_PARAMETER;
}
*hit_num = addcont_count;
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceAppContentGetEntitlementKey() { int dlcs_to_list = addcont_count < list_num ? addcont_count : list_num;
LOG_ERROR(Lib_AppContent, "(STUBBED) called"); for (int i = 0; i < dlcs_to_list; i++) {
strncpy(list[i].entitlement_label.data, addcont_info[i].entitlementLabel,
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE);
list[i].status = addcont_info[i].status;
}
if (hit_num != nullptr) {
*hit_num = dlcs_to_list;
}
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceAppContentGetEntitlementKey(
u32 service_label, const OrbisNpUnifiedEntitlementLabel* entitlement_label,
OrbisAppContentGetEntitlementKey* key) {
LOG_ERROR(Lib_AppContent, "called");
if (entitlement_label == nullptr || key == nullptr) {
return ORBIS_APP_CONTENT_ERROR_PARAMETER;
}
for (int i = 0; i < addcont_count; i++) {
if (strncmp(entitlement_label->data, addcont_info[i].entitlementLabel,
ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE - 1) != 0) {
continue;
}
memcpy(key->data, addcont_info[i].key.data, ORBIS_APP_CONTENT_ENTITLEMENT_KEY_SIZE);
return ORBIS_OK;
}
return ORBIS_APP_CONTENT_ERROR_DRM_NO_ENTITLEMENT;
}
int PS4_SYSV_ABI sceAppContentGetRegion() { int PS4_SYSV_ABI sceAppContentGetRegion() {
LOG_ERROR(Lib_AppContent, "(STUBBED) called"); LOG_ERROR(Lib_AppContent, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;
@ -150,7 +248,25 @@ int PS4_SYSV_ABI sceAppContentGetRegion() {
int PS4_SYSV_ABI sceAppContentInitialize(const OrbisAppContentInitParam* initParam, int PS4_SYSV_ABI sceAppContentInitialize(const OrbisAppContentInitParam* initParam,
OrbisAppContentBootParam* bootParam) { OrbisAppContentBootParam* bootParam) {
LOG_ERROR(Lib_AppContent, "(DUMMY) called"); LOG_ERROR(Lib_AppContent, "(DUMMY) called");
bootParam->attr = 0; // always 0 auto* param_sfo = Common::Singleton<PSF>::Instance();
const auto addons_dir = Common::FS::GetUserPath(Common::FS::PathType::AddonsDir);
title_id = param_sfo->GetString("TITLE_ID");
auto addon_path = addons_dir / title_id;
if (std::filesystem::exists(addon_path)) {
for (const auto& entry : std::filesystem::directory_iterator(addon_path)) {
if (entry.is_directory()) {
auto entitlement_label = entry.path().filename().string();
AddContInfo info{};
info.status = ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED;
strcpy(info.entitlementLabel, entitlement_label.c_str());
addcont_info[addcont_count++] = info;
}
}
}
return ORBIS_OK; return ORBIS_OK;
} }
@ -198,13 +314,9 @@ int PS4_SYSV_ABI sceAppContentTemporaryDataMount() {
int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOption option, int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOption option,
OrbisAppContentMountPoint* mountPoint) { OrbisAppContentMountPoint* mountPoint) {
if (std::string_view(mountPoint->data).empty()) // causing issues with save_data. if (mountPoint == nullptr)
return ORBIS_APP_CONTENT_ERROR_PARAMETER; return ORBIS_APP_CONTENT_ERROR_PARAMETER;
auto* param_sfo = Common::Singleton<PSF>::Instance(); strncpy(mountPoint->data, "/temp0", 16);
std::string id(param_sfo->GetString("CONTENT_ID"), 7, 9);
const auto& mount_dir = Common::FS::GetUserPath(Common::FS::PathType::TempDataDir) / id;
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
mnt->Mount(mount_dir, mountPoint->data);
LOG_INFO(Lib_AppContent, "sceAppContentTemporaryDataMount2: option = {}, mountPoint = {}", LOG_INFO(Lib_AppContent, "sceAppContentTemporaryDataMount2: option = {}, mountPoint = {}",
option, mountPoint->data); option, mountPoint->data);
return ORBIS_OK; return ORBIS_OK;
@ -225,12 +337,12 @@ int PS4_SYSV_ABI Func_C59A36FF8D7C59DA() {
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceAppContentAddcontEnqueueDownloadByEntitlemetId() { int PS4_SYSV_ABI sceAppContentAddcontEnqueueDownloadByEntitlementId() {
LOG_ERROR(Lib_AppContent, "(STUBBED) called"); LOG_ERROR(Lib_AppContent, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceAppContentAddcontMountByEntitlemetId() { int PS4_SYSV_ABI sceAppContentAddcontMountByEntitlementId() {
LOG_ERROR(Lib_AppContent, "(STUBBED) called"); LOG_ERROR(Lib_AppContent, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;
} }
@ -317,9 +429,9 @@ void RegisterlibSceAppContent(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("xZo2-418Wdo", "libSceAppContentBundle", 1, "libSceAppContent", 1, 1, LIB_FUNCTION("xZo2-418Wdo", "libSceAppContentBundle", 1, "libSceAppContent", 1, 1,
Func_C59A36FF8D7C59DA); Func_C59A36FF8D7C59DA);
LIB_FUNCTION("kJmjt81mXKQ", "libSceAppContentIro", 1, "libSceAppContent", 1, 1, LIB_FUNCTION("kJmjt81mXKQ", "libSceAppContentIro", 1, "libSceAppContent", 1, 1,
sceAppContentAddcontEnqueueDownloadByEntitlemetId); sceAppContentAddcontEnqueueDownloadByEntitlementId);
LIB_FUNCTION("efX3lrPwdKA", "libSceAppContentIro", 1, "libSceAppContent", 1, 1, LIB_FUNCTION("efX3lrPwdKA", "libSceAppContentIro", 1, "libSceAppContent", 1, 1,
sceAppContentAddcontMountByEntitlemetId); sceAppContentAddcontMountByEntitlementId);
LIB_FUNCTION("z9hgjLd1SGA", "libSceAppContentIro", 1, "libSceAppContent", 1, 1, LIB_FUNCTION("z9hgjLd1SGA", "libSceAppContentIro", 1, "libSceAppContent", 1, 1,
sceAppContentGetAddcontInfoByEntitlementId); sceAppContentGetAddcontInfoByEntitlementId);
LIB_FUNCTION("3wUaDTGmjcQ", "libSceAppContentIro", 1, "libSceAppContent", 1, 1, LIB_FUNCTION("3wUaDTGmjcQ", "libSceAppContentIro", 1, "libSceAppContent", 1, 1,

View File

@ -41,6 +41,16 @@ struct OrbisAppContentMountPoint {
constexpr int ORBIS_APP_CONTENT_TEMPORARY_DATA_OPTION_NONE = 0; constexpr int ORBIS_APP_CONTENT_TEMPORARY_DATA_OPTION_NONE = 0;
constexpr int ORBIS_APP_CONTENT_TEMPORARY_DATA_OPTION_FORMAT = (1 << 0); constexpr int ORBIS_APP_CONTENT_TEMPORARY_DATA_OPTION_FORMAT = (1 << 0);
constexpr int ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE = 17; constexpr int ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE = 17;
constexpr int ORBIS_APP_CONTENT_ENTITLEMENT_KEY_SIZE = 16;
constexpr int ORBIS_APP_CONTENT_INFO_LIST_MAX_SIZE = 2500;
enum OrbisAppContentAddcontDownloadStatus : u32 {
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_NO_EXTRA_DATA = 0,
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_NO_IN_QUEUE = 1,
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_DOWNLOADING = 2,
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_DOWNLOAD_SUSPENDED = 3,
ORBIS_APP_CONTENT_ADDCONT_DOWNLOAD_STATUS_INSTALLED = 4
};
struct OrbisNpUnifiedEntitlementLabel { struct OrbisNpUnifiedEntitlementLabel {
char data[ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE]; char data[ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE];
@ -54,11 +64,17 @@ struct OrbisAppContentAddcontInfo {
u32 status; u32 status;
}; };
struct OrbisAppContentGetEntitlementKey {
char data[ORBIS_APP_CONTENT_ENTITLEMENT_KEY_SIZE];
};
int PS4_SYSV_ABI _Z5dummyv(); int PS4_SYSV_ABI _Z5dummyv();
int PS4_SYSV_ABI sceAppContentAddcontDelete(); int PS4_SYSV_ABI sceAppContentAddcontDelete();
int PS4_SYSV_ABI sceAppContentAddcontEnqueueDownload(); int PS4_SYSV_ABI sceAppContentAddcontEnqueueDownload();
int PS4_SYSV_ABI sceAppContentAddcontEnqueueDownloadSp(); int PS4_SYSV_ABI sceAppContentAddcontEnqueueDownloadSp();
int PS4_SYSV_ABI sceAppContentAddcontMount(); int PS4_SYSV_ABI sceAppContentAddcontMount(u32 service_label,
const OrbisNpUnifiedEntitlementLabel* entitlement_label,
OrbisAppContentMountPoint* mount_point);
int PS4_SYSV_ABI sceAppContentAddcontShrink(); int PS4_SYSV_ABI sceAppContentAddcontShrink();
int PS4_SYSV_ABI sceAppContentAddcontUnmount(); int PS4_SYSV_ABI sceAppContentAddcontUnmount();
int PS4_SYSV_ABI sceAppContentAppParamGetInt(OrbisAppContentAppParamId paramId, s32* value); int PS4_SYSV_ABI sceAppContentAppParamGetInt(OrbisAppContentAppParamId paramId, s32* value);
@ -70,11 +86,15 @@ int PS4_SYSV_ABI sceAppContentDownload1Shrink();
int PS4_SYSV_ABI sceAppContentDownloadDataFormat(); int PS4_SYSV_ABI sceAppContentDownloadDataFormat();
int PS4_SYSV_ABI sceAppContentDownloadDataGetAvailableSpaceKb(); int PS4_SYSV_ABI sceAppContentDownloadDataGetAvailableSpaceKb();
int PS4_SYSV_ABI sceAppContentGetAddcontDownloadProgress(); int PS4_SYSV_ABI sceAppContentGetAddcontDownloadProgress();
int PS4_SYSV_ABI sceAppContentGetAddcontInfo(); int PS4_SYSV_ABI sceAppContentGetAddcontInfo(u32 service_label,
const OrbisNpUnifiedEntitlementLabel* entitlementLabel,
OrbisAppContentAddcontInfo* info);
int PS4_SYSV_ABI sceAppContentGetAddcontInfoList(u32 service_label, int PS4_SYSV_ABI sceAppContentGetAddcontInfoList(u32 service_label,
OrbisAppContentAddcontInfo* list, u32 list_num, OrbisAppContentAddcontInfo* list, u32 list_num,
u32* hit_num); u32* hit_num);
int PS4_SYSV_ABI sceAppContentGetEntitlementKey(); int PS4_SYSV_ABI sceAppContentGetEntitlementKey(
u32 service_label, const OrbisNpUnifiedEntitlementLabel* entitlement_label,
OrbisAppContentGetEntitlementKey* key);
int PS4_SYSV_ABI sceAppContentGetRegion(); int PS4_SYSV_ABI sceAppContentGetRegion();
int PS4_SYSV_ABI sceAppContentInitialize(const OrbisAppContentInitParam* initParam, int PS4_SYSV_ABI sceAppContentInitialize(const OrbisAppContentInitParam* initParam,
OrbisAppContentBootParam* bootParam); OrbisAppContentBootParam* bootParam);
@ -92,8 +112,8 @@ int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOp
int PS4_SYSV_ABI sceAppContentTemporaryDataUnmount(); int PS4_SYSV_ABI sceAppContentTemporaryDataUnmount();
int PS4_SYSV_ABI sceAppContentGetPftFlag(); int PS4_SYSV_ABI sceAppContentGetPftFlag();
int PS4_SYSV_ABI Func_C59A36FF8D7C59DA(); int PS4_SYSV_ABI Func_C59A36FF8D7C59DA();
int PS4_SYSV_ABI sceAppContentAddcontEnqueueDownloadByEntitlemetId(); int PS4_SYSV_ABI sceAppContentAddcontEnqueueDownloadByEntitlementId();
int PS4_SYSV_ABI sceAppContentAddcontMountByEntitlemetId(); int PS4_SYSV_ABI sceAppContentAddcontMountByEntitlementId();
int PS4_SYSV_ABI sceAppContentGetAddcontInfoByEntitlementId(); int PS4_SYSV_ABI sceAppContentGetAddcontInfoByEntitlementId();
int PS4_SYSV_ABI sceAppContentGetAddcontInfoListByIroTag(); int PS4_SYSV_ABI sceAppContentGetAddcontInfoListByIroTag();
int PS4_SYSV_ABI sceAppContentGetDownloadedStoreCountry(); int PS4_SYSV_ABI sceAppContentGetDownloadedStoreCountry();

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <memory> #include <memory>
#include <common/assert.h>
#include <magic_enum.hpp> #include <magic_enum.hpp>
#include "audio_core/sdl_audio.h" #include "audio_core/sdl_audio.h"
#include "common/assert.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/libraries/audio/audioout.h" #include "core/libraries/audio/audioout.h"
#include "core/libraries/error_codes.h" #include "core/libraries/error_codes.h"
@ -175,7 +176,6 @@ int PS4_SYSV_ABI sceAudioOutGetLastOutputTime() {
} }
int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* state) { int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* state) {
int type = 0; int type = 0;
int channels_num = 0; int channels_num = 0;
@ -235,8 +235,11 @@ int PS4_SYSV_ABI sceAudioOutGetSystemState() {
} }
int PS4_SYSV_ABI sceAudioOutInit() { int PS4_SYSV_ABI sceAudioOutInit() {
LOG_TRACE(Lib_AudioOut, "called");
if (audio != nullptr) {
return ORBIS_AUDIO_OUT_ERROR_ALREADY_INIT;
}
audio = std::make_unique<Audio::SDLAudio>(); audio = std::make_unique<Audio::SDLAudio>();
LOG_INFO(Lib_AudioOut, "called");
return ORBIS_OK; return ORBIS_OK;
} }

View File

@ -1,21 +1,34 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
// Generated By moduleGenerator
#include "avplayer.h" #include "avplayer.h"
#include "avplayer_impl.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/libraries/error_codes.h" #include "core/libraries/error_codes.h"
#include "core/libraries/kernel/thread_management.h"
#include "core/libraries/libs.h" #include "core/libraries/libs.h"
namespace Libraries::AvPlayer { namespace Libraries::AvPlayer {
int PS4_SYSV_ABI sceAvPlayerAddSource() { using namespace Kernel;
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK; s32 PS4_SYSV_ABI sceAvPlayerAddSource(SceAvPlayerHandle handle, const char* filename) {
LOG_TRACE(Lib_AvPlayer, "filename = {}", filename);
if (handle == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
const auto res = handle->AddSource(filename);
LOG_TRACE(Lib_AvPlayer, "returning {}", res);
return res;
} }
int PS4_SYSV_ABI sceAvPlayerAddSourceEx() { s32 PS4_SYSV_ABI sceAvPlayerAddSourceEx(SceAvPlayerHandle handle, SceAvPlayerUriType uriType,
SceAvPlayerSourceDetails* sourceDetails) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called"); LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
if (handle == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
return ORBIS_OK; return ORBIS_OK;
} }
@ -24,122 +37,247 @@ int PS4_SYSV_ABI sceAvPlayerChangeStream() {
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceAvPlayerClose() { s32 PS4_SYSV_ABI sceAvPlayerClose(SceAvPlayerHandle handle) {
LOG_TRACE(Lib_AvPlayer, "called");
if (handle == nullptr) {
LOG_TRACE(Lib_AvPlayer, "returning ORBIS_AVPLAYER_ERROR_INVALID_PARAMS");
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
delete handle;
LOG_TRACE(Lib_AvPlayer, "returning ORBIS_OK");
return ORBIS_OK;
}
u64 PS4_SYSV_ABI sceAvPlayerCurrentTime(SceAvPlayerHandle handle) {
LOG_TRACE(Lib_AvPlayer, "called");
if (handle == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
const auto res = handle->CurrentTime();
LOG_TRACE(Lib_AvPlayer, "returning {}", res);
return res;
}
s32 PS4_SYSV_ABI sceAvPlayerDisableStream(SceAvPlayerHandle handle, u32 stream_id) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
if (handle == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceAvPlayerEnableStream(SceAvPlayerHandle handle, u32 stream_id) {
LOG_TRACE(Lib_AvPlayer, "stream_id = {}", stream_id);
if (handle == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
const auto res = handle->EnableStream(stream_id);
LOG_TRACE(Lib_AvPlayer, "returning {}", res);
return res;
}
bool PS4_SYSV_ABI sceAvPlayerGetAudioData(SceAvPlayerHandle handle, SceAvPlayerFrameInfo* p_info) {
LOG_TRACE(Lib_AvPlayer, "called");
if (handle == nullptr || p_info == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
const auto res = handle->GetAudioData(*p_info);
LOG_TRACE(Lib_AvPlayer, "returning {}", res);
return res;
}
s32 PS4_SYSV_ABI sceAvPlayerGetStreamInfo(SceAvPlayerHandle handle, u32 stream_id,
SceAvPlayerStreamInfo* p_info) {
LOG_TRACE(Lib_AvPlayer, "stream_id = {}", stream_id);
if (handle == nullptr || p_info == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
const auto res = handle->GetStreamInfo(stream_id, *p_info);
LOG_TRACE(Lib_AvPlayer, "returning {}", res);
return res;
}
bool PS4_SYSV_ABI sceAvPlayerGetVideoData(SceAvPlayerHandle handle,
SceAvPlayerFrameInfo* video_info) {
LOG_TRACE(Lib_AvPlayer, "called");
if (handle == nullptr || video_info == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
const auto res = handle->GetVideoData(*video_info);
LOG_TRACE(Lib_AvPlayer, "returning {}", res);
return res;
}
bool PS4_SYSV_ABI sceAvPlayerGetVideoDataEx(SceAvPlayerHandle handle,
SceAvPlayerFrameInfoEx* video_info) {
LOG_TRACE(Lib_AvPlayer, "called");
if (handle == nullptr || video_info == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
const auto res = handle->GetVideoData(*video_info);
LOG_TRACE(Lib_AvPlayer, "returning {}", res);
return res;
}
SceAvPlayerHandle PS4_SYSV_ABI sceAvPlayerInit(SceAvPlayerInitData* data) {
LOG_TRACE(Lib_AvPlayer, "called");
if (data == nullptr) {
return nullptr;
}
if (data->memory_replacement.allocate == nullptr ||
data->memory_replacement.allocate_texture == nullptr ||
data->memory_replacement.deallocate == nullptr ||
data->memory_replacement.deallocate_texture == nullptr) {
LOG_ERROR(Lib_AvPlayer, "All allocators are required for AVPlayer Initialisation.");
return nullptr;
}
return new AvPlayer(*data);
}
s32 PS4_SYSV_ABI sceAvPlayerInitEx(const SceAvPlayerInitDataEx* p_data,
SceAvPlayerHandle* p_player) {
LOG_TRACE(Lib_AvPlayer, "called");
if (p_data == nullptr || p_player == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
if (p_data->memory_replacement.allocate == nullptr ||
p_data->memory_replacement.allocate_texture == nullptr ||
p_data->memory_replacement.deallocate == nullptr ||
p_data->memory_replacement.deallocate_texture == nullptr) {
LOG_ERROR(Lib_AvPlayer, "All allocators are required for AVPlayer Initialisation.");
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
SceAvPlayerInitData data = {};
data.memory_replacement = p_data->memory_replacement;
data.file_replacement = p_data->file_replacement;
data.event_replacement = p_data->event_replacement;
data.default_language = p_data->default_language;
data.num_output_video_framebuffers = p_data->num_output_video_framebuffers;
data.auto_start = p_data->auto_start;
*p_player = new AvPlayer(data);
return ORBIS_OK;
}
bool PS4_SYSV_ABI sceAvPlayerIsActive(SceAvPlayerHandle handle) {
LOG_TRACE(Lib_AvPlayer, "called");
if (handle == nullptr) {
LOG_TRACE(Lib_AvPlayer, "returning ORBIS_AVPLAYER_ERROR_INVALID_PARAMS");
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
const auto res = handle->IsActive();
LOG_TRACE(Lib_AvPlayer, "returning {}", res);
return res;
}
s32 PS4_SYSV_ABI sceAvPlayerJumpToTime(SceAvPlayerHandle handle, uint64_t time) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called, time (msec) = {}", time);
if (handle == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceAvPlayerPause(SceAvPlayerHandle handle) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
if (handle == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceAvPlayerPostInit(SceAvPlayerHandle handle, SceAvPlayerPostInitData* data) {
LOG_TRACE(Lib_AvPlayer, "called");
if (handle == nullptr || data == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
const auto res = handle->PostInit(*data);
LOG_TRACE(Lib_AvPlayer, "returning {}", res);
return res;
}
s32 PS4_SYSV_ABI sceAvPlayerPrintf(const char* format, ...) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called"); LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceAvPlayerCurrentTime() { s32 PS4_SYSV_ABI sceAvPlayerResume(SceAvPlayerHandle handle) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
if (handle == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceAvPlayerSetAvSyncMode(SceAvPlayerHandle handle,
SceAvPlayerAvSyncMode sync_mode) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
if (handle == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceAvPlayerSetLogCallback(SceAvPlayerLogCallback log_cb, void* user_data) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called"); LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceAvPlayerDisableStream() { s32 PS4_SYSV_ABI sceAvPlayerSetLooping(SceAvPlayerHandle handle, bool loop_flag) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called"); LOG_TRACE(Lib_AvPlayer, "called, looping = {}", loop_flag);
if (handle == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
if (!handle->SetLooping(loop_flag)) {
return ORBIS_AVPLAYER_ERROR_OPERATION_FAILED;
}
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceAvPlayerEnableStream() { s32 PS4_SYSV_ABI sceAvPlayerSetTrickSpeed(SceAvPlayerHandle handle, s32 trick_speed) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called"); LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
if (handle == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceAvPlayerGetAudioData() { s32 PS4_SYSV_ABI sceAvPlayerStart(SceAvPlayerHandle handle) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called"); LOG_TRACE(Lib_AvPlayer, "called");
return ORBIS_OK; if (handle == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
const auto res = handle->Start();
LOG_TRACE(Lib_AvPlayer, "returning {}", res);
return res;
} }
int PS4_SYSV_ABI sceAvPlayerGetStreamInfo() { s32 PS4_SYSV_ABI sceAvPlayerStop(SceAvPlayerHandle handle) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called"); LOG_TRACE(Lib_AvPlayer, "called");
return ORBIS_OK; if (handle == nullptr) {
LOG_TRACE(Lib_AvPlayer, "returning ORBIS_AVPLAYER_ERROR_INVALID_PARAMS");
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
const auto res = handle->Stop();
LOG_TRACE(Lib_AvPlayer, "returning {}", res);
return res;
} }
int PS4_SYSV_ABI sceAvPlayerGetVideoData() { s32 PS4_SYSV_ABI sceAvPlayerStreamCount(SceAvPlayerHandle handle) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called"); LOG_TRACE(Lib_AvPlayer, "called");
return ORBIS_OK; if (handle == nullptr) {
return ORBIS_AVPLAYER_ERROR_INVALID_PARAMS;
}
const auto res = handle->GetStreamCount();
LOG_TRACE(Lib_AvPlayer, "returning {}", res);
return res;
} }
int PS4_SYSV_ABI sceAvPlayerGetVideoDataEx() { s32 PS4_SYSV_ABI sceAvPlayerVprintf(const char* format, va_list args) {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerInit() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerInitEx() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerIsActive() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerJumpToTime() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerPause() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerPostInit() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerPrintf() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerResume() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerSetAvSyncMode() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerSetLogCallback() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerSetLooping() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerSetTrickSpeed() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerStart() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerStop() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerStreamCount() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceAvPlayerVprintf() {
LOG_ERROR(Lib_AvPlayer, "(STUBBED) called"); LOG_ERROR(Lib_AvPlayer, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;
} }

View File

@ -5,39 +5,288 @@
#include "common/types.h" #include "common/types.h"
#include <stdarg.h> // va_list
#include <stddef.h> // size_t
namespace Core::Loader { namespace Core::Loader {
class SymbolsResolver; class SymbolsResolver;
} }
namespace Libraries::AvPlayer { namespace Libraries::AvPlayer {
int PS4_SYSV_ABI sceAvPlayerAddSource(); class AvPlayer;
int PS4_SYSV_ABI sceAvPlayerAddSourceEx();
int PS4_SYSV_ABI sceAvPlayerChangeStream(); using SceAvPlayerHandle = AvPlayer*;
int PS4_SYSV_ABI sceAvPlayerClose();
int PS4_SYSV_ABI sceAvPlayerCurrentTime(); enum SceAvPlayerUriType { SCE_AVPLAYER_URI_TYPE_SOURCE = 0 };
int PS4_SYSV_ABI sceAvPlayerDisableStream();
int PS4_SYSV_ABI sceAvPlayerEnableStream(); struct SceAvPlayerUri {
int PS4_SYSV_ABI sceAvPlayerGetAudioData(); const char* name;
int PS4_SYSV_ABI sceAvPlayerGetStreamInfo(); u32 length;
int PS4_SYSV_ABI sceAvPlayerGetVideoData(); };
int PS4_SYSV_ABI sceAvPlayerGetVideoDataEx();
int PS4_SYSV_ABI sceAvPlayerInit(); enum SceAvPlayerSourceType {
int PS4_SYSV_ABI sceAvPlayerInitEx(); SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN = 0,
int PS4_SYSV_ABI sceAvPlayerIsActive(); SCE_AVPLAYER_SOURCE_TYPE_FILE_MP4 = 1,
int PS4_SYSV_ABI sceAvPlayerJumpToTime(); SCE_AVPLAYER_SOURCE_TYPE_HLS = 8
int PS4_SYSV_ABI sceAvPlayerPause(); };
int PS4_SYSV_ABI sceAvPlayerPostInit();
int PS4_SYSV_ABI sceAvPlayerPrintf(); struct SceAvPlayerSourceDetails {
int PS4_SYSV_ABI sceAvPlayerResume(); SceAvPlayerUri uri;
int PS4_SYSV_ABI sceAvPlayerSetAvSyncMode(); u8 reserved1[64];
int PS4_SYSV_ABI sceAvPlayerSetLogCallback(); SceAvPlayerSourceType source_type;
int PS4_SYSV_ABI sceAvPlayerSetLooping(); u8 reserved2[44];
int PS4_SYSV_ABI sceAvPlayerSetTrickSpeed(); };
int PS4_SYSV_ABI sceAvPlayerStart();
int PS4_SYSV_ABI sceAvPlayerStop(); struct SceAvPlayerAudio {
int PS4_SYSV_ABI sceAvPlayerStreamCount(); u16 channel_count;
int PS4_SYSV_ABI sceAvPlayerVprintf(); u8 reserved1[2];
u32 sample_rate;
u32 size;
u8 language_code[4];
};
struct SceAvPlayerVideo {
u32 width;
u32 height;
f32 aspect_ratio;
u8 language_code[4];
};
struct SceAvPlayerTextPosition {
u16 top;
u16 left;
u16 bottom;
u16 right;
};
struct SceAvPlayerTimedText {
u8 language_code[4];
u16 text_size;
u16 font_size;
SceAvPlayerTextPosition position;
};
union SceAvPlayerStreamDetails {
u8 reserved[16];
SceAvPlayerAudio audio;
SceAvPlayerVideo video;
SceAvPlayerTimedText subs;
};
struct SceAvPlayerFrameInfo {
u8* pData;
u8 reserved[4];
u64 timestamp;
SceAvPlayerStreamDetails details;
};
struct SceAvPlayerStreamInfo {
u32 type;
u8 reserved[4];
SceAvPlayerStreamDetails details;
u64 duration;
u64 start_time;
};
struct SceAvPlayerAudioEx {
u16 channel_count;
u8 reserved[2];
u32 sample_rate;
u32 size;
u8 language_code[4];
u8 reserved1[64];
};
struct SceAvPlayerVideoEx {
u32 width;
u32 height;
f32 aspect_ratio;
u8 language_code[4];
u32 framerate;
u32 crop_left_offset;
u32 crop_right_offset;
u32 crop_top_offset;
u32 crop_bottom_offset;
u32 pitch;
u8 luma_bit_depth;
u8 chroma_bit_depth;
bool video_full_range_flag;
u8 reserved1[37];
};
struct SceAvPlayerTimedTextEx {
u8 language_code[4];
u8 reserved[12];
u8 reserved1[64];
};
union SceAvPlayerStreamDetailsEx {
SceAvPlayerAudioEx audio;
SceAvPlayerVideoEx video;
SceAvPlayerTimedTextEx subs;
u8 reserved1[80];
};
struct SceAvPlayerFrameInfoEx {
void* pData;
u8 reserved[4];
u64 timestamp;
SceAvPlayerStreamDetailsEx details;
};
typedef void* PS4_SYSV_ABI (*SceAvPlayerAllocate)(void* p, u32 align, u32 size);
typedef void PS4_SYSV_ABI (*SceAvPlayerDeallocate)(void* p, void* mem);
typedef void* PS4_SYSV_ABI (*SceAvPlayerAllocateTexture)(void* p, u32 align, u32 size);
typedef void PS4_SYSV_ABI (*SceAvPlayerDeallocateTexture)(void* p, void* mem);
struct SceAvPlayerMemAllocator {
void* object_ptr;
SceAvPlayerAllocate allocate;
SceAvPlayerDeallocate deallocate;
SceAvPlayerAllocateTexture allocate_texture;
SceAvPlayerDeallocateTexture deallocate_texture;
};
typedef s32 PS4_SYSV_ABI (*SceAvPlayerOpenFile)(void* p, const char* name);
typedef s32 PS4_SYSV_ABI (*SceAvPlayerCloseFile)(void* p);
typedef s32 PS4_SYSV_ABI (*SceAvPlayerReadOffsetFile)(void* p, u8* buf, u64 pos, u32 len);
typedef u64 PS4_SYSV_ABI (*SceAvPlayerSizeFile)(void* p);
struct SceAvPlayerFileReplacement {
void* object_ptr;
SceAvPlayerOpenFile open;
SceAvPlayerCloseFile close;
SceAvPlayerReadOffsetFile readOffset;
SceAvPlayerSizeFile size;
};
typedef void PS4_SYSV_ABI (*SceAvPlayerEventCallback)(void* p, s32 event, s32 src_id, void* data);
struct SceAvPlayerEventReplacement {
void* object_ptr;
SceAvPlayerEventCallback event_callback;
};
enum SceAvPlayerDebuglevels {
SCE_AVPLAYER_DBG_NONE,
SCE_AVPLAYER_DBG_INFO,
SCE_AVPLAYER_DBG_WARNINGS,
SCE_AVPLAYER_DBG_ALL
};
struct SceAvPlayerInitData {
SceAvPlayerMemAllocator memory_replacement;
SceAvPlayerFileReplacement file_replacement;
SceAvPlayerEventReplacement event_replacement;
SceAvPlayerDebuglevels debug_level;
u32 base_priority;
s32 num_output_video_framebuffers;
bool auto_start;
u8 reserved[3];
const char* default_language;
};
struct SceAvPlayerInitDataEx {
size_t this_size;
SceAvPlayerMemAllocator memory_replacement;
SceAvPlayerFileReplacement file_replacement;
SceAvPlayerEventReplacement event_replacement;
const char* default_language;
SceAvPlayerDebuglevels debug_level;
u32 audio_decoder_priority;
u32 audio_decoder_affinity;
u32 video_decoder_priority;
u32 video_decoder_affinity;
u32 demuxer_priority;
u32 demuxer_affinity;
u32 controller_priority;
u32 controller_affinity;
u32 http_streaming_priority;
u32 http_streaming_affinity;
u32 file_streaming_priority;
u32 file_streaming_affinity;
s32 num_output_video_framebuffers;
bool auto_start;
u8 reserved[3];
};
enum SceAvPlayerStreamType {
SCE_AVPLAYER_VIDEO,
SCE_AVPLAYER_AUDIO,
SCE_AVPLAYER_TIMEDTEXT,
SCE_AVPLAYER_UNKNOWN
};
enum SceAvPlayerVideoDecoderType {
SCE_AVPLAYER_VIDEO_DECODER_TYPE_DEFAULT = 0,
SCE_AVPLAYER_VIDEO_DECODER_TYPE_RESERVED1,
SCE_AVPLAYER_VIDEO_DECODER_TYPE_SOFTWARE,
SCE_AVPLAYER_VIDEO_DECODER_TYPE_SOFTWARE2
};
enum SceAvPlayerAudioDecoderType {
SCE_AVPLAYER_AUDIO_DECODER_TYPE_DEFAULT = 0,
SCE_AVPLAYER_AUDIO_DECODER_TYPE_RESERVED1,
SCE_AVPLAYER_AUDIO_DECODER_TYPE_RESERVED2
};
struct SceAvPlayerDecoderInit {
union {
SceAvPlayerVideoDecoderType video_type;
SceAvPlayerAudioDecoderType audio_type;
u8 reserved[4];
} decoderType;
union {
struct {
s32 cpu_affinity_mask;
s32 cpu_thread_priority;
u8 decode_pipeline_depth;
u8 compute_pipe_id;
u8 compute_queue_id;
u8 enable_interlaced;
u8 reserved[16];
} avcSw2;
struct {
u8 audio_channel_order;
u8 reserved[27];
} aac;
u8 reserved[28];
} decoderParams;
};
struct SceAvPlayerHTTPCtx {
u32 http_context_id;
u32 ssl_context_id;
};
struct SceAvPlayerPostInitData {
u32 demux_video_buffer_size;
SceAvPlayerDecoderInit video_decoder_init;
SceAvPlayerDecoderInit audio_decoder_init;
SceAvPlayerHTTPCtx http_context;
u8 reserved[56];
};
enum SceAvPlayerAvSyncMode {
SCE_AVPLAYER_AV_SYNC_MODE_DEFAULT = 0,
SCE_AVPLAYER_AV_SYNC_MODE_NONE
};
typedef int PS4_SYSV_ABI (*SceAvPlayerLogCallback)(void* p, const char* format, va_list args);
enum SceAvPlayerEvents {
SCE_AVPLAYER_STATE_STOP = 0x01,
SCE_AVPLAYER_STATE_READY = 0x02,
SCE_AVPLAYER_STATE_PLAY = 0x03,
SCE_AVPLAYER_STATE_PAUSE = 0x04,
SCE_AVPLAYER_STATE_BUFFERING = 0x05,
SCE_AVPLAYER_TIMED_TEXT_DELIVERY = 0x10,
SCE_AVPLAYER_WARNING_ID = 0x20,
SCE_AVPLAYER_ENCRYPTION = 0x30,
SCE_AVPLAYER_DRM_ERROR = 0x40
};
void RegisterlibSceAvPlayer(Core::Loader::SymbolsResolver* sym); void RegisterlibSceAvPlayer(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::AvPlayer } // namespace Libraries::AvPlayer

View File

@ -0,0 +1,61 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "avplayer.h"
#include "avplayer_common.h"
#include <algorithm> // std::equal
#include <cctype> // std::tolower
#include <string_view> // std::string_view
namespace Libraries::AvPlayer {
using namespace Kernel;
static bool ichar_equals(char a, char b) {
return std::tolower(static_cast<unsigned char>(a)) ==
std::tolower(static_cast<unsigned char>(b));
}
static bool iequals(std::string_view l, std::string_view r) {
return std::ranges::equal(l, r, ichar_equals);
}
SceAvPlayerSourceType GetSourceType(std::string_view path) {
if (path.empty()) {
return SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN;
}
std::string_view name = path;
if (path.find("://") != std::string_view::npos) {
// This path is a URI. Strip HTTP parameters from it.
// schema://server.domain/path/file.ext/and/beyond?param=value#paragraph ->
// -> schema://server.domain/path/to/file.ext/and/beyond
name = path.substr(0, path.find_first_of("?#"));
if (name.empty()) {
return SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN;
}
}
// schema://server.domain/path/to/file.ext/and/beyond -> .ext/and/beyond
auto ext = name.substr(name.rfind('.'));
if (ext.empty()) {
return SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN;
}
// .ext/and/beyond -> .ext
ext = ext.substr(0, ext.find('/'));
if (iequals(ext, ".mp4") || iequals(ext, ".m4v") || iequals(ext, ".m3d") ||
iequals(ext, ".m4a") || iequals(ext, ".mov")) {
return SCE_AVPLAYER_SOURCE_TYPE_FILE_MP4;
}
if (iequals(ext, ".m3u8")) {
return SCE_AVPLAYER_SOURCE_TYPE_HLS;
}
return SCE_AVPLAYER_SOURCE_TYPE_UNKNOWN;
}
} // namespace Libraries::AvPlayer

View File

@ -0,0 +1,91 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "avplayer.h"
#include "common/assert.h"
#include "common/logging/log.h"
#include "core/libraries/kernel/thread_management.h"
#include <optional>
#include <utility>
#include <queue>
#define AVPLAYER_IS_ERROR(x) ((x) < 0)
namespace Libraries::AvPlayer {
enum class AvState {
Initial,
AddingSource,
Ready,
Play,
Stop,
EndOfFile,
Pause,
C0x08,
Jump,
TrickMode,
C0x0B,
Buffering,
Starting,
Error,
};
enum class AvEventType {
ChangeFlowState = 21,
WarningId = 22,
RevertState = 30,
AddSource = 40,
Error = 255,
};
union AvPlayerEventData {
u32 num_frames; // 20
AvState state; // AvEventType::ChangeFlowState
s32 error; // AvEventType::WarningId
u32 attempt; // AvEventType::AddSource
};
struct AvPlayerEvent {
AvEventType event;
AvPlayerEventData payload;
};
template <class T>
class AvPlayerQueue {
public:
size_t Size() {
return m_queue.size();
}
void Push(T&& value) {
std::lock_guard guard(m_mutex);
m_queue.emplace(std::forward<T>(value));
}
std::optional<T> Pop() {
if (Size() == 0) {
return std::nullopt;
}
std::lock_guard guard(m_mutex);
auto result = std::move(m_queue.front());
m_queue.pop();
return result;
}
void Clear() {
std::lock_guard guard(m_mutex);
m_queue = {};
}
private:
std::mutex m_mutex{};
std::queue<T> m_queue{};
};
SceAvPlayerSourceType GetSourceType(std::string_view path);
} // namespace Libraries::AvPlayer

View File

@ -0,0 +1,23 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "avplayer.h"
#include "common/types.h"
#include <string_view>
struct AVIOContext;
namespace Libraries::AvPlayer {
class IDataStreamer {
public:
virtual ~IDataStreamer() = default;
virtual bool Init(std::string_view path) = 0;
virtual AVIOContext* GetContext() = 0;
};
} // namespace Libraries::AvPlayer

View File

@ -0,0 +1,90 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "avplayer_file_streamer.h"
#include "avplayer_common.h"
#include <magic_enum.hpp>
extern "C" {
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
}
#include <algorithm> // std::max, std::min
#define AVPLAYER_AVIO_BUFFER_SIZE 4096
namespace Libraries::AvPlayer {
AvPlayerFileStreamer::AvPlayerFileStreamer(const SceAvPlayerFileReplacement& file_replacement)
: m_file_replacement(file_replacement) {}
AvPlayerFileStreamer::~AvPlayerFileStreamer() {
if (m_avio_context != nullptr) {
avio_context_free(&m_avio_context);
}
if (m_file_replacement.close != nullptr && m_fd >= 0) {
const auto close = m_file_replacement.close;
const auto ptr = m_file_replacement.object_ptr;
close(ptr);
}
}
bool AvPlayerFileStreamer::Init(std::string_view path) {
const auto ptr = m_file_replacement.object_ptr;
m_fd = m_file_replacement.open(ptr, path.data());
if (m_fd < 0) {
return false;
}
m_file_size = m_file_replacement.size(ptr);
// avio_buffer is deallocated in `avio_context_free`
const auto avio_buffer = reinterpret_cast<u8*>(av_malloc(AVPLAYER_AVIO_BUFFER_SIZE));
m_avio_context =
avio_alloc_context(avio_buffer, AVPLAYER_AVIO_BUFFER_SIZE, 0, this,
&AvPlayerFileStreamer::ReadPacket, nullptr, &AvPlayerFileStreamer::Seek);
return true;
}
s32 AvPlayerFileStreamer::ReadPacket(void* opaque, u8* buffer, s32 size) {
const auto self = reinterpret_cast<AvPlayerFileStreamer*>(opaque);
if (self->m_position >= self->m_file_size) {
return AVERROR_EOF;
}
if (self->m_position + size > self->m_file_size) {
size = self->m_file_size - self->m_position;
}
const auto read_offset = self->m_file_replacement.readOffset;
const auto ptr = self->m_file_replacement.object_ptr;
const auto bytes_read = read_offset(ptr, buffer, self->m_position, size);
if (bytes_read == 0 && size != 0) {
return AVERROR_EOF;
}
self->m_position += bytes_read;
return bytes_read;
}
s64 AvPlayerFileStreamer::Seek(void* opaque, s64 offset, int whence) {
const auto self = reinterpret_cast<AvPlayerFileStreamer*>(opaque);
if (whence & AVSEEK_SIZE) {
return self->m_file_size;
}
if (whence == SEEK_CUR) {
self->m_position =
std::min(u64(std::max(s64(0), s64(self->m_position) + offset)), self->m_file_size);
return self->m_position;
} else if (whence == SEEK_SET) {
self->m_position = std::min(u64(std::max(s64(0), offset)), self->m_file_size);
return self->m_position;
} else if (whence == SEEK_END) {
self->m_position =
std::min(u64(std::max(s64(0), s64(self->m_file_size) + offset)), self->m_file_size);
return self->m_position;
}
return -1;
}
} // namespace Libraries::AvPlayer

View File

@ -0,0 +1,39 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "avplayer.h"
#include "avplayer_data_streamer.h"
#include <string_view>
#include <vector>
struct AVIOContext;
namespace Libraries::AvPlayer {
class AvPlayerFileStreamer : public IDataStreamer {
public:
AvPlayerFileStreamer(const SceAvPlayerFileReplacement& file_replacement);
~AvPlayerFileStreamer();
bool Init(std::string_view path) override;
AVIOContext* GetContext() override {
return m_avio_context;
}
private:
static s32 ReadPacket(void* opaque, u8* buffer, s32 size);
static s64 Seek(void* opaque, s64 buffer, int whence);
SceAvPlayerFileReplacement m_file_replacement;
int m_fd = -1;
u64 m_position{};
u64 m_file_size{};
AVIOContext* m_avio_context{};
};
} // namespace Libraries::AvPlayer

Some files were not shown because too many files have changed in this diff Show More