Files
spoopyghosty0--frameport/tests/test_fade_quad.py
T
spoopyghosty0 c29cef5f97 FrameBridge: fade_quad draws colour-scale fades as a black quad over the picture (#197)
Opt-in game setting (Picture -> Draw fades over the picture). Batman: Arkham Shadow fades by dimming its projection
layer with XR_KHR_composition_layer_color_scale_bias; with fade_quad=1 FrameBridge adds a black, alpha-blended quad
right after the dimmed layer (VIEW space, 1 m ahead), opacity = 1 - scale in 16 steps. One 8x8 swapchain, refilled
only when the step changes (Vulkan clear on the app's queue / GLES clear in its context); one swapchain per step hit
XR_ERROR_LIMIT_REACHED. fade_quad=2 also removes the layer's own scale. Device (headless, Batman): swapchain created,
level 16/16 on the first frame, no xrEndFrame errors, 72 fps.
2026-10-12 21:40:01 -04:00

33 lines
1.4 KiB
Python

"""fade_quad (FrameBridge, GitHub #197): colour-scale fades drawn as a black quad over the picture."""
import os
import shutil
import subprocess
from pathlib import Path
import pytest
from frameport.patches import base
from frameport.patches.settings import UI, adapter_settings
ROOT = Path(__file__).resolve().parents[1]
def test_fade_levels_follow_the_colour_scale(tmp_path):
cc = shutil.which("cc") or shutil.which("gcc") or shutil.which("clang")
if not cc or os.name == "nt":
pytest.skip("needs a POSIX host C compiler")
binary = tmp_path / "fade-level-test"
subprocess.run([cc, "-std=c11", "-Wall", "-Wextra", "-Werror", "-I", str(ROOT / "native/adapter"),
str(ROOT / "tests/fixtures/src/fade_level_test.c"), "-o", str(binary), "-lm"], check=True)
subprocess.run([str(binary)], check=True)
def test_fade_quad_is_an_opt_in_game_setting():
base.load_all()
p = base.REGISTRY["adapter.fade_quad"]
assert p.default == 0 # opt-in: the owner asks testers first (Batman's catalog recipe doesn't set it)
assert adapter_settings({"adapter.fade_quad": {"value": 1}})["fade_quad"] == 1
assert UI["fade_quad"]["group"] == "picture" and UI["fade_quad"]["control"] == ("switch",)
# the adapter reads the key (a renamed setting would silently do nothing)
assert 'sscanf(line, "fade_quad=%f"' in (ROOT / "native/adapter/frame_adapter.c").read_text()