diff options
Diffstat (limited to 'steamvr/vrcompositor/shared.h')
| -rw-r--r-- | steamvr/vrcompositor/shared.h | 79 |
1 files changed, 79 insertions, 0 deletions
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 <tomasz@kramkow.ski> +// SPDX-License-Identifier: CC0-1.0 + +#ifndef STEAMVR_VRCOMPOSITOR_SHARED_H +#define STEAMVR_VRCOMPOSITOR_SHARED_H + +#include <layout.h> +#include <stddef.h> +#include <stdint.h> + +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 |
