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/vrcompositor/shared.h | 79 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 steamvr/vrcompositor/shared.h (limited to 'steamvr/vrcompositor/shared.h') diff --git a/steamvr/vrcompositor/shared.h b/steamvr/vrcompositor/shared.h new file mode 100644 index 0000000..2fdd755 --- /dev/null +++ b/steamvr/vrcompositor/shared.h @@ -0,0 +1,79 @@ +// SPDX-FileCopyrightText: 2026 Tomasz Kramkowski +// SPDX-License-Identifier: CC0-1.0 + +#ifndef STEAMVR_VRCOMPOSITOR_SHARED_H +#define STEAMVR_VRCOMPOSITOR_SHARED_H + +#include +#include +#include + +ASSERT_SIZE(void *, 8); + +struct Image; +struct SharedResource; +struct Semaphore; +struct NativeDevice; + +typedef uint32_t GetOwner(struct Image *); +typedef struct Semaphore *GetSemaphore(struct SharedResource *); +typedef uint64_t SemaphoreGetU64(struct Semaphore *); +typedef unsigned char +SubmitWait(struct Semaphore *, uint64_t, struct NativeDevice *, unsigned char); + +struct ImageVtable { + unsigned char unknown_000[0xd8]; + GetOwner *get_owner; +}; +ASSERT_OFFSET(struct ImageVtable, get_owner, 0xd8); + +// vr::IVRSharedImage +struct Image { + const struct ImageVtable *vtable; +}; + +struct SharedResourceVtable { + unsigned char unknown_000[0x30]; + GetSemaphore *get_semaphore; +}; +ASSERT_OFFSET(struct SharedResourceVtable, get_semaphore, 0x30); + +// vr::IVRSharedResource +struct SharedResource { + const struct SharedResourceVtable *vtable; +}; + +struct SemaphoreVtable { + unsigned char unknown_000[0x40]; + SemaphoreGetU64 *get_handle; + unsigned char unknown_048[0x70 - 0x48]; + SemaphoreGetU64 *get_value; + unsigned char unknown_078[8]; + SubmitWait *submit_wait; +}; +ASSERT_OFFSET(struct SemaphoreVtable, get_handle, 0x40); +ASSERT_OFFSET(struct SemaphoreVtable, get_value, 0x70); +ASSERT_OFFSET(struct SemaphoreVtable, submit_wait, 0x80); + +// vr::IVRSharedSemaphore +struct Semaphore { + const struct SemaphoreVtable *vtable; +}; + +typedef struct { + uintptr_t semaphore; + uint64_t value; +} SemaphoreEntry; +ASSERT_SIZE(SemaphoreEntry, 16); +ASSERT_OFFSET(SemaphoreEntry, value, 8); + +static inline struct SharedResource *image_to_resource(struct Image *image) +{ + // The vbase offset entry for converting `vr::IVRSharedImage *` to + // `vr::IVRSharedResource *` is located at `image->vtable - 0x50`. + ptrdiff_t resource_offset = + *(const ptrdiff_t *)((const char *)image->vtable - 0x50); + return (void *)((char *)image + resource_offset); +} + +#endif -- cgit v1.3.1