diff options
| author | Tomasz Kramkowski <tomasz@kramkow.ski> | 2026-11-18 01:52:10 +0000 |
|---|---|---|
| committer | Tomasz Kramkowski <tomasz@kramkow.ski> | 2026-11-18 01:52:10 +0000 |
| commit | 3b735d74d82e879aa7534677c565ece9fa556f78 (patch) | |
| tree | c1ba84a2aab546792fc75ab5c072f8416193afc6 /src/steamvr_patches/include | |
| parent | 363fe07ad4cd514d907647ee0eda2310f6efa3c0 (diff) | |
| download | steamvr-patches-3b735d74d82e879aa7534677c565ece9fa556f78.tar.gz steamvr-patches-3b735d74d82e879aa7534677c565ece9fa556f78.tar.xz steamvr-patches-3b735d74d82e879aa7534677c565ece9fa556f78.zip | |
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.
Diffstat (limited to 'src/steamvr_patches/include')
| -rw-r--r-- | src/steamvr_patches/include/layout.h | 17 | ||||
| -rw-r--r-- | src/steamvr_patches/include/trampoline.h | 59 |
2 files changed, 76 insertions, 0 deletions
diff --git a/src/steamvr_patches/include/layout.h b/src/steamvr_patches/include/layout.h new file mode 100644 index 0000000..07d312f --- /dev/null +++ b/src/steamvr_patches/include/layout.h @@ -0,0 +1,17 @@ +/* SPDX-FileCopyrightText: 2026 Tomasz Kramkowski <tomasz@kramkow.ski> + * SPDX-License-Identifier: CC0-1.0 + */ + +#ifndef PATCH_LAYOUT_H +#define PATCH_LAYOUT_H + +#include <stddef.h> + +#define ASSERT_SIZE(type, expected) \ + _Static_assert(sizeof(type) == (expected), #type " size must be " #expected) +#define ASSERT_OFFSET(type, field, expected) \ + _Static_assert( \ + offsetof(type, field) == (expected), #type "." #field " offset" \ + ) + +#endif diff --git a/src/steamvr_patches/include/trampoline.h b/src/steamvr_patches/include/trampoline.h new file mode 100644 index 0000000..5a14b9b --- /dev/null +++ b/src/steamvr_patches/include/trampoline.h @@ -0,0 +1,59 @@ +/* SPDX-FileCopyrightText: 2026 Tomasz Kramkowski <tomasz@kramkow.ski> + * SPDX-License-Identifier: CC0-1.0 + */ + +#ifndef PATCH_TRAMPOLINE_H +#define PATCH_TRAMPOLINE_H + +#if defined(__x86_64__) +#define PATCH_ASM_BEGIN ".intel_syntax noprefix\n" +#define PATCH_ASM_END ".att_syntax prefix\n" +#define PATCH_FUNCTION_TYPE "@function" +#elif defined(__aarch64__) +#define PATCH_ASM_BEGIN "" +#define PATCH_ASM_END "" +#define PATCH_FUNCTION_TYPE "%function" +#else +#error Unsupported architecture +#endif + +#define TRAMPOLINE(name, body) \ + __asm__(".pushsection .text.entry,\"ax\"\n" \ + ".global " #name "\n" \ + ".type " #name "," PATCH_FUNCTION_TYPE "\n" #name \ + ":\n" PATCH_ASM_BEGIN body PATCH_ASM_END ".size " #name ",.-" #name \ + "\n" \ + ".popsection\n") + +#if defined(__x86_64__) +// Restore a register list in the reverse of its save order. +__asm__(".macro patch_pop_regs first, rest:vararg\n" + " .ifnb \\first\n" + " .ifnb \\rest\n" + " patch_pop_regs \\rest\n" + " .endif\n" + " pop \\first\n" + " .endif\n" + ".endm\n"); + +// Call `func`, preserving `regs`. Pass the value of RSP % 16 as `stack_mod16`. +// `setup` is inserted after saving but before the call. +#define CALL(func, stack_mod16, regs, setup) \ + ".set .Lpatch_stack_pad, " #stack_mod16 "\n" \ + ".ifnb " regs "\n" \ + " .irp reg, " regs "\n" \ + " push \\reg\n" \ + " .set .Lpatch_stack_pad, (.Lpatch_stack_pad - 8) & 15\n" \ + " .endr\n" \ + ".endif\n" \ + ".if .Lpatch_stack_pad\n" \ + " sub rsp, .Lpatch_stack_pad\n" \ + ".endif\n" setup "\n" \ + "call " #func "\n" \ + ".if .Lpatch_stack_pad\n" \ + " add rsp, .Lpatch_stack_pad\n" \ + ".endif\n" \ + "patch_pop_regs " regs "\n" +#endif + +#endif |
