Triforce v0.8.4

Smoother frames and less memory: a compact pipeline cache on NVIDIA, the renderer and game-code profiles, native float in the hot game code, late GPU work left as before. A PC whose NVIDIA shader cache drops the game's gets a driver cache folder of its own. Fixes from the 0.8.3 reports: RenoDX's encoder and tone mapping matched on NVIDIA again; the out-of-memory notice at the next start; no microphone open without a recording device; Evil HD undergrowth kept to 80/120 m; the FG HUD layer keeps what it learned; a stick past 92% is a full push; the DualSense jack read only when used; Linux Save Select, Quit and Restart, and the Linux launcher's sound; the update check uses the program's own version.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-26 20:04:11 -06:00
parent ecb4d5cc99
commit 2df08c751e
45 changed files with 2828 additions and 567 deletions

View File

@@ -16,6 +16,7 @@
#include <stdio.h>
#include <stdlib.h>
#define WIN32_LEAN_AND_MEAN
#include <xmmintrin.h> /* ((Triforce) _mm_getcsr / _mm_setcsr: hos_fpcr_sync) */
#include <windows.h>
#ifndef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION /* (older Windows SDKs lack it: Windows 10 1803 and later take it) */
#define CREATE_WAITABLE_TIMER_HIGH_RESOLUTION 0x00000002
@@ -615,14 +616,52 @@ Ctx *hos_boot_main_thread(uint64_t stack_size) {
cur = t;
track(t);
hos_vcore_back(); /* (virtual cores: before any guest code) */
hos_fpcr_start(&t->ctx);
return &t->ctx;
}
/* (Triforce, 11-26: ProjectReLink's, pixl27) The host's MXCSR follows the guest's FPCR.FZ: results flushed to zero (FTZ) and
subnormal operands read as zeros (DAZ), which is what Arm's flush-to-zero mode does. With the lift option A64_NATIVE_FP
(nx2/nativefp.py) the hot functions' floating point runs on the host's own instructions, and those flush as the guest
expects only with both bits set; the exact helpers keep their values under them (with FZ they flush what they compute
themselves). Such a lift's constructor calls hos_fpcr_follow() before main, and its code calls hos_fpcr_sync() after every
MSR FPCR; the host syncs again at a thread's and a fiber's start (MXCSR is a thread's, and a fiber's with
FIBER_FLAG_FLOAT_SWITCH). A lift without the option never asks: MXCSR is left alone, as before. HOS_FPCR_SYNC=0: left
alone in any build (then a native lift's FZ is the host's default, no flush: a measurement switch only). */
static volatile LONG fpcr_follow;
static int fpcr_sync_on(void) {
static int on = -1;
if (on < 0) {
const char *e = getenv("HOS_FPCR_SYNC");
on = !(e && e[0] == '0');
}
return on;
}
static void fpcr_apply(const Ctx *c) {
#if defined(__x86_64__) || defined(_M_X64)
const unsigned want = ((uint32_t)c->fpcr & (1u << 24)) ? 0x8040u : 0u;
const unsigned now = _mm_getcsr();
if ((now & 0x8040u) != want) _mm_setcsr((now & ~0x8040u) | want);
#else
(void)c;
#endif
}
void hos_fpcr_follow(void) {
if (fpcr_sync_on()) InterlockedExchange(&fpcr_follow, 1);
}
void hos_fpcr_sync(Ctx *c) {
if (fpcr_follow) fpcr_apply(c);
}
void hos_fpcr_start(const Ctx *c) {
if (fpcr_follow) fpcr_apply(c);
}
static DWORD WINAPI thread_main(void *p) {
HosThread *t = (HosThread *)p;
hos_stack_guarantee();
cur = t;
Ctx *c = &t->ctx;
hos_fpcr_start(c);
c->x[0] = t->arg;
c->x[30] = 0;
c->x[31] = (t->stack + t->stack_size) & ~15ULL;
@@ -1639,6 +1678,7 @@ static void WINAPI fiber_main(void *p) {
c->x[0] = f->arg;
c->x[30] = 0;
c->x[31] = (f->stack + f->size) & ~15ULL;
hos_fpcr_start(c); /* (a new fiber has the default MXCSR and the FPCR of whoever started it) */
a64_icall(c, f->fn); /* FiberType* (*)(void*) */
const uint64_t next = c->x[0];
f->done = 1;