Files
spoopyghosty0--frameport/tests/test_surface_projection.py
T

54 lines
2.6 KiB
Python

"""Video adapter freshness and its native stereo projection regression."""
import shutil
import subprocess
from pathlib import Path
import pytest
def test_video_patches_outdate_only_the_recipes_that_gain_them():
"""Batman's cutscene setup moved from a package check in frame.adapter to its recipe (frame.hw_video_decode +
adapter.surface_native): its build is outdated by the recipe change; other games' builds stay installed."""
from frameport.patches.base import get, recipe_fingerprint
from frameport.ui.components import install_state
# revision 2 (#365) adds the dormant foveation diagnostic to every build; this test is about the package check
assert get("frame.adapter").revision_for("com.example.other") == 2
before = {"patches": {"frame.adapter": {}}}
after = {"patches": {"frame.adapter": {}, "frame.hw_video_decode": {}, "adapter.surface_native": {"value": 1}}}
for package, recipe, expected in (("com.camouflaj.manta", after, "outdated"),
("com.example.other", before, "installed")):
game = {"package": package, "recipe": recipe,
"build": {"sha256": "installed", "recipe_fp": recipe_fingerprint(before, package)}}
frame = {"installed": [{"package": package, "sha256": "installed"}]}
assert install_state(game, frame) == expected
def test_projection_shader_validates(tmp_path):
compiler, validator = shutil.which("glslangValidator"), shutil.which("spirv-val")
if not compiler or not validator:
pytest.skip("Shader regression requires glslangValidator and spirv-val")
root = Path(__file__).resolve().parents[1]
binary = tmp_path / "projection.spv"
subprocess.run([compiler, "-V", "--target-env", "vulkan1.0",
str(root / "native/adapter/surface_projection.comp"), "-o", str(binary)], check=True)
subprocess.run([validator, "--target-env", "vulkan1.0", str(binary)], check=True)
def test_video_compositor_revision_outdates_video_clients_only():
from frameport.patches.base import get, recipe_fingerprint
patch = get("adapter.surface_native")
current = patch.revision
assert current == 4
video = {"patches": {"frame.adapter": {}, "adapter.surface_native": {"value": 1}}}
ordinary = {"patches": {"frame.adapter": {}}}
new_video = recipe_fingerprint(video, "test.video")
new_ordinary = recipe_fingerprint(ordinary, "test.game")
try:
patch.revision = 3
assert recipe_fingerprint(video, "test.video") != new_video
assert recipe_fingerprint(ordinary, "test.game") == new_ordinary
finally:
patch.revision = current