Merge pull request #1245: AMD FSR 4 as a fourth scene upscaler, scene_upscaler = fsr4 (codexx-dev)

The PR's FSR 4 path (runtime/vk_ffx.c over AMD's FSR SDK 2.4 signed libraries, ffx_api_min.h, the cooperative
matrix and float8 device extensions in vk_device.c), its setup step that downloads amd_fidelityfx_loader_vk.dll and
amd_fidelityfx_upscaler_vk.dll, its notices and the FXAA copy shader hash 0x9d065204aac9766b now serve dev's own
scene upscaler as UPSCALER_FSR4. FSR 4 goes through vk_dlaa.c fsr_evaluate beside FSR 3.1: the same frame point,
jitter, motion vectors with the per-object pass, camera from vk_fg_camera, mip bias, fsr_sharpness, FXAA skip and
dynamic resolution hold.

Dropped from the PR: the dlaa_backend setting, FSR 3 through the DLL and the separate Upscalers row. vk_ffx.c pins
FSR 4 only; a device the libraries offer no FSR 4 for runs with the upscaler off and the menu says so. It keeps one
context per output size with dynamic resolution, like vk_fsr3.cpp, waits on the SDK's ring depth and is released
before the device goes. The menu's scene upscaler row gets "AMD FSR 4" (Windows; marked when the libraries or the
GPU are missing). The setup's FSR box and its strings are in all eleven installer catalogs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-23 14:13:20 +03:00
commit be98dbc336
37 files changed
+1183 -133

No files matched your search

+18 -2
View File
@@ -41,8 +41,8 @@ from installer.runner import Context # noqa: E402
from installer.steps import Fonts, all_steps # noqa: E402
from installer.guilogic import (DONE, FAILED, PENDING, RUNNING, SKIPPED, UI_LANGUAGE_LABELS, # noqa: E402
UI_LANGUAGES, Catalog, Form, Model, Process, amount, default_game_language,
describe_event, parse_line, ui_language_for_langid, ui_language_for_locale,
windows_ui_language)
describe_event, fsr_default, parse_line, ui_language_for_langid,
ui_language_for_locale, windows_ui_language)
INSTALLED = ROOT / 'build' / 'install-test'
FIXTURE = ROOT / 'build' / 'inst-gui' / 'e2e-install'
@@ -182,6 +182,22 @@ class RunStatesTest(unittest.TestCase):
self.assertEqual(m.result, 'ok')
class FsrDefaultTest(unittest.TestCase):
"""Download AMD FSR is ticked at start with an AMD adapter only: not with other GPUs, nor when no adapter could be
listed."""
def test_amd(self):
self.assertTrue(fsr_default(['AMD Radeon RX 9060 XT']))
self.assertTrue(fsr_default(['Intel(R) UHD Graphics', 'AMD Radeon(TM) Graphics']))
def test_other_gpus(self):
self.assertFalse(fsr_default(['NVIDIA GeForce RTX 4080 SUPER']))
self.assertFalse(fsr_default(['Intel(R) Arc(TM) A770 Graphics', 'Microsoft Basic Render Driver']))
def test_unknown(self):
self.assertFalse(fsr_default([]))
class FormTest(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.TemporaryDirectory()
+86 -1
View File
@@ -1297,7 +1297,7 @@ class FontsTest(unittest.TestCase):
def test_all_steps_order(self):
self.assertEqual([s.id for s in steps.all_steps()],
['check', 'kit', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'pc_prompts', 'shapes', 'dlss',
'cleanup'])
'fsr', 'cleanup'])
def test_extracts_into_the_install_folder(self):
self.fake_tool()
@@ -1612,5 +1612,90 @@ class HostProbeTest(unittest.TestCase):
self.assertIn(part, text[key], f'{path.name} {key}')
@unittest.skipUnless(steps.os.name == 'nt', 'FSR is Windows-only')
class FsrTest(unittest.TestCase):
"""The FSR step: off without --fsr, Windows-only, keeps a player's libraries, installs both files or none."""
NAMES = ('amd_fidelityfx_loader_vk.dll', 'amd_fidelityfx_upscaler_vk.dll')
def setUp(self):
self.tmp = tempfile.TemporaryDirectory()
base = Path(self.tmp.name)
self.dest, temp, src = base / 'dest', base / 'temp', base / 'src'
for d in (self.dest, temp, src):
d.mkdir()
files = []
for i, name in enumerate(self.NAMES):
(src / name).write_bytes(bytes([65 + i]) * (1000 + i))
files.append((name, 1000 + i, steps.file_sha256(src / name)))
self.src = src
self.saved = steps.FSR_BASE, steps.FSR_FILES
steps.FSR_BASE = src.as_uri() + '/' # urllib reads file: URLs as it reads https: ones
steps.FSR_FILES = tuple(files)
amd = {'devices': [{'name': 'AMD Radeon RX 9070 XT', 'api': [1, 4, 0], 'type': 2}]}
self.ctx = SimpleNamespace(dest=self.dest, temp=temp, host=amd, reporter=Reporter(out=io.StringIO()),
options=SimpleNamespace(fsr=True))
def tearDown(self):
steps.FSR_BASE, steps.FSR_FILES = self.saved
self.ctx.reporter.close()
self.tmp.cleanup()
def warnings(self):
return [json.loads(line)['id'] for line in self.ctx.reporter.out.getvalue().splitlines()
if json.loads(line)['type'] == 'warning']
def test_off_without_the_option(self):
self.ctx.options.fsr = False
self.assertEqual(steps.Fsr().run(self.ctx), {})
self.assertFalse(any((self.dest / n).exists() for n in self.NAMES))
self.assertNotEqual(steps.Fsr().key(self.ctx), steps.Fsr().key(SimpleNamespace(options=SimpleNamespace(fsr=True))))
def test_downloads_and_checks_both_libraries(self):
rec = steps.Fsr().run(self.ctx)
self.assertEqual(rec, {'installed': steps.FSR_VERSION})
for n in self.NAMES:
self.assertEqual((self.dest / n).read_bytes(), (self.src / n).read_bytes())
self.assertFalse(list(self.ctx.temp.iterdir()))
self.assertTrue(steps.Fsr().current(self.ctx, rec))
(self.dest / self.NAMES[1]).unlink()
self.assertFalse(steps.Fsr().current(self.ctx, rec))
def test_a_wrong_file_installs_neither(self):
name, size, _ = steps.FSR_FILES[1]
steps.FSR_FILES = (steps.FSR_FILES[0], (name, size, '0' * 64))
rec = steps.Fsr().run(self.ctx)
self.assertEqual(rec, {'failed': True})
self.assertFalse(any((self.dest / n).exists() for n in self.NAMES))
self.assertFalse(list(self.ctx.temp.iterdir()))
self.assertEqual(self.warnings(), ['warn.fsr_download_failed'])
self.assertFalse(steps.Fsr().current(self.ctx, rec))
def test_keeps_the_players_libraries(self):
(self.dest / self.NAMES[1]).write_bytes(b'newer')
self.assertEqual(steps.Fsr().run(self.ctx), {'kept': True})
self.assertEqual((self.dest / self.NAMES[1]).read_bytes(), b'newer')
self.assertFalse((self.dest / self.NAMES[0]).exists())
self.assertEqual(self.warnings(), ['warn.fsr_kept'])
def test_downloads_on_an_nvidia_gpu(self):
self.ctx.host = {'devices': [{'name': 'NVIDIA GeForce GTX 1050', 'api': [1, 3, 0], 'type': 2}]}
rec = steps.Fsr().run(self.ctx)
self.assertEqual(rec, {'installed': steps.FSR_VERSION})
for name in self.NAMES:
self.assertEqual((self.dest / name).read_bytes(), (self.src / name).read_bytes())
def test_old_no_amd_skip_record_is_retried(self):
old_key = steps.fingerprint('fsr-1', steps.FSR_VERSION,
*(sha for _, _, sha in steps.FSR_FILES))
state = {'format': 1, 'release': 'old', 'inputs': {},
'steps': {'fsr': {'key': old_key, 'release': 'old', 'skipped': 'no_amd'}}}
ctx = runner.Context(SimpleNamespace(release='new'), self.dest, self.ctx.temp, self.ctx.reporter,
self.ctx.options, state=state)
ctx.steps = [steps.Fsr()]
ctx.plan()
self.assertTrue(ctx.runs['fsr'])
if __name__ == '__main__':
unittest.main()