[XMA] Fix consume-only context resetting output buffer offsets

And remove the now-unused HasTightOutputBuffer heuristic
This commit is contained in:
Herman S.
2026-02-26 10:28:49 +09:00
parent aaf284a4b0
commit bc54720559
2 changed files with 5 additions and 16 deletions

View File

@@ -159,11 +159,6 @@ struct XMA_CONTEXT_DATA {
const bool IsConsumeOnlyContext() const {
return (input_buffer_0_packet_count | input_buffer_1_packet_count) == 0;
}
// Whether the SDC-based minimum exceeds the output buffer size.
const bool HasTightOutputBuffer() const {
return (int32_t)((subframe_decode_count * 2) - 1) >
(int32_t)output_buffer_block_count;
}
};
static_assert_size(XMA_CONTEXT_DATA, 64);

View File

@@ -130,21 +130,15 @@ bool XmaContextNew::Work() {
RingBuffer output_rb = PrepareOutputRingBuffer(&data);
if (data.IsConsumeOnlyContext()) {
// Nothing to drain — don't touch the context or we'll reset the
// game's output buffer offsets, causing stale PCM to be re-read.
if (current_frame_remaining_subframes_ == 0) {
return true;
}
XELOGAPU("XmaContext {}: Consume-only context, draining subframes", id());
Consume(&output_rb, &data);
data.output_buffer_write_offset =
output_rb.write_offset() / kOutputBytesPerBlock;
// Clearing contexts that match TightBufferOutput heuristic can disrupt
// playback (e.g. audio noise during races in PGR4), so we only clear
// contexts with enough output buffer headroom where empty input reliably
// indicates the stream is finished (e.g. needed for dialog completion in
// Borderlands 2 startup).
if (!data.HasTightOutputBuffer() &&
current_frame_remaining_subframes_ == 0 && output_rb.empty()) {
XELOGAPU("XmaContext {}: Consume-only context fully drained, clearing",
id());
ClearLocked(&data);
}
StoreContextMerged(data, initial_data, context_ptr);
return true;
}