mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 01:49:59 -04:00
Raise the frame rate: fewer copies into the VRAM mirrors, earlier GPU starts, render target images reused.
From the local fixes package (fix 11), measured in Kokiri Forest at 4K on an RTX 4090 over PCIe 3.0: 40.5 to 62.6 fps native and 45.6 to 74.9 fps with DLSS Quality, the mirror copies from 6.5 to 0.3 ms of GPU time a frame. - Pages a VRAM mirror wrote back into guest memory are not copied up into it again: the mirror sync reads page stamps of their own that a mirror's write-back leaves alone (vk_gpu_written_back, decided at record time by vk_mem_mirrored). This replaces the lookup table NX2NAVI_WB_NO_REUP had, keeps its name, and is now on by default. - The game's flushes of mirrored memory are not copied where the write watch covers the region, as every page the game wrote there is stamped already (47-57 MiB a frame); NX2NAVI_FLUSH_UPLOAD=1 copies them as before. - Written storage ranges up to NX2NAVI_WB_MERGE_MAX (now 32 MiB) are merged in 4 MiB pieces, so a range is no longer bound to what one dispatch covers; the snapshot pool keeps its budget-scaled size with 128 slots. - A submission's first part goes to the GPU at the first pass boundary while the GPU is idle (split_idle), long passes are split too (split_in_pass), and the part's time limit reads the clock less often. - A render target that needs an image of its own takes the image of a released one with the same parameters, released two or more frames before (tex_reuse); memory requirements are kept per parameter set; a released entry another descriptor's entry replaced at its address is kept and taken back. - The memory check reads a page's write-watch bit and stamp under the lock that keeps them together. - The launcher reads the gamepad only while its own window is in front, and does not start a second copy of the game. - make_game.py says why a Python package did not load, not only that it is missing. The fix's per-pass GPU timing is left out: NX2NAVI_GPU_PASSES does the same in main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -319,7 +319,7 @@ class App:
|
||||
|
||||
def poll_gamepad(self):
|
||||
try:
|
||||
for b in self.gamepad.poll():
|
||||
for b in self.gamepad.poll(winsys.in_front(self.root)):
|
||||
{'up': lambda: self.move(-1), 'down': lambda: self.move(1), 'left': lambda: self.side(-1),
|
||||
'right': lambda: self.side(1), 'a': self.activate, 'b': self.back,
|
||||
'y': lambda: self.check_now(force=True)}.get(b, lambda: None)()
|
||||
@@ -793,6 +793,10 @@ class App:
|
||||
return
|
||||
if self.game_proc and self.game_proc.poll() is None:
|
||||
return
|
||||
if saves.game_running(gd): # a copy this launcher did not start (another launcher, a shortcut, a test run)
|
||||
self.message = 'The game is already running.'
|
||||
self.render()
|
||||
return
|
||||
try:
|
||||
self.game_proc = winsys.start_game(exe)
|
||||
except OSError as e:
|
||||
|
||||
@@ -273,9 +273,32 @@ BUTTONS = {0x0001: 'up', 0x0002: 'down', 0x0004: 'left', 0x0008: 'right', 0x1000
|
||||
0x4000: 'x', 0x0010: 'start'}
|
||||
|
||||
|
||||
def in_front(root):
|
||||
"""Whether the window the user is typing into belongs to this process. XInput reads the pad whichever window is in
|
||||
front, so without this check the launcher, left open behind the game, took the presses meant for the game: A
|
||||
activated its focused row (it started the game five times in five minutes and tried a rebuild), the stick moved
|
||||
its focus and Y checked for updates. True where it cannot tell."""
|
||||
if os.name != 'nt':
|
||||
return True
|
||||
try:
|
||||
user32 = ctypes.windll.user32
|
||||
user32.GetForegroundWindow.restype = ctypes.c_void_p
|
||||
user32.GetWindowThreadProcessId.restype = ctypes.c_uint
|
||||
user32.GetWindowThreadProcessId.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint)]
|
||||
hwnd = user32.GetForegroundWindow()
|
||||
if not hwnd:
|
||||
return False # no window in front (the desktop is switching, a lock screen): nothing is meant for us
|
||||
pid = ctypes.c_uint(0)
|
||||
user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
|
||||
return pid.value == os.getpid()
|
||||
except (AttributeError, OSError):
|
||||
return True
|
||||
|
||||
|
||||
class Gamepad:
|
||||
"""Polls the first XInput pad; poll() returns the buttons pressed since the last call (edges), the left stick
|
||||
counted as the d-pad."""
|
||||
counted as the d-pad. poll(False) still reads the pad but returns nothing: a button held while another window was
|
||||
in front does not count as pressed when this one comes back."""
|
||||
|
||||
def __init__(self):
|
||||
self.dll = None
|
||||
@@ -288,7 +311,7 @@ class Gamepad:
|
||||
except (AttributeError, OSError):
|
||||
continue
|
||||
|
||||
def poll(self):
|
||||
def poll(self, active=True):
|
||||
if not self.dll:
|
||||
return set()
|
||||
st = _XInputState()
|
||||
@@ -309,7 +332,7 @@ class Gamepad:
|
||||
break
|
||||
except OSError:
|
||||
return set()
|
||||
pressed = down - self.held
|
||||
pressed = down - self.held if active else set()
|
||||
self.held = down
|
||||
return pressed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user