Commit Graph

44 Commits

Author SHA1 Message Date
Herman S.
d9747704be [XMA] Reserve headroom per decoded frame and account for it in gating
The 3-bit field at +24bit in DWORD 1 of the XMA context was named
subframe_skip_count but never actually used for skipping subframes.
Testing across multiple titles (PGR4, Halo Reach) shows the field
might control extra output buffer blocks that must be reserved per decoded
frame. Renaming the field to output_buffer_padding to reflect this
observed behavior and adding padding to the minimum output space threshold

Pdding blocks are reserved from the output budget after each frame is
fully consumed, preventing the decoder from overrunning the space
that the game expects to remain free.

This is still likely not entirely correct but reduces some of the
observed noise in current implementation.
2026-02-18 18:14:44 +09:00
Herman S.
2d6b7c6ca1 [XMA] Fix dedicated thread stalls by blocking guest audio thread
Includes various other thread safety and timing related adjustments
2026-02-17 13:57:32 +09:00
Herman S.
6e5b2a95b0 [XMA] Fix multiple audio issues in new decoder
- Handle XMA2 frames with headers split across packet boundaries
  (fixes audio cutoff in Capcom games)
- Output buffer minimum space check using actual frame size instead
  of SDC-based formula, allowing tight-buffer contexts to decode
  (fixes PGR4 engine sounds)
- Gate consume-only context clearing with tight-buffer heuristic to
  prevent disrupting playback while still allowing stream completion
  signaling (fixes Borderlands 2 dialog)
- Clamp read offset 0 to packet header size to prevent decode rejection
  loop (fixes Dirt 2 crashes)
2026-02-17 13:56:24 +09:00
Gliniak
0af253e230 [XMA] Separate error status into status and set fields
It's separate bit that defines if error is present
2025-12-05 22:29:09 +01:00
Gliniak
4494e40c71 [XMA] Added multiple versions of XMA decoders
- Fake: No decoding
- Master: 1:1 from base version of Xenia
- Old: Master with improvements
- New: Completely new decoder with better stability (but not compability)

Co-authored-by: Herman S. <429230+has207@users.noreply.github.com>
2025-12-03 20:05:41 +01:00
Gliniak
dd29365970 [APU] Switched to New XMA decoder as default
- Added codepath for "consume only" pass. This should resolve constant clicking in Source engine games.
- Added smaller performance improvements to decoder
2025-12-01 23:58:33 +01:00
Margen67
4cb783bf22 Header cleanup 2025-07-19 14:42:21 -07:00
Marco Rodolfi
f58fab1d2c [compiler] Misc changes to make this emulator properly compile under Linux with Clang 2025-01-19 21:37:29 +01:00
Gliniak
ec267c348a [LINT] Fixed lint issues after clang-format update 2024-06-13 20:56:56 +02:00
Gliniak
122f58c9dd [APU] Added new XMA decoder as config option. 2024-03-26 09:39:23 +01:00
Gliniak
b9061e6292 [LINT] Linted files + Added lint job to CI 2024-03-12 19:19:30 +01:00
Gliniak
b2dd489151 [APU] Set first frame offset for next buffer + Note about edgecase 2022-12-13 22:57:36 +01:00
Gliniak
9fdfd2ada9 [APU] Removed old hack that invalidates input on decoder error
Added returning parsing error while decoder fails
2022-11-26 17:25:39 +01:00
Gliniak
c080e2e17c [APU] Resolved crashes related to out of bound readouts 2022-11-01 11:24:01 +01:00
chss95cs@gmail.com
8f7f7dc6ad fixed wine crash from use of NtSetEventPriorityBoost
add xe::clear_lowest_bit, use it in place of shift-andnot in some bit iteration code
make is_allocated_ and is_enabled_ volatile in xma_context
preallocate avpacket buffer in XMAContext::Setup, the reallocations of the buffer in ffmpeg were showing up on profiles
check is_enabled and is_allocated BEFORE locking an xmacontext. XMA worker was spending most of its time locking and unlocking contexts
Removed XeDMAC, dma:: namespace. It was a bad idea and I couldn't make it work in the end. Kept vastcpy and moved it to the memory namespace instead
Made the rest of global_critical_region's members static. They never needed an instance.
Removed ifdef'ed out code from ring_buffer.h
Added EventInfo struct to threading, added Event::Query to aid with implementing NtQueryEvent.
Removed vector from WaitMultiple, instead use a fixed array of 64 handles that we populate. WaitForMultipleObjects cannot handle more than 64 objects.
Remove XE_MSVC_OPTIMIZE_SMALL() use in x64_sequences, x64 backend is now always size optimized because of premake
Make global_critical_region_ static constexpr in shared_memory.h to get rid of wasteage of 8 bytes (empty class=1byte, +alignment for next member=8)
Move trace-related data to the tail of SharedMemory to keep more important data together
In IssueDraw build an array of fetch constant addresses/sizes, then pre-lock the global lock before doing requestrange for each instead of individually locking within requestrange for each of them
Consistent access specifier protected for pm4_command_processor_declare
Devirtualize WriteOneRegisterFromRing.
Move ExecutePacket and ExecutePrimaryBuffer to pm4_command_buffer_x
Remove many redundant header inclusions access xenia-gpu
Minor microoptimization of ExecutePacketType0

Add TextureCache::RequestTextures for batch invocation of LoadTexturesData

Add TextureCache::LoadTexturesData for reducing the number of times we release and reacquire the global lock.
Ideally you should hold the global lock for as little time as possible, but if you are constantly acquiring and releasing it you are actually more likely to have contention
Add already_locked param to ObjectTable::LookupObject to help with reducing lock acquire/release pairs
Add missing checks to XAudioRegisterRenderDriverClient_entry. this is unlikely to fix anything, it was just an easy thing to do
Add NtQueryEvent system call implementation. I don't actually know of any games that need it.
Instead of using std::vector + push_back in KeWaitForMultipleObjects and xeNtWaitForMultipleObjectsEx use a fixed size array of 64 and track the count. More than 64 objects is not permitted by the kernel. The repeated reallocations from push_back were appearing unusually high on the profiler, but were masked until now by waitformultipleobjects natural overhead
Pre-lock the global lock before looking up each handle for xeNtWaitForMultipleObjectsEx and KeWaitForMultipleObjects.
Pre-lock before looking up the signal and waiter in NtSignalAndWaitForSingleObjectEx
add missing checks to NtWaitForMultipleObjectsEx
Support pre-locking in XObject::GetNativeObject
2022-10-08 09:55:17 -07:00
chss95cs@gmail.com
08f7a28920 Alternative mutex 2022-08-14 08:59:11 -07:00
Gliniak
de03165995 Merge remote-tracking branch 'GliniakRepo/audioSkipHeaderInputOffset' into canary_pr 2022-05-19 10:16:41 +02:00
Pseudo-Kernel
372bdd3ec9 [APU] XMA: Fix audio loop handling.
Handles audio loop if loop_start < loop_end.
Need to handle additional cases like loop_start > loop_end.
2022-01-29 02:49:00 -06:00
Gliniak
f40607041b [APU] Skip audio header when there is no valid input
Thanks Cancerous1/Randprint for initial reseach in this topic
2021-10-18 08:50:51 +02:00
Triang3l
add65318c2 [APU] XMA: ConvertFrame always returns true 2021-06-05 16:27:40 +03:00
Triang3l
60b24b2d3a [APU] XMA: Vectorize 2-channel ConvertFrame 2021-06-05 16:10:41 +03:00
Joel Linn
89a7c8f41f [APU] Add vectorized audio frame conversion 2021-06-05 14:08:16 +03:00
Joel Linn
534e263b05 [APU] XMA: Cross-buffer split frames. 2021-05-01 12:41:02 -05:00
Joel Linn
6547fa1748 [APU] Rewrite XMA packet parser
Use new FFmpeg frame decoder
2021-05-01 12:41:02 -05:00
Margen67
896ac4a682 Update documentation.
- Convert http to https, provide archive link when possible.
- Made CPU-JIT.png more readable on dark themes;
Added a white background so there isn't black text on a black
background.
2018-11-22 09:20:09 -06:00
DrChat
1b038125a1 Fix Travis and the build 2017-12-23 17:49:37 -06:00
Dr. Chat
4bc6980ad4 [APU] Fill in a few previously unknown fields in the HW context 2017-12-23 13:49:41 -06:00
Dr. Chat
a093fdcef8 XMA: Add an idle "low-power" state for the decoder. 2017-01-28 20:58:23 -06:00
Ben Vanik
e5fbf840d2 Shuffling kernel/. 2015-09-06 18:07:52 -07:00
Ben Vanik
790ce8aee1 Switch back to std:: muteces. mutices. mutexen. 2015-09-06 13:34:08 -07:00
Ben Vanik
3c96b6fa0a DANGER DANGER. Switching to global critical region.
This changes almost all locks held by guest threads to use a single global
critical region. This emulates the behavior on the PPC of disabling
interrupts (by calls like KeRaiseIrqlToDpcLevel or masking interrupts),
and prevents deadlocks from occuring when threads are suspended or
otherwise blocked.
This has performance implications and a pass is needed to ensure the
locking is as granular as possible. It could also break everything
because it's fundamentally unsound. We'll see.
2015-09-06 09:30:54 -07:00
Dr. Chat
8024e4fd20 XMA: We can only decode an entire frame and write it out at a time! Saving samples is bad. 2015-09-02 20:20:45 -05:00
Dr. Chat
f80e5fc98d Linting 2015-08-29 22:21:25 -05:00
Dr. Chat
6c83b35003 Partial frame support. 2015-08-29 21:42:06 -05:00
Dr. Chat
d8ed66c336 More improvements to the XMA decoder (and included some forgotten files) 2015-08-29 21:18:04 -05:00
Dr. Chat
0f9cd8cfb3 New WIP audio decoder 2015-08-29 21:16:57 -05:00
Ben Vanik
19299fad4b Removing apu/ deps on Emulator. 2015-08-18 10:54:56 -07:00
Ben Vanik
5e08889d93 More style cleanup. 2015-08-06 20:17:01 -07:00
Dr. Chat
766788be7b XMAContext abort instantly if libav failed mid-packet. 2015-07-27 18:24:04 -05:00
Ben Vanik
ecd4af10c9 Fixing some clang warnings/errors. 2015-07-15 23:26:58 -07:00
Ben Vanik
fb1f4906d9 xb format --all (we are now format clean). Buildbot will yell at you. 2015-06-22 22:26:51 -07:00
gibbed
75ef95b1b8 More XMA decoder cleanup. 2015-06-22 19:31:02 -05:00
gibbed
2c319db116 More shuffling of XMA decoder code. 2015-06-21 06:31:24 -05:00
gibbed
021b5a3d17 Moved the XMA decoder out of AudioSystem and into its own world (plus minor code cleanup in the process). 2015-06-21 02:25:24 -05:00