Compare commits

...

1363 Commits

Author SHA1 Message Date
Megamouse 27f6f497a2 use "config/custom_configs/" for custom configs (backwards compatible) 2019-01-31 20:14:52 +00:00
kd-11 09a8f7ae53 vk: Use FIFO mode for vsync
- Avoids tearing and also hides some driver bugs causing fullscreen bugs with mailbox mode
2019-01-31 21:53:02 +03:00
kd-11 3bfa564ef8 vk/windows: Try to keep msq thread from ever stopping
- NVIDIA drivers hook into the msq before our nativeEvent handler. This means NV is aware of events before rpcs3 is aware of them and sometimes stops until a new event is triggered.
  If rpcs3 is inside a driver call at this time, the system will deadlock since the driver waits for msq which waits for the renderer which waits for the driver.
- Use explicit hook management to control window events
- Add fence timeout to attempt detection of surface loss events
2019-01-31 21:53:02 +03:00
msuih 987b607cb0 Add debug console mode to settings 2019-01-31 16:03:38 +03:00
eladash d4a24433e8 Fix DECR mode allocations (sys_memory) 2019-01-31 16:03:38 +03:00
Nekotekina 400718dfd9 cellSaveData: try to handle occasional failures
Retry moving directory on FILE_ACCESS_ERROR
2019-01-31 01:08:30 +03:00
eladash 25aa5f80a6 Fix access violations reporting on RSX
and on other threads that do not have cpu_thread handler
2019-01-30 18:44:29 +03:00
eladash b61492ca30 Dont call std::terminate() after normal access violation handling 2019-01-30 18:44:29 +03:00
eladash 6f770c8e35 Fix potential crash in begin_occlusion_query() while closing the Emu 2019-01-30 18:44:29 +03:00
Nekotekina 039f8e1f9d Update About window
Updated supporters and contributors
2019-01-30 03:11:19 +03:00
Nekotekina f50d9cc136 Initial support for HLE in internal API
atomic_storage<>: add compare_exchange_hle_acq and fetch_add_hle_rel
shared_mutex: add methods (un)lock_hle and (un)lock_shared_hle
Clang: 👅
2019-01-29 04:33:59 +03:00
Nekotekina 58358e85dd spu_runtime::add minor optimization
Use preallocated vectors in trampoline generation subroutine
2019-01-29 03:32:16 +03:00
Nekotekina 2b66abaf10 Implement atomic_t<>::release
More relaxed store with release memory order
2019-01-29 03:32:16 +03:00
Nekotekina 50922faac9 Remove SPUThread::jit_dispatcher
Use global array - save memory
Move the array to JIT memory
2019-01-29 03:32:16 +03:00
Nekotekina 4292997a01 Added jit_runtime class
Is a memory manager for ASMJIT, replaces asmjit::JitRuntime
Unified memory manager for ASMJIT and LLVM
Unified SPU trampoline generation
Remove previous workarounds
2019-01-29 03:32:16 +03:00
max d1f544c755 Add QDoubleSpinBox styling
Updated themes
 - YoRHa by Ani
 - Kuroi (Dark) by Ani
2019-01-28 17:41:24 +00:00
eladash 587fe421ee Make ppu main_thread unjoinable 2019-01-25 18:04:33 +03:00
eladash 56b7581ade Return error code in sys_ppu_thread_get_join_state 2019-01-25 18:04:33 +03:00
kd-11 660bfeabae gl: Fixup - inline arrays 2019-01-25 14:34:22 +03:00
kd-11 fa9b448686 vk: Spec fixups
- Disable DEPTH<->RGBA typeless transfers for now as they require a lot more work to work for all vendors
- Do not allow switching layouts to UNDEFINED/PREINITIALIZED formats
2019-01-25 14:34:22 +03:00
kd-11 2163a59649 rsx: Typo fix 2019-01-25 14:34:22 +03:00
kd-11 521969bcc3 gl: Remove GL_R 'format'. There is no GL_R format, it part of the S-T-Q-R enums for texture coordinate space 2019-01-25 14:34:22 +03:00
kd-11 5a4bea8c4f gl: Blit fixup
- Typo fix. I meant to disable scissor test, not stencil test
- Also clean up and simplify/optimize the core logic
2019-01-25 14:34:22 +03:00
kd-11 7e33cdcb08 rsx: simple_array<T> improvements
- Implement move and copy ctors
2019-01-25 14:34:22 +03:00
kd-11 fb778e4821 rsx: Reimplement attrib divisor 2019-01-25 14:34:22 +03:00
kd-11 736415fcd9 rsx/fp: Detect broken/NOP shaders automatically
- Do not compile body if the shader is of no consequence, leave as a passthrough shader
2019-01-25 14:34:22 +03:00
kd-11 6fdc0fd7f0 rsx: Reimplement MSAA transparency
- Apply dither to edges that almost fail the straight-up alpha test
- Significantly improves alpha tested geometry far from the camera
- Also removes blend factor overrides/hacks as they give incorrect results due to background bleeding
2019-01-25 14:34:22 +03:00
kd-11 10a17feda2 rsx: Avoid potential deadlock in FIFO_ctrl 2019-01-25 14:34:22 +03:00
kd-11 7eec702c6d gl: Fix silly regression with blit dst resource readback 2019-01-25 14:34:22 +03:00
kd-11 8093c9b573 rsx: Disable rtt side-effects when async compilation is ongoing. Only real renders should promote buffer state from underined to drawn, otherwise keep previous contents intact. 2019-01-25 14:34:22 +03:00
kd-11 417a2e6731 rsx: Refactor index buffers
- Index offset is ignored anyway and only used to calculate vertex attribute divisor index
- Specialized optimization for untouched xfer without primitive restart
2019-01-25 14:34:22 +03:00
elad afeacc171f Fix spurious abort in sys_rwlock_tryrlock and sys_semaphore_trywait (#5579)
Use full cmpxchg loop to prevent occasional return of CELL_EBUSY
2019-01-22 23:10:17 +03:00
Nekotekina d5eda98e49 Fix le_t<> compilation error
Use memcpy for copying
2019-01-22 22:02:03 +03:00
Nekotekina 4f152ad126 SPU: multithread compilation
Allow parallel compilation of SPU code, both at startup and runtime
Remove 'SPU Shared Runtime' option (it became obsolete)
Refactor spu_runtime class (now is common for ASMJIT and LLVM)
Implement SPU ubertrampoline generation in raw assembly (LLVM)
Minor improvement of balanced_wait_until<> and balanced_awaken<>
Make JIT MemoryManager2 shared (global)
Fix wrong assertion in cond_variable
2019-01-22 22:02:02 +03:00
Megamouse 8d5d44141e rsx/Qt: fix some undefined behavior in progress_dialog CallAfters 2019-01-22 12:04:01 +03:00
eladash 688d5a9919 rsx: Fix unknown vertex base types
Clamp vertex type field into 3-bits instead of 4-bit value
Case 0 is UB256
2019-01-21 22:28:20 +03:00
Megamouse fa00fb3eac Qt: use patch version and firmware for PS3 disc games in the game list 2019-01-20 23:16:37 +01:00
Nekotekina d4591b1508 ALSA: disable recovery (experimental) 2019-01-18 16:49:17 +03:00
Nekotekina 59e0296281 cellMsgDialog: fix error spam on CELL_OK 2019-01-18 16:49:17 +03:00
Nekotekina cc430769c6 Rollback audio backend priority 2019-01-18 16:49:17 +03:00
eladash a11d76249d Patch ppu main thread prio 2019-01-17 21:58:09 +03:00
Megamouse 5ed718110a cellOskDialog/osk_dialog_frame: fix regexp for CELL_OSKDIALOG_NO_SPACE 2019-01-16 23:36:44 +03:00
msuih f902a7867c Fix cache removal 2019-01-16 07:43:39 +01:00
elad fc92ae4085 SPU/PPU atomics performance and LR event fixes (#5435)
* Fix SPU LR event setting in atomic commands according to hw test
* MFC: increment timestamp for PUT cmd in non-tsx path
* MFC: fix reservation lost test on non-tsx path in regard to the lock bit
* Reservation notification moved out of writer_lock scope to reduce its lifetime
* Use passive_lock/unlock in ppu atomic inctrustions to reduce redundancy
* Lock only once for dma transfers (non-TSX)
* Don't use RDTSC in reservation update logic
* Remove MFC cmd args passing to process_mfc_cmd
* Reorder check_state cpu_flag::memory check for faster unlocking
* Specialization for 128-byte data copy in SPU dma transfers
* Implement memory range locks and isolate PPU and SPU passive lock logic
2019-01-15 18:31:21 +03:00
eladash f19fd23227 spu: Fix support for multiple lists when one is stalled 2019-01-15 02:33:22 +03:00
Megamouse 58a22d1461 cellSaveData: add error_code 2019-01-14 21:12:13 +01:00
Nekotekina c5026f7109 cellVdec: fix minor race 2019-01-14 01:24:05 +03:00
Nekotekina a419e98acb Move PPU and shader cache
New hash-based location (already used for SPU)
Bump PPU cache version, improve naming and decrease size

Remove fs::get_data_dir
Disable boot.elf cache
2019-01-14 01:24:05 +03:00
Nekotekina aefee04c4a SPU analyser: fix branch to self
Fixed not filling the predeccessor list on BR-to-self on entry point
Version bumped (v1-tane)
Closes #5353
2019-01-14 00:01:27 +03:00
Nekotekina 74d684b57e cellAudio: fix template arg style
Add constexpr if
2019-01-14 00:01:27 +03:00
Nekotekina 81c50bad69 lf_queue: implement wait() method
Synchronization does not occupy additional space by reusing LSB
2019-01-13 14:45:36 +03:00
Nekotekina ac775cd75e Simplify gui_listener
Use lf_queue
2019-01-13 14:45:36 +03:00
Nekotekina 3fed4dcc5a Remove lf_mpsc, lf_spsc
Not practical
2019-01-13 14:45:36 +03:00
Nekotekina 435f60d503 lf_queue: add iterator support
Allow range-for loop over an object returned by `pop_all()`
2019-01-13 14:45:36 +03:00
Nekotekina cfdf50dcff SPU: ensure sys_spu_thread_group_join receives correct exit status
Following #5334
2019-01-13 14:45:36 +03:00
Nekotekina 453344c232 cellSaveData: workaround possible issues with symlinks
Don't use ../ location for temporary directories
2019-01-13 14:45:36 +03:00
Nekotekina bd9131ae1c Implement fs::get_cache_dir
Win32: equal to config dir for now
Linux: respect XDG_CACHE_HOME if specified
OSX: possibly incomplete
2019-01-13 14:45:36 +03:00
Nekotekina 20efed66e9 Implement RPCS3_CONFIG_DIR env variable (Win32)
Overrides config location, should end with / or \
2019-01-13 14:45:36 +03:00
eladash bc27f5f75c Implement invalid NV4097_NOTIFY context handling 2019-01-13 12:59:00 +03:00
Megamouse 022550a43b cellOskDialog: use atomic_op for state operations 2019-01-12 23:39:01 +01:00
Megamouse d7cc97433d cellOskDialogUnloadAsync: guarantee 0 terminated return string 2019-01-12 23:39:01 +01:00
Megamouse fce9f352a9 cellOskDialog: fix cellOskDialogAbort 2019-01-12 23:39:01 +01:00
Megamouse f9c1b15bf4 cellOskDialog: fix cellOskDialogUnloadAsync return string
fixes Class of Heroes 2G
2019-01-12 23:39:01 +01:00
Rui Pinheiro 3406acd8c9 Fixups for audio PR 2019-01-12 22:22:03 +03:00
Rui Pinheiro 49fbf9bf0f Tweaks to buffering algorithm
Increase untouched buffer timeout when some of the buffers have been
touched. Might improve audio quality on games that suffered from
miniscule popping even when buffering was enabled (such as DeS).

In addition, made time stretching algorithm slightly more aggressive.

Includes some other tiny tweaks as well.
2019-01-12 21:29:56 +03:00
Rui Pinheiro 1e4513e2e3 Fixups in audio backend
Removes 's_' prefix from variables that are no longer static and
thread_local. Removes superfluous comments left behind due to copy-paste
mistakes.
2019-01-12 21:29:56 +03:00
Rui Pinheiro fe9062671e Change audio tooltips, audio backend order 2019-01-12 21:29:56 +03:00
Megamouse 5e3311746c Qt/settings: add new audio buffering options 2019-01-12 21:29:56 +03:00
Rui Pinheiro 48db0430d4 Misc. Tweaks 2019-01-12 21:29:56 +03:00
Rui Pinheiro 650bc0c1f2 Fix game pausing/unpausing 2019-01-12 21:29:56 +03:00
Rui Pinheiro f17f984721 Add timeout for untouched buffers 2019-01-12 21:29:56 +03:00
Rui Pinheiro 8f6043b568 Change cellAudio diagnostic messages to Trace 2019-01-12 21:29:56 +03:00
Rui Pinheiro 67f9397746 Various fixes
In addition, linux builds (and ALSA/PA) now work again
2019-01-12 21:29:56 +03:00
Rui Pinheiro 4f39457858 Rewrite OpenAL backend to support new features 2019-01-12 21:29:56 +03:00
Rui Pinheiro f90646ec88 Update OpenAL to 1.19.1 2019-01-12 21:29:56 +03:00
Rui Pinheiro 892deb1552 Implement basic time stretching + Tweaks 2019-01-12 21:29:56 +03:00
Rui Pinheiro 5159d3559e Implement Audio Backend Capabilities querying
Also renames "AudioThread" to "AudioBackend". The new name is more
descriptive of what the class really is responsible for, since the
backends are not responsible for managing the audio thread.

NOTE: Right now only XAudio2 is supported
2019-01-12 21:29:56 +03:00
Rui Pinheiro 2addbe6be2 Implement basic cellAudio buffering 2019-01-12 21:29:56 +03:00
Rui Pinheiro 56962aa707 Disable OpenAL backend temporarily 2019-01-12 21:29:56 +03:00
Megamouse e18e9909af cellOsk fixup 2019-01-12 08:26:04 +01:00
RipleyTom fad80ed443 revert part of #5529 2019-01-12 06:59:07 +01:00
Megamouse e3ea29599d cellGame: fix some installation issues
fixes HAWX2 (at least until it crashes again)
2019-01-11 03:36:22 +03:00
Megamouse d9d5f45e9e rsx/input: fix rsx replay 2019-01-10 13:05:48 +01:00
Megamouse eb4d612bb9 cellOskDialog: fixes for multi-line dialog 2019-01-10 13:05:48 +01:00
Megamouse e5aede7aa7 cellOskDialog: initial code for cellOskDialogSetSeparateWindowOption 2019-01-10 13:05:48 +01:00
Megamouse 17058113df cellOskDialog: add multi-line option and handle more permutations (WIP) 2019-01-10 13:05:48 +01:00
Megamouse 4a8b30c625 cellOskDialog: cellOskDialogExtRegisterConfirmWordFilterCallback 2019-01-10 13:05:48 +01:00
Megamouse e0ac244fed split MsgDialogBase 2019-01-10 13:05:48 +01:00
Megamouse d5303b0b64 add error_code to cellOskDialog and cellMsgDialog 2019-01-10 13:05:48 +01:00
Megamouse 7cc4239cc2 cellOskDialog: add message 2019-01-10 13:05:48 +01:00
Megamouse cc30b4e5be cellOskDialog: don't send input signals without seperate screen enabled 2019-01-10 13:05:48 +01:00
Megamouse 16f2975792 cellOskDialog: properly handle dialog states to improve param checks 2019-01-10 13:05:48 +01:00
Megamouse 1b2e512179 Qt: make dockwidget title bars optional 2019-01-10 12:14:38 +01:00
Megamouse 0236b994e4 fix travis 2019-01-10 11:32:05 +01:00
Ani d7cd280827 Update Readme
Add Qt5Qml dependency for Arch
Solves #5518
2019-01-09 00:48:56 +00:00
kd-11 52ac0a901a rsx: improve memory coherency
- Avoid tagging and rely on read/write barriers and the dirty flag mechanism. Testing is done with a weak 8-byte memory test
- Introducing new data when tagging breaks applications with race conditions where tags can overwrite flushed data
2019-01-06 10:44:40 +03:00
kd-11 89c9c54743 rsx: Minor hot-fix
- Pitch 0 makes sense if width == 1 and height == 1
2019-01-06 10:44:40 +03:00
kd-11 95245bdd83 rsx: Improve ARGB8->D24S8 casting
- Set up partial transfers
- Force clear of target before starting the transfer
2019-01-06 10:44:40 +03:00
kd-11 475cc99117 rsx: Fix dirty flag reset after a partial attachment initialization
- D24S8 targets have 2 aspects that are dealt with separately; Forcefully initialize the remaining data if a partial init is done. Its 'free' anyway
- It seems that the stencil mask matters when clearing unlike the depth mask and color mask
2019-01-06 10:44:40 +03:00
kd-11 c80c7f06bb rsx: Typo fix
- This silly typo broke the flip improvements in the GT fixes PR
2019-01-06 10:44:40 +03:00
kd-11 2a62fa892b rsx: Texture cache refactor
- gl: Include an execution state wrapper to ensure state changes are consistent. Also removes a lot of required 'cleanup' for helper methods
- texture_cache: Make execition context a mandatory field as it is required for all operations. Also removes a lot of situations where duplicate argument is added in for both fixed and vararg fields
- Explicit read/write barrier for framebuffer resources depending on
  usage. Allows for operations like optional memory initialization before
  reading
2019-01-06 10:44:40 +03:00
kd-11 0f64583c7a rsx: Reimplement pitch lookup
- Remove the required_xxx_pitch constraint as it makes no sense. The pitch controls what can be written per line.
- It is possible to have a huge surface width but only render to a small region at the beginning and have a smaller pitch than can fit the surface (NFS carbon)
2019-01-06 10:44:40 +03:00
kd-11 1ffadbe086 rsx: Reorganize write barrier implementation (either clear or memory barrier) 2019-01-06 10:44:40 +03:00
kd-11 9c45ce6d37 vk: Reimplement typeless memory allocation to handle resolution upscaling 2019-01-06 10:44:40 +03:00
kd-11 d8e45c86e6 vk: Remove old useless hack that interferes with memory inheritance 2019-01-06 10:44:40 +03:00
kd-11 3be4b474d9 rsx: Handle rsx-self-tripping in draw call and triggering invalid invalidation
- If draw call resources consume memory that intersects with NA parts of the texture cache, we get a framebuffer test mismatch.
  This mismatch is false and happens because the thread has not yet reached the point of relocking the pages
2019-01-06 10:44:40 +03:00
kd-11 a95a44cf66 rsx: Strictness cleanups
- Also account for variable pitch textures (swizzled scan)
2019-01-06 10:44:40 +03:00
kd-11 474d0f61a2 minor typo fix 2019-01-06 10:44:40 +03:00
kd-11 362eea09a1 whitespace fix only 2019-01-06 10:44:40 +03:00
kd-11 15d5507154 rsx: Rewrite memory inheritance transfers
- Implicitly invoke a memory barrier if actively reading from an unsynchronized texture
- Simplify memory transfer operations
- Should allow more games to work without strict mode
2019-01-06 10:44:40 +03:00
kd-11 97704d1396 rsx: Fix texture size calculations 2019-01-06 10:44:40 +03:00
kd-11 50c07833e4 rsx: Do not force upload for missing data
- TODO: Finish implementing GPU RCB for mem-sync
- TODO: Refactor mem-sync
2019-01-06 10:44:40 +03:00
kd-11 6d932b042b vk: bump max number of compute jobs from 120 to 1024
- It is possible without bugs to have a very high number of compute invocations.
2019-01-06 10:44:40 +03:00
kd-11 64a8829614 rsx: Minor cleanup 2019-01-06 10:44:40 +03:00
kd-11 15488eb247 rsx: Avoid unnecessarily touching framebuffer memory
- Do not bind companion framebuffer when clearing single aspect; let the
  contest mechanism sort it out instead
- Do not prematurely tag framebuffers, instead only do so at
  write-confirmation time. Should avoid false tagging if setup does not
  allow a render to occur.
2019-01-06 10:44:40 +03:00
kd-11 a13986ec5c vk: Spec fixups
- Forgot to update descriptor pool init sizes over time
- Also clamp swapchain resources to allowable surface extents
2019-01-05 21:31:12 +03:00
Megamouse 6c10cb2eb5 Assume go to address to be hexadecimal 2019-01-05 04:03:18 +01:00
Megamouse 6fe615605a prevent debugger crash when no thread is selected 2019-01-05 04:03:18 +01:00
Megamouse bb464b0b64 fix some warnings 2019-01-05 04:03:18 +01:00
Megamouse daee2a27a3 Qt: spawn Confirmation Dialog on when booting games while Emu is running 2019-01-05 01:50:42 +01:00
Megamouse 5f9b441dd7 Qt: spawn Confirmation Dialog on exit 2019-01-05 01:50:42 +01:00
RipleyTom 37c621ebbf cellSysutilCheckCallback forced granularity 2019-01-03 02:15:01 +03:00
Nekotekina 7a4282b4c0 cellSysutil: drain callback queue at single step
This way if a new callback is registered in a process,
it will not be executed immediately in the same loop.
Remove mutex, use lock-free queue.
2019-01-03 02:15:01 +03:00
Megamouse 3b83e223d8 cellOskDialog: add some param checks 2019-01-02 15:45:51 +01:00
Megamouse 0e7fd45504 cellOskDialog: add Constants 2019-01-02 15:45:51 +01:00
Megamouse ad5cdc38cd cellOskDialog: implement CellOskDialogInputFieldResult
fixes abort and cancel
2019-01-02 15:45:51 +01:00
Megamouse 6f7b25de90 implement CELL_PAD_INFO_INTERCEPTED 2019-01-02 15:45:51 +01:00
Megamouse 8ad14c4ada Overlays: fix input loop when no controllers are detected 2019-01-02 15:45:51 +01:00
Megamouse a4f67ccb87 Add log messages for PPU compilation 2018-12-31 23:03:03 +03:00
Zion Nimchuk 17d413c110 Deploy linux binaries to RPCS3/rpcs3-binaries-linux via GitHub Releases 2018-12-31 20:06:17 +03:00
Zion Nimchuk 54d41f6805 Migrate to seperate file for environmental variables 2018-12-31 20:06:17 +03:00
Megamouse 632b0f489c Qt/Input: add keyboard stick interpolation 2018-12-31 12:42:34 +01:00
Megamouse a77bd41b50 Qt/Input: add mouse settings to the pad settings dialog 2018-12-31 12:42:34 +01:00
Megamouse 2db16c2c04 Input: add config entries for mouse deadzones and acceleration 2018-12-31 12:42:34 +01:00
RipleyTom 7ebd3bbcbf Fixes issues where the mutex is destroyed while an unlock is happening 2018-12-31 01:39:47 +03:00
eladash 483ee5e488 Fix sys_vm_memory_map address base 2018-12-30 20:12:32 +00:00
eladash 79a6a2c7fb Debug console emulation 2018-12-30 20:12:32 +00:00
eladash 2ea061b9c7 Set total memory size according to sdkver 2018-12-30 20:12:32 +00:00
eladash c0eb4965f2 mmapper_allocate_memory improvement
Added cases 0 for allocation granularity size,
alike sys_memory_allocate, the alignment of this case is 1mb.
2018-12-30 20:12:32 +00:00
JohnHolmesII be75a564ca Fix builds with musl c 2018-12-30 21:31:06 +03:00
Megamouse d1be1150c2 Settings Dialog Update 2018-12-30 17:47:51 +01:00
RipleyTom c6e47a573d cellVideoOutConfigure minor fix. 2018-12-30 17:58:20 +03:00
eladash db784556aa rsx: Evaluate cond render test at set_render_enabled 2018-12-30 15:04:59 +01:00
eladash 26d47afec6 hle gcm: Fix cellGcmGetReportDataAddressLocation
* Never return NULL (also apllies to similar functions)
* Base offset is 0x0e000000 for main location
* Default location is LOCAL

Info was taken from disasm of gcm
2018-12-30 15:04:59 +01:00
eladash 568206d11a Fix rsx capture (again) 2018-12-30 15:04:59 +01:00
Megamouse a1dd6e080c Qt: Sort game list after load settings to prevent icon size mismatch
This was sorely needed when the app crashed after resizing icons
2018-12-30 14:15:34 +01:00
fobb2 64ea7bf867 capitalize 'japanese' -> 'Japanese' 2018-12-30 05:08:43 +01:00
Jan Beich 8d308bb4c0 overlays: don't use /proc on BSDs as it may not be mounted 2018-12-29 18:07:45 +03:00
Jan Beich 33f7a39f5d fs: implement copy_file() fallback
sendfile(2) on DragonFly and FreeBSD can only write into sockets.
2018-12-29 18:07:45 +03:00
Megamouse cfe0709867 Qt: fix game grid font for unfocused tiles 2018-12-28 17:10:30 +01:00
RipleyTom aa306dd356 Trophy changes 2018-12-27 19:11:51 +01:00
eladash 4b65c3943c Fix sys_semaphore_post count check 2018-12-26 23:03:27 +03:00
eladash 653a4ef0df Set group status INIT on last thread stopped
this fixes the group status after sys_spu_thread_exit when not joining the spu group
2018-12-25 19:59:41 +03:00
scribam 7c74bafaf3 sceNp: improve sceNpManagerGetNetworkTime function (#5451) 2018-12-25 17:13:11 +03:00
msuih dbd4814584 Disable thread assignment for Intel 2018-12-24 19:33:08 +00:00
msuih 1dd3a4b3f0 Detect hyperthreading on Windows 2018-12-24 19:33:08 +00:00
Nekotekina d7be0a96f3 SPU LLVM: approximate xfloat option
Adapt previous SPU ASMJIT changes made by @kd-11
FM, FMA, FNMS, FMS are approximated.
FCGT, FCMGT are accurate.
2018-12-24 16:04:46 +03:00
Nekotekina f750b4c420 cellSaveData: try to address #5415 2018-12-24 16:04:46 +03:00
Nekotekina 522f5ea645 Fix cellFsGetFreeSize (following #5304)
Simplify device name extraction
2018-12-24 16:04:46 +03:00
kd-11 9c46386dd4 rsx: Check av configuration when selecting display buffers!
- Some applications have mismatch between video output configuration and display buffer sizes
2018-12-24 09:05:19 +03:00
kd-11 7555be232f rsx/vp: Fix double dst commands
- Test the vec_result mask before assigning to actual output
  Sometimes, VEC op is used to write to Rx, and SCA op is used to write to o[x]!
2018-12-24 09:05:19 +03:00
kd-11 10d96a60f1 rsx/capture: Force flip if no flip event was recorded 2018-12-24 09:05:19 +03:00
kd-11 f48abde14b rsx: Fixups for immediate rendering mode
- Immediate mode is isolated from the rest of the vertex configuration
- TODO: Verify register behaviour when immediate mode is used
  Check if per-primitive const register values are supported (likely are)
2018-12-24 09:05:19 +03:00
kd-11 4b79ef1ad9 rsx: Implement stencil mirror views
- Implements a mirror view of D24S8 data that accesses the stencil components.
  Finishes the implementation of TEX2D_DEPTH_RGBA as the stencil component was previously missing from the reconstructed data
- Add a few missing destructors
  Image classes are inherited a lot and I forgot to make the dtors virtual
2018-12-24 09:05:19 +03:00
kd-11 696b91cb9b rsx: Reimplement conditional execution in shaders
- Per-channel conditional execution introduces RAW hazards all over the place
- Its cheaper to process both branches and select between the two
- Also improves ShaderVariable functionality to allow functionality such as match_size and taking complex variables as inputs
2018-12-24 09:05:19 +03:00
kd-11 c75749f8ce rsx: fix flip logic when grabbing output from the surface cache 2018-12-24 09:05:19 +03:00
Ani 25b8a42519 Merge pull request #5445 from hcorion/stdc++-auto-checker
Remove distro whitelist and use the new automated stdc++ checker
2018-12-23 23:47:09 +00:00
Ani fc25df84f8 Merge branch 'master' into stdc++-auto-checker 2018-12-23 21:49:57 +00:00
MSuih eba364c64c Clear disk cache if it grows too large (dev_hdd1/cache) (#5411)
* Clear disk cache automatically

* Add disk cache to UI
2018-12-24 00:18:47 +03:00
Megamouse b99a88afe2 Qt/Input: disable in-game controls while the pad settings are opened 2018-12-23 04:13:27 +01:00
Megamouse e80f2793eb Qt/Input: immediately abort remapping if the controller was disconnected
added some fixups
2018-12-23 04:13:27 +01:00
Megamouse 6dcf66b064 Qt/Input: add disconnected label to the devicenames 2018-12-23 04:13:27 +01:00
Megamouse bdb5606317 Qt/Input: enable DS4 controller reconnect without refresh 2018-12-23 04:13:27 +01:00
Megamouse 6e323622a5 Qt/Input: use 1-n in the GUI instead of 1-(n-1)
I didn't look into evdev
2018-12-23 04:13:27 +01:00
Megamouse 91d834ce73 Qt/Input: improve DS4 device list
Needed to move Reset out to main_window due to hid closing problems. It's better to have the reset logic outside anyway
2018-12-23 04:13:27 +01:00
Megamouse f617e47152 Qt/Input: disable mapping for unconnected pads 2018-12-23 04:13:27 +01:00
Megamouse e80574cbd2 RSX/Qt: set min gs_frame size to 160x90 to prevent stupid new Vulkan bug 2018-12-22 23:10:34 +01:00
Megamouse 79003cd089 Qt/windows: use Qt's high dpi scaling 2018-12-22 23:10:34 +01:00
isshininu 9717e19be2 sceNpTrophy: use SCE_NP_TROPHY_STATUS_INSTALLED instead of SCE_NP_TROPHY_STATUS_NOT_INSTALLED
* Update sceNpTrophy.cpp

* Revert "Update sceNpTrophy.cpp"

* Update sceNpTrophy.cpp

* Update sceNpTrophy.cpp
2018-12-22 13:53:38 +01:00
Zion Nimchuk c775e5fb97 Remove distro whitelist and use the new automated stdc++ checker 2018-12-21 13:02:27 -08:00
Zion Nimchuk b5cbe02f4d Add CMake switch for disabling Discord Rich Presence and fix no llvm build 2018-12-20 11:29:35 +01:00
JohnHolmesII d643dcb43b Rewrite readme 2018-12-20 10:40:47 +01:00
eladash 69fc1f2613 Added CAMERA_NOT_INIT checks for no camera setting 2018-12-20 08:52:09 +01:00
Megamouse 6b1d80ec25 cellCamera: fix read_mode 2018-12-20 08:02:44 +01:00
Hrkrx ae85c40a0a added libevdev-dev as requirement for Debian & Ubuntu 2018-12-18 12:39:40 +03:00
Megamouse bc3ab7a9d9 Input: Enable In-Game Pad Config Reset 2018-12-17 19:41:18 +01:00
vit9696 5a40c1802b Support macOS bundling for binary distribution 2018-12-16 18:17:21 +03:00
eladash c50d459b1e cleanup rsx fifo debugger command display 2018-12-15 19:40:18 +03:00
eladash 098d634328 rsx fifo: Fix call cmd offset mask
highest 3 bits are masked according to tests, also filter certainly invalid jumps with offset higher than max
2018-12-15 19:40:18 +03:00
eladash c2aa10cccd reduce register_pair container 2018-12-15 19:40:18 +03:00
eladash 45ed58cdaf Fix rsx capture replay
Allow to capture non-increment cmd flag that was missing in command.reg
2018-12-15 19:40:18 +03:00
eladash 87988e9da8 rsx fifo: Stability improvements
* Restore stack in fifo error handling

* Update get register after the cmd execution

* Fix put pause in the middle of command

* Add restore points when branching to self

* Precise nopcmd detection

* Test all invalid cmds for early treatment of queue corruption
2018-12-15 19:40:18 +03:00
eladash 835a552d8d rsx: Implement cellGcmSetNotify 2018-12-15 19:40:18 +03:00
eladash fd894d4c69 hle gcm: Fix cellGcmGetNotifyDataAddress 2018-12-15 19:40:18 +03:00
eladash 415b995a54 log rsx get ctrl 2018-12-15 19:40:18 +03:00
eladash 8cbaa8627c Do not rely on cellPadInit in native ui 2018-12-15 13:51:16 +01:00
Megamouse 2e7e2bb07e XInput: fix usage of one controller for 2 players 2018-12-15 13:13:26 +01:00
msuih 76f94940cd Add strict texture flushing to debug options 2018-12-11 22:37:10 +03:00
Rui Pinheiro 54bfe2e102 Add log warning on slow flush path 2018-12-11 22:37:10 +03:00
Rui Pinheiro 18b9ee4541 Reimplement overlapping fbo "hack"
To avoid the need (and performance hit) of Read Color/Depth Buffers, we
may not invalidate overlapping fbos inside lock_memory_region unless
they are guaranteed to be superseded by the new one.

This avoids e.g. issues with overblooming, among others.
2018-12-11 22:37:10 +03:00
Rui Pinheiro 5ab7296665 Fix xcode build 2018-12-11 22:37:10 +03:00
Rui Pinheiro bcdf91edbb Misc. Texture Cache fixes 2018-12-11 22:37:10 +03:00
Rui Pinheiro 9d1cdccb1a Implement dedicated texture cache predictor 2018-12-11 22:37:10 +03:00
Rui Pinheiro af360b78f2 Texture cache section management fixups
Fixes VRAM leaks and incorrect destruction of resources, which could
lead to drivers crashes.

Additionally, lock_memory_region is now able to flush superseded
sections. However, due to the potential performance impact of this
for little gain, a new debug setting ("Strict Flushing") has been
added to config.yaml
2018-12-11 22:37:10 +03:00
Megamouse 1ca02c7d17 Qt: implement custom titles 2018-12-10 18:50:23 +01:00
Megamouse ead03caedc Qt: Fix silly edit bug that no one ever noticed 2018-12-10 18:50:23 +01:00
RipleyTom 077e710e3a sys_fs_fcntl with parameter 0xC0000002 should extract device path from the given path and use that to gather free space information 2018-12-10 14:24:07 +03:00
Nekotekina d6afba96f1 cellSaveData: fix 'Already exists' error 2018-12-10 01:43:47 +03:00
Nekotekina d98420fbc3 CMake: use CMAKE_SOURCE_DIR instead of .. in some places 2018-12-10 01:43:47 +03:00
eladash fb8302817f ppu: Set link unconditionally 2018-12-10 01:34:02 +03:00
RipleyTom 5207b00973 Extra Handling of result value of funcStat CB. 2018-12-08 18:44:00 +03:00
Nekotekina 92be67b402 Fix #5370 regression 2018-12-05 00:06:09 +03:00
Nekotekina 476090a747 Detach VBlank and RSX Decompiler threads
Should fix exception handling in RSX Thread
2018-12-04 23:41:54 +03:00
elad 90265edfcd SPU MFC: avoid copying of the lockline onto the stack in putllc/putlluc (#5392) 2018-12-04 21:09:55 +03:00
eladash 45942c4962 Fix segfault when scaled image dimension is less than clip's 2018-12-04 13:01:29 +03:00
eladash fa5652fceb rsx image_in: Implement negative scaling 2018-12-04 13:01:29 +03:00
eladash ce500c75c4 throw exceptions in case of invalid/unknown operations in image_in 2018-12-04 13:01:29 +03:00
eladash 6ecf2fb3d0 rsx: default lv2 semaphore context + dma_4097
extracted from vsh
2018-12-04 13:01:29 +03:00
eladash 28e4a9e0d0 rsx image_in: Fix in_pitch 0
The hw doesnt fix pitch, when specifying src pitch 0 it copies the same pixels line to dst. keep in mind out_pitch = 0 is not allowed in image_in.
Same goes for buffer_notify, though it allows out_pitch to be 0.
2018-12-04 13:01:29 +03:00
eladash d1d3ac984e rsx image_in: Fix src size calculation when in_pitch != line_lengh 2018-12-04 13:01:29 +03:00
eladash 0a1da14a15 rsx image_in: remove clip h and w hack
If clip region is empty, dont execute
2018-12-04 13:01:29 +03:00
eladash 4ddafc481e remove unreachable code 2018-12-04 13:01:29 +03:00
eladash b48a4b6459 rsx-capture: reduce capture size
* Dont bother capturing 'destination' blocks with no data. instead premap all main memory to ensure allocated
* Capture zcull and tile state as their compressed gcm forms
* Fix index array capturing, ignore empty sets
* hle gcm: Fix byteswaping in cellGcmSetZcull
2018-12-04 13:01:29 +03:00
NicknineTheEagle 32059bfaa2 Properly get PARAM.SFO and icons for C00 games (#5370)
* Added a helper function for fetching game's PARAM.SFO path

This should properly get SFO path for unlocked C00 games

* Normalized line endings

* Refresh game list after installing a RAP file
2018-12-04 01:46:01 +03:00
Megamouse afdf0b74a0 VS: filter for trophy_manager_dialog.h 2018-12-03 22:37:31 +01:00
Megamouse 87be1abb9a Qt: fix play icon default tooltip 2018-12-03 22:37:31 +01:00
U-GUILLAUME-LAPTO\rameg 6f086fd5af Added ignore = dirty to all submodules to make git operations faster 2018-12-03 22:20:42 +03:00
kd-11 a56ba737b5 vk: Silence log spam 2018-12-03 20:01:23 +03:00
kd-11 504ab5a6d4 rsx: Minor cleanup to silence stupid compiler warnings 2018-12-03 20:01:23 +03:00
kd-11 f4c28eceef rsx: Fix null renderer 2018-12-03 20:01:23 +03:00
kd-11 9d0042f509 rsx: Fixup for the flattener
- Reset the flattener before use
- Better detection of FIFO misalignment
2018-12-03 20:01:23 +03:00
scribam 24a8d0aeef sceNp: add SCE_NP_ERROR_ID_NOT_FOUND for sceNpBasic*Entry* functions 2018-12-03 15:26:29 +03:00
RipleyTom 7f3eaed435 Fullscreen fix 2018-12-03 14:16:47 +03:00
Michał Janiszewski 1001831c8e Update hidapi to address mingw compilation issues
Includes https://github.com/RPCS3/hidapi/pull/5 to fix
https://github.com/RPCS3/rpcs3/issues/5375
2018-12-02 23:59:41 +03:00
RipleyTom 25414953e0 Fixes maximize window to properly update the render surface in Vulkan 2018-12-01 22:20:59 +03:00
msuih 8afc035aac Category filter for PS1/PS2/PSP games 2018-12-01 16:56:56 +01:00
Michał Janiszewski 62c9920f2e Improve path to discord-rpc with non-MSVC
The path is set in https://github.com/RPCS3/rpcs3/blob/96cabeadff0c5a2052137a94f81c88912bcd5d44/3rdparty/CMakeLists.txt#L159
2018-12-01 14:17:19 +03:00
kd-11 ec768afbd9 rsx: Flip workarounds for applications that flip via syscall
- Do not assume flip marks end-of-frame if executed via syscall
- Also disables skip_frame for these applications as there is no frame boundary
- NOTE: QUEUE_HEAD cannot be relied on as it is seemingly possible to flip the same head and not need to queue it
2018-11-30 23:51:25 +03:00
kd-11 2168159d03 gl: Fix flip regression
- Restore graphics state after flip (including active fbo) because flip can be made through a syscall
2018-11-30 23:51:25 +03:00
kd-11 b96ed5cd4e gl: Do not rely on driver statistics for s3TC textures; they are inconsistent. 2018-11-30 23:51:25 +03:00
kd-11 f1c3b46d60 rsx: Fixup - undo vertex cache 'improvements' 2018-11-30 23:51:25 +03:00
kd-11 5b6e1420f3 rsx: Pipeline barriers fixed up
- Ensure barriers are invoked even if no draw occurs!
-- Ensures that deferred commands are executed eventually
2018-11-30 23:51:25 +03:00
kd-11 8a186bb97e rsx: Fix insertion of execution barriers
- Ignore barriers inserted after BEGIN but before any draw commands are emitted
- Properly process tail barriers inserted before END but after draw commands are submitted
- Ignore execution barriers with no effect (same register value written)
2018-11-30 23:51:25 +03:00
kd-11 1d19f71a46 rsx: Re-enable fifo error reset 2018-11-30 23:51:25 +03:00
kd-11 718a04c84f fixup: Clear disabled attrib entries 2018-11-30 23:51:25 +03:00
kd-11 833c25894f [WIP] rsx: Rebase cleanup 2018-11-30 23:51:25 +03:00
kd-11 5193c99973 rsx: Enable dynamic FIFO preprocessing
- Tries to detect when FIFO preprocessing is beneficial and only enables optimizations if the benefit outweighs the cost
- Current threshold is at least 500 draw calls saved at over 2000 draw calls to justify the overhead
- TODO: More tuning for other CPUs
2018-11-30 23:51:25 +03:00
kd-11 7b065d7781 rsx: Fixup; input attributes blob decoding
- Use an unstructured blob and index into the vec4 structures to extract the real data
2018-11-30 23:51:25 +03:00
kd-11 846daadd5d rsx: Fixups
- Improve vertex attribute layout format. Allows for full 16-bit attribute divisor
- Use actual pitch when declaring framebuffer rsx pitch instead of register value in case of swizzle? rendering
2018-11-30 23:51:25 +03:00
kd-11 2e32777375 rsx: Scrap the prebuffered queue approach
- Basically starting over
- The cost of making command copies into the queue has a measurable impact
2018-11-30 23:51:25 +03:00
kd-11 9deecd506a fixup: It is possible for NOP commands to contain other garbage 2018-11-30 23:51:25 +03:00
kd-11 26a56ef1f1 vk: Spec compliance.
- TODO: Implement push_constants path instead of copy + bind descriptor sets
2018-11-30 23:51:25 +03:00
kd-11 d6b4440ef9 gl: Separate vertex env from program env 2018-11-30 23:51:25 +03:00
kd-11 435afcb865 rsx: Fix fifo draw barriers 2018-11-30 23:51:25 +03:00
kd-11 2d88e41583 rsx: Fix some checks when using inlined array rendering 2018-11-30 23:51:25 +03:00
kd-11 54ec363e88 rsx: Critical pipeline fixes
- Fix scissor and viewport binding behavior
- Fixes recovery if empty scissor is specified and then 'fixed' later
- Optimizes state binding a bit
2018-11-30 23:51:25 +03:00
kd-11 1ad76ad331 rsx: Restructure programs
- Also re-enable pipeline optimizations
2018-11-30 23:51:25 +03:00
kd-11 b0a6b72ce8 rsx: Optimizations
- Replace a few more vectors with simple_array<T>
- Avoid unnecessary string comparisons in backends. We already know referenced textures from the program analysers!
2018-11-30 23:51:25 +03:00
kd-11 677b16f5c6 rsx: Fixups
- Also fix visual corruption when using disjoint indexed draws

- Refactor draw call emit again (vk)

- Improve execution barrier resolve
  - Allow vertex/index rebase inside begin/end pair
  - Add ALPHA_TEST to list of excluded methods [TODO: defer raster state]

- gl bringup

- Simplify
  - using the simple_array gets back a few more fps :)
2018-11-30 23:51:25 +03:00
kd-11 e01d2f08c9 rsx: Refactor FIFO
- Removes fifo structures from common RSXThread
- Sets up a dedicated FIFO controller
- Allows for configurable queue optimizations
2018-11-30 23:51:25 +03:00
Nekotekina 96cabeadff Rewrite condition variables
Implement helper functions balanced_wait_until and balanced_awaken
They include new path for Windows 8.1+ (WaitOnAddress)

shared_mutex, cond_variable, cond_one, cond_x16 modified to use it
Added helper function utils::popcnt16
Replace most semaphore<> with shared_mutex
2018-11-29 01:30:05 +03:00
Nekotekina f442a8a84c SPU TG: add thread group stop counter
Fix possible race condition introduced by waiting on `running` value
2018-11-27 23:37:26 +03:00
Nekotekina febe4d4a10 Implement class cond_x16
Use as reservation notifier
Limited to 16 threads but allows more precise control of contention
2018-11-26 00:23:29 +03:00
Nekotekina 7f1cbb1136 Fix 16 bit audio mode
Pointed by @ruipin, some backends may be affected
Reuse float buffer for conversion result
2018-11-24 02:55:29 +03:00
eladash 4baa159523 cellFsOpen flag fix 2018-11-24 02:54:48 +03:00
Megamouse 0526bfd7de Support trophy manager moc'ing in vcxproj 2018-11-23 20:29:43 +01:00
msuih bf0e6ca174 Load trophies in another thread 2018-11-23 20:29:43 +01:00
kd-11 f505ac7b63 qt/gs_frame: Hotfix
- Dynamically check the loaded QT library version in case of mismatch
- Fixes using 5.11.1 builds with non-buggy libraries and vice versa
2018-11-22 10:21:13 +03:00
eladash 3c7f02d99d Fix libcamera regression 2018-11-19 19:05:39 +03:00
vit9696 634a5fa31c Fix macOS compilation 2018-11-19 14:39:33 +03:00
Nekotekina 65ca934452 cellSaveData: fix truncation size (regression) 2018-11-17 14:40:11 +03:00
Nekotekina 12ceceff19 cellSaveData: restore atime/mtime for unmodified files 2018-11-17 14:40:11 +03:00
Nekotekina 1fdd013e4b fs: normalize atime (ensure atime >= mtime) 2018-11-17 14:40:11 +03:00
Nekotekina c719ae360d fs: disable ctime (return mtime instead) 2018-11-17 14:40:11 +03:00
isJuhn 225310e04b Add null alloc_addr checks to sys_memory_allocate and sys_memory_allocate_from_container 2018-11-16 18:37:07 +00:00
RipleyTom f4fb5200a0 cellVdecGetPicture accurate error checking 2018-11-15 20:06:49 +03:00
Nekotekina 0044eb44e2 Cleanup after #5310 (SPU thread groups)
Move lambda into a cpu_stop()
Use running thread counter to synchronize with sys_spu_thread_group_join()
Use SPU_STATUS_STOPPED_BY_STOP exclusively for sys_spu_thread_exit() as before
Remove unnecessary waiting in sys_spu_thread_group_exit()
Rollback some minor unnecessary changes
Use shared_mutex in SPU TG
2018-11-14 12:50:24 +03:00
RipleyTom 0e0a82e536 Ensures threads are stopped in join 2018-11-13 10:19:28 +03:00
eladash 2e1aec4de8 Implement sys_spu_thread_tryreceive_event 2018-11-12 21:12:33 +03:00
RipleyTom fada8b6594 Increases stack allocation for callbacks. 2018-11-12 15:09:26 +03:00
eladash 57b7892de6 Fix typo in sys_fs_mkdir
create_path is a less resticted version of create_dir, it doesnt check for EEXIST for one.
2018-11-12 13:28:58 +03:00
eladash 37b6afaf2c rsx: inlined array stride fix 2018-11-11 23:17:07 +03:00
RipleyTom 986bb24326 Extra check when opening pup file 2018-11-10 12:41:47 +03:00
Nekotekina 7180c1f2d0 typemap: make use of volatile qualifier
Use shared lock for volatile pointers
Use no lock for const volatile pointers
2018-11-09 16:19:59 +03:00
Nekotekina 6a30d5a6c1 shared_mutex: increase max_readers to 16383
Standard requires at least 10000 for SharedMutex concept
2018-11-09 16:19:59 +03:00
Nekotekina 2fd384ae95 SPU LLVM: check state in every callable chunk
It's often redundant but may be necessary
2018-11-09 16:19:59 +03:00
Nekotekina c17a98030a qt: Add supporters 2018-11-09 16:19:59 +03:00
eladash 90f816595a Fix cellPadGetData
* Remove complete buffer clear
* If pressure sensitivity option is not specified, write zeroes (should this be handled from our actual controller handler?)
* Check sensor setting before reporting changes
2018-11-07 15:46:51 +03:00
eladash 3332a10052 ppu: Fix threads scheduler
*Set priority under a lock
*Fix yield command making threads going out of scheduler control by removing it from the queue (not a bug that affects compatibility)
2018-11-07 13:06:29 +03:00
eladash 3fd17e43a3 lv2: Fix lwcond_queue_wait lock acquiring 2018-11-07 13:06:29 +03:00
eladash 3faaf9e7fb lv2: Fix lwmutex locking 2018-11-07 13:06:29 +03:00
eladash 777f36e604 Fix error code checking of sys_lwcond_signal_x 2018-11-07 13:06:29 +03:00
Ani 2abbedcc50 gui: Fix OpenCorrectionDialog message
It was incorrectly trying to get the previous setting value after updating the setting
2018-11-07 00:04:22 +01:00
Ani 11681f02cc Merge pull request #5300 from hcorion/fix-fedora
Add libnsl.so.1 to the AppImage, print resulting upload url
2018-11-05 15:20:58 +00:00
Ani 5f67c6050d Merge branch 'master' into fix-fedora 2018-11-05 14:25:54 +00:00
RipleyTom 9831bc6bc9 Bluetooth returns select as KEY_BACK for XBOX ONE controller. (#5303) 2018-11-05 14:25:38 +00:00
Nekotekina 488928eca2 Fix SPU STOP instruction
Check thread state after STOP instruction
2018-11-05 14:35:50 +03:00
Nekotekina f06e6be2c1 Disable npc update for SPU thread groups 2018-11-05 13:14:11 +03:00
Nekotekina eaa17b7f7c cellSaveData: anti-corruption precautions
Try to commit changes atomically
2018-11-05 13:14:11 +03:00
Nekotekina 6104685ad6 Implement cond_one sync primitive
Change futex() args to use unsigned int
2018-11-05 13:14:11 +03:00
Nekotekina 06253c8489 Implement "Initialize Directories" options
If disabled, /dev_hdd0, /dev_hdd1, etc, are not created automatically.
2018-11-05 13:14:11 +03:00
eladash 75221a6078 rsx: Fix inlined vertex array validation 2018-11-04 22:57:18 +03:00
Zion Nimchuk 2487a03648 Add libnsl.so.1 to the AppImage, print resulting upload url 2018-11-02 11:16:08 -07:00
eladash 43b75ccf04 cellGame: Add missing nullptr checks
if the param is null pointer, the library simply skips writing into it. also fix the order of writes.
2018-11-02 19:47:37 +03:00
HexyFify 98f2967aac Update firmware latest version to 4.83 2018-11-02 00:51:42 +00:00
Zion Nimchuk fa134337d9 Fix issue with memory validation 2018-11-02 03:21:36 +03:00
eladash 3a7f5b970f ppu: Fix stack base 2018-11-02 02:16:29 +03:00
eladash 7056b5fc70 rsx-debugger: add forgotten super ptrs 2018-10-30 22:33:59 +03:00
eladash 68a8efdc33 rsx-debugger: auto jump into get address on startup 2018-10-30 22:33:59 +03:00
eladash fb30c8a937 rsx enums: fix typos 2018-10-30 22:33:59 +03:00
eladash 5270dc1c9e rsx-debugger: fix ret and nop cmd display 2018-10-30 22:33:59 +03:00
eladash 4069470585 rsx-debugger: ignore invalid cmds
basically ignore all non method cmds when scrolling to the next command, not only branches.
2018-10-30 22:33:59 +03:00
eladash 2058d024ce Fix cellGcmInit (workaround) 2018-10-28 20:09:09 +03:00
Megamouse d56c85fe01 RSX/Capture: fix filePath and remove strict mode check (#5283)
- Fixes regression introduced by kd-11 when merging in jarves' flip rework.
2018-10-27 13:06:50 +03:00
Megamouse 1cf62e9ded Qt: add option to add games to the main menu 2018-10-27 02:37:59 +02:00
Megamouse 586c0ea1d0 Qt: rename deleteLLVMCache to removePPUCache 2018-10-23 22:35:50 +02:00
Dennis Luxen 36d4614d12 Fix a warning that shift overflows data type width (#5116) 2018-10-23 18:49:01 +03:00
eladash dfacdd8a40 fixup for rsx debugging tools segfaults 2018-10-23 18:02:03 +03:00
eladash 5ee351234c rsx-capture: unbreak 2018-10-23 18:02:03 +03:00
Megamouse eba2216c4a fix evdev device list 2018-10-20 22:08:58 +02:00
eladash d14c8a03b3 typo fix 2018-10-20 22:27:48 +03:00
Zion Nimchuk 966c3fea5b Fix command line arguments, add --version and set Qt application name 2018-10-20 20:42:25 +02:00
Megamouse aed83e69c9 Qt: add tick marks to Master Volume Slider 2018-10-20 19:19:54 +02:00
Megamouse 6e08d8e746 Qt: also enable/disable overlay centering checkboxes 2018-10-20 19:19:54 +02:00
Megamouse c9d8cd3613 Qt: refactor settings_dialog and add EnhanceSlider 2018-10-20 19:19:54 +02:00
Megamouse da5385686c Qt: add master volume slider to the audio tab 2018-10-20 19:19:54 +02:00
Zion Nimchuk db40cbda58 Qt: set Vulkan surface in gs_frame 2018-10-20 18:49:04 +02:00
msuih 56ea45f9d5 Add setting for master volume 2018-10-20 16:35:01 +03:00
elad 6829fa0286 rsx: Improve inlined arrays (#5248)
* rsx: Implement register reads in inlined arrays

* rsx: Check for disabled streams in inlined arrays
2018-10-20 16:00:53 +03:00
Nekotekina f588454d26 Internal: register WaitOnAddress family functions (WinAPI) 2018-10-19 22:22:35 +03:00
Nekotekina 1b37e775be Migration to named_thread<>
Add atomic_t<>::try_dec instead of fetch_dec_sat
Add atomic_t<>::try_inc
GDBDebugServer is broken (needs rewrite)
Removed old_thread class (former named_thread)
Removed storing/rethrowing exceptions from thread
Emu.Stop doesn't inject an exception anymore
task_stack helper class removed
thread_base simplified (no shared_from_this)
thread_ctrl::spawn simplified (creates detached thread)
Implemented overrideable thread detaching logic
Disabled cellAdec, cellDmux, cellFsAio
SPUThread renamed to spu_thread
RawSPUThread removed, spu_thread used instead
Disabled deriving from ppu_thread
Partial support for thread renaming
lv2_timer... simplified, screw it
idm/fxm: butchered support for on_stop/on_init
vm: improved allocation structure (added size)
2018-10-19 22:22:35 +03:00
Nekotekina 8ca6c9fff0 Fix thread_base::get_cycles (Linux/POSIX) 2018-10-19 22:22:35 +03:00
Nekotekina 430e2243ac Fix audio_thread buffer deallocation race 2018-10-19 22:22:35 +03:00
Nekotekina 73d35b0236 Remove CALL_FUNC, implement ppu_execute<>() 2018-10-19 22:22:35 +03:00
Megamouse 4ab777b429 Add title to emulator message dialogs 2018-10-14 23:14:46 +03:00
msuih 48416e81eb Save compatibility draw state 2018-10-13 17:05:36 +02:00
msuih 90688c4970 Compatibility status to grid view
Includes icon drawing, menu option and settings entry.
2018-10-13 14:43:23 +02:00
msuih 8cb0f5d2dd Gitignore: Support CLion IDE 2018-10-13 14:43:23 +02:00
scribam 8540399ecb ppu-interpreter: improve vminfp instruction 2018-10-12 21:30:14 +03:00
elad 623f1b35f6 rsx_capture/gcm: Fix tile binding (#5246)
* gcm: Fix tile offset setting

highest bit signifyies location, so ignore that while reading the offset.

* rsx-capture: Fix tile binding

fixes division by zero when dividing by pitch when the tile is not bound.

* rsx-capture: Fix zcull binding
2018-10-12 19:05:08 +03:00
Alex Yeazel d8424a1f35 README update
Specified "free and open-source" instead of just "open-source".
2018-10-11 01:18:41 +03:00
Alex Yeazel e52d338552 README update
Minor cleanup such as capitalization fixes, wording changes, and punctuation tweaks.
2018-10-11 01:18:41 +03:00
eladash 83b6c98563 rsx: Fix u16 index arrays overflow
Force u32 index array destinations to avoid overflows when adding vertex base index.
2018-10-08 16:39:47 +03:00
eladash e361e0daa6 rsx: Fix restart index check for u16 index arrays
Dont ignore upper bits of the restart index with u16 types
2018-10-08 16:39:47 +03:00
scribam 39272eef45 ppu-interpreter: improve vsl/vsr instructions 2018-10-08 00:15:26 +03:00
scribam cc846eb670 ppu-interpreter: improve fnmadd/fnmadds instructions (#5183)
* ppu-interpreter: improve fnmadd instruction

* ppu-interpreter: improve fnmadds instruction
2018-10-04 00:49:19 +03:00
Megamouse 49e5212a8f RSX/Overlays: Add option for japanese button layout 2018-10-03 23:08:33 +02:00
Megamouse 76da3fa907 RSX/Overlays: don't press buttons on every iteration 2018-10-03 21:37:05 +02:00
Megamouse 9693d1c3a3 RSX/Overlays: formatted comments 2018-10-03 21:37:05 +02:00
eladash 348db050ae rsx: Fix texture height read 2018-10-03 20:57:46 +03:00
eladash 62f97f2e5f rsx: Fix default texture dimensions
haha
2018-10-03 20:57:46 +03:00
eladash fa723f6dc4 rsx: Fix texture depth read 2018-10-03 20:57:46 +03:00
eladash 4174d7274d sys_rsx: fix log spam 2018-10-03 20:57:46 +03:00
eladash a92ae827c1 rsx: Remove texture mipmap hack 2018-10-03 20:57:46 +03:00
eladash 6586090307 rsx: Remove texture size hack 2018-10-03 20:57:46 +03:00
eladash eacd1b8f13 rsx: Remove texture address hack 2018-10-03 20:57:46 +03:00
Nekotekina 1b740995a4 Refactor audio_thread (g_idm) 2018-10-02 23:26:54 +03:00
Nekotekina a8a9c11bf8 typemap improvements 2018-10-02 23:26:54 +03:00
Nekotekina f6f72c1cf8 Rename -> typemap_ptr::unlock() 2018-10-02 23:26:54 +03:00
Nekotekina bc87c5808c Add cond_variable::wait_unlock 2018-10-02 23:26:54 +03:00
Nekotekina 4bef0f8dab Rename thread_abort (name conflict) 2018-10-02 23:26:54 +03:00
Megamouse c9adb52f63 Qt: Add shader loading screen options to the settings dialog 2018-10-02 09:28:58 +02:00
Nekotekina 1456678316 Refactor audio/camera/mic threads 2018-10-02 02:22:26 +03:00
Nekotekina 19a64e0e94 Add g_typemap and g_idm alias
Future idm/fxm replacement
2018-10-02 02:22:26 +03:00
Nekotekina 3359e9a51b Minor thread fixes
Call thread result destructor
2018-10-02 02:22:26 +03:00
Nekotekina 7a024f3355 Implement shared_mutex::lock_unlock
Minor fix for shared_mutex::try_lock - don't optimize for pessimistic case
2018-10-02 02:22:26 +03:00
Nekotekina 8a1b5abee1 utils::typemap implemented
Container for all types
2018-10-02 02:22:26 +03:00
Nekotekina 4a252e750f Rebase LLVM fork 2018-10-01 21:10:10 +03:00
Nekotekina da6ce80f4f Make vm::get_super_ptr return contiguous memory
Cleanup RSX code complexity
2018-09-27 23:37:13 +03:00
eladash 72ba062b1a rsx: Fix pfifo ret opcode 2018-09-27 17:47:32 +03:00
eladash a47ebad24c rsx: Fix pfifo nop cmd 2018-09-27 17:47:32 +03:00
Nekotekina 306f95a9ae New named_thread template (preview)
Old class named_thread renamed to old_thread
It's too hard to move in a single commit
2018-09-27 14:04:16 +03:00
Nekotekina 4ef384a161 Fix cellVdecClose
Thanks Micaelis#6971
2018-09-27 14:04:16 +03:00
Nekotekina 680aaf21f0 Fix consistency in Emu::Stop()
Don't clear force_boot on shortcut Load()
2018-09-27 12:16:43 +03:00
Nekotekina b2f29cd4d4 LLVM: remove false alarm errors
Writable sections ARE supported
2018-09-27 12:16:43 +03:00
Nekotekina bb524db236 Implement utils::memory_reset 2018-09-27 12:16:43 +03:00
Nekotekina a605dd0a3f Add missing deleted operators 2018-09-27 12:16:43 +03:00
Nekotekina a8a8cd88a0 Implement lf_queue<>, lf_value<>
lf_queue<>: unbound FIFO queue with dynamic linked-list
lf_value<>: concurrently-assignable value readable without locking at the cost of memory (using dynamic linked list)

Add atomic_t<>::compare_exchange
2018-09-27 12:16:43 +03:00
Nekotekina 9e5b633779 shared_mutex cleanup
Rewrite to use unsigned arithmetic, shrink to u32
Ensure zero default unlocked state (will need it later)
Inline all public methods, rewrite lock_upgrade()
Remove try_lock_degrade(), lock_degrade() methods
Implement lock_downgrade() (now trivial)
Remove is_reading(), added is_free()
Added reader_lock::try_upgrade()
2018-09-27 12:16:43 +03:00
kd-11 bdf85ed900 rsx: Fixup for vertex attrib parsing
- POS does not have to be fetched from ATTR[0]
  - Confirmed with UC1 that uses WEIGHT for positions
  - At least one POS stream has to exist to feed the position attribute which cannot repeat for a single triangle
2018-09-26 19:41:50 +03:00
kd-11 6a9f234dc7 rsx: Fixup flip behaviour
- handle_emu_flip is very heavy, only fire
2018-09-26 19:41:50 +03:00
eladash f056ef7a80 rsx-capture: Save initial method registers state 2018-09-26 17:55:08 +03:00
eladash 5b0ed1e2eb rsx-capture: Map dynamically rsx data injection addresses 2018-09-26 17:55:08 +03:00
eladash 8e268aedc7 rsx-capture: Rewrite FIFO commands allocation 2018-09-26 00:58:24 +03:00
kd-11 f72157bcec rsx: Fix vertex attrib parsing 2018-09-25 22:03:35 +03:00
kd-11 dab30c0051 rsx: Disable predictions if 50% of predictions are wrong
- This happens often in loading screens where the memory usage pattern is often randomized by loading in of assets
2018-09-24 21:19:38 +03:00
kd-11 a3d44b5e1f rsx: Cleanup changes for the flip patch 2018-09-24 16:44:02 +03:00
Jake 699eadc84f rsx: Move render flip from rsx queue command to flip command 2018-09-24 16:44:02 +03:00
Rui Pinheiro 35139ebf5d Texture cache cleanup, refactoring and fixes 2018-09-24 15:26:40 +03:00
Rui Pinheiro 8b3d1c2c91 Implement address_range utility class 2018-09-24 15:26:40 +03:00
Rui Pinheiro f3029b2b42 Change Cell->RSX map/unmap notifications
This allows for further flexibility on the RSX side, allowing us to fix
some bugs and crashes in later commits.
2018-09-24 15:26:40 +03:00
Rui Pinheiro a07cbaca8e Update ASSUME, add ASSERT and AUDIT
- ASSUME now uses __builtin_assume in clang
- ASSERT defined as a wrapper around verify
- AUDIT aliases ASSERT when _DEBUG or _AUDIT are set, otherwise empty
2018-09-24 15:26:40 +03:00
Rui Pinheiro 13faf4e816 Avoid silent failures in RSX violation handler 2018-09-24 15:26:40 +03:00
eladash 06572c6011 rsx: Fix vertex count if all the streams are disabled 2018-09-24 13:25:05 +03:00
eladash e0a676a3fe rsx: Fix vertex arrays fetch with inlined draws 2018-09-24 13:25:05 +03:00
eladash e8474145a5 rsx: Remove shader address verification
this came from a misunderstanding of the register's use
2018-09-24 13:25:05 +03:00
Megamouse b7e010bbd0 Fix Emu.Restart() 2018-09-23 01:49:58 +01:00
Jan Beich 0da556e1f8 build/cmake: properly disable assert() globally for release builds
Assertion failed: (ObjectBufferMap.find(Key) == ObjectBufferMap.end() && "Second attempt to perform debug registration."), function NotifyObjectEmitted, file llvm/lib/ExecutionEngine/GDBRegistrationListener.cpp, line 168.
2018-09-22 10:35:45 +03:00
Jan Beich efb3b08f87 build/cmake: ADDITIONAL_LIBS satisfy dependency by other libraries
/usr/bin/ld: undefined reference to symbol `libiconv_open' (try adding -liconv)
2018-09-22 10:35:45 +03:00
Jan Beich 1c8fc6852a build/cmake: build everything with -pthread, not just GLEW
error: POSIX thread support was disabled in PCH file but is currently enabled
2018-09-22 10:35:45 +03:00
Jan Beich 1133fbb017 build/cmake: add hidapi include directory on libusb platforms as well
3rdparty/hidapi/libusb/hid.c:52:10: fatal error: 'hidapi.h' file not found
 #include "hidapi.h"
          ^~~~~~~~~~
2018-09-22 10:35:45 +03:00
kd-11 dafc914bcc rsx: temporary hack
- Removes all use of valid_count as a metric until the new refactor is merged
2018-09-21 16:32:23 +03:00
kd-11 2b6e6a9ae9 gl: Fix problems with framebuffer reuse
- Matching attachments with resource id fails because drivers are reusing
  handles!
- Properly sets up stale fbo ref counting and removal
- Properly sets up resource reference test with subsequent removal to
  avoid using a broken fbo entry
2018-09-21 16:32:23 +03:00
kd-11 fc486a1bac rsx: Preserve memory order when doing flush
- Orders flushing to preserve memory at all cost
- Avoids false positive where flushing overlapping sections can falsely invalidate another with head/tail test
2018-09-21 16:32:23 +03:00
kd-11 23dc9d54e3 rsx: Fix flip source selector 2018-09-21 16:32:23 +03:00
kd-11 a21bdb9f45 rsx; blit engine fixes
- Forcefully downloads and reuploads data from the CPU in case of unexpected overlaps
- Properly detect correct size of newly created blit targets
- Remember to clear any existing views when changing the default component map!
2018-09-21 16:32:23 +03:00
Zion Nimchuk afa7eacfac Revert change to using --appimage-extract-and-run, as linuxdeployqt doesn't have it yet, Fixes #5148
I really didn't want to do this, but no new AppImages suck.
2018-09-20 23:15:56 +03:00
Zion Nimchuk dfd3035955 Fix travis timing out while silently cloning git submodules 2018-09-20 23:15:56 +03:00
eladash 1a6c819176 cellgcm: Fix SET_REFERENCE initial value 2018-09-20 01:05:40 +03:00
eladash e6b68b260a rsx: Improve FIFO mem faults handling
increase the delay between faults, reduce log spam by allowing the messages to stack up
2018-09-20 01:05:40 +03:00
eladash a8ea576b22 rsx/cellgcm: Implemet initialization registers reset 2018-09-20 01:05:40 +03:00
Lassi Hämäläinen 972de4c730 CMake: Fix Linux WITHOUT_LLVM build
- _XABORT_RETRY is defined in immintrin.h which wasn't included
2018-09-19 21:17:01 +03:00
Nekotekina 59090f6d26 VFS: fix /host_root 2018-09-19 14:15:38 +03:00
Nekotekina dce14a359a Rename lv2_spu_group::num to max_num 2018-09-19 14:15:15 +03:00
Nekotekina 26da91c972 Optimize logs
Pass va_args instead of constructing a temporary array
2018-09-19 14:14:04 +03:00
Nekotekina 11e297c975 Remove explicit in atomic_t constructor
Match with std::atomic
C++17 now allows writing std::atomic<int> x = 3;
2018-09-19 14:07:38 +03:00
Lassi Hämäläinen 9a457400e7 CMake: Fix Qt resource files not included in build
- Move Qt resource initialization to rpcs3_qt target
2018-09-19 01:59:27 +03:00
Lassi Hämäläinen 566c88802e CMake: LLVM, Pulse, Alsa and libevdev being disabled
- These dependencies have #defines which enable code related to them
  in rpcs3 and rpcs3_ui targets. They are only used in rpcs3_emu but
  HAVE_* defines have to be defined in rpcs3 and rpcs3_ui targets also,
  so they have to have PUBLIC visibility so defines carried over

CMake: Fix Alsa and Pulse audios being disabled

- HAVE_PULSE and HAVE_ALSA were not defined in rpcs3 target

Fixup libevdev
2018-09-19 01:59:27 +03:00
kd-11 d6dc1493cb rsx/overlays: Implement blur, darkening and ability to disable custom background 2018-09-18 16:24:13 +03:00
kd-11 9f61fb5a78 overlays: Allow custom background for message dialog 2018-09-18 16:24:13 +03:00
Lassi Hämäläinen 7aef811ff7 CMake: Refactor CMake build (#5032)
* CMake: Refactor build to multiple libraries

- Refactor CMake build system by creating separate libraries for
  different components
- Create interface libraries for most dependencies and add 3rdparty::*
  ALIAS targets for ease of use and use them to try specifying correct
  dependencies for each target
- Prefer 3rdparty:: ALIAS when linking dependencies
- Exclude xxHash subdirectory from ALL build target
- Add USE_SYSTEM_ZLIB option to select between using included ZLib and
  the ZLib in CMake search path

* Add cstring include to Log.cpp

* CMake: Add 3rdparty::glew interface target

* Add Visual Studio CMakeSettings.json to gitignore

* CMake: Move building and finding LLVM to 3rdparty/llvm.cmake script

- LLVM is now built under 3rdparty/ directory in the binary directory

* CMake: Move finding Qt5 to 3rdparty/qt5.cmake script

- Script has to be included in rpcs3/CMakeLists.txt because it defines
  Qt5::moc target which isn't available in that folder if it is
  included in 3rdparty directory
- Set AUTOMOC and AUTOUIC properties for targets requiring them (rpcs3
  and rpcs3_ui) instead of setting CMAKE_AUTOMOC and CMAKE_AUTOUIC so
  those properties are not defined for all targets under rpcs3 dir

* CMake: Remove redundant code from rpcs3/CMakeLists.txt

* CMake: Add BUILD_LLVM_SUBMODULE option instead of hardcoded check

- Add BUILD_LLVM_SUBMODULE option (defaults to ON) to allow controlling
  usage of the LLVM submodule.
- Move option definitions to root CMakeLists

* CMake: Remove separate Emu subtargets

- Based on discussion in pull request #5032, I decided to combine
  subtargets under Emu folder back to a single rpcs3_emu target

* CMake: Remove utilities, loader and crypto targets: merge them to Emu

- Removed separate targets and merged them into rpcs3_emu target as
  recommended in pull request (#5032) conversations. Separating targets
  probably later in a separate pull request

* Fix relative includes in pad_thread.cpp

* Fix Travis-CI cloning all submodules needlessly
2018-09-18 13:07:33 +03:00
Zion Nimchuk e37da61a1c Minor cleanup and add back in xcb lib removal 2018-09-17 18:47:29 +03:00
Zion Nimchuk 1a361e1f29 Fix travis mac build regression 2018-09-17 18:47:29 +03:00
eladash 05cd3712a3 spu: Fix MMIO index checking 2018-09-17 17:24:54 +03:00
Nekotekina 4cebf431fd Add forgotten SAFE_BUFFERS 2018-09-17 12:18:40 +03:00
Nekotekina a64beb583b Fix .editorconfig encoding 2018-09-17 12:18:40 +03:00
Nekotekina 9de31fc5ce Fix trailing zeros in CPU brand 2018-09-17 12:18:40 +03:00
elad 0d4f0f95cc rsx: Clamp texture offsets (#5137)
* rsx: Clamp texture offsets

* rsx: Remove texture location check/hack
2018-09-17 10:55:17 +03:00
Nekotekina ed8aa774bb Optimize logging via logs::channel
Use constant-initialized severity subobjects instead of temporaries
2018-09-16 00:36:20 +03:00
Nekotekina b94e98aed5 Rewrite sys_fs_opendir
Rewrite lv2_dir object
Support split files and mount points
2018-09-15 17:18:40 +03:00
Nekotekina c5676e5649 Remove thread_ctrl::atexit
It was only a workaround for poor C++11 thread_local support
2018-09-15 17:09:56 +03:00
Nekotekina f2229a5f53 PPU reservations: ensure aligned atomic ops
Store aligned 64 bits to ppu.rdata
Don't save reservation size
2018-09-15 17:09:56 +03:00
Nekotekina d347145855 Fix bitset formatting 2018-09-15 17:09:56 +03:00
Nekotekina 445e5def42 Remove safe_reader_lock, safe_writer_lock
It worked as a simple recursive locker for shared_mutex
But its design is flawed and thus can't be fully implemented
2018-09-15 17:09:56 +03:00
Nekotekina e8b5555630 Rewrite vfs::get and vfs::mount
Preprocess . and .. correctly
Don't use recursive locking
Also use std::string_view
Fix format system for std::string and std::string_view
Fix fmt::merge for std::string_view
2018-09-15 17:09:56 +03:00
kd-11 16dcbe8c74 rsx/vp: Fix ARL opcode properly
- NOTE: The address swizzle index is only for use as src. The address registers are only used one channel at a time.
- When the destination of ARL, the encoding is the same as the other temp registers
2018-09-15 11:57:06 +03:00
Megamouse ed7012c9db cellKb/Qt: Improve basic keyboard
Sadly the shift in Qt is a bit counter productive.
You'll have to hack another key as shift until i figured it out
2018-09-13 22:01:30 +02:00
elad d24f9194f7 typo fix
shader's location is decremented by one to match cellGcm's constants.
2018-09-13 16:49:58 +03:00
eladash b9ad578b00 rsx: Add a default shader address state 2018-09-13 16:49:58 +03:00
Dzmitry Malyshau d28c0d16f8 [vk] don't ask for VK_FORMAT_UNDEFINED support 2018-09-13 16:04:50 +03:00
scribam 4cb98014a2 rsx: tiny zcull optimizations 2018-09-13 12:43:40 +03:00
eladash cd11ae5d8b ppu: Fix extreme reservation corner case 2018-09-12 23:17:53 +03:00
eladash efbd77deb4 rsx: dont silently ignore null shader address 2018-09-12 00:40:20 +03:00
Dzmitry Malyshau 7c4693e271 [vk] Throw an exception on using a repder pass that the driver doesn't support 2018-09-11 23:44:56 +03:00
Dzmitry Malyshau 89ddeda24a [vk] check for attachment format properties before pre-creating render passes 2018-09-11 23:44:56 +03:00
scribam f294729b28 ppu: improve lvebx/lvehx/lvewx instructions 2018-09-11 21:20:52 +03:00
Zion Nimchuk 635ecbeb90 Travis refactor 2018-09-11 12:02:31 +03:00
scribam 3072571a4f cpu: use correct type when defining llvm value is_int constexpr 2018-09-10 19:59:37 +03:00
scribam c8c8ce5e9e rsx: add virtual destructor for default_vertex_cache 2018-09-10 19:59:37 +03:00
kd-11 f413996362 rsx: Minor texture cache fixes
- Retag resources reprotected under flush_always rules
- Properly check for blit resource fitting taking into account format
mismatch, pitch mismatch and typeless transfers
2018-09-10 15:43:28 +03:00
Nekotekina 2226125728 atomic_t<>: remove inline assignment
Add atomic_op/fetch_op overloads with template argument (may be removed in future)
Remove args... in atomic_op (capturing lambda is preferred)
2018-09-09 12:59:24 +03:00
Nekotekina 3ac1b46df2 Add option "HLE lwmutex"
Replaces lwmutex/lwcond implementation with alternative one
2018-09-09 01:02:19 +03:00
Alex James 5237779136 cellCamera: Fix check_dev_num call in cellCameraOpenEx 2018-09-08 20:07:10 +03:00
Nekotekina fb5cdf9769 atomic_t<>: extend fetch_op to support cancellation
Use std::invoke inside atomic_op/fetch_op
Remove op_fetch because it's easily replaced
Add fetch_dec_sat algorithm (conditional decrement)
2018-09-08 00:32:04 +03:00
Nekotekina ed9fb8405b Move rotate/cntlz/cnttz helpers to Utilities/asm.h 2018-09-08 00:32:04 +03:00
Nekotekina ee96807305 Remove explicit_bool_t, ignore, multicast<>
Remove vm::ptr operator %
This was a bad idea but explicit_bool_t was created almost for it
Other removed types are unused and have little to no meaning
2018-09-08 00:32:04 +03:00
Nekotekina 99ffc3fca9 Use std::invoke_result_t
Also simplify idm code
2018-09-08 00:32:04 +03:00
Nekotekina d750e955c3 Use std::uncaught_exceptions()
Also remove wrong attributes
2018-09-08 00:32:04 +03:00
Nekotekina ea4a3b2476 bs_t<>: add missing operators 2018-09-08 00:32:04 +03:00
Dzmitry Malyshau 4e09573937 [vk] Check for BGRA8 linear image to support blitting 2018-09-07 22:02:02 +03:00
Dzmitry Malyshau b454dde871 [vk] fix cubic view construction 2018-09-07 19:11:34 +01:00
Ofek d7b0344091 Fix trophy regression
Hopefully
Correct status order
2018-09-07 20:04:37 +03:00
Dzmitry Malyshau 27474316fd Add missing virtual desctructors (#5094) 2018-09-07 14:35:40 +03:00
Zion Nimchuk 46812d46ba better stub sceNpUtilBandwidthTestGetStatus 2018-09-07 12:38:51 +03:00
kd-11 66610a28af rsx/common: Clean up shared glsl header to minimize string concat operations 2018-09-06 21:11:11 +03:00
kd-11 346b97f871 rsx: Preserve fog coordinate across shader stages
- The x value contains the VP output value interpolated across primitive surface
- The y coordinate contains the fog fraction according to the selected fog formula
2018-09-06 21:11:11 +03:00
scribam 343656f66d cleanup: remove unnecessary return and namespace declaration 2018-09-06 13:15:59 +03:00
scribam 549a5370d8 cleanup: remove recursive_wrapper.hpp 2018-09-06 13:15:59 +03:00
scribam 2834c88de7 cleanup: remove intermediate const char* variables 2018-09-06 13:15:59 +03:00
scribam a745f02a07 cleanup: remove compatibility code for old versions of clang 2018-09-06 13:15:59 +03:00
scribam f83d381e1e clang-tidy: use nullptr 2018-09-06 13:15:59 +03:00
scribam c4cff9b543 clang-tidy: remove redundant "apply_swizzle_remap" declaration 2018-09-06 13:15:59 +03:00
scribam d7bb59cd99 c++17: use std::size 2018-09-06 13:15:59 +03:00
scribam 7724161c14 c++17: use std::clamp 2018-09-06 13:15:59 +03:00
scribam 02ba529eea sys_usbd: add sys_usbd_event_port_send function 2018-09-05 19:53:09 +03:00
Nekotekina ca5158a03e Cleanup semaphore<> (sema.h) and mutex.h (shared_mutex)
Remove semaphore_lock and writer_lock classes, replace with std::lock_guard
Change semaphore<> interface to Lockable (+ exotic try_unlock method)
2018-09-03 23:00:36 +03:00
Nekotekina 5e556a87ff Adjust cellMic log levels 2018-09-03 21:40:36 +03:00
Nekotekina ce4c4696dd Try to get rid of SIZE_32 macro 2018-09-03 21:40:36 +03:00
Nekotekina 7bccdbf157 Make vm::var unmoveable
Fix bugs with discarding vm::make_var result
2018-09-03 21:40:36 +03:00
Nekotekina 8abe6489ed Mega-cleanup for atomic_t<> and named bit-sets bs_t<>
Remove "atomic operator" classes
Remove test, test_and_set, test_and_reset, test_and_complement global functions
Simplify atomic_t<> with constexpr if, remove some garbage
Redesign bs_t<> to use class, mark its methods constexpr
Implement atomic_bs_t<> for optimizations
Remove unused __bitwise_ops concept (should be in other header anyway)
Bitsets can now be tested via safe bool conversion
2018-09-03 21:40:36 +03:00
Nekotekina a6d06b2e20 Use fold expr in fs::write_file 2018-09-03 21:40:36 +03:00
Nekotekina 01b4c68238 Remove EXPECTS/ENSURES macro 2018-09-03 21:40:36 +03:00
Nekotekina 69f0ad0d68 Remove ALIGN_32 macro
It's never used in expressions like SIZE_32(T) * n, so it doesn't help to fix any warning issued due to truncation.
2018-09-03 21:40:36 +03:00
kd-11 dea5193fd7 rsx: Fix FP temp register count 2018-09-03 21:39:18 +03:00
Rui Pinheiro 1175658bd5 Fix cellMic regression from #4467
cellMicEnd would get stuck waiting for the cellMic thread to finish, but
it never does because micInited is still true.

Fixes Resistance: Fall of Mankind getting stuck after the menu
2018-09-03 19:49:41 +02:00
kd-11 2e0ecb556c rsx: Possible fix for UB data type consistency 2018-09-03 18:24:20 +03:00
kd-11 5a08b690d5 gl: always clean up the heap when using legacy buffers 2018-09-03 18:24:20 +03:00
kd-11 815f4aa63b vk: Improve logging of device names and driver versions 2018-09-03 18:24:20 +03:00
kd-11 e23435a190 vk: whitespace fix only 2018-09-03 18:24:20 +03:00
kd-11 85d38b5751 d3d12: restore working graphics 2018-09-03 18:24:20 +03:00
kd-11 6399833182 rsx: Fix endianness order when immediate mode register is updated, but used as register lookup
- Simplify the code by unifying all the register-backed memory
2018-09-03 18:24:20 +03:00
eladash 9acaee563b Fix sys_memory_free 2018-09-01 22:44:20 +04:00
scribam bf89b709cb Remove useless #include 2018-08-31 20:13:54 +04:00
scribam c2973d2b82 Update ConfigureCompiler.cmake to check for the same compiler versions as those set in README.md 2018-08-31 20:13:54 +04:00
scribam 7d0e94ab0a Compilation fixes for optional on osx 2018-08-31 20:13:54 +04:00
scribam 6c62d042c5 3rdparty: remove optional submodule 2018-08-31 20:13:54 +04:00
Lassi Hämäläinen 79cf2832ae Remove Utilities/variant.hpp and use C++17 variant
- Remove also Utilities/variant_visitor.hpp
- Fix variant and variant_visitor usages and #includes
2018-08-31 17:49:59 +04:00
Jan Beich cd6bf37d06 Utilities: explicitly add more includes found by GCC
Utilities/Log.cpp: In member function 'void logs::file_writer::log(logs::level, const char*, std::size_t)':
Utilities/Log.cpp:559:9: error: 'memcpy' is not a member of 'std'
    std::memcpy(pos, text, frag);
         ^~~~~~
Utilities/Log.cpp:559:9: note: suggested alternative: 'empty'
    std::memcpy(pos, text, frag);
         ^~~~~~
         empty
Utilities/Log.cpp:560:9: error: 'memcpy' is not a member of 'std'
    std::memcpy(m_fptr, text + frag, size - frag);
         ^~~~~~
Utilities/Log.cpp:560:9: note: suggested alternative: 'empty'
    std::memcpy(m_fptr, text + frag, size - frag);
         ^~~~~~
         empty
Utilities/Log.cpp:564:9: error: 'memcpy' is not a member of 'std'
    std::memcpy(pos, text, size);
         ^~~~~~
Utilities/Log.cpp:564:9: note: suggested alternative: 'empty'
    std::memcpy(pos, text, size);
         ^~~~~~
         empty
Utilities/sync.h: In member function 'int futex(int*, int, int, const timespec*, int*, int)::futex_map::operator()(int*, int, int, const timespec*, int*, uint)':
Utilities/sync.h:110:20: error: 'find' is not a member of 'std'
     map.erase(std::find(map.find(uaddr), map.end(), ref));
                    ^~~~
Utilities/sync.h:110:20: note: suggested alternative: 'rend'
     map.erase(std::find(map.find(uaddr), map.end(), ref));
                    ^~~~
                    rend
2018-08-31 03:19:17 +04:00
Nekotekina 85fa0942e7 vm: allow 4k-aligned allocations for vm::stack
Fix utils::shm::map logic for MapViewOfFileEx
2018-08-30 14:56:45 +03:00
Nekotekina c49c7de427 sys_fs_stat: support split files
Was forgotten after sys_fs_open
2018-08-30 14:56:45 +03:00
Megamouse f933947a27 keyboard_pad_handler: fix mouse for multimonitor fullscreen 2018-08-30 07:38:11 +02:00
Megamouse e53ca429a1 Adjust to US keyboard... sigh 2018-08-30 07:38:11 +02:00
Megamouse 1fbd918d59 Qt: implement first Mouse Movement for keyboard pad handler 2018-08-30 07:38:11 +02:00
elad 685eaedbf9 rsx: Fix typos (#5054) 2018-08-30 00:47:48 +03:00
Ani 4357892081 Bump CMake Requirement to 3.8.2+
With older builds CMake will error out with `CXX_STANDARD is set to invalid value '17'`

CXX_STANDARD 17 was added on CMake 3.8.X as found in the 3.8.2 documentation: https://cmake.org/cmake/help/v3.8/prop_tgt/CXX_STANDARD.html

Also removes leftover from old VS2015/2017 mixed instructions, removes "Not GCC 6.1" since we require 7.3+ now and bumps Xcode to 10. Proper MacOS instructions will be added afterwards by someone else.
2018-08-29 22:01:57 +01:00
Ofek 4c1459534d Trophy fixes 2018-08-29 16:56:17 +03:00
Megamouse 686d3eb1df cellMsgDialog: improvements 2018-08-29 16:09:00 +03:00
Megamouse 00b31c27a3 cellGame: implement error messages and some stubs 2018-08-29 16:09:00 +03:00
Megamouse 7208aa37cc cellMsgDialog: introduce open_msg_dialog 2018-08-29 16:09:00 +03:00
Megamouse d4285fb196 cellGameExec: add param checks 2018-08-29 16:09:00 +03:00
Zion Nimchuk f9cab3270f Initial work on cellMic 2018-08-29 15:15:18 +03:00
jmatich b5dbd44087 Compilation fixes for Mingw64 (MSYS2) (#4899)
fix compilation on mingw
2018-08-29 14:27:10 +03:00
eladash 37ee0a2f55 Rsx/cellgcm: complete rsx_state::reset() 2018-08-29 13:37:50 +03:00
eladash fc50e6abcb Rsx: remove method registers reset
cellGcm manually resets registers each flip, tested with cellGcmSetFlip
2018-08-29 13:37:50 +03:00
Dzmitry Malyshau c452b43ebc Basic support for Vulkan Portability on OSX 2018-08-28 21:20:11 +03:00
Moritz Warning eaf20295ac add comma to readme 2018-08-28 20:29:17 +04:00
eladash acf1286b49 Rsx: fix unknown cull faces 2018-08-28 10:47:24 +03:00
eladash 38a72cc6ee Rsx: fix flip method registers reset
driver flip does not reset registers
2018-08-28 10:47:24 +03:00
eladash e279bdb304 Rsx: add missing default vertex shader attributes registers states 2018-08-28 10:47:24 +03:00
zarroboogs 23f5cee653 Git Revision Fix (#5043)
* fix shotrened git revision in version string
2018-08-27 22:53:45 +04:00
Nekotekina 7b4f70390d Don't use decltype(spu_opcode_t::...)
Add static constant for this purpose
Try to fix MSVC bug warning C4573
2018-08-25 21:06:24 +03:00
Nekotekina 93a9201316 Add _ENABLE_EXTENDED_ALIGNED_STORAGE
Should fix compilation error regarding std::aligned_storage
2018-08-25 21:06:24 +03:00
Nekotekina 84abb9923a Don't use std::aligned_storage
Don't need its limiting behaviour anyway
2018-08-25 15:47:03 +03:00
Nekotekina 363811981d Reintroduce LOG_CHANNEL
Groundwork for further improvements
2018-08-25 15:39:00 +03:00
Nekotekina 57f394e156 Fix type-safe formatting 2018-08-25 12:06:57 +03:00
Nekotekina 1d86c60548 Fix hidapi URI 2018-08-25 12:06:30 +03:00
Nekotekina a93a40e8d9 Disable texture_cache::emit_once (MSVC crash) 2018-08-25 01:58:28 +03:00
Nekotekina 955be34914 Update dependencies 2018-08-25 01:47:13 +03:00
Nekotekina 1c6c24f8ac Update GSL and yaml-cpp submodules 2018-08-25 01:15:47 +03:00
Nekotekina 923314aef5 Rewrite texture_cache::emit_once
Also trying to workaround MSVC bug
2018-08-25 01:15:47 +03:00
Nekotekina bb19feca96 Workaround MSVC bug
It fails to parse Args... in fmt::get_type_info<>()
2018-08-25 01:15:47 +03:00
Nekotekina 6bbec61856 VS: enable C++17 2018-08-25 01:15:47 +03:00
Zangetsu38 c30a7c0041 Update Project to Visual Studio 2017. 2018-08-25 01:15:47 +03:00
Nekotekina 3aa6741b8c Simplify error_code 2018-08-25 01:15:47 +03:00
Nekotekina 56a165ecdc Rearrange atomic operator internals 2018-08-25 01:15:47 +03:00
Nekotekina 5afd12e8a4 [CMake] Use C++17 2018-08-24 16:44:19 +03:00
Nekotekina 76bac80dde Add MATCH macro 2018-08-24 16:44:19 +03:00
Nekotekina 6cc7d1fb26 Use std::void_t 2018-08-24 16:44:19 +03:00
Nekotekina fba4dbf498 Travis: use gcc-8 2018-08-24 16:44:19 +03:00
kd-11 21e1911112 vk: Improve fence wait logic 2018-08-24 14:52:22 +03:00
kd-11 76f102e865 vk: Check for allowed texbuffer range instead of assuming 64M 2018-08-24 14:52:22 +03:00
Mårten Nordheim b095a0be90 Fix compilation with VS2017 2018-08-24 14:46:33 +04:00
kd-11 f0a91484a0 vk: Implement double-buffered heaps for platforms without universal support for host visibility (APPLE) 2018-08-23 22:54:56 +03:00
kd-11 c6e35706a3 vk: Support sw component swizzle decode because metal sucks 2018-08-23 22:54:56 +03:00
kd-11 f3d3a1a4a5 rsx: Rework section reuse logic 2018-08-22 17:22:54 +03:00
eladash 874d18f761 rsx-debugger: bugfixes and improvements
*always translate given address
*add a few missing methods names
*fix branches
2018-08-22 13:19:07 +03:00
eladash 56d553f10d Rsx: fix cmd jump over put register 2018-08-22 12:20:31 +03:00
eladash 18ec05c070 Fix cellGcmInit
add a missing reset
2018-08-22 12:20:31 +03:00
eladash 158019b50f Rsx: fix translation when address is negative
move address shift to where it should be, extend io table to catch all possible values.
2018-08-22 12:20:31 +03:00
Megamouse d1d1b2effd Qt: only center basic mouse input on active fullscreens 2018-08-20 20:19:41 +02:00
Ani 6fc869e21b Revert d1fd4d5000 2018-08-20 00:12:30 +04:00
kd-11 25ec3789fe rsx: Fix present modes ordering
- Newer nvidia drivers are not exposing IMMEDIATE present mode unless you change options in nvidia control panel
  This can cause severe performance degradation unless the vsync option is set to "off" in control panel
2018-08-19 15:56:07 +03:00
Nekotekina 386e301ea0 Name missing vm::spu location 2018-08-18 21:38:43 +03:00
Nekotekina e8d144f399 Improve vm::reader_lock
Add upgrade() method
2018-08-18 21:14:52 +03:00
Nekotekina 6ec4a88eb5 Hardcode vm::user64k location 2018-08-18 21:02:16 +03:00
Nekotekina 182c04b59d Improve vm::unmap
Prevent unmapping predefined locations
2018-08-18 21:01:32 +03:00
Megamouse 7cf82d2511 Qt: fix stylesheet warning 2018-08-18 22:00:37 +04:00
kd-11 7915dcb23c rsx: Do not overflow the program buffer!
- Some games overflow the program buffer e.g Resistance games
  The observed overflow is one instruction longer, likely an engine bug
with counting instructions
2018-08-18 16:14:30 +03:00
kd-11 dd21e43ed5 rsx: Force disable draw reordering when capturing a frame 2018-08-18 16:14:30 +03:00
kd-11 937f1e8cd0 fix gcc build 2018-08-18 16:14:30 +03:00
kd-11 4b2b662c3a rsx: Followup to the memory inheritance hierachy patch
- Tags framebuffer resources on first use (when on_write is called to verify memory)
- Texture cache now selects the best match and even sorts atlas writes with memory write order to avoid older data showing over newer one
2018-08-18 16:14:30 +03:00
kd-11 ec31157bc7 gl: Avoid unnecessary scissor state change every draw call. 2018-08-18 16:14:30 +03:00
kd-11 8c93db342f gl: Reuse framebuffer resources
- WIP optimizations for GL backend
2018-08-18 16:14:30 +03:00
kd-11 cca488d0cf rsx: Enable swizzled decode for all formats unless proven otherwise
- Some formats are proven to ignore swizzle flag
  - DXT compressed textures
  - COMPRESSED_BG_GB class textures
- Some applications are using swizzled wide integer formats so those are confirmed to swizzle
2018-08-18 16:14:30 +03:00
kd-11 f8a9b1fa30 [WIP] rsx: Improve memory inheritance hierachy
- Cascade memory writes by invalidating 'downstream' subsurfaces
- Fixup; always resolve for overlapping surfaces before sampling (force
  atlas gather test)
2018-08-18 16:14:30 +03:00
kd-11 ba5b59dc59 gl: Do not create secondary context if async is disabled
- Some third party programs fall apart when multiple contexts are created
2018-08-18 16:14:30 +03:00
kd-11 0f36e87010 zcull: Improve the delay algorithm to be more consistent
- Use proper time checking; depending on what is being done one 'tick' can
  be almost a millisecond long or several nanoseconds
- Avoid spamming the system timer unless necessary
2018-08-18 16:14:30 +03:00
kd-11 38191c3013 rsx: Avoid acquiring the vm lock; deadlock evasion
- A possible deadlock is still present if rsx is trying to get a super_ptr whilst the vm lock holder is in an access violation
  This patch makes this scenario very unlikely since each block need only be touched once
2018-08-18 16:14:30 +03:00
kd-11 741ee9ac41 rsx: Allow linear filtering when reading back GPU-resident memory 2018-08-18 16:14:30 +03:00
kd-11 cc7848b3ef vulkan: Fix blit engine transfer to ARGB8 render target memory 2018-08-18 16:14:30 +03:00
kd-11 e9d6096356 vk: Fixups for type b surfaces 2018-08-18 16:14:30 +03:00
kd-11 373e02e91c rsx: Timestamp accuracy workaround 2018-08-18 16:14:30 +03:00
kd-11 1200ca8172 rsx: Optimize hash_struct; vk cleanup 2018-08-18 16:14:30 +03:00
kd-11 d0165290b6 rsx: Refactor and fix framebuffer layout checks
- Refactors shared code back into rsx core
- Adds extra check to avoid contest confusion
2018-08-18 16:14:30 +03:00
kd-11 0267221586 Minor optimizations and fixes
- FIFO: avoid multiline spam
- VK: Fix program setup counter
- FS: Precalculate fragment constants buffer size during analysis step
2018-08-18 16:14:30 +03:00
kd-11 9f0fada17a ZCULL: lower notice severity to avoid spam 2018-08-18 16:14:30 +03:00
kd-11 8800c10476 zcull synchronization tweaks
- Implement forced reading when calling update method to sync partial lists
- Defer conditional render evaluation and use a read barrier to avoid extra work
- Fix HLE gcm library when binding tiles & zcull RAM
2018-08-18 16:14:30 +03:00
kd-11 3b47e43380 rsx: Synchronization rewritten
- Do not do a full sync on a texture read barrier
- Avoid calling zcull sync in FIFO spin wait
- Do not flush memory to cache from the renderer side; this method is now obsolete
2018-08-18 16:14:30 +03:00
Rui Pinheiro 23b52e1b1c Mark unsync textures dirty when deferred flushing
invalidate_range_impl_base does not mark all textures that will only be
unprotected as dirty when doing a deferred flush, since that is done by
flush_all.

However, if there are no sections to flush, the deferred flush will
use the same code path as non-deferred flushes for unprotecting textures
and forget to mark them as dirty.

This commit fixes this bug.
2018-08-16 15:38:36 +03:00
Rui Pinheiro fa6a5761b3 Refactor get_intersecting_set
The existing implementation restarts the loop immediately after
finding a range_data instance that updates the trampled_range.

This commit refactors this method to continue the loop with the updated
trampled_range, and then repeat only those range_data instances that
were iterated through before the trampled_range was last updated.
As a result, the number of total iterations required is reduced.
2018-08-16 15:38:36 +03:00
Rui Pinheiro b534d49e48 Fix off-by-one error in get_intersecting_set
When the trampled range changes, get_intersecting_set restarts the
outer loop. However, due to an off-by-one error, it skips the first
cache entry when doing so. This can cause a texture not to be
correctly unlocked, which could lead to issues or even deadlocks.

This commit fixes this off-by-one error.
2018-08-16 15:38:36 +03:00
Rui Pinheiro f82ce06fdc Fix typo in buffered_section::overlaps_page
If "address" is not page-aligned, the calculated end address for the
corresponding page is incorrect which can lead to false positives,
causing some textures to be re-uploaded unnecessarily.

This commit fixes this typo.
2018-08-16 15:38:36 +03:00
eladash 9d8c9c2460 sys_memory: fix default alignment flag
its 1mb
2018-08-16 03:27:11 +04:00
eladash 061c787e56 rsx-capture: unbreak 2018-08-16 03:27:11 +04:00
Nekotekina 6c62f42d8d Fix include in log_frame.cpp 2018-08-14 23:59:28 +03:00
Nekotekina 5e20d4b481 Fix vm regression from #4975
Incorrect vector management
2018-08-14 23:57:20 +03:00
Nekotekina a3daa99a33 Fixup sys_vm_memory_map 2018-08-14 16:08:45 +03:00
Nekotekina aa4040bb7b Implement vm::find_map; improve memory allocation
Add vm::user64k and vm::user1m constants
Remove vm::user_space, unreserve it
2018-08-14 15:14:06 +03:00
Nekotekina 9578e1e923 SPU LLVM: lower some log levels 2018-08-14 15:14:06 +03:00
Nekotekina 62f9a2dc4b sys_fs_open: support split files 2018-08-14 15:14:06 +03:00
Nekotekina 441541a42f Implement fs::make_gather 2018-08-14 12:46:22 +03:00
Megamouse 57ba9d3939 basic mouse handler: multi monitor adjustments 2018-08-13 22:23:22 +02:00
Megamouse 1a5b950d8b fix cellMouse lag + fullscreen mouse 2018-08-13 22:23:22 +02:00
Megamouse aaea9d6946 Add the accurate xfloat option to the CPU tab 2018-08-13 20:44:08 +04:00
eladash 449888b9db Rsx/vm: fix base addresses 2018-08-13 16:16:34 +03:00
eladash f349695a75 Rsx: rewrite address translation 2018-08-13 16:16:34 +03:00
eladash 9e380a4a4a Rsx: avoid invalid cmds execution 2018-08-12 23:37:24 +03:00
eladash c80eb1ba02 Rsx: fix CALL and RET cmd 2018-08-12 23:37:24 +03:00
Nekotekina 801089cf44 PPU LLVM: always link syscall_## functions
Regardless of whether they have name or not
Should fix "Linkage failed" errors introduced after #4886
2018-08-12 15:42:47 +03:00
Nekotekina 359bfa88b7 Update supporters 2018-08-12 15:42:47 +03:00
Nekotekina fdd4f03b93 SPU LLVM: improve xfloat precision
Use doubles for intermediate representation
Add option "Accurate xfloat" to enable
2018-08-12 15:42:47 +03:00
Nekotekina d1fd4d5000 PPU: don't use transactions (test) 2018-08-12 02:42:32 +03:00
Nekotekina 14e6577700 SPU LLVM: improve debugging RPCS3
Build cache in reverse order
Catch exceptions in instruction loop: print IR
2018-08-12 02:42:32 +03:00
Nekotekina 711e0f75ee SPU LLVM: inline WRCH (preview)
With lööps for TSX bróþers
2018-08-12 02:42:32 +03:00
Nekotekina d01bf3bcb0 SPU LLVM: rewrite CGX 2018-08-12 02:42:32 +03:00
Nekotekina d3ad44aec4 SPU LLVM: improve constant propagation
Propagate constants in non-volatile registers between chunks
Disable function table in Mega mode
2018-08-12 02:42:32 +03:00
Nekotekina a424fcfcf7 PPU LLVM: fix phenoms 2018-08-12 02:42:32 +03:00
Chris Weermann (TGE) fdcc5adc8d Fix overflow in PPUThread stack frame dump 2018-08-11 20:56:19 +04:00
eladash 745ed8331c Fix sys_rsx_context_iounmap args 2018-08-11 18:14:35 +04:00
Maxetto 05c1f192f5 Update new LV2 names (#4886) 2018-08-11 16:46:44 +04:00
JohnHolmesII 451b3f3c9d Readme update 2018-08-07 14:10:35 +04:00
VelocityRa 1625f4bcc9 cellCamera: Fixes
- Fix regression from #4676
- Refactoring of event queue management stuff
- Some accuracy fixes
2018-08-07 02:54:14 +02:00
Megamouse 69af607491 cellCamera: improvements 2018-08-02 00:24:06 +02:00
Megamouse 456aa4ab8d cellMusic: improvements 2018-08-02 00:24:06 +02:00
Megamouse f8c8a3a26c cellPad: improvements 2018-08-02 00:24:06 +02:00
Megamouse 27820f0371 cellMouse: improvements 2018-08-02 00:24:06 +02:00
Megamouse bff038f554 cellKb: improvements 2018-08-02 00:24:06 +02:00
Megamouse 6629983ca7 Fix alignment in KeyboardHandler.h 2018-08-02 00:24:06 +02:00
Megamouse 56a9966d69 VS: move keyboard_pad_handler to a better filter 2018-08-02 00:24:06 +02:00
Megamouse 8cb749110f RSX Overlay: fix set text 2018-07-30 20:58:41 +02:00
Megamouse 4f8b131e64 Qt/Emu: Fix RSX capture boot process 2018-07-29 13:31:09 +02:00
Megamouse 52e1a06f8c Qt: fix trophy table row selection 2018-07-29 13:31:09 +02:00
Megamouse d057c79733 RSX: use localtime_s instead of localtime 2018-07-28 23:10:45 +02:00
Megamouse f82739afb0 RSX: Add performance overlay colors to configs
use a string hex color code. Allowed string formats are:
#FFFFFF or #FFFFFFFF (or both without #)
2018-07-28 23:10:45 +02:00
Megamouse 2211e95e41 RSX/Qt: add the possibility to center the performance overlay 2018-07-28 23:10:45 +02:00
Megamouse 67aff85e8e RSX/Qt: Move rrc captures to captures dir 2018-07-28 23:10:45 +02:00
Megamouse bb8fa28521 RSX: add config settings for shader compilation hint positions 2018-07-28 23:10:45 +02:00
Megamouse eecb984689 RSX/Qt: add more performance overlay options to the gui 2018-07-28 23:10:45 +02:00
Megamouse 451d64407b Qt: fix gui settings options 2018-07-28 23:10:45 +02:00
Megamouse f8d396ac9e change rsx_capture filename 2018-07-28 23:10:45 +02:00
Megamouse 7788007cbd Qt: implement tty auto scroll 2018-07-28 23:10:45 +02:00
Megamouse ab84a67511 Loader: handle fs::file is Null fatal after decrypt self 2018-07-28 23:10:45 +02:00
Megamouse 3ed98be6cd Qt: format category maps. they were ugly af 2018-07-28 23:10:45 +02:00
Megamouse 50dd704f2b Qt: implement EnhanceSpinBox and EnhanceDoubleSpinBox 2018-07-28 23:10:45 +02:00
Megamouse 525c257c6a Qt: handle invalid entries in config files
and improve error handling in enhancements
2018-07-28 23:10:45 +02:00
Megamouse b0f464d110 Qt: fix initial deadzone label sizes 2018-07-27 19:56:56 +02:00
Megamouse 01d8c3f616 Qt: fix pad settings keyboard input 2018-07-27 19:56:56 +02:00
Megamouse e29ea61f7c Qt: fix user manager localusername and add textvalue to the inputdialog 2018-07-27 07:41:05 +02:00
Megamouse f84883223b Qt: add some hotkeys to some user account interactions 2018-07-27 07:41:05 +02:00
Megamouse c39bd490ba Qt: fix user manager directory scan 2018-07-27 07:41:05 +02:00
Megamouse 2f6957c9c8 Qt: minor user manager style changes 2018-07-27 07:41:05 +02:00
Megamouse 847da3951c Qt: fix user manager button behaviour 2018-07-27 07:41:05 +02:00
Megamouse b0b4998050 Qt: only ignore highlights on specified tables 2018-07-27 07:41:05 +02:00
Megamouse f6a3659a14 user_manager: megamouse fixes 4 2018-07-26 03:16:51 +04:00
Megamouse e58b7cbe1f user_manager: megamouse fixes 3 2018-07-26 03:16:51 +04:00
mpm11011 9ca8ec8ec7 user-manager: m_trophy_dir changed to lowercase. 2018-07-26 03:16:51 +04:00
Megamouse 622c8c2788 user_manager: megamouse fixes 2
(cherry picked from commit 89c7740df1b40095bfa715ff863056d5797b9f89)
2018-07-26 03:16:51 +04:00
Megamouse eef900ef41 user-manager: megamouse fixes
(cherry picked from commit 949807c1cc689e12e5f0cea367564306ea36a759)
2018-07-26 03:16:51 +04:00
mpm11011 68202eb2b7 user-manager: replacing fmt::format with string concat.
(cherry picked from commit 63379afc7a402edb2159912318281febc3e7438a)
2018-07-26 03:16:51 +04:00
mpm11011 948bd3673e user-manager: squash all commits for this feature. 2018-07-26 03:16:51 +04:00
scribam c5c0f68b3e ppu-precise: improve vaddsws and vadduws instructions 2018-07-22 19:53:28 +04:00
kd-11 19d808d378 rsx/gl: Minor cleanup and optimization
- Track register change status
- Remove unused gl classes
2018-07-22 17:19:59 +03:00
kd-11 8695f95267 rsx: Reimplement cached textures and their views 2018-07-22 17:19:59 +03:00
Megamouse 8b693ed7bb MMJOYSTICK: fix nullpointer crash in GetMMJOYDevice 2018-07-22 12:50:52 +02:00
Megamouse d13e71eeb8 Qt: merge pad settings 2018-07-22 12:50:52 +02:00
Megamouse 52bfe6d4fb Qt: remove obsolete and useless menu entry: "Show Game Tool Bar" 2018-07-22 12:50:52 +02:00
eladash 12b8908a00 cellvdec: stub unsupported video timebases 2018-07-21 15:32:38 +04:00
Nekotekina 9187911a29 Update LLVM
Fixes long pause/hang after loading PPU modules
2018-07-21 12:18:07 +03:00
Nekotekina 89fe3705a4 Remove cpu_translator::ucarry<> 2018-07-21 12:18:07 +03:00
Nekotekina 9b4e63df6d SPU LLVM: simplify CG, CGX, BG, BGX 2018-07-21 12:18:07 +03:00
Nekotekina 03e6725fcf PPU LLVM: simplify VMSUMUHS 2018-07-21 12:18:07 +03:00
Nekotekina d2d07abcc5 cellSaveData: print SECUREFILE secureId
This can help to decrypt savedata
2018-07-21 12:18:07 +03:00
John 6caffd0e32 Add a channel map to the PA backend to fix surround sound (#4911)
* Add a channel map to the PA backend to prevent issues with more than 6 channels

* Arranged the mapping per cellAudio.cpp
2018-07-21 03:02:07 +04:00
scribam 5828367013 spu-precise: fix double-precision floating-point exception checks 2018-07-20 15:22:14 +04:00
Megamouse 8bfe4c908c Qt: Add rrc capture replay per drag and drop 2018-07-19 22:37:27 +04:00
Megamouse 60a276e9ce Qt: allow bulk pkg installation 2018-07-19 22:37:27 +04:00
Megamouse 05c5763492 Fix Async Shader Tooltip 2018-07-19 22:37:27 +04:00
eladash 20e9ae069c Fix sys_time_get_current_time 2018-07-19 14:43:10 +04:00
Alex James 064d0619e8 VS: Fix QT deploy for paths with spaces 2018-07-18 15:32:01 +04:00
Megamouse a19113025c HLE/Qt: implement sys_tty_read 2018-07-16 00:05:30 +04:00
Megamouse 29270ed673 gitignore: completely ignore the game folders, some games use TEST12345
It wasn't working anyway.
Test-homebrews should be added by force in the future
2018-07-15 20:29:14 +04:00
Megamouse de693b0da1 Qt: handle upstream trolling 2018-07-15 20:29:14 +04:00
scribam 65d270e5d8 clang-tidy: performance-faster-string-find
https://clang.llvm.org/extra/clang-tidy/checks/performance-faster-string-find.html
2018-07-15 12:51:09 +04:00
scribam e18e6576f3 cmake: remove duplicated directive used to include cmake_modules 2018-07-15 12:51:09 +04:00
scribam b36d0fd59f clang: fix compilation on 3.6 2018-07-15 12:51:09 +04:00
scribam b09321354a clang: fix compilation on 3.7 2018-07-15 12:51:09 +04:00
scribam 4babe9076b clang: fix compilation on 3.8 2018-07-15 12:51:09 +04:00
kd-11 46abe0f315 vm: Fix memory mirror performance regression 2018-07-14 15:19:56 +03:00
kd-11 c35d0d16e7 vk: cleanup/optimization, remove unnecessary initialization code 2018-07-14 15:19:56 +03:00
kd-11 77e2af8c00 qt: Add async shaders toggle to the UI 2018-07-14 15:19:56 +03:00
kd-11 e7f30640ef rsx: Async shader compilation
- Defer compilation process to worker threads
- vulkan: Fixup for graphics_pipeline_state.
  Never use struct assignment operator on vk** structs due to padding after sType member (4 bytes)
2018-07-14 15:19:56 +03:00
eladash ac99fd764d mfc: clamp atomic cmd's addr 2018-07-14 01:40:40 +04:00
kd-11 fa55a8072c rsx: Improve vertex textures support
- Adds proper support for vertex textures, including dimensions other than 2D textures
- Minor analyser fixup, removes spurious 'analyser failed' errors
- Minor optimizations for program state tracking
2018-07-12 18:02:28 +03:00
kd-11 c5b2469fe7 silence warning 2018-07-12 18:02:28 +03:00
Ofek d3596fbc95 Change all hddFreeSizeKB to 40gb-1 2018-07-11 02:16:14 +04:00
eladash a5d4e58ddd fix barrier type mfc transfers 2018-07-10 14:54:51 +04:00
Chris Weermann (TGE) c5dcef52fa Implement sys_dbg_read_process_memory and sys_dbg_write_process_memory 2018-07-10 01:47:47 +04:00
kd-11 d266a25618 silence some annoying warnings 2018-07-09 13:06:00 +03:00
kd-11 1ddcad4fa4 facepalm
- Fix openGL regression
2018-07-09 13:06:00 +03:00
scribam 1fdc070e4e cmake: remove obsolete command for glslang integration 2018-07-09 03:33:05 +04:00
scribam 1b0f5b1ed9 spu: improve dfnma instruction 2018-07-09 03:33:05 +04:00
scribam 2ed6e51d24 ppu: improve vnmsubfp instruction 2018-07-09 03:33:05 +04:00
scribam 733efc6b0d ppu: improve fnmsubs instruction 2018-07-09 03:33:05 +04:00
scribam f1e6532ec0 ppu: improve fnmsub instruction 2018-07-09 03:33:05 +04:00
Megamouse 1c9769670c Qt: trophy repaint optimizations 2018-07-08 17:43:13 +04:00
Megamouse 0d72889c52 Qt: also repaint trophy game list background colors
And refactor a bit
2018-07-08 17:43:13 +04:00
kd-11 f0a9799b4b rsx/Qt: Fix Qt shader loading dialog crash 2018-07-07 16:20:33 +03:00
kd-11 4d40ed9dbd rsx: Silence harmless warning 2018-07-07 16:20:33 +03:00
kd-11 d78957d1cf rsx/vp: CodeGen improvements
- Fix double destination writes on conditional write masking
- Fix codegen to simplify simple scalar comparisons vs vector functions
2018-07-07 16:20:33 +03:00
kd-11 2c34195954 rsx/vp: Discard broken vertex programs with no writes to POS register 2018-07-07 16:20:33 +03:00
kd-11 2ca935a26b vp: Improve vertex program analyser
- Adds dead code elimination
- Fix absolute branch target addresses to take base address into account
- Patch branch targets relative to base address to improve hash matching
- Bumps shader cache version
- Enables shader logging option to write out vertex program binary,
  helpful when debugging problems.
2018-07-07 16:20:33 +03:00
kd-11 bd915bfebd rsx: vp decompiler fixes
- Fix program abort logic to never abort before resolving later label addresses
  Fixes jumping over broken code and jumping over END markers
- TEXTURE_CONTROL2 has indexing range of [0..15] without stride skipping!
  This register does not have interleaving with other texture registers
- Track shader address poke as it seems to invalidate programs as well
2018-07-07 16:20:33 +03:00
kd-11 66854b78fa rsx: Fix nv308a::color 2018-07-07 16:20:33 +03:00
Ofek dceba8a92b PPU analyser optimizations 2018-07-07 14:26:56 +04:00
Nekotekina d856dc89a8 SPU LLVM: combine SELB with comparison instructions
Turn bitwise select into a vector select
2018-07-06 02:26:18 +03:00
Nekotekina 2f0dc9bd0f PPU LLVM: simplify VSUBCUW, VSUBUBS, VSUBUHS, VSUBUWS 2018-07-06 00:33:52 +03:00
Nekotekina 9d9869e803 PPU LLVM: simplify VADDCUW, VADDUBS, VADDUHS, VADDUWS 2018-07-06 00:33:52 +03:00
Nekotekina caf827344f SPU LLVM: improve SHL, SHLH, ROTM, ROTHM instructions
Avoid zero extension, select undef result to zero
2018-07-06 00:33:52 +03:00
Nekotekina b9c026d441 SPU LLVM: improve ROTMA and ROTMAH instructions
Avoid sign extension, clamp shift amount with min op
2018-07-06 00:33:52 +03:00
Nekotekina 2b9fa7ed23 SPU LLVM: combine SHUFB with CWD-alike instructions
Turn SHUFB into a vector insert
2018-07-06 00:33:52 +03:00
Nekotekina 253e8b4466 SPU LLVM: improve SHUFB with constant mask 2018-07-06 00:33:52 +03:00
Nekotekina 622f2f7f66 SPU LLVM: constant computation fixes
Fixed instructions:
Gather Bits: GB, GBH, GBB
Form Select Mask: FSM, FSMH, FSMB
2018-07-06 00:33:52 +03:00
Nekotekina c959ab2698 SPU LLVM: fix constant propagation
Compute constant bitcasts
2018-07-06 00:33:52 +03:00
Nekotekina 20900ebea2 SPU: rename block stats
Use Block Weight and Retreats
2018-07-06 00:33:52 +03:00
Nekotekina a0c0d8b993 SPU: simplify unimplemented event check
Move checks closer to the actual use
2018-07-06 00:33:52 +03:00
Nekotekina afd5af04f6 SPU: improve analyser (v5)
Fix jumptable analysis
2018-07-06 00:33:52 +03:00
Nekotekina 712632d28a SPU LLVM: inline RDCH 2018-07-06 00:33:52 +03:00
Nekotekina c1385558ad SPU LLVM: inline RCHCNT 2018-07-06 00:33:52 +03:00
Nekotekina 0910acad42 SPU LLVM: clean NOP/LNOP
Add volatile to state check and update_pc()
2018-07-06 00:33:52 +03:00
Nekotekina 513bac0304 SPU LLVM: refactor halt instructions 2018-07-06 00:33:52 +03:00
Nekotekina a0bf103e8b Implement cpu_translator::pshufb<>()
Remove spu_translator::pshufb<>()
Improve PSHUFB emulation (pre-SSSE3)
Emit static shufflevector for the constant mask
PPU: Inline VPERM instruction
2018-07-06 00:33:52 +03:00
Nekotekina 41eab62ed7 Implement spu_iname helper
Remove old code
Report $SP anomalies
2018-07-06 00:33:52 +03:00
Nekotekina e009bbac10 Use LLVM 7 (master) 2018-07-06 00:33:52 +03:00
Nekotekina 1ac203a958 Funny workaround 2018-07-05 22:26:35 +03:00
Nekotekina c86dc133cf Rewrite cpu_translator::avg() 2018-07-05 22:26:35 +03:00
Nekotekina 8ad05ce10e SPU LLVM: fix jt target duplication bug 2018-07-05 22:26:35 +03:00
Nekotekina a999bccc03 SPU LLVM: use cpu_translator::build<> 2018-07-05 22:26:35 +03:00
Nekotekina ded9d1ddfd SPU LLVM: improve function type
Use pointers for args
Use noalias attribute
2018-07-05 22:26:35 +03:00
Nekotekina 88d0316aad Update cpu_translator
Add get_const_vector<v128>()
Add make_const_vector<v128>()
Add i2 and i4 types
Add build<>() for vector constants
Fix comparisons, allow EQ/NE for bool/char/i2/i4 types
2018-07-05 22:26:35 +03:00
Megamouse 6a62de6d68 Fix table headers for Qt 5.10 and below 2018-07-05 23:22:33 +04:00
Megamouse 544f8711f0 Qt: improve docks and toolbar flat style 2018-07-05 23:22:33 +04:00
Megamouse b9c9bb30ba Qt: fix toolbar element sizes on every toolbar repaint 2018-07-05 23:22:33 +04:00
Megamouse c69bb3ca04 Qt: Add Classic (Bright) Stylesheet 2018-07-05 23:22:33 +04:00
Megamouse e6d49798ce Qt: adjust custom stylesheets to work with the new toolbar slider 2018-07-05 23:22:33 +04:00
Megamouse 3a5ce90148 Qt: remove redundant custom toolbar colors.
They got too complicated when used with stylesheets. I left the gamelist icon color option since it does in no way interfere with the stylesheets
2018-07-05 23:22:33 +04:00
Megamouse 1270ee4b38 Qt: adjust table headers for Qt 5.11 2018-07-05 23:22:33 +04:00
Megamouse 62cec24235 Qt: update custom ui colors 2018-07-05 23:22:33 +04:00
Megamouse 124122839d Qt: update stylesheet 2018-07-05 23:22:33 +04:00
Megamouse 20d653b58a Qt: update table item delegates 2018-07-05 23:22:33 +04:00
Megamouse ed4caf0fbe Qt: fix icon repaint inaccuracy 2018-07-05 23:22:33 +04:00
Megamouse ff9024ae70 Qt: temporary game grid selection color adjustment 2018-07-05 23:22:33 +04:00
Megamouse 01dc09c436 Qt: Use QStyledItemDelegate instead of QItemDelegate 2018-07-05 23:22:33 +04:00
Megamouse 19514128e3 Qt: Fix style sheet edge case 2018-07-05 23:22:33 +04:00
Megamouse 23b10fc16d Qt: update default stylesheet (WIP) 2018-07-05 23:22:33 +04:00
Megamouse 4bddb6a9e3 Qt: update toolbar icons 2018-07-05 23:22:33 +04:00
Megamouse cb3933dcab Qt: toolbar adjustments 2018-07-05 23:22:33 +04:00
eladash 4db79c458d Fix cellSysCacheMount error checking 2018-07-05 16:36:57 +04:00
eladash 24699f0f96 Fix cellSysCacheClear 2018-07-05 16:36:57 +04:00
eladash 3b64e0fb3f Fix cache directory 2018-07-05 16:36:57 +04:00
Megamouse cd59bc3d6d bump appveyor Qt version to 5.11 2018-07-03 22:09:44 +01:00
Zion e2ee959ac8 Fix issues with AppImages and Mesa 18.1.1 and greater. Fixes #4509 (#4846) 2018-07-03 21:36:47 +01:00
isJuhn 3d8223fccc Fix LLVM STW reservation update 2018-07-02 15:19:50 +04:00
Ofek 5d3b0e7352 Fix cellGameDataCheckCreate2 (#4832)
* Fix cellGameDataCheckCreate2
2018-07-01 23:07:21 +01:00
Megamouse ca30131faa Qt: add new spu options to the settings dialog
Also rework the layout a bit.
We need to think about creating a firmware tab
2018-07-01 19:33:33 +04:00
Ryan Jarvis a545e23b00 White space and switch to .format() strings 2018-06-29 19:37:09 +01:00
eladash 345f92ab0a rsx: more efficient command reading 2018-06-27 21:59:34 +03:00
kd-11 42851a93d4 vk: Fixup 2018-06-26 20:07:20 +03:00
kd-11 24f4c92759 rsx: Improve texture cache read speculation 2018-06-26 20:07:20 +03:00
kd-11 c3d75e208f glslang: Bump to version 2776 2018-06-26 20:07:20 +03:00
kd-11 df2137781d vk: Strip 'stencil' MSB when writing d24x8 data
- Seems to contains garbage in MSB when DEPTH aspect is read back
- TODO: Implement custom depth and stencil readback routine
2018-06-26 20:07:20 +03:00
kd-11 1e375e5210 gl: Fixup 2018-06-26 20:07:20 +03:00
kd-11 1730708f47 rsx: Rework memory protection management for framebuffer access
- Avoid re-locking memory if there is no reason to do so (no draws issued)
- Actively bound regions should always get written to the backing cache
- Forcefully read memory during download if writes to the target have occured since last sync event
2018-06-26 20:07:20 +03:00
kd-11 bda65f93a6 vk: Tuning [WIP]
- Unroll main compute queue loop
- Do NOT run GPU cores on mappable memory! This has a dreadful impact on performance for obvious reasons
- Enable dynamic SSBO indexing (affects AMD)
- Make loop unrolling and loop length variable depending on hardware and find optimum
2018-06-26 20:07:20 +03:00
kd-11 d484253136 vk: Addendum - Synchronize graphics and compute pipelines with barriers 2018-06-26 20:07:20 +03:00
kd-11 5fb4009a07 vk; Add more compute routines to handle texture format conversions
- Implement le D24x8 to le D32 upload routine
- Implement endianness swapping and depth format conversions routines (readback)
2018-06-26 20:07:20 +03:00
kd-11 f45dcfe18a rsx: Fix texture readback
- gl: Fix up the calculation for internal image pitch
- vk: Implement GPU-side resizing for read back textures (fixes WCB zoom)
2018-06-26 20:07:20 +03:00
kd-11 278cb52f19 facepalm 2018-06-26 20:07:20 +03:00
scribam 3b8eab87dd cmake: add possibility to build zlib from submodule 2018-06-25 00:28:46 +04:00
eladash b9fd6ad37d rsx-capture: unbreak 2018-06-24 15:14:37 +03:00
Jake 00c9b323c2 rsx: fix image_in to use in_pitch when swizzling 2018-06-24 14:29:41 +04:00
Jake e2c288ff8a trophy: zero out data before setting 2018-06-24 14:29:41 +04:00
Jake edeb858138 loader: ignore invalid index_value and allow relative reloc 10 2018-06-24 14:29:41 +04:00
Jake 095d02e41b elf: handle decompress flag for 32 bit elfs 2018-06-24 14:29:41 +04:00
eladash b3a933ba84 cellgcm: fix regression 2018-06-24 10:57:30 +03:00
eladash b456955688 rsx: fix hardcoded rsx allocation address 2018-06-24 10:57:30 +03:00
scribam 3935cef691 pugixml: update submodule and build integration 2018-06-24 02:02:36 +04:00
isJuhn 83f096c435 Add conditional reservation update to STW 2018-06-23 23:13:34 +04:00
JohnHolmesII acd83673e9 Update readme library links 2018-06-23 20:09:32 +04:00
Nekotekina 6229b3ca8d Fixes for booting PS1 games 2018-06-23 17:30:16 +03:00
clienthax 8b449ce76c PS1 Classics 2018-06-23 16:34:19 +04:00
Nekotekina d62b0c88b0 Restore /dev_flash/ config 2018-06-23 09:26:11 +03:00
Nekotekina cd92d9bcdf Fix SPU ASMJIT for SSE2 CPUs 2018-06-23 08:46:50 +03:00
Nekotekina b0cc1cf472 Update LLVM commit 2018-06-23 08:45:56 +03:00
Megamouse 78ef205b4f Qt: fix minor bug in save_manager that occurred when sorting the tables 2018-06-22 22:30:02 +04:00
Megamouse 4464951c77 cellVdec: add more detail to the logging 2018-06-22 22:30:02 +04:00
Megamouse 64c04769d2 Qt: emu_settings: close config files after loading and saving 2018-06-22 22:30:02 +04:00
Megamouse dada341d4e Qt: fix crash in progress dialog 2018-06-22 22:30:02 +04:00
Megamouse a96a8a9db0 Qt: move ReadJSON in game compat to its own function 2018-06-22 22:30:02 +04:00
Megamouse dab82b70f7 Qt: workaround for settings_dialog resize 2018-06-22 22:30:02 +04:00
Megamouse c3916fee9c Qt: add DeleteSPUCache option 2018-06-22 22:30:02 +04:00
Megamouse e7a02f1506 Qt: use QDirIterator instead of fs::file stuff 2018-06-22 22:30:02 +04:00
Megamouse 68bb1bd6ee Qt: add more resize possibilities to the trophy manager 2018-06-22 22:30:02 +04:00
Megamouse cad017a64f Qt: minor icon size action fix 2018-06-22 22:30:02 +04:00
Nekotekina 81e5f3b7f2 Remove /dev_flash/ configuration
Simplify code by using root config location for /dev_flash/
Hide Emu.GetEmuDir() function due to the risk of misuse
2018-06-22 14:14:29 +03:00
Nekotekina e4da284176 SPU: analyser v4 and fixes
Build SPU cache after PPU, fix mixing progress
SPU ASMJIT: add support for Giga mode
SPU ASMJIT: use the same spu.log location as SPU LLVM
SPU: improve spu.log disasm
SPU: improve trampolines, unify with SPU ASMJIT
SPU: decode interrupt handler address from BR/BRA at 0x0
SPU LLVM: support Mega/Giga modes
SPU LLVM: implement function chunks
SPU LLVM: use PHI nodes, value visibility across basic blocks
SPU LLVM: implement function chunk table
New simple memory manager for LLVM (bugfix)
2018-06-21 22:29:34 +03:00
eladash 3e433ef05c create the shaderlog dir in Emu.Init() 2018-06-21 22:54:08 +04:00
kd-11 8f1c36d79f rsx: Fix region pitch inaccuracy
- Region pitch of 64 (disabled) can be used to indicate packed contents - do not assume it is the actual pitch!
- Also fixes interaction of AA factors with lockable_region size
2018-06-21 13:08:50 +03:00
Jan Beich c776ff5020 Add missing Discord guard after 27a94308a7
/usr/bin/ld: error: undefined symbol: Discord_Initialize
>>> referenced by _discord_utils.cpp
>>>               rpcs3/CMakeFiles/rpcs3.dir/rpcs3qt/_discord_utils.cpp.o:(discord::initialize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&))

/usr/bin/ld: error: undefined symbol: Discord_Shutdown
>>> referenced by _discord_utils.cpp
>>>               rpcs3/CMakeFiles/rpcs3.dir/rpcs3qt/_discord_utils.cpp.o:(discord::shutdown())

/usr/bin/ld: error: undefined symbol: Discord_UpdatePresence
>>> referenced by _discord_utils.cpp
>>>               rpcs3/CMakeFiles/rpcs3.dir/rpcs3qt/_discord_utils.cpp.o:(discord::update_presence(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool))
c++: error: linker command failed with exit code 1 (use -v to see invocation)
2018-06-21 01:07:05 +01:00
Megamouse 0ffaf6c1ce Qt/RSX: reset gs_frame taskbar progr. when closing native progr. dialogs
I forgot that the gs_frame's taskbar progress will stay unchanged due to its persistence, unlike the msgdialog.
2018-06-19 21:58:09 +03:00
Megamouse 4419e5d838 Qt: add possibility to copy 'Name [Serial]' 2018-06-19 20:45:00 +04:00
Megamouse 27a94308a7 Discord fixes 2018-06-19 20:45:00 +04:00
Megamouse 0c4cdaa7d3 Qt: add boot by pressing enter or return while having an item selected 2018-06-19 17:13:08 +03:00
Zion Nimchuk 87194e5887 Make register editor dialog work 2018-06-19 14:06:26 +03:00
VelocityRa 392a4bdc0b Qt: Add perf overlay position to settings dialog 2018-06-18 22:34:26 +03:00
VelocityRa dd0684b58a overlays/perf_overlay: Make pos, font, opacity, margin configurable
- Also some perf overlay refactoring
2018-06-18 22:34:26 +03:00
VelocityRa 58f4b26134 overlays: Consider padding when auto-resizing label elements
- Also make auto_resize return whether it changed the size
2018-06-18 22:34:26 +03:00
VelocityRa 84d1cf5065 overlays: Change how padding and margin work
- Also add 3 helper functions to compiled_resource
2018-06-18 22:34:26 +03:00
VelocityRa 07731d0228 overlays: Fix text rendering position
- It should be offset by one line, not half
- Also tweak every overlay element affected by this
  to look as it used to
2018-06-18 22:34:26 +03:00
VelocityRa 44449dd9e9 overlays: Refactoring
- Use names for overlay command config and vertex data instead of std::pair.
- Make a couple of compiled_resource constructors explicitly named functions.
2018-06-18 22:34:26 +03:00
VelocityRa 9d431e77a4 Utilities/geometry: Add unsigned specializations to typedefs 2018-06-18 22:34:26 +03:00
kd-11 c60f7b89ba vk: Implement safe typeless transfer
- Used to transfer D32S8 data where it makes sense to use this variant
 - On nvidia cards, it is very slow to move aspects from D24S8 probably due to the format being faked.
   For this reason, the unsafe variant is used for both D16 and D24S8 to avoid the heavy performance loss
2018-06-18 17:32:22 +03:00
kd-11 0d61bae1b9 vk: Performance fix for RADV
- RADV does not keep a mapping ptr around for subsequent remap and falls back to heavy amdgpu methods every time
  Explicitly manage pointer in the ring buffer structure to fix this
2018-06-18 17:32:22 +03:00
kd-11 d77e62c94e rsx: Improve GPU resource read prediction 2018-06-18 17:32:22 +03:00
kd-11 2afcf369ec vk: Add synchronous compute pipelines
- Compute is now used to assist in some parts of blit operations, since there are no format conversions with vulkan like OGL does
- TODO: Integrate this into all types of GPU memory conversion operations instead of downloading to CPU then converting
2018-06-18 17:32:22 +03:00
kd-11 0d5c071eee vk: Implement typeless image transport 2018-06-18 17:32:22 +03:00
kd-11 dd4c13b625 rsx: Avoid race conditions in unsynchronized unprotect 2018-06-18 17:32:22 +03:00
eladash af62c92b7f mfc: clamp list transfer size 2018-06-17 23:20:00 +04:00
Megamouse af71cf0922 implement "Enable TSX" combobox 2018-06-17 00:43:00 +04:00
Ofek 2bc4cb4e58 Fix sys_spu_thread_connect event 2018-06-16 19:05:51 +04:00
Zangetsu38 b2a4e759fc Fix temp file folder for project pnglibconf and zlib.
Delete win32 config in Project not needed.
Clean bin folder.
2018-06-16 14:54:04 +04:00
scribam 903da117e5 zlib.vcxproj: remove PreprocessorDefinitions "Z_SOLO" 2018-06-14 22:42:04 +01:00
scribam 9f420081fd libpng: use official repository instead of the fork from RPCS3 and update submodule 2018-06-14 21:55:39 +04:00
Megamouse ddded7ba5c Qt: cleanup syntax_highlighter a bit 2018-06-14 18:35:21 +04:00
Megamouse 79dd62cda2 Qt: Add copy to clipboard for game data 2018-06-14 18:35:21 +04:00
Megamouse d013524ea9 Qt: add notes as tooltips 2018-06-14 18:35:21 +04:00
Megamouse 61a517cc1a Qt: don't adjust columns in case of empty results after filtering 2018-06-14 18:35:21 +04:00
Megamouse fddd39d508 Qt: rename some members in game_list_frame to use m_ 2018-06-14 18:35:21 +04:00
Megamouse 661d19e33f Qt: fix settings dialog subscriptions for custom configs 2018-06-14 18:35:21 +04:00
Ivan 21a7f1a550 Merge pull request #4748 from scribam/asmjit
asmjit: update build integration
2018-06-14 16:30:13 +04:00
scribam 6f3a63df94 fix compiler warning "-Winconsistent-missing-override" 2018-06-13 20:22:53 +02:00
scribam 968f3995ff Merge branch 'master' into asmjit 2018-06-13 09:27:12 +02:00
Talkashie f491dc1413 Update System.h 2018-06-13 10:00:32 +03:00
scribam 14dc1fead6 yaml-cpp: update submodule and build integration 2018-06-13 04:25:34 +04:00
scribam ea8397fbab cmake: don't use hardcoded lib names when using system ffmpeg and remove unneeded line 2018-06-12 22:28:30 +02:00
scribam 3a9778668a asmjit: update build integration 2018-06-12 20:03:53 +02:00
Zion Nimchuk 4db0cf005b Enable wayland for AppImages 2018-06-12 16:51:26 +01:00
Zion Nimchuk 67a6db8325 Prefer GLVND for OpenGL rather than legacy 2018-06-12 16:51:26 +01:00
Zion 09c8162235 evdev: Add nullptr check, fixes #4713 (#4744) 2018-06-12 16:12:37 +01:00
scribam cc22d25490 qt: fix asm instructions highlighting (#4745)
* qt: fix asm instructions highlighting
2018-06-12 15:38:19 +01:00
Nekotekina 88b6d51643 Fix cellGameContentPermit 2018-06-12 02:09:22 +03:00
Nekotekina eb081bbcfa SPU: add 'Accurate PUTLLUC' option
Effectively rollback previous PUTLLUC accuracy commit by default
Minor changes in GETLLAR/PUTLLUC transactions
2018-06-12 02:09:22 +03:00
Nekotekina 0a58464f01 SPU ASMJIT: returnable STOP in Mega mode
Fix STOP, STOPD, SYNC, DSYNC in Safe mode
2018-06-12 02:09:22 +03:00
scribam 626836f95b qt: rewrite syntax highlighter
- fix multi-line comments
- remove compilation warnings "unknown escape sequence"
- fewer lines of code
2018-06-12 02:49:58 +04:00
Megamouse a8f19fbfae RSX: fix shader cache progress bar exit state shenanigans 2018-06-11 22:41:38 +03:00
Megamouse 2b8cab906c Qt: clamp progress bar values 2018-06-11 22:41:38 +03:00
isJuhn 88bfdb0c05 cellGameContentPermit: Don't set content and usrdir path on gamedata if cellGameCreateGameData was never called 2018-06-11 21:48:29 +04:00
Megamouse 3dd45fc859 Qt: add counters to the find dialog 2018-06-11 16:24:51 +03:00
jjsat 53ca2526ed Fix VSLO and VSRO in the LLVM PPU recompiler 2018-06-10 20:12:40 +04:00
scribam db9a6113d7 3rdparty: update stb_image.h and stb_truetype.h 2018-06-09 11:06:55 +03:00
Megamouse 5454f57dd0 cellSaveData: handle fatal error fs::file is_null (read-only files) 2018-06-08 23:41:56 +03:00
Megamouse 4003aacc6a RSX: add taskbar progress to native ui progress dialogs 2018-06-08 23:41:56 +03:00
Megamouse 17250bc2d4 Qt: set up taskbar progress for the gs_frame 2018-06-08 23:41:56 +03:00
Megamouse b9b6bd85a6 Qt/RSX: add taskbar progress in msg_dialog_frame for shader compilation 2018-06-08 23:41:56 +03:00
Megamouse edc9e9b4ec Qt/RSX: add window title to the shader compilation msg_dialog 2018-06-08 23:41:56 +03:00
Megamouse 7aa2cddb05 Qt: remove multi message dialog code 2018-06-08 23:41:56 +03:00
Megamouse 38e88253cc Qt: Fix message dialog progress bars never reaching 100%
and clean up a bit
2018-06-08 23:41:56 +03:00
kd-11 da9affb348 vk: Fix overlays for variable sampler count 2018-06-08 22:17:50 +03:00
kd-11 00eaf39c01 vk: RADV support for depth scaling and transfer 2018-06-08 22:17:50 +03:00
kd-11 63f803b68a Refactoring
- Make the memory allocator a unique child of the render device.
  Fixes object lifetime issues with swapchain management due to cyclic dependencies
2018-06-08 22:17:50 +03:00
kd-11 c9e367befd rsx/debug: Fix rendering when FIFO reordering is disabled 2018-06-08 22:17:50 +03:00
kd-11 1c5667f0ce vk: Avoid use-after-free fence object 2018-06-08 22:17:50 +03:00
kd-11 e9c3ab7ae6 fix some linux issues
- Fix build
- Fix VMA incompatibility with swapchain_NATIVE
2018-06-08 22:17:50 +03:00
kd-11 1b9c9267f0 rsx: Update memory flags after memory transfer 2018-06-08 22:17:50 +03:00
kd-11 fc18e17ba6 vk: Implement depth scaling using hardware blit/copy engines
- Removes the old depth scaling using an overlay.
  It was never going to work properly due to per-pixel stencil writes being unavailable
- TODO: Preserve stencil buffer during ARGB8->D32S8 shader conversion pass
2018-06-08 22:17:50 +03:00
kd-11 3150619320 rsx: Preserve read AA state separate from write AA state
- Some applications (e.g Backbreaker) use an evil hack to resolve MSAA.
  The application respecifies a formerly AA region as a region with no AA then performs a framebuffer feedback lookup.
  The old memory keeps AA during read, but writes back to itself with AA resolved.
  This is evil on several levels but it just happens to work on PS3
2018-06-08 22:17:50 +03:00
kd-11 0f24379c0e rsx: Obey MSAA resolve during memory persistence transfer
- Ugh. This is a bandaid on a festering wound, AA badly needs a rewrite

 Also silence some warnings
2018-06-08 22:17:50 +03:00
Daniel Valentine fb20c27e7b Delay GDB server launch until emulator run (#4658) 2018-06-08 13:34:27 +01:00
Zion Nimchuk 7b5dcd9d6a Deploy binaries to RPCS3/rpcs3-binaries-win 2018-06-08 05:10:56 +01:00
isJuhn dde4a9c6e7 Fix cellGameCreateGameData temporary path 2018-06-06 23:51:58 +04:00
ikki84 73f7ab29bc Return offline according to g_psn_connection_status. 2018-06-06 19:14:12 +04:00
ikki84 83b09cf047 sceNpManagerRequestTicket2 (return offline)
Returning CELL_OK in sceNpManagerRequestTicket2 makes NPEB01268 loop indefinitely trying to check the downloaded content.
Telling that the system is offline escapes the loop and make the game go further.
Moves NPEB01268/BLES01794 from Intro to Ingame.
2018-06-06 19:14:12 +04:00
scribam 824ad4fea7 cmake: simplify glslang integration (#4652)
* cmake: simplify glslang integration

* Fix warning (ignored attributes), part 2
2018-06-06 15:45:28 +03:00
Nekotekina 5c9d0e4b46 Add "SPU Cache" option
If disabled, the cache will still be loaded, but never updated.
2018-06-05 12:35:26 +03:00
Nekotekina 5d4c5ecc1c Add "SPU Verification" option
Should be always enabled
2018-06-05 12:35:26 +03:00
Nekotekina 12eee6a19e SPU ASMJIT: Implement Mega block mode (experimental)
Disable extra modes for SPU LLVM for now.
In Mega mode, SPU Analyser tries to determine complete functions.
Recompiler tries to speed up returns via 'stack mirror'.
2018-06-05 12:35:26 +03:00
Nekotekina 11bdb4102a SPU LLVM: implement returnable check_state()
Call it only at the beginning of loop entries
2018-06-05 12:35:26 +03:00
Nekotekina df489d786a sys_timer_usleep: give Linux a partial exemption 2018-06-05 12:35:26 +03:00
Nekotekina ec6d1fb1ba SPU: optimize GETLLAR (TSX)
Add an option "Accurate GETLLAR"
2018-06-05 12:35:26 +03:00
Nekotekina a5f4e6ecef SPU: fix PUTLLUC accuracy 2018-06-04 16:01:17 +03:00
Nekotekina 9fe03a94d8 SPU ASMJIT: implement returnable check_state() 2018-06-04 16:01:17 +03:00
Nekotekina 7242387a42 Block GUI after stopping emulation
This is necessary to prevent restarting the emulation until it's finished
Remove "process_events" callback completely
2018-06-04 16:01:17 +03:00
Nekotekina 1e107487da SPU: improve analyser (v3) 2018-06-04 16:01:17 +03:00
Nekotekina 05e24f38f9 SPU: use progress dialog 2018-06-04 16:01:17 +03:00
Zion Nimchuk ea1bb3b90e Convert all spaces to tabs in CMakeLists.txt 2018-06-04 17:00:44 +04:00
Zion Nimchuk 4d3b60cf46 Unify Linux detection in CMake 2018-06-04 17:00:44 +04:00
Alex James 311cd0ce76 Add additional Fedora dependencies
These are needed for evdev controllers and ALSA support.
2018-06-04 14:55:00 +04:00
Jake 84ae643692 Fix msvc debug build 2018-06-03 16:37:37 +04:00
Megamouse 9dea602496 Discord: add some stuff 2018-06-03 13:28:12 +04:00
JohnHolmesII 39e3fb4638 Update Arch install directions, and other touchups 2018-06-03 00:35:25 +04:00
Zion dcd7f442fa appveyor: Fixes #4682 (#4685)
Only rename a build to master versioning if it succeeds
2018-06-01 18:36:34 +01:00
Dravonic 400079a006 Parallel shader cache loading (#4677)
* Parallel shader cache loading
2018-06-01 19:49:29 +03:00
kd-11 87b510d5bf vulkan improvements
- Remove deprecated device layers
- Reimplement overlays resource management using real heap instead of using first_vertex hack
2018-05-31 11:22:40 +03:00
kd-11 9f9e1b5fe0 overlay; Fix leak 2018-05-31 11:22:40 +03:00
Nekotekina b0ee369135 Rewrite LLVM compilation progress dialog
Use a single dialog
2018-05-30 20:35:35 +03:00
Nekotekina a2253e840f SPU LLVM: fix *QBI instructions (UB)
Improve codegen at the cost of unnecessary shuffle, use u64[2]
2018-05-30 20:35:35 +03:00
Nekotekina 37577714fa SPU LLVM: emulate PSHUFB
For targets without SSSE3 support
2018-05-30 20:35:35 +03:00
Nekotekina 759370ea1b SPU: rewrite FSM/FSMH/FSMB instructions
Remove lookup tables
2018-05-30 20:35:35 +03:00
Nekotekina 55e9d437a9 Fix warning (ignored attributes) 2018-05-30 20:35:35 +03:00
Nekotekina bdf6545571 SPU: rewrite spu_interpreter::SHUFB
Use ASMJIT to generate SSSE3+ code at runtime
Remove static SSSE3 code from spu_interpreter
2018-05-30 20:35:35 +03:00
Nekotekina bebb1bdeda Extend ppu_decoder/spu_decoder templates
Automatically dereference pointers
2018-05-30 20:35:35 +03:00
Nekotekina 1193ab0b89 Use memfd_create (Linux) 2018-05-30 20:35:35 +03:00
Nekotekina 944e89058e SPU: improve SHUFB 2018-05-30 20:35:35 +03:00
Megamouse c5709f71b3 Qt: Add performance overlay options to the emu tab in the settings dialog 2018-05-30 21:31:45 +04:00
Megamouse cc50d503ef Qt: Add a gui tab to the settings dialog
this is mainly to make place in the emulator tab
2018-05-30 21:31:45 +04:00
kd-11 cf2cb7978b facepalm 2018-05-30 13:30:23 +03:00
kd-11 f543fb0243 vk/gl: Fix flush synchronization to be kinder to weaker CPUs but not harm higher end CPUs 2018-05-30 13:30:23 +03:00
kd-11 6362942928 rsx: Avoid semaphore acquire deadlock 2018-05-30 13:30:23 +03:00
Jan Beich 3d632a3774 CPUStats: add support for macOS and BSDs 2018-05-30 12:35:41 +03:00
VelocityRa c8d8a81ccd overlays: Performance Overlay 2018-05-30 12:35:41 +03:00
VelocityRa c2e17d04e1 overlays: Font improvements
* Support for using arbitrary firmware fonts
* Support for specifying font extension in `font` constructor (useful for most firmware fonts that use .TTF)
2018-05-30 12:35:41 +03:00
VelocityRa 33b01d9306 overlays: Allow for non-interactable UI components
* Also fix a few warnings in overlay_controls
2018-05-30 12:35:41 +03:00
VelocityRa 8981227644 util/thread_ctrl: Method for measuring cycles a thread has run for
Also add a getter for the native thread handle.
2018-05-30 12:35:41 +03:00
VelocityRa 5defa9c7b0 util: Class for getting overall CPU usage and thread count 2018-05-30 12:35:41 +03:00
eladash 4576a31f47 fix memory mapping alignment 2018-05-30 00:34:38 +04:00
eladash 8826948c43 cellgcm: implement cellGcmTerminate 2018-05-29 19:57:28 +03:00
eladash 23b380eb41 allow deallocations to unmap rsx mapped memory 2018-05-29 19:57:28 +03:00
eladash ce98c962f8 cellgcm: use offset table to get the corresponding address to io address 2018-05-29 19:57:28 +03:00
eladash c2b2dee56d cellgcm/sys_rsx: fix multiple io maps at the same effective address and vice verse
from hw testing, as long as the io address is valid, it returns CELL_OK, even when it doesn't make much sense
2018-05-29 19:57:28 +03:00
eladash 97515a0941 sys_rsx/cellgcm: return EINVAL if the io map requast's size is 0 2018-05-29 19:57:28 +03:00
eladash 0a7902d313 sys_rsx: fix mem_handle id 2018-05-29 19:57:28 +03:00
eladash 8eab9fe36c sys_rsx: fix unused pointer dereferencing 2018-05-29 19:57:28 +03:00
kd-11 824340363d disable thread scheduler on intel 2018-05-29 13:54:30 +03:00
kd-11 d48f391b41 lv2: Ease the pain of lower end CPUs
- Avoid busy waiting in usleep code as much as possible, instead yield
- Also avoid busy_wait for SPU concurrency choker
2018-05-29 13:54:30 +03:00
kd-11 83f9be2524 rsx: Promote FIFO optimizations outside of strict mode
- The benefits of FIFO optimizations are huge in some cases.
  The optimizations also do not break any tested applications so no need to disable with strict mode
- A debug option is provided to disable this behaviour for testing
2018-05-29 13:54:30 +03:00
kd-11 be13a776f4 lv2: Reimplement sys_timer_usleep
- Matches ps3 accuracy for all tested values with few exceptions
- Do not enter the host OS kernel if waiting for less than 500us to avoid scheduler issues
2018-05-29 13:54:30 +03:00
kd-11 2adb2ebb00 overlays: Avoid race condition on remove-on-update views
- Improves cleanup code to consist of 2 parts, remove then dispose. Remove
  does not deallocate the item until dispose is called on it, allowing the
  backends to first deallocate external references.
- Caller is responsible for managing list locking and tracking disposable list
  of items when external references have been cleaned up before using
  dispose method.
2018-05-29 13:54:30 +03:00
Roberto Anić Banić 2bfafe4b0d Add SHA256 hash verification
Amended 3 times because of my stupidity...
2018-05-25 16:56:42 +04:00
Roberto Anić Banić fed94e3823 Vulkan SDK Mirror
Setup Mirror for Vulkan SDK executable.
Let's not be assholes and append ?Human=True to the link cause we might get ourselves put on a blacklist if we keeep using it after the requirement stops.
If the mirror is down it will fail back to lunar cdn.
2018-05-25 16:56:42 +04:00
Jan Beich c09c792636 GPUOpen: drop bogus include
GNU libc and musl have aligned_alloc() in <stdlib.h> while on BSDs
<malloc.h> shouldn't be used.

In file included from rpcs3/Emu/RSX/VK/VKMemAlloc.cpp:2:
In file included from rpcs3/../3rdparty/GPUOpen/include/vk_mem_alloc.h:2233:
/usr/include/malloc.h:3:2: error: "<malloc.h> has been replaced by <stdlib.h>"
 #error "<malloc.h> has been replaced by <stdlib.h>"
  ^
2018-05-24 20:00:35 +04:00
kd-11 0fc67aa2f6 gl: fix wcb regression
- Partial framebuffers and blit targets are possible!
2018-05-24 10:36:04 +03:00
kd-11 493d4e8613 fixup - Improve invalidated region checks for performance 2018-05-24 10:36:04 +03:00
kd-11 b030d1900c rsx: Fixup - fix broken memory protection fail caused by region respec
- Some applications will alternate memory between framebuffer and texture data
2018-05-24 10:36:04 +03:00
kd-11 f38f61d110 vk: Clean up memory allocation and fix GPUOpen VMA for Radeon 2018-05-23 19:07:08 +03:00
kd-11 92b5a705d8 fixup - locking 2018-05-23 19:07:08 +03:00
kd-11 b957eac6e8 rsx: Avoid calling any blocking callbacks from threads that are not rsx::thread
- Defers on_notity_memory_unmapped to only run from within rsx context
- Avoids passive_lock + writer_lock deadlock
2018-05-23 19:07:08 +03:00
kd-11 d2bf04796f Optimized cached write-through
- Allows grabbing an unsynchronized memory block if overwriting contents
anyway
- Allows flushing only specified range of memory
2018-05-23 19:07:08 +03:00
kd-11 f8d999b384 fixup - range check 2018-05-23 19:07:08 +03:00
kd-11 fbf6581249 rsx: Fix segmented memory access for rsx::super_ptr 2018-05-23 19:07:08 +03:00
kd-11 d283200e13 vk: Do not do extension test if in a fast context (enum only) 2018-05-23 19:07:08 +03:00
kd-11 3f14bc6961 rsx: Silence some meaningless error 2018-05-23 19:07:08 +03:00
kd-11 f2a3167193 rsx: Lower format compatibility severity since it confuses some people 2018-05-23 19:07:08 +03:00
kd-11 8fcd5c1e5a rsx: Texture cache fixes
1. rsx: Rework section synchronization using the new memory mirrors
2. rsx: Tweaks
    - Simplify peeking into the current rsx::thread instance.
      Use a simple rsx::get_current_renderer instead of asking fxm for the same
    - Fix global rsx super memory shm block management
3. rsx: Improve memory validation. test_framebuffer() and
tag_framebuffer() are simplified due to mirror support
4. rsx: Only write back confirmed memory range to avoid overapproximation errors in blit engine
5. rsx: Explicitly mark clobbered flushable sections as dirty to have them
removed
6. rsx: Cumulative fixes
    - Reimplement rsx::buffered_section management routines
    - blit engine subsections are not hit-tested against confirmed/committed memory range
      Not all applications are 'honest' about region bounds, making the real cpu range useless for blit ops
2018-05-23 19:07:08 +03:00
pauls-gh f8a0be8c3e Performance enhancement - Vulkan memory allocator (#4635)
* Incorporates the vulkan memory allocator from the AMD GPUOpen project
2018-05-23 17:02:35 +03:00
Nekotekina 00f5335895 Add Human=true in appveyor.yml 2018-05-23 15:36:29 +03:00
Nekotekina c5d8d50908 Move SPU LLVM log file 2018-05-23 15:36:29 +03:00
Nekotekina 3e580afe21 SPU: remove passive lock (fixup) 2018-05-23 15:36:29 +03:00
scribam 2270b8d15c vulkan: link with vulkan-1.lib instead of VKstatic.1.lib 2018-05-23 13:54:27 +03:00
Megamouse b230b0df0d Qt: Workaround for yet another hidden column resize 2018-05-22 16:27:33 +01:00
Megamouse 62efe6e5be Qt: set smaller default log frame height 2018-05-22 16:27:33 +01:00
Megamouse 7c031c2330 Qt: remove redundant visibility check in FixNarrowColumns 2018-05-22 16:27:33 +01:00
Megamouse 40d2341ef1 Qt: resize game list columns by default with slight spacing 2018-05-22 16:27:33 +01:00
Megamouse f1670a9ea0 Qt: disable resizing trophy tables to contents by default 2018-05-22 16:27:33 +01:00
Megamouse 325048a134 Qt: apply header states after populating the tables 2018-05-22 16:27:33 +01:00
Megamouse bff9a06f9f Qt: simplify occasions of restoreState 2018-05-22 16:27:33 +01:00
Megamouse 31101b4828 Qt: use correct menu icon for "Play last played game" on booting RPCS3 2018-05-22 16:27:33 +01:00
Megamouse 598008868e Qt: include QButtonGroup in settings_dialog.cpp in order to fix Qt 5.11 2018-05-22 16:27:33 +01:00
Nekotekina 72574b11ff SPU: use reservation spinlocks on writes (non-TSX)
This should decrease contention by avoiding global lock
2018-05-21 21:56:14 +03:00
Nekotekina 182259e4a5 cellSaveData fix 2018-05-21 21:47:04 +03:00
kd-11 c9669818eb Facepalm
- overlays: Do not free self handle!!!!
2018-05-21 15:55:25 +03:00
Nekotekina 6fd402bcf8 Transactions: drop RDTSC usage
Use simple increment (minor optimization)
2018-05-21 00:18:37 +03:00
Nekotekina fb0f5f0c8b Fix vm::reservation_notifier 2018-05-21 00:18:37 +03:00
Nekotekina 7a6db3dd7e spu_getll_tx: diagnose loop count 2018-05-21 00:18:37 +03:00
Nekotekina 295f782b30 spu_putlluc_tx: diagnose loop count 2018-05-21 00:18:37 +03:00
Nekotekina a33f297315 Replace notifier::lock_shared() with try_lock_shared()
Also add notify_one(), try_lock() and unlock()
Move some code in cond.cpp
2018-05-21 00:18:37 +03:00
Nekotekina 8d5bbfb850 Update SPU dump: print current MFC cmd 2018-05-21 00:18:37 +03:00
Nekotekina 33a1c743a4 Transactions: move loops inside
Rewrite loops in assembler (minor optimization)
2018-05-21 00:18:37 +03:00
kd-11 f6f45b8699 Native UI refactored (#4623)
Refactor and improve native overlays
2018-05-20 23:05:00 +03:00
Megamouse 68fff54a8b cellSaveData: don't return after funcStat was successful in savedata_op
also add some missing constants
2018-05-20 23:16:11 +04:00
Megamouse c61049b76f Qt: Fix missing rows in our beloved trophy manager 2018-05-20 14:29:56 +04:00
Megamouse f8bbdc39c5 Qt: Change Trophy Manager to use item selection instead of double click 2018-05-20 14:29:56 +04:00
Megamouse 4c03348e60 Qt: Restrict trophy manager combo box size 2018-05-20 14:29:56 +04:00
VelocityRa 05efa7d957 build: Add xxHash as an emucore dependency (fixes Windows build)
Previously needed to manually build the xxhash project before emucore (linker error)
2018-05-20 03:03:24 +01:00
Megamouse e1c9d8cb59 gitignore: also ignore .dat files and KD-11's weird backups 2018-05-19 21:59:13 +01:00
Megamouse 95951c31f8 Qt: Fix obnoxious glitch where game list columns ended up with 0 width
Qt can be messy at times
2018-05-19 21:59:13 +01:00
Megamouse 67637dfaa4 Qt: Fix compat download exception 2018-05-19 21:59:13 +01:00
scribam bf2f00a163 log: add Vulkan header version 2018-05-19 10:59:10 +03:00
scribam 6c5c89a4a3 3rdparty: remove Vulkan/Vulkan-LoaderAndValidationLayers 2018-05-19 10:59:10 +03:00
Megamouse 4e8ce7fac0 Qt: Enable all play options for the last played game on StartUp
- main_window::CreateThumbnailToolbar into main_window::Init
- also moved the log message for "Recent Game Not Valid" from Error to Warning (only the common occurance)
2018-05-18 21:30:16 +01:00
Megamouse 6b3eebc907 Qt: trophy manager - fix trophy sorting by ID + handle some warnings 2018-05-18 23:17:10 +04:00
Megamouse 9269d8a370 Qt: resize initial game list headers to minimal size if necessary
we do this on showing columns already
2018-05-18 23:17:10 +04:00
Megamouse 99c52a0d0c Qt: use column names instead of numbers in gui_settings 2018-05-18 23:17:10 +04:00
Megamouse d1a9afbd67 Qt: refactor game list column initialization 2018-05-18 23:17:10 +04:00
Megamouse 2b8f96dcec Qt: refactor Get-/SetGamelistColVisibility 2018-05-18 23:17:10 +04:00
Megamouse 9c025be831 Qt: improve game list header behavior 2018-05-18 23:17:10 +04:00
Megamouse aee03114fd Qt: rsx debugger replace wrong setSectionResize command 2018-05-18 23:17:10 +04:00
Megamouse bb8e89f84a Qt: add game icons to the trophy manager
and fix some header behaviour
2018-05-18 23:17:10 +04:00
Megamouse 6f0bad34f4 Qt: remove trophy_tree_widget_item.h 2018-05-18 23:17:10 +04:00
Megamouse d275c36e0a Qt: trophy manager overhaul 2018-05-18 23:17:10 +04:00
Megamouse 4e5cceb03e TROPUSR: add GetUnlockedTrophiesCount() 2018-05-18 23:17:10 +04:00
Nekotekina 67391322f4 Transactions: touch memory only after a failure
Minor optimization
2018-05-17 22:19:26 +03:00
Nekotekina 0b1c8bc676 Change retire strategy in cond_variable::imp_wait (WIN32)
Instead of waiting infinitely, try and yield until success
2018-05-17 21:29:49 +03:00
Nekotekina 39088e5005 SPU: Allow waiting on LR+TM events (fixup) 2018-05-17 21:21:15 +03:00
Nekotekina 7afda26c69 spu_putllc_tx: preload a little more (WIN32) 2018-05-17 18:58:08 +03:00
Nekotekina 08cd8e0cb1 Cleanup: unused imports 2018-05-17 18:33:44 +03:00
Nekotekina 58e4d49bb5 Fixup (endless loop) 2018-05-17 18:33:44 +03:00
scribam ae0f27a18e travis: minor qt cleanup and improvements 2018-05-17 19:20:25 +04:00
scribam 06a6cfb9f7 travis: remove Vulkan-LoaderAndValidationLayers submodule checkout 2018-05-17 19:20:25 +04:00
scribam 3918a9b9fd travis: improve osx build (still not working and disabled) 2018-05-17 19:20:25 +04:00
scribam 8f975e2329 cmake: improve pthread inclusion 2018-05-17 18:42:44 +04:00
scribam 3dfe46fc42 cmake: use -Wno-unused-command-line-argument only with clang (gcc doesn't have this option) 2018-05-17 18:42:44 +04:00
scribam 580c8b8803 cmake: remove leftover from #4329 about X11 2018-05-17 18:42:44 +04:00
scribam e1e0af5f81 cmake: remove unused "CMAKE_BUILD" definition
It was introduced in commit 855d693 and used in the file rpcs3/Gui/GLGSFrame.cpp (wxWidgets) which doesn't exist anymore.
2018-05-17 18:42:44 +04:00
scribam 5ef1cab30b cmake: update cotire to 1.8.0 2018-05-17 18:42:44 +04:00
pauls-gh fdef77d779 Set Windows timer resolution to 0,5ms (#4579)
* Fix for https://github.com/RPCS3/rpcs3/issues/4569
(Win 10 update 1803 performance regression)
2018-05-17 15:00:22 +04:00
Megamouse 2eae06454b Qt: simplify horizontal header text alignment in the gamelist
Needs reset of the gamelist state in the settings to work properly.
Also added minor refactor
2018-05-17 14:27:45 +04:00
Megamouse 29318803a6 Qt: add sanity check to remove game (prevent nasty system flush).
and minor code refactor
2018-05-17 14:27:45 +04:00
Megamouse ff2c05da50 Qt: Use pointer to game info instead of index in game list
this should fix differences between model and view
2018-05-17 14:27:45 +04:00
Megamouse cafcac9ccd Qt: streamline custom config refresh in game list and thus ignore scroll
move l_GetItem lambda into custom_table_widget_item constructor
2018-05-17 14:27:45 +04:00
Megamouse e43afa7148 Qt: streamline game removal in game list and fix followed item selection 2018-05-17 14:27:45 +04:00
Megamouse 9a1c0e4577 Qt: merge custom context menu functions 2018-05-17 14:27:45 +04:00
Megamouse baec681c9e Qt: minor fix for compat downloader 2018-05-17 14:27:45 +04:00
Megamouse 8b54552ddf Qt: use NoEditTriggers instead of ItemIsEditable flags in the gamelist 2018-05-17 14:27:45 +04:00
Megamouse 1cff1ca03e Qt: add "Move Support" column to the gamelist and load the info from psf 2018-05-17 14:27:45 +04:00
Megamouse 3ba133f485 Qt: fix gamelist sort by adding a sort_role to custom_list_widget_item 2018-05-17 14:27:45 +04:00
Megamouse 28e19a1d14 Qt: use GameInfo's bootable instead of GUI_GameInfo's bootable member 2018-05-17 14:27:45 +04:00
Megamouse 49a4015d5d Qt: Hide firmware and path columns by default 2018-05-17 14:27:45 +04:00
Megamouse 3e71284d56 gitignore: improve bin 2018-05-17 03:49:07 +01:00
Jan Beich a68dac7282 JIT: add missing header after fd525ae1cf
In file included from Utilities/JIT.cpp:1:
Utilities/JIT.h:33:23: error: implicit instantiation of undefined template 'std::__1::array<asmjit::X86Gp, 4>'
        std::array<X86Gp, 4> args;
                             ^
/usr/include/c++/v1/__tuple:223:64: note: template is declared here
template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
                                                               ^
2018-05-17 04:42:05 +04:00
Florent Castelli 253248349f Link against the top-level LLVM targets only
Dependencies are still linked through usage requirements.
2018-05-16 23:35:53 +01:00
Florent Castelli afd55da8cb Add EXCLUDE_FROM_ALL to add_subdirectory calls 2018-05-16 23:35:53 +01:00
scribam 2bb5354fd9 Remove old references missed in commit b97a9d22f5 2018-05-17 00:53:31 +04:00
scribam 70e2873e69 Compilation fix for GCC 8 (at least) 2018-05-17 00:53:31 +04:00
Zion Nimchuk 705525510e re-enable LLVM for travis and build AppImages with LLVM 6 2018-05-17 00:01:53 +04:00
Nekotekina 367f039523 Build transactions at runtime
Drop _xbegin family intrinsics due to bad codegen
Implemented `notifier` class, replacing vm::notify
Minor optimization: detach transactions from global mutex on TSX path
Minor optimization: don't acquire vm::passive_lock on PPU on TSX path
2018-05-16 17:31:58 +03:00
Nekotekina fd525ae1cf Implement build_function_asm
Uses ASMJIT to build function at startup
2018-05-16 15:48:35 +03:00
scribam fd8aae5725 emu: remove wait_engine files
These files are empty and do not serve any purpose currently
2018-05-16 03:56:06 +04:00
scribam 7518200c7e ps3emu_api: remove leftover files
Initial removal has been started with commit 6dd2c78b1b
2018-05-16 03:56:06 +04:00
scribam b97a9d22f5 rpcs3-tests: remove project
It is currently unmaintained and obsolete
2018-05-16 03:56:06 +04:00
scribam 196f985283 hle: improve cellSync2 error checks and logging 2018-05-15 22:59:34 +04:00
sftt 27004eb934 Avoid illegal available_user_memory in sys_memory (#4399)
jarveson says "the comment and minus can be completely deleted/reverted" in 17cf24d0ed
2018-05-15 17:40:45 +01:00
Zion Nimchuk 036448ac3f Fix xxhash and AppImages Fixes #4573 2018-05-15 16:06:05 +04:00
scribam 04ad49de4d typos 2018-05-14 21:14:39 +04:00
isJuhn fc23243d01 Fix setParam in cellHddGameCheck 2018-05-14 16:56:47 +01:00
Jan Beich 2cfb2428d2 build/cmake: pass -DNDEBUG by default like msvc
Downstream may override CMAKE_CXX_FLAGS_RELEASE in order to enforce
consistent optimization flags for every package. If -DNDEBUG is lost
RPCS3 may run slower and fall victim to assertions in bundled libs.
2018-05-14 16:01:19 +01:00
tlm-2501 21dc05265d Add description for SPU LLVM (#4558)
Not entirely sure on the wording, but some form of a description seems necessary.
2018-05-14 15:32:47 +01:00
creeperjedi 819ed801a7 Added (experimental) next to LLVM Recompiler 2018-05-14 14:41:50 +01:00
Nekotekina a46ef4f29a Increase open file limit on Linux
Add some assertions to VirtualMemory.cpp
2018-05-13 23:56:43 +03:00
Nekotekina 3c70645f0b Update SPU cache (v2)
Improve SPU analyser: filter unreachable fragments
More strict NOP/LNOP analysis
Fill block predecessors info
ASMJIT: fix assertion and improve indirect branch
2018-05-13 20:40:23 +03:00
Megamouse 84a4671a0e Qt: Use additional windows resource file for qt.conf
fixup for a39384cadd
2018-05-13 21:02:21 +04:00
Megamouse a39384cadd Qt: Create qt/plugins dir to tidy up our Visual Studio builds
see folders: bearer, imageformats, styles and platforms.
This will stay compatible with the old builds too, unless someone wisely put their plugin folders into a 'plugin' subdirectory
2018-05-13 18:39:24 +04:00
kd-11 4836a03a7d rsx: Fix build 2018-05-13 14:44:14 +03:00
kd-11 ad108720fb exclude qt autogen files 2018-05-13 14:44:14 +03:00
kd-11 9d1f4a2538 vk: Include RADV POLARIS and RADV VEGA in the primitive restart
blacklist
2018-05-13 14:44:14 +03:00
kd-11 bff6060bd6 rsx: Improve puller state management
- Properly identify puller spin primitives
- Add a small wake delay after exiting a spin delay. Fixes desynchronization
  It seems real hw has a small delay between cell edits to commandbuffer memory at the GET address and the changes becoming visible to the DMA puller
  Simulated with a short busy_wait, large values will improve sync but degrade performance
2018-05-13 14:44:14 +03:00
kd-11 1aa44ede31 gl: Improve AMD multidraw workaround
- Reimplements the AMD workaround using an identity buffer to avoid the performance hit of doing multiple glDrawArrays for every single compiled set
- Reimplements first/count allocation using a scratch buffer to reduce allocation overhead when large number of draw calls is used
2018-05-13 14:44:14 +03:00
kd-11 eccb57d4b8 vk: AMD primitive restart bug workaround
- Emulate primitive restart with degenerate triangles
2018-05-13 14:44:14 +03:00
kd-11 b7979d3f57 rsx/vk: Improvements and minor optimizations
- Improve dirty state tracking affecting program state
- vk: Refactor out transform constants upload into a separate channel to avoid if possible
  transform data uploads are quite expensive
2018-05-13 14:44:14 +03:00
kd-11 440a31ef18 rsx: Optimizations for program management 2018-05-13 14:44:14 +03:00
kd-11 a52ea7f870 rsx: Improve fragment and vertex program usage
- Introduces a gpu program analyser step to examine shader contents before attempting compilation or cache search
  - Avoids detecting shader as being different because of unused textures having state changes
  - Adds better program size detection for vertex programs
- Improved vertex program decompiler
  - Properly support CAL type instructions
  - Support jumping over instructions marked with a termination marker with BRA/CAL class opcodes
  - Fix SRC checks and abort
  - Fix CC register initialization
  - NOTE: Even unused SRC registers have to be valid (usually referencing in.POS)
2018-05-13 14:44:14 +03:00
Jake 75b40931fc rsx: initial capture/replay functionality (#4510)
* rsx: initial capture/replay functionality
2018-05-13 12:18:05 +03:00
Jan Beich 177da2984d VirtualMemory: add missing header after 5d15d64ec8 (#4532)
Utilities/VirtualMemory.cpp:123:8: error: use of undeclared identifier 'errno'
                        if (errno != EEXIST)
                            ^
Utilities/VirtualMemory.cpp:123:17: error: use of undeclared identifier 'EEXIST'
                        if (errno != EEXIST)
                                     ^
2018-05-13 11:34:33 +03:00
Nekotekina 7cb4672344 Travis: remove LLVM for now 2018-05-13 00:03:08 +03:00
Nekotekina 4c7afb6952 Opt-in set DAZ and FTZ 2018-05-13 00:03:08 +03:00
Nekotekina a77896c1b6 Update LLVM commit, use small code model 2018-05-13 00:03:08 +03:00
Nekotekina be5c18cc85 SPU Re: more precise jt generation
Improve analyser, set v1
Fix branch indirect conditional
2018-05-12 23:50:49 +03:00
Nekotekina 737db90058 Set DAZ and FTZ 2018-05-09 23:38:26 +03:00
Nekotekina 5d15d64ec8 Memory mirror support
Implemented utils::memory_release (not used)
Implemented utils::shm class (handler for shared memory)
Improved sys_mmapper syscalls
Rewritten ppu_patch function
Implemented vm::get_super_ptr (ignores memory protection)
Minimal allocation alignment increased to 0x10000
2018-05-09 23:35:34 +03:00
Nekotekina fe4c3c4d84 Implement SPU recompiler cache
Shared between ASMJIT/LLVM recompilers, compiled at startup
2018-05-09 23:35:18 +03:00
Nekotekina f5ee6fb113 Convert newlines in game title 2018-05-09 22:19:55 +03:00
Nekotekina acfe22e5bc SPU: improve jumptable detection 2018-05-09 22:19:55 +03:00
Nekotekina cfa9b163fd Implement fmt::to_lower
It was strangely removed...
2018-05-09 22:19:55 +03:00
Nekotekina eae78a8711 Improve fs::create_path
Don't fail if already exists
2018-05-09 22:19:55 +03:00
Nekotekina 88dc6b7700 Cfg: add missing get() methods 2018-05-09 22:19:55 +03:00
Nekotekina 8f91917e8c SPU ASMJIT: simplify patchpoints
Remove SPU thread reference from spu_recompiler_base
Disable support for far jumps in pathpoints (they were rare and unsafe)
2018-05-09 22:19:55 +03:00
Nekotekina 1ca51a023c SPU LLVM Recompiler (preview) 2018-05-09 22:19:55 +03:00
Nekotekina a975ecdc4f Use LLVM 6 2018-05-08 13:05:29 +03:00
Nekotekina 8b704588d0 Update cpu_translator 2018-05-08 13:05:29 +03:00
Nekotekina a7c34123a6 Improve dynamic_library 2018-05-08 13:05:29 +03:00
Nekotekina 18f9781ea8 Update .clang-format 2018-05-08 13:05:29 +03:00
Nekotekina db229dffb0 PPU LLVM: minor update 2018-05-08 13:05:29 +03:00
Nekotekina 16f5167aed SPU Analyser improved
This restores some functionality removed in SPU ASMJIT v2.0
Also implements new experimental features
2018-05-08 13:05:29 +03:00
Nekotekina 767dfa271e SPU ASMJIT: internal jumptable
Allow indirect calls within current function using a jumptable
This restores some functionality removed in SPU ASMJIT 2.0
Change SPUThread::get_ch_value prototype
2018-05-08 13:05:29 +03:00
Nekotekina df453d6d4f SPU ASMJIT: allow holes in raw block data
This is preparation for further changes.
This commit shouldn't affect anything.
2018-05-08 13:05:29 +03:00
Nekotekina 2fecddcde2 SPU ASMJIT: rewrite halt instruction
Use conditional memory access to invalid address.
This approach can allow continue (for debugging);
but at the same time it doesn't add function call to recompiled code.
2018-05-08 13:05:29 +03:00
Nekotekina 4d60d85db5 SPU: fix MFC_PUTQLLUC_CMD fence trait 2018-05-08 13:05:29 +03:00
Nekotekina f4af3f2987 PPU: improve LWARX/LDARX consistency 2018-05-08 13:05:29 +03:00
Ani 753d8170d1 gui/themes: Refactor Kuroi
Also tweaks a few things visually and removes dead code
2018-05-07 23:04:07 +04:00
Maxetto dca6f1f863 Update some lv2 syscall names (#4490) 2018-05-06 14:21:50 +04:00
scribam ff1b0d73b7 hle: make cellSubDisplayInit returns CELL_SUBDISPLAY_ERROR_ZERO_REGISTERED 2018-05-06 12:49:44 +04:00
JohnHolmesII 25ec899cfe Readme (#4503)
* Update VS 2017 instructions

* Mention build config
2018-04-30 13:23:40 +04:00
isJuhn f27f7d50c9 Add Rich Presence option 2018-04-29 18:38:00 +01:00
kd-11 98b715d8c8 gl: Workaround for AMD driver bug 2018-04-25 19:14:36 +03:00
kd-11 ffa62918aa gl: Improve pixel transfer code and notify on AMD driver bug
- Readback does not work at all with float textures on AMD openGL
  Driver throws a bogus OUT_OF_MEMORY error regardless of amount of VRAM and system RAM available
2018-04-25 19:14:36 +03:00
kd-11 f3210a9a33 rsx: Workaround for lost memory sections
- TODO: surface_cache and texture_cache need a better method of persisting partial framebuffer resources
2018-04-25 19:14:36 +03:00
kd-11 58035697d5 rsx: Restore component mapping override for depth textures 2018-04-25 19:14:36 +03:00
kd-11 7e32e7343a vk: Reorganize handling of formats support
- Formats support is linked to the physical device and by extension the logical device derived from it
  It therefore makes no sense to track this as a separate object.
  Simplifies parameter passing and template specialization.
  Also avoids corner cases with AMD hardware (where D24S8 is not supported)
2018-04-25 19:14:36 +03:00
kd-11 291a828217 fixups 2018-04-25 19:14:36 +03:00
kd-11 40ae5e605d vk: Fix border color selection 2018-04-25 19:14:36 +03:00
kd-11 c5d1f30e82 rsx: Fix performance counters
- Detect jump-to-self type idling
2018-04-25 19:14:36 +03:00
kd-11 91a6091d26 rsx: Minor fixes
- vk: Clear dirty textures before copying 'old contents' in case the old data does not fill the new region
- rsx: Properly decode border color - seems to be in BGRA format
- vk: better approximation of border color to better choose between the presets
- vk: Individually clear color images outside render pass and without scissor
- vk: Fix renderpass selection for clear overlay pass
- vk: Include scissor region when emulating clear mask

NOTES:
- vk: Completely avoid using vkClearXXXXimage - its 'broken' on nvidia drivers
  Spec is vague about the function so its not an actual bug
  ClearAttachment is clearly defined as bypassing bound state which works correctly
- TODO: Implement memory sampling to simulate loading precleared memory if cell used memset to preinitialize the framebuffer
  Autoclear depth to 1|255 and color to 0 is hacky!
2018-04-25 19:14:36 +03:00
kd-11 da99f3cb9a rsx: Critical fixes
- texture cache: Avoid leaking memory sections
  - Avoid double ref increment on flush-always reprotection
  - Detect invalidated_resources entries in surface cache when protecting fbo memory
- vk: Copypasta bugfix, properly initialize aspect mask
2018-04-25 19:14:36 +03:00
kd-11 a42b00488d rsx: Texture fixes
- gl/vk: Fix subresource copy/blit
- gl/vk: Fix default_component_map reading
- vk: Reimplement cell readback path and improve software channel decoder
- Properly name the subresource layout field - its in blocks not bytes!
- Implement d24s8 upload from memory correctly
- Do not ignore DEPTH_FLOAT textures - they are depth textures and abide by the depth compare rules
- NOTE: Redirection of 16-bit textures is not implemented yet
2018-04-25 19:14:36 +03:00
kd-11 63d9cb37ec rsx: Framebuffer fixes
Primary:
- Fix SET_SURFACE_CLEAR channel mask - it has been wrong for all these
  years! Layout is RGBA not ARGB/BGRA like other registers

Other Fixes:
- vk: Implement subchannel clears using overla pass
- vk: Simplify and clean up state management
- gl: Fix nullptr deref in case of failed subresource copy
- vk/gl: Ignore float buffer clears as hardware seems to do
2018-04-25 19:14:36 +03:00
kd-11 9abbbb79ae rsx: Blit engine fixes
- Ignore unlocked blit sections [TODO]
- Do not attempt blit on hw if bytesize is unsupported
- gl: Implement typeless memory transfers
  Uses pbo to handle type-agnostic memory transfer
2018-04-25 19:14:36 +03:00
kd-11 bb5622401c overlays/gl: minor fixes
- fix ogl color map for overlay resources
- fix label background for save dialog
2018-04-25 19:14:36 +03:00
kd-11 6d46ac1ad6 gl: Reimplement textures
- Separate texture data from texture views
2018-04-25 19:14:36 +03:00
kd-11 cf1b700ebc rsx: Improve format mismatch detection hack 2018-04-25 19:14:36 +03:00
kd-11 c5cd758700 rsx: Workaround for G8B8 render targets
- Mainly affected are colormasks and read swizzles

NOTES:
- Writes to G write to the second and fourth component (YW)
- Writes to B write to first and third component (XZ)
- This means the actual format layout is BGBG (RGBA) making RG mapping actually GR
- Clear does not seem to have any intended effect on this format (TLOU)
2018-04-25 19:14:36 +03:00
Nekotekina bd1d4de422 Fix unnecessary cache dir 2018-04-22 00:06:49 +03:00
Nekotekina da6afb11f0 Fix game title if unset 2018-04-22 00:06:49 +03:00
Nekotekina ef0196d791 Fix warning (vm::reservation_update) 2018-04-22 00:06:49 +03:00
Nekotekina 841d8955de Fix warning (fmt_unveil) 2018-04-22 00:06:49 +03:00
Nekotekina 738a7cac4f SPU ASMJIT: inline WRCH 2018-04-22 00:06:49 +03:00
Nekotekina 9516250bec SPU: fix MFC_WrTagUpdate 2018-04-22 00:06:49 +03:00
Nekotekina 2418de7e8b SPU ASMJIT: inline RDCH 2018-04-22 00:06:49 +03:00
Nekotekina 00ce814501 SPU ASMJIT: inline RCHCNT 2018-04-22 00:06:49 +03:00
Nekotekina 9ad5fc8a08 SPU: rewrite spu_channel_t 2018-04-22 00:06:49 +03:00
Nekotekina 3ffafb741c SPU ASMJIT: übertrampolines and spu_runtime
Use opt-out shared spu_runtime to save memory (Option: SPU Shared Runtime)
Implement "übertrampolines" for dispatching compiled blocks
Patch fixed branch points to use trampolines after check failure
2018-04-22 00:06:49 +03:00
Nekotekina 8ca33bcb94 SPU ASMJIT v2.0
Use X86Assembler and blocks
2018-04-22 00:06:48 +03:00
Robbie 477522210e Refactor debugger_frame into subclasses. Mostly trying to simplify
breakpoints.
2018-04-21 22:21:51 +04:00
Greg V 633004c820 Fix build with ffmpeg 4.0 2018-04-21 21:06:06 +04:00
Megamouse 8f4fa8a5b6 cellPad: check for more invalid parameters 2018-04-20 17:09:14 +04:00
Zion Nimchuk 3b24e7e685 Discord Rich Presence Integration (Thanks to @Megamouse for fixing the windows build) 2018-04-19 04:47:56 +04:00
Zion Nimchuk 3d551482a9 Remove weird whitespace from appdata
Fixes xml validation
2018-04-19 02:30:35 +04:00
Zion Nimchuk c6f44299c3 remove glapi.so.0, and do some minor cleanup 2018-04-19 02:30:35 +04:00
TheAnig eb3dfb6bb4 Implemented sysCacheClear() (#4445) 2018-04-18 18:17:55 +04:00
Megamouse cecfc59040 Qt: implement log Repaint 2018-04-18 01:28:11 +04:00
TGEnigma 6baf675205 Fixes PPU disasm for branch opcodes 2018-04-16 19:02:06 +04:00
isJuhn da6f98f310 Fix setParam in cellGameDataCheckCreate2 2018-04-16 15:53:22 +04:00
Zion Nimchuk 2bb0387fc5 Fix appstream copypasta, thanks to @Dominator56 for pointing it out 2018-04-16 15:11:37 +04:00
Zion Nimchuk d957531dab Fix AppImages for distros that are not ubuntu 14.04 2018-04-16 02:30:23 +01:00
Megamouse 41f4bb9016 Rename Supporter 2018-04-15 15:49:01 +01:00
Megamouse 69b5f25644 Qt: Fix vfs dialog reset and add some translations
Reset would crash the app, because a cleared item received a signal on currentItemChanged.
Also, Reset did not reset the list as one might think, but clean it and then result in wrong behaviour.
Furthermore the settings were saved, regardless of accepting the dialog or not.
2018-04-15 15:49:01 +01:00
Zion Nimchuk 78bb9a7278 Add appstream metadata for linux 2018-04-14 01:10:12 +04:00
JohnHolmesII 7303f04bc5 Minor bugfix 2018-04-10 15:06:56 +03:00
Nekotekina ea82b732a3 SPU: fix non-TSX path 2018-04-08 23:30:50 +03:00
Talkashie 64992f758d Fix typos (#4410)
* MASSIVE TYPO FIX part 1

* ANOTHER HUUUUGE TYPO FIX part 2

* thank you :hcorion: for all of your help. I could not have done this without you
2018-04-08 01:01:39 +01:00
GinkREAL 8a51af0b56 cellVdec: Do not decode next frame during end_sequence 2018-04-08 02:51:46 +04:00
Nekotekina c77b310422 Implement sys_vm_invalidate 2018-04-07 21:18:34 +03:00
Nekotekina 0797164fac SPU: fix possible livelock
The bug affects TSX path
2018-04-07 20:51:21 +03:00
Nekotekina 3681507136 Rewrite vm::reservation
Use flat virtual memory area
2018-04-07 20:51:21 +03:00
Nekotekina 2b5cf2455f SPU: improve TSX usage
Reduce transaction failure amount
Remove vm::try_to_lock
2018-04-06 21:47:54 +03:00
Nekotekina d392379c7a Use vm::passive_lock for SPU threads 2018-04-06 15:47:00 +03:00
Nekotekina e88508b679 SPU: cache barrier/fence masks 2018-04-06 15:47:00 +03:00
Zion Nimchuk 90e0bade77 Bundle libstdc++6 with AppImage to make it work on trusty 2018-04-06 02:20:08 +04:00
kd-11 568118634e vk: Squash some spec violations that went unnoticed 2018-04-05 01:06:50 +03:00
kd-11 cfd0b8a975 rsx: Fix alphakill 2018-04-05 01:06:50 +03:00
kd-11 93b2776604 rsx: Fix vertex input detection
- Properly detect inline array registers vs constant value registers
- Silence needless spam, 306E is 2D surface engiine, the assumption that y is multiplied by 306E pitch is not crazy
2018-04-05 01:06:50 +03:00
kd-11 53f2533a08 rsx: Implement proper Z-order curve in 3 dimensions
- Should fix garbage palette textures getting uploaded (LSD graphics)
2018-04-05 01:06:50 +03:00
kd-11 e291494282 rsx: Texture cache updates
- Properly implement section gather for 3d and cubemaps
  Implements render-to-3d and fixes some corner cases for render-to-cubemap
2018-04-05 01:06:50 +03:00
Zion Nimchuk b0352d6ef7 Silence some annoying terminal output 2018-04-03 03:17:52 +04:00
Zion Nimchuk 8c19ff4fb9 Make loading StyleSheets work for AppImages and if installed via make install 2018-04-03 03:17:52 +04:00
Nekotekina da9baac842 Improve save data dialog
Bug fix: don't display new data entry when not asked for
Use icon/title provided by the game for the new data entry
Display new data entry at the beginning of list when necessary
Minor cellSaveData cleanup
2018-04-02 16:27:28 +03:00
Nekotekina 0e74f2e340 Fix MMIO on SPU
Thanks Digitaldude555 for reporting the bug and @elad335 for pinging me
2018-04-01 22:39:48 +03:00
Nekotekina 402ca480cd Fix vm::check_addr usage 2018-04-01 22:39:48 +03:00
Nekotekina d871675b3b Process RawSPU MMIO in do_dma_transfer 2018-04-01 22:39:48 +03:00
Nekotekina bb0cfe383d Fix MFC_SYNC_CMD 2018-04-01 20:52:54 +03:00
scribam 717f2b0ac8 cellVdec: log error when using interlaced frame instead of throwing an exception 2018-04-01 03:36:22 +04:00
Megamouse 2bf405e36d rsx_debugger: clear command count when not used 2018-04-01 02:53:53 +04:00
Megamouse c42b25f10e rsx_debugger: use PerformJump on doubleclick instead of the mouse scroll 2018-04-01 02:53:53 +04:00
Megamouse b9318f73e6 rsx_debugger: handle show buffer per doubleclick through an event filter 2018-04-01 02:53:53 +04:00
Megamouse ff89f7ca45 Qt: add show_windowed_image to qt_utils 2018-04-01 02:53:53 +04:00
Megamouse ed7d514c31 rsx_debugger: move debugger table resize to qt_utils for reusability
maybe create a custom table class in the future
2018-04-01 02:53:53 +04:00
Megamouse d97d30ea2e rsx_debugger: save/restore table header states 2018-04-01 02:53:53 +04:00
Megamouse 4899e35fbb rsx_debugger: layout refactoring for highdpi and resizeability 2018-04-01 02:53:53 +04:00
Megamouse 92ec846375 Qt: simplify resetGeometry occurances 2018-04-01 02:53:53 +04:00
Megamouse 755ceb50a4 stub cellGem some more (#4349) 2018-04-01 02:03:37 +04:00
VelocityRa 706faa1d32 PPUTranslator: Ignore relative relocations 2018-04-01 01:32:08 +04:00
jjsat 4620fa8bd8 Return parameter error if the result of funcFixed is invalid. 2018-04-01 01:04:37 +04:00
jjsat 1dc87a0704 Corrected logic for handling number of returned save data list entries and total number of save entries. 2018-04-01 01:04:37 +04:00
jjsat bba7184090 Handle some invalid save function parameters. 2018-04-01 01:04:37 +04:00
jjsat d973337c4e Calculate save data file size more accurately and return size in savedata_get_list_item if requested. 2018-04-01 01:04:37 +04:00
Nekotekina 898637f830 Remove mfc_thread
Clear mfc_queue on reset
Improve MFC Proxy a bit
2018-03-31 21:13:12 +03:00
Nekotekina 78dbc4fb5f RawSPU: reset status register on start
Was proposed by @elad335
Implemented as atomic op
2018-03-31 20:35:30 +03:00
Nekotekina a3db2774f1 [LLVM] Fix thread limiter
Allow to apply max llvm threads setting as usual
2018-03-31 20:35:30 +03:00
Nekotekina c3a5e3f491 [LLVM Cache] Minor workaround 2018-03-31 16:51:19 +03:00
Ani 7359774c76 qt: Do not deploy Qt5Quick
We're using Qt5Qml but not Qt5Quick, therefore the extra extension can be removed
2018-03-31 02:54:59 +01:00
VelocityRa bca46e92d4 cellCamera: Implement cellCamera*NotifyEventQueue and do some refactoring 2018-03-30 20:50:31 +01:00
Jake 2c16dddd1e fix debug build 2018-03-30 13:30:04 +03:00
Jake 6d6d6fa827 dx12/vk/gl: implement use of vertex_data_base_index when calculating index 2018-03-30 13:30:04 +03:00
Megamouse 3e863f2189 remove redundant error messages in sceNpTrophy 2018-03-30 05:40:57 +04:00
Megamouse 2d68aed68f improve sceNpTrophyGetTrophyInfo and sceNpTrophyGetGameInfo 2018-03-30 05:40:57 +04:00
kd-11 ee0fe28ddc rsx: Fix copypasta 2018-03-29 13:52:11 +03:00
kd-11 7627ad04f1 rsx: Disable gamma control on WZYX textures
- Gamma is seemingly used for (D/X/A)RGB only. Data textures are unaffected
2018-03-29 13:52:11 +03:00
kd-11 f559c088a1 rsx: Dubious fix for broken B8 swizzle remap 2018-03-29 13:52:11 +03:00
pauls-gh a17025c465 Strict Rendering Mode (SRM) fix. Move old surface copy before texture upload.
Fixes the following issues on Tales of Vesperia which requires SRM.
- Blacked out scene after the sleeping dog now renders correctly
- Ghosting effect. The ghosting was most noticeable as a delay between the character rendering and the cell shading around the character. This appears to be gone with this change.
2018-03-29 11:01:58 +03:00
Megamouse 70cc2e3665 Qt: minor fixes 2018-03-28 16:01:32 +01:00
kd-11 fca6c4fb7f vk: Improve compatibility workarounds
- Disable fence reset on gcn1 - gcn3
- Enable polaris+ workarounds on linux if proprietary driver is used
2018-03-28 11:30:11 +03:00
Megamouse 05fc49506a Qt: use seperate icon sizes for game list and game grid 2018-03-27 19:40:25 +01:00
Kravickas e6cb4df877 Fix a typo in gcm_enums.cpp (#4333)
* Update gcm_enums.cpp
2018-03-27 18:43:38 +01:00
Asinine 2172e61ce5 Update settings to indicate speed differences between Interpreters and Recompilers for less confusion (#4345)
* Update settings_dialog.ui

* Qt: completely detach ppu and spu ui texts from backend.
2018-03-27 17:55:54 +01:00
kd-11 a36acf49d8 vulkan-build: use stub sha1 to bypass spirv_tools check when running setup scripts 2018-03-25 16:02:47 +03:00
kd-11 5aac8aa424 rsx: Clamp negative fog distance 2018-03-25 16:02:47 +03:00
kd-11 887ea43e39 rsx: Fix some texture cache problems
- gl/vk: Properly handle remapping temporary resources
2018-03-25 13:31:06 +03:00
kd-11 9fce5b0f7a gl: Fix leaking occlusion queries
- GL queries share the target binding (not asynchronous!)
- Discard active queries by closing them, leave closed queries alone (nothing to be done for discard op)
2018-03-25 13:31:06 +03:00
kd-11 22af70d0d0 gl: Always use indexed blend caps to avoid conflict with the state cache.
- glEnable/glDisable should not be used with GL_BLEND as the main renderer uses the indexed variant
2018-03-25 13:31:06 +03:00
kd-11 321c360dcb rsx: Overhaul rendertarget sampling/shuffles
- Reimplements render target views used for sampling
- Optimizes access using an encoded control token
- Adds proper encoding for 24-bit textures (DRGB8 -> ORGB/OBGR)
- Adds proper encoding for ABGR textures (ABGR8 -> ARGB8)
- Silence some compiler warnings as well
- TODO: Real texture views for OGL current method is a hack
2018-03-25 13:31:06 +03:00
kd-11 9bb1ed78f9 gl: Implement video-out calibration for gamma and dynamic range
- Seems to be of limited use but if it is determined to be useful, a vulkan implementation can be done
2018-03-25 13:31:06 +03:00
kd-11 9fc1740608 rsx/fp: Fragment program overhaul
- Separate TXB from TXL: They are completely different!
- Properly perform TMU emulation in the fragment shader. Implemens SRGB conversion and alphakill at the moment
- Properly perform ROP emulation in the fragment shader. Implements FRAMEBUFFER_SRGB. While support on the chip looks to be incomplete (and wierd), it does work
- Document some more bits in SHADER_CONTROL register
2018-03-25 13:31:06 +03:00
kd-11 c6a2525c9b video out: Set up video configuration options in fxm
- TODO: Actually do something with the values
2018-03-25 13:31:06 +03:00
kd-11 aeebeed0f2 vk: Fix AMD primitive restart emulation when strict mode is active
The restart emulation is there to keep the proprietary drivers from randomly crashing when using primitive restart
2018-03-25 13:31:06 +03:00
kd-11 9f416e5ce1 rsx/gl/vk: Obey channel remapping on framebuffer resources if requested 2018-03-25 13:31:06 +03:00
kd-11 27552891ad rsx/fp: Improvements
- Export some debug information in the free texture register space components zw
  Very useful when analysing renderdoc captures
- Enable shadow comparison on depth as long as compare function is active and texture is uploaded for depth read
  Some engines (UE3) read all the components in the shader and use mul/mad with the result
2018-03-25 13:31:06 +03:00
kd-11 5817f9fe3f rsx: Texture format fixes
- Implement SRGB (gamma corrected) textures (DXT1, DXT3, DXT5, RGBA8 only)
- Fix channel map decode for XY data texture formats
- Fix remap layout for X16 textures (verified with Mass Effect 3)
2018-03-25 13:31:06 +03:00
Talkashie a35bcb131e unimportant teepo fix (#4328)
* ultra teepo fix part 1

* super mega teepo fix part 2
2018-03-24 20:21:50 +04:00
eladash 63fa50080d sys_spu: dont check prio if spu group type is 0x20
it's currently unknown whats the exact relationship between the prio and the group type SYS_SPU_THREAD_GROUP_TYPE_COOPERATE_WITH_SYSTEM (0x20).
tho we do know prio'es whom less than 16 are reserved for the system.
2018-03-24 19:48:14 +04:00
eladash d27a375363 RawSPU/MFC: fix get start type proxy commands 2018-03-24 19:48:14 +04:00
eladash fad9cd6ef1 sys_spu: fix spu image loading address calculation
by calculating mem_size after nsegs has being calculated
2018-03-24 19:48:14 +04:00
Zeke Sonxx 3066a05df0 sys_crash_dump user_log_area improvements
Gets Destiny BLUS31181 to Intro
2018-03-24 17:49:18 +04:00
scribam 50446f7fef Partial compilation fixes for osx 2018-03-24 11:14:40 +00:00
Birk Magnussen c5caaa9211 Fix missing Detection for AVX OS Support 2018-03-24 03:30:27 +04:00
Kaiwen Xu 32d38a4633 Fix git-version.h not correctly updating. 2018-03-24 00:52:11 +04:00
scribam 1ae724f739 sys_fs: returns the correct error value when the path is 0 or an empty string 2018-03-23 21:45:22 +04:00
Megamouse 50ff987850 stub sceNpScoreWaitAsync and sceNpScorePollAsync
and sceNpScoreCreateTransactionCtx
2018-03-23 20:46:24 +04:00
pauls-gh 44cddda4b4 Fix VTC source index increment 2018-03-23 12:01:30 +03:00
pauls-gh d79a544320 VTC tiling - fix source offset increment. 2018-03-23 12:01:30 +03:00
pauls-gh e5b4710471 Add end condition for VTC copy. This handles the case when depth is not a multiple of 4. 2018-03-23 12:01:30 +03:00
pauls-gh e6010ba2ca Fix code formatting 2018-03-23 12:01:30 +03:00
pauls-gh fd8d2ecbf4 Remove Volume Texture Compression (VTC) tiling for Vulkan, DX12 and ATI (OpenGL). 2018-03-23 12:01:30 +03:00
Nekotekina 78cfba158d Use lowercase for FNIDs for consistency 2018-03-22 23:24:58 +03:00
Nekotekina 20785b00f6 Implement fmt::base57
For future use
2018-03-22 23:24:58 +03:00
Nekotekina 2c6c8f1a25 Implement patch support for PRX
Store SHA-1 hash in ppu_module
2018-03-22 23:24:58 +03:00
Nekotekina 19944eeed0 Implement SPRX precompilation
Automatically precompile firmware modules
Add "Create LLVM Cache" menu (for games)
Reimplement jit_compiler::cpu as static method
2018-03-22 23:24:58 +03:00
Megamouse 9d961f620b rsx/Qt: add option to disable the shader compilation hint 2018-03-22 16:33:37 +04:00
Megamouse 9fcba58537 Qt: sort the game list case insensitive initially 2018-03-22 16:33:37 +04:00
Megamouse 9f1fe5775e Qt: use QString::simplified() instead of get_single_line
hopefully this works
2018-03-22 16:33:37 +04:00
Megamouse baea538c32 Qt: clean up gui_settings.h - move general functions to qt_utils.h 2018-03-22 16:33:37 +04:00
Megamouse c10e195dba Qt: move compat_status to game_compatibility.h 2018-03-22 16:33:37 +04:00
Megamouse 5492e0eae1 Qt: enable hiding on game list and optimize the game list filter 2018-03-22 16:33:37 +04:00
Megamouse 17d2124a71 visual studio: add filters for some module headers 2018-03-22 16:33:37 +04:00
scribam af89b62194 Check if the compiler supports "-march=native" 2018-03-21 14:11:05 +03:00
scribam 526228442b Use "USE_NATIVE_INSTRUCTIONS" variable instead of a specific "TRAVIS" variable 2018-03-21 14:11:05 +03:00
GeniusMage 4e2a8a3cdb Teepo fix
2D isn't always > 3D
2018-03-21 13:40:34 +03:00
eladash 252ddf8085 set logging stack mode to true by default 2018-03-20 02:49:53 +04:00
eladash fc3698f831 qt: make description of disabled AF setting a bit clearer 2018-03-20 02:49:53 +04:00
eladash 3426531e38 qt/spu: remove max dma write size setting
This wasn't really used for anything tbh
2018-03-20 02:49:53 +04:00
eladash ce674dbc5d add enc_temp_folder to gitignore
this folder randomly pops up when you modify code files while debugging using VS
2018-03-20 02:49:53 +04:00
kd-11 92fb828d52 gl: Compat support for mesa drivers Needs CLIENT_STORAGE bit set for persistent buffers to make them useful 2018-03-20 00:11:41 +03:00
kd-11 d13584f858 rsx: fixups
gl/vk: Bump shader cache version
gl/vk: Disable anisotropic override when strict mode enabled as it is proven to alter some games negatively
gl: Clamp buffer view range to not exceed the backing buffer size. Also add assert for the same condition
2018-03-19 12:13:34 +03:00
Nekotekina f66d5adf5f Prevent accessing incomplete RPCS3.log.gz
Use permissions to make it inaccessible
On Windows, autodelete the file

Implement fs::unread for this purpose
Rename fs::unshare to fs::lock
Fix fs::lock correctness
2018-03-17 00:39:45 +03:00
scribam b232409cc5 Add return codes when camera handler is set to null 2018-03-16 18:16:49 +00:00
scribam da635af0d6 Make cellCameraInit returns CELL_OK when no camera is plugged in. 2018-03-16 18:16:49 +00:00
kd-11 5f047034ae rsx: Disable async count verification to avoid lockup due to zombie reports in ZCULL 2018-03-13 18:55:03 +03:00
kd-11 ffe6c9ba5a fix linux builds 2018-03-13 18:55:03 +03:00
kd-11 910fc54ee2 vk: Implement reading from cell if swap image isn't found 2018-03-13 18:55:03 +03:00
kd-11 f00d9a7c7f rssx" Halfplement alpha-to-coverage AA transparency 2018-03-13 18:55:03 +03:00
kd-11 2dce55d036 rsx: ZCULL synchronization fixes
- Track asynchronous operations in RSX core
- Add read barriers to force pending writes to finish.
  Fixes zcull delay flicker in all UE3 titles without forcing hard stall
- Increase zcull latency as all writes should be synchronized now
2018-03-13 18:55:03 +03:00
kd-11 315798b1f4 rsx: ZCULL rewrite and other improvements
- ZCULL unit emulation rewritten
- ZCULL reports are now deferred avoiding pipeline stalls
- Minor optimizations; replaced std::mutex with shared_mutex where contention is rare
- Silence unnecessary error message
- Small improvement to out of memory handling for vulkan and slightly bump vertex buffer heap
2018-03-13 18:55:03 +03:00
kd-11 dece1e01f4 rsx: Improve transform constants management
- Removes the duplicate local_transform_constants
- Resets the transform constants on every context reset
- Simplifies the code abit which should make it faster
- NOTE: Transform constants are persistent across context re-init events (VF5)
2018-03-13 18:55:03 +03:00
kd-11 a19ffba8e8 rsx: Simplify MRT blend setup; Enable separable MRT blend on vulkan and fix corner cases for GL 2018-03-13 18:55:03 +03:00
kd-11 e230867492 rsx: Properly implement raster window offsets 2018-03-13 18:55:03 +03:00
kd-11 0c8e4c0887 rsx: Improve FIFO commandlist flattening
- TODO: Alot of work is still needed to execute draw commands out of order
  Thats the only solution to games sending many draw calls with high frequency of state changes
2018-03-13 18:55:03 +03:00
kd-11 84b8a08d26 rsx: Basic performance counters 2018-03-13 18:55:03 +03:00
kd-11 2855869530 vulkan: Support APPLE
- Adds support for compilation on MAC with moltenVK. Note that vulkan does
  not work on MacOS yet. There are two main blockers:-
  1) Texture component swizzles are not supported except for
  RGBA8_UNORM->BGRA8_UNORM.
  2) There is a bug in their SPIR-V -> MSL generator.
  GLSL.std.450.xxxx functions are not implemented which breaks rpcs3
  functionality. Trying to compile a vertex shader will throw because
  unpackHalf2x16 is missing.
2018-03-13 18:55:03 +03:00
kd-11 d41b49d8b4 rsx/fp: Color output registers are always present and zero initialized
- According to NV_fragment_program spec, registers are zero initialized always
- A program even without writing to these registers will have black (0, 0, 0, 0) output
  Confirmed behaviour with MotorStorm games. Their engine uses this quirk to clear color buffers when doing depth replace
  Might be an unfixed game bug
2018-03-13 18:55:03 +03:00
kd-11 4804efc17d rsx: Clear up confusion on depth writes.
According to the NV_fragment_program spec, its not feasible to have 16-bit depth wries
 NOTE: NV_fragement_program precedes NV_fragment_program2 which is very
 close to what RSX consumes. It is hardware from that era afterall
2018-03-13 18:55:03 +03:00
kd-11 053ab585f4 gl/vk: Clean up some format casts
- TODO: Byte ordering considerations on data casts
2018-03-13 18:55:03 +03:00
kd-11 20d4c09a1c rsx/vk/gl: Enforce format matching for render target resources. Fall back to raw data copy if match fails
- Forces Bitcast of texture data if input format cannot possibly be the
  same as the existing texture format

- rsx: Other minor improvements to texture cache :-
  - remove obsolete blit engine incompatibility warning. The texture will be re-uploaded if it is indeed incompatible
  - Implement warn_once and err_once to avoid spamming the log with systemic errors
  - Track mispredicted flushes
  - Reswizzle bitcasted texture data to native layout
    TODO: Also needs reshuffle according to input remap vector
2018-03-13 18:55:03 +03:00
kd-11 68b3229756 rsx/fp: Improve rgister component gather detection
- Also avoids clobbering register data by keeping gathered bits in a temp var
2018-03-13 18:55:03 +03:00
kd-11 87741141f1 rsx/vulkan: Add post-compilation key validation and dynamically determine attachment write maks based on decompiled shader
- A new step is added between decompilation and pipeline object creation allowing for properties to be updated based on shader contents
- Allos masking off attachment writes that are unmodified in the shader
2018-03-13 18:55:03 +03:00
kd-11 705820c430 rsx: Nvidia driver compatibility workarounds
- Sanitize NaN values before they reach the driver. On nvidia (X * NaN = X)
2018-03-13 18:55:03 +03:00
kd-11 6b23e733d0 rsx/gl/vk: Improvements
- gl: Do not call makeCurrent every flip - it is already called in set_current()
- gl: Improve ring buffer behaviour; use sliding window to view buffers larger than maximum viewable hardware range
  NV hardware can only view 128M at a time
- gl/vk: Bump transform constant heap size When lots of draw calls are issued, the heap is exhaused very fast (8k per draw)
- gl: Remove CLIENT_STORAGE_BIT from ring buffers. Performance is marginally better without this flag (at least on windows)
2018-03-13 18:55:03 +03:00
kd-11 07cbf3da48 rsx/gl: Minor fixes
- Identify depth textures reaching the gpu via shader_read upload path
- Use correct timestamp counter for opengl
- inline draw_state::test_property because msvc doesnt do it for us
2018-03-13 18:55:03 +03:00
kd-11 af1b13550b rsx/vk: More optimizations
- Do not bother rechecking the dirty sampler pool for hits. Its faster to create new sampler than to search the pool
- Reserve some memory on vertex layout struct to reduce reallocation penalty
2018-03-13 18:55:03 +03:00
kd-11 8ccaabb502 vulkan: Optimize vertex data upload
- Reuse buffer views as much as possible, vkCreateBufferView is slow on NV
  Implemented as a large sliding window, reuseable until it is filled
2018-03-13 18:55:03 +03:00
kd-11 01349b8cee rsx: Texture cache fixes - Optionally attempt to merge framebuffers into an atlas if partial resources are missing - Support for data update requests to the temporary subresource handler This is useful for framebuffer feedback loops where a new copy is needed after every draw call (resource is always dirty) 2018-03-13 18:55:03 +03:00
kd-11 4487cc8e7a Remove an ugly hack pertaining to partial framebuffer-resident texture data - Its better to fill in the missing information with a wrap or clamp than to fake the texture reads in valid regions - Texture coordinate scaling is used to fill in for the cropped dimension available 2018-03-13 18:55:03 +03:00
TGEnigma cb9e6e75db Debugger improvements (#4026)
* Improve debugger
 * Added 'Step Over' functionality
 * Added special SPU pause functionality that pauses the SPU thread when the tag mask is at 0x80000000 by holding ctrl while pausing
  * Go to address dialog now evaluates expressions, including defined variables such as pc, r1, r2, etc
    * Requires QtScript to be linked with the project
  * Made the option to center shown addresses (Go to addr/pc) optional by making it an entry in the GUI ini config
  * Shown addresses now appear 'selected'
  * New keyboard shortcuts!
    - Ctrl+G -> Go to address
    - F10 -> Step Over
    - F11 -> Step (Into)
2018-03-13 16:23:12 +04:00
Jan Beich e487480ca9 Thread: unbreak build on BSDs after ac82ecf387
Utilities/Thread.cpp:1644:2: error: use of undeclared identifier 'pthread_setname_np'; did you mean 'pthread_set_name_np'?
        pthread_setname_np(pthread_self(), m_name.substr(0, 15).c_str());
        ^~~~~~~~~~~~~~~~~~
        pthread_set_name_np
/usr/include/pthread_np.h:58:6: note: 'pthread_set_name_np' declared here
void pthread_set_name_np(pthread_t, const char *);
     ^
2018-03-13 12:51:22 +04:00
Danila Malyutin bc9594ed57 Use latest Qt patch level on appveyor. 2018-03-13 04:56:47 +04:00
Nekotekina 817dfe8651 cellGameContentPermit workaround 2018-03-12 19:16:52 +03:00
Nekotekina ba54f7ae39 Improve cellGameCreateGameData error checks 2018-03-12 18:53:57 +03:00
Nekotekina f328cdbaef Fix cellGame regression 2018-03-12 11:40:12 +03:00
Roberto Anić Banić f2e5b6c350 Travis Fixup Fixup (#4273) 2018-03-12 03:07:37 +04:00
Nekotekina ac82ecf387 Use pthread_setname_np (Linux, GDB) 2018-03-11 19:33:02 +03:00
Nekotekina 4b1c052030 Fix crash on exit after access violation 2018-03-11 19:33:02 +03:00
Nekotekina c0a0cb98c5 Fix argv for DG category 2018-03-11 19:33:01 +03:00
Nekotekina 4fd69a09c7 Fix cellGameDataCheckCreate2 2018-03-11 19:33:01 +03:00
Nekotekina eea2c20420 Improve vfs::mount
Mount /dev_bdvd/PS3_GAME if necessary
2018-03-11 19:33:01 +03:00
Nekotekina f4d2fccdfe Improve boot dir access
Add Emu.GetDir() method
2018-03-11 19:33:01 +03:00
Nekotekina c8a6bc6e24 Relax /dev_bdvd mounting requirements
Allow some PSN games with DG category to boot
2018-03-11 19:33:01 +03:00
Nekotekina 7f542a5c99 Fix safe_writer_lock (typo) 2018-03-11 19:33:01 +03:00
Roberto Anić Banić c1f32aa570 Fix Travis by using a PPA to install QT. (#4269) 2018-03-11 20:13:56 +04:00
Jake 7bbadfd08b ppu/sys_interrupt: add stack_reset command to fix sys_interrupt stack overflowing 2018-03-09 20:30:59 +04:00
Jake 3a9428a88e rsx: Fix alpha test on VK/GL
Moving alpha test outside of fp_main. This enforces alpha test is still done even if shader asm has early return
2018-03-09 18:06:20 +03:00
Jake 7233640cf0 rsx: add vertex data base to offset and mask before translating address 2018-03-07 16:57:20 +03:00
Zion Nimchuk effdb65ae4 Update Vulkan-LoadAndValidationLayers to make CI work again 2018-03-06 22:22:15 +04:00
Ani 91d0511154 gui/themes: YoRHa by Ani - Bugfixes
- Fixed Library List
-- Removed uppercasing
-- Formatted checkboxes
-- Fixed selected text being white (unreadable)

- Fixed Log readability issues
-- Uses dark flat color background for improved readibility
-- Uses default font family and size for improved readibiluty
-- Adjusts success, always, stack and TTY colors

- Fixed Debugger issues
-- Removed uppercasing
-- Restored default font family
-- Restored default font size

- Styled QSliders
- Added border to SpinBox
2018-03-05 19:20:57 +00:00
Talkashie d4e88aa11c gui: Fix typos and clean up Engrish (#4250) 2018-03-05 18:28:10 +00:00
Jake ec0cd9f006 cellGame: Fix cellDiscGameGetBootDiscInfo return values (#4241) 2018-03-03 03:11:25 +04:00
Megamouse 8db7ef4d5a Qt: enable background images for floating dock widgets 2018-03-02 21:50:48 +04:00
Nick Renieris 504e3112dd [HLE] First steps to Playstation Move (#4083)
* [sysutil] Add Magnetometer system param

*  [ui] Add UI for Move handler

 Current options are "Null" and "Fake".

* cellGem: Improvements

* cellCamera: Improvements
2018-03-02 20:51:21 +04:00
Nekotekina f96e9b6ed7 Fix boot game crash 2018-03-01 16:28:08 +03:00
Nekotekina f056b2f4ab Improve TTY output
Use atomic variable to sync TTY size
Implement console_putc (liblv2)
Write plaintext instead of HTML
Slightly improve performance
Fix random line breaks in TTY
2018-03-01 16:28:08 +03:00
Nekotekina 445b7c0758 Optimize SPU interpreter
Made SPU decoder similar to PPU decoder
2018-03-01 16:13:35 +03:00
Nekotekina 53f8b03acc CPUTranslator: implement ICmp ops
Added operators ==, !=, >, <, >=, <=
2018-03-01 16:13:35 +03:00
Megamouse 900329a1de Qt: fix dockwidget background 2018-03-01 17:10:26 +04:00
Ani 7c6c33eef8 gui/themes: YoRHa by Ani
I hope you enjoy the theme as much as I enjoyed making it.
Based on NieR Automata's YoRHa UI style.
2018-03-01 01:34:11 +00:00
scribam dacc9af38f Add 2-channels mode for cellAudioOutGetDeviceInfo 2018-03-01 04:20:54 +04:00
scribam 8d7620d95f Change return of function "sceNpMatching2Init" to CELL_OK 2018-03-01 01:41:42 +04:00
Megamouse 3043c73745 Fix Boot regression introduced by #4158 2018-02-28 23:44:06 +04:00
Megamouse f786c078c2 Qt: enable custom fonts for stylesheets and add random object names 2018-02-28 23:44:06 +04:00
scribam 31cee7e4c8 Make cellNetCtlGetInfo returns the correct value in disconnected mode 2018-02-28 22:25:51 +04:00
elad 6e8ccbcf17 spu/interp: optimize floating point exception checking
read once the MXCSR register and use his value to check for all exceptions
2018-02-28 21:30:33 +04:00
Megamouse 72e54e8b60 Qt: ask for cache and config removal on app remove (#4016) 2018-02-28 20:06:44 +04:00
Andrey e0f53ace19 Improve GDB debug server (#4027)
* Made GDB debugger working with IDA

* Added async interrupts support

* Report proper thread after pausing

* Support attaching debugger before running app
2018-02-28 19:31:39 +04:00
Megamouse 2444385763 Qt: simplify Boot options a bit (#4158) 2018-02-28 18:53:39 +04:00
Megamouse 6141bc5598 Fix firmware installation for vfs 2018-02-28 17:27:06 +04:00
Megamouse 9138d537c8 Qt: remove gamelist toolbar 2018-02-28 16:52:19 +04:00
scribam 05354698f0 Add callbacks for cellStorage 2018-02-28 15:58:50 +04:00
scribam 14e15b2feb Add callbacks for cellUserInfo 2018-02-28 15:58:50 +04:00
scribam 324d21d849 Add callbacks for cellPhotoImport 2018-02-28 15:58:50 +04:00
scribam aa30e865c2 Add callbacks for cellSysconf 2018-02-28 15:58:50 +04:00
scribam 0772b9c879 Add callbacks for cellCrossController 2018-02-28 15:58:50 +04:00
scribam 296052b1ff Add callbacks for cellPrint 2018-02-28 15:58:50 +04:00
scribam be834a67d1 Add callbacks for cellPhotoDecode 2018-02-28 15:58:50 +04:00
scribam b63461f599 Add callbacks for cellMusicExport 2018-02-28 15:58:50 +04:00
scribam 1fb7cc4002 Add callbacks for cellMusicDecode 2018-02-28 14:47:35 +04:00
Zion Nimchuk a766478e15 Refactor .travis.yml and qt installation 2018-02-28 00:21:54 +00:00
elad b61a69c877 fix spu interpreter single stepping 2018-02-25 20:30:44 +04:00
scribam 7753ac60b0 Add CELL_GAMEUPDATE_RESULT_STATUS_* enum 2018-02-25 13:17:38 +00:00
scribam aabf3c6695 Checks for content_id in sceNpDrmVerifyUpgradeLicense and sceNpDrmVerifyUpgradeLicense2 2018-02-25 13:17:38 +00:00
zarroboogs d78b0467d8 RPCS3 0.0.5: Versioning Changes (Hotfix) (#4208)
* travis hotfix

* expose env vars for tag, hash and commit number

* bump version

* also update av version string

* remove hash from av version for master builds

* change hash encoding back to ascii
2018-02-24 19:54:58 +00:00
zarroboogs dc55d5be8f linux appimage versioning changes synced with windows artifact version 2018-02-24 15:06:08 +00:00
zarroboogs 06546b5195 windows artifact versioning changes, plus a small syntax fix 2018-02-24 15:06:08 +00:00
zarroboogs ca9c1674f7 minor syntax changes 2018-02-24 15:06:08 +00:00
scribam ede76033a7 Add callbacks for cellMusic 2018-02-24 02:38:43 +04:00
Nikolay Amiantov 41bd07274f Fix quoting in cmake 2018-02-23 19:06:37 +00:00
Megamouse 5266dd6c60 Update for Qt 5.10 (#4202)
* Update Readme for Qt 5.10

* Update cmake for Qt 5.10

* Update travis to Qt 5.10.1
2018-02-23 02:08:14 +04:00
Megamouse cf1c45dfe8 Qt: use setAttribute(AA_DisableWindowContextHelpButton) instead of flags
probably needs Qt 5.10.1 to work propery
2018-02-22 00:18:14 +04:00
Megamouse ae7e275a9d sceNpTrophyGetRequiredDiskSpace: take vfs into account for trophy dir 2018-02-22 00:18:14 +04:00
Megamouse b60f29282a Qt: add translation to save manager messageboxes 2018-02-22 00:18:14 +04:00
Megamouse bda466c3bd Qt: improve VFS dialog a bit
- use normal selection instead of doubleclick
- move SaveSettings out of the tabs to reduce file access
- translate EmptyPath as well
- some other minor refactors to reduce lines of code
2018-02-22 00:18:14 +04:00
kd-11 4c6ceeff11 rsx/vk: Cleanup
- Silence some warnings, remove dprints
2018-02-21 14:59:46 +03:00
kd-11 77f2b521e1 vulkan: Swapchains reimplemented
- Adds support for abstract implementations
- Adds native windowing implementations for WIN32 and X11 as fallbacks
  when present support is lacking (headless configs)
2018-02-21 14:59:46 +03:00
Juhn 1b26ec56ed Implement _sys_qsort in sys_libc_.cpp (#4176) 2018-02-21 00:24:47 +04:00
elad 7c0fd5094e disasm: clamp spu address 2018-02-20 20:27:57 +04:00
elad d5b9eb0caa add kdevelop to gitignore 2018-02-19 19:07:22 +00:00
elad 1a0b2bf050 add vscode files to gitignore
such as .vscode\settings.json
2018-02-19 19:07:22 +00:00
Zion Nimchuk f52fa5e46c Re-arrange VULKAN_PREBUILT option 2018-02-19 17:30:24 +04:00
Zion Nimchuk 77b8f3a0f9 Add an easy way for package builders to disable native cpu optimizations 2018-02-19 17:30:24 +04:00
Megamouse 95d232db4f Qt: fix gamegrid scroll
scrollafter is useless in gamegrid, because the currentIndex was reset after PopulateGameGrid, so just ignore it.
2018-02-19 01:23:40 +04:00
Robbie 00b1ff752d Add flag for rockband. Tests have shown it independent other flags. But, actual use is currently not known. 2018-02-18 04:29:41 +04:00
elad 877b296fc3 hle: return enosys on unpresented syscalls 2018-02-16 21:57:31 +04:00
kd-11 ee88e7f948 rsx/gl: Hotfix for GL format compatibility check when high precision depth buffers is enabled 2018-02-16 16:14:54 +03:00
kd-11 ebb9fc7cd9 vk/drivers: Restore polaris+ patch to disable primitive restart 2018-02-16 16:14:54 +03:00
kd-11 32f0e91893 vulkan: Improve primitive restart workaround for vega/polaris
- For some reason the hardware forgets that primitive restart is enabled and tries to actually read vertex index 65535
- Works correctly if uint32 vertex indices are used instead of uint16 for cases where primitive restart is active
2018-02-16 16:14:54 +03:00
kd-11 a8ab408f64 rsx: Account for null blit ops (memcpy)
- Do not perform extra memory tasks if no actual image copy was performed
2018-02-16 16:14:54 +03:00
kd-11 661b8b006f rsx: Add texture readback statistics to the texture cache and debug overlay 2018-02-16 16:14:54 +03:00
kd-11 1bd77c2f51 rsx: Add cache pattern checking to blit engine resources
- Feature was implemented long ago but was not functional due to bugs
2018-02-16 16:14:54 +03:00
kd-11 c191a98ec3 vulkan API fixes
- Fix for texture barriers
- vulkan: Rework texture cache handling of depth surfaces
- Support for scaled depth blit using overlay pass
- Support proper readback of D24S8 in both D32F_S8 and D24U_S8 variants
- Optimize the depth conversion routines with SSE
- vulkan: Replace slow single element copy with std::memcpy
- Check heap status before attempting blit operations
- Bump guard size on upload buffer as well
2018-02-16 16:14:54 +03:00
kd-11 3bbecd998a infinitesimal fixes 2018-02-16 16:14:54 +03:00
kd-11 3406cc9886 gl: Fix save binding state for cube textures 2018-02-16 16:14:54 +03:00
kd-11 bd297d079d rsx: Minor optimizations 2018-02-16 16:14:54 +03:00
kd-11 a5500ebfa4 rsx: Fix disjoint draw range splitting
- Fixes flickering and missing draws in R&C and other games such as Motorstorm Apocalypse and Okami HD when strict mode is disabled
2018-02-16 16:14:54 +03:00
kd-11 a64bea1286 rsx/fp: Discard shaders with undefined (non-existent) writes. On nvidia+vulkan, undefined writes autofill with blue color 2018-02-16 16:14:54 +03:00
kd-11 b67f28e00d rsx/texture_cache: Do not access non-existent components 2018-02-16 16:14:54 +03:00
kd-11 89c548b5d3 rsx: fbo fixes 2.5
- Implement flush-always behaviour to partially fix readback from a currently bound fbo
  - Without this, only the first read is correct, as more draws are added the results become 'wrong'
  - Fixes WCB and cpublit behviour
- Synchronize blit_dst surfaces to avoid data loss when gpu texture scaling is used
  - Its still faster in such cases to disable gpu texture scaling but some types cannot be disabled without force cpu blit (e.g framebuffer transfers)
- Memory management tuning
  - rsx: on-demand texture cache rescanning for unprotected sections
  - rsx: Only framebuffer resources are upscaled
  - Do not resize regular blit engine resources
  - Lazy initialize readback buffer when using opengl
  -- These measures should help minimize vram usage
2018-02-16 16:14:54 +03:00
kd-11 02e571adbc gl: Cleanup some more things
- Avoid referencing GL's null texture
- Improve texture creation helpers
- Remove useless __glcheck from GLHelpers.cpp
2018-02-16 16:14:54 +03:00
kd-11 98e50d3064 gl: Reuse framebuffer textures whenever possible 2018-02-16 16:14:54 +03:00
kd-11 f20fd217f8 rsx: Reorganize framebuffer setup code
- Fixes some fast paths for framebuffer creation and binding
2018-02-16 16:14:54 +03:00
elad 95c6ac699b hle: gpio syscalls
* add sys_gpio_get, sys_gpio_set
2018-02-12 04:29:07 +04:00
Ani 9caceeacd7 gui: Update compatibility colors
Update to the colors now used by the website
2018-02-12 01:58:14 +04:00
Ani 2f7f8a629d Move Contributing to .github 2018-02-12 01:58:14 +04:00
Ani a994c46256 GL: Update glext.h to ver 20180114 2018-02-12 01:58:14 +04:00
Ani c689a9ba8e rpcs3qt: Handle duplicate name warning
The name 'verticalLayout_29' (QVBoxLayout) is already in use, defaulting to 'verticalLayout_291'.
2018-02-12 01:58:14 +04:00
Ani 777cd9a8ae Remove redundant imports
They are already included on the related rpcs3qt files
2018-02-12 01:58:14 +04:00
Ani 6dd2c78b1b Remove unused files (ps3emu_api) 2018-02-12 01:58:14 +04:00
Ani 372cb39ce8 openAL: Update to 1.18.2 2018-02-12 01:58:14 +04:00
Nekotekina d2652aedd2 VK: add two options (workarounds)
Force FIFO present mode option is workaround for recent MESA drivers
Force primitive restart flag should also work on said drivers
2018-02-11 19:52:14 +03:00
Nekotekina fa04ff6d90 CPUTranslator: add bitcast, trunc, zext, sext 2018-02-10 15:57:01 +03:00
Nekotekina cce0ad0c35 Clean vm::ps3 namespace use 2018-02-09 17:49:37 +03:00
Nekotekina 76be7d40ac Remove PSP2 2018-02-09 15:24:46 +03:00
904 changed files with 93193 additions and 75838 deletions
+3 -5
View File
@@ -11,11 +11,11 @@ BreakConstructorInitializersBeforeComma: true
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: false
AlwaysBreakTemplateDeclarations: true
AllowShortIfStatementsOnASingleLine: true
AllowShortBlocksOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
Cpp11BracedListStyle: true
IndentCaseLabels: false
SortIncludes: false
@@ -29,5 +29,3 @@ BinPackParameters: true
AlwaysBreakAfterReturnType: None
KeepEmptyLinesAtTheStartOfBlocks: true
IndentWrappedFunctionNames: false
#SpaceAfterTemplateKeyword: false
+1 -1
View File
@@ -1,7 +1,7 @@
root = true
[*.{h,cpp,hpp}]
charset = utf-8
charset = utf-8-bom
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
+1 -1
View File
@@ -6,7 +6,7 @@ or our discord:
https://discord.me/RPCS3
PLEASE READ THE GUIDELINES BEFORE OPENING AN ISSUE:
https://github.com/RPCS3/rpcs3/blob/master/CONTRIBUTING.md
https://github.com/RPCS3/rpcs3/blob/master/.github/CONTRIBUTING.md
====================================================
+28 -28
View File
@@ -31,7 +31,6 @@
*.wav
/build
/bin
/lib
/tmp
/ipch
@@ -41,46 +40,31 @@
/Vulkan/Vulkan-build
/Vulkan/glslang-build
!/bin
/bin/*
# Themes
!/bin/GuiConfigs/
/bin/GuiConfigs/*.ini
/bin/rpcs3.ini
/bin/rpcs3.ipdb
/bin/rpcs3.iobj
/bin/FragmentProgram.txt
/bin/VertexProgram.txt
/bin/*.hlsl
/bin/BreakPoints.dat
/bin/textures
/bin/*.lib
/bin/*.exp
rpcs3/git-version.h
/bin/GuiConfigs/*.ini.*
/bin/GuiConfigs/*.dat
/bin/GuiConfigs/*.dat.*
# Visual Studio Files
.vs/*
.vscode/*
*.ipch
*.vspx
*.psess
*.VC.*
*.vcxproj.user
# Copyrighted files
/bin/data/
/bin/dev_flash/data/font
/bin/dev_flash/sys
/bin/dev_flash/vsh
# Ignore installed games except test homebrews
!/bin/dev_hdd0/game/
/bin/dev_hdd0/game/*
!/bin/dev_hdd0/game/TEST12345/
/bin/dev_hdd0/disc/*
enc_temp_folder/*
CMakeSettings.json
# Ignore other system generated files
bin/dev_hdd0/*.txt
x64/*
rpcs3/x64/*
rpcs3-tests/x64/*
rpcs3/git-version.h
# cmake
Makefile
@@ -92,8 +76,24 @@ CMakeCache.txt
rpcs3/cotire/*
rpcs3/rpcs3_*_cotire.cmake
# kdevelop
*.kdev4
.kdev4/*
# Qt
moc_*.cpp
qrc_resources.cpp
qrc_*.cpp
rpcs3_automoc.cpp
ui_*.h
rpcs3/rpcs3_autogen/*
# QtCreator
CMakeLists.txt.user
# CLion
/.idea/*
/cmake-build-*/
# macOS
.DS_Store
+18 -12
View File
@@ -1,6 +1,7 @@
[submodule "rpcs3-ffmpeg"]
path = 3rdparty/ffmpeg
url = https://github.com/hrydgard/ppsspp-ffmpeg
ignore = dirty
[submodule "asmjit"]
path = asmjit
url = https://github.com/kobalicek/asmjit
@@ -9,36 +10,41 @@
path = llvm
url = https://github.com/RPCS3/llvm
branch = release_60
ignore = dirty
[submodule "GSL"]
path = 3rdparty/GSL
url = https://github.com/Microsoft/GSL.git
[submodule "libpng"]
path = 3rdparty/libpng
url = https://github.com/RPCS3/libpng
ignore = dirty
[submodule "Vulkan/glslang"]
path = Vulkan/glslang
url = https://github.com/KhronosGroup/glslang.git
[submodule "Vulkan/Vulkan-LoaderAndValidationLayers"]
path = Vulkan/Vulkan-LoaderAndValidationLayers
url = https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers
[submodule "Utilities/yaml-cpp"]
path = Utilities/yaml-cpp
url = https://github.com/RPCS3/yaml-cpp
ignore = dirty
[submodule "3rdparty/cereal"]
path = 3rdparty/cereal
url = https://github.com/USCiLab/cereal.git
ignore = dirty
[submodule "3rdparty/zlib"]
path = 3rdparty/zlib
url = https://github.com/madler/zlib
ignore = dirty
[submodule "3rdparty/hidapi"]
path = 3rdparty/hidapi
url = https://github.com/RPCS3/hidapi
branch = master
ignore = dirty
[submodule "3rdparty/Optional"]
path = 3rdparty/Optional
url = https://github.com/akrzemi1/Optional.git
[submodule "3rdparty/pugixml"]
path = 3rdparty/pugixml
url = https://github.com/zeux/pugixml
ignore = dirty
[submodule "3rdparty/xxHash"]
path = 3rdparty/xxHash
url = https://github.com/Cyan4973/xxHash
ignore = dirty
[submodule "3rdparty/yaml-cpp"]
path = 3rdparty/yaml-cpp
url = https://github.com/jbeder/yaml-cpp.git
ignore = dirty
[submodule "3rdparty/libpng"]
path = 3rdparty/libpng
url = https://github.com/glennrp/libpng.git
ignore = dirty
+32 -119
View File
@@ -1,124 +1,37 @@
language: cpp
sudo: required
os:
- linux
#- osx
# osx_image: xcode6.4
compiler:
- clang
- gcc
cache:
ccache: true
directories:
- $HOME/hombebrew_cache
matrix:
exclude:
- os: osx
compiler: gcc
include:
- os: linux
env:
- NAME="Linux build"
- COMPILER="gcc"
dist: trusty
services: docker
cache: ccache
install: "docker pull rpcs3/rpcs3-travis-trusty:1.0"
script: 'travis_wait docker run -v $(pwd):/rpcs3 -v "$HOME/.ccache":/root/.ccache --env-file .travis/travis.env rpcs3/rpcs3-travis-trusty:1.0 /bin/bash -ex /rpcs3/.travis/build-linux.bash'
- os: linux
env:
- NAME="Linux build"
- COMPILER="clang"
- DEPLOY_APPIMAGE="true"
dist: trusty
services: docker
cache: ccache
install: "docker pull rpcs3/rpcs3-travis-trusty:1.0"
script: 'travis_wait docker run -v $(pwd):/rpcs3 -v "$HOME/.ccache":/root/.ccache --env-file .travis/travis.env rpcs3/rpcs3-travis-trusty:1.0 /bin/bash -ex /rpcs3/.travis/build-linux.bash'
- os: osx
osx_image: xcode10.1
addons:
homebrew:
packages:
- ccache
- glew
- ninja
- qt
script: "/bin/bash -ex .travis/build-mac.bash"
cache: ccache
git:
depth: false # Unshallow clone to obtain proper GIT_VERSION
submodules: false
before_install:
- if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$CXX" = "g++" ]; then
export CXX="g++-5" CC="gcc-5" CXXFLAGS="-Wno-format-security";
fi;
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then
wget http://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run ;
chmod a+x ./qt-unified-linux-x64-online.run ;
export QT_QPA_PLATFORM=minimal ;
travis_wait 60 ./qt-unified-linux-x64-online.run --script qt-installer-noninteractive.qs --no-force-installations --verbose ;
fi;
# Install updated libglew-dev since the version provided by trusty is outdated
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then
wget https://mirrors.kernel.org/ubuntu/pool/universe/g/glew/libglew-dev_2.0.0-5_amd64.deb;
wget https://mirrors.kernel.org/ubuntu/pool/universe/g/glew/libglew2.0_2.0.0-5_amd64.deb;
wget https://mirrors.kernel.org/ubuntu/pool/universe/v/vulkan/libvulkan1_1.0.61.1+dfsg1-1ubuntu1~16.04.1_amd64.deb;
wget https://mirrors.kernel.org/ubuntu/pool/universe/v/vulkan/libvulkan-dev_1.0.61.1+dfsg1-1ubuntu1~16.04.1_amd64.deb;
sudo dpkg -i libglew2.0_2.0.0-5_amd64.deb libglew-dev_2.0.0-5_amd64.deb libvulkan1_1.0.61.1+dfsg1-1ubuntu1~16.04.1_amd64.deb libvulkan-dev_1.0.61.1+dfsg1-1ubuntu1~16.04.1_amd64.deb;
else
brew update;
brew install ccache glew llvm40;
fi;
before_script:
- git submodule update --init asmjit 3rdparty/ffmpeg 3rdparty/pugixml 3rdparty/GSL 3rdparty/libpng Utilities/yaml-cpp 3rdparty/cereal 3rdparty/hidapi 3rdparty/Optional Vulkan/glslang Vulkan/Vulkan-LoaderAndValidationLayers
- mkdir build
- cd build
- export CMAKE_PREFIX_PATH=~/Qt/5.10.0/gcc_64/lib/cmake
- export CXXFLAGS="$CXXFLAGS -DTRAVIS=true";
- if [ "$TRAVIS_PULL_REQUEST" = false ]; then
export CXXFLAGS="$CXXFLAGS -DBRANCH=$TRAVIS_REPO_SLUG/$TRAVIS_BRANCH";
else
export CXXFLAGS="$CXXFLAGS -DBRANCH=$TRAVIS_REPO_SLUG/$TRAVIS_BRANCH/#$TRAVIS_PULL_REQUEST";
fi;
- cmake .. -DCMAKE_INSTALL_PREFIX=/usr -G Ninja;
- ninja
- # AppImage generation
- if [ -n "$UPLOAD_URL" ] && [ "$TRAVIS_BRANCH" = "master" ] && [ "$CC" = "clang" ] && [ "$TRAVIS_PULL_REQUEST" = false ]; then
export LD_LIBRARY_PATH=~/Qt/5.10.0/gcc_64/lib;
DESTDIR=appdir ninja install ; find appdir/ ;
find ../bin ;
wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" ;
chmod a+x linuxdeployqt*.AppImage ;
export PATH=~/Qt/5.10.0/gcc_64/bin/:${PATH} ;
./linuxdeployqt*.AppImage --appimage-extract ;
./linuxdeployqt*.AppImage ./appdir/usr/share/applications/*.desktop -bundle-non-qt-libs ;
mkdir ./appdir/usr/plugins/xcbglintegrations/ ;
mkdir ./appdir/usr/plugins/imageformats/ ;
cp ~/Qt/5.10.0/gcc_64/lib/libQt5Svg.so.5 ./appdir/usr/lib/ ;
cp ~/Qt/5.10.0/gcc_64/plugins/xcbglintegrations/* ./appdir/usr/plugins/xcbglintegrations/ ;
cp ~/Qt/5.10.0/gcc_64/plugins/imageformats/* ./appdir/usr/plugins/imageformats/ ;
cp ~/Qt/5.10.0/gcc_64/plugins/platforms/* ./appdir/usr/plugins/platforms/ ;
rm ./appdir/usr/lib/libfreetype.so.6 ;
export PATH=${TRAVIS_BUILD_DIR}/build/squashfs-root/usr/bin/:${PATH} ;
./squashfs-root/usr/bin/appimagetool ${TRAVIS_BUILD_DIR}/build/appdir ;
find ./appdir -executable -type f -exec ldd {} \; | grep " => /usr" | cut -d " " -f 2-3 | sort | uniq ;
curl ${UPLOAD_URL}${TRAVIS_COMMIT:0:7}-${TRAVIS_BUILD_NUMBER}_linux64 --upload-file ./RPCS3*.AppImage;
fi;
script:
# Add a command to show all the variables. May be useful for debugging Travis.
#- echo "--Shell Export Lists START--" ; export -p; echo "--Shell Export Lists STOP--";
# And to ensure the versions of toolchain
- echo "--CXX version?"; "$CXX" --version; echo "--CXX version confirmed";
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- sourceline: 'ppa:jonathonf/binutils' # We need to update binutils to a newer version to link against the ffmpeg libs on.
packages:
- binutils
- cmake
- ninja-build
- libasound2-dev
- libopenal-dev
- freeglut3-dev
#- libglew-dev
#- libvulkan1
#- libvulkan-dev
- libc6-dev
- llvm-4.0
- llvm-4.0-dev
# Clang 5.0 is now bundled in travis, so we no longer need the ppa version.
#- clang-4.0
- libedit-dev
- g++-5
- gcc-5
- libstdc++-5-dev
- lib32stdc++6
- zlib1g-dev
# We need to install qt 5.10.0 manually because the version trusty provides is too old.
#- qtbase5-dev
- libudev-dev
- libevdev-dev
- libpulse-dev
+35
View File
@@ -0,0 +1,35 @@
#!/bin/env bash -ex
shopt -s nocasematch
# Setup Qt variables
export QT_BASE_DIR=/opt/qt${QTVERMIN}
export PATH=$QT_BASE_DIR/bin:$PATH
export LD_LIBRARY_PATH=$QT_BASE_DIR/lib/x86_64-linux-gnu:$QT_BASE_DIR/lib
cd rpcs3
git submodule update --quiet --init asmjit 3rdparty/ffmpeg 3rdparty/pugixml 3rdparty/GSL 3rdparty/libpng 3rdparty/cereal 3rdparty/hidapi 3rdparty/xxHash 3rdparty/yaml-cpp Vulkan/glslang
# Download pre-compiled llvm libs
curl -sLO https://github.com/RPCS3/llvm/releases/download/continuous-linux-master/llvmlibs-linux.tar.gz
mkdir llvmlibs
tar -xzf ./llvmlibs-linux.tar.gz -C llvmlibs
mkdir build ; cd build
if [ $COMPILER = "gcc" ]; then
# These are set in the dockerfile
export CC=${GCC_BINARY}
export CXX=${GXX_BINARY}
else
export CC=${CLANG_BINARY}
export CXX=${CLANGXX_BINARY}
fi
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_LLVM_SUBMODULE=OFF -DLLVM_DIR=llvmlibs/lib/cmake/llvm/ -DUSE_NATIVE_INSTRUCTIONS=OFF -G Ninja
ninja
cd ..
# If it compiled succesfully let's deploy
if [ $? -eq 0 ] && [ -n "$GITHUB_TOKEN" ] && [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = false ]; then /bin/bash -ex .travis/deploy-linux.bash ; fi
+26
View File
@@ -0,0 +1,26 @@
export CCACHE_SLOPPINESS=pch_defines,time_macros
export CMAKE_PREFIX_PATH=/usr/local/opt/qt5/
export PATH="/usr/local/opt/ccache/libexec:$PATH"
# Allow using optional on 10.13
sudo perl -pi -e 'BEGIN{undef $/;} s/(_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS[ ]+\\\n[^\n]+10)\.14/\1.13/;' \
$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__config
# Setup vulkan and gfx-rs/portability
curl -sLO https://github.com/gfx-rs/portability/releases/download/latest/gfx-portability-macos-latest.zip
unzip -: gfx-portability-macos-latest.zip
curl -sLO https://github.com/KhronosGroup/Vulkan-Headers/archive/sdk-1.1.92.0.zip
unzip -: sdk-*.zip
mkdir vulkan-sdk
ln -s ${PWD}/Vulkan-Headers*/include vulkan-sdk/include
mkdir vulkan-sdk/lib
cp target/release/libportability.dylib vulkan-sdk/lib/libVulkan.dylib
# Let macdeployqt locate and install Vulkan library
install_name_tool -id ${PWD}/vulkan-sdk/lib/libVulkan.dylib vulkan-sdk/lib/libVulkan.dylib
export VULKAN_SDK=${PWD}/vulkan-sdk
git submodule update --quiet --init asmjit 3rdparty/ffmpeg 3rdparty/pugixml 3rdparty/GSL 3rdparty/libpng 3rdparty/cereal 3rdparty/hidapi 3rdparty/xxHash 3rdparty/yaml-cpp Vulkan/glslang
mkdir build; cd build
cmake .. -DWITH_LLVM=OFF -DUSE_NATIVE_INSTRUCTIONS=OFF -G Ninja
ninja
+53
View File
@@ -0,0 +1,53 @@
#!/bin/env bash -ex
shopt -s nocasematch
cd build
if [ "$DEPLOY_APPIMAGE" = "true" ]; then
DESTDIR=appdir ninja install
curl -sLO "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
chmod a+x linuxdeployqt*.AppImage
./linuxdeployqt*.AppImage --appimage-extract
./squashfs-root/AppRun ./appdir/usr/share/applications/*.desktop -bundle-non-qt-libs
ls ./appdir/usr/lib/
rm -r ./appdir/usr/share/doc
rm ./appdir/usr/lib/libxcb*
cp $(readlink -f /lib/x86_64-linux-gnu/libnsl.so.1) ./appdir/usr/lib/libnsl.so.1
export PATH=/rpcs3/build/squashfs-root/usr/bin/:${PATH}
# Embed newer libstdc++ for distros that don't come with it (ubuntu 14.04, 16.04)
mkdir -p appdir/usr/optional/ ; mkdir -p appdir/usr/optional/libstdc++/
cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ./appdir/usr/optional/libstdc++/
rm ./appdir/AppRun
curl -sL https://github.com/RPCS3/AppImageKit-checkrt/releases/download/continuous2/AppRun-patched-x86_64 -o ./appdir/AppRun
chmod a+x ./appdir/AppRun
curl -sL https://github.com/RPCS3/AppImageKit-checkrt/releases/download/continuous2/exec-x86_64.so -o ./appdir/usr/optional/exec.so
# Compile checker binary for AppImageKit-checkrt
# This may need updating if you update the compiler or rpcs3 uses newer c++ features
# See https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/config/abi/pre/gnu.ver
# for which definitions correlate to which CXXABI version.
printf "#include <memory>\nint main(){std::make_exception_ptr(0);}" | $CXX -x c++ -o ./appdir/usr/optional/checker -
# Package it up and send it off
./squashfs-root/usr/bin/appimagetool /rpcs3/build/appdir
ls
COMM_TAG="$(git describe --tags $(git rev-list --tags --max-count=1))"
COMM_COUNT="$(git rev-list --count HEAD)"
curl -sLO https://github.com/hcorion/uploadtool/raw/master/upload.sh
mv ./RPCS3*.AppImage rpcs3-${COMM_TAG}-${COMM_COUNT}-${TRAVIS_COMMIT:0:8}_linux64.AppImage
FILESIZEMB=$(bc <<< "scale=6; $(stat -c %s ./rpcs3*.AppImage)/1000000")
SHA256SUM=($(sha256sum ./rpcs3*.AppImage))
unset TRAVIS_REPO_SLUG
REPO_SLUG=RPCS3/rpcs3-binaries-linux \
UPLOADTOOL_BODY="$SHA256SUM;${FILESIZEMB}MB"\
RELEASE_NAME=build-${TRAVIS_COMMIT}\
RELEASE_TITLE=${COMM_TAG}-${COMM_COUNT}\
REPO_COMMIT=d812f1254a1157c80fd402f94446310560f54e5f\
bash upload.sh rpcs3*.AppImage
fi
if [ "$DEPLOY_PPA" = "true" ]; then
export DEBFULLNAME="RPCS3 Build Bot"
fi
+9
View File
@@ -0,0 +1,9 @@
# Variables set by Travis CI
TRAVIS_PULL_REQUEST
TRAVIS_BRANCH
TRAVIS_COMMIT
# Variables for Travis build matrix
COMPILER
DEPLOY_APPIMAGE
# Private Travis CI variables
GITHUB_TOKEN
+363
View File
@@ -0,0 +1,363 @@
find_package(PkgConfig)
include(ExternalProject)
if(APPLE)
set(PLATFORM_ARCH "macosx/x86_64")
elseif(WIN32)
set(PLATFORM_ARCH "Windows/x86_64")
else()
set(PLATFORM_ARCH "linux/x86_64")
endif()
# Dummy target to use when lib isn't available
add_library(3rdparty_dummy_lib INTERFACE)
# ZLib
if (USE_SYSTEM_ZLIB)
find_package(ZLIB QUIET)
endif()
if (NOT ZLIB_FOUND)
message(STATUS "Using builtin ZLIB")
set(SKIP_INSTALL_ALL ON)
add_subdirectory(zlib EXCLUDE_FROM_ALL)
set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zlib" "${CMAKE_CURRENT_BINARY_DIR}/zlib")
set(ZLIB_LIBRARY zlibstatic)
endif()
add_library(3rdparty_zlib INTERFACE)
target_link_libraries(3rdparty_zlib INTERFACE ${ZLIB_LIBRARY})
target_include_directories(3rdparty_zlib INTERFACE ${ZLIB_INCLUDE_DIR})
# libPNG
# Select the version of libpng to use, default is builtin
if (NOT USE_SYSTEM_LIBPNG)
# We use libpng's static library and don't need to build the shared library and run the tests
set(PNG_SHARED OFF CACHE BOOL "Build shared lib" FORCE)
set(PNG_TESTS OFF CACHE BOOL "Build libpng tests" FORCE)
set(PNG_BUILD_ZLIB ON CACHE BOOL "ZLIB is already build or package is found" FORCE)
set(SKIP_INSTALL_ALL ON)
add_subdirectory(libpng EXCLUDE_FROM_ALL)
set(LIBPNG_TARGET png_static)
target_include_directories(png_static INTERFACE "${libpng_BINARY_DIR}" "${libpng_SOURCE_DIR}")
else()
find_package(PNG REQUIRED)
add_library(3rdparty_system_libpng INTERFACE)
target_include_directories(3rdparty_system_libpng INTERFACE ${PNG_INCLUDE_DIR})
target_link_libraries(3rdparty_system_libpng INTERFACE ${PNG_LIBRARY})
target_compile_definitions(3rdparty_system_libpng INTERFACE ${PNG_DEFINITIONS})
set(LIBPNG_TARGET 3rdparty_system_libpng)
endif()
# pugixml
add_subdirectory(pugixml EXCLUDE_FROM_ALL)
# hidapi
add_library(3rdparty_hidapi INTERFACE)
target_include_directories(3rdparty_hidapi INTERFACE hidapi/hidapi)
if(APPLE)
add_subdirectory(hidapi/mac EXCLUDE_FROM_ALL)
target_include_directories(hidapi-mac PUBLIC hidapi/hidapi)
target_link_libraries(3rdparty_hidapi INTERFACE hidapi-mac "-framework CoreFoundation" "-framework IOKit")
elseif(CMAKE_SYSTEM MATCHES "Linux")
add_subdirectory(hidapi/linux EXCLUDE_FROM_ALL)
target_include_directories(hidapi-hidraw PUBLIC hidapi/hidapi)
target_link_libraries(3rdparty_hidapi INTERFACE hidapi-hidraw udev)
elseif(WIN32)
add_subdirectory(hidapi/windows EXCLUDE_FROM_ALL)
target_include_directories(hidapi-hid PUBLIC hidapi/hidapi)
target_link_libraries(3rdparty_hidapi INTERFACE hidapi-hid Shlwapi.lib)
else()
add_subdirectory(hidapi/libusb EXCLUDE_FROM_ALL)
target_include_directories(hidapi-libusb PUBLIC hidapi/hidapi)
target_link_libraries(3rdparty_hidapi INTERFACE hidapi-libusb usb)
endif()
# yaml-cpp
# We don't want to install yaml-cpp but its cmake file doesn't have option
# to disable it...
# So we just install it to a different directory
set(CMAKE_INSTALL_PREFIX_OLD ${CMAKE_INSTALL_PREFIX})
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/yaml-cpp_install)
set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "Enable testing" FORCE)
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "Enable parse tools" FORCE)
set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "Enable contrib stuff in library" FORCE)
add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL)
set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX_OLD})
# xxHash
set(XXHASH_BUNDLED_MODE ON)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Make xxHash build static libs")
add_subdirectory(xxHash/cmake_unofficial EXCLUDE_FROM_ALL)
target_include_directories(xxhash INTERFACE xxHash)
# cereal
add_library(3rdparty_cereal INTERFACE)
target_include_directories(3rdparty_cereal INTERFACE cereal/include)
# OpenGL
# Prefer GLVND for OpenGL rather than legacy
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
add_library(3rdparty_opengl INTERFACE)
target_include_directories(3rdparty_opengl INTERFACE GL)
if (WIN32)
if(NOT MSVC)
target_link_libraries(3rdparty_opengl INTERFACE ${OPENGL_LIBRARIES} opengl32.lib glu32.lib)
else()
target_link_libraries(3rdparty_opengl INTERFACE dxgi.lib d2d1.lib dwrite.lib)
endif()
else()
target_link_libraries(3rdparty_opengl INTERFACE ${OPENGL_LIBRARIES})
target_compile_definitions(3rdparty_opengl
INTERFACE
-DGL_GLEXT_PROTOTYPES
-DGLX_GLXEXT_PROTOTYPES)
endif()
# GSL
add_library(3rdparty_gsl INTERFACE)
target_include_directories(3rdparty_gsl INTERFACE GSL/include)
# stblib
add_library(3rdparty_stblib INTERFACE)
target_include_directories(3rdparty_stblib INTERFACE stblib)
# discord_rpc
add_library(3rdparty_discord-rpc INTERFACE)
# We don't want Discord Rich Presence on the BSDs and other OSes
if (USE_DISCORD_RPC AND (WIN32 OR CMAKE_SYSTEM MATCHES "Linux" OR APPLE))
if (WIN32 AND NOT MSVC)
ExternalProject_Add(discord-rpc
GIT_REPOSITORY https://github.com/discordapp/discord-rpc
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/discord-rpc
INSTALL_COMMAND ""
)
endif()
target_include_directories(3rdparty_discord-rpc INTERFACE discord-rpc/include)
target_compile_definitions(3rdparty_discord-rpc INTERFACE -DWITH_DISCORD_RPC)
set(DISCORD_RPC_LIB NOTFOUND)
if (WIN32)
if (NOT MSVC)
set(DISCORD_RPC_LIB ${CMAKE_CURRENT_BINARY_DIR}/discord-rpc/src/libdiscord-rpc.a)
else()
find_library(DISCORD_RPC_LIB discord-rpc PATHS discord-rpc/lib/ NO_DEFAULT_PATH)
endif()
elseif(CMAKE_SYSTEM MATCHES "Linux")
find_library(DISCORD_RPC_LIB discord-rpc-linux PATHS discord-rpc/lib/ NO_DEFAULT_PATH)
elseif(APPLE)
find_library(DISCORD_RPC_LIB discord-rpc-mac PATHS discord-rpc/lib/ NO_DEFAULT_PATH)
endif()
target_link_libraries(3rdparty_discord-rpc INTERFACE ${DISCORD_RPC_LIB})
if(APPLE)
target_link_libraries(3rdparty_discord-rpc INTERFACE "objc" "-framework Foundation" "-framework CoreServices")
endif()
endif()
# ALSA
set(ALSA_TARGET 3rdparty_dummy_lib)
if(USE_ALSA)
find_package(ALSA)
if(ALSA_FOUND)
add_library(3rdparty_alsa INTERFACE)
target_compile_definitions(3rdparty_alsa INTERFACE -DHAVE_ALSA)
target_include_directories(3rdparty_alsa SYSTEM INTERFACE ${ALSA_INCLUDE_DIRS})
target_link_libraries(3rdparty_alsa INTERFACE ${ALSA_LIBRARIES})
set(ALSA_TARGET 3rdparty_alsa)
endif()
endif()
# Pulse
set(PULSE_TARGET 3rdparty_dummy_lib)
if(USE_PULSE)
pkg_check_modules(PULSE libpulse-simple)
if(PULSE_FOUND)
add_library(3rdparty_pulse INTERFACE)
target_compile_definitions(3rdparty_pulse INTERFACE -DHAVE_PULSE)
target_include_directories(3rdparty_pulse SYSTEM
INTERFACE ${PULSE_INCLUDE_DIRS})
target_link_libraries(3rdparty_pulse INTERFACE ${PULSE_LDFLAGS})
set(PULSE_TARGET 3rdparty_pulse)
endif()
endif()
# libevdev
set(LIBEVDEV_TARGET 3rdparty_dummy_lib)
if(USE_LIBEVDEV)
pkg_check_modules(LIBEVDEV libevdev)
if(LIBEVDEV_FOUND)
add_library(3rdparty_libevdev INTERFACE)
target_compile_definitions(3rdparty_libevdev INTERFACE -DHAVE_LIBEVDEV)
target_include_directories(3rdparty_libevdev SYSTEM
INTERFACE ${LIBEVDEV_INCLUDE_DIRS})
target_link_libraries(3rdparty_libevdev INTERFACE ${LIBEVDEV_LDFLAGS})
set(LIBEVDEV_TARGET 3rdparty_libevdev)
endif()
endif()
# Vulkan
set(VULKAN_TARGET 3rdparty_dummy_lib)
if(USE_VULKAN)
find_package(Vulkan)
if(VULKAN_FOUND)
add_library(3rdparty_vulkan INTERFACE)
target_compile_definitions(3rdparty_vulkan INTERFACE -DHAVE_VULKAN)
target_link_libraries(3rdparty_vulkan INTERFACE SPIRV Vulkan::Vulkan)
if(UNIX AND NOT APPLE)
find_package(Wayland)
if (WAYLAND_FOUND)
target_include_directories(3rdparty_vulkan
INTERFACE ${WAYLAND_INCLUDE_DIR})
target_compile_definitions(3rdparty_vulkan
INTERFACE -DVK_USE_PLATFORM_WAYLAND_KHR)
endif()
endif()
set(VULKAN_TARGET 3rdparty_vulkan)
else()
message("WARNING! USE_VULKAN was enabled, but libvulkan was not found. RPCS3 will be compiled without Vulkan support.")
endif()
endif()
# OpenAL
if (MSVC)
find_path(OPENAL_INCLUDE_DIR al.h PATHS OpenAL/include)
find_library(OPENAL_LIBRARY OpenAL32 PATHS OpenAL/libs/Win64/)
else()
find_package(OpenAL REQUIRED)
endif()
add_library(3rdparty_openal INTERFACE)
target_include_directories(3rdparty_openal INTERFACE ${OPENAL_INCLUDE_DIR})
target_link_libraries(3rdparty_openal INTERFACE ${OPENAL_LIBRARY})
# FFMPEG
add_library(3rdparty_ffmpeg INTERFACE)
# Select the version of ffmpeg to use, default is builtin
if(USE_SYSTEM_FFMPEG)
message("-- RPCS3: using shared ffmpeg")
find_package(FFMPEG REQUIRED)
target_include_directories(3rdparty_ffmpeg INTERFACE ${FFMPEG_INCLUDE_DIR})
target_link_libraries(3rdparty_ffmpeg INTERFACE ${FFMPEG_LIBRARIES})
else()
set(FFMPEG_PLATFORM_DIR "ffmpeg/${PLATFORM_ARCH}")
if (NOT MSVC AND WIN32)
message("-- RPCS3: building ffmpeg submodule")
ExternalProject_Add(ffmpeg-mingw
DOWNLOAD_COMMAND ""
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/ffmpeg
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg/configure --prefix=./Windows/x86_64 --arch=x86_64 --disable-avdevice --disable-programs --disable-avfilter --disable-postproc --disable-doc --disable-pthreads --enable-w32threads --disable-network --disable-everything --disable-encoders --disable-muxers --disable-hwaccels --disable-parsers --disable-protocols --enable-dxva2 --enable-static --disable-shared --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=atrac3 --enable-decoder=atrac3p --enable-decoder=mp3 --enable-decoder=pcm_s16le --enable-decoder=pcm_s8 --enable-decoder=h264 --enable-decoder=mpeg4 --enable-decoder=mpeg2video --enable-decoder=mjpeg --enable-decoder=mjpegb --enable-encoder=pcm_s16le --enable-encoder=ffv1 --enable-encoder=mpeg4 --enable-parser=h264 --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=mpegvideo --enable-parser=mjpeg --enable-parser=aac --enable-parser=aac_latm --enable-muxer=avi --enable-demuxer=h264 --enable-demuxer=m4v --enable-demuxer=mp3 --enable-demuxer=mpegvideo --enable-demuxer=mpegps --enable-demuxer=mjpeg --enable-demuxer=avi --enable-demuxer=aac --enable-demuxer=pmp --enable-demuxer=oma --enable-demuxer=pcm_s16le --enable-demuxer=pcm_s8 --enable-demuxer=wav --enable-hwaccel=h264_dxva2 --enable-indev=dshow --enable-protocol=file
BUILD_COMMAND make -j 4
INSTALL_COMMAND make install
)
set(FFMPEG_LIB_AVFORMAT "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg/${PLATFORM_ARCH}/lib/libavformat.a")
set(FFMPEG_LIB_AVCODEC "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg/${PLATFORM_ARCH}/lib/libavcodec.a")
set(FFMPEG_LIB_AVUTIL "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg/${PLATFORM_ARCH}/lib/libavutil.a")
set(FFMPEG_LIB_SWSCALE "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg/${PLATFORM_ARCH}/lib/libswscale.a")
else()
message("-- RPCS3: using builtin ffmpeg")
set(FFMPEG_LIB_DIR "${FFMPEG_PLATFORM_DIR}/lib")
find_library(FFMPEG_LIB_AVFORMAT avformat PATHS ${FFMPEG_LIB_DIR} NO_DEFAULT_PATH)
find_library(FFMPEG_LIB_AVCODEC avcodec PATHS ${FFMPEG_LIB_DIR} NO_DEFAULT_PATH)
find_library(FFMPEG_LIB_AVUTIL avutil PATHS ${FFMPEG_LIB_DIR} NO_DEFAULT_PATH)
find_library(FFMPEG_LIB_SWSCALE swscale PATHS ${FFMPEG_LIB_DIR} NO_DEFAULT_PATH)
endif()
target_include_directories(3rdparty_ffmpeg INTERFACE "${FFMPEG_PLATFORM_DIR}/include")
target_link_libraries(3rdparty_ffmpeg
INTERFACE
${FFMPEG_LIB_AVFORMAT}
${FFMPEG_LIB_AVCODEC}
${FFMPEG_LIB_AVUTIL}
${FFMPEG_LIB_SWSCALE})
endif()
# dx12
add_library(3rdparty_dx12 INTERFACE)
if (WIN32)
target_link_libraries(3rdparty_dx12 INTERFACE dxgi.lib d2d1.lib dwrite.lib)
endif()
# GLEW
add_library(3rdparty_glew INTERFACE)
if(NOT MSVC)
find_package(GLEW 1.13.0 REQUIRED)
target_link_libraries(3rdparty_glew INTERFACE GLEW::GLEW)
endif()
# LLVM
include(llvm.cmake)
# add nice ALIAS targets for ease of use
add_library(3rdparty::zlib ALIAS 3rdparty_zlib)
add_library(3rdparty::pugixml ALIAS pugixml)
add_library(3rdparty::yaml-cpp ALIAS yaml-cpp)
add_library(3rdparty::xxhash ALIAS xxhash)
add_library(3rdparty::hidapi ALIAS 3rdparty_hidapi)
add_library(3rdparty::libpng ALIAS ${LIBPNG_TARGET})
add_library(3rdparty::cereal ALIAS 3rdparty_cereal)
add_library(3rdparty::opengl ALIAS 3rdparty_opengl)
add_library(3rdparty::gsl ALIAS 3rdparty_gsl)
add_library(3rdparty::stblib ALIAS 3rdparty_stblib)
add_library(3rdparty::discord-rpc ALIAS 3rdparty_discord-rpc)
add_library(3rdparty::alsa ALIAS ${ALSA_TARGET})
add_library(3rdparty::pulse ALIAS ${PULSE_TARGET})
add_library(3rdparty::libevdev ALIAS ${LIBEVDEV_TARGET})
add_library(3rdparty::vulkan ALIAS ${VULKAN_TARGET})
add_library(3rdparty::openal ALIAS 3rdparty_openal)
add_library(3rdparty::ffmpeg ALIAS 3rdparty_ffmpeg)
add_library(3rdparty::dx12 ALIAS 3rdparty_dx12)
add_library(3rdparty::glew ALIAS 3rdparty_glew)
+699 -25
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1 -1
+118 -2
View File
@@ -13,8 +13,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* Or go to http://www.gnu.org/copyleft/lgpl.html
*/
@@ -97,6 +97,31 @@ extern "C" {
#ifndef AL_EXT_MCFORMATS
#define AL_EXT_MCFORMATS 1
/* Provides support for surround sound buffer formats with 8, 16, and 32-bit
* samples.
*
* QUAD8: Unsigned 8-bit, Quadraphonic (Front Left, Front Right, Rear Left,
* Rear Right).
* QUAD16: Signed 16-bit, Quadraphonic.
* QUAD32: 32-bit float, Quadraphonic.
* REAR8: Unsigned 8-bit, Rear Stereo (Rear Left, Rear Right).
* REAR16: Signed 16-bit, Rear Stereo.
* REAR32: 32-bit float, Rear Stereo.
* 51CHN8: Unsigned 8-bit, 5.1 Surround (Front Left, Front Right, Front Center,
* LFE, Side Left, Side Right). Note that some audio systems may label
* 5.1's Side channels as Rear or Surround; they are equivalent for the
* purposes of this extension.
* 51CHN16: Signed 16-bit, 5.1 Surround.
* 51CHN32: 32-bit float, 5.1 Surround.
* 61CHN8: Unsigned 8-bit, 6.1 Surround (Front Left, Front Right, Front Center,
* LFE, Rear Center, Side Left, Side Right).
* 61CHN16: Signed 16-bit, 6.1 Surround.
* 61CHN32: 32-bit float, 6.1 Surround.
* 71CHN8: Unsigned 8-bit, 7.1 Surround (Front Left, Front Right, Front Center,
* LFE, Rear Left, Rear Right, Side Left, Side Right).
* 71CHN16: Signed 16-bit, 7.1 Surround.
* 71CHN32: 32-bit float, 7.1 Surround.
*/
#define AL_FORMAT_QUAD8 0x1204
#define AL_FORMAT_QUAD16 0x1205
#define AL_FORMAT_QUAD32 0x1206
@@ -393,6 +418,97 @@ ALC_API void ALC_APIENTRY alcDeviceResumeSOFT(ALCdevice *device);
#endif
#endif
#ifndef AL_EXT_BFORMAT
#define AL_EXT_BFORMAT 1
/* Provides support for B-Format ambisonic buffers (first-order, FuMa scaling
* and layout).
*
* BFORMAT2D_8: Unsigned 8-bit, 3-channel non-periphonic (WXY).
* BFORMAT2D_16: Signed 16-bit, 3-channel non-periphonic (WXY).
* BFORMAT2D_FLOAT32: 32-bit float, 3-channel non-periphonic (WXY).
* BFORMAT3D_8: Unsigned 8-bit, 4-channel periphonic (WXYZ).
* BFORMAT3D_16: Signed 16-bit, 4-channel periphonic (WXYZ).
* BFORMAT3D_FLOAT32: 32-bit float, 4-channel periphonic (WXYZ).
*/
#define AL_FORMAT_BFORMAT2D_8 0x20021
#define AL_FORMAT_BFORMAT2D_16 0x20022
#define AL_FORMAT_BFORMAT2D_FLOAT32 0x20023
#define AL_FORMAT_BFORMAT3D_8 0x20031
#define AL_FORMAT_BFORMAT3D_16 0x20032
#define AL_FORMAT_BFORMAT3D_FLOAT32 0x20033
#endif
#ifndef AL_EXT_MULAW_BFORMAT
#define AL_EXT_MULAW_BFORMAT 1
#define AL_FORMAT_BFORMAT2D_MULAW 0x10031
#define AL_FORMAT_BFORMAT3D_MULAW 0x10032
#endif
#ifndef ALC_SOFT_HRTF
#define ALC_SOFT_HRTF 1
#define ALC_HRTF_SOFT 0x1992
#define ALC_DONT_CARE_SOFT 0x0002
#define ALC_HRTF_STATUS_SOFT 0x1993
#define ALC_HRTF_DISABLED_SOFT 0x0000
#define ALC_HRTF_ENABLED_SOFT 0x0001
#define ALC_HRTF_DENIED_SOFT 0x0002
#define ALC_HRTF_REQUIRED_SOFT 0x0003
#define ALC_HRTF_HEADPHONES_DETECTED_SOFT 0x0004
#define ALC_HRTF_UNSUPPORTED_FORMAT_SOFT 0x0005
#define ALC_NUM_HRTF_SPECIFIERS_SOFT 0x1994
#define ALC_HRTF_SPECIFIER_SOFT 0x1995
#define ALC_HRTF_ID_SOFT 0x1996
typedef const ALCchar* (ALC_APIENTRY*LPALCGETSTRINGISOFT)(ALCdevice *device, ALCenum paramName, ALCsizei index);
typedef ALCboolean (ALC_APIENTRY*LPALCRESETDEVICESOFT)(ALCdevice *device, const ALCint *attribs);
#ifdef AL_ALEXT_PROTOTYPES
ALC_API const ALCchar* ALC_APIENTRY alcGetStringiSOFT(ALCdevice *device, ALCenum paramName, ALCsizei index);
ALC_API ALCboolean ALC_APIENTRY alcResetDeviceSOFT(ALCdevice *device, const ALCint *attribs);
#endif
#endif
#ifndef AL_SOFT_gain_clamp_ex
#define AL_SOFT_gain_clamp_ex 1
#define AL_GAIN_LIMIT_SOFT 0x200E
#endif
#ifndef AL_SOFT_source_resampler
#define AL_SOFT_source_resampler
#define AL_NUM_RESAMPLERS_SOFT 0x1210
#define AL_DEFAULT_RESAMPLER_SOFT 0x1211
#define AL_SOURCE_RESAMPLER_SOFT 0x1212
#define AL_RESAMPLER_NAME_SOFT 0x1213
typedef const ALchar* (AL_APIENTRY*LPALGETSTRINGISOFT)(ALenum pname, ALsizei index);
#ifdef AL_ALEXT_PROTOTYPES
AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index);
#endif
#endif
#ifndef AL_SOFT_source_spatialize
#define AL_SOFT_source_spatialize
#define AL_SOURCE_SPATIALIZE_SOFT 0x1214
#define AL_AUTO_SOFT 0x0002
#endif
#ifndef ALC_SOFT_output_limiter
#define ALC_SOFT_output_limiter
#define ALC_OUTPUT_LIMITER_SOFT 0x199A
#endif
#ifndef ALC_SOFT_device_clock
#define ALC_SOFT_device_clock 1
typedef int64_t ALCint64SOFT;
typedef uint64_t ALCuint64SOFT;
#define ALC_DEVICE_CLOCK_SOFT 0x1600
#define ALC_DEVICE_LATENCY_SOFT 0x1601
#define ALC_DEVICE_CLOCK_LATENCY_SOFT 0x1602
#define AL_SAMPLE_OFFSET_CLOCK_SOFT 0x1202
#define AL_SEC_OFFSET_CLOCK_SOFT 0x1203
typedef void (ALC_APIENTRY*LPALCGETINTEGER64VSOFT)(ALCdevice *device, ALCenum pname, ALsizei size, ALCint64SOFT *values);
#ifdef AL_ALEXT_PROTOTYPES
ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname, ALsizei size, ALCint64SOFT *values);
#endif
#endif
#ifdef __cplusplus
}
#endif
+1 -1
View File
@@ -345,7 +345,7 @@ typedef struct {
/* Driving Presets */
#define EFX_REVERB_PRESET_DRIVING_COMMENTATOR \
{ 1.0000f, 0.0000f, 3.1623f, 0.5623f, 0.5012f, 2.4200f, 0.8800f, 0.6800f, 0.1995f, 0.0930f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x1 }
{ 1.0000f, 0.0000f, 0.3162f, 0.5623f, 0.5012f, 2.4200f, 0.8800f, 0.6800f, 0.1995f, 0.0930f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x1 }
#define EFX_REVERB_PRESET_DRIVING_PITGARAGE \
{ 0.4287f, 0.5900f, 0.3162f, 0.7079f, 0.5623f, 1.7200f, 0.9300f, 0.8700f, 0.5623f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 }
-91
View File
@@ -1,84 +1,35 @@
EXPORTS
alAuxiliaryEffectSlotf
alAuxiliaryEffectSlotfv
alAuxiliaryEffectSloti
alAuxiliaryEffectSlotiv
alBuffer3f
alBuffer3i
alBufferData
alBufferSamplesSOFT
alBufferSubDataSOFT
alBufferSubSamplesSOFT
alBufferf
alBufferfv
alBufferi
alBufferiv
alDeferUpdatesSOFT
alDeleteAuxiliaryEffectSlots
alDeleteBuffers
alDeleteEffects
alDeleteFilters
alDeleteFontsoundsSOFT
alDeletePresetsSOFT
alDeleteSoundfontsSOFT
alDeleteSources
alDisable
alDistanceModel
alDopplerFactor
alDopplerVelocity
alEffectf
alEffectfv
alEffecti
alEffectiv
alEnable
alFilterf
alFilterfv
alFilteri
alFilteriv
alFontsound2iSOFT
alFontsoundModulatoriSOFT
alFontsoundiSOFT
alFontsoundivSOFT
alGenAuxiliaryEffectSlots
alGenBuffers
alGenEffects
alGenFilters
alGenFontsoundsSOFT
alGenPresetsSOFT
alGenSoundfontsSOFT
alGenSources
alGetAuxiliaryEffectSlotf
alGetAuxiliaryEffectSlotfv
alGetAuxiliaryEffectSloti
alGetAuxiliaryEffectSlotiv
alGetBoolean
alGetBooleanv
alGetBuffer3f
alGetBuffer3i
alGetBufferSamplesSOFT
alGetBufferf
alGetBufferfv
alGetBufferi
alGetBufferiv
alGetDouble
alGetDoublev
alGetEffectf
alGetEffectfv
alGetEffecti
alGetEffectiv
alGetEnumValue
alGetError
alGetFilterf
alGetFilterfv
alGetFilteri
alGetFilteriv
alGetFloat
alGetFloatv
alGetFontsoundModulatorivSOFT
alGetFontsoundivSOFT
alGetInteger
alGetInteger64SOFT
alGetInteger64vSOFT
alGetIntegerv
alGetListener3f
alGetListener3i
@@ -86,32 +37,17 @@ EXPORTS
alGetListenerfv
alGetListeneri
alGetListeneriv
alGetPresetivSOFT
alGetProcAddress
alGetSoundfontivSOFT
alGetSource3dSOFT
alGetSource3f
alGetSource3i
alGetSource3i64SOFT
alGetSourcedSOFT
alGetSourcedvSOFT
alGetSourcef
alGetSourcefv
alGetSourcei
alGetSourcei64SOFT
alGetSourcei64vSOFT
alGetSourceiv
alGetString
alIsAuxiliaryEffectSlot
alIsBuffer
alIsBufferFormatSupportedSOFT
alIsEffect
alIsEnabled
alIsExtensionPresent
alIsFilter
alIsFontsoundSOFT
alIsPresetSOFT
alIsSoundfontSOFT
alIsSource
alListener3f
alListener3i
@@ -119,25 +55,8 @@ EXPORTS
alListenerfv
alListeneri
alListeneriv
alLoadSoundfontSOFT
alMidiEventSOFT
alMidiGainSOFT
alMidiPauseSOFT
alMidiPlaySOFT
alMidiResetSOFT
alMidiSoundfontSOFT
alMidiSoundfontvSOFT
alMidiStopSOFT
alMidiSysExSOFT
alPresetFontsoundsSOFT
alPresetiSOFT
alPresetivSOFT
alProcessUpdatesSOFT
alSoundfontPresetsSOFT
alSource3dSOFT
alSource3f
alSource3i
alSource3i64SOFT
alSourcePause
alSourcePausev
alSourcePlay
@@ -148,13 +67,9 @@ EXPORTS
alSourceStop
alSourceStopv
alSourceUnqueueBuffers
alSourcedSOFT
alSourcedvSOFT
alSourcef
alSourcefv
alSourcei
alSourcei64SOFT
alSourcei64vSOFT
alSourceiv
alSpeedOfSound
alcCaptureCloseDevice
@@ -165,23 +80,17 @@ EXPORTS
alcCloseDevice
alcCreateContext
alcDestroyContext
alcDevicePauseSOFT
alcDeviceResumeSOFT
alcGetContextsDevice
alcGetCurrentContext
alcGetEnumValue
alcGetError
alcGetInteger64vSOFT
alcGetIntegerv
alcGetProcAddress
alcGetString
alcGetThreadContext
alcIsExtensionPresent
alcIsRenderFormatSupportedSOFT
alcLoopbackOpenDeviceSOFT
alcMakeContextCurrent
alcOpenDevice
alcProcessContext
alcRenderSamplesSOFT
alcSetThreadContext
alcSuspendContext
Binary file not shown.
Submodule 3rdparty/Optional deleted from f27e79084a
+26
View File
@@ -0,0 +1,26 @@
#pragma once
#if defined(DISCORD_DYNAMIC_LIB)
# if defined(_WIN32)
# if defined(DISCORD_BUILDING_SDK)
# define DISCORD_EXPORT __declspec(dllexport)
# else
# define DISCORD_EXPORT __declspec(dllimport)
# endif
# else
# define DISCORD_EXPORT __attribute__((visibility("default")))
# endif
#else
# define DISCORD_EXPORT
#endif
#ifdef __cplusplus
extern "C" {
#endif
DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command);
DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId);
#ifdef __cplusplus
}
#endif
+87
View File
@@ -0,0 +1,87 @@
#pragma once
#include <stdint.h>
// clang-format off
#if defined(DISCORD_DYNAMIC_LIB)
# if defined(_WIN32)
# if defined(DISCORD_BUILDING_SDK)
# define DISCORD_EXPORT __declspec(dllexport)
# else
# define DISCORD_EXPORT __declspec(dllimport)
# endif
# else
# define DISCORD_EXPORT __attribute__((visibility("default")))
# endif
#else
# define DISCORD_EXPORT
#endif
// clang-format on
#ifdef __cplusplus
extern "C" {
#endif
typedef struct DiscordRichPresence {
const char* state; /* max 128 bytes */
const char* details; /* max 128 bytes */
int64_t startTimestamp;
int64_t endTimestamp;
const char* largeImageKey; /* max 32 bytes */
const char* largeImageText; /* max 128 bytes */
const char* smallImageKey; /* max 32 bytes */
const char* smallImageText; /* max 128 bytes */
const char* partyId; /* max 128 bytes */
int partySize;
int partyMax;
const char* matchSecret; /* max 128 bytes */
const char* joinSecret; /* max 128 bytes */
const char* spectateSecret; /* max 128 bytes */
int8_t instance;
} DiscordRichPresence;
typedef struct DiscordJoinRequest {
const char* userId;
const char* username;
const char* discriminator;
const char* avatar;
} DiscordJoinRequest;
typedef struct DiscordEventHandlers {
void (*ready)(void);
void (*disconnected)(int errorCode, const char* message);
void (*errored)(int errorCode, const char* message);
void (*joinGame)(const char* joinSecret);
void (*spectateGame)(const char* spectateSecret);
void (*joinRequest)(const DiscordJoinRequest* request);
} DiscordEventHandlers;
#define DISCORD_REPLY_NO 0
#define DISCORD_REPLY_YES 1
#define DISCORD_REPLY_IGNORE 2
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
DiscordEventHandlers* handlers,
int autoRegister,
const char* optionalSteamId);
DISCORD_EXPORT void Discord_Shutdown(void);
/* checks for incoming messages, dispatches callbacks */
DISCORD_EXPORT void Discord_RunCallbacks(void);
/* If you disable the lib starting its own io thread, you'll need to call this from your own */
#ifdef DISCORD_DISABLE_IO_THREAD
DISCORD_EXPORT void Discord_UpdateConnection(void);
#endif
DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence);
DISCORD_EXPORT void Discord_ClearPresence(void);
DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply);
DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers* handlers);
#ifdef __cplusplus
} /* extern "C" */
#endif
Binary file not shown.
Binary file not shown.
Binary file not shown.
+142
View File
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug Library|x64">
<Configuration>Debug Library</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release Library|x64">
<Configuration>Release Library</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D6973076-9317-4EF2-A0B8-B7A18AC0713E}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>libpng</RootNamespace>
</PropertyGroup>
<Import Project="$(SolutionDir)\3rdparty\zlib.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|x64'">
<LinkIncremental>false</LinkIncremental>
<CustomBuildBeforeTargets />
<TargetName>$(ProjectName)16</TargetName>
<OutDir>$(SolutionDir)lib/</OutDir>
<IntDir>$(SolutionDir)tmp\$(ProjectName)-$(Configuration)-$(Platform)/</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|x64'">
<LinkIncremental>false</LinkIncremental>
<CustomBuildBeforeTargets />
<TargetName>$(ProjectName)16</TargetName>
<OutDir>$(SolutionDir)lib/</OutDir>
<IntDir>$(SolutionDir)tmp\$(ProjectName)-$(Configuration)-$(Platform)/</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>$(WarningLevel)</WarningLevel>
<MinimalRebuild>false</MinimalRebuild>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FunctionLevelLinking>true</FunctionLevelLinking>
<FloatingPointExceptions>false</FloatingPointExceptions>
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
<PrecompiledHeaderFile>pngpriv.h</PrecompiledHeaderFile>
<BrowseInformation>true</BrowseInformation>
<CompileAs>CompileAsC</CompileAs>
<StringPooling>true</StringPooling>
<DisableSpecificWarnings>$(DisableSpecificWarnings)</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(ZLibSrcDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError>$(TreatWarningAsError)</TreatWarningAsError>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|x64'">
<ClCompile>
<WarningLevel>$(WarningLevel)</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FloatingPointExceptions>false</FloatingPointExceptions>
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
<PrecompiledHeaderFile>pngpriv.h</PrecompiledHeaderFile>
<BrowseInformation>true</BrowseInformation>
<CompileAs>CompileAsC</CompileAs>
<StringPooling>true</StringPooling>
<MinimalRebuild>false</MinimalRebuild>
<DisableSpecificWarnings>$(DisableSpecificWarnings)</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(ZLibSrcDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError>$(TreatWarningAsError)</TreatWarningAsError>
<Optimization>Full</Optimization>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Lib>
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include=".\libpng\png.c">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Library|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release Library|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include=".\libpng\pngerror.c" />
<ClCompile Include=".\libpng\pngget.c" />
<ClCompile Include=".\libpng\pngmem.c" />
<ClCompile Include=".\libpng\pngpread.c" />
<ClCompile Include=".\libpng\pngread.c" />
<ClCompile Include=".\libpng\pngrio.c" />
<ClCompile Include=".\libpng\pngrtran.c" />
<ClCompile Include=".\libpng\pngrutil.c" />
<ClCompile Include=".\libpng\pngset.c" />
<ClCompile Include=".\libpng\pngtrans.c" />
<ClCompile Include=".\libpng\pngwio.c" />
<ClCompile Include=".\libpng\pngwrite.c" />
<ClCompile Include=".\libpng\pngwtran.c" />
<ClCompile Include=".\libpng\pngwutil.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include=".\libpng\scripts\pngwin.rc">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Library|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release Library|x64'">true</ExcludedFromBuild>
</ResourceCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
+65
View File
@@ -0,0 +1,65 @@
if(WITH_LLVM)
if(BUILD_LLVM_SUBMODULE)
message(STATUS "LLVM will be built from the submodule.")
set(LLVM_TARGETS_TO_BUILD "X86" CACHE INTERNAL "")
option(LLVM_BUILD_RUNTIME OFF)
option(LLVM_BUILD_TOOLS OFF)
option(LLVM_INCLUDE_DOCS OFF)
option(LLVM_INCLUDE_EXAMPLES OFF)
option(LLVM_INCLUDE_TESTS OFF)
option(LLVM_INCLUDE_TOOLS OFF)
option(LLVM_INCLUDE_UTILS OFF)
option(WITH_POLLY OFF)
option(LLVM_ENABLE_CXX1Z TRUE)
set(CXX_FLAGS_OLD ${CMAKE_CXX_FLAGS})
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS")
endif()
# LLVM needs to be built out-of-tree
add_subdirectory(${CMAKE_SOURCE_DIR}/llvm ${CMAKE_CURRENT_BINARY_DIR}/llvm_build EXCLUDE_FROM_ALL)
set(LLVM_DIR "${CMAKE_CURRENT_BINARY_DIR}/llvm_build/lib/cmake/llvm/")
set(CMAKE_CXX_FLAGS ${CXX_FLAGS_OLD})
# now tries to find LLVM again
find_package(LLVM 8.0 CONFIG)
if(NOT LLVM_FOUND)
message(FATAL_ERROR "Couldn't build LLVM from the submodule. You might need to run `git submodule update --init`")
endif()
else()
message(STATUS "Using prebuilt LLVM")
if (LLVM_DIR AND NOT IS_ABSOLUTE "${LLVM_DIR}")
# change relative LLVM_DIR to be relative to the source dir
set(LLVM_DIR ${CMAKE_SOURCE_DIR}/${LLVM_DIR})
endif()
find_package(LLVM 8.0 CONFIG)
if (NOT LLVM_FOUND)
if (LLVM_VERSION AND LLVM_VERSION_MAJOR LESS 8)
message(FATAL_ERROR "Found LLVM version ${LLVM_VERSION}. Required version 8.0. \
Enable BUILD_LLVM_SUBMODULE option to build LLVM from included as a git submodule.")
endif()
message(FATAL_ERROR "Can't find LLVM libraries from the CMAKE_PREFIX_PATH path or LLVM_DIR. \
Enable BUILD_LLVM_SUBMODULE option to build LLVM from included as a git submodule.")
endif()
endif()
set(LLVM_LIBS LLVMMCJIT LLVMX86CodeGen)
add_library(3rdparty_llvm INTERFACE)
target_link_libraries(3rdparty_llvm INTERFACE ${LLVM_LIBS})
target_include_directories(3rdparty_llvm INTERFACE ${LLVM_INCLUDE_DIRS})
target_compile_definitions(3rdparty_llvm INTERFACE ${LLVM_DEFINITIONS} -DLLVM_AVAILABLE)
add_library(3rdparty::llvm ALIAS 3rdparty_llvm)
else()
add_library(3rdparty::llvm ALIAS 3rdparty_dummy_lib)
endif()
+64
View File
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{EB33566E-DA7F-4D28-9077-88C0B7C77E35}</ProjectGuid>
<RootNamespace>pnglibconf</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(SolutionDir)\3rdparty\zlib.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<CustomBuildBeforeTargets>Build</CustomBuildBeforeTargets>
<IntDir>$(SolutionDir)tmp\$(ProjectName)-$(Configuration)-$(Platform)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>$(WarningLevel)</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<CustomBuildStep>
<Command>copy .\libpng\scripts\pnglibconf.h.prebuilt .\libpng\pnglibconf.h</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Generating pnglibconf.h</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>.\libpng\pnglibconf.h</Outputs>
</CustomBuildStep>
<CustomBuildStep>
<Inputs>.\libpng\scripts\pnglibconf.h.prebuilt</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemGroup>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
+49
View File
@@ -0,0 +1,49 @@
add_library(3rdparty_qt5 INTERFACE)
find_package(Qt5 5.10 CONFIG COMPONENTS Widgets Network Qml)
if(WIN32)
find_package(Qt5 5.10 COMPONENTS WinExtras REQUIRED)
target_link_libraries(3rdparty_qt5 INTERFACE Qt5::Widgets Qt5::WinExtras Qt5::Network Qt5::Qml)
else()
find_package(Qt5 5.10 COMPONENTS DBus Gui)
if(Qt5DBus_FOUND)
target_link_libraries(3rdparty_qt5 INTERFACE Qt5::Widgets Qt5::DBus Qt5::Network Qt5::Qml)
target_compile_definitions(3rdparty_qt5 INTERFACE -DHAVE_QTDBUS)
else()
target_link_libraries(3rdparty_qt5 INTERFACE Qt5::Widgets Qt5::Network Qt5::Qml)
endif()
target_include_directories(3rdparty_qt5 INTERFACE ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
endif()
if(NOT Qt5Widgets_FOUND)
if(Qt5Widgets_VERSION VERSION_LESS 5.10.0)
message("Minimum supported Qt5 version is 5.10.0! You have version ${Qt5Widgets_VERSION} installed, please upgrade!")
if(CMAKE_SYSTEM MATCHES "Linux")
message(FATAL_ERROR "Most distros do not provide an up-to-date version of Qt.
If you're on Ubuntu or Linux Mint, there are PPAs you can use to install one of the latest qt5 versions.
https://launchpad.net/~beineri/+archive/ubuntu/opt-qt-5.11.0-bionic
https://launchpad.net/~beineri/+archive/ubuntu/opt-qt-5.11.0-xenial
https://launchpad.net/~beineri/+archive/ubuntu/opt-qt-5.10.1-trusty
just make sure to run
source /opt/qt511/bin/qt511-env.sh
respective
source /opt/qt510/bin/qt510-env.sh
before re-running cmake")
elseif(WIN32)
message(FATAL_ERROR "You can download the latest version of Qt5 here: https://www.qt.io/download-open-source/")
else()
message(FATAL_ERROR "Look online for instructions on installing an up-to-date Qt5 on ${CMAKE_SYSTEM}.")
endif()
endif()
message("CMake was unable to find Qt5!")
if(WIN32)
message(FATAL_ERROR "Make sure the QTDIR env variable has been set properly. (for example C:\\Qt\\5.11.1\\msvc2017_64\\)")
elseif(CMAKE_SYSTEM MATCHES "Linux")
message(FATAL_ERROR "Make sure to install your distro's qt5 package!")
else()
message(FATAL_ERROR "You need to have Qt5 installed, look online for instructions on installing Qt5 on ${CMAKE_SYSTEM}.")
endif()
endif()
add_library(3rdparty::qt5 ALIAS 3rdparty_qt5)
+5428 -4664
View File
File diff suppressed because it is too large Load Diff
+3849 -2297
View File
File diff suppressed because it is too large Load Diff
Vendored Submodule
+1
Submodule 3rdparty/xxHash added at 3064d42e7d
+59
View File
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{939FE206-1182-ABC3-1234-FEAB88E98404}</ProjectGuid>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\rpcs3_default.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="..\rpcs3_debug.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="..\rpcs3_release.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="xxHash/xxhash.c" />
</ItemGroup>
<ItemGroup>
<Text Include="LICENSE" />
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="xxHash/xxhash.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Vendored Submodule
+1
Submodule 3rdparty/yaml-cpp added at c90c08ccc9
+1 -1
View File
@@ -19,7 +19,7 @@
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
+1 -1
View File
@@ -2,7 +2,7 @@
<!--
* zlib.props - location of zlib source
*
* libpng version 1.6.20 - December 3, 2015
* libpng version 1.6.34 - September 29, 2017
*
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
*
+106
View File
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(ZLibSrcDir)\adler32.c" />
<ClCompile Include="$(ZLibSrcDir)\compress.c" />
<ClCompile Include="$(ZLibSrcDir)\crc32.c" />
<ClCompile Include="$(ZLibSrcDir)\deflate.c" />
<ClCompile Include="$(ZLibSrcDir)\infback.c" />
<ClCompile Include="$(ZLibSrcDir)\inffast.c" />
<ClCompile Include="$(ZLibSrcDir)\inflate.c" />
<ClCompile Include="$(ZLibSrcDir)\inftrees.c" />
<ClCompile Include="$(ZLibSrcDir)\trees.c" />
<ClCompile Include="$(ZLibSrcDir)\uncompr.c" />
<ClCompile Include="$(ZLibSrcDir)\zutil.c" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{60F89955-91C6-3A36-8000-13C592FEC2DF}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>zlib</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(SolutionDir)\3rdparty\zlib.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)lib\$(Configuration)-$(Platform)\</OutDir>
<IntDir>$(SolutionDir)tmp\$(ProjectName)-$(Configuration)-$(Platform)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)lib\$(Configuration)-$(Platform)\</OutDir>
<IntDir>$(SolutionDir)tmp\$(ProjectName)-$(Configuration)-$(Platform)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>$(WarningLevel)</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<BrowseInformation>true</BrowseInformation>
<FunctionLevelLinking>true</FunctionLevelLinking>
<DisableSpecificWarnings>$(DisableSpecificWarnings);4127;4131;4242;4244</DisableSpecificWarnings>
<TreatWarningAsError>$(TreatWarningAsError)</TreatWarningAsError>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>$(WarningLevel)</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Full</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<WholeProgramOptimization>true</WholeProgramOptimization>
<BufferSecurityCheck>false</BufferSecurityCheck>
<BrowseInformation>true</BrowseInformation>
<FunctionLevelLinking>true</FunctionLevelLinking>
<DisableSpecificWarnings>$(DisableSpecificWarnings);4127;4131;4242;4244</DisableSpecificWarnings>
<TreatWarningAsError>$(TreatWarningAsError)</TreatWarningAsError>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Lib>
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
</Lib>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
+38 -29
View File
@@ -1,19 +1,41 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.8.2)
project(rpcs3)
option(WITH_GDB "WITH_GDB" OFF)
option(WITHOUT_LLVM "WITHOUT_LLVM" OFF)
option(USE_NATIVE_INSTRUCTIONS "USE_NATIVE_INSTRUCTIONS makes rpcs3 compile with -march=native, which is useful for local builds, but not good for packages." ON)
option(WITH_LLVM "Enable usage of LLVM library" ON)
option(BUILD_LLVM_SUBMODULE "Build LLVM from git submodule" ON)
option(USE_ALSA "ALSA audio backend" ON)
option(USE_PULSE "PulseAudio audio backend" ON)
option(USE_LIBEVDEV "libevdev-based joystick support" ON)
option(USE_DISCORD_RPC "Discord rich presence integration" ON)
option(USE_SYSTEM_ZLIB "Prefer system ZLIB instead of the builtin one" ON)
option(USE_VULKAN "Vulkan render backend" ON)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/rpcs3/cmake_modules")
set(CMAKE_CXX_STANDARD 17)
include(CheckCXXCompilerFlag)
if (WITH_GDB)
add_definitions(-DWITH_GDB_DEBUGGER)
endif()
set(ASMJIT_STATIC TRUE)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DNDEBUG)
endif()
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
message( FATAL_ERROR "RPCS3 can only be compiled on 64-bit platforms." )
endif()
@@ -24,36 +46,23 @@ if (CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif()
add_definitions(-DCMAKE_BUILD)
# We use libpng's static library and don't need to build the shared library and run the tests
set(PNG_SHARED OFF CACHE BOOL "Build shared lib." FORCE)
set(PNG_TESTS OFF CACHE BOOL "Build tests." FORCE)
# Select the version of libpng to use, default is builtin
if (NOT USE_SYSTEM_LIBPNG)
add_subdirectory( 3rdparty/libpng )
if(WIN32)
add_definitions(-DUNICODE)
add_definitions(-D_WIN32_WINNT=0x0602)
endif()
option(VULKAN_PREBUILT "" OFF)
if(APPLE)
include_directories(/opt/local/include)
link_directories(/opt/local/lib)
endif()
add_subdirectory(Vulkan EXCLUDE_FROM_ALL)
add_subdirectory(asmjitsrc EXCLUDE_FROM_ALL)
add_subdirectory(3rdparty)
# TODO: do real installation, including copying directory structure
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BINARY_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJECT_BINARY_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${PROJECT_BINARY_DIR}/bin")
add_subdirectory( Vulkan )
add_subdirectory( rpcs3 )
include_directories(3rdparty/hidapi/hidapi)
if(APPLE)
add_subdirectory(3rdparty/hidapi/mac)
#list(APPEND LIBS hidapi)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_subdirectory(3rdparty/hidapi/linux)
elseif(MSVC)
add_subdirectory(3rdparty/hidapi/windows)
else()
add_subdirectory(3rdparty/hidapi/libusb)
#list(APPEND LIBS hidapi-libusb)
endif()
add_subdirectory(rpcs3)
+60 -70
View File
@@ -4,103 +4,93 @@ RPCS3
[![Build Status](https://travis-ci.org/RPCS3/rpcs3.svg?branch=master)](https://travis-ci.org/RPCS3/rpcs3)
[![Build status](https://ci.appveyor.com/api/projects/status/411c4clmiohtx7eo/branch/master?svg=true)](https://ci.appveyor.com/project/rpcs3/rpcs3/branch/master)
The world's first open-source PlayStation 3 emulator/debugger written in C++ for Windows and Linux.
The world's first free and open-source PlayStation 3 emulator/debugger, written in C++ for Windows and Linux.
You can find some basic information in our [**website**](https://rpcs3.net/).
For discussion about this emulator and PS3 emulation please visit our [**forums**](https://forums.rpcs3.net) and our [**Discord server**](https://discord.me/RPCS3).
You can find some basic information on our [**website**](https://rpcs3.net/). Game info is being populated on the [**Wiki**](https://wiki.rpcs3.net/).
For discussion about this emulator, PS3 emulation, and game compatibility reports, please visit our [**forums**](https://forums.rpcs3.net) and our [**Discord server**](https://discord.me/RPCS3).
[**Support Lead Developers Nekotekina and kd-11 on Patreon**](https://www.patreon.com/Nekotekina)
## Development
## Contributing
If you want to contribute please take a look at the [Coding Style](https://github.com/RPCS3/rpcs3/wiki/Coding-Style), [Roadmap](https://github.com/RPCS3/rpcs3/wiki/Roadmap) and [Developer Information](https://github.com/RPCS3/rpcs3/wiki/Developer-Information) pages. You should as well contact any of the developers in the forums or in Discord in order to know more about the current situation of the emulator.
If you want to help the project but do not code, the best way to help out is to test games and make bug reports. See:
* [Quickstart](https://rpcs3.net/quickstart)
If you want to contribute as a developer, please take a look at the following pages:
* [Coding Style](https://github.com/RPCS3/rpcs3/wiki/Coding-Style)
* [Developer Information](https://github.com/RPCS3/rpcs3/wiki/Developer-Information)
* [Roadmap](https://rpcs3.net/roadmap)
You should also contact any of the developers in the forums or in the Discord server to learn more about the current state of the emulator.
## Dependencies
### Windows
* [Visual Studio 2015](https://www.visualstudio.com/vs/older-downloads/)
* [Visual C++ Redistributable Packages for Visual Studio 2015](http://www.microsoft.com/en-us/download/details.aspx?id=48145)
* [Cmake 3.1.0+](https://www.cmake.org/download/) (required; add to PATH)
* [Python 3.3+](https://www.python.org/downloads/) (required; add to PATH)
* [Qt 5.8+](https://www.qt.io/download-open-source/) (required; add QTDIR `<QtInstallFolder>\5.8\msvc2015_64\` environment variable if you do not want to use the Visual Studio Qt Plugin)
* [Visual Studio Qt Plugin](https://marketplace.visualstudio.com/items?itemName=TheQtCompany.QtVisualStudioTools2015) (optional; see above)
* [Visual Studio 2017](https://www.visualstudio.com/en/downloads/)
* [Visual C++ Redistributable Packages for Visual Studio 2017](https://go.microsoft.com/fwlink/?LinkId=746572)
* [CMake 3.8.2+](https://www.cmake.org/download/) (add to PATH)
* [Python 3.3+](https://www.python.org/downloads/) (add to PATH)
* [Vulkan SDK](https://vulkan.lunarg.com/sdk/home) (See "Install the SDK" [here](https://vulkan.lunarg.com/doc/sdk/latest/windows/getting_started.html))
* [Qt 5.10+](https://www.qt.io/download-open-source/) (Avoid 5.11.1, due to a bug)
**Either add the** `QTDIR` **environment variable, e.g.** `<QtInstallFolder>\5.11.2\msvc2017_64\` **, or use the [Visual Studio Qt Plugin](https://marketplace.visualstudio.com/items?itemName=TheQtCompany.QtVisualStudioTools-19123)**
### Linux
* [Qt 5.7+](https://www.qt.io/download-open-source/)
* GCC 5.1+ or Clang 3.5.0+ ([not GCC 6.1](https://github.com/RPCS3/rpcs3/issues/1691))
* Debian & Ubuntu: `sudo apt-get install cmake build-essential libasound2-dev libpulse-dev libopenal-dev libglew-dev zlib1g-dev libedit-dev libvulkan-dev libudev-dev git qt5-default`
* Arch: `sudo pacman -S glew openal cmake llvm qt5-base`
* Fedora: `sudo dnf install cmake glew glew-devel libatomic libudev-devel openal-devel qt5-devel vulkan-devel`
* [Qt 5.10+](https://www.qt.io/download-open-source/) (Avoid 5.11.1, due to a bug)
* GCC 7.3+ or Clang 5.0+
* CMake 3.8.2+
* Debian & Ubuntu: `sudo apt-get install cmake build-essential libasound2-dev libpulse-dev libopenal-dev libglew-dev zlib1g-dev libedit-dev libvulkan-dev libudev-dev git qt5-default libevdev-dev`
* Arch: `sudo pacman -S glew openal cmake vulkan-validation-layers qt5-base qt5-declarative`
* Fedora: `sudo dnf install alsa-lib-devel cmake glew glew-devel libatomic libevdev-devel libudev-devel openal-devel qt5-devel vulkan-devel`
* OpenSUSE: `sudo zypper install git cmake libasound2 libpulse-devel openal-soft-devel glew-devel zlib-devel libedit-devel vulkan-devel libudev-devel libqt5-qtbase-devel libevdev-devel`
**If you have a NVIDIA GPU, you may need to install the libglvnd package.**
### MacOS
MacOS is not supported at this moment because it doesn't meet system requirements (OpenGL 4.3)
* Xcode 6+ (tested with Xcode 6.4)
* Install with Homebrew: `brew install glew llvm qt cmake`
**If you have an NVIDIA GPU, you may need to install the libglvnd package.**
## Building on Windows:
To initialize the repository don't forget to execute `git submodule update --init` to pull the submodules.
## Building
### Configuring Qt
Only Windows and Linux are officially supported for building. However, various other platforms are capable of building RPCS3. Other instructions may be found [here](https://wiki.rpcs3.net/index.php?title=Building).
*If you're using Visual Studio 2017 without Qt plugin support (or simply dont want to use it):*
1) Add `QTDIR` environment variable and set it to `<QtInstallFolder>\5.8\msvc2015_64\` </br>
Clone and initialize the repository:
1) `git clone https://github.com/RPCS3/rpcs3.git`
2) `cd rpcs3/`
3) `git submodule update --init`
### Windows
#### Configuring the Qt plugin (if used)
1) Go to the Qt5 menu and edit Qt5 options.
2) Add the path to your Qt installation with compiler e.g. `<QtInstallFolder>\5.11.2\msvc2017_64`.
3) While selecting the rpcs3qt project, go to Qt5->Project Setting and select the version you added.
#### Building the projects
Open `rpcs3.sln`. The recommended build configuration is `Release - LLVM` for all purposes.
You may want to download precompiled [LLVM libs](https://github.com/RPCS3/llvm/releases/download/continuous-master/llvmlibs.7z) and extract to root rpcs3 folder (which contains `rpcs3.sln`), as well as download and extract [additional libs](https://drive.google.com/uc?export=download&id=1A2eOMmCO714i0U7J0qI4aEMKnuWl8l_R) to `lib\%CONFIGURATION%-x64\` to speed up compilation time (unoptimised/debug libs are currently not available precompiled).
If you're not using precompiled libs, build the projects in *__BUILD_BEFORE* folder: right-click on every project > *Build*.
Open `rpcs3.sln`
`Build > Build Solution`
*If you wish to use the Visual Studio plugin for Qt:* </br>
1) Go to the Qt5 menu and edit Qt5 options. Add the path to your Qt installation with compiler e.g. `C:\Qt\5.8\msvc2015_64`. </br>
2) While selecting the rpcs3qt project, go to Qt5->Project Setting and select the version you added.
### Linux
### Building the projects
You may want to download precompiled [LLVM lib](https://drive.google.com/uc?export=download&id=0B8A6NaxhQAGRY2k3Q2Yya05lcm8) and extract to root rpcs3 folder (which contains `rpcs3.sln`), as well as download and extract [additional libs](https://drive.google.com/uc?export=download&id=0B8A6NaxhQAGRaHYxV3VOS2d0a0U) to `lib\%CONFIGURATION%-x64\` to speed up compilation time (unoptimised/debug libs are currently not available precompiled).
While still in the project root:
If you're not using precompiled libs, build the projects in *__BUILD_BEFORE* folder: right-click on every project > *Build*. </br></br>
`Build > Build Solution`</br>
## Building on Linux & Mac OS:
1) `git clone https://github.com/RPCS3/rpcs3.git` </br>
2) `cd rpcs3/` </br>
3) `git submodule update --init` </br>
4) `cd ../ && mkdir rpcs3_build && cd rpcs3_build`
4) `cmake ../rpcs3/ && make GitVersion && make` </br>
5) Run RPCS3 with `./bin/rpcs3` </br>
If you are on MacOS and want to build with brew llvm and qt don't forget to add the following environment variables
* `LLVM_DIR=/usr/local/opt/llvm/` (or wherever llvm was installed).
* `Qt5_DIR=/usr/local/opt/qt/lib/cmake/Qt5` (or wherever qt was installed).
1) `cd .. && mkdir rpcs3_build && cd rpcs3_build`
2) `cmake ../rpcs3/ && make GitVersion && make`
3) Run RPCS3 with `./bin/rpcs3`
When using GDB, configure it to ignore SIGSEGV signal (`handle SIGSEGV nostop noprint`).
## CMake Build Options (Linux & Mac OS)
- ```-DUSE_SYSTEM_LIBPNG=ON/OFF``` (default = *OFF*)
Build against the shared libpng instead of using the builtin one. libpng 1.6+ highly recommended. Try this option if you get version conflict errors or only see black game icons.
- ```-DUSE_SYSTEM_FFMPEG=ON/OFF``` (default = *OFF*)
Build against the shared ffmpeg libraries instead of using the builtin patched version. Try this if the builtin version breaks the OpenGL renderer for you.
- ```-DWITHOUT_LLVM=ON/OFF``` (default = *OFF*)
This forces RPCS3 to build without LLVM, not recommended.
- ```-DWITH_GDB=ON/OFF``` (default = *OFF*)
This Builds RPCS3 with support for debugging PS3 games using gdb.
- ```-DUSE_VULKAN=ON/OFF``` (default = *ON*)
This builds RPCS3 with Vulkan support.
If desired, use the various build options in [CMakeLists](https://github.com/RPCS3/rpcs3/blob/master/CMakeLists.txt).
## License
Most files are licensed under the terms of GNU GPLv2 License, see LICENSE file for details. Some files may be licensed differently, check appropriate file headers for details.
Most files are licensed under the terms of GNU GPLv2 License; see LICENSE file for details. Some files may be licensed differently; check appropriate file headers for details.
+429 -321
View File
File diff suppressed because it is too large Load Diff
+20 -36
View File
@@ -1,6 +1,7 @@
#pragma once
#include "types.h"
#include <cstring>
// 128-bit vector type and also se_storage<> storage type
union alignas(16) v128
@@ -307,7 +308,7 @@ struct offset32_array<v128::masked_array_t<T, N, M>>
template <typename Arg>
static inline u32 index32(const Arg& arg)
{
return SIZE_32(T) * (static_cast<u32>(arg) ^ static_cast<u32>(M));
return u32{sizeof(T)} * (static_cast<u32>(arg) ^ static_cast<u32>(M));
}
};
@@ -334,7 +335,10 @@ inline v128 operator~(const v128& other)
template <typename T, std::size_t Align, std::size_t Size>
struct se_storage
{
using type = std::aligned_storage_t<Size, Align>;
struct type
{
alignas(Align) std::byte data[Size];
};
// Unoptimized generic byteswap for unaligned data
static void reverse(u8* dst, const u8* src)
@@ -358,16 +362,6 @@ struct se_storage
reverse(reinterpret_cast<u8*>(&result), reinterpret_cast<const u8*>(&src));
return result;
}
static type copy(const type& src)
{
type result;
for (std::size_t i = 0; i < Size; i++)
{
reinterpret_cast<u8*>(&result)[i] = reinterpret_cast<const u8*>(&src)[i];
}
return result;
}
};
template <typename T>
@@ -394,11 +388,6 @@ struct se_storage<T, 2, 2>
const u16 result = swap(src);
return reinterpret_cast<const T&>(result);
}
static inline T copy(const T& src)
{
return src;
}
};
template <typename T>
@@ -425,11 +414,6 @@ struct se_storage<T, 4, 4>
const u32 result = swap(src);
return reinterpret_cast<const T&>(result);
}
static inline T copy(const T& src)
{
return src;
}
};
template <typename T>
@@ -456,11 +440,6 @@ struct se_storage<T, 8, 8>
const u64 result = swap(src);
return reinterpret_cast<const T&>(result);
}
static inline T copy(const T& src)
{
return src;
}
};
template <typename T>
@@ -483,11 +462,6 @@ struct se_storage<T, 16, 16>
const v128 result = swap(src);
return reinterpret_cast<const T&>(result);
}
static inline T copy(const T& src)
{
return src;
}
};
// Switched endianness
@@ -550,31 +524,41 @@ class se_t<T, false, Align>
stype m_data;
static stype init(type value)
{
stype result;
std::memcpy(&result, &value, sizeof(result));
return result;
}
public:
se_t() = default;
se_t(type value)
: m_data(reinterpret_cast<const stype&>(value))
: m_data(init(value))
{
}
type value() const
{
return storage::copy(reinterpret_cast<const type&>(m_data));
type result;
std::memcpy(&result, &m_data, sizeof(result));
return result;
}
se_t& operator=(const se_t& value) = default;
se_t& operator=(type value)
{
return m_data = reinterpret_cast<const stype&>(value), *this;
std::memcpy(&m_data, &value, sizeof(m_data));
return *this;
}
using simple_type = simple_t<T>;
operator type() const
{
return storage::copy(reinterpret_cast<const type&>(m_data));
return value();
}
};
+243
View File
@@ -0,0 +1,243 @@
#pragma once
#include <Utilities/types.h>
#ifdef _WIN32
#include "windows.h"
#include "tlhelp32.h"
#else
#include "stdlib.h"
#include "sys/times.h"
#include "sys/types.h"
#include "unistd.h"
#endif
#ifdef __APPLE__
# include <mach/mach_init.h>
# include <mach/task.h>
# include <mach/vm_map.h>
#endif
#ifdef __linux__
# include <dirent.h>
#endif
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# include <sys/sysctl.h>
# if defined(__DragonFly__) || defined(__FreeBSD__)
# include <sys/user.h>
# endif
# if defined(__NetBSD__)
# undef KERN_PROC
# define KERN_PROC KERN_PROC2
# define kinfo_proc kinfo_proc2
# endif
# if defined(__DragonFly__)
# define KP_NLWP(kp) (kp.kp_nthreads)
# elif defined(__FreeBSD__)
# define KP_NLWP(kp) (kp.ki_numthreads)
# elif defined(__NetBSD__)
# define KP_NLWP(kp) (kp.p_nlwps)
# endif
#endif
class CPUStats
{
#ifdef _WIN32
HANDLE m_self;
using time_type = ULARGE_INTEGER;
#else
using time_type = clock_t;
#endif
private:
s32 m_num_processors;
time_type m_last_cpu, m_sys_cpu, m_usr_cpu;
public:
CPUStats()
{
#ifdef _WIN32
SYSTEM_INFO sysInfo;
FILETIME ftime, fsys, fuser;
GetSystemInfo(&sysInfo);
m_num_processors = sysInfo.dwNumberOfProcessors;
GetSystemTimeAsFileTime(&ftime);
memcpy(&m_last_cpu, &ftime, sizeof(FILETIME));
m_self = GetCurrentProcess();
GetProcessTimes(m_self, &ftime, &ftime, &fsys, &fuser);
memcpy(&m_sys_cpu, &fsys, sizeof(FILETIME));
memcpy(&m_usr_cpu, &fuser, sizeof(FILETIME));
#else
struct tms timeSample;
m_last_cpu = times(&timeSample);
m_sys_cpu = timeSample.tms_stime;
m_usr_cpu = timeSample.tms_utime;
m_num_processors = sysconf(_SC_NPROCESSORS_ONLN);
#endif
}
double get_usage()
{
#ifdef _WIN32
FILETIME ftime, fsys, fusr;
ULARGE_INTEGER now, sys, usr;
GetSystemTimeAsFileTime(&ftime);
memcpy(&now, &ftime, sizeof(FILETIME));
GetProcessTimes(m_self, &ftime, &ftime, &fsys, &fusr);
memcpy(&sys, &fsys, sizeof(FILETIME));
memcpy(&usr, &fusr, sizeof(FILETIME));
double percent = double(sys.QuadPart - m_sys_cpu.QuadPart) + (usr.QuadPart - m_usr_cpu.QuadPart);
percent /= (now.QuadPart - m_last_cpu.QuadPart);
percent /= m_num_processors;
m_last_cpu = now;
m_usr_cpu = usr;
m_sys_cpu = sys;
return std::clamp(percent * 100, 0.0, 100.0);
#else
struct tms timeSample;
clock_t now;
double percent;
now = times(&timeSample);
if (now <= m_last_cpu || timeSample.tms_stime < m_sys_cpu || timeSample.tms_utime < m_usr_cpu)
{
// Overflow detection. Just skip this value.
percent = -1.0;
}
else
{
percent = (timeSample.tms_stime - m_sys_cpu) + (timeSample.tms_utime - m_usr_cpu);
percent /= (now - m_last_cpu);
percent /= m_num_processors;
percent *= 100;
}
m_last_cpu = now;
m_sys_cpu = timeSample.tms_stime;
m_usr_cpu = timeSample.tms_utime;
return percent;
#endif
}
static u32 get_thread_count()
{
#ifdef _WIN32
// first determine the id of the current process
DWORD const id = GetCurrentProcessId();
// then get a process list snapshot.
HANDLE const snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
// initialize the process entry structure.
PROCESSENTRY32 entry = {0};
entry.dwSize = sizeof(entry);
// get the first process info.
BOOL ret = true;
ret = Process32First(snapshot, &entry);
while (ret && entry.th32ProcessID != id)
{
ret = Process32Next(snapshot, &entry);
}
CloseHandle(snapshot);
return ret ? entry.cntThreads : 0;
#elif defined(__APPLE__)
const task_t task = mach_task_self();
mach_msg_type_number_t thread_count;
thread_act_array_t thread_list;
if (task_threads(task, &thread_list, &thread_count) != KERN_SUCCESS)
{
return 0;
}
vm_deallocate(task, reinterpret_cast<vm_address_t>(thread_list),
sizeof(thread_t) * thread_count);
return static_cast<u32>(thread_count);
#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
int mib[] = {
CTL_KERN,
KERN_PROC,
KERN_PROC_PID,
getpid(),
#if defined(__NetBSD__)
sizeof(struct kinfo_proc),
1,
#endif
};
u_int miblen = std::size(mib);
struct kinfo_proc info;
size_t size = sizeof(info);
if (sysctl(mib, miblen, &info, &size, NULL, 0))
{
return 0;
}
return KP_NLWP(info);
#elif defined(__OpenBSD__)
int mib[] = {
CTL_KERN,
KERN_PROC,
KERN_PROC_PID | KERN_PROC_SHOW_THREADS,
getpid(),
sizeof(struct kinfo_proc),
0,
};
u_int miblen = std::size(mib);
// get number of structs
size_t size;
if (sysctl(mib, miblen, NULL, &size, NULL, 0))
{
return 0;
}
mib[5] = size / mib[4];
// populate array of structs
struct kinfo_proc info[mib[5]];
if (sysctl(mib, miblen, &info, &size, NULL, 0))
{
return 0;
}
// exclude empty members
u32 thread_count{0};
for (int i = 0; i < size / mib[4]; i++)
{
if (info[i].p_tid != -1)
++thread_count;
}
return thread_count;
#elif defined(__linux__)
u32 thread_count{0};
DIR* proc_dir = opendir("/proc/self/task");
if (proc_dir)
{
// proc available, iterate through tasks and count them
struct dirent* entry;
while ((entry = readdir(proc_dir)) != NULL)
{
if (entry->d_name[0] == '.')
continue;
++thread_count;
}
closedir(proc_dir);
}
return thread_count;
#else
// unimplemented
return 0;
#endif
}
};
+7 -9
View File
@@ -7,8 +7,6 @@
namespace cfg
{
logs::channel cfg("CFG");
_base::_base(type _type)
: m_type(_type)
{
@@ -67,19 +65,19 @@ bool cfg::try_to_int64(s64* out, const std::string& value, s64 min, s64 max)
}
catch (const std::exception& e)
{
if (out) cfg.error("cfg::try_to_int('%s'): exception: %s", value, e.what());
if (out) LOG_ERROR(GENERAL, "cfg::try_to_int('%s'): exception: %s", value, e.what());
return false;
}
if (pos != value.size())
{
if (out) cfg.error("cfg::try_to_int('%s'): unexpected characters (pos=%zu)", value, pos);
if (out) LOG_ERROR(GENERAL, "cfg::try_to_int('%s'): unexpected characters (pos=%zu)", value, pos);
return false;
}
if (result < min || result > max)
{
if (out) cfg.error("cfg::try_to_int('%s'): out of bounds (%lld..%lld)", value, min, max);
if (out) LOG_ERROR(GENERAL, "cfg::try_to_int('%s'): out of bounds (%lld..%lld)", value, min, max);
return false;
}
@@ -119,13 +117,13 @@ bool cfg::try_to_enum_value(u64* out, decltype(&fmt_class_string<int>::format) f
if (pos != value.size())
{
if (out) cfg.error("cfg::try_to_enum_value('%s'): unexpected characters (pos=%zu)", value, pos);
if (out) LOG_ERROR(GENERAL, "cfg::try_to_enum_value('%s'): unexpected characters (pos=%zu)", value, pos);
return false;
}
if (val > max)
{
if (out) cfg.error("cfg::try_to_enum_value('%s'): out of bounds(0..%u)", value, max);
if (out) LOG_ERROR(GENERAL, "cfg::try_to_enum_value('%s'): out of bounds(0..%u)", value, max);
return false;
}
@@ -134,7 +132,7 @@ bool cfg::try_to_enum_value(u64* out, decltype(&fmt_class_string<int>::format) f
}
catch (const std::exception& e)
{
if (out) cfg.error("cfg::try_to_enum_value('%s'): invalid enum value: %s", value, e.what());
if (out) LOG_ERROR(GENERAL, "cfg::try_to_enum_value('%s'): invalid enum value: %s", value, e.what());
return false;
}
}
@@ -300,7 +298,7 @@ bool cfg::node::from_string(const std::string& value) try
}
catch (const std::exception& e)
{
cfg.fatal("%s thrown: %s", typeid(e).name(), e.what());
LOG_FATAL(GENERAL, "%s thrown: %s", typeid(e).name(), e.what());
return false;
}
+17 -1
View File
@@ -49,9 +49,10 @@ namespace cfg
_base(type _type, class node* owner, const std::string& name);
public:
// Disallow copy/move constructors and assignments
_base(const _base&) = delete;
_base& operator=(const _base&) = delete;
// Get type
type get_type() const { return m_type; }
@@ -132,6 +133,11 @@ namespace cfg
return m_value;
}
bool get() const
{
return m_value;
}
void from_default() override;
std::string to_string() const override
@@ -178,6 +184,11 @@ namespace cfg
return m_value;
}
T get() const
{
return m_value;
}
void from_default() override
{
m_value = def;
@@ -236,6 +247,11 @@ namespace cfg
return m_value;
}
int_type get() const
{
return m_value;
}
void from_default() override
{
m_value = def;
+279 -102
View File
@@ -9,6 +9,7 @@
#include <cstring>
#include <cerrno>
#include <typeinfo>
#include <map>
using namespace std::literals::string_literals;
@@ -134,10 +135,10 @@ static fs::error to_error(DWORD e)
#if defined(__APPLE__)
#include <copyfile.h>
#include <mach-o/dyld.h>
#elif defined(__DragonFly__) || defined(__FreeBSD__)
#include <sys/socket.h> // sendfile
#elif defined(__linux__) || defined(__sun)
#include <sys/sendfile.h>
#else
#include <fstream>
#endif
static fs::error to_error(int e)
@@ -216,7 +217,7 @@ std::shared_ptr<fs::device_base> fs::device_manager::get_device(const std::strin
std::shared_ptr<fs::device_base> fs::device_manager::set_device(const std::string& name, const std::shared_ptr<device_base>& device)
{
writer_lock lock(m_mutex);
std::lock_guard lock(m_mutex);
return m_map[name] = device;
}
@@ -283,7 +284,7 @@ bool fs::stat(const std::string& path, stat_t& info)
info.size = (u64)attrs.nFileSizeLow | ((u64)attrs.nFileSizeHigh << 32);
info.atime = to_time(attrs.ftLastAccessTime);
info.mtime = to_time(attrs.ftLastWriteTime);
info.ctime = to_time(attrs.ftCreationTime);
info.ctime = info.mtime;
#else
struct ::stat file_info;
if (::stat(path.c_str(), &file_info) != 0)
@@ -297,9 +298,12 @@ bool fs::stat(const std::string& path, stat_t& info)
info.size = file_info.st_size;
info.atime = file_info.st_atime;
info.mtime = file_info.st_mtime;
info.ctime = file_info.st_ctime;
info.ctime = info.mtime;
#endif
if (info.atime < info.mtime)
info.atime = info.mtime;
return true;
}
@@ -495,18 +499,30 @@ bool fs::create_dir(const std::string& path)
bool fs::create_path(const std::string& path)
{
const auto& parent = get_parent_dir(path);
const std::string parent = get_parent_dir(path);
if (!parent.empty() && !is_dir(parent) && !create_path(parent))
if (!parent.empty() && !create_path(parent))
{
return false;
}
return create_dir(path);
if (!create_dir(path) && g_tls_error != error::exist)
{
return false;
}
return true;
}
bool fs::remove_dir(const std::string& path)
{
if (path.empty())
{
// Don't allow removing empty path (TODO)
g_tls_error = fs::error::noent;
return false;
}
if (auto device = get_virtual_device(path))
{
return device->remove_dir(path);
@@ -533,6 +549,13 @@ bool fs::remove_dir(const std::string& path)
bool fs::rename(const std::string& from, const std::string& to, bool overwrite)
{
if (from.empty() || to.empty())
{
// Don't allow opening empty path (TODO)
g_tls_error = fs::error::noent;
return false;
}
const auto device = get_virtual_device(from);
if (device != get_virtual_device(to))
@@ -610,7 +633,7 @@ bool fs::copy_file(const std::string& from, const std::string& to, bool overwrit
}
return true;
#else
#elif defined(__APPLE__) || defined(__linux__) || defined(__sun)
/* Source: http://stackoverflow.com/questions/2180079/how-can-i-copy-a-file-on-unix-using-c */
const int input = ::open(from.c_str(), O_RDONLY);
@@ -634,17 +657,13 @@ bool fs::copy_file(const std::string& from, const std::string& to, bool overwrit
#if defined(__APPLE__)
// fcopyfile works on OS X 10.5+
if (::fcopyfile(input, output, 0, COPYFILE_ALL))
#elif defined(__DragonFly__) || defined(__FreeBSD__)
if (::sendfile(input, output, 0, 0, NULL, NULL, 0))
#elif defined(__linux__) || defined(__sun)
// sendfile will work with non-socket output (i.e. regular file) on Linux 2.6.33+
off_t bytes_copied = 0;
struct ::stat fileinfo = { 0 };
if (::fstat(input, &fileinfo) || ::sendfile(output, input, &bytes_copied, fileinfo.st_size))
#else // NetBSD, OpenBSD, etc.
fmt::throw_exception("fs::copy_file() isn't implemented for this platform.\nFrom: %s\nTo: %s", from, to);
errno = 0;
if (true)
#else
#error "Native file copy implementation is missing"
#endif
{
const int err = errno;
@@ -657,6 +676,31 @@ bool fs::copy_file(const std::string& from, const std::string& to, bool overwrit
::close(input);
::close(output);
return true;
#else // fallback
{
std::ifstream out{to, std::ios::binary};
if (out.good() && !overwrite)
{
g_tls_error = to_error(EEXIST);
return false;
}
}
std::ifstream in{from, std::ios::binary};
std::ofstream out{to, std::ios::binary};
if (!in.good() || !out.good())
{
g_tls_error = to_error(errno);
return false;
}
std::istreambuf_iterator<char> bin(in);
std::istreambuf_iterator<char> ein;
std::ostreambuf_iterator<char> bout(out);
std::copy(bin, ein, bout);
return true;
#endif
}
@@ -780,6 +824,13 @@ void fs::file::xfail() const
fs::file::file(const std::string& path, bs_t<open_mode> mode)
{
if (path.empty())
{
// Don't allow opening empty path (TODO)
g_tls_error = fs::error::noent;
return;
}
if (auto device = get_virtual_device(path))
{
if (auto&& _file = device->open(path, mode))
@@ -793,29 +844,34 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
#ifdef _WIN32
DWORD access = 0;
if (test(mode & fs::read)) access |= GENERIC_READ;
if (test(mode & fs::write)) access |= test(mode & fs::append) ? FILE_APPEND_DATA : GENERIC_WRITE;
if (mode & fs::read) access |= GENERIC_READ;
if (mode & fs::write) access |= DELETE | (mode & fs::append ? FILE_APPEND_DATA : GENERIC_WRITE);
DWORD disp = 0;
if (test(mode & fs::create))
if (mode & fs::create)
{
disp =
test(mode & fs::excl) ? CREATE_NEW :
test(mode & fs::trunc) ? CREATE_ALWAYS : OPEN_ALWAYS;
mode & fs::excl ? CREATE_NEW :
mode & fs::trunc ? CREATE_ALWAYS : OPEN_ALWAYS;
}
else
{
if (test(mode & fs::excl))
if (mode & fs::excl)
{
g_tls_error = error::inval;
return;
}
disp = test(mode & fs::trunc) ? TRUNCATE_EXISTING : OPEN_EXISTING;
disp = mode & fs::trunc ? TRUNCATE_EXISTING : OPEN_EXISTING;
}
DWORD share = FILE_SHARE_READ;
if (!test(mode & fs::unshare))
DWORD share = 0;
if (!(mode & fs::unread) || !(mode & fs::write))
{
share |= FILE_SHARE_READ;
}
if (!(mode & (fs::lock + fs::unread)) || !(mode & fs::write))
{
share |= FILE_SHARE_WRITE | FILE_SHARE_DELETE;
}
@@ -854,7 +910,10 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
info.size = this->size();
info.atime = to_time(basic_info.LastAccessTime);
info.mtime = to_time(basic_info.ChangeTime);
info.ctime = to_time(basic_info.CreationTime);
info.ctime = info.mtime;
if (info.atime < info.mtime)
info.atime = info.mtime;
return info;
}
@@ -938,16 +997,23 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
#else
int flags = 0;
if (test(mode & fs::read) && test(mode & fs::write)) flags |= O_RDWR;
else if (test(mode & fs::read)) flags |= O_RDONLY;
else if (test(mode & fs::write)) flags |= O_WRONLY;
if (mode & fs::read && mode & fs::write) flags |= O_RDWR;
else if (mode & fs::read) flags |= O_RDONLY;
else if (mode & fs::write) flags |= O_WRONLY;
if (test(mode & fs::append)) flags |= O_APPEND;
if (test(mode & fs::create)) flags |= O_CREAT;
if (test(mode & fs::trunc)) flags |= O_TRUNC;
if (test(mode & fs::excl)) flags |= O_EXCL;
if (mode & fs::append) flags |= O_APPEND;
if (mode & fs::create) flags |= O_CREAT;
if (mode & fs::trunc && !(mode & (fs::lock + fs::unread))) flags |= O_TRUNC;
if (mode & fs::excl) flags |= O_EXCL;
const int fd = ::open(path.c_str(), flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
int perm = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
if (mode & fs::write && mode & fs::unread)
{
perm = 0;
}
const int fd = ::open(path.c_str(), flags, perm);
if (fd == -1)
{
@@ -955,13 +1021,19 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
return;
}
if (test(mode & fs::unshare) && ::flock(fd, LOCK_EX | LOCK_NB) != 0)
if (mode & fs::write && mode & (fs::lock + fs::unread) && ::flock(fd, LOCK_EX | LOCK_NB) != 0)
{
g_tls_error = errno == EWOULDBLOCK ? fs::error::acces : to_error(errno);
::close(fd);
return;
}
if (mode & fs::trunc && mode & (fs::lock + fs::unread))
{
// Postpone truncation in order to avoid using O_TRUNC on a locked file
::ftruncate(fd, 0);
}
class unix_file final : public file_base, public get_native_handle
{
const int m_fd;
@@ -988,7 +1060,10 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
info.size = file_info.st_size;
info.atime = file_info.st_atime;
info.mtime = file_info.st_mtime;
info.ctime = file_info.st_ctime;
info.ctime = info.mtime;
if (info.atime < info.mtime)
info.atime = info.mtime;
return info;
}
@@ -1152,6 +1227,13 @@ void fs::dir::xnull() const
bool fs::dir::open(const std::string& path)
{
if (path.empty())
{
// Don't allow opening empty path (TODO)
g_tls_error = fs::error::noent;
return false;
}
if (auto device = get_virtual_device(path))
{
if (auto&& _dir = device->open_dir(path))
@@ -1188,7 +1270,10 @@ bool fs::dir::open(const std::string& path)
info.size = ((u64)found.nFileSizeHigh << 32) | (u64)found.nFileSizeLow;
info.atime = to_time(found.ftLastAccessTime);
info.mtime = to_time(found.ftLastWriteTime);
info.ctime = to_time(found.ftCreationTime);
info.ctime = info.mtime;
if (info.atime < info.mtime)
info.atime = info.mtime;
m_entries.emplace_back(std::move(info));
}
@@ -1271,7 +1356,10 @@ bool fs::dir::open(const std::string& path)
info.size = file_info.st_size;
info.atime = file_info.st_atime;
info.mtime = file_info.st_mtime;
info.ctime = file_info.st_ctime;
info.ctime = info.mtime;
if (info.atime < info.mtime)
info.atime = info.mtime;
return true;
}
@@ -1296,8 +1384,9 @@ const std::string& fs::get_config_dir()
std::string dir;
#ifdef _WIN32
wchar_t buf[2048];
if (GetModuleFileName(NULL, buf, ::size32(buf)) - 1 >= ::size32(buf) - 1)
wchar_t buf[32768];
if (GetEnvironmentVariable(L"RPCS3_CONFIG_DIR", buf, std::size(buf)) - 1 >= std::size(buf) - 1 &&
GetModuleFileName(NULL, buf, std::size(buf)) - 1 >= std::size(buf) - 1)
{
MessageBoxA(0, fmt::format("GetModuleFileName() failed: error %u.", GetLastError()).c_str(), "fs::get_config_dir()", MB_ICONERROR);
return dir; // empty
@@ -1309,16 +1398,22 @@ const std::string& fs::get_config_dir()
dir.resize(dir.rfind('/') + 1);
#else
if (const char* home = ::getenv("XDG_CONFIG_HOME"))
dir = home;
#ifdef __APPLE__
if (const char* home = ::getenv("HOME"))
dir = home + "/Library/Application Support"s;
#else
if (const char* conf = ::getenv("XDG_CONFIG_HOME"))
dir = conf;
else if (const char* home = ::getenv("HOME"))
dir = home + "/.config"s;
#endif
else // Just in case
dir = "./config";
dir += "/rpcs3/";
if (!is_dir(dir) && !create_path(dir))
if (!create_path(dir))
{
std::printf("Failed to create configuration directory '%s' (%d).\n", dir.c_str(), errno);
}
@@ -1330,76 +1425,42 @@ const std::string& fs::get_config_dir()
return s_dir;
}
std::string fs::get_data_dir(const std::string& prefix, const std::string& location, const std::string& suffix)
const std::string& fs::get_cache_dir()
{
static const std::string s_dir = []
{
const std::string& dir = get_config_dir() + "data/";
std::string dir;
if (!is_dir(dir) && !create_path(dir))
#ifdef _WIN32
dir = get_config_dir();
#else
#ifdef __APPLE__
if (const char* home = ::getenv("HOME"))
dir = home + "/Library/Caches"s;
#else
if (const char* cache = ::getenv("XDG_CACHE_HOME"))
dir = cache;
else if (const char* conf = ::getenv("XDG_CONFIG_HOME"))
dir = conf;
else if (const char* home = ::getenv("HOME"))
dir = home + "/.cache"s;
#endif
else // Just in case
dir = "./cache";
dir += "/rpcs3/";
if (!create_path(dir))
{
return get_config_dir();
std::printf("Failed to create configuration directory '%s' (%d).\n", dir.c_str(), errno);
}
#endif
return dir;
}();
std::vector<u8> buf;
buf.reserve(location.size() + 1);
// Normalize location
for (char c : location)
{
#ifdef _WIN32
if (c == '/' || c == '\\')
#else
if (c == '/')
#endif
{
if (buf.empty() || buf.back() != '/')
{
buf.push_back('/');
}
continue;
}
buf.push_back(c);
}
// Calculate hash
u8 hash[20];
sha1(buf.data(), buf.size(), hash);
// Concatenate
std::string&& result = fmt::format("%s%s/%016llx%08x-%s/", s_dir, prefix, reinterpret_cast<be_t<u64>&>(hash[0]), reinterpret_cast<be_t<u32>&>(hash[8]), suffix);
if (!is_dir(result))
{
// Create dir if necessary
if (create_path(result))
{
// Acknowledge original location
file(result + ".location", rewrite).write(buf);
}
}
return result;
}
std::string fs::get_data_dir(const std::string& prefix, const std::string& path)
{
#ifdef _WIN32
const auto& delim = "/\\";
#else
const auto& delim = "/";
#endif
// Extract file name and location
const std::string& location = fs::get_parent_dir(path);
const std::size_t name_pos = path.find_first_not_of(delim, location.size());
return fs::get_data_dir(prefix, location, name_pos == -1 ? std::string{} : path.substr(name_pos));
return s_dir;
}
void fs::remove_all(const std::string& path, bool remove_root)
@@ -1453,6 +1514,122 @@ u64 fs::get_dir_size(const std::string& path)
return result;
}
fs::file fs::make_gather(std::vector<fs::file> files)
{
struct gather_stream : file_base
{
u64 pos = 0;
u64 end = 0;
std::vector<file> files;
std::map<u64, u64> ends; // Fragment End Offset -> Index
gather_stream(std::vector<fs::file> arg)
: files(std::move(arg))
{
// Preprocess files
for (auto&& f : files)
{
end += f.size();
ends.emplace(end, ends.size());
}
}
~gather_stream() override
{
}
fs::stat_t stat() override
{
fs::stat_t result{};
if (!files.empty())
{
result = files[0].stat();
}
result.is_directory = false;
result.is_writable = false;
result.size = end;
return result;
}
bool trunc(u64 length) override
{
return false;
}
u64 read(void* buffer, u64 size) override
{
if (pos < end)
{
// Current pos
const u64 start = pos;
// Get readable size
if (const u64 max = std::min<u64>(size, end - pos))
{
u8* buf_out = static_cast<u8*>(buffer);
u64 buf_max = max;
for (auto it = ends.upper_bound(pos); it != ends.end(); ++it)
{
// Set position for the fragment
files[it->second].seek(pos - it->first, fs::seek_end);
const u64 count = std::min<u64>(it->first - pos, buf_max);
const u64 read = files[it->second].read(buf_out, count);
buf_out += count;
buf_max -= count;
pos += read;
if (read < count || buf_max == 0)
{
break;
}
}
return pos - start;
}
}
return 0;
}
u64 write(const void* buffer, u64 size) override
{
return 0;
}
u64 seek(s64 offset, seek_mode whence) override
{
const s64 new_pos =
whence == fs::seek_set ? offset :
whence == fs::seek_cur ? offset + pos :
whence == fs::seek_end ? offset + end :
(fmt::raw_error("fs::gather_stream::seek(): invalid whence"), 0);
if (new_pos < 0)
{
fs::g_tls_error = fs::error::inval;
return -1;
}
pos = new_pos;
return pos;
}
u64 size() override
{
return end;
}
};
fs::file result;
result.reset(std::make_unique<gather_stream>(std::move(files)));
return result;
}
template<>
void fmt_class_string<fs::seek_mode>::format(std::string& out, u64 arg)
{
+11 -10
View File
@@ -25,7 +25,8 @@ namespace fs
create,
trunc,
excl,
unshare,
lock,
unread,
__bitset_enum_max
};
@@ -36,7 +37,8 @@ namespace fs
constexpr auto create = +open_mode::create; // Create file if it doesn't exist
constexpr auto trunc = +open_mode::trunc; // Clear opened file if it's not empty
constexpr auto excl = +open_mode::excl; // Failure if the file already exists (used with `create`)
constexpr auto unshare = +open_mode::unshare; // Prevent opening the file twice
constexpr auto lock = +open_mode::lock; // Prevent opening the file more than once
constexpr auto unread = +open_mode::unread; // Aggressively prevent reading the opened file (do not use)
constexpr auto rewrite = open_mode::write + open_mode::create + open_mode::trunc;
@@ -185,7 +187,7 @@ namespace fs
file() = default;
// Open file with specified mode
explicit file(const std::string& path, bs_t<open_mode> mode = ::fs::read);
explicit file(const std::string& path, bs_t<open_mode> mode = ::fs::read);
// Open memory for read
explicit file(const void* ptr, std::size_t size);
@@ -400,7 +402,7 @@ namespace fs
{
m_dir = std::move(ptr);
}
std::unique_ptr<dir_base> release()
{
return std::move(m_dir);
@@ -482,11 +484,8 @@ namespace fs
// Get configuration directory
const std::string& get_config_dir();
// Get data/cache directory for specified prefix and suffix
std::string get_data_dir(const std::string& prefix, const std::string& location, const std::string& suffix);
// Get data/cache directory for specified prefix and path (suffix will be filename)
std::string get_data_dir(const std::string& prefix, const std::string& path);
// Get common cache directory
const std::string& get_cache_dir();
// Delete directory and all its contents recursively
void remove_all(const std::string& path, bool remove_root = true);
@@ -617,10 +616,12 @@ namespace fs
if (fs::file f{path, mode})
{
// Write args sequentially
int seq[]{ (f.write(args), 0)... };
(f.write(args), ...);
return true;
}
return false;
}
file make_gather(std::vector<file>);
}
+70 -34
View File
@@ -4,7 +4,7 @@
#include "GDBDebugServer.h"
#include "Log.h"
#include <algorithm>
#include "Emu/Memory/Memory.h"
#include "Emu/Memory/vm.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/CPU/CPUThread.h"
@@ -13,13 +13,13 @@
#include "Emu/Cell/SPUThread.h"
#ifndef _WIN32
#include"fcntl.h"
#include "fcntl.h"
#endif
extern void ppu_set_breakpoint(u32 addr);
extern void ppu_remove_breakpoint(u32 addr);
logs::channel gdbDebugServer("gdbDebugServer");
LOG_CHANNEL(gdbDebugServer);
int sock_init(void)
{
@@ -166,9 +166,10 @@ char GDBDebugServer::read_char()
u8 GDBDebugServer::read_hexbyte()
{
char buf[2];
read(buf, 2);
return static_cast<u8>(strtol(buf, nullptr, 16));
std::string s = "";
s += read_char();
s += read_char();
return hex_to_u8(s);
}
void GDBDebugServer::try_read_cmd(gdb_cmd & out_cmd)
@@ -176,7 +177,7 @@ void GDBDebugServer::try_read_cmd(gdb_cmd & out_cmd)
char c = read_char();
//interrupt
if (UNLIKELY(c == 0x03)) {
out_cmd.cmd = "\0x03";
out_cmd.cmd = '\x03';
out_cmd.data = "";
out_cmd.checksum = 0;
return;
@@ -223,7 +224,7 @@ void GDBDebugServer::try_read_cmd(gdb_cmd & out_cmd)
}
out_cmd.checksum = read_hexbyte();
if (out_cmd.checksum != checksum) {
throw new wrong_checksum_exception("Wrong checksum for packet" HERE);
throw wrong_checksum_exception("Wrong checksum for packet" HERE);
}
}
@@ -337,6 +338,7 @@ bool GDBDebugServer::select_thread(u64 id)
selected_thread = ppu.ptr;
return true;
}
gdbDebugServer.warning("Unable to select thread! Is the emulator running?");
return false;
}
@@ -365,7 +367,7 @@ std::string GDBDebugServer::get_reg(std::shared_ptr<ppu_thread> thread, u32 rid)
return std::string(8, 'x');
default:
if (rid > 70) return "";
return (rid > 31)
return (rid > 31)
? u64_to_padded_hex(reinterpret_cast<u64&>(thread->fpr[rid - 32])) //fpr
: u64_to_padded_hex(thread->gpr[rid]); //gpr
}
@@ -427,6 +429,25 @@ bool GDBDebugServer::send_reason()
return send_cmd_ack("S05");
}
void GDBDebugServer::wait_with_interrupts() {
char c;
while (!paused) {
int result = recv(client_socket, &c, 1, 0);
if (result == SOCKET_ERROR) {
if (check_errno_again()) {
thread_ctrl::wait_for(50);
continue;
}
gdbDebugServer.error("Error during socket read");
fmt::throw_exception("Error during socket read" HERE);
} else if (c == 0x03) {
paused = true;
}
}
}
bool GDBDebugServer::cmd_extended_mode(gdb_cmd & cmd)
{
return send_cmd_ack("OK");
@@ -453,24 +474,25 @@ bool GDBDebugServer::cmd_thread_info(gdb_cmd & cmd)
result += u64_to_padded_hex(static_cast<u64>(cpu.id));
};
idm::select<ppu_thread>(on_select);
idm::select<ARMv7Thread>(on_select);
idm::select<RawSPUThread>(on_select);
idm::select<SPUThread>(on_select);
//idm::select<RawSPUThread>(on_select);
//idm::select<SPUThread>(on_select);
//todo: this may exceed max command length
result = "m" + result + "l";
return send_cmd_ack(result);;
}
bool GDBDebugServer::cmd_current_thread(gdb_cmd & cmd)
{
return send_cmd_ack(selected_thread.expired() ? "" : u64_to_padded_hex(selected_thread.lock()->id));
return send_cmd_ack(selected_thread.expired() ? "" : ("QC" + u64_to_padded_hex(selected_thread.lock()->id)));
}
bool GDBDebugServer::cmd_read_register(gdb_cmd & cmd)
{
select_thread(general_ops_thread_id);
if (!select_thread(general_ops_thread_id)) {
return send_cmd_ack("E02");
}
auto th = selected_thread.lock();
if (th->id_type() == 1) {
auto ppu = std::static_pointer_cast<ppu_thread>(th);
@@ -488,7 +510,9 @@ bool GDBDebugServer::cmd_read_register(gdb_cmd & cmd)
bool GDBDebugServer::cmd_write_register(gdb_cmd & cmd)
{
select_thread(general_ops_thread_id);
if (!select_thread(general_ops_thread_id)) {
return send_cmd_ack("E02");
}
auto th = selected_thread.lock();
if (th->id_type() == 1) {
auto ppu = std::static_pointer_cast<ppu_thread>(th);
@@ -517,7 +541,7 @@ bool GDBDebugServer::cmd_read_memory(gdb_cmd & cmd)
std::string result;
result.reserve(len * 2);
for (u32 i = 0; i < len; ++i) {
if (vm::check_addr(addr + i)) {
if (vm::check_addr(addr, 1, vm::page_allocated | vm::page_readable)) {
result += to_hexbyte(vm::read8(addr + i));
} else {
break;
@@ -543,7 +567,7 @@ bool GDBDebugServer::cmd_write_memory(gdb_cmd & cmd)
u32 len = hex_to_u32(cmd.data.substr(s + 1, s2 - s - 1));
const char* data_ptr = (cmd.data.c_str()) + s2 + 1;
for (u32 i = 0; i < len; ++i) {
if (vm::check_addr(addr + i)) {
if (vm::check_addr(addr + i, 1, vm::page_allocated | vm::page_writable)) {
u8 val;
int res = sscanf_s(data_ptr, "%02hhX", &val);
if (!res) {
@@ -634,30 +658,31 @@ bool GDBDebugServer::cmd_vcont(gdb_cmd & cmd)
{
//todo: handle multiple actions and thread ids
this->from_breakpoint = false;
if (cmd.data[1] == 'c') {
if (cmd.data[1] == 'c' || cmd.data[1] == 's') {
select_thread(continue_ops_thread_id);
auto ppu = std::static_pointer_cast<ppu_thread>(selected_thread.lock());
ppu->state -= cpu_flag::dbg_pause;
if (Emu.IsPaused()) {
Emu.Resume();
paused = false;
if (cmd.data[1] == 's') {
ppu->state += cpu_flag::dbg_step;
}
thread_ctrl::wait();
//we are in all-stop mode
Emu.Pause();
return send_reason();
} else if (cmd.data[1] == 's') {
select_thread(continue_ops_thread_id);
auto ppu = std::static_pointer_cast<ppu_thread>(selected_thread.lock());
ppu->state += cpu_flag::dbg_step;
ppu->state -= cpu_flag::dbg_pause;
//special case if app didn't start yet (only loaded)
if (!Emu.IsPaused() && !Emu.IsRunning()) {
Emu.Run();
}
if (Emu.IsPaused()) {
Emu.Resume();
} else {
ppu->notify();
}
thread_ctrl::wait();
wait_with_interrupts();
//we are in all-stop mode
Emu.Pause();
select_thread(pausedBy);
// we have to remove dbg_pause from thread that paused execution, otherwise
// it will be paused forever (Emu.Resume only removes dbg_global_pause)
ppu = std::static_pointer_cast<ppu_thread>(selected_thread.lock());
ppu->state -= cpu_flag::dbg_pause;
return send_reason();
}
return send_cmd_ack("");
@@ -729,7 +754,9 @@ void GDBDebugServer::on_task()
return;
}
//stop immediately
Emu.Pause();
if (Emu.IsRunning()) {
Emu.Pause();
}
try {
char hostbuf[32];
@@ -768,7 +795,7 @@ void GDBDebugServer::on_task()
}
}
}
catch (std::runtime_error& e)
catch (std::runtime_error& e)
{
if (client_socket) {
closesocket(client_socket);
@@ -802,7 +829,16 @@ void GDBDebugServer::on_stop()
this->stop = true;
//just in case we are waiting for breakpoint
this->notify();
named_thread::on_stop();
old_thread::on_stop();
}
void GDBDebugServer::pause_from(cpu_thread* t) {
if (paused) {
return;
}
paused = true;
pausedBy = t->id;
notify();
}
u32 g_gdb_debugger_id = 0;
+11 -15
View File
@@ -40,8 +40,8 @@ public:
const u64 ALL_THREADS = 0xffffffffffffffff;
const u64 ANY_THREAD = 0;
class GDBDebugServer : public named_thread {
class GDBDebugServer
{
socket_t server_socket;
socket_t client_socket;
std::weak_ptr<cpu_thread> selected_thread;
@@ -50,7 +50,7 @@ class GDBDebugServer : public named_thread {
//initialize server socket and start listening
void start_server();
//read at most cnt bytes to buf, returns nubmer of bytes actually read
//read at most cnt bytes to buf, returns number of bytes actually read
int read(void* buf, int cnt);
//reads one character
char read_char();
@@ -60,8 +60,8 @@ class GDBDebugServer : public named_thread {
void try_read_cmd(gdb_cmd& out_cmd);
//reads commands until receiveing one with valid checksum
//in case of other exception (i.e. wrong first char of command)
//it will log exception text and return false
//in that case best for caller would be to stop reading, because
//it will log exception text and return false
//in that case best for caller would be to stop reading, because
//chance of getting correct command is low
bool read_cmd(gdb_cmd& out_cmd);
//send cnt bytes from buf to client
@@ -90,6 +90,8 @@ class GDBDebugServer : public named_thread {
//send reason of stop, returns false if sending response failed
bool send_reason();
void wait_with_interrupts();
//commands
bool cmd_extended_mode(gdb_cmd& cmd);
bool cmd_reason(gdb_cmd& cmd);
@@ -110,20 +112,14 @@ class GDBDebugServer : public named_thread {
bool cmd_set_breakpoint(gdb_cmd& cmd);
bool cmd_remove_breakpoint(gdb_cmd& cmd);
protected:
void on_task() override final;
void on_exit() override final;
public:
static const u32 id_base = 1;
static const u32 id_step = 1;
static const u32 id_count = 0x100000;
bool from_breakpoint = true;
bool stop = false;
bool paused = false;
u64 pausedBy;
virtual std::string get_name() const;
virtual void on_stop() override final;
void operator()();
void pause_from(cpu_thread* t);
};
extern u32 g_gdb_debugger_id;
+1 -1
View File
@@ -4,7 +4,7 @@
#pragma push_macro("new")
#undef new
#include <gsl.h>
#include <gsl/gsl>
#pragma pop_macro("new")
#undef Expects
#undef Ensures
+311 -78
View File
@@ -1,3 +1,214 @@
#include "types.h"
#include "JIT.h"
#include "StrFmt.h"
#include "File.h"
#include "Log.h"
#include "mutex.h"
#include "sysinfo.h"
#include "VirtualMemory.h"
#include <immintrin.h>
// Memory manager mutex
shared_mutex s_mutex2;
#ifdef __linux__
#define CAN_OVERCOMMIT
#endif
static u8* get_jit_memory()
{
// Reserve 2G memory (magic static)
static void* const s_memory2 = []() -> void*
{
void* ptr = utils::memory_reserve(0x80000000);
#ifdef CAN_OVERCOMMIT
utils::memory_commit(ptr, 0x80000000);
utils::memory_protect(ptr, 0x40000000, utils::protection::wx);
#endif
return ptr;
}();
return static_cast<u8*>(s_memory2);
}
// Allocation counters (1G code, 1G data subranges)
static atomic_t<u64> s_code_pos{0}, s_data_pos{0};
// Snapshot of code generated before main()
static std::vector<u8> s_code_init, s_data_init;
template <atomic_t<u64>& Ctr, uint Off, utils::protection Prot>
static u8* add_jit_memory(std::size_t size, uint align)
{
// Select subrange
u8* pointer = get_jit_memory() + Off;
if (UNLIKELY(!size && !align))
{
// Return subrange info
return pointer;
}
#ifndef CAN_OVERCOMMIT
std::lock_guard lock(s_mutex2);
#endif
u64 olda, newa;
// Simple allocation by incrementing pointer to the next free data
const u64 pos = Ctr.atomic_op([&](u64& ctr) -> u64
{
const u64 _pos = ::align(ctr, align);
const u64 _new = ::align(_pos + size, align);
if (UNLIKELY(_new > 0x40000000))
{
return -1;
}
// Check the necessity to commit more memory
olda = ::align(ctr, 0x10000);
newa = ::align(_new, 0x10000);
ctr = _new;
return _pos;
});
if (UNLIKELY(pos == -1))
{
LOG_FATAL(GENERAL, "JIT: Out of memory (size=0x%x, align=0x%x, off=0x%x)", size, align, Off);
return nullptr;
}
if (UNLIKELY(olda != newa))
{
#ifdef CAN_OVERCOMMIT
// TODO: possibly madvise
#else
// Commit more memory
utils::memory_commit(pointer + olda, newa - olda, Prot);
#endif
}
return pointer + pos;
}
jit_runtime::jit_runtime()
: HostRuntime()
{
}
jit_runtime::~jit_runtime()
{
}
asmjit::Error jit_runtime::_add(void** dst, asmjit::CodeHolder* code) noexcept
{
std::size_t codeSize = code->getCodeSize();
if (UNLIKELY(!codeSize))
{
*dst = nullptr;
return asmjit::kErrorNoCodeGenerated;
}
void* p = jit_runtime::alloc(codeSize, 16);
if (UNLIKELY(!p))
{
*dst = nullptr;
return asmjit::kErrorNoVirtualMemory;
}
std::size_t relocSize = code->relocate(p);
if (UNLIKELY(!relocSize))
{
*dst = nullptr;
return asmjit::kErrorInvalidState;
}
flush(p, relocSize);
*dst = p;
return asmjit::kErrorOk;
}
asmjit::Error jit_runtime::_release(void* ptr) noexcept
{
return asmjit::kErrorOk;
}
u8* jit_runtime::alloc(std::size_t size, uint align, bool exec) noexcept
{
if (exec)
{
return add_jit_memory<s_code_pos, 0x0, utils::protection::wx>(size, align);
}
else
{
return add_jit_memory<s_data_pos, 0x40000000, utils::protection::rw>(size, align);
}
}
void jit_runtime::initialize()
{
if (!s_code_init.empty() || !s_data_init.empty())
{
return;
}
// Create code/data snapshot
s_code_init.resize(s_code_pos);
std::memcpy(s_code_init.data(), alloc(0, 0, true), s_code_pos);
s_data_init.resize(s_data_pos);
std::memcpy(s_data_init.data(), alloc(0, 0, false), s_data_pos);
}
void jit_runtime::finalize() noexcept
{
// Reset JIT memory
#ifdef CAN_OVERCOMMIT
utils::memory_reset(get_jit_memory(), 0x80000000);
utils::memory_protect(get_jit_memory(), 0x40000000, utils::protection::wx);
#else
utils::memory_decommit(get_jit_memory(), 0x80000000);
#endif
s_code_pos = 0;
s_data_pos = 0;
// Restore code/data snapshot
std::memcpy(alloc(s_code_init.size(), 1, true), s_code_init.data(), s_code_init.size());
std::memcpy(alloc(s_data_init.size(), 1, false), s_data_init.data(), s_data_init.size());
}
::jit_runtime& asmjit::get_global_runtime()
{
// Magic static
static ::jit_runtime g_rt;
return g_rt;
}
asmjit::Label asmjit::build_transaction_enter(asmjit::X86Assembler& c, asmjit::Label fallback)
{
Label fall = c.newLabel();
Label begin = c.newLabel();
c.jmp(begin);
c.bind(fall);
c.test(x86::eax, _XABORT_RETRY);
c.jz(fallback);
c.align(kAlignCode, 16);
c.bind(begin);
c.xbegin(fall);
return begin;
}
void asmjit::build_transaction_abort(asmjit::X86Assembler& c, unsigned char code)
{
c.db(0xc6);
c.db(0xf8);
c.db(code);
}
#ifdef LLVM_AVAILABLE
#include <unordered_map>
@@ -7,14 +218,6 @@
#include <array>
#include <deque>
#include "types.h"
#include "StrFmt.h"
#include "File.h"
#include "Log.h"
#include "mutex.h"
#include "sysinfo.h"
#include "VirtualMemory.h"
#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
@@ -34,8 +237,6 @@
#include <sys/mman.h>
#endif
#include "JIT.h"
// Memory manager mutex
shared_mutex s_mutex;
@@ -72,7 +273,7 @@ static void* s_next = s_memory;
static std::deque<std::vector<RUNTIME_FUNCTION>> s_unwater;
static std::vector<std::vector<RUNTIME_FUNCTION>> s_unwind; // .pdata
#else
static std::deque<std::tuple<u8*, u64, std::size_t>> s_unfire;
static std::deque<std::pair<u8*, std::size_t>> s_unfire;
#endif
// Reset memory manager
@@ -89,27 +290,9 @@ extern void jit_finalize()
s_unwind.clear();
#else
struct MemoryManager : llvm::RTDyldMemoryManager
{
u8* allocateCodeSection(std::uintptr_t size, uint align, uint sec_id, llvm::StringRef sec_name) override
{
return nullptr;
}
u8* allocateDataSection(std::uintptr_t size, uint align, uint sec_id, llvm::StringRef sec_name, bool is_ro) override
{
return nullptr;
}
bool finalizeMemory(std::string* = nullptr) override
{
return false;
}
} mem;
for (auto&& t : s_unfire)
{
mem.deregisterEHFrames(std::get<0>(t), std::get<1>(t), std::get<2>(t));
llvm::RTDyldMemoryManager::deregisterEHFramesInProcess(t.first, t.second);
}
s_unfire.clear();
@@ -163,7 +346,7 @@ struct MemoryManager : llvm::RTDyldMemoryManager
if ((u64)s_memory > 0x80000000 - s_memory_size ? (u64)addr - (u64)s_memory >= s_memory_size : addr >= 0x80000000)
{
// Lock memory manager
writer_lock lock(s_mutex);
std::lock_guard lock(s_mutex);
// Allocate memory for trampolines
if (!m_tramps)
@@ -199,7 +382,7 @@ struct MemoryManager : llvm::RTDyldMemoryManager
u8* allocateCodeSection(std::uintptr_t size, uint align, uint sec_id, llvm::StringRef sec_name) override
{
// Lock memory manager
writer_lock lock(s_mutex);
std::lock_guard lock(s_mutex);
// Simple allocation
const u64 next = ::align((u64)s_next + size, 4096);
@@ -220,7 +403,7 @@ struct MemoryManager : llvm::RTDyldMemoryManager
u8* allocateDataSection(std::uintptr_t size, uint align, uint sec_id, llvm::StringRef sec_name, bool is_ro) override
{
// Lock memory manager
writer_lock lock(s_mutex);
std::lock_guard lock(s_mutex);
// Simple allocation
const u64 next = ::align((u64)s_next + size, 4096);
@@ -233,7 +416,6 @@ struct MemoryManager : llvm::RTDyldMemoryManager
if (!is_ro)
{
LOG_ERROR(GENERAL, "LLVM: Writeable data section not supported!");
}
utils::memory_commit(s_next, size);
@@ -245,7 +427,7 @@ struct MemoryManager : llvm::RTDyldMemoryManager
bool finalizeMemory(std::string* = nullptr) override
{
// Lock memory manager
writer_lock lock(s_mutex);
std::lock_guard lock(s_mutex);
// TODO: make only read-only sections read-only
//#ifdef _WIN32
@@ -263,7 +445,7 @@ struct MemoryManager : llvm::RTDyldMemoryManager
{
#ifdef _WIN32
// Lock memory manager
writer_lock lock(s_mutex);
std::lock_guard lock(s_mutex);
// Use s_memory as a BASE, compute the difference
const u64 unwind_diff = (u64)addr - (u64)s_memory;
@@ -287,17 +469,42 @@ struct MemoryManager : llvm::RTDyldMemoryManager
s_unwind.emplace_back(std::move(pdata));
}
#else
s_unfire.push_front(std::make_tuple(addr, load_addr, size));
s_unfire.push_front(std::make_pair(addr, size));
#endif
return RTDyldMemoryManager::registerEHFrames(addr, load_addr, size);
}
void deregisterEHFrames(u8* addr, u64 load_addr, std::size_t size) override
void deregisterEHFrames() override
{
}
};
// Simple memory manager
struct MemoryManager2 : llvm::RTDyldMemoryManager
{
MemoryManager2() = default;
~MemoryManager2() override
{
}
u8* allocateCodeSection(std::uintptr_t size, uint align, uint sec_id, llvm::StringRef sec_name) override
{
return jit_runtime::alloc(size, align, true);
}
u8* allocateDataSection(std::uintptr_t size, uint align, uint sec_id, llvm::StringRef sec_name, bool is_ro) override
{
return jit_runtime::alloc(size, align, false);
}
bool finalizeMemory(std::string* = nullptr) override
{
return false;
}
};
// Helper class
struct EventListener : llvm::JITEventListener
{
@@ -336,7 +543,7 @@ struct EventListener : llvm::JITEventListener
}
// Lock memory manager
writer_lock lock(s_mutex);
std::lock_guard lock(s_mutex);
// Use s_memory as a BASE, compute the difference
const u64 code_diff = (u64)m_mem.m_code_addr - (u64)s_memory;
@@ -373,15 +580,15 @@ public:
std::string name = m_path;
name.append(module->getName());
fs::file(name, fs::rewrite).write(obj.getBufferStart(), obj.getBufferSize());
LOG_SUCCESS(GENERAL, "LLVM: Created module: %s", module->getName().data());
LOG_NOTICE(GENERAL, "LLVM: Created module: %s", module->getName().data());
}
static std::unique_ptr<llvm::MemoryBuffer> load(const std::string& path)
{
if (fs::file cached{path, fs::read})
{
auto buf = llvm::MemoryBuffer::getNewUninitMemBuffer(cached.size());
cached.read(const_cast<char*>(buf->getBufferStart()), buf->getBufferSize());
auto buf = llvm::WritableMemoryBuffer::getNewUninitMemBuffer(cached.size());
cached.read(buf->getBufferStart(), buf->getBufferSize());
return buf;
}
@@ -395,7 +602,7 @@ public:
if (auto buf = load(path))
{
LOG_SUCCESS(GENERAL, "LLVM: Loaded module: %s", module->getName().data());
LOG_NOTICE(GENERAL, "LLVM: Loaded module: %s", module->getName().data());
return buf;
}
@@ -403,10 +610,10 @@ public:
}
};
jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, std::string _cpu)
: m_link(_link)
, m_cpu(std::move(_cpu))
std::string jit_compiler::cpu(const std::string& _cpu)
{
std::string m_cpu = _cpu;
if (m_cpu.empty())
{
m_cpu = llvm::sys::getHostCPUName();
@@ -417,15 +624,35 @@ jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, st
m_cpu == "broadwell" ||
m_cpu == "skylake" ||
m_cpu == "skylake-avx512" ||
m_cpu == "cannonlake")
m_cpu == "cannonlake" ||
m_cpu == "icelake")
{
// Downgrade if AVX is not supported by some chips
if (!utils::has_avx())
{
m_cpu = "nehalem";
}
}
if (m_cpu == "skylake-avx512" ||
m_cpu == "cannonlake" ||
m_cpu == "icelake")
{
// Downgrade if AVX-512 is disabled or not supported
if (!utils::has_512())
{
m_cpu = "skylake";
}
}
}
return m_cpu;
}
jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, const std::string& _cpu, bool large)
: m_link(_link)
, m_cpu(cpu(_cpu))
{
std::string result;
if (m_link.empty())
@@ -433,8 +660,10 @@ jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, st
// Auxiliary JIT (does not use custom memory manager, only writes the objects)
m_engine.reset(llvm::EngineBuilder(std::make_unique<llvm::Module>("null_", m_context))
.setErrorStr(&result)
.setEngineKind(llvm::EngineKind::JIT)
.setMCJITMemoryManager(std::make_unique<MemoryManager2>())
.setOptLevel(llvm::CodeGenOpt::Aggressive)
.setCodeModel(llvm::CodeModel::Small)
.setCodeModel(large ? llvm::CodeModel::Large : llvm::CodeModel::Small)
.setMCPU(m_cpu)
.create());
}
@@ -446,9 +675,10 @@ jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, st
m_engine.reset(llvm::EngineBuilder(std::make_unique<llvm::Module>("null", m_context))
.setErrorStr(&result)
.setEngineKind(llvm::EngineKind::JIT)
.setMCJITMemoryManager(std::move(mem))
.setOptLevel(llvm::CodeGenOpt::Aggressive)
.setCodeModel(llvm::CodeModel::Small)
.setCodeModel(large ? llvm::CodeModel::Large : llvm::CodeModel::Small)
.setMCPU(m_cpu)
.create());
@@ -468,6 +698,25 @@ jit_compiler::~jit_compiler()
{
}
bool jit_compiler::has_ssse3() const
{
if (m_cpu == "generic" ||
m_cpu == "k8" ||
m_cpu == "opteron" ||
m_cpu == "athlon64" ||
m_cpu == "athlon-fx" ||
m_cpu == "k8-sse3" ||
m_cpu == "opteron-sse3" ||
m_cpu == "athlon64-sse3" ||
m_cpu == "amdfam10" ||
m_cpu == "barcelona")
{
return false;
}
return true;
}
void jit_compiler::add(std::unique_ptr<llvm::Module> module, const std::string& path)
{
ObjectCache cache{path};
@@ -485,6 +734,19 @@ void jit_compiler::add(std::unique_ptr<llvm::Module> module, const std::string&
}
}
void jit_compiler::add(std::unique_ptr<llvm::Module> module)
{
const auto ptr = module.get();
m_engine->addModule(std::move(module));
m_engine->generateCodeForModule(ptr);
for (auto& func : ptr->functions())
{
// Delete IR to lower memory consumption
func.deleteBody();
}
}
void jit_compiler::add(const std::string& path)
{
m_engine->addObjectFile(std::move(llvm::object::ObjectFile::createObjectFile(*ObjectCache::load(path)).get()));
@@ -500,33 +762,4 @@ u64 jit_compiler::get(const std::string& name)
return m_engine->getGlobalValueAddress(name);
}
std::unordered_map<std::string, u64> jit_compiler::add(std::unordered_map<std::string, std::string> data)
{
// Lock memory manager
writer_lock lock(s_mutex);
std::unordered_map<std::string, u64> result;
std::size_t size = 0;
for (auto&& pair : data)
{
size += ::align(pair.second.size(), 16);
}
utils::memory_commit(s_next, size, utils::protection::wx);
std::memset(s_next, 0xc3, ::align(size, 4096));
for (auto&& pair : data)
{
std::memcpy(s_next, pair.second.data(), pair.second.size());
result.emplace(pair.first, (u64)s_next);
s_next = (void*)::align((u64)s_next + pair.second.size(), 16);
}
s_next = (void*)::align((u64)s_next, 4096);
return result;
}
#endif
+101 -8
View File
@@ -1,9 +1,97 @@
#pragma once
#define ASMJIT_EMBED
#define ASMJIT_DEBUG
#include <asmjit/asmjit.h>
#include <array>
#include <functional>
enum class jit_class
{
ppu_code,
ppu_data,
spu_code,
spu_data,
};
// ASMJIT runtime for emitting code in a single 2G region
struct jit_runtime final : asmjit::HostRuntime
{
jit_runtime();
~jit_runtime() override;
// Allocate executable memory
asmjit::Error _add(void** dst, asmjit::CodeHolder* code) noexcept override;
// Do nothing (deallocation is delayed)
asmjit::Error _release(void* p) noexcept override;
// Allocate memory
static u8* alloc(std::size_t size, uint align, bool exec = true) noexcept;
// Should be called at least once after global initialization
static void initialize();
// Deallocate all memory
static void finalize() noexcept;
};
namespace asmjit
{
// Should only be used to build global functions
::jit_runtime& get_global_runtime();
// Emit xbegin and adjacent loop, return label at xbegin
Label build_transaction_enter(X86Assembler& c, Label fallback);
// Emit xabort
void build_transaction_abort(X86Assembler& c, unsigned char code);
}
// Build runtime function with asmjit::X86Assembler
template <typename FT, typename F>
FT build_function_asm(F&& builder)
{
using namespace asmjit;
auto& rt = get_global_runtime();
CodeHolder code;
code.init(rt.getCodeInfo());
code._globalHints = asmjit::CodeEmitter::kHintOptimizedAlign;
std::array<X86Gp, 4> args;
#ifdef _WIN32
args[0] = x86::rcx;
args[1] = x86::rdx;
args[2] = x86::r8;
args[3] = x86::r9;
#else
args[0] = x86::rdi;
args[1] = x86::rsi;
args[2] = x86::rdx;
args[3] = x86::rcx;
#endif
X86Assembler compiler(&code);
builder(std::ref(compiler), args);
FT result;
if (rt.add(&result, &code))
{
return nullptr;
}
return result;
}
#ifdef LLVM_AVAILABLE
#include <memory>
#include <string>
#include <string_view>
#include <unordered_map>
#include "types.h"
@@ -40,7 +128,7 @@ class jit_compiler final
std::string m_cpu;
public:
jit_compiler(const std::unordered_map<std::string, u64>& _link, std::string _cpu);
jit_compiler(const std::unordered_map<std::string, u64>& _link, const std::string& _cpu, bool large = false);
~jit_compiler();
// Get LLVM context
@@ -49,9 +137,20 @@ public:
return m_context;
}
auto& get_engine() const
{
return *m_engine;
}
// Test SSSE3 feature
bool has_ssse3() const;
// Add module (path to obj cache dir)
void add(std::unique_ptr<llvm::Module> module, const std::string& path);
// Add module (not cached)
void add(std::unique_ptr<llvm::Module> module);
// Add object (path to obj file)
void add(const std::string& path);
@@ -61,14 +160,8 @@ public:
// Get compiled function address
u64 get(const std::string& name);
// Add functions directly to the memory manager (name -> code)
static std::unordered_map<std::string, u64> add(std::unordered_map<std::string, std::string>);
// Get CPU info
const std::string& cpu() const
{
return m_cpu;
}
static std::string cpu(const std::string& _cpu);
// Check JIT purpose
bool is_primary() const
+55 -24
View File
@@ -6,10 +6,13 @@
#include "Utilities/sysinfo.h"
#include "Utilities/Thread.h"
#include "rpcs3_version.h"
#include <cstring>
#include <cstdarg>
#include <string>
#include <unordered_map>
#include <thread>
#include <chrono>
#include <cstring>
using namespace std::literals::chrono_literals;
@@ -18,6 +21,7 @@ using namespace std::literals::chrono_literals;
#include <Windows.h>
#else
#include <sys/mman.h>
#include <sys/stat.h>
#endif
#include <zlib.h>
@@ -71,7 +75,7 @@ namespace logs
#endif
uchar* m_fptr{};
z_stream m_zs{};
semaphore<> m_m;
shared_mutex m_m;
alignas(128) atomic_t<u64> m_buf{0}; // MSB (40 bit): push begin, LSB (24 bis): push size
alignas(128) atomic_t<u64> m_out{0}; // Amount of bytes written to file
@@ -177,17 +181,16 @@ namespace logs
channel HLE("HLE");
channel PPU("PPU");
channel SPU("SPU");
channel ARMv7("ARMv7");
// Channel registry mutex
semaphore<> g_mutex;
shared_mutex g_mutex;
// Must be set to true in main()
atomic_t<bool> g_init{false};
void reset()
{
semaphore_lock lock(g_mutex);
std::lock_guard lock(g_mutex);
for (auto&& pair : get_logger()->channels)
{
@@ -197,7 +200,7 @@ namespace logs
void set_level(const std::string& ch_name, level value)
{
semaphore_lock lock(g_mutex);
std::lock_guard lock(g_mutex);
get_logger()->channels[ch_name].set_level(value);
}
@@ -207,7 +210,7 @@ namespace logs
{
if (!g_init)
{
semaphore_lock lock(g_mutex);
std::lock_guard lock(g_mutex);
get_logger()->messages.clear();
g_init = true;
}
@@ -223,7 +226,7 @@ void logs::listener::add(logs::listener* _new)
// Get first (main) listener
listener* lis = get_logger();
semaphore_lock lock(g_mutex);
std::lock_guard lock(g_mutex);
// Install new listener at the end of linked list
while (lis->m_next || !lis->m_next.compare_and_swap_test(nullptr, _new))
@@ -238,7 +241,7 @@ void logs::listener::add(logs::listener* _new)
}
}
void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, const u64* args)
void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, ...) const
{
// Get timestamp
const u64 stamp = get_stamp();
@@ -246,7 +249,7 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, const u
// Register channel
if (ch->enabled == level::_uninit)
{
semaphore_lock lock(g_mutex);
std::lock_guard lock(g_mutex);
auto& info = get_logger()->channels[ch->name];
@@ -267,9 +270,23 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, const u
}
}
// Get text
thread_local std::string text; text.clear();
fmt::raw_append(text, fmt, sup, args);
// Get text, extract va_args
thread_local std::string text;
thread_local std::vector<u64> args;
std::size_t args_count = 0;
for (auto v = sup; v->fmt_string; v++)
args_count++;
text.clear();
args.resize(args_count);
va_list c_args;
va_start(c_args, sup);
for (u64& arg : args)
arg = va_arg(c_args, u64);
va_end(c_args);
fmt::raw_append(text, fmt, sup, args.data());
std::string prefix = g_tls_log_prefix();
// Get first (main) listener
@@ -277,7 +294,7 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, const u
if (!g_init)
{
semaphore_lock lock(g_mutex);
std::lock_guard lock(g_mutex);
if (!g_init)
{
@@ -305,12 +322,12 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, const u
logs::file_writer::file_writer(const std::string& name)
: m_name(name)
{
const std::string log_name = fs::get_config_dir() + name + ".log";
const std::string buf_name = fs::get_config_dir() + name + ".buf";
const std::string log_name = fs::get_cache_dir() + name + ".log";
const std::string buf_name = fs::get_cache_dir() + name + ".buf";
try
{
if (!m_file.open(buf_name, fs::read + fs::write + fs::create + fs::trunc + fs::unshare))
if (!m_file.open(buf_name, fs::read + fs::rewrite + fs::lock))
{
if (fs::g_tls_error == fs::error::acces)
{
@@ -335,7 +352,7 @@ logs::file_writer::file_writer(const std::string& name)
// Check free space
fs::device_stat stats{};
if (!fs::statfs(fs::get_config_dir(), stats) || stats.avail_free < s_log_size * 8)
if (!fs::statfs(fs::get_cache_dir(), stats) || stats.avail_free < s_log_size * 8)
{
fmt::throw_exception("Not enough free space (%f KB)", stats.avail_free / 1000000.);
}
@@ -355,18 +372,25 @@ logs::file_writer::file_writer(const std::string& name)
verify(name.c_str()), m_fptr;
// Rotate backups (TODO)
fs::remove_file(fs::get_config_dir() + name + "1.log.gz");
fs::create_dir(fs::get_config_dir() + "old_logs");
fs::rename(fs::get_config_dir() + m_name + ".log.gz", fs::get_config_dir() + "old_logs/" + m_name + ".log.gz", true);
fs::remove_file(fs::get_cache_dir() + name + "1.log.gz");
fs::create_dir(fs::get_cache_dir() + "old_logs");
fs::rename(fs::get_cache_dir() + m_name + ".log.gz", fs::get_cache_dir() + "old_logs/" + m_name + ".log.gz", true);
// Actual log file (allowed to fail)
m_fout.open(log_name, fs::rewrite);
// Compressed log
if (!m_fout2.open(log_name + ".gz", fs::rewrite) || deflateInit2(&m_zs, 9, Z_DEFLATED, 16 + 15, 9, Z_DEFAULT_STRATEGY) != Z_OK)
// Compressed log, make it inaccessible (foolproof)
if (!m_fout2.open(log_name + ".gz", fs::rewrite + fs::unread) || deflateInit2(&m_zs, 9, Z_DEFLATED, 16 + 15, 9, Z_DEFAULT_STRATEGY) != Z_OK)
{
m_fout2.close();
}
#ifdef _WIN32
// Autodelete compressed log file
FILE_DISPOSITION_INFO disp;
disp.DeleteFileW = TRUE;
SetFileInformationByHandle(m_fout2.get_handle(), FileDispositionInfo, &disp, sizeof(disp));
#endif
}
catch (const std::exception& e)
{
@@ -444,16 +468,23 @@ logs::file_writer::~file_writer()
}
#ifdef _WIN32
// Cancel compressed log file autodeletion
FILE_DISPOSITION_INFO disp;
disp.DeleteFileW = FALSE;
SetFileInformationByHandle(m_fout2.get_handle(), FileDispositionInfo, &disp, sizeof(disp));
UnmapViewOfFile(m_fptr);
CloseHandle(m_fmap);
#else
// Restore compressed log file permissions
::fchmod(m_fout2.get_handle(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
::munmap(m_fptr, s_log_size);
#endif
}
bool logs::file_writer::flush(u64 bufv)
{
semaphore_lock lock(m_m);
std::lock_guard lock(m_m);
const u64 st = +m_out;
const u64 end = std::min<u64>((st + s_log_size) & ~(s_log_size - 1), bufv >> 24);
@@ -592,7 +623,7 @@ void logs::file_listener::log(u64 stamp, const logs::message& msg, const std::st
case level::_uninit: text = u8"· "; break;
}
// Print miscosecond timestamp
// Print µs timestamp
const u64 hours = stamp / 3600'000'000;
const u64 mins = (stamp % 3600'000'000) / 60'000'000;
const u64 secs = (stamp % 60'000'000) / 1'000'000;
+15 -16
View File
@@ -23,14 +23,17 @@ namespace logs
struct channel;
// Message information (temporary data)
// Message information
struct message
{
channel* ch;
level sev;
private:
// Send log message to global logger instance
void broadcast(const char*, const fmt_type_info*, const u64*);
void broadcast(const char*, const fmt_type_info*, ...) const;
friend struct channel;
};
class listener
@@ -67,21 +70,16 @@ namespace logs
{
}
// Formatting function
template<typename... Args>
SAFE_BUFFERS FORCE_INLINE void format(level sev, const char* fmt, const Args&... args)
{
if (UNLIKELY(sev <= enabled))
{
message{this, sev}.broadcast(fmt, fmt::get_type_info<fmt_unveil_t<Args>...>(), fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});
}
}
#define GEN_LOG_METHOD(_sev)\
template<typename... Args>\
SAFE_BUFFERS void _sev(const char* fmt, const Args&... args)\
const message msg_##_sev{this, level::_sev};\
template <typename... Args>\
void _sev(const char* fmt, const Args&... args)\
{\
return format<Args...>(level::_sev, fmt, args...);\
if (UNLIKELY(level::_sev <= enabled))\
{\
static constexpr fmt_type_info type_list[sizeof...(Args) + 1]{fmt_type_info::make<fmt_unveil_t<Args>>()...};\
msg_##_sev.broadcast(fmt, type_list, u64{fmt_unveil<Args>::get(args)}...);\
}\
}
GEN_LOG_METHOD(fatal)
@@ -104,7 +102,6 @@ namespace logs
extern channel HLE;
extern channel PPU;
extern channel SPU;
extern channel ARMv7;
// Log level control: set all channels to level::notice
void reset();
@@ -113,6 +110,8 @@ namespace logs
void set_level(const std::string&, level);
}
#define LOG_CHANNEL(ch, ...) ::logs::channel ch(#ch, ##__VA_ARGS__);
// Legacy:
#define LOG_SUCCESS(ch, fmt, ...) logs::ch.success("" fmt, ##__VA_ARGS__)
+67 -11
View File
@@ -4,6 +4,7 @@
#include "cfmt.h"
#include <algorithm>
#include <string_view>
#ifdef _WIN32
#include <Windows.h>
@@ -23,34 +24,81 @@ void fmt_class_string<std::pair<const fmt_type_info*, u64>>::format(std::string&
}
}
template <>
void fmt_class_string<fmt::base57>::format(std::string& out, u64 arg)
{
const auto& _arg = get_object(arg);
if (_arg.data && _arg.size)
{
// Precomputed tail sizes if input data is not multiple of 8
static constexpr u8 s_tail[8] = {0, 2, 3, 5, 6, 7, 9, 10};
// Get full output size
const std::size_t out_size = _arg.size / 8 * 11 + s_tail[_arg.size % 8];
out.resize(out.size() + out_size);
const auto ptr = &out.front() + (out.size() - out_size);
// Each 8 bytes of input data produce 11 bytes of base57 output
for (std::size_t i = 0, p = 0; i < _arg.size; i += 8, p += 11)
{
// Load up to 8 bytes
be_t<u64> be_value;
if (_arg.size - i < sizeof(be_value))
{
std::memset(&be_value, 0, sizeof(be_value));
std::memcpy(&be_value, _arg.data + i, _arg.size - i);
}
else
{
std::memcpy(&be_value, _arg.data + i, sizeof(be_value));
}
u64 value = be_value;
for (int j = 10; j >= 0; j--)
{
if (p + j < out_size)
{
ptr[p + j] = "0123456789ACEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"[value % 57];
}
value /= 57;
}
}
}
}
void fmt_class_string<const void*>::format(std::string& out, u64 arg)
{
if (arg)
{
fmt::append(out, "%p", reinterpret_cast<const void*>(static_cast<std::uintptr_t>(arg)));
}
else
{
out += "(NULL)";
}
fmt::append(out, "%p", arg);
}
void fmt_class_string<const char*>::format(std::string& out, u64 arg)
{
if (arg)
{
out += reinterpret_cast<const char*>(static_cast<std::uintptr_t>(arg));
out += reinterpret_cast<const char*>(arg);
}
else
{
out += "(NULL)";
out += "(NULLSTR)";
}
}
template <>
void fmt_class_string<std::string>::format(std::string& out, u64 arg)
{
out += get_object(arg).c_str(); // TODO?
out += get_object(arg);
}
template <>
void fmt_class_string<std::string_view>::format(std::string& out, u64 arg)
{
out += get_object(arg);
}
template <>
@@ -375,6 +423,14 @@ std::string fmt::to_upper(const std::string& string)
return result;
}
std::string fmt::to_lower(const std::string& string)
{
std::string result;
result.resize(string.size());
std::transform(string.begin(), string.end(), result.begin(), ::tolower);
return result;
}
bool fmt::match(const std::string& source, const std::string& mask)
{
std::size_t source_position = 0, mask_position = 0;
+32 -7
View File
@@ -91,9 +91,9 @@ struct fmt_unveil<T, std::enable_if_t<std::is_enum<T>::value>>
template <typename T>
struct fmt_unveil<T*, void>
{
using type = const T*;
using type = std::add_const_t<T>*;
static inline u64 get(const T* arg)
static inline u64 get(type arg)
{
return reinterpret_cast<std::uintptr_t>(arg);
}
@@ -102,9 +102,9 @@ struct fmt_unveil<T*, void>
template <typename T, std::size_t N>
struct fmt_unveil<T[N], void>
{
using type = const T*;
using type = std::add_const_t<T>*;
static inline u64 get(const T* arg)
static inline u64 get(type arg)
{
return reinterpret_cast<std::uintptr_t>(arg);
}
@@ -250,15 +250,38 @@ using fmt_args_t = const u64(&&)[sizeof...(Args) + 1];
namespace fmt
{
// Base-57 format helper
struct base57
{
const uchar* data;
std::size_t size;
template <typename T>
base57(const T& arg)
: data(reinterpret_cast<const uchar*>(&arg))
, size(sizeof(T))
{
}
base57(const uchar* data, std::size_t size)
: data(data)
, size(size)
{
}
};
template <typename... Args>
SAFE_BUFFERS FORCE_INLINE const fmt_type_info* get_type_info()
{
// Constantly initialized null-terminated list of type-specific information
static constexpr fmt_type_info result[sizeof...(Args) + 1]{fmt_type_info::make<Args>()...};
static constexpr fmt_type_info result[sizeof...(Args) + 1]{fmt_type_info::make<fmt_unveil_t<Args>>()...};
return result;
}
template <typename... Args>
constexpr const fmt_type_info type_info_v[sizeof...(Args) + 1]{fmt_type_info::make<fmt_unveil_t<Args>>()...};
// Internal formatting function
void raw_append(std::string& out, const char*, const fmt_type_info*, const u64*) noexcept;
@@ -266,7 +289,8 @@ namespace fmt
template <typename... Args>
SAFE_BUFFERS FORCE_INLINE void append(std::string& out, const char* fmt, const Args&... args)
{
raw_append(out, fmt, fmt::get_type_info<fmt_unveil_t<Args>...>(), fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});
static constexpr fmt_type_info type_list[sizeof...(Args) + 1]{fmt_type_info::make<fmt_unveil_t<Args>>()...};
raw_append(out, fmt, type_list, fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});
}
// Formatting function
@@ -286,6 +310,7 @@ namespace fmt
template <typename T = std::runtime_error, typename... Args>
[[noreturn]] SAFE_BUFFERS FORCE_INLINE void throw_exception(const char* fmt, const Args&... args)
{
raw_throw_exception<T>(fmt, fmt::get_type_info<fmt_unveil_t<Args>...>(), fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});
static constexpr fmt_type_info type_list[sizeof...(Args) + 1]{fmt_type_info::make<fmt_unveil_t<Args>>()...};
raw_throw_exception<T>(fmt, type_list, fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});
}
}
+4 -2
View File
@@ -5,6 +5,7 @@
#include <string>
#include <vector>
#include <functional>
#include <string_view>
// Copy null-terminated string from std::string to char array with truncation
template <std::size_t N>
@@ -100,10 +101,10 @@ namespace fmt
auto end = source.end();
for (--end; it != end; ++it)
{
result += *it + separator;
result += std::string{*it} + separator;
}
return result + source.back();
return result + std::string{source.back()};
}
template <typename T>
@@ -134,6 +135,7 @@ namespace fmt
}
std::string to_upper(const std::string& string);
std::string to_lower(const std::string& string);
bool match(const std::string& source, const std::string& mask);
}
+193 -227
View File
@@ -1,5 +1,5 @@
#include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/Memory/vm.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/Cell/RawSPUThread.h"
@@ -14,6 +14,7 @@
#include <Windows.h>
#include <Psapi.h>
#include <process.h>
#include <sysinfoapi.h>
#else
#ifdef __APPLE__
#define _XOPEN_SOURCE
@@ -21,7 +22,7 @@
#include <mach/thread_act.h>
#include <mach/thread_policy.h>
#endif
#if defined(__DragonFly__) || defined(__FreeBSD__)
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <pthread_np.h>
#define cpu_set_t cpuset_t
#endif
@@ -31,13 +32,16 @@
#include <pthread.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <time.h>
#endif
#include "sync.h"
#include "Log.h"
thread_local u64 g_tls_fault_all = 0;
thread_local u64 g_tls_fault_rsx = 0;
thread_local u64 g_tls_fault_spu = 0;
extern thread_local std::string(*g_tls_log_prefix)();
[[noreturn]] void catch_all_exceptions()
{
@@ -47,11 +51,11 @@ thread_local u64 g_tls_fault_spu = 0;
}
catch (const std::exception& e)
{
report_fatal_error("Unhandled exception of type '"s + typeid(e).name() + "': "s + e.what());
report_fatal_error("{" + g_tls_log_prefix() + "} Unhandled exception of type '"s + typeid(e).name() + "': "s + e.what());
}
catch (...)
{
report_fatal_error("Unhandled exception (unknown)");
report_fatal_error("{" + g_tls_log_prefix() + "} Unhandled exception (unknown)");
}
}
@@ -90,7 +94,7 @@ enum x64_reg_t : u32
X64R_XMM13,
X64R_XMM14,
X64R_XMM15,
X64R_AL,
X64R_CL,
X64R_DL,
@@ -99,7 +103,7 @@ enum x64_reg_t : u32
X64R_CH,
X64R_DH,
X64R_BH,
X64_NOT_SET,
X64_IMM8,
X64_IMM16,
@@ -176,7 +180,7 @@ void decode_x64_reg_op(const u8* code, x64_op_t& out_op, x64_reg_t& out_reg, siz
{
LOG_ERROR(MEMORY, "decode_x64_reg_op(%016llxh): LOCK prefix found twice", (size_t)code - out_length);
}
lock = true;
continue;
}
@@ -186,7 +190,7 @@ void decode_x64_reg_op(const u8* code, x64_op_t& out_op, x64_reg_t& out_reg, siz
{
LOG_ERROR(MEMORY, "decode_x64_reg_op(%016llxh): REPNE/REPNZ prefix found twice", (size_t)code - out_length);
}
repne = true;
continue;
}
@@ -196,7 +200,7 @@ void decode_x64_reg_op(const u8* code, x64_op_t& out_op, x64_reg_t& out_reg, siz
{
LOG_ERROR(MEMORY, "decode_x64_reg_op(%016llxh): REP/REPE/REPZ prefix found twice", (size_t)code - out_length);
}
repe = true;
continue;
}
@@ -225,7 +229,7 @@ void decode_x64_reg_op(const u8* code, x64_op_t& out_op, x64_reg_t& out_reg, siz
{
LOG_ERROR(MEMORY, "decode_x64_reg_op(%016llxh): operand-size override prefix found twice", (size_t)code - out_length);
}
oso = true;
continue;
}
@@ -837,7 +841,7 @@ static const decltype(_REG_RAX) reg_table[] =
#else
static const decltype(REG_RAX) reg_table[] =
static const int reg_table[] =
{
REG_RAX, REG_RCX, REG_RDX, REG_RBX, REG_RSP, REG_RBP, REG_RSI, REG_RDI,
REG_R8, REG_R9, REG_R10, REG_R11, REG_R12, REG_R13, REG_R14, REG_R15, REG_RIP
@@ -917,7 +921,7 @@ bool get_x64_reg_value(x64_context* context, x64_reg_t reg, size_t d_size, size_
else if (reg == X64_IMM32)
{
const s32 imm_value = *(s32*)(RIP(context) + i_size - 4);
switch (d_size)
{
case 4: out_value = (u32)imm_value; return true;
@@ -1088,16 +1092,42 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
const auto cpu = get_current_cpu_thread();
if (rsx::g_access_violation_handler && rsx::g_access_violation_handler(addr, is_writing))
if (rsx::g_access_violation_handler)
{
g_tls_fault_rsx++;
bool handled = false;
if (cpu)
try
{
cpu->test_state();
handled = rsx::g_access_violation_handler(addr, is_writing);
}
catch (const std::exception& e)
{
LOG_FATAL(RSX, "g_access_violation_handler(0x%x, %d): %s", addr, is_writing, e.what());
if (cpu)
{
vm::temporary_unlock(*cpu);
cpu->state += cpu_flag::dbg_pause;
if (cpu->test_stopped())
{
std::terminate();
}
}
return false;
}
return true;
if (handled)
{
g_tls_fault_rsx++;
if (cpu && cpu->test_stopped())
{
//
}
return true;
}
}
auto code = (const u8*)RIP(context);
@@ -1138,7 +1168,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
// check if address is RawSPU MMIO register
if (addr - RAW_SPU_BASE_ADDR < (6 * RAW_SPU_OFFSET) && (addr % RAW_SPU_OFFSET) >= RAW_SPU_PROB_OFFSET)
{
auto thread = idm::get<RawSPUThread>((addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET);
auto thread = idm::get<named_thread<spu_thread>>(spu_thread::find_raw_spu((addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET));
if (!thread)
{
@@ -1233,9 +1263,9 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
if (vm::check_addr(addr, std::max<std::size_t>(1, d_size), vm::page_allocated | (is_writing ? vm::page_writable : vm::page_readable)))
{
if (cpu)
if (cpu && cpu->test_stopped())
{
cpu->test_state();
//
}
return true;
@@ -1243,7 +1273,8 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
if (cpu)
{
if (fxm::check<page_fault_notification_entries>())
// TODO: Only PPU thread page fault notifications are supported
if (cpu->id_type() == 1 && fxm::check<page_fault_notification_entries>())
{
for (const auto& entry : fxm::get<page_fault_notification_entries>()->entries)
{
@@ -1254,27 +1285,27 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
}
if (entry.start_addr <= addr && addr <= addr + mem->size - 1)
{
// Place the page fault event onto table so that other functions [sys_mmapper_free_address and ppu pagefault funcs]
// Place the page fault event onto table so that other functions [sys_mmapper_free_address and ppu pagefault funcs]
// know that this thread is page faulted and where.
auto pf_entries = fxm::get_always<page_fault_event_entries>();
{
semaphore_lock pf_lock(pf_entries->pf_mutex);
std::lock_guard pf_lock(pf_entries->pf_mutex);
page_fault_event pf_event{ cpu->id, addr };
pf_entries->events.emplace_back(pf_event);
}
// Now, we notify the game that a page fault occurred so it can rectify it.
// Note, for data3, were the memory readable AND we got a page fault, it must be due to a write violation since reads are allowed.
be_t<u64> data1 = addr;
be_t<u64> data2 = (SYS_MEMORY_PAGE_FAULT_TYPE_PPU_THREAD << 32) + cpu->id; // TODO: fix hack for now that assumes PPU thread always.
be_t<u64> data3 = vm::check_addr(addr, a_size, vm::page_readable) ? SYS_MEMORY_PAGE_FAULT_CAUSE_READ_ONLY : SYS_MEMORY_PAGE_FAULT_CAUSE_NON_MAPPED;
u64 data1 = addr;
u64 data2 = ((u64)SYS_MEMORY_PAGE_FAULT_TYPE_PPU_THREAD << 32) + cpu->id;
u64 data3 = vm::check_addr(addr, a_size, vm::page_readable) ? SYS_MEMORY_PAGE_FAULT_CAUSE_READ_ONLY : SYS_MEMORY_PAGE_FAULT_CAUSE_NON_MAPPED;
LOG_ERROR(MEMORY, "Page_fault %s location 0x%x because of %s memory", is_writing ? "writing" : "reading",
addr, data3 == SYS_MEMORY_PAGE_FAULT_CAUSE_READ_ONLY ? "writing read-only" : "using unmapped");
error_code sending_error = sys_event_port_send(entry.port_id, data1, data2, data3);
// If we fail due to being busy, wait a bit and try again.
while (sending_error == CELL_EBUSY)
{
@@ -1282,7 +1313,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
thread_ctrl::wait_for(1000);
sending_error = sys_event_port_send(entry.port_id, data1, data2, data3);
}
if (sending_error)
{
fmt::throw_exception("Unknown error %x while trying to pass page fault.", sending_error.value);
@@ -1295,9 +1326,20 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
}
}
LOG_FATAL(MEMORY, "Access violation %s location 0x%x", is_writing ? "writing" : "reading", addr);
cpu->state += cpu_flag::dbg_pause;
cpu->check_state();
vm::temporary_unlock(*cpu);
}
LOG_FATAL(MEMORY, "Access violation %s location 0x%x", is_writing ? "writing" : "reading", addr);
Emu.Pause();
while (Emu.IsPaused())
{
thread_ctrl::wait();
}
if (Emu.IsStopped())
{
std::terminate();
}
return true;
@@ -1382,7 +1424,6 @@ static LONG exception_handler(PEXCEPTION_POINTERS pExp)
return EXCEPTION_CONTINUE_EXECUTION;
}
}
return EXCEPTION_CONTINUE_SEARCH;
}
@@ -1547,66 +1588,26 @@ extern atomic_t<u32> g_thread_count(0);
thread_local DECLARE(thread_ctrl::g_tls_this_thread) = nullptr;
extern thread_local std::string(*g_tls_log_prefix)();
DECLARE(thread_ctrl::g_native_core_layout) { native_core_arrangement::undefined };
void thread_ctrl::start(const std::shared_ptr<thread_ctrl>& ctrl, task_stack task)
void thread_base::start(native_entry entry)
{
#ifdef _WIN32
using thread_result = uint;
using thread_type = thread_result(__stdcall*)(void* arg);
m_thread = ::_beginthreadex(nullptr, 0, entry, this, CREATE_SUSPENDED, nullptr);
verify("thread_ctrl::start" HERE), m_thread, ::ResumeThread(reinterpret_cast<HANDLE>(+m_thread)) != -1;
#else
using thread_result = void*;
using thread_type = thread_result(*)(void* arg);
verify("thread_ctrl::start" HERE), pthread_create(reinterpret_cast<pthread_t*>(&m_thread.raw()), nullptr, entry, this) == 0;
#endif
// Thread entry point
const thread_type entry = [](void* arg) -> thread_result
{
// Recover shared_ptr from short-circuited thread_ctrl object pointer
const std::shared_ptr<thread_ctrl> ctrl = static_cast<thread_ctrl*>(arg)->m_self;
try
{
ctrl->initialize();
task_stack{std::move(ctrl->m_task)}.invoke();
}
catch (...)
{
// Capture exception
ctrl->finalize(std::current_exception());
return 0;
}
ctrl->finalize(nullptr);
return 0;
};
ctrl->m_self = ctrl;
ctrl->m_task = std::move(task);
// TODO: implement simple thread pool
#ifdef _WIN32
std::uintptr_t thread = _beginthreadex(nullptr, 0, entry, ctrl.get(), 0, nullptr);
verify("thread_ctrl::start" HERE), thread != 0;
#else
pthread_t thread;
verify("thread_ctrl::start" HERE), pthread_create(&thread, nullptr, entry, ctrl.get()) == 0;
#endif
// TODO: this is unsafe and must be duplicated in thread_ctrl::initialize
ctrl->m_thread = (uintptr_t)thread;
}
void thread_ctrl::initialize()
void thread_base::initialize()
{
// Initialize TLS variable
g_tls_this_thread = this;
thread_ctrl::g_tls_this_thread = this;
g_tls_log_prefix = []
{
return g_tls_this_thread->m_name;
return thread_ctrl::g_tls_this_thread->m_name.get();
};
++g_thread_count;
@@ -1625,7 +1626,7 @@ void thread_ctrl::initialize()
{
THREADNAME_INFO info;
info.dwType = 0x1000;
info.szName = m_name.c_str();
info.szName = m_name.get().c_str();
info.dwThreadID = -1;
info.dwFlags = 0;
@@ -1638,13 +1639,22 @@ void thread_ctrl::initialize()
}
}
#endif
#if defined(__APPLE__)
pthread_setname_np(m_name.get().substr(0, 15).c_str());
#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
pthread_set_name_np(pthread_self(), m_name.get().c_str());
#elif defined(__NetBSD__)
pthread_setname_np(pthread_self(), "%s", (void*)m_name.get().c_str());
#elif !defined(_WIN32)
pthread_setname_np(pthread_self(), m_name.get().substr(0, 15).c_str());
#endif
}
void thread_ctrl::finalize(std::exception_ptr eptr) noexcept
bool thread_base::finalize(int) noexcept
{
// Run atexit functions
m_task.invoke();
m_task.reset();
// Report pending errors
error_code::error_report(0, 0, 0, 0);
#ifdef _WIN32
ULONG64 cycles{};
@@ -1664,7 +1674,7 @@ void thread_ctrl::finalize(std::exception_ptr eptr) noexcept
g_tls_log_prefix = []
{
return g_tls_this_thread->m_name;
return thread_ctrl::g_tls_this_thread->m_name.get();
};
LOG_NOTICE(GENERAL, "Thread time: %fs (%fGc); Faults: %u [rsx:%u, spu:%u];",
@@ -1674,47 +1684,31 @@ void thread_ctrl::finalize(std::exception_ptr eptr) noexcept
g_tls_fault_rsx,
g_tls_fault_spu);
--g_thread_count;
// Return true if need to delete thread object
const bool result = m_state.exchange(thread_state::finished) == thread_state::detached;
// Untangle circular reference, set exception
semaphore_lock{m_mutex}, m_self.reset(), m_exception = eptr;
// Signal joining waiters
// Signal waiting threads
m_mutex.lock_unlock();
m_jcv.notify_all();
return result;
}
void thread_ctrl::_push(task_stack task)
void thread_base::finalize() noexcept
{
g_tls_this_thread->m_task.push(std::move(task));
g_tls_log_prefix = []() -> std::string { return {}; };
thread_ctrl::g_tls_this_thread = nullptr;
--g_thread_count;
}
bool thread_ctrl::_wait_for(u64 usec)
{
auto _this = g_tls_this_thread;
struct half_lock
{
semaphore<>& ref;
void lock()
{
// Used to avoid additional lock + unlock
}
void unlock()
{
ref.post();
}
}
_lock{_this->m_mutex};
do
{
// Mutex is unlocked at the start and after the waiting
if (u32 sig = _this->m_signal.load())
{
thread_ctrl::test();
if (sig & 1)
{
_this->m_signal &= ~1;
@@ -1728,57 +1722,31 @@ bool thread_ctrl::_wait_for(u64 usec)
return false;
}
// Lock (semaphore)
_this->m_mutex.wait();
_this->m_mutex.lock();
// Double-check the value
if (u32 sig = _this->m_signal.load())
{
if (sig & 2 && _this->m_exception)
{
_this->_throw();
}
if (sig & 1)
{
_this->m_signal &= ~1;
_this->m_mutex.post();
_this->m_mutex.unlock();
return true;
}
}
}
while (_this->m_cond.wait(_lock, std::exchange(usec, usec > cond_variable::max_timeout ? -1 : 0)));
while (_this->m_cond.wait_unlock(std::exchange(usec, usec > cond_variable::max_timeout ? -1 : 0), _this->m_mutex));
// Timeout
return false;
}
[[noreturn]] void thread_ctrl::_throw()
{
std::exception_ptr ex = std::exchange(m_exception, std::exception_ptr{});
m_signal &= ~3;
m_mutex.post();
std::rethrow_exception(std::move(ex));
}
void thread_ctrl::_notify(cond_variable thread_ctrl::* ptr)
{
// Optimized lock + unlock
if (!m_mutex.get())
{
m_mutex.wait();
m_mutex.post();
}
(this->*ptr).notify_one();
}
thread_ctrl::thread_ctrl(std::string&& name)
: m_name(std::move(name))
thread_base::thread_base(std::string_view name)
: m_name(name)
{
}
thread_ctrl::~thread_ctrl()
thread_base::~thread_base()
{
if (m_thread)
{
@@ -1790,70 +1758,65 @@ thread_ctrl::~thread_ctrl()
}
}
std::exception_ptr thread_ctrl::get_exception() const
void thread_base::join() const
{
semaphore_lock lock(m_mutex);
return m_exception;
}
void thread_ctrl::set_exception(std::exception_ptr ptr)
{
semaphore_lock lock(m_mutex);
m_exception = ptr;
if (m_exception)
if (m_state == thread_state::finished)
{
m_signal |= 2;
m_cond.notify_one();
return;
}
else
{
m_signal &= ~2;
}
}
void thread_ctrl::join()
{
#ifdef _WIN32
//verify("thread_ctrl::join" HERE), WaitForSingleObjectEx((HANDLE)m_thread.load(), -1, false) == WAIT_OBJECT_0;
#endif
std::unique_lock lock(m_mutex);
semaphore_lock lock(m_mutex);
while (m_self)
while (m_state != thread_state::finished)
{
m_jcv.wait(lock);
}
if (UNLIKELY(m_exception && !std::uncaught_exception()))
{
std::rethrow_exception(m_exception);
}
}
void thread_ctrl::notify()
void thread_base::notify()
{
if (!(m_signal & 1))
{
m_signal |= 1;
_notify(&thread_ctrl::m_cond);
m_mutex.lock_unlock();
m_cond.notify_one();
}
}
void thread_ctrl::test()
u64 thread_base::get_cycles()
{
const auto _this = g_tls_this_thread;
u64 cycles;
if (_this->m_signal & 2)
#ifdef _WIN32
if (QueryThreadCycleTime((HANDLE)m_thread.load(), &cycles))
{
_this->m_mutex.wait();
if (_this->m_exception)
#elif __APPLE__
mach_port_name_t port = pthread_mach_thread_np((pthread_t)m_thread.load());
mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
thread_basic_info_data_t info;
kern_return_t ret = thread_info(port, THREAD_BASIC_INFO, (thread_info_t)&info, &count);
if (ret == KERN_SUCCESS)
{
cycles = static_cast<u64>(info.user_time.seconds + info.system_time.seconds) * 1'000'000'000 +
static_cast<u64>(info.user_time.microseconds + info.system_time.microseconds) * 1'000;
#else
clockid_t _clock;
struct timespec thread_time;
if (!pthread_getcpuclockid((pthread_t)m_thread.load(), &_clock) && !clock_gettime(_clock, &thread_time))
{
cycles = static_cast<u64>(thread_time.tv_sec) * 1'000'000'000 + thread_time.tv_nsec;
#endif
if (const u64 old_cycles = m_cycles.exchange(cycles))
{
_this->_throw();
return cycles - old_cycles;
}
_this->m_mutex.post();
// Report 0 the first time this function is called
return 0;
}
else
{
return m_cycles;
}
}
@@ -1867,9 +1830,52 @@ void thread_ctrl::detect_cpu_layout()
{
g_native_core_layout.store(native_core_arrangement::amd_ccx);
}
else if (system_id.find("i3") != std::string::npos || system_id.find("i7") != std::string::npos)
else if (system_id.find("Intel") != std::string::npos)
{
g_native_core_layout.store(native_core_arrangement::intel_ht);
#ifdef _WIN32
const LOGICAL_PROCESSOR_RELATIONSHIP relationship = LOGICAL_PROCESSOR_RELATIONSHIP::RelationProcessorCore;
DWORD buffer_size = 0;
// If buffer size is set to 0 bytes, it will be overwritten with the required size
if (GetLogicalProcessorInformationEx(relationship, nullptr, &buffer_size))
{
LOG_ERROR(GENERAL, "GetLogicalProcessorInformationEx returned 0 bytes");
return;
}
DWORD error_code = GetLastError();
if (error_code != ERROR_INSUFFICIENT_BUFFER)
{
LOG_ERROR(GENERAL, "Unexpected windows error code when detecting CPU layout: %u", error_code);
return;
}
std::vector<u8> buffer(buffer_size);
if (!GetLogicalProcessorInformationEx(relationship,
reinterpret_cast<SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *>(buffer.data()), &buffer_size))
{
LOG_ERROR(GENERAL, "GetLogicalProcessorInformationEx failed (size=%u, error=%u)", buffer_size, GetLastError());
}
else
{
// Iterate through the buffer until a core with hyperthreading is found
auto ptr = reinterpret_cast<std::uintptr_t>(buffer.data());
const std::uintptr_t end = ptr + buffer_size;
while (ptr < end)
{
auto info = reinterpret_cast<SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *>(ptr);
if (info->Relationship == relationship && info->Processor.Flags == LTP_PC_SMT)
{
g_native_core_layout.store(native_core_arrangement::intel_ht);
break;
}
ptr += info->Size;
}
}
#else
LOG_TODO(GENERAL, "Thread scheduler is not implemented for Intel and this OS");
#endif
}
}
@@ -1926,6 +1932,7 @@ u16 thread_ctrl::get_affinity_mask(thread_class group)
}
case native_core_arrangement::intel_ht:
{
/* This has been disabled as it seems to degrade performance instead of improving it.
if (thread_count <= 4)
{
//i3 or worse
@@ -1940,6 +1947,7 @@ u16 thread_ctrl::get_affinity_mask(thread_class group)
return all_cores_mask;
}
}
*/
return all_cores_mask;
}
@@ -2006,45 +2014,3 @@ void thread_ctrl::set_thread_affinity_mask(u16 mask)
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cs);
#endif
}
named_thread::named_thread()
{
}
named_thread::~named_thread()
{
}
std::string named_thread::get_name() const
{
return fmt::format("('%s') Unnamed Thread", typeid(*this).name());
}
void named_thread::start_thread(const std::shared_ptr<void>& _this)
{
// Ensure it's not called from the constructor and the correct object is passed
verify("named_thread::start_thread" HERE), _this.get() == this;
// Run thread
thread_ctrl::spawn(m_thread, get_name(), [this, _this]()
{
try
{
LOG_TRACE(GENERAL, "Thread started");
on_spawn();
on_task();
LOG_TRACE(GENERAL, "Thread ended");
}
catch (const std::exception& e)
{
LOG_FATAL(GENERAL, "%s thrown: %s", typeid(e).name(), e.what());
Emu.Pause();
}
on_exit();
});
}
task_stack::task_base::~task_base()
{
}
+283 -208
View File
@@ -3,12 +3,13 @@
#include "types.h"
#include "Atomic.h"
#include <exception>
#include <string>
#include <memory>
#include <string_view>
#include "sema.h"
#include "mutex.h"
#include "cond.h"
#include "lockless.h"
// Report error and call std::abort(), defined in main.cpp
[[noreturn]] void report_fatal_error(const std::string&);
@@ -33,92 +34,82 @@ enum class thread_class : u32
ppu
};
// Simple list of void() functors
class task_stack
enum class thread_state
{
struct task_base
{
std::unique_ptr<task_base> next;
virtual ~task_base();
virtual void invoke()
{
if (next)
{
next->invoke();
}
}
};
template <typename F>
struct task_type final : task_base
{
std::remove_reference_t<F> func;
task_type(F&& func)
: func(std::forward<F>(func))
{
}
void invoke() final override
{
func();
task_base::invoke();
}
};
std::unique_ptr<task_base> m_stack;
public:
task_stack() = default;
template <typename F>
task_stack(F&& func)
: m_stack(new task_type<F>(std::forward<F>(func)))
created, // Initial state
detached, // The thread has been detached to destroy its own named_thread object (can be dangerously misused)
aborting, // The thread has been joined in the destructor or explicitly aborted (mutually exclusive with detached)
finished // Final state, always set at the end of thread execution
};
template <class Context>
class named_thread;
template <typename T>
struct result_storage
{
alignas(T) std::byte data[sizeof(T)];
static constexpr bool empty = false;
using type = T;
T* get()
{
return reinterpret_cast<T*>(&data);
}
void push(task_stack stack)
const T* get() const
{
auto _top = stack.m_stack.release();
auto _next = m_stack.release();
m_stack.reset(_top);
while (UNLIKELY(_top->next)) _top = _top->next.get();
_top->next.reset(_next);
return reinterpret_cast<const T*>(&data);
}
void reset()
void destroy() noexcept
{
m_stack.reset();
}
void invoke() const
{
if (m_stack)
{
m_stack->invoke();
}
get()->~T();
}
};
// Thread control class
class thread_ctrl final
template <>
struct result_storage<void>
{
// Current thread
static thread_local thread_ctrl* g_tls_this_thread;
static constexpr bool empty = true;
// Target cpu core layout
static atomic_t<native_core_arrangement> g_native_core_layout;
using type = void;
};
// Self pointer
std::shared_ptr<thread_ctrl> m_self;
template <class Context, typename... Args>
using result_storage_t = result_storage<std::invoke_result_t<Context, Args...>>;
// Detect on_abort() method (should return void)
template <typename T, typename = void>
struct thread_on_abort : std::bool_constant<false> {};
template <typename T>
struct thread_on_abort<T, decltype(std::declval<named_thread<T>&>().on_abort())> : std::bool_constant<true> {};
// Detect on_cleanup() static member function (should return void) (in C++20 can use destroying delete instead)
template <typename T, typename = void>
struct thread_on_cleanup : std::bool_constant<false> {};
template <typename T>
struct thread_on_cleanup<T, decltype(named_thread<T>::on_cleanup(std::declval<named_thread<T>*>()))> : std::bool_constant<true> {};
// Thread base class
class thread_base
{
// Native thread entry point function type
#ifdef _WIN32
using native_entry = uint(__stdcall*)(void* arg);
#else
using native_entry = void*(*)(void* arg);
#endif
// Thread handle (platform-specific)
atomic_t<std::uintptr_t> m_thread{0};
// Thread mutex
mutable semaphore<> m_mutex;
mutable shared_mutex m_mutex;
// Thread condition variable
cond_variable m_cond;
@@ -127,77 +118,123 @@ class thread_ctrl final
atomic_t<u32> m_signal{0};
// Thread joining condition variable
cond_variable m_jcv;
mutable cond_variable m_jcv;
// Remotely set or caught exception
std::exception_ptr m_exception;
// Thread state
atomic_t<thread_state> m_state = thread_state::created;
// Thread initial task or atexit task
task_stack m_task;
// Thread name
lf_value<std::string> m_name;
// Fixed name
std::string m_name;
//
atomic_t<u64> m_cycles = 0;
// Start thread
static void start(const std::shared_ptr<thread_ctrl>&, task_stack);
void start(native_entry);
// Called at the thread start
void initialize();
// Called at the thread end
void finalize(std::exception_ptr) noexcept;
// Called at the thread end, returns true if needs destruction
bool finalize(int) noexcept;
// Add task (atexit)
static void _push(task_stack);
// Cleanup after possibly deleting the thread instance
static void finalize() noexcept;
friend class thread_ctrl;
template <class Context>
friend class named_thread;
protected:
thread_base(std::string_view name);
~thread_base();
public:
// Get CPU cycles since last time this function was called. First call returns 0.
u64 get_cycles();
// Wait for the thread (it does NOT change thread state, and can be called from multiple threads)
void join() const;
// Notify the thread
void notify();
};
// Collection of global function for current thread
class thread_ctrl final
{
// Current thread
static thread_local thread_base* g_tls_this_thread;
// Target cpu core layout
static atomic_t<native_core_arrangement> g_native_core_layout;
// Internal waiting function, may throw. Infinite value is -1.
static bool _wait_for(u64 usec);
// Internal throwing function. Mutex must be locked and will be unlocked.
[[noreturn]] void _throw();
// Internal notification function
void _notify(cond_variable thread_ctrl::*);
friend class thread_base;
public:
thread_ctrl(std::string&& name);
thread_ctrl(const thread_ctrl&) = delete;
~thread_ctrl();
// Get thread name
const std::string& get_name() const
// Get current thread name
static std::string_view get_name()
{
return m_name;
return g_tls_this_thread->m_name.get();
}
// Get exception
std::exception_ptr get_exception() const;
// Get thread name
template <typename T>
static std::string_view get_name(const named_thread<T>& thread)
{
return static_cast<const thread_base&>(thread).m_name.get();
}
// Set exception
void set_exception(std::exception_ptr ptr);
// Set current thread name (not recommended)
static void set_name(std::string_view name)
{
g_tls_this_thread->m_name.assign(name);
}
// Get thread result (may throw, simultaneous joining allowed)
void join();
// Set thread name (not recommended)
template <typename T>
static void set_name(named_thread<T>& thread, std::string_view name)
{
static_cast<thread_base&>(thread).m_name.assign(name);
}
// Notify the thread
void notify();
template <typename T>
static u64 get_cycles(named_thread<T>& thread)
{
return static_cast<thread_base&>(thread).get_cycles();
}
// Wait once with timeout. Abortable, may throw. May spuriously return false.
template <typename T>
static void notify(named_thread<T>& thread)
{
static_cast<thread_base&>(thread).notify();
}
// Read current state
static inline thread_state state()
{
return g_tls_this_thread->m_state;
}
// Wait once with timeout. May spuriously return false.
static inline bool wait_for(u64 usec)
{
return _wait_for(usec);
}
// Wait. Abortable, may throw.
// Wait.
static inline void wait()
{
_wait_for(-1);
}
// Wait until pred(). Abortable, may throw.
template<typename F, typename RT = std::result_of_t<F()>>
// Wait until pred().
template <typename F, typename RT = std::invoke_result_t<F>>
static inline RT wait(F&& pred)
{
while (true)
@@ -211,49 +248,12 @@ public:
}
}
// Wait eternally until aborted.
[[noreturn]] static inline void eternalize()
{
while (true)
{
_wait_for(-1);
}
}
// Test exception (may throw).
static void test();
// Get current thread (may be nullptr)
static thread_ctrl* get_current()
static thread_base* get_current()
{
return g_tls_this_thread;
}
// Register function at thread exit (for the current thread)
template<typename F>
static inline void atexit(F&& func)
{
_push(std::forward<F>(func));
}
// Create detached named thread
template<typename N, typename F>
static inline void spawn(N&& name, F&& func)
{
auto out = std::make_shared<thread_ctrl>(std::forward<N>(name));
thread_ctrl::start(out, std::forward<F>(func));
}
// Named thread factory
template<typename N, typename F>
static inline void spawn(std::shared_ptr<thread_ctrl>& out, N&& name, F&& func)
{
out = std::make_shared<thread_ctrl>(std::forward<N>(name));
thread_ctrl::start(out, std::forward<F>(func));
}
// Detect layout
static void detect_cpu_layout();
@@ -265,91 +265,166 @@ public:
// Sets the preferred affinity mask for this thread
static void set_thread_affinity_mask(u16 mask);
// Spawn a detached named thread
template <typename F>
static void spawn(std::string_view name, F&& func)
{
new named_thread<F>(thread_state::detached, name, std::forward<F>(func));
}
};
class named_thread
// Derived from the callable object Context, possibly a lambda
template <class Context>
class named_thread final : public Context, result_storage_t<Context>, thread_base
{
// Pointer to managed resource (shared with actual thread)
std::shared_ptr<thread_ctrl> m_thread;
using result = result_storage_t<Context>;
using thread = thread_base;
// Type-erased thread entry point
#ifdef _WIN32
static inline uint __stdcall entry_point(void* arg) try
#else
static inline void* entry_point(void* arg) try
#endif
{
const auto _this = static_cast<named_thread*>(static_cast<thread*>(arg));
// Perform self-cleanup if necessary
if (_this->entry_point())
{
// Call on_cleanup() static member function if it's available
if constexpr (thread_on_cleanup<Context>())
{
Context::on_cleanup(_this);
}
else
{
delete _this;
}
}
thread::finalize();
return 0;
}
catch (...)
{
catch_all_exceptions();
}
bool entry_point()
{
thread::initialize();
if constexpr (result::empty)
{
// No result
Context::operator()();
}
else
{
// Construct the result using placement new (copy elision should happen)
new (result::get()) typename result::type(Context::operator()());
}
return thread::finalize(0);
}
// Detached thread constructor
named_thread(thread_state s, std::string_view name, Context&& f)
: Context(std::forward<Context>(f))
, thread(name)
{
thread::m_state.raw() = s;
thread::start(&named_thread::entry_point);
}
friend class thread_ctrl;
public:
named_thread();
// Normal forwarding constructor
template <typename... Args, typename = std::enable_if_t<std::is_constructible_v<Context, Args&&...>>>
named_thread(std::string_view name, Args&&... args)
: Context(std::forward<Args>(args)...)
, thread(name)
{
thread::start(&named_thread::entry_point);
}
virtual ~named_thread();
// Lambda constructor, also the implicit deduction guide candidate
named_thread(std::string_view name, Context&& f)
: Context(std::forward<Context>(f))
, thread(name)
{
thread::start(&named_thread::entry_point);
}
// Deleted copy/move constructors + copy/move operators
named_thread(const named_thread&) = delete;
// Get thread name
virtual std::string get_name() const;
named_thread& operator=(const named_thread&) = delete;
protected:
// Start thread (cannot be called from the constructor: should throw in such case)
void start_thread(const std::shared_ptr<void>& _this);
// Thread task (called in the thread)
virtual void on_task() = 0;
// Thread finalization (called after on_task)
virtual void on_exit() {}
// Called once upon thread spawn within the thread's own context
virtual void on_spawn() {}
public:
// ID initialization
virtual void on_init(const std::shared_ptr<void>& _this)
// Wait for the completion and access result (if not void)
[[nodiscard]] decltype(auto) operator()()
{
return start_thread(_this);
thread::join();
if constexpr (!result::empty)
{
return *result::get();
}
}
// ID finalization
virtual void on_stop()
// Wait for the completion and access result (if not void)
[[nodiscard]] decltype(auto) operator()() const
{
m_thread->join();
thread::join();
if constexpr (!result::empty)
{
return *result::get();
}
}
// Access thread_ctrl
thread_ctrl* get() const
// Access thread state
operator thread_state() const
{
return m_thread.get();
return thread::m_state.load();
}
void join() const
// Try to abort/detach
named_thread& operator=(thread_state s)
{
return m_thread->join();
if (s != thread_state::aborting && s != thread_state::detached)
{
ASSUME(0);
}
if (thread::m_state.compare_and_swap_test(thread_state::created, s))
{
if (s == thread_state::aborting)
{
// Call on_abort() method if it's available
if constexpr (thread_on_abort<Context>())
{
Context::on_abort();
}
}
thread::notify();
}
return *this;
}
void notify() const
// Context type doesn't need virtual destructor
~named_thread()
{
return m_thread->notify();
}
};
// Wrapper for named thread, joins automatically in the destructor, can only be used in function scope
class scope_thread final
{
std::shared_ptr<thread_ctrl> m_thread;
public:
template<typename N, typename F>
scope_thread(N&& name, F&& func)
{
thread_ctrl::spawn(m_thread, std::forward<N>(name), std::forward<F>(func));
}
// Deleted copy/move constructors + copy/move operators
scope_thread(const scope_thread&) = delete;
// Destructor with exceptions allowed
~scope_thread() noexcept(false)
{
m_thread->join();
}
// Access thread_ctrl
thread_ctrl* get() const
{
return m_thread.get();
*this = thread_state::aborting;
thread::join();
if constexpr (!result::empty)
{
result::destroy();
}
}
};
+7
View File
@@ -49,4 +49,11 @@ public:
return std::chrono::duration_cast<std::chrono::nanoseconds>(now - m_start).count();
}
u64 GetMsSince(std::chrono::steady_clock::time_point timestamp)
{
std::chrono::steady_clock::time_point now = m_stopped ? m_end : std::chrono::steady_clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(now - timestamp).count();
}
};
+194 -4
View File
@@ -7,10 +7,27 @@
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#endif
#ifdef __linux__
#include <sys/syscall.h>
#ifdef __NR_memfd_create
#elif __x86_64__
#define __NR_memfd_create 319
#elif __aarch64__
#define __NR_memfd_create 279
#endif
static int memfd_create_(const char *name, uint flags)
{
return syscall(__NR_memfd_create, name, flags);
}
#endif
namespace utils
{
// Convert memory protection (internal)
@@ -63,7 +80,7 @@ namespace utils
#ifdef _WIN32
verify(HERE), ::VirtualAlloc(pointer, size, MEM_COMMIT, +prot);
#else
verify(HERE), ::mprotect((void*)((u64)pointer & -4096), ::align(size, 4096), +prot) != -1;
verify(HERE), ::mprotect((void*)((u64)pointer & -4096), size + ((u64)pointer & 4095), +prot) != -1;
#endif
}
@@ -76,13 +93,186 @@ namespace utils
#endif
}
void memory_reset(void* pointer, std::size_t size, protection prot)
{
#ifdef _WIN32
memory_decommit(pointer, size);
memory_commit(pointer, size, prot);
#else
verify(HERE), ::mmap(pointer, size, +prot, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
#endif
}
void memory_release(void* pointer, std::size_t size)
{
#ifdef _WIN32
verify(HERE), ::VirtualFree(pointer, 0, MEM_RELEASE);
#else
verify(HERE), ::munmap(pointer, size) != -1;
#endif
}
void memory_protect(void* pointer, std::size_t size, protection prot)
{
#ifdef _WIN32
DWORD old;
verify(HERE), ::VirtualProtect(pointer, size, +prot, &old);
for (u64 addr = (u64)pointer, end = addr + size; addr < end;)
{
const u64 boundary = (addr + 0x10000) & -0x10000;
const u64 block_size = std::min(boundary, end) - addr;
DWORD old;
if (!::VirtualProtect((LPVOID)addr, block_size, +prot, &old))
{
fmt::throw_exception("VirtualProtect failed (%p, 0x%x, addr=0x%x, error=%#x)", pointer, size, addr, GetLastError());
}
// Next region
addr += block_size;
}
#else
verify(HERE), ::mprotect((void*)((u64)pointer & -4096), ::align(size, 4096), +prot) != -1;
verify(HERE), ::mprotect((void*)((u64)pointer & -4096), size + ((u64)pointer & 4095), +prot) != -1;
#endif
}
shm::shm(u32 size)
: m_size(::align(size, 0x10000))
{
#ifdef _WIN32
m_handle = ::CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_EXECUTE_READWRITE, 0, m_size, NULL);
verify(HERE), m_handle != INVALID_HANDLE_VALUE;
#elif __linux__
m_file = ::memfd_create_("", 0);
verify(HERE), m_file >= 0;
verify(HERE), ::ftruncate(m_file, m_size) >= 0;
#else
while ((m_file = ::shm_open("/rpcs3-mem1", O_RDWR | O_CREAT | O_EXCL, S_IWUSR | S_IRUSR)) == -1)
{
if (m_file == -1 && errno == EMFILE)
{
fmt::throw_exception("Too many open files. Raise the limit and try again.");
}
verify(HERE), errno == EEXIST;
}
verify(HERE), ::shm_unlink("/rpcs3-mem1") >= 0;
verify(HERE), ::ftruncate(m_file, m_size) >= 0;
#endif
}
shm::~shm()
{
#ifdef _WIN32
::CloseHandle(m_handle);
#else
::close(m_file);
#endif
}
u8* shm::map(void* ptr, protection prot) const
{
#ifdef _WIN32
DWORD access = FILE_MAP_WRITE;
switch (prot)
{
case protection::rw:
case protection::ro:
case protection::no:
break;
case protection::wx:
case protection::rx:
access |= FILE_MAP_EXECUTE;
break;
}
if (auto ret = static_cast<u8*>(::MapViewOfFileEx(m_handle, access, 0, 0, m_size, ptr)))
{
if (prot != protection::rw && prot != protection::wx)
{
DWORD old;
if (!::VirtualProtect(ret, m_size, +prot, &old))
{
::UnmapViewOfFile(ret);
return nullptr;
}
}
return ret;
}
return nullptr;
#else
return static_cast<u8*>(::mmap((void*)((u64)ptr & -0x10000), m_size, +prot, MAP_SHARED | (ptr ? MAP_FIXED : 0), m_file, 0));
#endif
}
u8* shm::map_critical(void* ptr, protection prot)
{
const auto target = (u8*)((u64)ptr & -0x10000);
#ifdef _WIN32
::MEMORY_BASIC_INFORMATION mem;
if (!::VirtualQuery(target, &mem, sizeof(mem)) || mem.State != MEM_RESERVE || !::VirtualFree(mem.AllocationBase, 0, MEM_RELEASE))
{
return nullptr;
}
const auto base = (u8*)mem.AllocationBase;
const auto size = mem.RegionSize + (target - base);
if (base < target && !::VirtualAlloc(base, target - base, MEM_RESERVE, PAGE_NOACCESS))
{
return nullptr;
}
if (target + m_size < base + size && !::VirtualAlloc(target + m_size, base + size - target - m_size, MEM_RESERVE, PAGE_NOACCESS))
{
return nullptr;
}
#endif
return this->map(target, prot);
}
void shm::unmap(void* ptr) const
{
#ifdef _WIN32
::UnmapViewOfFile(ptr);
#else
::munmap(ptr, m_size);
#endif
}
void shm::unmap_critical(void* ptr)
{
const auto target = (u8*)((u64)ptr & -0x10000);
this->unmap(target);
#ifdef _WIN32
::MEMORY_BASIC_INFORMATION mem, mem2;
if (!::VirtualQuery(target - 1, &mem, sizeof(mem)) || !::VirtualQuery(target + m_size, &mem2, sizeof(mem2)))
{
return;
}
if (mem.State == MEM_RESERVE && !::VirtualFree(mem.AllocationBase, 0, MEM_RELEASE))
{
return;
}
if (mem2.State == MEM_RESERVE && !::VirtualFree(mem2.AllocationBase, 0, MEM_RELEASE))
{
return;
}
const auto size1 = mem.State == MEM_RESERVE ? target - (u8*)mem.AllocationBase : 0;
const auto size2 = mem2.State == MEM_RESERVE ? mem2.RegionSize : 0;
if (!::VirtualAlloc(mem.State == MEM_RESERVE ? mem.AllocationBase : target, m_size + size1 + size2, MEM_RESERVE, PAGE_NOACCESS))
{
return;
}
#endif
}
}
+44 -3
View File
@@ -25,11 +25,52 @@ namespace utils
*/
void memory_commit(void* pointer, std::size_t size, protection prot = protection::rw);
/**
* Decommit all memory committed via commit_page_memory.
*/
// Decommit all memory committed via commit_page_memory.
void memory_decommit(void* pointer, std::size_t size);
// Decommit all memory and commit it again.
void memory_reset(void* pointer, std::size_t size, protection prot = protection::rw);
// Free memory after reserved by memory_reserve, should specify original size
void memory_release(void* pointer, std::size_t size);
// Set memory protection
void memory_protect(void* pointer, std::size_t size, protection prot);
// Shared memory handle
class shm
{
#ifdef _WIN32
void* m_handle;
#else
int m_file;
#endif
u32 m_size;
public:
explicit shm(u32 size);
shm(const shm&) = delete;
shm& operator=(const shm&) = delete;
~shm();
// Map shared memory
u8* map(void* ptr, protection prot = protection::rw) const;
// Map shared memory over reserved memory region, which is unsafe (non-atomic) under Win32
u8* map_critical(void* ptr, protection prot = protection::rw);
// Unmap shared memory
void unmap(void* ptr) const;
// Unmap shared memory, undoing map_critical
void unmap_critical(void* ptr);
u32 size() const
{
return m_size;
}
};
}
+590
View File
@@ -0,0 +1,590 @@
#include "types.h"
#include "StrFmt.h"
#include <vector>
namespace utils
{
class address_range_vector;
/**
* Constexprs
*/
constexpr inline u32 page_start(u32 addr)
{
return addr & ~4095u;
}
constexpr inline u32 next_page(u32 addr)
{
return page_start(addr + 4096u);
}
constexpr inline u32 page_end(u32 addr)
{
return next_page(addr) - 1;
}
constexpr inline u32 is_page_aligned(u32 addr)
{
return page_start(addr) == addr;
}
/**
* Address Range utility class
*/
class address_range
{
public:
u32 start = UINT32_MAX; // First address in range
u32 end = 0; // Last address
private:
// Helper constexprs
static constexpr inline bool range_overlaps(u32 start1, u32 end1, u32 start2, u32 end2)
{
return (start1 <= end2 && start2 <= end1);
}
static constexpr inline bool address_overlaps(u32 address, u32 start, u32 end)
{
return (start <= address && address <= end);
}
static constexpr inline bool range_inside_range(u32 start1, u32 end1, u32 start2, u32 end2)
{
return (start1 >= start2 && end1 <= end2);
}
address_range(u32 _start, u32 _end) : start(_start), end(_end) {};
public:
// Constructors
address_range() = default;
address_range(const address_range &other) : start(other.start), end(other.end) {};
static inline address_range start_length(u32 _start, u32 _length)
{
return address_range(_start, _start + (_length - 1));
}
static inline address_range start_end(u32 _start, u32 _end)
{
return address_range(_start, _end);
}
// Length
u32 length() const
{
AUDIT(valid());
return end - start + 1;
}
void set_length(const u32 new_length)
{
end = start + new_length - 1;
ASSERT(valid());
}
u32 next_address() const
{
return end + 1;
}
u32 prev_address() const
{
return start - 1;
}
// Overlapping checks
bool overlaps(const address_range &other) const
{
AUDIT(valid() && other.valid());
return range_overlaps(start, end, other.start, other.end);
}
bool overlaps(const u32 addr) const
{
AUDIT(valid());
return address_overlaps(addr, start, end);
}
bool inside(const address_range &other) const
{
AUDIT(valid() && other.valid());
return range_inside_range(start, end, other.start, other.end);
}
inline bool inside(const address_range_vector &vec) const;
inline bool overlaps(const address_range_vector &vec) const;
bool touches(const address_range &other) const
{
AUDIT(valid() && other.valid());
// returns true if there is overlap, or if sections are side-by-side
return overlaps(other) || other.start == next_address() || other.end == prev_address();
}
// Utilities
s32 signed_distance(const address_range &other) const
{
if (touches(other))
{
return 0;
}
// other after this
if (other.start > end)
{
return (s32)(other.start - end - 1);
}
// this after other
AUDIT(start > other.end);
return -((s32)(start - other.end - 1));
}
u32 distance(const address_range &other) const
{
if (touches(other))
{
return 0;
}
// other after this
if (other.start > end)
{
return (other.start - end - 1);
}
// this after other
AUDIT(start > other.end);
return (start - other.end - 1);
}
address_range get_min_max(const address_range &other) const
{
return {
std::min(valid() ? start : UINT32_MAX, other.valid() ? other.start : UINT32_MAX),
std::max(valid() ? end : 0, other.valid() ? other.end : 0)
};
}
void set_min_max(const address_range &other)
{
const address_range _range = get_min_max(other);
start = _range.start;
end = _range.end;
}
bool is_page_range() const
{
return (valid() && start % 4096u == 0 && length() % 4096u == 0);
}
address_range to_page_range() const
{
AUDIT(valid());
return { page_start(start), page_end(end) };
}
void page_align()
{
AUDIT(valid());
start = page_start(start);
end = page_end(end);
AUDIT(is_page_range());
}
address_range get_intersect(const address_range &clamp) const
{
if (!valid() || !clamp.valid())
{
return {};
}
return { std::max(start, clamp.start), std::min(end, clamp.end) };
}
void intersect(const address_range &clamp)
{
if (!clamp.valid())
{
invalidate();
}
else
{
start = std::max(start, clamp.start);
end = std::min(end, clamp.end);
}
}
// Validity
bool valid() const
{
return (start <= end);
}
void invalidate()
{
start = UINT32_MAX;
end = 0;
}
// Comparison Operators
bool operator ==(const address_range &other) const
{
return (start == other.start && end == other.end);
}
bool operator !=(const address_range &other) const
{
return (start != other.start || end != other.end);
}
/**
* Debug
*/
std::string str() const
{
return fmt::format("{0x%x->0x%x}", start, end);
}
};
static inline address_range page_for(u32 addr)
{
return address_range::start_end(page_start(addr), page_end(addr));
}
/**
* Address Range Vector utility class
*
* Collection of address_range objects. Allows for merging and removing ranges from the set.
*/
class address_range_vector
{
public:
using vector_type = typename std::vector<address_range>;
using iterator = typename vector_type::iterator;
using const_iterator = typename vector_type::const_iterator;
using size_type = typename vector_type::size_type;
private:
vector_type data;
public:
// Wrapped functions
inline void reserve(size_t nr) { data.reserve(nr); }
inline void clear() { data.clear(); }
inline size_type size() const { return data.size(); }
inline bool empty() const { return data.empty(); }
inline address_range& operator[](size_type n) { return data[n]; }
inline const address_range& operator[](size_type n) const { return data[n]; }
inline iterator begin() { return data.begin(); }
inline const_iterator begin() const { return data.begin(); }
inline iterator end() { return data.end(); }
inline const_iterator end() const { return data.end(); }
// Search for ranges that touch new_range. If found, merge instead of adding new_range.
// When adding a new range, re-use invalid ranges whenever possible
void merge(const address_range &new_range)
{
// Note the case where we have
// AAAA BBBB
// CCCC
// If we have data={A,B}, and new_range=C, we have to merge A with C, then B with A and invalidate B
if (!new_range.valid())
{
return;
}
address_range *found = nullptr;
address_range *invalid = nullptr;
for (auto &existing : data)
{
if (!existing.valid())
{
invalid = &existing;
continue;
}
// range1 overlaps, is immediately before, or is immediately after range2
if (existing.touches(new_range))
{
if (found != nullptr)
{
// Already found a match, merge and invalidate "existing"
found->set_min_max(existing);
existing.invalidate();
}
else
{
// First match, merge "new_range"
existing.set_min_max(new_range);
found = &existing;
}
}
}
if (found != nullptr)
{
return;
}
if (invalid != nullptr)
{
*invalid = new_range;
}
else
{
data.push_back(new_range);
}
AUDIT(check_consistency());
}
void merge(const address_range_vector &other)
{
for (const address_range &new_range : other)
{
merge(new_range);
}
}
// Exclude a given range from data
void exclude(const address_range &exclusion)
{
// Note the case where we have
// AAAAAAA
// EEE
// where data={A} and exclusion=E.
// In this case, we need to reduce A to the head (before E starts), and then create a new address_range B for the tail (after E ends), i.e.
// AA BB
// EEE
if (!exclusion.valid())
{
return;
}
address_range *invalid = nullptr; // try to re-use an invalid range instead of calling push_back
// We use index access because we might have to push_back within the loop, which could invalidate the iterators
size_type _size = data.size();
for (int n = 0; n < _size; ++n)
{
address_range &existing = data[n];
if (!existing.valid())
{
// Null
invalid = &existing;
continue;
}
if (!existing.overlaps(exclusion))
{
// No overlap, skip
continue;
}
const bool head_excluded = exclusion.overlaps(existing.start); // This section has its start inside excluded range
const bool tail_excluded = exclusion.overlaps(existing.end); // This section has its end inside excluded range
if (head_excluded && tail_excluded)
{
// Cannot be salvaged, fully excluded
existing.invalidate();
invalid = &existing;
}
else if (head_excluded)
{
// Head overlaps, truncate head
existing.start = exclusion.next_address();
}
else if (tail_excluded)
{
// Tail overlaps, truncate tail
existing.end = exclusion.prev_address();
}
else
{
// Section sits in the middle (see comment above function header)
AUDIT(exclusion.inside(existing));
const auto tail_end = existing.end;
// Head
existing.end = exclusion.prev_address();
// Tail
if (invalid != nullptr)
{
invalid->start = exclusion.next_address();
invalid->end = tail_end;
invalid = nullptr;
}
else
{
// IMPORTANT: adding to data invalidates "existing". This must be done last!
data.push_back(address_range::start_end(exclusion.next_address(), tail_end));
}
}
}
AUDIT(check_consistency());
AUDIT(!overlaps(exclusion));
}
void exclude(const address_range_vector &other)
{
for (const address_range &exclusion : other)
{
exclude(exclusion);
}
}
// Checks the consistency of this vector.
// Will fail if ranges within the vector overlap our touch each-other
bool check_consistency() const
{
size_t _size = data.size();
for (int i = 0; i < _size; ++i)
{
const auto &r1 = data[i];
if (!r1.valid())
{
continue;
}
for (int j = i + 1; j < _size; ++j)
{
const auto &r2 = data[j];
if (!r2.valid())
{
continue;
}
if (r1.touches(r2))
{
return false;
}
}
}
return true;
}
// Test for overlap with a given range
bool overlaps(const address_range &range) const
{
for (const address_range &current : data)
{
if (!current.valid())
{
continue;
}
if (current.overlaps(range))
{
return true;
}
}
return false;
}
// Test for overlap with a given address_range vector
bool overlaps(const address_range_vector &other) const
{
for (const address_range &rng1 : data)
{
if (!rng1.valid())
{
continue;
}
for (const address_range &rng2 : other.data)
{
if (!rng2.valid())
{
continue;
}
if (rng1.overlaps(rng2))
{
return true;
}
}
}
return false;
}
// Test if a given range is fully contained inside this vector
bool contains(const address_range &range) const
{
for (const address_range &cur : *this)
{
if (!cur.valid())
{
continue;
}
if (range.inside(cur))
{
return true;
}
}
return false;
}
// Test if all ranges in this vector are full contained inside a specific range
bool inside(const address_range &range) const
{
for (const address_range &cur : *this)
{
if (!cur.valid())
{
continue;
}
if (!cur.inside(range))
{
return false;
}
}
return true;
}
};
// These declarations must be done after address_range_vector has been defined
bool address_range::inside(const address_range_vector &vec) const
{
return vec.contains(*this);
}
bool address_range::overlaps(const address_range_vector &vec) const
{
return vec.overlaps(*this);
}
}; // namespace utils
namespace std {
static_assert(sizeof(size_t) >= 2 * sizeof(u32), "size_t must be at least twice the size of u32");
template <>
struct hash<utils::address_range>
{
std::size_t operator()(const utils::address_range& k) const
{
// we can guarantee a unique hash since our type is 64 bits and size_t as well
return (size_t{ k.start } << 32) | size_t{ k.end };
}
};
};
+185
View File
@@ -0,0 +1,185 @@
#pragma once
#include "types.h"
namespace utils
{
inline u32 cntlz32(u32 arg, bool nonzero = false)
{
#ifdef _MSC_VER
ulong res;
return _BitScanReverse(&res, arg) || nonzero ? res ^ 31 : 32;
#else
return arg || nonzero ? __builtin_clz(arg) : 32;
#endif
}
inline u64 cntlz64(u64 arg, bool nonzero = false)
{
#ifdef _MSC_VER
ulong res;
return _BitScanReverse64(&res, arg) || nonzero ? res ^ 63 : 64;
#else
return arg || nonzero ? __builtin_clzll(arg) : 64;
#endif
}
inline u32 cnttz32(u32 arg, bool nonzero = false)
{
#ifdef _MSC_VER
ulong res;
return _BitScanForward(&res, arg) || nonzero ? res : 32;
#else
return arg || nonzero ? __builtin_ctz(arg) : 32;
#endif
}
inline u64 cnttz64(u64 arg, bool nonzero = false)
{
#ifdef _MSC_VER
ulong res;
return _BitScanForward64(&res, arg) || nonzero ? res : 64;
#else
return arg || nonzero ? __builtin_ctzll(arg) : 64;
#endif
}
inline u8 popcnt16(u16 arg)
{
const u32 a1 = arg & 0x5555;
const u32 a2 = (arg >> 1) & 0x5555;
const u32 a3 = a1 + a2;
const u32 b1 = a3 & 0x3333;
const u32 b2 = (a3 >> 2) & 0x3333;
const u32 b3 = b1 + b2;
const u32 c1 = b3 & 0x0f0f;
const u32 c2 = (b3 >> 4) & 0x0f0f;
const u32 c3 = c1 + c2;
return static_cast<u8>(c3 + (c3 >> 8));
}
// Rotate helpers
#if defined(__GNUG__)
inline u8 rol8(u8 x, u8 n)
{
u8 result = x;
__asm__("rolb %[n], %[result]" : [result] "+g"(result) : [n] "c"(n));
return result;
}
inline u8 ror8(u8 x, u8 n)
{
u8 result = x;
__asm__("rorb %[n], %[result]" : [result] "+g"(result) : [n] "c"(n));
return result;
}
inline u16 rol16(u16 x, u16 n)
{
u16 result = x;
__asm__("rolw %b[n], %[result]" : [result] "+g"(result) : [n] "c"(n));
return result;
}
inline u16 ror16(u16 x, u16 n)
{
u16 result = x;
__asm__("rorw %b[n], %[result]" : [result] "+g"(result) : [n] "c"(n));
return result;
}
inline u32 rol32(u32 x, u32 n)
{
u32 result = x;
__asm__("roll %b[n], %[result]" : [result] "+g"(result) : [n] "c"(n));
return result;
}
inline u32 ror32(u32 x, u32 n)
{
u32 result = x;
__asm__("rorl %b[n], %[result]" : [result] "+g"(result) : [n] "c"(n));
return result;
}
inline u64 rol64(u64 x, u64 n)
{
u64 result = x;
__asm__("rolq %b[n], %[result]" : [result] "+g"(result) : [n] "c"(n));
return result;
}
inline u64 ror64(u64 x, u64 n)
{
u64 result = x;
__asm__("rorq %b[n], %[result]" : [result] "+g"(result) : [n] "c"(n));
return result;
}
inline u64 umulh64(u64 a, u64 b)
{
u64 result;
__asm__("mulq %[b]" : "=d"(result) : [a] "a"(a), [b] "rm"(b));
return result;
}
inline s64 mulh64(s64 a, s64 b)
{
s64 result;
__asm__("imulq %[b]" : "=d"(result) : [a] "a"(a), [b] "rm"(b));
return result;
}
#elif defined(_MSC_VER)
inline u8 rol8(u8 x, u8 n)
{
return _rotl8(x, n);
}
inline u8 ror8(u8 x, u8 n)
{
return _rotr8(x, n);
}
inline u16 rol16(u16 x, u16 n)
{
return _rotl16(x, (u8)n);
}
inline u16 ror16(u16 x, u16 n)
{
return _rotr16(x, (u8)n);
}
inline u32 rol32(u32 x, u32 n)
{
return _rotl(x, (int)n);
}
inline u32 ror32(u32 x, u32 n)
{
return _rotr(x, (int)n);
}
inline u64 rol64(u64 x, u64 n)
{
return _rotl64(x, (int)n);
}
inline u64 ror64(u64 x, u64 n)
{
return _rotr64(x, (int)n);
}
inline u64 umulh64(u64 x, u64 y)
{
return __umulh(x, y);
}
inline s64 mulh64(s64 x, s64 y)
{
return __mulh(x, y);
}
#endif
} // namespace utils
+1 -1
View File
@@ -1,5 +1,5 @@
#include "bin_patch.h"
#include "yaml-cpp/yaml.h"
#include <yaml-cpp/yaml.h>
#include "File.h"
#include "Config.h"
+284 -603
View File
File diff suppressed because it is too large Load Diff
+8 -7
View File
@@ -1,6 +1,7 @@
#pragma once
#include "types.h"
#include "asm.h"
#include <climits>
#include <string>
#include <vector>
@@ -56,7 +57,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
const auto write_octal = [&](u64 value, u64 min_num)
{
out.resize(out.size() + std::max<u64>(min_num, 66 / 3 - (cntlz64(value | 1, true) + 2) / 3), '0');
out.resize(out.size() + std::max<u64>(min_num, 66 / 3 - (utils::cntlz64(value | 1, true) + 2) / 3), '0');
// Write in reversed order
for (auto i = out.rbegin(); value; i++, value /= 8)
@@ -67,8 +68,8 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
const auto write_hex = [&](u64 value, bool upper, u64 min_num)
{
out.resize(out.size() + std::max<u64>(min_num, 64 / 4 - cntlz64(value | 1, true) / 4), '0');
out.resize(out.size() + std::max<u64>(min_num, 64 / 4 - utils::cntlz64(value | 1, true) / 4), '0');
// Write in reversed order
for (auto i = out.rbegin(); value; i++, value /= 16)
{
@@ -141,7 +142,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
{
ctx.width = read_decimal(ch - '0');
}
break;
}
@@ -157,7 +158,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
ctx.width = std::abs(warg);
ctx.left |= warg < 0;
}
break;
}
@@ -307,7 +308,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
const std::size_t start = out.size();
const std::size_t size1 = src.fmt_string(out, ctx.args);
if (ctx.dot && size1 > ctx.prec)
{
// Shrink if necessary
@@ -576,7 +577,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
// Add padding if necessary
out.insert(ctx.left ? out.end() : out.begin() + start, ctx.width - size2, ' ');
}
src.skip(ctx.args);
ctx = {0};
break;
+265 -78
View File
@@ -1,5 +1,6 @@
#include "cond.h"
#include "sync.h"
#include "lockless.h"
#include <limits.h>
@@ -9,100 +10,286 @@
bool cond_variable::imp_wait(u32 _old, u64 _timeout) noexcept
{
verify(HERE), _old != -1; // Very unlikely: it requires 2^32 distinct threads to wait simultaneously
const bool is_inf = _timeout > max_timeout;
verify("cond_variable overflow" HERE), (_old & 0xffff) != 0xffff; // Very unlikely: it requires 65535 distinct threads to wait simultaneously
return balanced_wait_until(m_value, _timeout, [&](u32& value, auto... ret) -> int
{
if (value >> 16)
{
// Success
value -= 0x10001;
return +1;
}
if constexpr (sizeof...(ret))
{
// Retire
value -= 1;
return -1;
}
return 0;
});
#ifdef _WIN32
LARGE_INTEGER timeout;
timeout.QuadPart = _timeout * -10;
if (HRESULT rc = NtWaitForKeyedEvent(nullptr, &m_value, false, is_inf ? nullptr : &timeout))
if (_old >= 0x10000 && !OptWaitOnAddress && m_value)
{
verify(HERE), rc == WAIT_TIMEOUT;
// Retire
if (!m_value.fetch_op([](u32& value) { if (value) value--; }))
{
NtWaitForKeyedEvent(nullptr, &m_value, false, nullptr);
return true;
}
return false;
}
return true;
#else
timespec timeout;
timeout.tv_sec = _timeout / 1000000;
timeout.tv_nsec = (_timeout % 1000000) * 1000;
for (u32 value = _old + 1;; value = m_value)
{
const int err = futex((int*)&m_value.raw(), FUTEX_WAIT_PRIVATE, value, is_inf ? nullptr : &timeout, nullptr, 0) == 0
? 0
: errno;
// Normal or timeout wakeup
if (!err || (!is_inf && err == ETIMEDOUT))
{
// Cleanup (remove waiter)
verify(HERE), m_value--;
return !err;
}
// Not a wakeup
verify(HERE), err == EAGAIN;
// Workaround possibly stolen signal
imp_wake(1);
}
#endif
}
void cond_variable::imp_wake(u32 _count) noexcept
{
#ifdef _WIN32
// Try to subtract required amount of waiters
const u32 count = m_value.atomic_op([=](u32& value)
// TODO (notify_one)
balanced_awaken<true>(m_value, m_value.atomic_op([&](u32& value) -> u32
{
if (value > _count)
// Subtract already signaled number from total amount of waiters
const u32 can_sig = (value & 0xffff) - (value >> 16);
const u32 num_sig = std::min<u32>(can_sig, _count);
value += num_sig << 16;
return num_sig;
}));
}
bool notifier::imp_try_lock(u32 count)
{
return m_counter.atomic_op([&](u32& value)
{
if ((value % (max_readers + 1)) + count <= max_readers)
{
value -= _count;
return _count;
value += count;
return true;
}
return std::exchange(value, 0);
return false;
});
}
void notifier::imp_unlock(u32 count)
{
const u32 counter = m_counter.sub_fetch(count);
if (UNLIKELY(counter % (max_readers + 1)))
{
return;
}
if (counter)
{
const u32 _old = m_counter.atomic_op([](u32& value) -> u32
{
if (value % (max_readers + 1))
{
return 0;
}
return std::exchange(value, 0) / (max_readers + 1);
});
const u32 wc = m_cond.m_value;
if (_old && wc)
{
m_cond.imp_wake(_old > wc ? wc : _old);
}
}
}
u32 notifier::imp_notify(u32 count)
{
return m_counter.atomic_op([&](u32& value) -> u32
{
if (const u32 add = value % (max_readers + 1))
{
// Mutex is locked
const u32 result = add > count ? count : add;
value += result * (max_readers + 1);
return result;
}
else
{
// Mutex is unlocked
value = 0;
return count;
}
});
}
bool notifier::wait(u64 usec_timeout)
{
const u32 _old = m_cond.m_value.fetch_add(1);
if (max_readers < m_counter.fetch_op([](u32& value)
{
if (value > max_readers)
{
value -= max_readers;
}
value -= 1;
}))
{
// Return without waiting
m_cond.imp_wait(_old, 0);
return true;
}
const bool res = m_cond.imp_wait(_old, usec_timeout);
while (!try_lock_shared())
{
// TODO
busy_wait();
}
return res;
}
bool cond_one::imp_wait(u64 _timeout) noexcept
{
// State transition: c_sig -> c_lock \ c_lock -> c_wait
const u32 _old = m_value.fetch_sub(1);
if (LIKELY(_old == c_sig))
return true;
return balanced_wait_until(m_value, _timeout, [&](u32& value, auto... ret) -> int
{
if (value == c_sig)
{
value = c_lock;
return +1;
}
if constexpr (sizeof...(ret))
{
value = c_lock;
return -1;
}
return 0;
});
}
void cond_one::imp_notify() noexcept
{
auto [old, ok] = m_value.fetch_op([](u32& v)
{
if (UNLIKELY(v > 0 && v < c_sig))
{
v = c_sig;
return true;
}
return false;
});
for (u32 i = count; i > 0; i--)
verify(HERE), old <= c_sig;
if (LIKELY(!ok || old == c_lock))
{
NtReleaseKeyedEvent(nullptr, &m_value, false, nullptr);
return;
}
#else
for (u32 i = _count; i > 0; std::this_thread::yield())
{
const u32 value = m_value;
// Constrain remaining amount with imaginary waiter count
if (i > value)
{
i = value;
}
if (!value || i == 0)
{
// Nothing to do
return;
}
if (const int res = futex((int*)&m_value.raw(), FUTEX_WAKE_PRIVATE, i > INT_MAX ? INT_MAX : i, nullptr, nullptr, 0))
{
verify(HERE), res >= 0 && (u32)res <= i;
i -= res;
}
if (!m_value || i == 0)
{
// Escape
return;
}
}
#endif
balanced_awaken(m_value, 1);
}
bool cond_x16::imp_wait(u32 slot, u64 _timeout) noexcept
{
const u32 wait_bit = c_wait << slot;
const u32 lock_bit = c_lock << slot;
// Change state from c_lock to c_wait
const u32 old_ = m_cvx16.fetch_op([=](u32& cvx16)
{
if (cvx16 & wait_bit)
{
// c_sig -> c_lock
cvx16 &= ~wait_bit;
}
else
{
cvx16 |= wait_bit;
cvx16 &= ~lock_bit;
}
});
if (old_ & wait_bit)
{
// Already signaled, return without waiting
return true;
}
return balanced_wait_until(m_cvx16, _timeout, [&](u32& cvx16, auto... ret) -> int
{
if (cvx16 & lock_bit)
{
// c_sig -> c_lock
cvx16 &= ~wait_bit;
return +1;
}
if constexpr (sizeof...(ret))
{
// Retire
cvx16 |= lock_bit;
cvx16 &= ~wait_bit;
return -1;
}
return 0;
});
}
void cond_x16::imp_notify() noexcept
{
auto [old, ok] = m_cvx16.fetch_op([](u32& v)
{
const u32 lock_mask = v >> 16;
const u32 wait_mask = v & 0xffff;
if (const u32 sig_mask = lock_mask ^ wait_mask)
{
v |= sig_mask | sig_mask << 16;
return true;
}
return false;
});
// Determine if some waiters need a syscall notification
const u32 wait_mask = old & (~old >> 16);
if (UNLIKELY(!ok || !wait_mask))
{
return;
}
balanced_awaken<true>(m_cvx16, utils::popcnt16(wait_mask));
}
bool lf_queue_base::wait(u64 _timeout)
{
return balanced_wait_until(m_head, _timeout, [](std::uintptr_t& head, auto... ret) -> int
{
if (head != 1)
{
return +1;
}
if constexpr (sizeof...(ret))
{
head = 0;
return -1;
}
return 0;
});
}
void lf_queue_base::imp_notify()
{
balanced_awaken(m_head, 1);
}
+215 -2
View File
@@ -2,6 +2,8 @@
#include "types.h"
#include "Atomic.h"
#include <shared_mutex>
#include "asm.h"
// Lightweight condition variable
class cond_variable
@@ -9,6 +11,8 @@ class cond_variable
// Internal waiter counter
atomic_t<u32> m_value{0};
friend class notifier;
protected:
// Internal waiting function
bool imp_wait(u32 _old, u64 _timeout) noexcept;
@@ -21,7 +25,7 @@ public:
// Intrusive wait algorithm for lockable objects
template <typename T>
explicit_bool_t wait(T& object, u64 usec_timeout = -1)
bool wait(T& object, u64 usec_timeout = -1)
{
const u32 _old = m_value.fetch_add(1); // Increment waiter counter
object.unlock();
@@ -30,6 +34,15 @@ public:
return res;
}
// Unlock all specified objects but don't lock them again
template <typename... Locks>
bool wait_unlock(u64 usec_timeout, Locks&&... locks)
{
const u32 _old = m_value.fetch_add(1); // Increment waiter counter
(..., std::forward<Locks>(locks).unlock());
return imp_wait(_old, usec_timeout);
}
// Wake one thread
void notify_one() noexcept
{
@@ -44,9 +57,209 @@ public:
{
if (m_value)
{
imp_wake(-1);
imp_wake(65535);
}
}
static constexpr u64 max_timeout = u64{UINT32_MAX} / 1000 * 1000000;
};
// Pair of a fake shared mutex (only limited shared locking) and a condition variable
class notifier
{
atomic_t<u32> m_counter{0};
cond_variable m_cond;
bool imp_try_lock(u32 count);
void imp_unlock(u32 count);
u32 imp_notify(u32 count);
public:
constexpr notifier() = default;
bool try_lock()
{
return imp_try_lock(max_readers);
}
void unlock()
{
imp_unlock(max_readers);
}
bool try_lock_shared()
{
return imp_try_lock(1);
}
void unlock_shared()
{
imp_unlock(1);
}
bool wait(u64 usec_timeout = -1);
void notify_all()
{
if (m_counter)
{
imp_notify(-1);
}
// Notify after imaginary "exclusive" lock+unlock
m_cond.notify_all();
}
void notify_one()
{
// TODO
if (m_counter)
{
if (imp_notify(1))
{
return;
}
}
m_cond.notify_one();
}
static constexpr u32 max_readers = 0x7f;
};
class cond_one
{
enum : u32
{
c_wait = 1,
c_lock = 2,
c_sig = 3,
};
atomic_t<u32> m_value{0};
bool imp_wait(u64 _timeout) noexcept;
void imp_notify() noexcept;
public:
constexpr cond_one() = default;
void lock() noexcept
{
// Shouldn't be locked by more than one thread concurrently
while (UNLIKELY(!m_value.compare_and_swap_test(0, c_lock)))
;
}
void unlock() noexcept
{
m_value = 0;
}
bool wait(std::unique_lock<cond_one>& lock, u64 usec_timeout = -1) noexcept
{
AUDIT(lock.owns_lock());
AUDIT(lock.mutex() == this);
return imp_wait(usec_timeout);
}
void notify() noexcept
{
// Early exit if notification is not required
if (LIKELY(!m_value))
return;
imp_notify();
}
};
// Packed version of cond_one, supports up to 16 readers.
class cond_x16
{
// For information, shouldn't modify
enum : u32
{
c_wait = 1,
c_lock = 1 << 16,
c_sig = 1 << 16 | 1,
};
// Split in 16-bit parts for convenient bit combining
atomic_t<u32> m_cvx16{0};
// Effectively unused, only counts readers
atomic_t<u32> m_total{0};
class lock_x16
{
cond_x16* m_this;
u32 m_slot;
friend class cond_x16;
public:
lock_x16(cond_x16* _this) noexcept
: m_this(_this)
{
// Spin if the number of readers exceeds 16
while (UNLIKELY(m_this->m_total++ >= 16))
m_this->m_total--;
// Lock and remember obtained slot index
m_slot = m_this->m_cvx16.atomic_op([](u32& cvx16)
{
// Combine used bits and invert to find least significant bit unused
const u32 slot = utils::cnttz32(~((cvx16 & 0xffff) | (cvx16 >> 16)), true);
// Set lock bit
cvx16 |= c_lock << slot;
AUDIT(slot < 16);
return slot;
});
}
lock_x16(const lock_x16&) = delete;
lock_x16& operator=(const lock_x16&) = delete;
~lock_x16()
{
// Clear the slot
m_this->m_cvx16 &= ~((c_wait | c_lock) << m_slot);
m_this->m_total -= 1;
}
bool wait(u64 usec_timeout = -1) const noexcept
{
return m_this->wait(*this, usec_timeout);
}
};
bool imp_wait(u32 slot, u64 _timeout) noexcept;
void imp_notify() noexcept;
public:
constexpr cond_x16() = default;
lock_x16 lock_one() noexcept
{
return lock_x16(this);
}
bool wait(lock_x16 const& lock, u64 usec_timeout = -1) noexcept
{
AUDIT(lock.m_this == this);
return imp_wait(lock.m_slot, usec_timeout);
}
void notify_all() noexcept
{
if (LIKELY(!m_cvx16))
return;
imp_notify();
}
};
+32
View File
@@ -0,0 +1,32 @@
#pragma once
namespace date_time
{
static inline tm get_time(time_t* _time)
{
tm buf;
time_t t = time(_time);
#ifdef _MSC_VER
localtime_s(&buf, &t);
#else
buf = *localtime(&t);
#endif
return buf;
}
static inline std::string current_time()
{
char str[80];
tm now = get_time(0);
strftime(str, sizeof(str), "%c", &now);
return str;
}
static inline std::string current_time_narrow()
{
char str[80];
tm now = get_time(0);
strftime(str, sizeof(str), "%Y%m%d%H%M%S", &now);
return str;
}
}
+15 -3
View File
@@ -63,18 +63,30 @@ namespace utils
{
}
// Caller
R operator()(Args... args)
void init()
{
if (!ptr)
{
// TODO: atomic
ptr = reinterpret_cast<R(*)(Args...)>(get_proc_address(lib, name));
}
}
operator bool()
{
init();
return ptr;
}
// Caller
R operator()(Args... args)
{
init();
return ptr(args...);
}
};
}
#define DYNAMIC_IMPORT(lib, name, ...) static utils::dynamic_import<__VA_ARGS__> name(lib, #name);
#define DYNAMIC_IMPORT(lib, name, ...) inline utils::dynamic_import<__VA_ARGS__> name(lib, #name);
+6 -4
View File
@@ -71,7 +71,7 @@ public:
}
// Conditionally set state (optimized)
explicit_bool_t state_test_and_set(T expected, T state)
bool state_test_and_set(T expected, T state)
{
if (m_value == expected && m_value.compare_and_swap_test(expected, state))
{
@@ -83,7 +83,7 @@ public:
}
// Conditionally set state (list version)
explicit_bool_t state_test_and_set(std::initializer_list<T> expected, T state)
bool state_test_and_set(std::initializer_list<T> expected, T state)
{
T _old;
@@ -111,9 +111,10 @@ public:
// Unconditionally set next state
void state_next()
{
T _old, state = m_value.op_fetch([&](T& value)
T _old, state = m_value.atomic_op([&](T& value)
{
_old = value++;
return value;
});
(static_cast<CRT*>(this)->*transition_get(state))(_old);
@@ -122,9 +123,10 @@ public:
// Unconditionally set previous state
void state_prev()
{
T _old, state = m_value.op_fetch([&](T& value)
T _old, state = m_value.atomic_op([&](T& value)
{
_old = value--;
return value;
});
(static_cast<CRT*>(this)->*transition_get(state))(_old);
+15
View File
@@ -976,62 +976,77 @@ struct color1_base
};
//specializations
using positionu = position_base<unsigned int>;
using positioni = position_base<int>;
using positionf = position_base<float>;
using positiond = position_base<double>;
using coordu = coord_base<unsigned int>;
using coordi = coord_base<int>;
using coordf = coord_base<float>;
using coordd = coord_base<double>;
using areau = area_base<unsigned int>;
using areai = area_base<int>;
using areaf = area_base<float>;
using aread = area_base<double>;
using position1u = position1_base<unsigned int>;
using position1i = position1_base<int>;
using position1f = position1_base<float>;
using position1d = position1_base<double>;
using position2u = position2_base<unsigned int>;
using position2i = position2_base<int>;
using position2f = position2_base<float>;
using position2d = position2_base<double>;
using position3u = position3_base<unsigned int>;
using position3i = position3_base<int>;
using position3f = position3_base<float>;
using position3d = position3_base<double>;
using position4u = position4_base<unsigned int>;
using position4i = position4_base<int>;
using position4f = position4_base<float>;
using position4d = position4_base<double>;
using size2u = size2_base<unsigned int>;
using size2i = size2_base<int>;
using size2f = size2_base<float>;
using size2d = size2_base<double>;
using sizeu = size2u;
using sizei = size2i;
using sizef = size2f;
using sized = size2d;
using size3u = size3_base<unsigned int>;
using size3i = size3_base<int>;
using size3f = size3_base<float>;
using size3d = size3_base<double>;
using coord3u = coord3_base<unsigned int>;
using coord3i = coord3_base<int>;
using coord3f = coord3_base<float>;
using coord3d = coord3_base<double>;
using color4u = color4_base<unsigned int>;
using color4i = color4_base<int>;
using color4f = color4_base<float>;
using color4d = color4_base<double>;
using color3u = color3_base<unsigned int>;
using color3i = color3_base<int>;
using color3f = color3_base<float>;
using color3d = color3_base<double>;
using color2u = color2_base<unsigned int>;
using color2i = color2_base<int>;
using color2f = color2_base<float>;
using color2d = color2_base<double>;
using color1u = color1_base<unsigned int>;
using color1i = color1_base<int>;
using color1f = color1_base<float>;
using color1d = color1_base<double>;
+5 -5
View File
@@ -69,14 +69,14 @@ if defined APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH (
rem // Otherwise, GIT_BRANCH=branch
set GIT_BRANCH=%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%
)
rem // Make GIT_VERSION the last commit (shortened); Don't include commit count on non-master builds
for /F %%I IN ('call %GIT% rev-parse --short HEAD') do set GIT_VERSION=%%I
for /F %%I IN ('call %GIT% rev-parse --short^=8 HEAD') do set GIT_VERSION=%%I
) else (
rem // Get last commit (shortened) and concat after commit count in GIT_VERSION
for /F %%I IN ('call %GIT% rev-parse --short HEAD') do set GIT_VERSION=%COMMIT_COUNT%-%%I
for /F %%I IN ('call %GIT% rev-parse --short^=8 HEAD') do set GIT_VERSION=%COMMIT_COUNT%-%%I
for /F %%I IN ('call %GIT% rev-parse --abbrev-ref HEAD') do set GIT_BRANCH=%%I
)
+29 -5
View File
@@ -9,19 +9,43 @@ namespace rpcs3
return static_cast<size_t>(value);
}
template<typename T>
static size_t hash_struct(const T& value)
template<typename T, typename U>
static size_t hash_struct_base(const T& value)
{
// FNV 64-bit
size_t result = 14695981039346656037ull;
const unsigned char *bytes = reinterpret_cast<const unsigned char*>(&value);
const U *bits = reinterpret_cast<const U*>(&value);
for (size_t n = 0; n < sizeof(T); ++n)
for (size_t n = 0; n < (sizeof(T) / sizeof(U)); ++n)
{
result ^= bytes[n];
result ^= bits[n];
result *= 1099511628211ull;
}
return result;
}
template<typename T>
static size_t hash_struct(const T& value)
{
// TODO: use c++17 if constexpr
static constexpr auto block_sz = sizeof(T);
if ((block_sz & 0x7) == 0)
{
return hash_struct_base<T, u64>(value);
}
if ((block_sz & 0x3) == 0)
{
return hash_struct_base<T, u32>(value);
}
if ((block_sz & 0x1) == 0)
{
return hash_struct_base<T, u16>(value);
}
return hash_struct_base<T, u8>(value);
}
}
+334 -172
View File
@@ -5,10 +5,10 @@
//! Simple sizeless array base for concurrent access. Cannot shrink, only growths automatically.
//! There is no way to know the current size. The smaller index is, the faster it's accessed.
//!
//!
//! T is the type of elements. Currently, default constructor of T shall be constexpr.
//! N is initial element count, available without any memory allocation and only stored contiguously.
template<typename T, std::size_t N>
template <typename T, std::size_t N>
class lf_array
{
// Data (default-initialized)
@@ -70,7 +70,7 @@ public:
{
return reinterpret_cast<const atomic_t<u32>&>(m_ctrl).load(); // Hack
}
// Acquire the place for one or more elements.
u32 push_begin(u32 count = 1)
{
@@ -130,7 +130,7 @@ public:
{
return m_default_key_data;
}
// Calculate hash and array position
for (std::size_t pos = Hash{}(key) % Size;; pos += Size)
{
@@ -146,185 +146,347 @@ public:
}
};
// Fixed-size single-producer single-consumer queue
template <typename T, std::uint32_t N>
class lf_spsc
// Helper type, linked list element
template <typename T>
class lf_queue_item final
{
// If N is a power of 2, m_push/m_pop can safely overflow and the algorithm is simplified
static_assert(N && (1u << 31) % N == 0, "lf_spsc<> error: size must be power of 2");
lf_queue_item* m_link = nullptr;
protected:
volatile std::uint32_t m_push{0};
volatile std::uint32_t m_pop{0};
T m_data[N]{};
T m_data;
public:
constexpr lf_spsc() = default;
template <typename U>
friend class lf_queue_iterator;
// Try to push (producer only)
template <typename T2>
bool try_push(T2&& data)
template <typename U>
friend class lf_queue_slice;
template <typename U>
friend class lf_queue;
constexpr lf_queue_item() = default;
template <typename... Args>
constexpr lf_queue_item(lf_queue_item* link, Args&&... args)
: m_link(link)
, m_data(std::forward<Args>(args)...)
{
const std::uint32_t pos = m_push;
if (pos - m_pop >= N)
{
return false;
}
_mm_lfence();
m_data[pos % N] = std::forward<T2>(data);
_mm_sfence();
m_push = pos + 1;
return true;
}
// Try to get push pointer (producer only)
operator T*()
{
const std::uint32_t pos = m_push;
if (pos - m_pop >= N)
{
return nullptr;
}
_mm_lfence();
return m_data + (pos % N);
}
// Increment push counter (producer only)
void end_push()
{
const std::uint32_t pos = m_push;
if (pos - m_pop < N)
{
_mm_sfence();
m_push = pos + 1;
}
}
// Unsafe access
T& get_push(std::size_t i)
{
_mm_lfence();
return m_data[(m_push + i) % N];
}
// Try to pop (consumer only)
template <typename T2>
bool try_pop(T2& out)
{
const std::uint32_t pos = m_pop;
if (m_push - pos <= 0)
{
return false;
}
_mm_lfence();
out = std::move(m_data[pos % N]);
_mm_sfence();
m_pop = pos + 1;
return true;
}
// Increment pop counter (consumer only)
void end_pop()
{
const std::uint32_t pos = m_pop;
if (m_push - pos > 0)
{
_mm_sfence();
m_pop = pos + 1;
}
}
// Get size (consumer only)
std::uint32_t size() const
{
return m_push - m_pop;
}
// Direct access (consumer only)
T& operator [](std::size_t i)
{
_mm_lfence();
return m_data[(m_pop + i) % N];
}
};
// Fixed-size multi-producer single-consumer queue
template <typename T, std::uint32_t N>
class lf_mpsc : lf_spsc<T, N>
{
protected:
using lf_spsc<T, N>::m_push;
using lf_spsc<T, N>::m_pop;
using lf_spsc<T, N>::m_data;
enum : std::uint64_t
{
c_ack = 1ull << 0,
c_rel = 1ull << 32,
};
atomic_t<std::uint64_t> m_lock{0};
void release(std::uint64_t value)
{
// Push all pending elements at once when possible
if (value && value % c_rel == value / c_rel)
{
_mm_sfence();
m_push += value % c_rel;
m_lock.compare_and_swap_test(value, 0);
}
}
public:
constexpr lf_mpsc() = default;
lf_queue_item(const lf_queue_item&) = delete;
// Try to get push pointer
operator T*()
lf_queue_item& operator=(const lf_queue_item&) = delete;
~lf_queue_item()
{
const std::uint64_t old = m_lock.fetch_add(c_ack);
const std::uint32_t pos = m_push;
if (old % N >= N || pos - m_pop >= N - (old % N))
for (lf_queue_item* ptr = m_link; ptr;)
{
release(m_lock.sub_fetch(c_ack));
return nullptr;
delete std::exchange(ptr, std::exchange(ptr->m_link, nullptr));
}
return m_data + ((pos + old) % N);
}
// Increment push counter (producer only)
void end_push()
{
release(m_lock.add_fetch(c_rel));
}
// Try to push
template <typename T2>
bool try_push(T2&& data)
{
if (T* ptr = *this)
{
*ptr = std::forward<T2>(data);
end_push();
return true;
}
return false;
}
// Enable consumer methods
using lf_spsc<T, N>::try_pop;
using lf_spsc<T, N>::end_pop;
using lf_spsc<T, N>::size;
using lf_spsc<T, N>::operator [];
};
// Forward iterator: non-owning pointer to the list element in lf_queue_slice<>
template <typename T>
class lf_queue_iterator
{
lf_queue_item<T>* m_ptr = nullptr;
template <typename U>
friend class lf_queue_slice;
public:
constexpr lf_queue_iterator() = default;
bool operator ==(const lf_queue_iterator& rhs) const
{
return m_ptr == rhs.m_ptr;
}
bool operator !=(const lf_queue_iterator& rhs) const
{
return m_ptr != rhs.m_ptr;
}
T& operator *() const
{
return m_ptr->m_data;
}
T* operator ->() const
{
return &m_ptr->m_data;
}
lf_queue_iterator& operator ++()
{
m_ptr = m_ptr->m_link;
return *this;
}
lf_queue_iterator operator ++(int)
{
lf_queue_iterator result;
result.m_ptr = m_ptr;
m_ptr = m_ptr->m_link;
return result;
}
};
// Owning pointer to the linked list taken from the lf_queue<>
template <typename T>
class lf_queue_slice
{
lf_queue_item<T>* m_head = nullptr;
template <typename U>
friend class lf_queue;
public:
constexpr lf_queue_slice() = default;
lf_queue_slice(const lf_queue_slice&) = delete;
lf_queue_slice(lf_queue_slice&& r) noexcept
: m_head(r.m_head)
{
r.m_head = nullptr;
}
lf_queue_slice& operator =(const lf_queue_slice&) = delete;
lf_queue_slice& operator =(lf_queue_slice&& r) noexcept
{
if (this != &r)
{
delete m_head;
m_head = r.m_head;
r.m_head = nullptr;
}
return *this;
}
~lf_queue_slice()
{
delete m_head;
}
T& operator *() const
{
return m_head->m_data;
}
T* operator ->() const
{
return &m_head->m_data;
}
explicit operator bool() const
{
return m_head != nullptr;
}
T* get() const
{
return m_head ? &m_head->m_data : nullptr;
}
lf_queue_iterator<T> begin() const
{
lf_queue_iterator<T> result;
result.m_ptr = m_head;
return result;
}
lf_queue_iterator<T> end() const
{
return {};
}
lf_queue_slice& pop_front()
{
delete std::exchange(m_head, std::exchange(m_head->m_link, nullptr));
return *this;
}
};
class lf_queue_base
{
protected:
atomic_t<std::uintptr_t> m_head = 0;
void imp_notify();
public:
// Wait for new elements pushed, no other thread shall call wait() or pop_all() simultaneously
bool wait(u64 usec_timeout = -1);
};
// Linked list-based multi-producer queue (the consumer drains the whole queue at once)
template <typename T>
class lf_queue : public lf_queue_base
{
using lf_queue_base::m_head;
// Extract all elements and reverse element order (FILO to FIFO)
lf_queue_item<T>* reverse() noexcept
{
if (auto* head = m_head.load() ? reinterpret_cast<lf_queue_item<T>*>(m_head.exchange(0)) : nullptr)
{
if (auto* prev = head->m_link)
{
head->m_link = nullptr;
do
{
auto* pprev = prev->m_link;
prev->m_link = head;
head = std::exchange(prev, pprev);
}
while (prev);
}
return head;
}
return nullptr;
}
public:
constexpr lf_queue() = default;
~lf_queue()
{
delete reinterpret_cast<T*>(m_head.load());
}
template <typename... Args>
void push(Args&&... args)
{
auto _old = m_head.load();
auto* item = new lf_queue_item<T>(_old & 1 ? nullptr : reinterpret_cast<lf_queue_item<T>*>(_old), std::forward<Args>(args)...);
while (!m_head.compare_exchange(_old, reinterpret_cast<std::uint64_t>(item)))
{
item->m_link = _old & 1 ? nullptr : reinterpret_cast<lf_queue_item<T>*>(_old);
}
if (_old & 1)
{
lf_queue_base::imp_notify();
}
}
// Withdraw the list, supports range-for loop: for (auto&& x : y.pop_all()) ...
lf_queue_slice<T> pop_all()
{
lf_queue_slice<T> result;
result.m_head = reverse();
return result;
}
// Apply func(data) to each element, return the total length
template <typename F>
std::size_t apply(F&& func)
{
std::size_t count = 0;
for (auto slice = pop_all(); slice; slice.pop_front())
{
std::invoke(std::forward<F>(func), *slice);
}
return count;
}
// apply() overload for callable template argument
template <auto F>
std::size_t apply()
{
std::size_t count = 0;
for (auto slice = pop_all(); slice; slice.pop_front())
{
std::invoke(F, *slice);
}
return count;
}
};
// Assignable lock-free thread-safe value of any type (memory-inefficient)
template <typename T>
class lf_value final
{
atomic_t<lf_value*> m_head;
T m_data;
public:
template <typename... Args>
explicit constexpr lf_value(Args&&... args)
: m_head(this)
, m_data(std::forward<Args>(args)...)
{
}
~lf_value()
{
// All values are kept in the queue until the end
for (lf_value* ptr = m_head.load(); ptr != this;)
{
delete std::exchange(ptr, std::exchange(ptr->m_head.raw(), ptr));
}
}
// Get current head, allows to inspect old values
[[nodiscard]] const lf_value* head() const
{
return m_head.load();
}
// Inspect the initial (oldest) value
[[nodiscard]] const T& first() const
{
return m_data;
}
[[nodiscard]] const T& get() const
{
return m_head.load()->m_data;
}
[[nodiscard]] operator const T&() const
{
return m_head.load()->m_data;
}
// Construct new value in-place
template <typename... Args>
const T& assign(Args&&... args)
{
lf_value* val = new lf_value(std::forward<Args>(args)...);
lf_value* old = m_head.load();
do
{
val->m_head = old;
}
while (!m_head.compare_exchange(old, val));
return val->m_data;
}
// Copy-assign new value
const T& operator =(const T& value)
{
return assign(value);
}
// Move-assign new value
const T& operator =(T&& value)
{
return assign(std::move(value));
}
};
+110 -284
View File
@@ -2,333 +2,159 @@
#include "sync.h"
#include <climits>
#include <vector>
#include <algorithm>
// TLS variable for tracking owned mutexes
thread_local std::vector<shared_mutex*> g_tls_locks;
void shared_mutex::imp_lock_shared(s64 _old)
void shared_mutex::imp_lock_shared(u32 val)
{
verify("shared_mutex overflow" HERE), _old <= c_max;
verify("shared_mutex underflow" HERE), val < c_err;
for (int i = 0; i < 10; i++)
{
busy_wait();
const s64 value = m_value.load();
if (value >= c_min && m_value.compare_and_swap_test(value, value - c_min))
if (try_lock_shared())
{
return;
}
}
#ifdef _WIN32
// Acquire writer lock
imp_wait(m_value.load());
// Acquire writer lock and downgrade
const u32 old = m_value.fetch_add(c_one);
// Convert to reader lock
s64 value = m_value.fetch_add(c_one - c_min);
// Proceed exclusively
return;
if (value != 0)
if (old == 0)
{
imp_unlock(value);
}
// Wait as a reader if necessary
if (value + c_one - c_min < 0)
{
NtWaitForKeyedEvent(nullptr, (int*)&m_value + 1, false, nullptr);
}
#else
// Acquire writer lock
imp_wait(0);
// Convert to reader lock
m_value += c_one - c_min;
// Disabled code
while (false)
{
const s64 value0 = m_value.fetch_op([](s64& value)
{
if (value >= c_min)
{
value -= c_min;
}
});
if (value0 >= c_min)
{
return;
}
// Acquire writer lock
imp_wait(value0);
// Convert to reader lock
s64 value1 = m_value.fetch_add(c_one - c_min);
if (value1 != 0)
{
imp_unlock(value1);
}
value1 += c_one - c_min;
if (value1 > 0)
{
return;
}
// Wait as a reader if necessary
while (futex((int*)&m_value.raw() + IS_LE_MACHINE, FUTEX_WAIT_BITSET_PRIVATE, int(value1 >> 32), nullptr, nullptr, INT_MIN))
{
value1 = m_value.load();
if (value1 >= 0)
{
return;
}
}
// If blocked by writers, release the reader lock and try again
const s64 value2 = m_value.fetch_op([](s64& value)
{
if (value < 0)
{
value += c_min;
}
});
if (value2 >= 0)
{
return;
}
imp_unlock_shared(value2);
}
#endif
}
void shared_mutex::imp_unlock_shared(s64 _old)
{
verify("shared_mutex overflow" HERE), _old + c_min <= c_max;
// Check reader count, notify the writer if necessary
if ((_old + c_min) % c_one == 0)
{
#ifdef _WIN32
NtReleaseKeyedEvent(nullptr, &m_value, false, nullptr);
#else
m_value -= c_sig;
futex((int*)&m_value.raw() + IS_LE_MACHINE, FUTEX_WAKE_BITSET_PRIVATE, 1, nullptr, nullptr, u32(c_sig >> 32));
#endif
}
}
void shared_mutex::imp_wait(s64)
{
#ifdef _WIN32
if (m_value.sub_fetch(c_one))
{
NtWaitForKeyedEvent(nullptr, &m_value, false, nullptr);
}
#else
if (!m_value.sub_fetch(c_one))
{
// Return immediately if locked
lock_downgrade();
return;
}
while (true)
{
// Load new value, try to acquire c_sig
const s64 value = m_value.fetch_op([](s64& value)
{
if (value <= c_one - c_sig)
{
value += c_sig;
}
});
if (value <= c_one - c_sig)
{
return;
}
futex((int*)&m_value.raw() + IS_LE_MACHINE, FUTEX_WAIT_BITSET_PRIVATE, int(value >> 32), nullptr, nullptr, u32(c_sig >> 32));
}
#endif
verify("shared_mutex overflow" HERE), (old % c_sig) + c_one < c_sig;
imp_wait();
lock_downgrade();
}
void shared_mutex::imp_lock(s64 _old)
void shared_mutex::imp_unlock_shared(u32 old)
{
verify("shared_mutex overflow" HERE), _old <= c_max;
verify("shared_mutex underflow" HERE), old - 1 < c_err;
// Check reader count, notify the writer if necessary
if ((old - 1) % c_one == 0)
{
imp_signal();
}
}
void shared_mutex::imp_wait()
{
while (!balanced_wait_until(m_value, -1, [&](u32& value, auto...)
{
if (value >= c_sig)
{
value -= c_sig;
return true;
}
return false;
}))
{
}
}
void shared_mutex::imp_signal()
{
m_value += c_sig;
balanced_awaken(m_value, 1);
}
void shared_mutex::imp_lock(u32 val)
{
verify("shared_mutex underflow" HERE), val < c_err;
for (int i = 0; i < 10; i++)
{
busy_wait();
const s64 value = m_value.load();
if (value == c_one && m_value.compare_and_swap_test(c_one, 0))
if (!m_value && try_lock())
{
return;
}
}
imp_wait(m_value.load());
const u32 old = m_value.fetch_add(c_one);
if (old == 0)
{
return;
}
verify("shared_mutex overflow" HERE), (old % c_sig) + c_one < c_sig;
imp_wait();
}
void shared_mutex::imp_unlock(s64 _old)
void shared_mutex::imp_unlock(u32 old)
{
verify("shared_mutex overflow" HERE), _old + c_one <= c_max;
verify("shared_mutex underflow" HERE), old - c_one < c_err;
// 1) Notify the next writer if necessary
// 2) Notify all readers otherwise if necessary
#ifdef _WIN32
if (_old + c_one <= 0)
// 2) Notify all readers otherwise if necessary (currently indistinguishable from writers)
if (old - c_one)
{
NtReleaseKeyedEvent(nullptr, &m_value, false, nullptr);
imp_signal();
}
else if (s64 count = -_old / c_min * 0)
{
// Disabled code
while (count--)
{
NtReleaseKeyedEvent(nullptr, (int*)&m_value + 1, false, nullptr);
}
}
#else
if (_old + c_one <= 0)
{
m_value -= c_sig;
futex((int*)&m_value.raw() + IS_LE_MACHINE, FUTEX_WAKE_BITSET_PRIVATE, 1, nullptr, nullptr, u32(c_sig >> 32));
}
else if (false)
{
// Disabled code
futex((int*)&m_value.raw() + IS_LE_MACHINE, FUTEX_WAKE_BITSET_PRIVATE, INT_MAX, nullptr, nullptr, INT_MIN);
}
#endif
}
void shared_mutex::imp_lock_upgrade()
{
// TODO
unlock_shared();
lock();
for (int i = 0; i < 10; i++)
{
busy_wait();
if (try_lock_upgrade())
{
return;
}
}
// Convert to writer lock
const u32 old = m_value.fetch_add(c_one - 1);
verify("shared_mutex overflow" HERE), (old % c_sig) + c_one - 1 < c_sig;
if (old % c_one == 1)
{
return;
}
imp_wait();
}
void shared_mutex::imp_lock_degrade()
void shared_mutex::imp_lock_unlock()
{
// TODO
u32 _max = 1;
for (int i = 0; i < 30; i++)
{
const u32 val = m_value;
if (val % c_one == 0 && (val / c_one < _max || val >= c_sig))
{
// Return if have cought a state where:
// 1) Mutex is free
// 2) Total number of waiters decreased since last check
// 3) Signal bit is set (if used on the platform)
return;
}
_max = val / c_one;
busy_wait(1500);
}
// Lock and unlock
if (!m_value.fetch_add(c_one))
{
unlock();
return;
}
imp_wait();
unlock();
lock_shared();
}
bool shared_mutex::try_lock_shared()
{
// Conditional decrement
return m_value.fetch_op([](s64& value) { if (value >= c_min) value -= c_min; }) >= c_min;
}
bool shared_mutex::try_lock()
{
// Conditional decrement (TODO: obtain c_sig)
return m_value.compare_and_swap_test(c_one, 0);
}
bool shared_mutex::try_lock_upgrade()
{
// TODO
return m_value.compare_and_swap_test(c_one - c_min, 0);
}
bool shared_mutex::try_lock_degrade()
{
// TODO
return m_value.compare_and_swap_test(0, c_one - c_min);
}
safe_reader_lock::safe_reader_lock(shared_mutex& mutex)
: m_mutex(mutex)
, m_is_owned(false)
{
if (std::count(g_tls_locks.cbegin(), g_tls_locks.cend(), &m_mutex) == 0)
{
m_is_owned = true;
if (m_is_owned)
{
m_mutex.lock_shared();
g_tls_locks.emplace_back(&m_mutex);
return;
}
// TODO: order locks
}
}
safe_reader_lock::~safe_reader_lock()
{
if (m_is_owned)
{
m_mutex.unlock_shared();
g_tls_locks.erase(std::remove(g_tls_locks.begin(), g_tls_locks.end(), &m_mutex), g_tls_locks.cend());
return;
}
// TODO: order locks
}
safe_writer_lock::safe_writer_lock(shared_mutex& mutex)
: m_mutex(mutex)
, m_is_owned(false)
, m_is_upgraded(false)
{
if (std::count(g_tls_locks.cbegin(), g_tls_locks.cend(), &m_mutex) == 0)
{
m_is_owned = true;
if (m_is_owned)
{
m_mutex.lock_shared();
g_tls_locks.emplace_back(&m_mutex);
return;
}
// TODO: order locks
}
if (m_mutex.is_reading())
{
m_is_upgraded = true;
m_mutex.lock_upgrade();
}
}
safe_writer_lock::~safe_writer_lock()
{
if (m_is_upgraded)
{
m_mutex.lock_degrade();
return;
}
if (m_is_owned)
{
m_mutex.unlock();
g_tls_locks.erase(std::remove(g_tls_locks.begin(), g_tls_locks.end(), &m_mutex), g_tls_locks.cend());
return;
}
// TODO: order locks
}
+119 -137
View File
@@ -1,65 +1,108 @@
#pragma once
#include <mutex>
#include "types.h"
#include "Atomic.h"
// Shared mutex.
// Shared mutex with small size (u32).
class shared_mutex final
{
enum : s64
enum : u32
{
c_one = 1ull << 31, // Fixed-point 1.0 value (one writer)
c_min = 0x00000001, // Fixed-point 1.0/max_readers value
c_sig = 1ull << 62,
c_max = c_one
c_one = 1u << 14, // Fixed-point 1.0 value (one writer, max_readers = c_one - 1)
c_sig = 1u << 30,
c_err = 1u << 31,
};
atomic_t<s64> m_value{c_one}; // Semaphore-alike counter
void imp_lock_shared(s64 _old);
void imp_unlock_shared(s64 _old);
void imp_wait(s64 _old);
void imp_lock(s64 _old);
void imp_unlock(s64 _old);
atomic_t<u32> m_value{};
void imp_lock_shared(u32 val);
void imp_unlock_shared(u32 old);
void imp_wait();
void imp_signal();
void imp_lock(u32 val);
void imp_unlock(u32 old);
void imp_lock_upgrade();
void imp_lock_degrade();
void imp_lock_unlock();
public:
constexpr shared_mutex() = default;
bool try_lock_shared();
bool try_lock_shared()
{
const u32 value = m_value.load();
// Conditional increment
return value < c_one - 1 && m_value.compare_and_swap_test(value, value + 1);
}
void lock_shared()
{
const s64 value = m_value.load();
const u32 value = m_value.load();
// Fast path: decrement if positive
if (UNLIKELY(value < c_min || value > c_one || !m_value.compare_and_swap_test(value, value - c_min)))
if (UNLIKELY(value >= c_one - 1 || !m_value.compare_and_swap_test(value, value + 1)))
{
imp_lock_shared(value);
}
}
void lock_shared_hle()
{
const u32 value = m_value.load();
if (LIKELY(value < c_one - 1))
{
u32 old = value;
if (LIKELY(atomic_storage<u32>::compare_exchange_hle_acq(m_value.raw(), old, value + 1)))
{
return;
}
}
imp_lock_shared(value);
}
void unlock_shared()
{
// Unconditional increment
const s64 value = m_value.fetch_add(c_min);
// Unconditional decrement (can result in broken state)
const u32 value = m_value.fetch_sub(1);
if (value < 0 || value > c_one - c_min)
if (UNLIKELY(value >= c_one))
{
imp_unlock_shared(value);
}
}
bool try_lock();
void unlock_shared_hle()
{
const u32 value = atomic_storage<u32>::fetch_add_hle_rel(m_value.raw(), -1);
if (UNLIKELY(value >= c_one))
{
imp_unlock_shared(value);
}
}
bool try_lock()
{
return m_value.compare_and_swap_test(0, c_one);
}
void lock()
{
// Try to lock
const s64 value = m_value.compare_and_swap(c_one, 0);
const u32 value = m_value.compare_and_swap(0, c_one);
if (value != c_one)
if (UNLIKELY(value))
{
imp_lock(value);
}
}
void lock_hle()
{
u32 value = 0;
if (UNLIKELY(!atomic_storage<u32>::compare_exchange_hle_acq(m_value.raw(), value, c_one)))
{
imp_lock(value);
}
@@ -67,38 +110,66 @@ public:
void unlock()
{
// Unconditional increment
const s64 value = m_value.fetch_add(c_one);
// Unconditional decrement (can result in broken state)
const u32 value = m_value.fetch_sub(c_one);
if (value != 0)
if (UNLIKELY(value != c_one))
{
imp_unlock(value);
}
}
bool try_lock_upgrade();
void unlock_hle()
{
const u32 value = atomic_storage<u32>::fetch_add_hle_rel(m_value.raw(), -c_one);
if (UNLIKELY(value != c_one))
{
imp_unlock(value);
}
}
bool try_lock_upgrade()
{
const u32 value = m_value.load();
// Conditional increment, try to convert a single reader into a writer, ignoring other writers
return (value + c_one - 1) % c_one == 0 && m_value.compare_and_swap_test(value, value + c_one - 1);
}
void lock_upgrade()
{
if (!m_value.compare_and_swap_test(c_one - c_min, 0))
if (UNLIKELY(!try_lock_upgrade()))
{
imp_lock_upgrade();
}
}
bool try_lock_degrade();
void lock_degrade()
void lock_downgrade()
{
if (!m_value.compare_and_swap_test(0, c_one - c_min))
// Convert to reader lock (can result in broken state)
m_value -= c_one - 1;
}
// Optimized wait for lockability without locking, relaxed
void lock_unlock()
{
if (UNLIKELY(m_value != 0))
{
imp_lock_degrade();
imp_lock_unlock();
}
}
bool is_reading() const
// Check whether can immediately obtain an exclusive (writer) lock
bool is_free() const
{
return (m_value.load() % c_one) != 0;
return m_value.load() == 0;
}
// Check whether can immediately obtain a shared (reader) lock
bool is_lockable() const
{
return m_value.load() < c_one - 1;
}
};
@@ -108,28 +179,18 @@ class reader_lock final
shared_mutex& m_mutex;
bool m_upgraded = false;
void lock()
{
m_upgraded ? m_mutex.lock() : m_mutex.lock_shared();
}
void unlock()
{
m_upgraded ? m_mutex.unlock() : m_mutex.unlock_shared();
}
friend class cond_variable;
public:
reader_lock(const reader_lock&) = delete;
reader_lock& operator=(const reader_lock&) = delete;
explicit reader_lock(shared_mutex& mutex)
: m_mutex(mutex)
{
lock();
m_mutex.lock_shared();
}
// One-way lock upgrade
// One-way lock upgrade; note that the observed state could have been changed
void upgrade()
{
if (!m_upgraded)
@@ -139,93 +200,14 @@ public:
}
}
// Try to upgrade; if it succeeds, the observed state has NOT been changed
bool try_upgrade()
{
return m_upgraded || (m_upgraded = m_mutex.try_lock_upgrade());
}
~reader_lock()
{
unlock();
m_upgraded ? m_mutex.unlock() : m_mutex.unlock_shared();
}
};
// Simplified exclusive (writer) lock implementation.
class writer_lock final
{
shared_mutex& m_mutex;
void lock()
{
m_mutex.lock();
}
void unlock()
{
m_mutex.unlock();
}
friend class cond_variable;
public:
writer_lock(const writer_lock&) = delete;
explicit writer_lock(shared_mutex& mutex)
: m_mutex(mutex)
{
lock();
}
~writer_lock()
{
unlock();
}
};
// Safe reader lock. Can be recursive above other safe locks (reader or writer).
class safe_reader_lock final
{
shared_mutex& m_mutex;
bool m_is_owned;
void lock()
{
m_mutex.lock_shared();
}
void unlock()
{
m_mutex.unlock_shared();
}
friend class cond_variable;
public:
safe_reader_lock(const safe_reader_lock&) = delete;
explicit safe_reader_lock(shared_mutex& mutex);
~safe_reader_lock();
};
// Safe writer lock. Can be recursive above other safe locks. Performs upgrade and degrade operations above existing reader lock if necessary.
class safe_writer_lock final
{
shared_mutex& m_mutex;
bool m_is_owned;
bool m_is_upgraded;
void lock()
{
m_mutex.lock();
}
void unlock()
{
m_mutex.unlock();
}
friend class cond_variable;
public:
safe_writer_lock(const safe_writer_lock&) = delete;
explicit safe_writer_lock(shared_mutex& mutex);
~safe_writer_lock();
};
+1 -5
View File
@@ -1,10 +1,6 @@
#pragma once
#ifndef PUGIXML_HEADER_ONLY
#define PUGIXML_HEADER_ONLY 1
#endif // !PUGIXML_HEADER_ONLY
#include "pugixml.hpp"
#undef PUGIXML_HEADER_ONLY
#include <pugixml.hpp>
struct rXmlNode
{
-124
View File
@@ -1,124 +0,0 @@
#ifndef MAPBOX_UTIL_RECURSIVE_WRAPPER_HPP
#define MAPBOX_UTIL_RECURSIVE_WRAPPER_HPP
// Based on variant/recursive_wrapper.hpp from boost.
//
// Original license:
//
// Copyright (c) 2002-2003
// Eric Friedman, Itay Maman
//
// 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)
#include <cassert>
#include <utility>
//namespace mapbox {
//namespace util {
namespace std {
template <typename T>
class recursive_wrapper
{
T* p_;
void assign(T const& rhs)
{
this->get() = rhs;
}
public:
using type = T;
/**
* Default constructor default initializes the internally stored value.
* For POD types this means nothing is done and the storage is
* uninitialized.
*
* @throws std::bad_alloc if there is insufficient memory for an object
* of type T.
* @throws any exception thrown by the default constructur of T.
*/
recursive_wrapper()
: p_(new T){}
~recursive_wrapper() noexcept { delete p_; }
recursive_wrapper(recursive_wrapper const& operand)
: p_(new T(operand.get())) {}
recursive_wrapper(T const& operand)
: p_(new T(operand)) {}
recursive_wrapper(recursive_wrapper&& operand)
: p_(new T(std::move(operand.get()))) {}
recursive_wrapper(T&& operand)
: p_(new T(std::move(operand))) {}
inline recursive_wrapper& operator=(recursive_wrapper const& rhs)
{
assign(rhs.get());
return *this;
}
inline recursive_wrapper& operator=(T const& rhs)
{
assign(rhs);
return *this;
}
inline void swap(recursive_wrapper& operand) noexcept
{
T* temp = operand.p_;
operand.p_ = p_;
p_ = temp;
}
recursive_wrapper& operator=(recursive_wrapper&& rhs) noexcept
{
swap(rhs);
return *this;
}
recursive_wrapper& operator=(T&& rhs)
{
get() = std::move(rhs);
return *this;
}
T& get()
{
assert(p_);
return *get_pointer();
}
T const& get() const
{
assert(p_);
return *get_pointer();
}
T* get_pointer() { return p_; }
const T* get_pointer() const { return p_; }
operator T const&() const { return this->get(); }
operator T&() { return this->get(); }
}; // class recursive_wrapper
template <typename T>
inline void swap(recursive_wrapper<T>& lhs, recursive_wrapper<T>& rhs) noexcept
{
lhs.swap(rhs);
}
}
//} // namespace util
//} // namespace mapbox
#endif // MAPBOX_UTIL_RECURSIVE_WRAPPER_HPP
+6 -18
View File
@@ -26,7 +26,7 @@ void semaphore_base::imp_wait()
while (true)
{
// Try hard way
const s32 value = m_value.op_fetch([](s32& value)
const s32 value = m_value.atomic_op([](s32& value)
{
// Use sign bit to acknowledge waiter presence
if (value && value > INT32_MIN)
@@ -44,16 +44,18 @@ void semaphore_base::imp_wait()
// Set sign bit
value = INT32_MIN;
}
return value;
});
if (value >= 0)
{
// Signal other waiter to wake up or to restore sign bit
futex(&m_value.raw(), FUTEX_WAKE_PRIVATE, 1, nullptr, nullptr, 0);
futex(&m_value, FUTEX_WAKE_PRIVATE, 1);
return;
}
futex(&m_value.raw(), FUTEX_WAIT_PRIVATE, value, nullptr, nullptr, 0);
futex(&m_value, FUTEX_WAIT_PRIVATE, value);
}
#endif
}
@@ -65,24 +67,10 @@ void semaphore_base::imp_post(s32 _old)
#ifdef _WIN32
NtReleaseKeyedEvent(nullptr, &m_value, false, nullptr);
#else
futex(&m_value.raw(), FUTEX_WAKE_PRIVATE, 1, nullptr, nullptr, 0);
futex(&m_value, FUTEX_WAKE_PRIVATE, 1);
#endif
}
bool semaphore_base::try_wait()
{
// Conditional decrement
const s32 value = m_value.fetch_op([](s32& value)
{
if (value > 0)
{
value -= 1;
}
});
return value > 0;
}
bool semaphore_base::try_post(s32 _max)
{
// Conditional increment
+11 -40
View File
@@ -1,5 +1,6 @@
#pragma once
#include <mutex>
#include "types.h"
#include "Atomic.h"
@@ -13,8 +14,6 @@ class semaphore_base
void imp_post(s32 _old);
friend class semaphore_lock;
protected:
explicit constexpr semaphore_base(s32 value)
: m_value{value}
@@ -33,7 +32,10 @@ protected:
}
}
bool try_wait();
bool try_wait()
{
return m_value.try_dec(0);
}
void post(s32 _max)
{
@@ -73,36 +75,36 @@ class semaphore final : public semaphore_base
public:
// Default constructor (recommended)
constexpr semaphore()
: base{Def}
: base(Def)
{
}
// Explicit value constructor (not recommended)
explicit constexpr semaphore(s32 value)
: base{value}
: base(value)
{
}
// Obtain a semaphore
void wait()
void lock()
{
return base::wait();
}
// Try to obtain a semaphore
explicit_bool_t try_wait()
bool try_lock()
{
return base::try_wait();
}
// Return a semaphore
void post()
void unlock()
{
return base::post(Max);
}
// Try to return a semaphore
explicit_bool_t try_post()
bool try_unlock()
{
return base::try_post(Max);
}
@@ -113,34 +115,3 @@ public:
return Max;
}
};
class semaphore_lock
{
semaphore_base& m_base;
void lock()
{
m_base.wait();
}
void unlock()
{
m_base.post(INT32_MAX);
}
friend class cond_variable;
public:
explicit semaphore_lock(const semaphore_lock&) = delete;
semaphore_lock(semaphore_base& sema)
: m_base(sema)
{
lock();
}
~semaphore_lock()
{
unlock();
}
};
+168 -22
View File
@@ -17,6 +17,7 @@
#include <unistd.h>
#else
#endif
#include <algorithm>
#include <ctime>
#include <chrono>
#include <mutex>
@@ -24,10 +25,12 @@
#include <unordered_map>
#ifdef _WIN32
DYNAMIC_IMPORT("ntdll.dll", NtSetTimerResolution, NTSTATUS(ULONG DesiredResolution, BOOLEAN SetResolution, PULONG CurrentResolution));
DYNAMIC_IMPORT("ntdll.dll", NtWaitForKeyedEvent, NTSTATUS(HANDLE Handle, PVOID Key, BOOLEAN Alertable, PLARGE_INTEGER Timeout));
DYNAMIC_IMPORT("ntdll.dll", NtReleaseKeyedEvent, NTSTATUS(HANDLE Handle, PVOID Key, BOOLEAN Alertable, PLARGE_INTEGER Timeout));
DYNAMIC_IMPORT("ntdll.dll", NtDelayExecution, NTSTATUS(BOOLEAN Alertable, PLARGE_INTEGER DelayInterval));
inline utils::dynamic_import<BOOL(volatile VOID* Address, PVOID CompareAddress, SIZE_T AddressSize, DWORD dwMilliseconds)> OptWaitOnAddress("kernel32.dll", "WaitOnAddress");
inline utils::dynamic_import<VOID(PVOID Address)> OptWakeByAddressSingle("kernel32.dll", "WakeByAddressSingle");
inline utils::dynamic_import<VOID(PVOID Address)> OptWakeByAddressAll("kernel32.dll", "WakeByAddressAll");
#endif
#ifndef __linux__
@@ -46,37 +49,37 @@ enum
};
#endif
inline int futex(int* uaddr, int futex_op, int val, const timespec* timeout, int* uaddr2, int val3)
inline int futex(volatile void* uaddr, int futex_op, uint val, const timespec* timeout = nullptr, uint mask = 0)
{
#ifdef __linux__
return syscall(SYS_futex, uaddr, futex_op, val, timeout, uaddr, val3);
return syscall(SYS_futex, uaddr, futex_op, static_cast<int>(val), timeout, nullptr, static_cast<int>(mask));
#else
static struct futex_map
static struct futex_manager
{
struct waiter
{
int val;
uint val;
uint mask;
std::condition_variable cv;
};
std::mutex mutex;
std::unordered_multimap<int*, waiter*, pointer_hash<int>> map;
std::unordered_multimap<volatile void*, waiter*, pointer_hash<volatile void, alignof(int)>> map;
int operator()(int* uaddr, int futex_op, int val, const timespec* timeout, int*, uint val3)
int operator()(volatile void* uaddr, int futex_op, uint val, const timespec* timeout, uint mask)
{
std::unique_lock<std::mutex> lock(mutex);
std::unique_lock lock(mutex);
switch (futex_op)
{
case FUTEX_WAIT:
case FUTEX_WAIT_PRIVATE:
{
val3 = -1;
// Fallthrough
mask = -1;
[[fallthrough]];
}
case FUTEX_WAIT_BITSET:
case FUTEX_WAIT_BITSET_PRIVATE:
{
if (*(volatile int*)uaddr != val)
if (*reinterpret_cast<volatile uint*>(uaddr) != val)
{
errno = EAGAIN;
return -1;
@@ -84,7 +87,7 @@ inline int futex(int* uaddr, int futex_op, int val, const timespec* timeout, int
waiter rec;
rec.val = val;
rec.mask = val3;
rec.mask = mask;
const auto& ref = *map.emplace(uaddr, &rec);
int res = 0;
@@ -107,25 +110,25 @@ inline int futex(int* uaddr, int futex_op, int val, const timespec* timeout, int
{
// TODO
}
map.erase(std::find(map.find(uaddr), map.end(), ref));
return res;
}
case FUTEX_WAKE:
case FUTEX_WAKE_PRIVATE:
{
val3 = -1;
// Fallthrough
mask = -1;
[[fallthrough]];
}
case FUTEX_WAKE_BITSET:
case FUTEX_WAKE_BITSET_PRIVATE:
{
int res = 0;
for (auto range = map.equal_range(uaddr); val && range.first != range.second; range.first++)
{
auto& entry = *range.first->second;
if (entry.mask & val3)
if (entry.mask & mask)
{
entry.cv.notify_one();
entry.mask = 0;
@@ -143,6 +146,149 @@ inline int futex(int* uaddr, int futex_op, int val, const timespec* timeout, int
}
} g_futex;
return g_futex(uaddr, futex_op, val, timeout, uaddr2, val3);
return g_futex(uaddr, futex_op, val, timeout, mask);
#endif
}
template <typename T, typename Pred>
bool balanced_wait_until(atomic_t<T>& var, u64 usec_timeout, Pred&& pred)
{
static_assert(sizeof(T) == 4 || sizeof(T) == 8);
const bool is_inf = usec_timeout > u64{UINT32_MAX / 1000} * 1000000;
// Optional second argument indicates that the predicate should try to retire
auto test_pred = [&](T& _new, auto... args)
{
T old = var.load();
while (true)
{
_new = old;
// Zero indicates failure without modifying the value
// Negative indicates failure but modifies the value
auto ret = std::invoke(std::forward<Pred>(pred), _new, args...);
if (LIKELY(!ret || var.compare_exchange(old, _new)))
{
return ret > 0;
}
}
};
T value;
#ifdef _WIN32
if (OptWaitOnAddress)
{
while (!test_pred(value))
{
if (OptWaitOnAddress(&var, &value, sizeof(T), is_inf ? INFINITE : usec_timeout / 1000))
{
if (!test_pred(value, nullptr))
{
return false;
}
break;
}
if (GetLastError() == ERROR_TIMEOUT)
{
// Retire
return test_pred(value, nullptr);
}
}
return true;
}
LARGE_INTEGER timeout;
timeout.QuadPart = usec_timeout * -10;
if (!usec_timeout || NtWaitForKeyedEvent(nullptr, &var, false, is_inf ? nullptr : &timeout))
{
// Timed out: retire
if (!test_pred(value, nullptr))
{
return false;
}
// Signaled in the last moment: restore balance
NtWaitForKeyedEvent(nullptr, &var, false, nullptr);
return true;
}
if (!test_pred(value, nullptr))
{
// Stolen notification: restore balance
NtReleaseKeyedEvent(nullptr, &var, false, nullptr);
return false;
}
return true;
#else
struct timespec timeout;
timeout.tv_sec = usec_timeout / 1000000;
timeout.tv_nsec = (usec_timeout % 1000000) * 1000;
while (!test_pred(value))
{
if (futex(&var, FUTEX_WAIT_PRIVATE, static_cast<u32>(value), is_inf ? nullptr : &timeout) == 0)
{
if (!test_pred(value, nullptr))
{
return false;
}
break;
}
switch (errno)
{
case EAGAIN: break;
case ETIMEDOUT: return test_pred(value, nullptr);
default: verify("Unknown futex error" HERE), 0;
}
}
return true;
#endif
}
template <bool All = false, typename T>
void balanced_awaken(atomic_t<T>& var, u32 weight)
{
static_assert(sizeof(T) == 4 || sizeof(T) == 8);
#ifdef _WIN32
if (OptWaitOnAddress)
{
if (All || weight > 3)
{
OptWakeByAddressAll(&var);
return;
}
for (u32 i = 0; i < weight; i++)
{
OptWakeByAddressSingle(&var);
}
return;
}
for (u32 i = 0; i < weight; i++)
{
NtReleaseKeyedEvent(nullptr, &var, false, nullptr);
}
#else
if (All || weight)
{
futex(&var, FUTEX_WAKE_PRIVATE, All ? INT_MAX : std::min<u32>(INT_MAX, weight));
}
return;
#endif
}
+22 -6
View File
@@ -13,29 +13,40 @@ bool utils::has_ssse3()
return g_value;
}
bool utils::has_sse41()
{
static const bool g_value = get_cpuid(0, 0)[0] >= 0x1 && get_cpuid(1, 0)[2] & 0x80000;
return g_value;
}
bool utils::has_avx()
{
static const bool g_value = get_cpuid(0, 0)[0] >= 0x1 && get_cpuid(1, 0)[2] & 0x10000000;
static const bool g_value = get_cpuid(0, 0)[0] >= 0x1 && get_cpuid(1, 0)[2] & 0x10000000 && (get_cpuid(1, 0)[2] & 0x0C000000) == 0x0C000000 && (get_xgetbv(0) & 0x6) == 0x6;
return g_value;
}
bool utils::has_avx2()
{
static const bool g_value = get_cpuid(0, 0)[0] >= 0x7 && get_cpuid(7, 0)[1] & 0x20;
static const bool g_value = get_cpuid(0, 0)[0] >= 0x7 && get_cpuid(7, 0)[1] & 0x20 && (get_cpuid(1, 0)[2] & 0x0C000000) == 0x0C000000 && (get_xgetbv(0) & 0x6) == 0x6;
return g_value;
}
bool utils::has_rtm()
{
// Check RTM and MPX extensions in order to filter out TSX on Haswell CPUs
static const bool g_value = get_cpuid(0, 0)[0] >= 0x7 && (get_cpuid(7, 0)[1] & 0x4800) == 0x4800;
static const bool g_value = get_cpuid(0, 0)[0] >= 0x7 && (get_cpuid(7, 0)[1] & 0x800) == 0x800;
return g_value;
}
bool utils::has_mpx()
{
static const bool g_value = get_cpuid(0, 0)[0] >= 0x7 && (get_cpuid(7, 0)[1] & 0x4000) == 0x4000;
return g_value;
}
bool utils::has_512()
{
// Check AVX512F, AVX512CD, AVX512DQ, AVX512BW, AVX512VL extensions (Skylake-X level support)
static const bool g_value = get_cpuid(0, 0)[0] >= 0x7 && (get_cpuid(7, 0)[1] & 0xd0030000) == 0xd0030000;
static const bool g_value = get_cpuid(0, 0)[0] >= 0x7 && (get_cpuid(7, 0)[1] & 0xd0030000) == 0xd0030000 && (get_cpuid(1,0)[2] & 0x0C000000) == 0x0C000000 && (get_xgetbv(0) & 0xe6) == 0xe6;
return g_value;
}
@@ -62,8 +73,9 @@ std::string utils::get_system_info()
brand = "Unknown CPU";
}
brand.erase(0, brand.find_first_not_of(' '));
brand.erase(brand.find_last_not_of('\0') + 1);
brand.erase(brand.find_last_not_of(' ') + 1);
brand.erase(0, brand.find_first_not_of(' '));
while (auto found = brand.find(" ") + 1)
{
@@ -108,6 +120,10 @@ std::string utils::get_system_info()
if (has_rtm())
{
result += " | TSX";
if (!has_mpx())
{
result += " disabled by default";
}
}
return result;
+15 -18
View File
@@ -16,35 +16,32 @@ namespace utils
return {0u+regs[0], 0u+regs[1], 0u+regs[2], 0u+regs[3]};
}
inline u64 get_xgetbv(u32 xcr)
{
#ifdef _MSC_VER
return _xgetbv(xcr);
#else
u32 eax, edx;
__asm__ volatile( "xgetbv" : "=a"(eax), "=d"(edx) : "c"(xcr));
return eax | (u64(edx) << 32);
#endif
}
bool has_ssse3();
bool has_sse41();
bool has_avx();
bool has_avx2();
bool has_rtm();
bool has_mpx();
bool has_512();
bool has_xop();
inline bool transaction_enter()
{
while (true)
{
const auto status = _xbegin();
if (status == _XBEGIN_STARTED)
{
return true;
}
if (!(status & _XABORT_RETRY))
{
return false;
}
}
}
std::string get_system_info();
}
+1259
View File
File diff suppressed because it is too large Load Diff
+56 -305
View File
@@ -9,9 +9,11 @@
#include <emmintrin.h>
#include <cstdint>
#include <cstddef>
#include <type_traits>
#include <utility>
#include <chrono>
#include <limits>
#include <array>
// Assume little-endian
@@ -19,31 +21,42 @@
#define IS_BE_MACHINE 0
#ifdef _MSC_VER
#define ASSUME(cond) __assume(cond)
#define ASSUME(...) __assume(__VA_ARGS__) // MSVC __assume ignores side-effects
#define LIKELY
#define UNLIKELY
#define SAFE_BUFFERS __declspec(safebuffers)
#define NEVER_INLINE __declspec(noinline)
#define FORCE_INLINE __forceinline
#else
#define ASSUME(cond) do { if (!(cond)) __builtin_unreachable(); } while (0)
#define LIKELY(cond) __builtin_expect(!!(cond), 1)
#define UNLIKELY(cond) __builtin_expect(!!(cond), 0)
#else // not _MSC_VER
#ifdef __clang__
#if defined(__has_builtin) && __has_builtin(__builtin_assume)
#pragma clang diagnostic ignored "-Wassume" // ignore the clang "side-effects ignored" warning
#define ASSUME(...) __builtin_assume(!!(__VA_ARGS__)) // __builtin_assume (supported by modern clang) ignores side-effects
#endif
#endif
#ifndef ASSUME // gcc and old clang
#define ASSUME(...) do { if (!(__VA_ARGS__)) __builtin_unreachable(); } while (0) // note: the compiler will generate code to evaluate "cond" if the expression is opaque
#endif
#define LIKELY(...) __builtin_expect(!!(__VA_ARGS__), 1)
#define UNLIKELY(...) __builtin_expect(!!(__VA_ARGS__), 0)
#define SAFE_BUFFERS
#define NEVER_INLINE __attribute__((noinline))
#define FORCE_INLINE __attribute__((always_inline)) inline
#endif
#endif // _MSC_VER
#define CHECK_SIZE(type, size) static_assert(sizeof(type) == size, "Invalid " #type " type size")
#define CHECK_ALIGN(type, align) static_assert(alignof(type) == align, "Invalid " #type " type alignment")
#define CHECK_MAX_SIZE(type, size) static_assert(sizeof(type) <= size, #type " type size is too big")
#define CHECK_SIZE_ALIGN(type, size, align) CHECK_SIZE(type, size); CHECK_ALIGN(type, align)
// Return 32 bit sizeof() to avoid widening/narrowing conversions with size_t
#define SIZE_32(...) static_cast<u32>(sizeof(__VA_ARGS__))
// Return 32 bit alignof() to avoid widening/narrowing conversions with size_t
#define ALIGN_32(...) static_cast<u32>(alignof(__VA_ARGS__))
// Variant pattern matching helper
#define MATCH(arg, ...) constexpr(std::is_same_v<std::decay_t<decltype(arg)>, __VA_ARGS__>)
#define CONCATENATE_DETAIL(x, y) x ## y
#define CONCATENATE(x, y) CONCATENATE_DETAIL(x, y)
@@ -53,14 +66,20 @@
#define HERE "\n(in file " __FILE__ ":" STRINGIZE(__LINE__) ")"
// Ensure that the expression evaluates to true. Obsolete.
//#define EXPECTS(...) do { if (!(__VA_ARGS__)) fmt::raw_error("Precondition failed: " #__VA_ARGS__ HERE); } while (0)
//#define ENSURES(...) do { if (!(__VA_ARGS__)) fmt::raw_error("Postcondition failed: " #__VA_ARGS__ HERE); } while (0)
#define DECLARE(...) decltype(__VA_ARGS__) __VA_ARGS__
#define STR_CASE(...) case __VA_ARGS__: return #__VA_ARGS__
#define ASSERT(...) do { if(!(__VA_ARGS__)) fmt::raw_error("Assertion failed: " STRINGIZE(__VA_ARGS__) HERE); } while(0)
#if defined(_DEBUG) || defined(_AUDIT)
#define AUDIT(...) ASSERT(__VA_ARGS__)
#else
#define AUDIT(...) ((void)0)
#endif
using schar = signed char;
using uchar = unsigned char;
using ushort = unsigned short;
@@ -69,7 +88,11 @@ using ulong = unsigned long;
using ullong = unsigned long long;
using llong = long long;
#if __APPLE__
using uptr = std::uint64_t;
#else
using uptr = std::uintptr_t;
#endif
using u8 = std::uint8_t;
using u16 = std::uint16_t;
@@ -87,7 +110,7 @@ using steady_clock = std::conditional<
namespace gsl
{
enum class byte : u8;
using std::byte;
}
// Formatting helper, type-specific preprocessing for improving safety and functionality
@@ -111,64 +134,9 @@ struct se_storage;
template <typename T, bool Se = true, std::size_t Align = alignof(T)>
class se_t;
template <typename T, std::size_t Size = sizeof(T)>
struct atomic_storage;
template <typename T1, typename T2, typename = void>
struct atomic_add;
template <typename T1, typename T2, typename = void>
struct atomic_sub;
template <typename T1, typename T2, typename = void>
struct atomic_and;
template <typename T1, typename T2, typename = void>
struct atomic_or;
template <typename T1, typename T2, typename = void>
struct atomic_xor;
template <typename T, typename = void>
struct atomic_pre_inc;
template <typename T, typename = void>
struct atomic_post_inc;
template <typename T, typename = void>
struct atomic_pre_dec;
template <typename T, typename = void>
struct atomic_post_dec;
template <typename T1, typename T2, typename = void>
struct atomic_test_and_set;
template <typename T1, typename T2, typename = void>
struct atomic_test_and_reset;
template <typename T1, typename T2, typename = void>
struct atomic_test_and_complement;
template <typename T>
class atomic_t;
#ifdef _MSC_VER
using std::void_t;
#else
namespace void_details
{
template <typename...>
struct make_void
{
using type = void;
};
}
template <typename... T>
using void_t = typename void_details::make_void<T...>::type;
#endif
// Extract T::simple_type if available, remove cv qualifiers
template <typename T, typename = void>
struct simple_type_helper
@@ -177,7 +145,7 @@ struct simple_type_helper
};
template <typename T>
struct simple_type_helper<T, void_t<typename T::simple_type>>
struct simple_type_helper<T, std::void_t<typename T::simple_type>>
{
using type = typename T::simple_type;
};
@@ -204,22 +172,6 @@ public:
}
};
// Bool wrapper for restricting bool result conversions
struct explicit_bool_t
{
const bool value;
constexpr explicit_bool_t(bool value)
: value(value)
{
}
explicit constexpr operator bool() const
{
return value;
}
};
#ifndef _MSC_VER
using u128 = __uint128_t;
using s128 = __int128_t;
@@ -435,14 +387,6 @@ CHECK_SIZE_ALIGN(f16, 2, 2);
using f32 = float;
using f64 = double;
struct ignore
{
template <typename T>
ignore(T)
{
}
};
template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
constexpr T align(const T& value, ullong align)
{
@@ -471,7 +415,7 @@ struct offset32_array
template <typename Arg>
static inline u32 index32(const Arg& arg)
{
return SIZE_32(std::remove_extent_t<T>) * static_cast<u32>(arg);
return u32{sizeof(std::remove_extent_t<T>)} * static_cast<u32>(arg);
}
};
@@ -481,7 +425,7 @@ struct offset32_array<std::array<T, N>>
template <typename Arg>
static inline u32 index32(const Arg& arg)
{
return SIZE_32(T) * static_cast<u32>(arg);
return u32{sizeof(T)} * static_cast<u32>(arg);
}
};
@@ -514,46 +458,6 @@ struct offset32_detail<T3 T4::*>
}
};
inline u32 cntlz32(u32 arg, bool nonzero = false)
{
#ifdef _MSC_VER
ulong res;
return _BitScanReverse(&res, arg) || nonzero ? res ^ 31 : 32;
#else
return arg || nonzero ? __builtin_clzll(arg) - 32 : 32;
#endif
}
inline u64 cntlz64(u64 arg, bool nonzero = false)
{
#ifdef _MSC_VER
ulong res;
return _BitScanReverse64(&res, arg) || nonzero ? res ^ 63 : 64;
#else
return arg || nonzero ? __builtin_clzll(arg) : 64;
#endif
}
inline u32 cnttz32(u32 arg, bool nonzero = false)
{
#ifdef _MSC_VER
ulong res;
return _BitScanForward(&res, arg) || nonzero ? res : 32;
#else
return arg || nonzero ? __builtin_ctzll(arg) : 32;
#endif
}
inline u64 cnttz64(u64 arg, bool nonzero = false)
{
#ifdef _MSC_VER
ulong res;
return _BitScanForward64(&res, arg) || nonzero ? res : 64;
#else
return arg || nonzero ? __builtin_ctzll(arg) : 64;
#endif
}
// Helper function, used by ""_u16, ""_u32, ""_u64
constexpr u8 to_u8(char c)
{
@@ -725,7 +629,7 @@ struct narrow_impl<From, To, std::enable_if_t<std::is_signed<From>::value && std
// Simple type enabled (TODO: allow for To as well)
template <typename From, typename To>
struct narrow_impl<From, To, void_t<typename From::simple_type>>
struct narrow_impl<From, To, std::void_t<typename From::simple_type>>
: narrow_impl<simple_t<From>, To>
{
};
@@ -757,42 +661,6 @@ constexpr u32 size32(const T (&)[Size], const char* msg = nullptr)
return static_cast<u32>(Size);
}
template <typename T1, typename = std::enable_if_t<std::is_integral<T1>::value>>
constexpr bool test(const T1& value)
{
return value != 0;
}
template <typename T1, typename T2, typename = std::enable_if_t<std::is_integral<T1>::value && std::is_integral<T2>::value>>
constexpr bool test(const T1& lhs, const T2& rhs)
{
return (lhs & rhs) != 0;
}
template <typename T, typename T2, typename = std::enable_if_t<std::is_integral<T>::value && std::is_integral<T2>::value>>
inline bool test_and_set(T& lhs, const T2& rhs)
{
const bool result = (lhs & rhs) != 0;
lhs |= rhs;
return result;
}
template <typename T, typename T2, typename = std::enable_if_t<std::is_integral<T>::value && std::is_integral<T2>::value>>
inline bool test_and_reset(T& lhs, const T2& rhs)
{
const bool result = (lhs & rhs) != 0;
lhs &= ~rhs;
return result;
}
template <typename T, typename T2, typename = std::enable_if_t<std::is_integral<T>::value && std::is_integral<T2>::value>>
inline bool test_and_complement(T& lhs, const T2& rhs)
{
const bool result = (lhs & rhs) != 0;
lhs ^= rhs;
return result;
}
// Simplified hash algorithm for pointers. May be used in std::unordered_(map|set).
template <typename T, std::size_t Align = alignof(T)>
struct pointer_hash
@@ -817,7 +685,7 @@ struct value_hash
template <template <typename> class TT, std::size_t S, std::size_t A = S>
struct alignas(A) any_pod
{
std::aligned_storage_t<S, A> data;
alignas(A) std::byte data[S];
any_pod() = default;
@@ -900,35 +768,6 @@ struct cmd64 : any64
static_assert(sizeof(cmd64) == 8 && std::is_pod<cmd64>::value, "Incorrect cmd64 type");
// Allows to define integer convertible to multiple types
template <typename T, T Value, typename T1 = void, typename... Ts>
struct multicast : multicast<T, Value, Ts...>
{
constexpr multicast()
: multicast<T, Value, Ts...>()
{
}
// Implicit conversion to desired type
constexpr operator T1() const
{
return static_cast<T1>(Value);
}
};
// Recursion terminator
template <typename T, T Value>
struct multicast<T, Value, void>
{
constexpr multicast() = default;
// Explicit conversion to base type
explicit constexpr operator T() const
{
return Value;
}
};
// Error code type (return type), implements error reporting. Could be a template.
struct error_code
{
@@ -953,26 +792,23 @@ struct error_code
};
template<typename ET>
struct is_error<ET, void_t<decltype(ET::__not_an_error)>> : std::false_type
struct is_error<ET, std::enable_if_t<sizeof(ET::__not_an_error) != 0>> : std::false_type
{
};
// Not an error constructor
template<typename ET, typename = decltype(ET::__not_an_error)>
error_code(const ET& value, std::nullptr_t = nullptr)
// Common constructor
template<typename ET>
error_code(const ET& value)
: value(static_cast<s32>(value))
{
}
// Error constructor
template<typename ET, typename = std::enable_if_t<is_error<ET>::value>>
error_code(const ET& value)
: value(error_report(fmt::get_type_info<fmt_unveil_t<ET>>(), fmt_unveil<ET>::get(value), nullptr, 0))
{
if constexpr(is_error<ET>::value)
{
this->value = error_report(fmt::get_type_info<fmt_unveil_t<ET>>(), fmt_unveil<ET>::get(value), nullptr, 0);
}
}
// Error constructor (2 args)
template<typename ET, typename T2, typename = std::enable_if_t<is_error<ET>::value>>
template<typename ET, typename T2>
error_code(const ET& value, const T2& value2)
: value(error_report(fmt::get_type_info<fmt_unveil_t<ET>>(), fmt_unveil<ET>::get(value), fmt::get_type_info<fmt_unveil_t<T2>>(), fmt_unveil<T2>::get(value2)))
{
@@ -992,93 +828,8 @@ constexpr FORCE_INLINE error_code::not_an_error not_an_error(const T& value)
}
// Synchronization helper (cache-friendly busy waiting)
inline void busy_wait(std::size_t count = 100)
inline void busy_wait(std::size_t cycles = 3000)
{
while (count--) _mm_pause();
const u64 s = __rdtsc();
do _mm_pause(); while (__rdtsc() - s < cycles);
}
// Rotate helpers
#if defined(__GNUG__)
inline u8 rol8(u8 x, u8 n)
{
u8 result = x;
__asm__("rolb %[n], %[result]" : [result] "+g" (result) : [n] "c" (n));
return result;
}
inline u8 ror8(u8 x, u8 n)
{
u8 result = x;
__asm__("rorb %[n], %[result]" : [result] "+g" (result) : [n] "c" (n));
return result;
}
inline u16 rol16(u16 x, u16 n)
{
u16 result = x;
__asm__("rolw %b[n], %[result]" : [result] "+g" (result) : [n] "c" (n));
return result;
}
inline u16 ror16(u16 x, u16 n)
{
u16 result = x;
__asm__("rorw %b[n], %[result]" : [result] "+g" (result) : [n] "c" (n));
return result;
}
inline u32 rol32(u32 x, u32 n)
{
u32 result = x;
__asm__("roll %b[n], %[result]" : [result] "+g" (result) : [n] "c" (n));
return result;
}
inline u32 ror32(u32 x, u32 n)
{
u32 result = x;
__asm__("rorl %b[n], %[result]" : [result] "+g" (result) : [n] "c" (n));
return result;
}
inline u64 rol64(u64 x, u64 n)
{
u64 result = x;
__asm__("rolq %b[n], %[result]" : [result] "+g" (result) : [n] "c" (n));
return result;
}
inline u64 ror64(u64 x, u64 n)
{
u64 result = x;
__asm__("rorq %b[n], %[result]" : [result] "+g" (result) : [n] "c" (n));
return result;
}
inline u64 umulh64(u64 a, u64 b)
{
u64 result;
__asm__("mulq %[b]" : "=d" (result) : [a] "a" (a), [b] "rm" (b));
return result;
}
inline s64 mulh64(s64 a, s64 b)
{
s64 result;
__asm__("imulq %[b]" : "=d" (result) : [a] "a" (a), [b] "rm" (b));
return result;
}
#elif defined(_MSC_VER)
inline u8 rol8(u8 x, u8 n) { return _rotl8(x, n); }
inline u8 ror8(u8 x, u8 n) { return _rotr8(x, n); }
inline u16 rol16(u16 x, u16 n) { return _rotl16(x, (u8)n); }
inline u16 ror16(u16 x, u16 n) { return _rotr16(x, (u8)n); }
inline u32 rol32(u32 x, u32 n) { return _rotl(x, (int)n); }
inline u32 ror32(u32 x, u32 n) { return _rotr(x, (int)n); }
inline u64 rol64(u64 x, u64 n) { return _rotl64(x, (int)n); }
inline u64 ror64(u64 x, u64 n) { return _rotr64(x, (int)n); }
inline u64 umulh64(u64 x, u64 y) { return __umulh(x, y); }
inline s64 mulh64(s64 x, s64 y) { return __mulh(x, y); }
#endif
-980
View File
@@ -1,980 +0,0 @@
#ifndef MAPBOX_UTIL_VARIANT_HPP
#define MAPBOX_UTIL_VARIANT_HPP
#include <cassert>
#include <cstddef> // size_t
#include <new> // operator new
#include <stdexcept> // runtime_error
#include <string>
#include <tuple>
#include <type_traits>
#include <typeinfo>
#include <utility>
#include "recursive_wrapper.hpp"
#include "variant_visitor.hpp"
// clang-format off
// [[deprecated]] is only available in C++14, use this for the time being
#if __cplusplus <= 201103L
# ifdef __GNUC__
# define MAPBOX_VARIANT_DEPRECATED __attribute__((deprecated))
# elif defined(_MSC_VER)
# define MAPBOX_VARIANT_DEPRECATED __declspec(deprecated)
# else
# define MAPBOX_VARIANT_DEPRECATED
# endif
#else
# define MAPBOX_VARIANT_DEPRECATED [[deprecated]]
#endif
#ifdef _MSC_VER
// https://msdn.microsoft.com/en-us/library/bw1hbe6y.aspx
# ifdef NDEBUG
# define VARIANT_INLINE __forceinline
# else
# define VARIANT_INLINE //__declspec(noinline)
# endif
#else
# ifdef NDEBUG
# define VARIANT_INLINE //inline __attribute__((always_inline))
# else
# define VARIANT_INLINE __attribute__((noinline))
# endif
#endif
// clang-format on
// Exceptions
#if defined( __EXCEPTIONS) || defined( _MSC_VER)
#define HAS_EXCEPTIONS
#endif
#define VARIANT_MAJOR_VERSION 1
#define VARIANT_MINOR_VERSION 1
#define VARIANT_PATCH_VERSION 0
#define VARIANT_VERSION (VARIANT_MAJOR_VERSION * 100000) + (VARIANT_MINOR_VERSION * 100) + (VARIANT_PATCH_VERSION)
//namespace mapbox {
// namespace util {
namespace std {
// XXX This should derive from std::logic_error instead of std::runtime_error.
// See https://github.com/mapbox/variant/issues/48 for details.
class bad_variant_access : public std::runtime_error
{
public:
explicit bad_variant_access(const std::string& what_arg)
: runtime_error(what_arg) {}
explicit bad_variant_access(const char* what_arg)
: runtime_error(what_arg) {}
}; // class bad_variant_access
namespace detail {
static constexpr std::size_t invalid_value = std::size_t(-1);
template <typename T, typename... Types>
struct direct_type;
template <typename T, typename First, typename... Types>
struct direct_type<T, First, Types...>
{
static constexpr std::size_t index = std::is_same<T, First>::value
? sizeof...(Types)
: direct_type<T, Types...>::index;
};
template <typename T>
struct direct_type<T>
{
static constexpr std::size_t index = invalid_value;
};
#if __cpp_lib_logical_traits >= 201510L
using std::disjunction;
#else
template <typename...>
struct disjunction : std::false_type {};
template <typename B1>
struct disjunction<B1> : B1 {};
template <typename B1, typename B2>
struct disjunction<B1, B2> : std::conditional<B1::value, B1, B2>::type {};
template <typename B1, typename... Bs>
struct disjunction<B1, Bs...> : std::conditional<B1::value, B1, disjunction<Bs...>>::type {};
#endif
template <typename T, typename... Types>
struct convertible_type;
template <typename T, typename First, typename... Types>
struct convertible_type<T, First, Types...>
{
static constexpr std::size_t index = std::is_convertible<T, First>::value
? disjunction<std::is_convertible<T, Types>...>::value ? invalid_value : sizeof...(Types)
: convertible_type<T, Types...>::index;
};
template <typename T>
struct convertible_type<T>
{
static constexpr std::size_t index = invalid_value;
};
template <typename T, typename... Types>
struct value_traits
{
using value_type = typename std::remove_const<typename std::remove_reference<T>::type>::type;
static constexpr std::size_t direct_index = direct_type<value_type, Types...>::index;
static constexpr bool is_direct = direct_index != invalid_value;
static constexpr std::size_t index = is_direct ? direct_index : convertible_type<value_type, Types...>::index;
static constexpr bool is_valid = index != invalid_value;
static constexpr std::size_t tindex = is_valid ? sizeof...(Types)-index : 0;
using target_type = typename std::tuple_element<tindex, std::tuple<void, Types...>>::type;
};
template <typename T, typename R = void>
struct enable_if_type
{
using type = R;
};
template <typename F, typename V, typename Enable = void>
struct result_of_unary_visit
{
using type = typename std::result_of<F(V&)>::type;
};
template <typename F, typename V>
struct result_of_unary_visit<F, V, typename enable_if_type<typename F::result_type>::type>
{
using type = typename F::result_type;
};
template <typename F, typename V, typename Enable = void>
struct result_of_binary_visit
{
using type = typename std::result_of<F(V&, V&)>::type;
};
template <typename F, typename V>
struct result_of_binary_visit<F, V, typename enable_if_type<typename F::result_type>::type>
{
using type = typename F::result_type;
};
template <std::size_t arg1, std::size_t... others>
struct static_max;
template <std::size_t arg>
struct static_max<arg>
{
static const std::size_t value = arg;
};
template <std::size_t arg1, std::size_t arg2, std::size_t... others>
struct static_max<arg1, arg2, others...>
{
static const std::size_t value = arg1 >= arg2 ? static_max<arg1, others...>::value : static_max<arg2, others...>::value;
};
template <typename... Types>
struct variant_helper;
template <typename T, typename... Types>
struct variant_helper<T, Types...>
{
VARIANT_INLINE static void destroy(const std::size_t type_index, void* data)
{
if (type_index == sizeof...(Types))
{
reinterpret_cast<T*>(data)->~T();
}
else
{
variant_helper<Types...>::destroy(type_index, data);
}
}
VARIANT_INLINE static void move(const std::size_t old_type_index, void* old_value, void* new_value)
{
if (old_type_index == sizeof...(Types))
{
new (new_value) T(std::move(*reinterpret_cast<T*>(old_value)));
}
else
{
variant_helper<Types...>::move(old_type_index, old_value, new_value);
}
}
VARIANT_INLINE static void copy(const std::size_t old_type_index, const void* old_value, void* new_value)
{
if (old_type_index == sizeof...(Types))
{
new (new_value) T(*reinterpret_cast<const T*>(old_value));
}
else
{
variant_helper<Types...>::copy(old_type_index, old_value, new_value);
}
}
};
template <>
struct variant_helper<>
{
VARIANT_INLINE static void destroy(const std::size_t, void*) {}
VARIANT_INLINE static void move(const std::size_t, void*, void*) {}
VARIANT_INLINE static void copy(const std::size_t, const void*, void*) {}
};
template <typename T>
struct unwrapper
{
static T const& apply_const(T const& obj) { return obj; }
static T& apply(T& obj) { return obj; }
};
template <typename T>
struct unwrapper<recursive_wrapper<T>>
{
static auto apply_const(recursive_wrapper<T> const& obj)
-> typename recursive_wrapper<T>::type const&
{
return obj.get();
}
static auto apply(recursive_wrapper<T>& obj)
-> typename recursive_wrapper<T>::type&
{
return obj.get();
}
};
template <typename T>
struct unwrapper<std::reference_wrapper<T>>
{
static auto apply_const(std::reference_wrapper<T> const& obj)
-> typename std::reference_wrapper<T>::type const&
{
return obj.get();
}
static auto apply(std::reference_wrapper<T>& obj)
-> typename std::reference_wrapper<T>::type&
{
return obj.get();
}
};
template <typename F, typename V, typename R, typename... Types>
struct dispatcher;
template <typename F, typename V, typename R, typename T, typename... Types>
struct dispatcher<F, V, R, T, Types...>
{
VARIANT_INLINE static R apply_const(V const& v, F&& f)
{
if (v.template is<T>())
{
return f(unwrapper<T>::apply_const(v.template get_unchecked<T>()));
}
else
{
return dispatcher<F, V, R, Types...>::apply_const(v, std::forward<F>(f));
}
}
VARIANT_INLINE static R apply(V& v, F&& f)
{
if (v.template is<T>())
{
return f(unwrapper<T>::apply(v.template get_unchecked<T>()));
}
else
{
return dispatcher<F, V, R, Types...>::apply(v, std::forward<F>(f));
}
}
};
template <typename F, typename V, typename R, typename T>
struct dispatcher<F, V, R, T>
{
VARIANT_INLINE static R apply_const(V const& v, F&& f)
{
return f(unwrapper<T>::apply_const(v.template get_unchecked<T>()));
}
VARIANT_INLINE static R apply(V& v, F&& f)
{
return f(unwrapper<T>::apply(v.template get_unchecked<T>()));
}
};
template <typename F, typename V, typename R, typename T, typename... Types>
struct binary_dispatcher_rhs;
template <typename F, typename V, typename R, typename T0, typename T1, typename... Types>
struct binary_dispatcher_rhs<F, V, R, T0, T1, Types...>
{
VARIANT_INLINE static R apply_const(V const& lhs, V const& rhs, F&& f)
{
if (rhs.template is<T1>()) // call binary functor
{
return f(unwrapper<T0>::apply_const(lhs.template get_unchecked<T0>()),
unwrapper<T1>::apply_const(rhs.template get_unchecked<T1>()));
}
else
{
return binary_dispatcher_rhs<F, V, R, T0, Types...>::apply_const(lhs, rhs, std::forward<F>(f));
}
}
VARIANT_INLINE static R apply(V& lhs, V& rhs, F&& f)
{
if (rhs.template is<T1>()) // call binary functor
{
return f(unwrapper<T0>::apply(lhs.template get_unchecked<T0>()),
unwrapper<T1>::apply(rhs.template get_unchecked<T1>()));
}
else
{
return binary_dispatcher_rhs<F, V, R, T0, Types...>::apply(lhs, rhs, std::forward<F>(f));
}
}
};
template <typename F, typename V, typename R, typename T0, typename T1>
struct binary_dispatcher_rhs<F, V, R, T0, T1>
{
VARIANT_INLINE static R apply_const(V const& lhs, V const& rhs, F&& f)
{
return f(unwrapper<T0>::apply_const(lhs.template get_unchecked<T0>()),
unwrapper<T1>::apply_const(rhs.template get_unchecked<T1>()));
}
VARIANT_INLINE static R apply(V& lhs, V& rhs, F&& f)
{
return f(unwrapper<T0>::apply(lhs.template get_unchecked<T0>()),
unwrapper<T1>::apply(rhs.template get_unchecked<T1>()));
}
};
template <typename F, typename V, typename R, typename T, typename... Types>
struct binary_dispatcher_lhs;
template <typename F, typename V, typename R, typename T0, typename T1, typename... Types>
struct binary_dispatcher_lhs<F, V, R, T0, T1, Types...>
{
VARIANT_INLINE static R apply_const(V const& lhs, V const& rhs, F&& f)
{
if (lhs.template is<T1>()) // call binary functor
{
return f(unwrapper<T1>::apply_const(lhs.template get_unchecked<T1>()),
unwrapper<T0>::apply_const(rhs.template get_unchecked<T0>()));
}
else
{
return binary_dispatcher_lhs<F, V, R, T0, Types...>::apply_const(lhs, rhs, std::forward<F>(f));
}
}
VARIANT_INLINE static R apply(V& lhs, V& rhs, F&& f)
{
if (lhs.template is<T1>()) // call binary functor
{
return f(unwrapper<T1>::apply(lhs.template get_unchecked<T1>()),
unwrapper<T0>::apply(rhs.template get_unchecked<T0>()));
}
else
{
return binary_dispatcher_lhs<F, V, R, T0, Types...>::apply(lhs, rhs, std::forward<F>(f));
}
}
};
template <typename F, typename V, typename R, typename T0, typename T1>
struct binary_dispatcher_lhs<F, V, R, T0, T1>
{
VARIANT_INLINE static R apply_const(V const& lhs, V const& rhs, F&& f)
{
return f(unwrapper<T1>::apply_const(lhs.template get_unchecked<T1>()),
unwrapper<T0>::apply_const(rhs.template get_unchecked<T0>()));
}
VARIANT_INLINE static R apply(V& lhs, V& rhs, F&& f)
{
return f(unwrapper<T1>::apply(lhs.template get_unchecked<T1>()),
unwrapper<T0>::apply(rhs.template get_unchecked<T0>()));
}
};
template <typename F, typename V, typename R, typename... Types>
struct binary_dispatcher;
template <typename F, typename V, typename R, typename T, typename... Types>
struct binary_dispatcher<F, V, R, T, Types...>
{
VARIANT_INLINE static R apply_const(V const& v0, V const& v1, F&& f)
{
if (v0.template is<T>())
{
if (v1.template is<T>())
{
return f(unwrapper<T>::apply_const(v0.template get_unchecked<T>()),
unwrapper<T>::apply_const(v1.template get_unchecked<T>())); // call binary functor
}
else
{
return binary_dispatcher_rhs<F, V, R, T, Types...>::apply_const(v0, v1, std::forward<F>(f));
}
}
else if (v1.template is<T>())
{
return binary_dispatcher_lhs<F, V, R, T, Types...>::apply_const(v0, v1, std::forward<F>(f));
}
return binary_dispatcher<F, V, R, Types...>::apply_const(v0, v1, std::forward<F>(f));
}
VARIANT_INLINE static R apply(V& v0, V& v1, F&& f)
{
if (v0.template is<T>())
{
if (v1.template is<T>())
{
return f(unwrapper<T>::apply(v0.template get_unchecked<T>()),
unwrapper<T>::apply(v1.template get_unchecked<T>())); // call binary functor
}
else
{
return binary_dispatcher_rhs<F, V, R, T, Types...>::apply(v0, v1, std::forward<F>(f));
}
}
else if (v1.template is<T>())
{
return binary_dispatcher_lhs<F, V, R, T, Types...>::apply(v0, v1, std::forward<F>(f));
}
return binary_dispatcher<F, V, R, Types...>::apply(v0, v1, std::forward<F>(f));
}
};
template <typename F, typename V, typename R, typename T>
struct binary_dispatcher<F, V, R, T>
{
VARIANT_INLINE static R apply_const(V const& v0, V const& v1, F&& f)
{
return f(unwrapper<T>::apply_const(v0.template get_unchecked<T>()),
unwrapper<T>::apply_const(v1.template get_unchecked<T>())); // call binary functor
}
VARIANT_INLINE static R apply(V& v0, V& v1, F&& f)
{
return f(unwrapper<T>::apply(v0.template get_unchecked<T>()),
unwrapper<T>::apply(v1.template get_unchecked<T>())); // call binary functor
}
};
// comparator functors
struct equal_comp
{
template <typename T>
bool operator()(T const& lhs, T const& rhs) const
{
return lhs == rhs;
}
};
struct less_comp
{
template <typename T>
bool operator()(T const& lhs, T const& rhs) const
{
return lhs < rhs;
}
};
template <typename Variant, typename Comp>
class comparer
{
public:
explicit comparer(Variant const& lhs) noexcept
: lhs_(lhs) {}
comparer& operator=(comparer const&) = delete;
// visitor
template <typename T>
bool operator()(T const& rhs_content) const
{
T const& lhs_content = lhs_.template get_unchecked<T>();
return Comp()(lhs_content, rhs_content);
}
private:
Variant const& lhs_;
};
} // namespace detail
struct no_init
{
};
template <typename... Types>
class variant
{
static_assert(sizeof...(Types) > 0, "Template parameter type list of variant can not be empty");
static_assert(!detail::disjunction<std::is_reference<Types>...>::value, "Variant can not hold reference types. Maybe use std::reference_wrapper?");
private:
static const std::size_t data_size = detail::static_max<sizeof(Types)...>::value;
static const std::size_t data_align = detail::static_max<alignof(Types)...>::value;
using first_type = typename std::tuple_element<0, std::tuple<Types...>>::type;
using data_type = typename std::aligned_storage<data_size, data_align>::type;
using helper_type = detail::variant_helper<Types...>;
std::size_t type_index;
data_type data;
public:
VARIANT_INLINE variant() noexcept(std::is_nothrow_default_constructible<first_type>::value)
: type_index(sizeof...(Types)-1)
{
static_assert(std::is_default_constructible<first_type>::value, "First type in variant must be default constructible to allow default construction of variant");
new (&data) first_type();
}
VARIANT_INLINE variant(no_init) noexcept
: type_index(detail::invalid_value) {}
// http://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers
template <typename T, typename Traits = detail::value_traits<T, Types...>,
typename Enable = typename std::enable_if<Traits::is_valid>::type>
VARIANT_INLINE variant(T&& val) noexcept(std::is_nothrow_constructible<typename Traits::target_type, T&&>::value)
: type_index(Traits::index)
{
new (&data) typename Traits::target_type(std::forward<T>(val));
}
VARIANT_INLINE variant(variant<Types...> const& old)
: type_index(old.type_index)
{
helper_type::copy(old.type_index, &old.data, &data);
}
VARIANT_INLINE variant(variant<Types...>&& old) noexcept(std::is_nothrow_move_constructible<std::tuple<Types...>>::value)
: type_index(old.type_index)
{
helper_type::move(old.type_index, &old.data, &data);
}
private:
VARIANT_INLINE void copy_assign(variant<Types...> const& rhs)
{
helper_type::destroy(type_index, &data);
type_index = detail::invalid_value;
helper_type::copy(rhs.type_index, &rhs.data, &data);
type_index = rhs.type_index;
}
VARIANT_INLINE void move_assign(variant<Types...>&& rhs)
{
helper_type::destroy(type_index, &data);
type_index = detail::invalid_value;
helper_type::move(rhs.type_index, &rhs.data, &data);
type_index = rhs.type_index;
}
public:
VARIANT_INLINE variant<Types...>& operator=(variant<Types...>&& other)
{
move_assign(std::move(other));
return *this;
}
VARIANT_INLINE variant<Types...>& operator=(variant<Types...> const& other)
{
copy_assign(other);
return *this;
}
// conversions
// move-assign
template <typename T>
VARIANT_INLINE variant<Types...>& operator=(T&& rhs) noexcept
{
variant<Types...> temp(std::forward<T>(rhs));
move_assign(std::move(temp));
return *this;
}
// copy-assign
template <typename T>
VARIANT_INLINE variant<Types...>& operator=(T const& rhs)
{
variant<Types...> temp(rhs);
copy_assign(temp);
return *this;
}
template <typename T, typename std::enable_if<
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE bool is() const
{
return type_index == detail::direct_type<T, Types...>::index;
}
template <typename T, typename std::enable_if<
(detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE bool is() const
{
return type_index == detail::direct_type<recursive_wrapper<T>, Types...>::index;
}
VARIANT_INLINE bool valid() const
{
return type_index != detail::invalid_value;
}
template <typename T, typename... Args>
VARIANT_INLINE void set(Args&&... args)
{
helper_type::destroy(type_index, &data);
type_index = detail::invalid_value;
new (&data) T(std::forward<Args>(args)...);
type_index = detail::direct_type<T, Types...>::index;
}
// get_unchecked<T>()
template <typename T, typename std::enable_if<
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get_unchecked()
{
return *reinterpret_cast<T*>(&data);
}
#ifdef HAS_EXCEPTIONS
// get<T>()
template <typename T, typename std::enable_if<
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get()
{
if (type_index == detail::direct_type<T, Types...>::index)
{
return *reinterpret_cast<T*>(&data);
}
else
{
throw bad_variant_access("in get<T>()");
}
}
#endif
template <typename T, typename std::enable_if<
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get_unchecked() const
{
return *reinterpret_cast<T const*>(&data);
}
#ifdef HAS_EXCEPTIONS
template <typename T, typename std::enable_if<
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get() const
{
if (type_index == detail::direct_type<T, Types...>::index)
{
return *reinterpret_cast<T const*>(&data);
}
else
{
throw bad_variant_access("in get<T>()");
}
}
#endif
// get_unchecked<T>() - T stored as recursive_wrapper<T>
template <typename T, typename std::enable_if<
(detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get_unchecked()
{
return (*reinterpret_cast<recursive_wrapper<T>*>(&data)).get();
}
#ifdef HAS_EXCEPTIONS
// get<T>() - T stored as recursive_wrapper<T>
template <typename T, typename std::enable_if<
(detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get()
{
if (type_index == detail::direct_type<recursive_wrapper<T>, Types...>::index)
{
return (*reinterpret_cast<recursive_wrapper<T>*>(&data)).get();
}
else
{
throw bad_variant_access("in get<T>()");
}
}
#endif
template <typename T, typename std::enable_if<
(detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get_unchecked() const
{
return (*reinterpret_cast<recursive_wrapper<T> const*>(&data)).get();
}
#ifdef HAS_EXCEPTIONS
template <typename T, typename std::enable_if<
(detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get() const
{
if (type_index == detail::direct_type<recursive_wrapper<T>, Types...>::index)
{
return (*reinterpret_cast<recursive_wrapper<T> const*>(&data)).get();
}
else
{
throw bad_variant_access("in get<T>()");
}
}
#endif
// get_unchecked<T>() - T stored as std::reference_wrapper<T>
template <typename T, typename std::enable_if<
(detail::direct_type<std::reference_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get_unchecked()
{
return (*reinterpret_cast<std::reference_wrapper<T>*>(&data)).get();
}
#ifdef HAS_EXCEPTIONS
// get<T>() - T stored as std::reference_wrapper<T>
template <typename T, typename std::enable_if<
(detail::direct_type<std::reference_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get()
{
if (type_index == detail::direct_type<std::reference_wrapper<T>, Types...>::index)
{
return (*reinterpret_cast<std::reference_wrapper<T>*>(&data)).get();
}
else
{
throw bad_variant_access("in get<T>()");
}
}
#endif
template <typename T, typename std::enable_if<
(detail::direct_type<std::reference_wrapper<T const>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get_unchecked() const
{
return (*reinterpret_cast<std::reference_wrapper<T const> const*>(&data)).get();
}
#ifdef HAS_EXCEPTIONS
template <typename T, typename std::enable_if<
(detail::direct_type<std::reference_wrapper<T const>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get() const
{
if (type_index == detail::direct_type<std::reference_wrapper<T const>, Types...>::index)
{
return (*reinterpret_cast<std::reference_wrapper<T const> const*>(&data)).get();
}
else
{
throw bad_variant_access("in get<T>()");
}
}
#endif
// This function is deprecated because it returns an internal index field.
// Use which() instead.
MAPBOX_VARIANT_DEPRECATED VARIANT_INLINE std::size_t get_type_index() const
{
return type_index;
}
VARIANT_INLINE int which() const noexcept
{
return static_cast<int>(sizeof...(Types)-type_index - 1);
}
template <typename T, typename std::enable_if<
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE static constexpr int which() noexcept
{
return static_cast<int>(sizeof...(Types)-detail::direct_type<T, Types...>::index - 1);
}
// visitor
// unary
template <typename F, typename V, typename R = typename detail::result_of_unary_visit<F, first_type>::type>
auto VARIANT_INLINE static visit(V const& v, F&& f)
-> decltype(detail::dispatcher<F, V, R, Types...>::apply_const(v, std::forward<F>(f)))
{
return detail::dispatcher<F, V, R, Types...>::apply_const(v, std::forward<F>(f));
}
// non-const
template <typename F, typename V, typename R = typename detail::result_of_unary_visit<F, first_type>::type>
auto VARIANT_INLINE static visit(V& v, F&& f)
-> decltype(detail::dispatcher<F, V, R, Types...>::apply(v, std::forward<F>(f)))
{
return detail::dispatcher<F, V, R, Types...>::apply(v, std::forward<F>(f));
}
// binary
// const
template <typename F, typename V, typename R = typename detail::result_of_binary_visit<F, first_type>::type>
auto VARIANT_INLINE static binary_visit(V const& v0, V const& v1, F&& f)
-> decltype(detail::binary_dispatcher<F, V, R, Types...>::apply_const(v0, v1, std::forward<F>(f)))
{
return detail::binary_dispatcher<F, V, R, Types...>::apply_const(v0, v1, std::forward<F>(f));
}
// non-const
template <typename F, typename V, typename R = typename detail::result_of_binary_visit<F, first_type>::type>
auto VARIANT_INLINE static binary_visit(V& v0, V& v1, F&& f)
-> decltype(detail::binary_dispatcher<F, V, R, Types...>::apply(v0, v1, std::forward<F>(f)))
{
return detail::binary_dispatcher<F, V, R, Types...>::apply(v0, v1, std::forward<F>(f));
}
// match
// unary
template <typename... Fs>
auto VARIANT_INLINE match(Fs&&... fs) const
-> decltype(variant::visit(*this, ::std::make_visitor(std::forward<Fs>(fs)...)))
{
return variant::visit(*this, ::std::make_visitor(std::forward<Fs>(fs)...));
}
// non-const
template <typename... Fs>
auto VARIANT_INLINE match(Fs&&... fs)
-> decltype(variant::visit(*this, ::std::make_visitor(std::forward<Fs>(fs)...)))
{
return variant::visit(*this, ::std::make_visitor(std::forward<Fs>(fs)...));
}
~variant() noexcept // no-throw destructor
{
helper_type::destroy(type_index, &data);
}
// comparison operators
// equality
VARIANT_INLINE bool operator==(variant const& rhs) const
{
assert(valid() && rhs.valid());
if (this->which() != rhs.which())
{
return false;
}
detail::comparer<variant, detail::equal_comp> visitor(*this);
return visit(rhs, visitor);
}
VARIANT_INLINE bool operator!=(variant const& rhs) const
{
return !(*this == rhs);
}
// less than
VARIANT_INLINE bool operator<(variant const& rhs) const
{
assert(valid() && rhs.valid());
if (this->which() != rhs.which())
{
return this->which() < rhs.which();
}
detail::comparer<variant, detail::less_comp> visitor(*this);
return visit(rhs, visitor);
}
VARIANT_INLINE bool operator>(variant const& rhs) const
{
return rhs < *this;
}
VARIANT_INLINE bool operator<=(variant const& rhs) const
{
return !(*this > rhs);
}
VARIANT_INLINE bool operator>=(variant const& rhs) const
{
return !(*this < rhs);
}
};
// unary visitor interface
// const
template <typename F, typename V>
auto VARIANT_INLINE apply_visitor(F&& f, V const& v) -> decltype(V::visit(v, std::forward<F>(f)))
{
return V::visit(v, std::forward<F>(f));
}
// non-const
template <typename F, typename V>
auto VARIANT_INLINE apply_visitor(F&& f, V& v) -> decltype(V::visit(v, std::forward<F>(f)))
{
return V::visit(v, std::forward<F>(f));
}
// binary visitor interface
// const
template <typename F, typename V>
auto VARIANT_INLINE apply_visitor(F&& f, V const& v0, V const& v1) -> decltype(V::binary_visit(v0, v1, std::forward<F>(f)))
{
return V::binary_visit(v0, v1, std::forward<F>(f));
}
// non-const
template <typename F, typename V>
auto VARIANT_INLINE apply_visitor(F&& f, V& v0, V& v1) -> decltype(V::binary_visit(v0, v1, std::forward<F>(f)))
{
return V::binary_visit(v0, v1, std::forward<F>(f));
}
// getter interface
#ifdef HAS_EXCEPTIONS
template <typename ResultType, typename T>
auto get(T& var)->decltype(var.template get<ResultType>())
{
return var.template get<ResultType>();
}
#endif
template <typename ResultType, typename T>
ResultType& get_unchecked(T& var)
{
return var.template get_unchecked<ResultType>();
}
#ifdef HAS_EXCEPTIONS
template <typename ResultType, typename T>
auto get(T const& var)->decltype(var.template get<ResultType>())
{
return var.template get<ResultType>();
}
#endif
template <typename ResultType, typename T>
ResultType const& get_unchecked(T const& var)
{
return var.template get_unchecked<ResultType>();
}
}
// } // namespace util
//} // namespace mapbox
#endif // MAPBOX_UTIL_VARIANT_HPP
-45
View File
@@ -1,45 +0,0 @@
#ifndef MAPBOX_UTIL_VARIANT_VISITOR_HPP
#define MAPBOX_UTIL_VARIANT_VISITOR_HPP
#include <utility>
//namespace mapbox {
//namespace util {
namespace std {
template <typename... Fns>
struct visitor;
template <typename Fn>
struct visitor<Fn> : Fn
{
using Fn::operator();
template<typename T>
visitor(T&& fn) : Fn(std::forward<T>(fn)) {}
};
template <typename Fn, typename... Fns>
struct visitor<Fn, Fns...> : Fn, visitor<Fns...>
{
using Fn::operator();
using visitor<Fns...>::operator();
template<typename T, typename... Ts>
visitor(T&& fn, Ts&&... fns)
: Fn(std::forward<T>(fn))
, visitor<Fns...>(std::forward<Ts>(fns)...) {}
};
template <typename... Fns>
visitor<typename std::decay<Fns>::type...> make_visitor(Fns&&... fns)
{
return visitor<typename std::decay<Fns>::type...>
(std::forward<Fns>(fns)...);
}
}
//} // namespace util
//} // namespace mapbox
#endif // MAPBOX_UTIL_VARIANT_VISITOR_HPP
+4 -8
View File
@@ -1,8 +1,4 @@
if(WIN32 AND NOT VULKAN_PREBUILT)
set(BUILD_TESTS OFF CACHE BOOL "Build tests" FORCE)
set(BUILD_DEMOS OFF CACHE BOOL "Build demos" FORCE)
set(BUILD_LAYERS OFF CACHE BOOL "Build demos" FORCE)
set(BUILD_VKJSON OFF CACHE BOOL "Build demos" FORCE)
add_subdirectory( Vulkan-LoaderAndValidationLayers )
add_subdirectory( glslang )
endif()
set(SKIP_GLSLANG_INSTALL ON CACHE BOOL "Skip installation" FORCE)
set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL "Builds glslangValidator and spirv-remap" FORCE)
set(ENABLE_HLSL OFF CACHE BOOL "Enables HLSL input support" FORCE)
add_subdirectory(glslang)
-67
View File
@@ -1,67 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{58B40697-B15E-429E-B325-D52C28AEBCBF}</ProjectGuid>
<Keyword>MakeFileProj</Keyword>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<NMakeBuildCommandLine>start /W /B pre-build.bat
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DBUILD_TESTS=OFF -DBUILD_DEMOS=OFF -DBUILD_LAYERS=OFF -DBUILD_VKJSON=OFF ../Vulkan-LoaderAndValidationLayers
msbuild.exe ALL_BUILD.vcxproj /t:build /p:Configuration=Release /m</NMakeBuildCommandLine>
<NMakeCleanCommandLine>cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DBUILD_TESTS=OFF -DBUILD_DEMOS=OFF -DBUILD_LAYERS=OFF -DBUILD_VKJSON=OFF ../Vulkan-LoaderAndValidationLayers
msbuild.exe ALL_BUILD.vcxproj /t:clean /p:Configuration=Release /m</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>start /W /B pre-build.bat
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DBUILD_TESTS=OFF -DBUILD_DEMOS=OFF -DBUILD_LAYERS=OFF -DBUILD_VKJSON=OFF ../Vulkan-LoaderAndValidationLayers
msbuild.exe ALL_BUILD.vcxproj /t:rebuild /p:Configuration=Release /m
</NMakeReBuildCommandLine>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<NMakeBuildCommandLine>start /W /B pre-build.bat
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DBUILD_TESTS=OFF -DBUILD_DEMOS=OFF -DBUILD_LAYERS=OFF -DBUILD_VKJSON=OFF ../Vulkan-LoaderAndValidationLayers
msbuild.exe ALL_BUILD.vcxproj /t:build /p:Configuration=Debug /m</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>start /W /B pre-build.bat
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DBUILD_TESTS=OFF -DBUILD_DEMOS=OFF -DBUILD_LAYERS=OFF -DBUILD_VKJSON=OFF ../Vulkan-LoaderAndValidationLayers
msbuild.exe ALL_BUILD.vcxproj /t:rebuild /p:Configuration=Debug /m</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DBUILD_TESTS=OFF -DBUILD_DEMOS=OFF -DBUILD_LAYERS=OFF -DBUILD_VKJSON=OFF ../Vulkan-LoaderAndValidationLayers
msbuild.exe ALL_BUILD.vcxproj /t:clean /p:Configuration=Debug /m</NMakeCleanCommandLine>
</PropertyGroup>
<ItemDefinitionGroup>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
-13
View File
@@ -1,13 +0,0 @@
@ECHO OFF
REM Setting up dummy git helper
MKDIR ..\Vulkan-LoaderAndValidationLayers\external\glslang\External\spirv-tools
SET header="@ECHO off"
SET content="ECHO unused"
ECHO %header:"=% > git.bat
ECHO %content:"=% >> git.bat
COPY /Y git.bat ..\Vulkan-LoaderAndValidationLayers\external\glslang\External\spirv-tools\git.bat
REM Set up gitignore
SET ignored="*"
ECHO %ignored:"=% > ..\Vulkan-LoaderAndValidationLayers\external\glslang\External\spirv-tools\.gitignore
+8 -8
View File
@@ -19,12 +19,12 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -39,24 +39,24 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<NMakeBuildCommandLine>cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ../glslang
<NMakeBuildCommandLine>cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ../glslang
msbuild.exe ALL_BUILD.vcxproj /t:build /p:Configuration=Release /m</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ../glslang
<NMakeReBuildCommandLine>cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ../glslang
msbuild.exe ALL_BUILD.vcxproj /t:rebuild /p:Configuration=Release /m</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ../glslang
<NMakeCleanCommandLine>cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ../glslang
msbuild.exe ALL_BUILD.vcxproj /t:clean /p:Configuration=Release /m</NMakeCleanCommandLine>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<NMakeBuildCommandLine>
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ../glslang
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ../glslang
msbuild.exe ALL_BUILD.vcxproj /t:build /p:Configuration=Debug /m
</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ../glslang
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ../glslang
msbuild.exe ALL_BUILD.vcxproj /t:rebuild /p:Configuration=Debug /m
</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ../glslang
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ../glslang
msbuild.exe ALL_BUILD.vcxproj /t:clean /p:Configuration=Debug /m
</NMakeCleanCommandLine>
</PropertyGroup>

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