Skip to content

Build the FSR 3.1.5 upscaler - #10

Merged
viktor-ferenczi merged 2 commits into
mainfrom
fsr
Aug 29, 2026
Merged

Build the FSR 3.1.5 upscaler#10
viktor-ferenczi merged 2 commits into
mainfrom
fsr

Conversation

@viktor-ferenczi

Copy link
Copy Markdown
Contributor
  • Adds Scripts/build_fidelityfx.sh, which builds libamd_fidelityfx_loader_dx12.so — the FSR upscaler Space Engineers 2 P/Invokes as amd_fidelityfx_loader_dx12.dll — from the AMD FSR SDK v2.3.0 and stages it into the SE2 archive. The ffx_api dispatcher, the DX12 backend and the FSR 3.1.5 provider are linked into one object, so AMD's provider-DLL discovery never runs.
  • Compiles the DX12 backend against vkd3d-proton's installed headers, so the COM vtables it is built against are by construction the ones the game passes in. The step runs after build_vkd3d_proton.sh and invokes it when those headers are missing.
  • Generates the FSR 3.1 shader permutations during the build (ten passes, four variants each, six boolean options) with AMD's FidelityFX_SC, ported to Linux from SDK v1.1.4 because the 2.x releases ship it as a Windows binary only. It is driven by a second, stock DXC build, cached separately and not shipped: the shipped libdxcompiler.so carries the SE2 WCHAR ABI patch and cannot be called by a normal 4-byte-wchar_t host tool.
  • Adds Patches/fidelityfx/{sdk,ffx-sc}/, the Linux port itself, together with the provider registry the SDK declares but leaves for each shipping loader DLL to define. Only FSR 3.1.5 is registered — FSR 4.x is a prebuilt Windows DLL and the driver-side provider is closed source.
  • Ships LICENSES/FidelityFX-{LICENSE,README}.txt. The SDK's default terms are binary-redistribution-only; MIT applies through the exception list in its own docs/license.md, and every one of the 107 files this build compiles is named there.
  • Caches the new step in CI, with the host DXC keyed on the DXC commit alone so that editing Patches/dxc/ does not trigger another full DXC build.
  • Documents the dependency, its pins, the port and the bump procedure across README.md and docs/.

Space Engineers 2 P/Invokes five entry points -- ffxCreateContext,
ffxDestroyContext, ffxConfigure, ffxQuery and ffxDispatch -- from
"amd_fidelityfx_loader_dx12.dll" when the graphics Quality setting
selects FSR upscaling. That is AMD's flat ffx_api ABI, with
vkd3d-proton's own ID3D12Device/ID3D12Resource pointers passed straight
through, so a native SysV .so exporting those five symbols works as-is.

- Adds `Scripts/build_fidelityfx.sh`, which builds
`libamd_fidelityfx_loader_dx12.so` from the AMD FSR SDK v2.3.0 and
stages it into the SE2 archive. The ffx_api dispatcher, the DX12 backend
and the FSR 3.1.5 provider are linked into one object, so AMD's
provider-DLL discovery never runs. FSR 4.x has no source and the
driver-side provider lives in AMD's closed tree, so 3.1.5 is the only
upscaler included.
- Compiles the DX12 backend against vkd3d-proton's installed headers, so
the vtables it is built against are by construction the ones the game
passes in. The step therefore runs after `build_vkd3d_proton.sh`, and
invokes it when those headers are missing.
- Compiles the ten FSR 3.1 passes to DXIL during the build, in four
variants each (wave32/wave64 x fp32/fp16) with six boolean shader
options expanded into 64 permutations, transcribing the SDK's own
`BuildFSR3UpscalerShaders.bat`. The compiler is AMD's FidelityFX_SC,
ported to Linux from SDK v1.1.4 -- the 2.x releases ship it as a Windows
binary only.
- Builds a second, STOCK DXC for that tool (`build/dxc-host`, same pin as
`build_dxc.sh`, read out of it rather than duplicated): the shipped
libdxcompiler.so carries the SE2 2-byte-WCHAR ABI patch and is
deliberately incompatible with a normal 4-byte-wchar_t caller. It is
cached under its own stamp and is not shipped.
- Adds `Patches/fidelityfx/{sdk,ffx-sc}/`, the Linux port itself:
MSVC-only CRT calls, the AGS and PIX tracing paths, MSVC-only d3dx12.h
helpers, Win32 diagnostics, `D3D12SerializeRootSignature` resolved
through dlopen against libvkd3d-proton-d3d12.so, and two consequences of
4-byte wchar_t (narrowing at the D3D12 ABI, and a private context that
outgrows the SDK's own size reservation). It also supplies
`GetProvider()`/`GetProviderVersions()`, which the SDK declares but
leaves for each shipping loader DLL to define.
- Ships `LICENSES/FidelityFX-{LICENSE,README}.txt`. The SDK's default
terms are binary-redistribution-only; MIT applies through the exception
list in its own `docs/license.md`, and every one of the 107 files this
build compiles is named there.
- Caches the new step in CI, with the host DXC keyed on the DXC commit
alone so editing `Patches/dxc/` does not cost another 19-minute build.

Verified in-game: "FSR upscaler provider selected: 3.1.5" in the Render12
log, a loaded world rendering with no ffx asserts and no artifacts.
The FidelityFX build compiles its DX12 backend against the headers
vkd3d-proton installs, but CI cached only that step's staged .so files.
On a warm run the vkd3d-proton build was skipped, the install destdir
never existed, and the FidelityFX step aborted with "vkd3d-proton headers
not found".

- Treats `build/vkd3d-proton-out/include/vkd3d-proton/` as an output of
`build_vkd3d_proton.sh`: its presence is part of the cache check, so a
tree (or a restored cache entry) that has the libraries but not the
headers rebuilds instead of being re-used, and the build asserts the
headers were installed before staging.
- Adds `ARTEFACT_REV` to that script's stamp, following `build_sdl3.sh`'s
`CONFIG_REV`. The commit and patch hash alone would still match the cache
entry saved before this change, and cache entries are immutable, so the
identity has to move for CI to save an entry that contains the headers.
- Caches `build/vkd3d-proton-out/include` alongside the libraries.
@viktor-ferenczi viktor-ferenczi changed the title Build the FSR 3.1.5 upscaler for Linux Build the FSR 3.1.5 upscaler Aug 29, 2026
@viktor-ferenczi
viktor-ferenczi merged commit 3519dc8 into main Aug 29, 2026
1 check passed
@viktor-ferenczi
viktor-ferenczi deleted the fsr branch August 29, 2026 19:16
viktor-ferenczi added a commit to CometWorks/linux-compat2 that referenced this pull request Aug 29, 2026
- Maps `amd_fidelityfx_loader_dx12` onto the bundled
`libamd_fidelityfx_loader_dx12.so` in `LinuxNativeLibraryResolver`, with
`SE2_FIDELITYFX_LIBRARY` as the override. The name-to-path switch
becomes a shared helper, reused by a new non-throwing probe.
- Turns `UpsamplingPatch` from an unconditional FSR-to-FXAA substitution
into an availability gate: the library is probed once, and only a
missing or unloadable one falls back to FXAA. The gate has to stay
because `FSR4_1.TryCreateContext` does not guard against a failing
context despite its name, so the P/Invoke would otherwise take down the
render thread.
- Forces `ForceUseFSR_3_1` in the same postfix, since the bundled
library carries the FSR 3.1.5 provider only. The getter returns a copy
of the settings struct, so the player's own setting is untouched.

Depends on the SE2 dependency archive gaining the upscaler library
(CometWorks/linux-dependencies#10).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant