Commit Graph

8524 Commits

Author SHA1 Message Date
Michael Oliver
6de80dffe2 [Emulator] Load title plugins before main thread execution begins
This keeps the title thread suspended until plugins are loaded, allowing early init and hook setup before guest code starts running.
2026-04-29 20:20:08 +02:00
Radosław Gliński
6dca89834e [VFS] Removed error path that seems to be invalid
Seems like console do not care about returning directory with non-directory flag
2026-04-28 13:33:29 +02:00
Gliniak
60f77c3622 [VFS] Skip treating NT Device paths root as non-directory.
This fixes cache initialization failure
2026-04-27 20:19:10 +02:00
Gliniak
cff0773e00 [HID] Portal: Simplified device searching procedure 2026-04-26 13:26:30 +02:00
Adrian
dc561e4df5 [XMP] Fixed XMP Overriding
Fixed cutscene audio in 58411446

Co-Authored-By: The-Little-Wolf <116989599+the-little-wolf@users.noreply.github.com>
2026-04-25 18:27:28 +02:00
Wunkolo
8e1b286578 [x64] Add GFNI and AVX512VBMI optimizations for VECTOR_SHL(Int8)
Uses `{v}gf2p8mulb` as a general int8-multiplication instruction to do
variable Int8 bit-shifts.
Uses `{v}gf2p8affineqb` in the case that all of the shift values are the same.

Based on this original PR I had made to Xenia:
https://github.com/xenia-project/xenia/pull/2247
and this little write-up I did on this method:
https://wunkolo.github.io/post/2020/11/gf2p8affineqb-int8-shifting/
2026-04-23 22:07:39 +02:00
Adrian
e2200e8435 [BUILD] Fixed clang format selecting wrong binary architecture 2026-04-23 07:27:17 +02:00
Adrian
5174c2f2e0 [BUILD] Remove IMGUI_USE_STB_SPRINTF for checked builds 2026-04-22 19:50:17 +02:00
Adrian
68d409ebba [Kernel] Fixed releasing XObject handles on title termination 2026-04-21 22:42:12 +02:00
Gliniak
e91faca1c4 [VFS] Return more proper error codes in OpenFile
- Added handling for opening file with directory flag
2026-04-21 21:58:49 +02:00
Gliniak
e3e57bdb47 [XAM/XMP] Fixed incorrect size of XMP_SONGINFO structure
Thanks The-Little-Wolf
2026-04-20 20:41:40 +02:00
The-Little-Wolf
a6e92f43ea [XAM/XNOTIFY] - Fixes and more flags
- Properly set is_system in XamNotifyCreateListener
- Save is_system for later use
- Correct X_NOTIFICATION_ID
- Add missing XNotificationID flags
2026-04-19 22:03:31 +02:00
Adrian
73e3caa5e1 [CPU] Disable instruction info cache if context promotion is disabled
Fixed XMA writing to unknown registers when context promotion is disabled.
2026-04-19 20:51:12 +02:00
Gliniak
049a55f036 [CPU/Posix] Fixed crash caused by calling mmap on empty file 2026-04-19 20:21:24 +02:00
Adrian
bc7bc76d68 [APP] Fixed loading profile icon via login slots 2026-04-19 18:32:23 +02:00
Herman S.
4fcb8e4498 [Memory] Treat AllocRange high_page_number as exclusive
The free-block tracker search in BaseHeap::AllocRange treats
high_page_number as inclusive, shifting allocator-returned addresses
by one stride relative to the old loop-based search. Some titles
encode allocator-returned addresses in PPC code and break when that
layout shifts (Far Cry 3, Far Cry 4, Watchdogs).

In addition, reapply xe::align on the high side of AllocRange
(essentially reverting c28019e33). Without the round-up, a caller
passing a min/max window exactly the size of its request loses a
stride at the top and fails the early page_count size check.
2026-04-14 13:59:45 +09:00
Herman S.
763b160c7a [Threading/Linux] Add fallback to nice values
SCHED_FIFO requires CAP_SYS_NICE or root, try SCHED_FIFO first for real-time
priority control, then fall back to setpriority() nice values if permission
is denied.
2026-04-13 16:23:27 +09:00
Herman S.
844cc6e2ed [Memory] Remove unnecessary 256MB carve-out from v00000000 virtual heap
The 4KB-page virtual heap (v00000000, 0x00000000-0x3FFFFFFF) had 256MB
reserved at its top end for thread stacks, but thread stacks only use
the 64KB-page heap (v40000000) at 0x70000000-0x7F000000. This wasted
256MB of allocatable address space.

Keep the carve-out only on the v40000000 heap where stacks actually reside.
2026-04-13 13:16:55 +09:00
Herman S.
658bd5db70 [Xboxkrnl] Return error code from KeSetAffinityThread on null thread
If the guest-supplied thread pointer doesn't resolve to an XThread,
we previously returned STATUS_SUCCESS without setting the affinity
or writing previous_affinity_ptr, leaving callers believing the call
succeeded. Real NT kernel would crash on a bad pointer, but that's not
easy for us to replicate so return STATUS_INVALID_HANDLE instead and
log the pointer value so the condition is visible rather than silent.
2026-04-13 13:07:53 +09:00
Herman S.
d42411ec2a [Kernel] Fix NtReleaseSemaphore returning wrong status code 2026-04-13 12:59:36 +09:00
Herman S.
c17a3b19fb [Kernel] Implement per-process TLS allocation
Previous global TLS bitmap was shared across all processes. Now
per-process TLS bitmaps stored X_KPROCESS structures which should
better match Xbox360 architecture.
2026-04-13 12:42:42 +09:00
Herman S.
2590f03bc1 [Emulator] Delegate to UI thread instead of assert 2026-04-13 12:20:22 +09:00
Herman S.
c261027225 [UI] Fix leaked locked_achievement_icon_ texture on drawer teardown
Reset locked_achievement_icon_ alongside font_texture_ and
notification_icon_textures_ when the immediate drawer is cleared,
preventing a debug assertion in D3D12ImmediateDrawer's destructor.
2026-04-13 12:19:56 +09:00
Herman S.
7887efa69f [APU] fix potential semaphore leak on invalid client index 2026-04-13 12:16:24 +09:00
Herman S.
c28019e333 [Memory] Fix AllocRange upper bound and update PhysicalHeap tests
BaseHeap::AllocRange was rounding the inclusive high_address UP via
xe::align(), which could push the search range one alignment stride
past the requested end. The new free-block-tracker top-down search
treats high_page_number as an inclusive max (usable_end =
high_page_number + 1), so the round-up caused it to return a base
page one stride beyond the caller's bound — most visibly when
PhysicalHeap::Alloc passed parent_heap_end = GetPhysicalAddress(...)
just below a page boundary, producing a translated address one page
past the child heap and tripping "passed out of range address range"
in BaseHeap::AllocFixed.

Drop the xe::align on the high side so high_address stays a true
inclusive bound. The low_address round-up is still correct since
allocations must START at or above the aligned low.
2026-04-13 11:38:01 +09:00
Herman S.
ea02e8d317 [Memory] Add free block tracker to BaseHeap for O(log n) allocation
Replace linear page_table_ scans in AllocRange with a std::map-based
free block index that tracks contiguous free regions.

Insertions now coalesce with adjacent blocks on release and AllocFixed
uses the targeted tracker for pure reserves and falls back to a full rebuild
for mixed-state commits.

Also fixing PhysicalHeap leaking parent memory on child allocation failure,
Reset() not restoring unreserved_page_count_ and some incorrect method names
in PhysicalHeap error messages
2026-04-13 09:31:48 +09:00
Herman S.
80c6751b82 [UI] Eliminate mouse requirement for initial profile create dialogs
Enable keyboard navigation and accept Enter to complete profile creation
2026-04-13 08:16:05 +09:00
The-Little-Wolf
a292248bee [XAM/CONTENT] - Stub XamContentLaunchImage
- Stub XamContentLaunchImage and XamContentLaunchImageInternalEx
- Creates a common function for all XamContentLaunchImage functions
2026-04-12 19:38:41 +02:00
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