Commit Graph

8496 Commits

Author SHA1 Message Date
Gliniak
1da37db584 [Winkey] Passthrough: Added support for hid key codes.
Thanks Devildwarf for initial implementation
2026-04-12 09:47:12 +02:00
Herman S.
65b74819aa [Threading] Implement priority boost on wake
When a thread wakes from a kernel wait, the Xenon scheduler boosts its
effective priority by the increment passed to the signaling call
(KeSetEvent, KeReleaseSemaphore, KeReleaseMutant). The boost is clamped
to the per-thread max_dynamic_priority cap, respects the guest
boost_disabled flag, and is drained on the next quantum expiry.
Guest KTHREAD priority fields are now initialized from parent process
defaults, and the previously unknown fields involved have been renamed
to match their identified purpose.
2026-04-11 17:05:05 +09:00
Herman S.
b3d8a21b72 [Threading] Add thread priority mapping with timer-driven quantum decay
And default ignore_thread_priorities to false.

Map Xenon's 0-31 priority range across all 5 host priority levels
instead of collapsing 0-17 into kNormal.

Use timer-driven quantum decay (~20ms period) matching Xenon's
60-quantum / 3-per-tick cycle to prevent starvation by gradually lowering
effective priority for non-real-time threads (< 18), piggybacking on the
existing 1ms timestamp timer.
2026-04-10 08:21:42 +09:00
Herman S.
61c8eb0707 [Threading] Improve same-CPU spinlock contention
Spinlock acquire now checks if the lock holder shares the same guest
CPU and yields more aggressively (Sleep(0)) when contending on the
same Xenon HW thread, which should better approximate real kernel's
implicit serialization.

Child threads without an explicit affinity mask now inherit the
parent's guest CPU assignment instead of round-robining, so the
spinlock check correctly identifies parent-child co-location.
2026-04-09 21:14:39 +09:00
Adrian
e23376afcc [Kernel] Fixed NtSignalAndWaitForSingleObjectEx prototype 2026-04-07 20:05:12 +02:00
Herman S.
4acda223db [CPU] Remove ATOMIC_EXCHANGE opcode (dead code) 2026-04-08 00:05:29 +09:00
Herman S.
ade7e610bb [XMA] Fix stall detection false positive in Work loop
Stall detection was triggering during multi-pass subframe consumption
(e.g. stereo with subframe_decode_count < total subframes), breaking
audio looping in games like Tomb Raider. Now only detects a stall when
no subframes were pending, so Consume-only iterations aren't mistaken
for no-progress cycles. Fixes Halo 4 without regressing Tomb Raider.
2026-04-07 23:14:08 +09:00
goldislead
8a49c0380f [GPU] EVENT_WRITE_ZPD relaxed END detection
Fixes culling flicker in 555307D5.
2026-04-04 22:18:17 +02:00
goldislead
9c00ce9366 [GPU] EVENT_WRITE_ZPD batched sample accumulation cvar 2026-04-04 19:29:52 +02:00
Gliniak
7e39a7018f [Memory] Added heap offset to alignment guards
- This was causing page deallocation on proper allocations
2026-03-31 20:43:49 +02:00
Wunkolo
c383d049ec [CPU] Implement AND+NOT folding into AND_NOT
Detect dependent `AND` and `NOT` IR sequences and combine them into a
singular `AND_NOT` opcode. The later dead-code-elimination-pass will
get rid of the left-over `NOT` opcode if nothing else uses it.
This gets quite a good amount of hits in some of the titles I've tested.

Also updates unit tests with additional data-types and ensures that
`And(..., Not())` returns the same result as `AndNot(...)`
2026-04-01 01:55:04 +09:00
Herman S.
11ad6b0a87 [Memory] Add alignment guards to PhysicalHeap allocations
Add alignment checks and parent release on failure in Alloc, AllocFixed,
and AllocRange to prevent misaligned addresses reaching BaseHeap.

Fixes #954
2026-03-31 21:49:19 +09:00
Herman S.
d2c8ca675e [A64] Use ARM64 bitmask immediates for AND/OR/XOR with constants 2026-03-31 18:21:22 +09:00
Herman S.
84b05bd20a [A64] Skip software denormal flushing when FPCR.FZ handles inputs
Depends on hardware support, detected and runtime and controllable
via a64_extension_mask bit 1.
2026-03-31 18:21:21 +09:00
Herman S.
02ea71ed51 [A64] Replace RSQRT CallNativeSafe with direct blr calls 2026-03-31 18:21:21 +09:00
Herman S.
06f56a20ea [A64] Inline V128 bit-shifts with NEON, remove C helper thunks 2026-03-31 18:21:21 +09:00
Herman S.
2fc5aca628 [A64] Optimizations for DIV, MUL_HI, SWIZZLE, LOAD_VECTOR_SHL/SHR
- DIV_I32/I64 and MUL_HI_I64: use source registers directly in
  sdiv/udiv/umulh/smulh instead of copying to scratch first
- SWIZZLE: fast paths for identity (no-op), broadcast (dup), and
  pair-swap (rev64) before falling back to general TBL
- LOAD_VECTOR_SHL/SHR: build base index vector with fmov+ins
  instead of stp+ldr stack round-trip
2026-03-31 18:21:21 +09:00
Herman S.
59f9fb9964 [A64] Optimize FPCR switching with lazy mode tracking
Replace per-op save/restore of FPCR in EmitWithVmxFpcr with tracked
lazy switching via ChangeFpcrMode. Consecutive VMX float ops in the
same basic block now emit a single FPCR switch instead of one per op.

ChangeFpcrMode loads pre-computed values from the backend context
(fpcr_fpu/fpcr_vmx) instead of MRS + read-modify-write, eliminating
an expensive system register read per switch.

FPU mode is restored at block boundaries and calls via ForgetFpcrMode.
Scalar FP sequences guard with ChangeFpcrMode(Fpu) which is a no-op
when already in FPU mode.
2026-03-31 18:21:21 +09:00
Herman S.
904c6c8b1c [A64] Fix RESERVED_STORE LSE path leaving labels unbound
The LSE paths in RESERVED_STORE_I32/I64 returned early from Emit,
leaving forward-referenced no_reserve/done labels unbound. Xbyak
encodes these as offset-zero branches (branch-to-self), causing
infinite loops when the reservation check fails on LSE hardware.

Replace early return with branch-to-done inside an if/else so
labels are always bound regardless of the LSE path taken.

Adds tests for RESERVED_STORE I64 success path and I32/I64
no-reservation failure path with timeout-based hang detection.
2026-03-30 11:10:30 +09:00
Adrian
d3d0478403 [Kernel] Fixed ObCreateSymbolicLink returning error if symbolic link is already registered
Fixed Crackdown greyed out Play Now - CO-OP option.
2026-03-29 21:15:20 +02:00
Herman S.
553aedebb5 [A64] Remove dead code 2026-03-29 17:16:56 +09:00
Herman S.
2d2105cfd8 [A64] Assert OPCODE_MEMSET invariants, remove dead general-case path 2026-03-29 15:14:04 +09:00
Wunkolo
664b77f38e [a64] Optimize OPCODE_MEMSET with zva
* Add unit tests
* Use `dc zva` to zero out entire cache-lines worth of data, when possible
 * Special instruction that zaps an entire cache-line into being zero-values, typically 64-bytes at a time
* Statically read and initialize the `DCZID_EL0` register value since reading registers with `mrs` can be kinda slow and isn't worth doing redundantly at JIT-time when it never changes.
* Update store-instructions to use inline post-increments to avoid an additional `add` instruction and keep encoded instruction immediates small

Pretty much every arm processor has a cache line size of 64 bytes, so a typical `dcbz128` to clear 128-bytes of data now results in:
```
dc zva, x0
add x0, x0, 64
dc zva, x0
```
rather than a sequence of 8 `stp xzr, xzr, ...` instructions
2026-03-29 15:13:45 +09:00
Adrian
1a53f261f7 [Base] Increase arena chunk size
Fixed Phantom Breaker (465607DE) from crashing.
2026-03-28 21:41:26 +01:00
Adrian
d680f5a499 [Kernel] Fixed XTimer reporting resume support
Fixed Quake 4 performance issues
2026-03-28 20:46:25 +01:00
Gliniak
9b1ebffd27 [Memory] GetPhysicalAddress - Added case to assume that input address is already physical
- Restored break on Indirect Buffer failure (Hopefully it won't break anything)
2026-03-28 20:11:43 +01:00
Herman S.
9d6b27e2ad [Build] Fix MSVC compilation on ARM64 2026-03-28 12:25:15 +09:00
Herman S.
a8ef7faeae [Build/macOS] Exclude empty translation units and Vulkan/SPIR-V targets 2026-03-27 16:12:08 +09:00
Herman S.
24015ef164 [Build/Release] Convert linux release to produce an appimage
Ported from xenia-edge with minor adjustments to remove Qt deps.
2026-03-27 15:51:45 +09:00
Herman S.
02ca07484c [Build] Ensure clang/lld are pinned to the correct version 2026-03-27 14:54:15 +09:00
Adrian
e97d0a80c6 [README] Update netplay status 2026-03-27 11:17:55 +09:00
Herman S.
57c1af465a [Build/CPU] Remove #pragma pack from Export and PPCOpcodeDisasmInfo
Pack(1) causes unaligned pointer errors on ARM64 with Apple's linker.
These are static read-only tables where the ~9KB size savings from
packing is negligible. Removing the pack may also marginally improve
access speed on x86 by avoiding unaligned loads.
2026-03-27 02:44:00 +09:00
Herman S.
57c4051eca [macOS] Build infrastructure and portability fixes
Build system:
- Enable ObjC++, macOS deployment target, framework linking
- Fix AppleClang detection
- macOS platform name for output directories
- Skip Vulkan on macOS, null graphics without Vulkan dependency
- macOS SDL2 framework detection and discord-rpc macOS sources

Portability fixes:
- mach_absolute_time for macOS tick counting
- _NSGetExecutablePath for macOS
- guard MAP_FIXED_NOREPLACE, ftruncate64->ftruncate
- guard Vulkan include/usage, fix data root for all POSIX
2026-03-27 02:44:00 +09:00
Herman S.
1af96481b2 [Build/MacOS] Fix sprintf deprecation warnings
Convert to snprintf in trace_viewer and suppress in 3pp stb header.
2026-03-27 01:24:05 +09:00
Herman S.
5f04b5420d [Build/MacOS] Add SDL2 framework 2026-03-27 00:11:59 +09:00
Herman S.
824e7f4257 [Build/MacOS] Skip vulkan 2026-03-27 00:11:59 +09:00
Herman S.
8cd7f69cbc [Kernel] Fix macro collisions with macOS system headers
Rename IPPROTO_TCP/UDP/VDP enum values to XE_IPPROTO_* to avoid
collision with macOS <netinet/in.h> macros. Add #undef WAIT_ANY
guard for macOS <sys/wait.h> macro.
2026-03-27 00:11:59 +09:00
Herman S.
46613f1126 [3PP] Update disruptorplus for libc++ std::min fix 2026-03-26 23:49:21 +09:00
Herman S.
5fcb6985e7 [Build] Mark third-party includes as SYSTEM to suppress warnings
Prevents -Werror from failing on warnings in code we don't control
2026-03-26 23:49:21 +09:00
Herman S.
78600212b2 [3PP/MacOS] Fix ffmpeg and sha256 build
ffmpeg: macOS uses "_" symbol prefix (Mach-O), has no <malloc.h>,
and doesn't support .data.rel.ro sections. Add __APPLE__ guards
in ffmpeg-xenia/config.h.

sha256: macOS provides endian macros in <machine/endian.h> instead
of <endian.h>.
2026-03-26 23:49:21 +09:00
Herman S.
cf013fdc15 [Base/Posix] mapped_memory portability and correctness fixes
Replace Linux-specific fstat64/ftruncate64 with portable POSIX equivalents.
Fix mmap error check to use MAP_FAILED instead of null pointer comparison.
Remove unconditional ftruncate after mmap that could corrupt files.
Add zero-length guard.
2026-03-26 23:10:47 +09:00
Herman S.
19e9d0c2de [Base/Posix] filesystem portability and correctness fixes
Replace Linux-specific fseeko64/ftello64/ftruncate64 with portable
POSIX equivalents.
Fix pread/pwrite error handling that assigned -1 to unsigned size_t.
Implement SetAttributes via chmod instead of stubbing it out.
Fix potential overflow in Unix-to-Windows filetime conversion.
Clean up unused removeCallback.
2026-03-26 23:10:47 +09:00
Herman S.
648b2bad78 [Build/A64] Extend ARM64 architecture detection for macOS 2026-03-26 23:10:47 +09:00
Herman S.
cb12f7fa1e [Build] Generalize POSIX platform guards
Most non-Windows code paths use standard POSIX APIs (sockets, signals,
dlopen, threading) that work on any POSIX platform. Change Linux-specific
guards to !WIN32 or #else where the code is portable. Linux-specific
APIs (SIGRTMIN, Vulkan/X11, fontconfig/GTK) remain Linux-guarded.
2026-03-26 23:10:47 +09:00
Herman S.
6c20f64e0d [Build] Guard Linux-specific CMake config behind platform check
GTK3, system SDL2 (pkg-config), Linux link libraries, linker groups,
and _GLIBCXX_DEBUG were in the generic non-MSVC branch, breaking
cmake configure on non-Linux POSIX platforms.
2026-03-26 23:10:47 +09:00
Herman S.
597a0c2d1e [Xboxkrnl] Use towupper in RtlUpcaseUnicodeChar for portability
std::ctype<char16_t> is a non-standard extension that's not available
on all platforms. Neither this nor the original technically match the
Windows kernel's fixed Unicode table approach and can produce different
results based on system locale.
2026-03-26 23:10:47 +09:00
Herman S.
30fd2a5ac9 [CPU] Fix breakpoint host_address() to_hex_string portability
Cast uintptr_t to uint64_t explicitly for to_hex_string, which
has no uintptr_t overload and can be ambiguous on some platforms.
2026-03-26 23:10:47 +09:00
Wunkolo
45cf464f63 [a64] Optimize more LoadV128Const splat opportunities
Optimize `LoadV128Const` to detect even more opportunities
to use `movi`, `mvni`, and `fmov` and such for 16-bit, 32-bit
and 64-bit splats.

Update some `mov`+`dup` idioms into `LoadV128Const` as well
to catch more opportunities to optimize these const-loads when
possible.
2026-03-26 22:42:01 +09:00
Herman S.
a90f5996de [Build] Python min version -> 3.6
Remove 3.10 syntax sugar and reduce min required python version to avoid
having to do needless python upgrades on various dev systems as 3.10 is
not yet ubiquitous and building on older systems is also still a thing.
2026-03-26 21:14:04 +09:00
Herman S.
3efc88abbb [Base] Fix math.h portability: use __builtin_ffs and fix lzcnt narrowing
ffs() can collide with POSIX macro definitions on some platforms;
__builtin_ffs is the portable GCC/Clang intrinsic. log2_floor/log2_ceil
passed template types directly to lzcnt which has only uint32_t and
uint64_t overloads, causing implicit narrowing on smaller types.
2026-03-26 16:28:27 +09:00