From 3b735d74d82e879aa7534677c565ece9fa556f78 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Wed, 18 Nov 2026 01:52:10 +0000 Subject: steamvr: even bug fixes have bugs The stutter fix was incomplete, waits were added for images which the renderers render and consume, but not for images coming from the application (e.g. eye textures). This hid some of the problem but you can still get stutter in intensive games that regularly miss their frame targets. Also, the headset can send spurious acks for frame 0 after a reconnect, despite not having received a frame, which can put the host into 3.3FPS mode. --- steamvr/driver_vrlink/ack-window.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 steamvr/driver_vrlink/ack-window.c (limited to 'steamvr/driver_vrlink') diff --git a/steamvr/driver_vrlink/ack-window.c b/steamvr/driver_vrlink/ack-window.c new file mode 100644 index 0000000..acd668d --- /dev/null +++ b/steamvr/driver_vrlink/ack-window.c @@ -0,0 +1,35 @@ +// SPDX-FileCopyrightText: 2026 Tomasz Kramkowski +// SPDX-License-Identifier: CC0-1.0 + +#include +#include +#include + +struct Transmitter { + unsigned char unknown_000[0x17c]; + int32_t next_frame; // -1 before the first frame is issued + int32_t last_ack; + int32_t cutoff; +}; +ASSERT_OFFSET(struct Transmitter, next_frame, 0x17c); +ASSERT_OFFSET(struct Transmitter, last_ack, 0x180); +ASSERT_OFFSET(struct Transmitter, cutoff, 0x184); + +void maybe_update_ack(struct Transmitter *tx, uint32_t incoming) +{ + if (tx->next_frame < 0) return; + uint16_t behind = (uint16_t)(tx->next_frame - 1 - incoming); + if (behind >= 0x8000) return; + + if (tx->cutoff >= 0 && (uint16_t)(incoming - tx->cutoff) >= 0x8000) return; + tx->last_ack = incoming; + tx->cutoff = incoming; +} + +// Hooks where the current code checks an incoming ack, clears the cutoff, and +// updates the last ack. The intent is to specifically replace all of that. +TRAMPOLINE( + accept_ack, CALL(maybe_update_ack, 0, "r8", + "mov rdi, rbx\n" + "mov esi, eax\n") "jmp resume_ack\n" +); -- cgit v1.3.1