mirror of
https://github.com/astromaddie/HaloCE-VR.git
synced 2026-10-26 23:00:16 +01:00
Reading the visibility counters still waited, once a frame, for the GPU to finish all queued work, so a frame's time was the CPU's plus the GPU's: raising the headset's resolution to 1.25 dropped the first level to 37 frames a second. Each frame's counters are now copied, behind the frame fence the stream ring already uses, into a buffer of that ring slot, and read once the GPU has passed it (host_gl_frame_done, without waiting); a test's result is the latest the GPU has finished, a frame or two old, which lens flares do not show. At 1.25 (2160x2160 an eye) the second level now runs stereo at the headset's 72 frames a second. Valve's Mesa in Lepton writes a kernel trace marker around every flush and context switch, a couple of hundred a frame; the descriptors it opens on trace_marker are pointed at /dev/null once the GL context and the OpenXR session exist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
3.6 KiB
C
99 lines
3.6 KiB
C
/*
|
|
HOST.H
|
|
|
|
Internals of the Android port's host library (libmain.so). See
|
|
port/android/README.md for the overall design and
|
|
port/android/include/halo_android_abi.h for the guest contract.
|
|
*/
|
|
|
|
#ifndef __HALO_ANDROID_HOST_H
|
|
#define __HALO_ANDROID_HOST_H
|
|
|
|
#include <stdarg.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#include "halo_android_abi.h"
|
|
|
|
/* ---------- logging (logcat tag "halo") */
|
|
|
|
void host_logf(int priority, const char *format, ...) __attribute__((format(printf, 2, 3)));
|
|
#define HOST_LOG_INFO 4
|
|
#define HOST_LOG_WARN 5
|
|
#define HOST_LOG_ERROR 6
|
|
/* guest services also used inside the host (host_main.c) */
|
|
void host_exit(int code) __attribute__((noreturn));
|
|
int host_errno(void);
|
|
|
|
/* logs, shows the message to the player and terminates */
|
|
void host_fatal(const char *format, ...) __attribute__((format(printf, 1, 2), noreturn));
|
|
|
|
/* ---------- guest memory (host_memory.c)
|
|
|
|
All memory the guest can address lies below 4 GB. The host reserves the
|
|
Xbox window and the image's range at start-up, and hands out pages for
|
|
everything else (the guest's malloc arenas, thread stacks, anonymous
|
|
mappings) from pools of address space it reserves below 4 GB on demand. */
|
|
|
|
/* reserves the fixed ranges; returns 0 on success */
|
|
int host_memory_initialize(uint32_t image_base, uint32_t image_size);
|
|
/* page-granular allocations below 4 GB; NULL on failure */
|
|
void *host_low_map(size_t size, int protection);
|
|
void host_low_unmap(void *address, size_t size);
|
|
/* 1 if [address, address + size) was handed out by host_low_map or is one of
|
|
the fixed ranges */
|
|
int host_low_owns(uintptr_t address, size_t size);
|
|
/* the guest's mmap/munmap/mprotect/madvise/mremap (host_syscall.c) */
|
|
long host_guest_mmap(uint64_t address, uint64_t size, int protection, int flags, int fd, int64_t offset);
|
|
long host_guest_munmap(uint64_t address, uint64_t size);
|
|
long host_guest_mprotect(uint64_t address, uint64_t size, int protection);
|
|
|
|
/* ---------- the guest image (host_loader.c) */
|
|
|
|
struct host_guest_image
|
|
{
|
|
const struct halo_guest_header *header;
|
|
uint32_t base, end;
|
|
};
|
|
|
|
extern struct host_guest_image host_image;
|
|
|
|
/* maps the image from the ELF file in memory; returns 0 on success */
|
|
int host_load_image(const void *elf, size_t size);
|
|
|
|
/* ---------- entering guest code (host_thread.c) */
|
|
|
|
/* calls the guest function at address with up to four 32-bit arguments on
|
|
this thread, which must have been made by host_native_thread_create (giving
|
|
the thread a guest struct pthread first if it has none); returns the
|
|
guest's w0 */
|
|
uint32_t host_call_guest(uint32_t function, uint32_t a, uint32_t b, uint32_t c, uint32_t d);
|
|
/* starts a thread running function(argument) with its stack in guest
|
|
memory, so that it can call guest code; the stack is freed after it exits.
|
|
Returns 0 or an errno value */
|
|
int host_native_thread_create(void *(*function)(void *), void *argument, size_t stack_size);
|
|
/* runs the guest's __guest_start on the calling thread (one made by
|
|
host_native_thread_create); does not return */
|
|
void host_run_guest_main(uint32_t boot) __attribute__((noreturn));
|
|
|
|
/* ---------- debugging (host_debug.c) */
|
|
|
|
void host_debug_thread_started(void);
|
|
void host_debug_thread_exited(void);
|
|
/* config.toml's debug.sample_seconds: seconds between samples of the guest
|
|
threads, as text */
|
|
void host_debug_start_sampler(const char *setting);
|
|
|
|
/* ---------- import table (host_imports.c) */
|
|
|
|
/* the host function for an import name, or NULL */
|
|
void *host_resolve_import(const char *name);
|
|
|
|
/* ---------- SDL / GL (host_sdl.c, host_gl.c) */
|
|
|
|
void *host_gl_resolve(const char *name);
|
|
/* points the GL driver's kernel trace markers at /dev/null (host_gl.c) */
|
|
int host_gl_quiet_trace_markers(void);
|
|
|
|
#endif
|