mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 02:39:57 -04:00
Speed up the replay and fix what the perf pass found, and add a frame capture key for chasing rendering faults.
Performance: draws reuse the bindings that did not change and record only the dynamic states that differ from what the command buffer holds; small uploads come from a staging arena; finished submissions are held briefly and handed to the queue in batches; the recorder thread can keep a CPU core of its own; ASTC block-linear textures are deswizzled on the GPU; dynamic resolution steps the upscaler mode to hold a frame-time target. Each has a setting in nx2navi.ini (bind_reuse, dyn_delta, stg_arena, submit_batch, recorder_core, recorder_prio, astc_gpu_deswizzle, dyn_res) and the staging cache now frees what it holds at shutdown. Capture: NX2NAVI_DUMP=key saves the frame after each press of Insert, with mesh draws listed by task, mesh and fragment shader, depth test and face culling, and mesh_prims.txt giving each mesh draw's primitive, clipping and fragment counts. All of it is off unless NX2NAVI_DUMP is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -390,6 +390,29 @@ int plat_thread_join_ns(PlatThread *t, uint64_t ns) {
|
||||
// The thread keeps using t->fn and t->arg, so the struct stays allocated (a few bytes per detached thread).
|
||||
void plat_thread_detach(PlatThread *t) { pthread_detach(t->t); }
|
||||
|
||||
// The calling thread gets the last processor of its affinity mask to itself: every other thread of the process now
|
||||
// running loses that processor (threads they start later inherit their masks), and the caller keeps only it. Returns
|
||||
// 1, or 0 when the mask has fewer than three processors or the caller's mask cannot be set.
|
||||
int plat_cpu_reserve(void) {
|
||||
cpu_set_t all, mine, rest;
|
||||
if (sched_getaffinity(0, sizeof all, &all) || CPU_COUNT(&all) < 3) return 0;
|
||||
int last = -1;
|
||||
for (int i = CPU_SETSIZE - 1; i >= 0 && last < 0; i--)
|
||||
if (CPU_ISSET(i, &all)) last = i;
|
||||
rest = all;
|
||||
CPU_CLR(last, &rest);
|
||||
CPU_ZERO(&mine);
|
||||
CPU_SET(last, &mine);
|
||||
pid_t me = (pid_t)syscall(SYS_gettid);
|
||||
DIR *d = opendir("/proc/self/task");
|
||||
for (struct dirent *e; d && (e = readdir(d));) {
|
||||
pid_t tid = (pid_t)atoi(e->d_name);
|
||||
if (tid > 0 && tid != me) sched_setaffinity(tid, sizeof rest, &rest);
|
||||
}
|
||||
if (d) closedir(d);
|
||||
return sched_setaffinity(0, sizeof mine, &mine) == 0;
|
||||
}
|
||||
|
||||
uint64_t plat_thread_affinity(PlatThread *t, uint64_t mask) {
|
||||
pthread_t th = t ? t->t : pthread_self();
|
||||
cpu_set_t old, set;
|
||||
|
||||
Reference in New Issue
Block a user