Engine: RTX VSR over a game on Wayland crashed the engine at once

The overlay's window is an X11 (GLX) one on a Wayland session, but PyOpenGL
picked EGL there and couldn't look up newer GL functions for that context:
glTexStorage2D was a null function, and RTX VSR's first frame ended the engine
(Summit's picture flashed up and closed). PyOpenGL now uses GLX along with
pyGLFW's X11 build.

And a failing RTX VSR no longer ends the session: that frame is drawn without
it, VSR comes off the list, FSR 1 takes over, and a message says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ZebraticandClaude Opus 5.5 committed 2026-11-25 02:59:32 +01:00
1 parent d44502447b
commit 023f8b3ecc
2 files changed
+43 -4

No files matched your search

+28 -4
View File
@@ -575,6 +575,11 @@ class GLWindowSink:
# open the XWayland window the overlay needs ("glfw init failed"): load the X11 one. Read on the first
# `import glfw`, which is this one.
os.environ.setdefault("PYGLFW_LIBRARY_VARIANT", "x11")
# ...and PyOpenGL has to look functions up through GLX too: in a Wayland session it picks EGL, which
# gives an X11 window's context no newer functions (glTexStorage2D: RTX VSR crashed the engine).
# Read on PyOpenGL's first import, which is just below.
if "OpenGL" not in sys.modules:
os.environ.setdefault("PYOPENGL_PLATFORM", "glx")
import glfw
from OpenGL import GL
@@ -1688,8 +1693,8 @@ class GLWindowSink:
src, fbo = self.look_gl.input_target(dw, dh)
self.fsr.draw(self.tex, self.w, self.h, fbo, 0, 0, dw, dh)
flip_in = True # (FSR draws upright)
elif upscale and mode == "vsr":
src, flip_in = self._vsr_render(round(dw * ss), round(dh * ss))[0], False
elif upscale and mode == "vsr" and self._vsr_safely(lambda: self._vsr_render(round(dw * ss), round(dh * ss))):
src, flip_in = self.vsr_out[0], False
else:
src, flip_in = self.tex, False # the look's first pass resizes it
self.look_gl.draw(plan, src, flip_in, target, x0, y0, dw, dh, True, self._frame_no)
@@ -1698,8 +1703,8 @@ class GLWindowSink:
elif upscale and mode == "fsr":
self.fsr.draw(self.tex, self.w, self.h, target, x0, y0, dw, dh)
GL.glViewport(0, 0, fw, fh)
elif upscale and mode == "vsr":
self._vsr_draw(x0, y0, dw, dh, ss)
elif upscale and mode == "vsr" and self._vsr_safely(lambda: self._vsr_draw(x0, y0, dw, dh, ss)):
pass
else:
GL.glBindFramebuffer(GL.GL_READ_FRAMEBUFFER, self.fbo)
# Image row 0 is the top; GL row 0 is the bottom, so blit with destination Y flipped.
@@ -1734,6 +1739,25 @@ class GLWindowSink:
cmd, self.cmd = self.cmd, None
return cmd
def _vsr_safely(self, draw) -> bool:
"""Runs a VSR draw. If it fails, RTX VSR is off for the rest of the session (out of the upscaler list, FSR 1
in its place, a message saying why) and this frame is drawn without it: the game goes on either way."""
try:
draw()
return True
except Exception as e: # noqa: BLE001 - an optional upscaler never ends the session
why = f"{type(e).__name__}: {str(e)[:160]}"
print(f"[display] RTX VSR failed, switching to FSR 1 for this session ({why})", flush=True)
try:
self._vsr_target_free()
except Exception: # noqa: BLE001 - tidying up after a failure
pass
self.vsr_out, self.vsr, self._vsr_args, self.vsr_why = None, None, None, f"it failed here ({why})"
self.modes = [m for m in self.modes if m != "vsr"]
self.mode = "fsr" if "fsr" in self.modes else self.modes[0]
self.toast("RTX VSR stopped working, so Summit switched to FSR 1. The log says why.", 6.0)
return False
def _vsr_draw(self, x0: int, y0: int, dw: int, dh: int, ss: float = 1.0) -> None:
"""RTX VSR from the staged RGBA frame straight into a window-sized GL texture, then a 1:1 blit."""
GL = self.GL
+15
View File
@@ -371,3 +371,18 @@ def test_the_mouse_anywhere_on_a_tab_without_a_scrollbar_or_list():
m.hover(x, y)
m.grab(x, y)
m.release()
def test_a_failing_rtx_vsr_falls_back_to_fsr_instead_of_ending_the_session():
import types
from framegen.io import GLWindowSink
said = []
w = types.SimpleNamespace(vsr_out=None, vsr=object(), _vsr_args=(1, 1, False), vsr_why=None,
modes=["fsr", "vsr", "bilinear", "off"], mode="vsr",
_vsr_target_free=lambda: None, toast=lambda t, s=2.0: said.append(t))
def boom():
raise RuntimeError("no glTexStorage2D")
assert GLWindowSink._vsr_safely(w, boom) is False
assert w.mode == "fsr" and "vsr" not in w.modes and w.vsr is None and "no glTexStorage2D" in w.vsr_why
assert said and "FSR" in said[0]
assert GLWindowSink._vsr_safely(w, lambda: None) is True