[XMA] Fix consume-only path write offset and drain check

This commit is contained in:
Herman S.
2026-02-21 00:39:11 +09:00
parent 6ee55aafb4
commit d68ff7243a

View File

@@ -130,9 +130,19 @@ bool XmaContextNew::Work() {
RingBuffer output_rb = PrepareOutputRingBuffer(&data);
if (data.IsConsumeOnlyContext()) {
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() &&
data.output_buffer_read_offset == data.output_buffer_write_offset) {
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);