Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d47fe6640 |
No files matched your search
@@ -19,6 +19,27 @@ GitHub release body, so a missing section will mean an empty release note.
|
||||
|
||||
### Added
|
||||
|
||||
- **The FSR 3.0 host route: a fifth AMD target, `ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale`.**
|
||||
Cyberpunk 2077 at FSR 3 upscales through the FSR 3.0 **host** DLL's named export while its frame
|
||||
generation goes through the 1.1.x monolith's `ffxDispatch`, so the leaf-only build printed
|
||||
`upscaler: N/A` beside `FsrFg` (§H11, 2026-09-04). The host is hooked at its own export with its own
|
||||
trampoline and latch, keyed by module in the installer, under the same family and publish point as
|
||||
the four ffx-api rows (`PublishFfxFamilyIfWhole` waits for a loaded host as it waits for a loaded
|
||||
leaf); its UPSCALE feeds the same drain word — identity `FSR3` as a fact, `renderSize` as the
|
||||
extent, the count when neither Streamline nor a PREPARE has spoken. Rule 4: `renderSize` of the
|
||||
descriptor the title passed and nothing else; the offset is pinned to a literal (1256).
|
||||
`ffxFsr3DispatchFrameGeneration` is deliberately not a row, with the reversal condition
|
||||
pre-committed in §H11. **The headers are vendored from tag `fsr3-v3.0.4`, not the `v1.1.4` three
|
||||
documents named**: the shipped module's twelve `ffxFsr3*` exports match 3.0.4 exactly, 1.1.4
|
||||
declares fifteen and appends fields after `renderSize`, and at 3.0.4 `ffx_types.h` reaches no
|
||||
`<mutex>` at all (ten files, no `ffx_message.h`; `src/native/third_party/fidelityfx-fsr3/`, root
|
||||
`LICENSE.txt` MIT verbatim, `license-check.ps1` §2e per file, blob shas checked against upstream).
|
||||
The two FidelityFX trees share one struct name, so the 3.0.4 header is included inside a
|
||||
namespace. Fixtures: the `ffx_fsr3_x64.dll` stub (Pass C's second positive control), harness
|
||||
topologies `fsr3host` / `fsr3host+mono`, an `[ffx]` injected case at K = 1 (the row's double-count
|
||||
control) and K ∈ {1, 4} beside the monolith, and a consumer case for Cyberpunk's shape. Owed: the
|
||||
owner's acceptance run, rows B1–B4 in §H11.
|
||||
|
||||
- **A whole-resource tag now yields the size the tagged `sl::Resource` declares.** Streamline
|
||||
documents a zero `extent` as "use the entire resource"; a title tagging that way stated the
|
||||
render size nowhere the Overlay read, and Dying Light: The Beast (SL 2.8.0) still published no
|
||||
|
||||
+7
-2
@@ -269,8 +269,13 @@ F_app = Σ fgEvaluations (APPLICATION frames, counted at the
|
||||
> the first** is 7c's own rule, and this is it.
|
||||
>
|
||||
> The acceptance table for the owner's three launches is pre-committed in `20_OPEN_QUESTIONS` §H11.
|
||||
> What this route does NOT reach: the FSR 3.0 host DLLs (`ffx_fsr3_x64.dll`, named exports, deferred
|
||||
> to their own PR), statically linked FSR (§Scope decisions), and Intel (closed at the census).
|
||||
> What this route does NOT reach: statically linked FSR (§Scope decisions) and Intel (closed at the
|
||||
> census). **The FSR 3.0 host DLL is reached since 2026-09-05** — a fifth AMD target,
|
||||
> `ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale` (Cyberpunk 2077's copy; named export, its own
|
||||
> descriptor, tag `fsr3-v3.0.4`), whose UPSCALE feeds the same drain word: identity `FSR3` as a
|
||||
> fact, `renderSize` as the extent, and the count from its upscales when neither Streamline nor a
|
||||
> PREPARE has ever spoken. On Cyberpunk the count stays Streamline's and `FsrFg` stays the
|
||||
> monolith's; the host adds the identity the leaf-only build printed as `N/A`.
|
||||
|
||||
> **MEASURED 2026-08-15, AND IT CHANGES WHAT THIS SECTION CAN PROMISE.** On the one title
|
||||
> measured — Cyberpunk 2077, SL 2.7.1 — `slEvaluateFeature(kFeatureDLSS_G)` is **never
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ Targets:
|
||||
- `fl-probe-hookprofile` → build-profile probes for `/guard:cf` and `-D_HAS_EXCEPTIONS=0` (`20_OPEN_QUESTIONS` §H1/§H3)
|
||||
- `fl-probe-guard` → measures the Windows APIs the guard is built on, unelevated (`spike-notes.md` §1). Not the guard, and takes no injection rights.
|
||||
- `fl_stub_sl_interposer` → `sl.interposer.dll`, and `fl_stub_sl_common` → `sl.common.dll` (`src/native/tools/vendor-stubs/`). **Fixtures, never shipped**, built under `FL_BUILD_TOOLS`; nothing `12_BUILD` publishes references them. They export the **measured** vendor names from `docs/vendor-exports.json` so the Overlay's symbol resolution is observable, and the second is a **decoy** exporting the same name from a different module — without it, "we resolve module-scoped" is a property no test can falsify. Their **output filenames are the vendor's and their version blocks are ours**: `fl_add_version_resource` takes the real filename so a file called `sl.interposer.dll` in our build tree still says plainly that it is FrameLedger's, which `19_SAFETY` requires of everything we build.
|
||||
- `fl_stub_ffx_dx12` → `amd_fidelityfx_dx12.dll`, `fl_stub_ffx_upscaler` → `amd_fidelityfx_upscaler_dx12.dll`, `fl_stub_ffx_fg` → `amd_fidelityfx_framegeneration_dx12.dll` — the three AMD **leaves** — and `fl_stub_ffx_loader` → `amd_fidelityfx_loader_dx12.dll`, a **forwarding stand-in** bound to the two 2.x leaves through their FrameLedger-named *direct* entry — the way the real loader was measured to bypass the leaves' exports — so `--hold-presenting-ffx` can push every dispatch through a loader that is hooked along with the leaves and prove the count reads 1× (2026-09-04). Same rules as the Streamline stubs: fixtures, never shipped, vendor filenames with our version blocks.
|
||||
- `fl_stub_ffx_dx12` → `amd_fidelityfx_dx12.dll`, `fl_stub_ffx_upscaler` → `amd_fidelityfx_upscaler_dx12.dll`, `fl_stub_ffx_fg` → `amd_fidelityfx_framegeneration_dx12.dll` — the three AMD **leaves** — and `fl_stub_ffx_loader` → `amd_fidelityfx_loader_dx12.dll`, a **forwarding stand-in** bound to the two 2.x leaves through their FrameLedger-named *direct* entry — the way the real loader was measured to bypass the leaves' exports — so `--hold-presenting-ffx` can push every dispatch through a loader that is hooked along with the leaves and prove the count reads 1× (2026-09-04). Same rules as the Streamline stubs: fixtures, never shipped, vendor filenames with our version blocks. `fl_stub_ffx_fsr3_host` → `ffx_fsr3_x64.dll` (2026-09-05): the FSR 3.0 **host** facade, exporting the four names `SpeaksFsr3Host` probes for through the vendored `fsr3-v3.0.4` header's own `FFX_API`; `--ffx-topology fsr3host|fsr3host+mono` drives it, and `hookinventory-check` Pass C reads it as the export parser's second positive control.
|
||||
- **`fl_fidelityfx_headers`** → an INTERFACE target over the five vendored FidelityFX ffx-api headers (`src/native/third_party/fidelityfx/`, tag v2.3.0, MIT by exception). Three include directories because upstream's headers include each other by relative path; include directories only and nothing to link — no `.lib` is vendored — and `hookinventory-check` Pass C reads the Overlay's export table because `ffx_api.h` declares its entry points `__declspec(dllexport)` unconditionally.
|
||||
- **`fl_streamline_headers`** → an INTERFACE target over the vendored MIT Streamline headers (`src/native/third_party/streamline/`). Include directories only, **never linked**: `SL_API` entry points are `extern "C"` imports, and linking one would make `sl.interposer.dll` a load-time dependency of `FrameLedger.Overlay.dll`, which would stop the Overlay loading in every game that ships no Streamline — in the loader, before any of our code runs, with no message anywhere.
|
||||
|
||||
|
||||
@@ -151,9 +151,9 @@ Every hook must be listed here with a purpose. Anything not on this list is not
|
||||
| ✅ Streamline: `slEvaluateFeature` · ⏳ `slInit`, `slSetFeatureLoaded`, `slSetConstants`, `slGetFeatureRequirements` | Feature set actually active when the game goes through SL rather than NGX directly (`kFeatureDLSS`, `DLSS_G`, `DLSS_RR`, `Reflex`, `NIS`). **Built 2026-08-09**, identity only: one MinHook detour on `sl.interposer.dll!slEvaluateFeature`, resolved **module-scoped** and installed lazily by the watchdog. Sets `FL_MEASURED_UPSCALER` + `FL_HOOK_UPSCALER_IDENTITY`; decodes `kFeatureDLSS`/`kFeatureNIS` and reports `FL_UPSCALER_UNKNOWN` for anything else. **Never `FL_UPSCALER_NONE`** — a Streamline-only writer cannot see FFX, XeSS or NGX-direct, and `NONE` is the only one of the three states that may be aggregated as a negative |
|
||||
| ✅ Streamline: `slSetTag` | The **global** resource tags, where a title states the size of the buffer it is upscaling *from*: `kBufferTypeScalingInputColor`'s extent → `renderW/H` — **or, since 2026-09-05, the size the tagged `sl::Resource` declares when the extent is zero** (`TagSize` in `fl_sl_inputs.h`, shared by all three tag routes; GUID-checked; a Resource declaring no size is still the honest unknown). **Built 2026-08-15** (`FL_HOOK_UPSCALER_PARAMS`), and it is an ALTERNATIVE to the local tags in `slEvaluateFeature`'s `inputs`, not a layer over them — `sl_core_api.h:258` says global and local tags "do NOT interact", so a title using one yields nothing from the other and both are read. Published only on a frame where an evaluation was also seen, because a tag is viewport state that outlives any one frame. This row was MISSING from this table while the hook shipped, which is the gap the banner above now names |
|
||||
| ✅ Streamline: `slSetTagForFrame` | The same global tags through **Streamline 2.8's frame-based entry point**, which deprecates `slSetTag`: `(const FrameToken&, const ViewportHandle&, const ResourceTag*, uint32_t, CommandBuffer*)` — the token first, then exactly `slSetTag`'s list, handed to the same tag walk. **Built 2026-09-04** (`FL_HOOK_UPSCALER_PARAMS`, its own trampoline; the family is now **published when whole** — once every tag export the loaded interposer has is patched — because publishing on the first row entitled records the second was not yet producing, 38 of 41 on the fixture: the ffx leaves' #110 defect again, fixed the same way). Measured need: Dying Light: The Beast (SL 2.8.0) published `Dlss` identity on every batch and the params bit on none across three captures, because a 2.8 title that tags per frame never calls the deprecated export. The token is not read; the frame count stays with `slGetNewFrameToken`. The installer picks this detour by SYMBOL (`kSymbolSlSetTagForFrame`, bound to the row by `static_assert`), not by family, since the two rows share a family bit and differ in signature |
|
||||
| ✅ **FidelityFX ffx-api: `ffxDispatch` on the FOUR modules a game calls** — `amd_fidelityfx_dx12.dll` (SDK 1.1.x monolith), `amd_fidelityfx_upscaler_dx12.dll`, `amd_fidelityfx_framegeneration_dx12.dll`, **and `amd_fidelityfx_loader_dx12.dll`** (added the evening of 2026-09-04: three loader-shipping titles at FSR produced zero dispatches at any leaf export, so the loader is where their calls arrive) · ⏳ FSR 3.0 host route `ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale` / `ffxFsr3DispatchFrameGeneration` · ~~`ffxFsr2ContextCreate`~~ · ~~`ffxCreateContext`~~ | **Built 2026-09-04** (`HANDOFF` item 7c). One observer behind three trampolines reads the DESCRIPTOR the title passed — head type first, body only after the type matched a constant from the vendored MIT headers (`third_party/fidelityfx/`, tag v2.3.0): **UPSCALE** → identity (`FSR3` from the monolith, `FSR_UNVERSIONED` from the 2.x upscaler DLL, which hosts FSR 3.1 and FSR 4 behind one type) + `renderSize` → `renderW/H` (quality and sharpness `0xFF`: the dispatch carries neither) + one COUNT; **PREPARE / PREPARE_V2** → `frameID` counted on a *new* index only — this vendor's `slGetNewFrameToken`, the `fgEvaluations` producer once a title has ever prepared, with the UPSCALE count as the fallback for a title that never does; **FRAMEGENERATION** → `fgMode = FSR_FG` on that present. Rule 4: the argument of the API we hooked, never `context`, `pNext`, a command list or a resource. **Why all four:** a UE5 title ships the two leaves with no loader and calls their exports; a loader-shipping title calls the loader's export and the signed loader reaches its providers through an object, not the leaves' exports (measured: Dying Light: The Beast, KCD2, Wukong). The morning's "never the loader" rested on the export tables alone and was reversed by the run. What guards against a loader that DID re-enter a leaf's export is the K = 1 control with all four hooked and the consumer's `frames/upscale-drained`, both of which read 2× in that case. `ffxCreateContext` is deliberately NOT a row — nothing it carries fills a field the dispatch does not, and its honest family would collide with `slEvaluateFeature`'s under the installer's equality binding. The family is compound (`IDENTITY \| PARAMS \| FG_EVALUATIONS`), pinned by `static_assert`s that also bind the leaf table to the rows both ways and refuse the loader as a row. Streamline keeps precedence for the count once it has ever issued a token, so every §S31-validated title is byte-identical. Second count: the consumer prints `frames/upscale-drained`, the AMD `tokens/batch`. **FSR 3.0** (Cyberpunk's `ffx_fsr3_x64.dll`, named exports) is its own later PR — ten host headers from tag v1.1.4, and one title here to test on |
|
||||
| ✅ **FidelityFX ffx-api: `ffxDispatch` on the FOUR modules a game calls** — `amd_fidelityfx_dx12.dll` (SDK 1.1.x monolith), `amd_fidelityfx_upscaler_dx12.dll`, `amd_fidelityfx_framegeneration_dx12.dll`, **and `amd_fidelityfx_loader_dx12.dll`** (added the evening of 2026-09-04: three loader-shipping titles at FSR produced zero dispatches at any leaf export, so the loader is where their calls arrive) · ⏳ FSR 3.0 host route `ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale` / `ffxFsr3DispatchFrameGeneration` · ~~`ffxFsr2ContextCreate`~~ · ~~`ffxCreateContext`~~ | **Built 2026-09-04** (`HANDOFF` item 7c). One observer behind three trampolines reads the DESCRIPTOR the title passed — head type first, body only after the type matched a constant from the vendored MIT headers (`third_party/fidelityfx/`, tag v2.3.0): **UPSCALE** → identity (`FSR3` from the monolith, `FSR_UNVERSIONED` from the 2.x upscaler DLL, which hosts FSR 3.1 and FSR 4 behind one type) + `renderSize` → `renderW/H` (quality and sharpness `0xFF`: the dispatch carries neither) + one COUNT; **PREPARE / PREPARE_V2** → `frameID` counted on a *new* index only — this vendor's `slGetNewFrameToken`, the `fgEvaluations` producer once a title has ever prepared, with the UPSCALE count as the fallback for a title that never does; **FRAMEGENERATION** → `fgMode = FSR_FG` on that present. Rule 4: the argument of the API we hooked, never `context`, `pNext`, a command list or a resource. **Why all four:** a UE5 title ships the two leaves with no loader and calls their exports; a loader-shipping title calls the loader's export and the signed loader reaches its providers through an object, not the leaves' exports (measured: Dying Light: The Beast, KCD2, Wukong). The morning's "never the loader" rested on the export tables alone and was reversed by the run. What guards against a loader that DID re-enter a leaf's export is the K = 1 control with all four hooked and the consumer's `frames/upscale-drained`, both of which read 2× in that case. `ffxCreateContext` is deliberately NOT a row — nothing it carries fills a field the dispatch does not, and its honest family would collide with `slEvaluateFeature`'s under the installer's equality binding. The family is compound (`IDENTITY \| PARAMS \| FG_EVALUATIONS`), pinned by `static_assert`s that also bind the leaf table to the rows both ways and refuse the loader as a row. Streamline keeps precedence for the count once it has ever issued a token, so every §S31-validated title is byte-identical. Second count: the consumer prints `frames/upscale-drained`, the AMD `tokens/batch`. **FSR 3.0 — BUILT 2026-09-05 as a fifth AMD target:** `ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale` (Cyberpunk's copy; named export, its own descriptor, vendored from tag **`fsr3-v3.0.4`** — the tag whose twelve `ffxFsr3*` declarations match the shipped module, not the `v1.1.4` first named). Rule 4: the detour reads `renderSize` of the descriptor the title passed and nothing else — never the context, a resource or the command list; the offset is pinned to a literal (1256) so a re-vendoring that moved it fails to compile. Same family and publish point as the four rows (`PublishFfxFamilyIfWhole` waits for a loaded host too), keyed by module in the installer; identity `FSR3` as a fact. `ffxFsr3DispatchFrameGeneration` is deliberately not a row (§H11 carries the reversal condition); the `ffx_fsr3upscaler_x64.dll` leaf is the pre-committed alternative if the facade reads silent (row B2) — never both, or `frames/upscale-drained` reads 2.00 |
|
||||
| XeSS: `xessD3D12CreateContext`, `xessD3D12Init`, `xessD3D12Execute` | `outputResolution`, `qualitySetting`, XeSS version; `xess_fg` variants for XeFG |
|
||||
| ✅ **Application frames per present** (`fgEvaluations`) — **`sl.interposer.dll!slGetNewFrameToken` since 2026-09-03** | Native vs Displayed frame counts at Tier 1 — see `03_METRICS` §Frame Generation. **The producer is the frame-token export**: Streamline hands a title one token per application frame and the title must ask; the detour counts distinct tokens between two presents (pointer changes, nothing dereferenced), `FL_HOOK_FG_EVALUATIONS` is its family, and it installs on every Streamline 2 title including the ones that evaluate nothing through `slEvaluateFeature`. Rule 4: the out-parameter of an API we hooked. Premise and its gate in `03_METRICS`; pre-committed table in `20_OPEN_QUESTIONS` §S31. *The row as it stood before:* ~~NGX/SL/FFX/XeSS FG feature evaluations per present. **Built 2026-08-15 for Streamline, and MEASURED TO YIELD NOTHING ON THAT ROUTE**~~ — `slEvaluateFeature(kFeatureDLSS_G)` is never called by Cyberpunk 2077 (0 across ~14,000 batches, four FG settings), so this row installs, is honest, and counts zero; see `docs/HANDOFF.md` item 3. Built on the detour that was already there: `kFeatureDLSS_G` contributes to a saturating COUNT in the same word the feature bits live in (`fl_sl_seen.h`) rather than to a bit, because a bit collapses several evaluations between two presents into one — and under multi-frame generation that is the common case, not the edge. The row's family is therefore compound (`FL_HOOK_UPSCALER_IDENTITY \| FL_HOOK_FG_EVALUATIONS`), pinned by a `static_assert` because `hookinventory-check` reads that column as an opaque identifier. **Counts EVALUATIONS, not generated frames** — the 2026-08-14 owner ruling; the multiplier lives in `sl::DLSSGOptions`, which is only reachable by the route §2b refused. ~~Non-NVIDIA FG vendors are **deferred with a written rationale**: `amd_fidelityfx_framegeneration_dx12.dll` 3.1.5 exports only the five generic `ffx*` entry points, identical to five sibling modules, so identity is in the arguments and we have no headers~~ — **AMD has a producer since 2026-09-04** (the FidelityFX row above: the PREPARE dispatch's `frameID`, or the UPSCALE count on a title that never prepares, feeds `fgEvaluations` when Streamline has never issued a token); Intel stays at the census (`20_OPEN_QUESTIONS` §Scope decisions, by licence); the FSR 3.0 host DLLs are deferred to their own PR |
|
||||
| ✅ **Application frames per present** (`fgEvaluations`) — **`sl.interposer.dll!slGetNewFrameToken` since 2026-09-03** | Native vs Displayed frame counts at Tier 1 — see `03_METRICS` §Frame Generation. **The producer is the frame-token export**: Streamline hands a title one token per application frame and the title must ask; the detour counts distinct tokens between two presents (pointer changes, nothing dereferenced), `FL_HOOK_FG_EVALUATIONS` is its family, and it installs on every Streamline 2 title including the ones that evaluate nothing through `slEvaluateFeature`. Rule 4: the out-parameter of an API we hooked. Premise and its gate in `03_METRICS`; pre-committed table in `20_OPEN_QUESTIONS` §S31. *The row as it stood before:* ~~NGX/SL/FFX/XeSS FG feature evaluations per present. **Built 2026-08-15 for Streamline, and MEASURED TO YIELD NOTHING ON THAT ROUTE**~~ — `slEvaluateFeature(kFeatureDLSS_G)` is never called by Cyberpunk 2077 (0 across ~14,000 batches, four FG settings), so this row installs, is honest, and counts zero; see `docs/HANDOFF.md` item 3. Built on the detour that was already there: `kFeatureDLSS_G` contributes to a saturating COUNT in the same word the feature bits live in (`fl_sl_seen.h`) rather than to a bit, because a bit collapses several evaluations between two presents into one — and under multi-frame generation that is the common case, not the edge. The row's family is therefore compound (`FL_HOOK_UPSCALER_IDENTITY \| FL_HOOK_FG_EVALUATIONS`), pinned by a `static_assert` because `hookinventory-check` reads that column as an opaque identifier. **Counts EVALUATIONS, not generated frames** — the 2026-08-14 owner ruling; the multiplier lives in `sl::DLSSGOptions`, which is only reachable by the route §2b refused. ~~Non-NVIDIA FG vendors are **deferred with a written rationale**: `amd_fidelityfx_framegeneration_dx12.dll` 3.1.5 exports only the five generic `ffx*` entry points, identical to five sibling modules, so identity is in the arguments and we have no headers~~ — **AMD has a producer since 2026-09-04** (the FidelityFX row above: the PREPARE dispatch's `frameID`, or the UPSCALE count on a title that never prepares, feeds `fgEvaluations` when Streamline has never issued a token); Intel stays at the census (`20_OPEN_QUESTIONS` §Scope decisions, by licence); the FSR 3.0 host DLL's UPSCALE (`ffxFsr3ContextDispatchUpscale`, since 2026-09-05) counts like an ffx-api UPSCALE when neither Streamline nor a PREPARE has spoken |
|
||||
|
||||
> `GetFrameStatistics().PresentCount` is **not** in this inventory and must not be
|
||||
> re-added as an FG signal. It counts presents the application submitted through
|
||||
|
||||
@@ -135,10 +135,21 @@ Read off the upstream repository through the GitHub API, not from memory:
|
||||
header of interest carries the same grant inline — the `ffx-api/include/ffx_api/` set and the
|
||||
FSR 3.0 host API under `sdk/include/FidelityFX/host/`. None of step 2's needles appear. **This
|
||||
paragraph said "vendor from this tag", and its own reversal condition fired the same day** —
|
||||
see the third bullet. The host API is still only here: `main` dropped `ffx_fsr3.h`, so the FSR
|
||||
see the third bullet. ~~The host API is still only here: `main` dropped `ffx_fsr3.h`, so the FSR
|
||||
3.0 route (Cyberpunk's `ffx_fsr3_x64.dll`, named exports) vendors from `v1.1.4` when it is built,
|
||||
and its closure is **ten** files, not the nine first listed — `ffx_interface.h` includes
|
||||
`ffx_message.h` — with `<mutex>`/`<shared_mutex>` reached through `ffx_types.h`.
|
||||
`ffx_message.h` — with `<mutex>`/`<shared_mutex>` reached through `ffx_types.h`.~~ **Wrong tag,
|
||||
corrected 2026-09-05 when the route was built.** Cyberpunk's `ffx_fsr3_x64.dll` exports twelve
|
||||
`ffxFsr3*` names (`vendor-exports.json`), which is exactly tag **`fsr3-v3.0.4`**'s declaration
|
||||
list; `v1.1.4` declares fifteen and appends `upscaleSize`, `flags` and `frameID` to
|
||||
`FfxFsr3DispatchUpscaleDescription` *after* `renderSize` — a detour typed against it would read
|
||||
the wrong bytes off the module the title ships. At `fsr3-v3.0.4` the root `LICENSE.txt` is MIT
|
||||
verbatim, every header carries the grant inline, and **`ffx_types.h` includes `<stdint.h>` and
|
||||
nothing else** — the `<mutex>` block exists only from 1.1.x behind `#ifndef FFX_MUTEX`. The
|
||||
closure is ten files with **no `ffx_message.h`** (nine host headers plus
|
||||
`gpu/fsr3upscaler/ffx_fsr3upscaler_resources.h`). Vendored at
|
||||
`src/native/third_party/fidelityfx-fsr3/` in its own directory because the licence *shape*
|
||||
differs from `v2.3.0`'s exception list; `license-check.ps1` §2e asserts it per file.
|
||||
- **`main` == tag `v2.3.0`** (`60f4ea81`, "AMD FSR SDK 2.3.0", 2026-06-24) is a different shape:
|
||||
its `docs/license.md` is a **binary-only, no-reverse-engineering** default licence that
|
||||
"applies to all files except as noted below", followed by an MIT exception list of 845 paths.
|
||||
|
||||
@@ -94,7 +94,7 @@ or it becomes the next stale status claim this file exists to record.
|
||||
| **S29** | 🔴 **open, new 2026-08-05 — five ✅ and two ◐, counted off the glyphs below on 2026-08-20** | (a) ◐ **CORRECTED**: the honesty assertion *is* in the merge gate, natively (`fl_guard`, 20.58 s on CI); only the **managed** drain is ungated, and §S19(b) is **not** a prerequisite of the feature hooks — the original claim was wrong and had been used to re-order the work. **Sharpened 2026-08-06:** fixing §S19(b) alone would still gate nothing, because `build.ps1`'s `-SkipIntegration` applies `--filter 'Category!=Integration'` and excludes the class *before* the guard is ever asked. Two independent mechanisms produce one absence, and `ci.yml` must drop the switch too; (b) ✅ `fl_vtable_indices` now pins the Overlay's indices through a shared header; (c) ✅ **closed 2026-08-06 by deleting `ShouldUnhookAsync`** — zero production callers, strictly weaker than `ScanOnceAsync`, and inverted in polarity; the gate's public instance surface is now pinned to `{StartAsync}`; (d) ◐ `vklayer-blastradius` case 3 is now an assertion, but the script still runs only by hand; (e) ✅ **closed 2026-08-06 host-side**, with a held process handle and a classifier that takes no elapsed-time parameter, so a frozen `writeIndex` can never end a session; (f) ✅ **closed 2026-08-20**: the normative contradiction between CLAUDE.md rule 7 and `03_METRICS` about inline RayQuery is settled the way the entry proposed — AS-build activity proves ray tracing is happening, *naming the technique* is what needs a DXIL scan — and rule 7 is amended in the PR that wrote the hooks. Its second half closes with it: `FL_MEASURED_RT` now has a producer (both command-list detours, installed off the game's own device), so all three conjuncts of the `No` branch are live and **`Yes` and `No` are both reachable for the first time**, proved by injection in both directions; (g) ✅ the present-only writer claimed `FL_MEASURED_OUTPUT_RES` unconditionally, including on records with no size |
|
||||
| **S30** | ✅ **closed 2026-08-15** | Answered on the title that raised it: with Ray Reconstruction on, Cyberpunk 2077 evaluates `kFeatureDLSS_RR` on every application frame and `kFeatureDLSS` **not once**, so RR was doing the upscaling and the decode had no arm for it. Evidence rather than inference: `renderW/H` are published only on a frame that drained an evaluation and read 1485×835 = 0.58 × 2560×1440, so the scaling-input tag arrives ON the RR evaluation. Two further defects fell out — the pre-committed decision table had two holes, and the fix contaminated the census that found it (it derived the id from the decoded byte) |
|
||||
| **S31** | ✅ **resolved 2026-09-04 — row P1, and `tokens/batch = 1.00`** | Is a drained Streamline batch an application frame? **Yes.** The `slGetNewFrameToken` count (#103, #105) reads 1.00 / 2.99 / 3.99 against Cyberpunk's own off / ×3 / ×4 and 4.00 on Hell Is Us, and on every leg with batches the two counts agree to the frame. Two independent per-frame API counts are the oracle four instruments could not be. `fg_factor` is published; `none` is reachable by counting. *(The row as it stood while open:)* ◐ **row P2, 2026-08-27 — the ORACLE is retired, the QUESTION is not** | Is a drained Streamline batch an application frame? The PresentMon 2.x `FrameType` test, with its decision table pre-committed BEFORE the run and `tools/frametype-oracle.ps1` producing the input as two dimensionless ratios. **Two obstacles measured before it could be run**: the console binary will not start a trace session unelevated on the dev box (exit 6; the account is in neither Administrators nor Performance Log Users, and the running shared service does not help), and `--track_frame_type` is a **beta** option whose own help says it needs application or driver instrumentation of the Intel-PresentMon provider — so it may be as unavailable as `fl-baseline-probe` proved to be. Two of the table's six rows retire it outright. Blocks HANDOFF item 3's producer decision |
|
||||
| **H11** | ◐ **AMD ffx-api BUILT and RUN 2026-09-04 (A1–A3 accepted; the loader row added the same evening after three loader titles read silent); Intel closed at the census by licence; FSR 3.0 host route deferred to its own PR** | XeFG and FSR3-FG identity. The AMD half is measured on nine titles: the three ffx-api leaves AND the SDK 2.x loader are hooked (the loader turned out to be the game's entry on loader-shipping titles, with the leaves silent behind it), the vendored MIT headers (tag v2.3.0) decode the dispatch descriptor, and rows A1–A3 landed as pre-committed and **R6 closed on Dying Light: The Beast and KCD2 the same night** (`FSR (3.1 or 4 …)` / `FsrFg` / ×2 / 1.01 and `none` / 1.00 through the loader row). Wukong's FSR upscaling is compiled in (Rune Factory's shape; the title has no FSR frame generation), so nothing more is owed on the AMD half; the FSR 3.0 host route is the one deferred piece Intel's SDK failed the licence checklist, so XeSS/XeFG stay at the census (§Scope decisions). `ffx_fsr3_x64.dll` (FSR 3.0, Cyberpunk only here) needs ten host headers from tag v1.1.4 and is deferred with that costing written |
|
||||
| **H11** | ◐ **AMD ffx-api BUILT and RUN 2026-09-04 (A1–A3 accepted; the loader row added the same evening after three loader titles read silent); Intel closed at the census by licence; FSR 3.0 host route deferred to its own PR** | XeFG and FSR3-FG identity. The AMD half is measured on nine titles: the three ffx-api leaves AND the SDK 2.x loader are hooked (the loader turned out to be the game's entry on loader-shipping titles, with the leaves silent behind it), the vendored MIT headers (tag v2.3.0) decode the dispatch descriptor, and rows A1–A3 landed as pre-committed and **R6 closed on Dying Light: The Beast and KCD2 the same night** (`FSR (3.1 or 4 …)` / `FsrFg` / ×2 / 1.01 and `none` / 1.00 through the loader row). Wukong's FSR upscaling is compiled in (Rune Factory's shape; the title has no FSR frame generation), so nothing more is owed on the AMD half; the FSR 3.0 host route is the one deferred piece Intel's SDK failed the licence checklist, so XeSS/XeFG stay at the census (§Scope decisions). `ffx_fsr3_x64.dll` (FSR 3.0, Cyberpunk only here) ~~needs ten host headers from tag v1.1.4 and is deferred with that costing written~~ **built 2026-09-05** from tag `fsr3-v3.0.4` (the docs' `v1.1.4` was the wrong tag: twelve exports match 3.0.4, not 1.1.4's fifteen, and 1.1.4's descriptor appends fields after `renderSize`); one row, the host's UPSCALE; **rows B1–B4 owed** (below) |
|
||||
|
||||
~~**Six items are ❓ and one is 🚫.**~~ **Recounted 2026-08-05: TWELVE items block
|
||||
exit criterion 2, not seven, and the undercount came from reading only the ❓ rows.**
|
||||
@@ -3378,7 +3378,7 @@ load-bearing rather than stylistic.
|
||||
> | **Hell Is Us**, FSR, FG off | same | same | `none` | `FPS: 104.18` | 1.00 |
|
||||
> | **Expedition 33**, FSR upscale + **DLSS frame generation ×3** | UE5, two leaves | `FSR (3.1 or 4 …)`, 1707×961 | `Active (technology not identified)` — no FRAMEGENERATION dispatch, no Streamline token; the count came from the UPSCALE dispatches | `67.51 → 200.66 (×2.97 FG)` | 1.00 (fg-dispatch/frame 0.00) |
|
||||
> | **Expedition 33**, FSR, FG off | same | same | `none` | `FPS: 85.12` | 1.00 |
|
||||
> | **Cyberpunk 2077**, FSR 3 + FG | FSR 3.0 host DLLs for upscaling, the **1.1.x monolith for frame generation** | `N/A` (upscale is `ffx_fsr3upscaler_x64.dll`, the deferred route) — render 1506×847 from PREPARE | `FsrFg` (4261 generated batches) | `72.93 → 145.76 (×2)` | — (no UPSCALE dispatch; count = Streamline tokens 4266) |
|
||||
> | **Cyberpunk 2077**, FSR 3 + FG | FSR 3.0 host DLLs for upscaling, the **1.1.x monolith for frame generation** | `N/A` (upscale is through the FSR 3.0 host DLLs, unhooked on this build; **the host row landed 2026-09-05 — rows B1–B4 below**) — render 1506×847 from PREPARE | `FsrFg` (4261 generated batches) | `72.93 → 145.76 (×2)` | — (no UPSCALE dispatch; count = Streamline tokens 4266) |
|
||||
> | **Dying Light: The Beast**, FSR + **FSR FG** | loader + two leaves | `N/A` | `N/A` — **zero dispatches at any leaf export** | `Presented 146.54`, WARNING | census: no FSR identity, no FSR_FG |
|
||||
> | **KCD2**, FSR (×2 runs) | loader + upscaler leaf | `N/A` | `N/A` — zero leaf dispatches | `Presented 58.8`, cannot-include shape (no FG runtime) | — |
|
||||
> | **Black Myth: Wukong**, FSR | monolith + loader 2.1.0 | `N/A` | `none` (Streamline tokens = presents) — zero leaf dispatches | `FPS: 41.11` | — |
|
||||
@@ -3437,11 +3437,47 @@ load-bearing rather than stylistic.
|
||||
> identity out of reach by name, the application-frame count carried by Streamline's token. Nothing
|
||||
> is owed on it.
|
||||
>
|
||||
> **Still deferred, with the costing written:** the FSR 3.0 host route — `ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale`
|
||||
> ~~**Still deferred, with the costing written:** the FSR 3.0 host route — `ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale`
|
||||
> / `ffxFsr3DispatchFrameGeneration`, named exports, no struct decode for identity — needs ten
|
||||
> host headers from tag `v1.1.4` (`main` dropped `ffx_fsr3.h`), whose closure reaches
|
||||
> `<mutex>`/`<shared_mutex>` through `ffx_types.h`, for exactly one installed title (Cyberpunk 2077,
|
||||
> whose default here is DLSS). Its own PR, with Cyberpunk switched to FSR 3 as the oracle.
|
||||
> whose default here is DLSS). Its own PR, with Cyberpunk switched to FSR 3 as the oracle.~~
|
||||
>
|
||||
> ### THE FSR 3.0 HOST ROUTE IS BUILT, 2026-09-05 — and the costing above named the wrong tag
|
||||
>
|
||||
> **`fsr3-v3.0.4`, not `v1.1.4`.** Read off the upstream tags: Cyberpunk's `ffx_fsr3_x64.dll`
|
||||
> exports twelve `ffxFsr3*` names, which is exactly `fsr3-v3.0.4`'s declaration list; `v1.1.4`
|
||||
> declares fifteen (adds `ContextGetGpuMemoryUsage`, `ContextDispatchFrameGenerationPrepare`,
|
||||
> `GetEffectVersion`) and its `FfxFsr3DispatchUpscaleDescription` appends `upscaleSize`, `flags`
|
||||
> and `frameID` **after `renderSize`** — a detour typed against it would read the wrong bytes off
|
||||
> the module the title ships. The prefix through `renderSize` is identical across 3.0.3 / 3.0.4 /
|
||||
> 1.1.4 and is the only field read; `dllmain.cpp` pins its offset to a literal. And **`<mutex>` is
|
||||
> not in the closure at all** at this tag — `ffx_types.h` includes `<stdint.h>` only; the mutex block
|
||||
> exists only from 1.1.x. Ten files, no `ffx_message.h`, vendored at
|
||||
> `src/native/third_party/fidelityfx-fsr3/` (root `LICENSE.txt` = MIT verbatim, inline grants;
|
||||
> `license-check.ps1` §2e).
|
||||
>
|
||||
> **One row, the same family.** `ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale` feeds the ffx-api
|
||||
> drain word: identity `FSR3` as a fact (the 3.0 host hosts nothing else), `renderSize` as the
|
||||
> extent, and the UPSCALE count when neither Streamline nor a PREPARE has ever spoken. Published by
|
||||
> `PublishFfxFamilyIfWhole`, which now waits for a loaded host as it waits for a loaded leaf.
|
||||
> `ffxFsr3DispatchFrameGeneration` is **not** a row: on the one title the monolith generates
|
||||
> (4261 batches) and the count is Streamline's, and the host's FG export fires per *generated*
|
||||
> batch. **Reversal, pre-committed:** it becomes a row only on a title reading
|
||||
> `Active (technology not identified)` with `FL_CENSUS_FFX_FSR3` set and no monolith in the census.
|
||||
> Fixtures: the `ffx_fsr3_x64.dll` stub (Pass C's second positive control), harness topologies
|
||||
> `fsr3host` and `fsr3host+mono`, and a `[ffx]` injected case at K = 1 (the double-count control
|
||||
> for the row) and K ∈ {1, 4} beside the monolith.
|
||||
>
|
||||
> **Acceptance, pre-committed — Cyberpunk 2077 (runbook title 3), one launch per leg:**
|
||||
>
|
||||
> | Row | Leg / reading | Verdict |
|
||||
> |---|---|---|
|
||||
> | **B1** | FSR 3 + FSR FG: `upscaler: Fsr3`; `render 1506x847 -> 2560x1440` with **one** distinct extent (the host's `renderSize` and the monolith's PREPARE agree); `frame generation: FsrFg`; `≈73 → ≈146 (×2 FG)` from tokens; `frames/upscale-drained = 1.00`, `fg-dispatch/frame = 1.00`; `module: ffx_fsr3_x64.dll (no version resource)` | accept |
|
||||
> | **B1-off** | FSR 3, FG off: `Fsr3`, `none` by count, `frames/upscale-drained = 1.00` | accept |
|
||||
> | **B2** | `upscale-drained = 0` with `ffx_fsr3_x64.dll` in the census and FSR on — the game calls `ffx_fsr3upscaler_x64.dll` directly and the facade is silent | add the upscaler-DLL row (`ffxFsr3UpscalerContextDispatch`, ten `FfxResource`s, its own offset pin) **instead** — never both |
|
||||
> | **B3** | `frames/upscale-drained ≈ 2.00` | two upscale contexts per frame or a re-entered dispatch — investigate before publishing (mirrors R4) |
|
||||
> | **B4** | `SETTINGS MOVED: 2 distinct extents` | the host and the PREPARE disagree on the input size; print both, do not average |
|
||||
>
|
||||
> *The banner as it stood on the morning of 2026-09-04:* **The deferral has a next step, and it is `HANDOFF` item 7c.** The Streamline
|
||||
> work built every tool this needs — module-scoped inventory rows, types-only vendoring with a
|
||||
@@ -3452,7 +3488,7 @@ load-bearing rather than stylistic.
|
||||
> entry names and nobody had made: **run the licence checklist on the FidelityFX and XeSS SDK
|
||||
> headers.** ~~Both are published under MIT~~ — **run 2026-09-04, and the sentence struck was
|
||||
> wrong about Intel.** FidelityFX at tag `v1.1.4` is MIT root-and-inline and is clear to vendor
|
||||
> types-only; the XeSS SDK is the Intel Simplified Software License (binary-only grant,
|
||||
> types-only (as is `fsr3-v3.0.4`, the tag the host route actually vendored on 2026-09-05); the XeSS SDK is the Intel Simplified Software License (binary-only grant,
|
||||
> no-reverse-engineering, termination) and its headers say they may not be copied without
|
||||
> Intel's permission, so step 3 binds and XeSS stays where NGX is. `18_GPU_VENDOR_APIS` §Vendor
|
||||
> SDKs carries both decisions with the evidence. **So 7c is AMD only.** The one thing that
|
||||
|
||||
+17
-5
@@ -818,9 +818,19 @@ at 1.01, KCD2 at FSR printed the identity and `none` by count at 1.00 — the lo
|
||||
both, once. **Wukong at FSR read silent at the monolith AND the loader with the monolith loaded**:
|
||||
FSR upscaling compiled into its UE plugin (Rune Factory's shape) with the monolith loaded and
|
||||
unused — ~~owed: Wukong with FSR frame generation ON~~ **the title has no FSR frame-generation
|
||||
option (owner, same night)**, so Wukong is the second static title and nothing is owed on it. **The FSR 3.0 host route
|
||||
option (owner, same night)**, so Wukong is the second static title and nothing is owed on it. ~~**The FSR 3.0 host route
|
||||
(`ffx_fsr3_x64.dll`, step 3 below) is deferred to its own PR** — ten host headers from `v1.1.4`;
|
||||
Cyberpunk at FSR 3 is its oracle and already prints `FsrFg` from the monolith beside it.
|
||||
Cyberpunk at FSR 3 is its oracle and already prints `FsrFg` from the monolith beside it.~~
|
||||
**BUILT 2026-09-05, and the tag was not `v1.1.4`.** Cyberpunk's module exports exactly
|
||||
`fsr3-v3.0.4`'s twelve `ffxFsr3*` names; 1.1.4 appends fields after `renderSize` and declares
|
||||
three exports the module lacks. One row — `ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale`,
|
||||
the same family and publish point as the ffx-api rows, keyed by module in the installer —
|
||||
reads `renderSize` and nothing else; `ffxFsr3DispatchFrameGeneration` is deliberately not a
|
||||
row (the monolith generates on the one title; §H11 pre-commits the reversal). **What is owed
|
||||
is the owner's acceptance run**, rows B1–B4 in §H11: Cyberpunk at FSR 3 + FG must print
|
||||
`upscaler: Fsr3` with one extent agreeing between the host and the monolith's PREPARE, and
|
||||
`frames/upscale-drained = 1.00`; B2 (facade silent, `upscale-drained = 0`) is the pre-committed
|
||||
condition for adding the `ffx_fsr3upscaler_x64.dll` row instead — never both.
|
||||
|
||||
<details>
|
||||
<summary>The entry as it stood, kept for the reasoning it carries</summary>
|
||||
@@ -843,7 +853,7 @@ exports `xessD3D12Init` / `xessD3D12Execute` and XeFG `xefgSwapChainD3D12InitFro
|
||||
ffx_framegeneration.h, dx12/ffx_api_dx12.h, vk/ffx_api_vk.h}` for the 3.1 facade the
|
||||
installed titles call, and `sdk/include/FidelityFX/host/{ffx_fsr3.h, ffx_fsr3upscaler.h,
|
||||
ffx_frameinterpolation.h, ffx_opticalflow.h, ffx_types.h, ffx_error.h, ffx_interface.h,
|
||||
ffx_util.h, ffx_assert.h}` for the FSR 3.0 host API. Do not take `main`: it is SDK 2.x under
|
||||
ffx_util.h, ffx_assert.h}` for the FSR 3.0 host API *(2026-09-05: vendored from **`fsr3-v3.0.4`**, not `v1.1.4` — the tag whose declarations match the module Cyberpunk ships; see the banner above)*. Do not take `main`: it is SDK 2.x under
|
||||
a binary-only `docs/license.md` that excepts these headers as MIT only by an 845-line list.
|
||||
Extend `hookinventory-check` Pass C's forbidden-import list with `amd_fidelityfx_*.dll` /
|
||||
`ffx_*.dll` in the same PR — the Streamline lesson, one vendor over. *Intel XeSS SDK*:
|
||||
@@ -870,8 +880,10 @@ exports `xessD3D12Init` / `xessD3D12Execute` and XeFG `xefgSwapChainD3D12InitFro
|
||||
same five names, and the plugin modules are called by the facade, not by the game — an
|
||||
unscoped hook would count each dispatch twice, straight into `fg_factor`.
|
||||
3. **AMD 3.0 (`ffx_fsr3_x64.dll`, Cyberpunk's copy):** named exports, no struct decode needed —
|
||||
`ffxFsr3ContextDispatchUpscale` for identity and extent, `ffxFsr3DispatchFrameGeneration`
|
||||
once per application frame.
|
||||
`ffxFsr3ContextDispatchUpscale` for identity and extent, ~~`ffxFsr3DispatchFrameGeneration`
|
||||
once per application frame~~ *(built 2026-09-05 without the FG row: on the one title the
|
||||
monolith generates and the count is Streamline's; the host's FG export fires per generated
|
||||
batch and is not a count producer. §H11 carries the reversal condition.)*
|
||||
4. **Intel — closed at the census (step 1).** No hook on any `libxess*.dll` export. The
|
||||
report line for an Intel title is what the writer already produces: upscaler
|
||||
`NOT_REPORTED`, and if `libxess_fg.dll` is in the census, Presented FPS with the *"MAY
|
||||
|
||||
+2
-2
@@ -1702,7 +1702,7 @@ one launch per capture, consent granted after launch. Exit codes and full report
|
||||
| Expedition 33 | upscaler 4.0.2 + frame generation 3.1.5, **no loader** | UE5: the plugin's built-in loader calls the leaves directly |
|
||||
| Hell Is Us | upscaler **4.0.3** + frame generation **4.0.0** under `Plugins/FSR/Source/fidelityfx-sdk/Kits/FidelityFX/signedbin/`, **no loader** | UE5, SDK 2.1.x |
|
||||
| Red Dead Redemption 2 | `ffx_fsr2_api_x64.dll` + `_dx12_` + `_vk_` | FSR 2, dynamic |
|
||||
| Cyberpunk 2077 (also) | `ffx_fsr3_x64.dll`, `ffx_backend_dx12_x64.dll`, `ffx_frameinterpolation_x64.dll`, `ffx_fsr3upscaler_x64.dll`, `ffx_opticalflow_x64.dll` | FSR 3.0 host DLLs, named exports — the deferred route |
|
||||
| Cyberpunk 2077 (also) | `ffx_fsr3_x64.dll`, `ffx_backend_dx12_x64.dll`, `ffx_frameinterpolation_x64.dll`, `ffx_fsr3upscaler_x64.dll`, `ffx_opticalflow_x64.dll` | FSR 3.0 host DLLs, named exports — ~~the deferred route~~ hooked 2026-09-05 at the host facade (`ffxFsr3ContextDispatchUpscale`, tag `fsr3-v3.0.4`: the module's twelve exports match that tag, not `v1.1.4`) |
|
||||
|
||||
Every module in the ffx-api family exports the same five names and nothing else
|
||||
(`vendor-exports.json`) — which the morning read as "the loader can only reach a leaf through
|
||||
@@ -1718,7 +1718,7 @@ one launch per capture, consent granted after launch. Exit codes and full report
|
||||
and `none` by count with FG off; **Hell Is Us** `FSR (3.1 or 4 …)` / `FsrFg` / ×2 / 1.00, and
|
||||
`none` with FG off; **Expedition 33** FSR upscale under DLSS FG ×3 → `×2.97`, *technology not
|
||||
identified*, count from UPSCALE dispatches (no PREPARE, no token); **Cyberpunk** at FSR 3: the FSR
|
||||
3.0 host DLLs upscale (`upscaler: N/A`, deferred route) while the 1.1.x monolith generates
|
||||
3.0 host DLLs upscale (`upscaler: N/A` on that build; the host row landed 2026-09-05, §H11 B1 owed) while the 1.1.x monolith generates
|
||||
(`FsrFg`, 4261 batches, ×2); **Dying Light: The Beast** (FSR + FSR FG), **KCD2** (FSR) and
|
||||
**Wukong** (FSR): **zero dispatches at any leaf export**, `upscaler: N/A` — the loader-row
|
||||
reversal; **Rune Factory** (FSR FG): no AMD module in the census, `59.99 → 119.95 (×2)` from
|
||||
|
||||
@@ -57,6 +57,7 @@ Telemetry is layered so no proprietary vendor licence is ever required (`docs/18
|
||||
| **DXGI + Windows performance counters (PDH)** | Vendor-neutral baseline: utilisation, VRAM, adapter identity | Windows OS APIs | n/a |
|
||||
| **NVIDIA Streamline headers** (`sl.h`, its eight-file include closure, and `sl_dlss.h`) | Declarations only — `sl::Feature`, the `kFeature*` ids and `PFun_slEvaluateFeature` — so the Overlay's upscaler hook has the vendor's own signature instead of a hand-written guess. **Types and `decltype` only: never linked**, or `sl.interposer.dll` would become a load-time dependency and the Overlay would fail to load in every game that ships no Streamline | **MIT** — <https://github.com/NVIDIA-RTX/Streamline>, `main`, 2026-08-09 | **Vendored 2026-08-09** at `src/native/third_party/streamline/`: `license.txt` and ten headers. **`sl_nvperf.h` is excluded** — the same `license.txt` carries a second, proprietary "NSight Perf SDK License, Version 2023.3" block naming `sl_nvperf.h` and `sl_nvperf.dll`. **All of `external/` is excluded** — upstream's `external/ngx-sdk/` is the RTX SDKs Licence. `license-check.ps1` asserts both exclusions and the grant text |
|
||||
| **AMD FidelityFX SDK headers** (`ffx_api.h`, `ffx_api_types.h`, `ffx_upscale.h`, `ffx_framegeneration.h`, `ffx_framegeneration_api_types.h`) | Declarations only — `ffxApiHeader::type`, the `FFX_API_*_DESC_TYPE_*` values, `ffxDispatchDescUpscale::renderSize`, the frame-generation `Prepare` descriptors' `frameID` and `PfnFfxDispatch` — so the Overlay's AMD hook decodes the dispatch descriptor by the vendor's own layout instead of a guess. **Types only: never linked**, and the Overlay defines none of the names the header declares `dllexport` (`hookinventory-check` Pass C reads its export table) | **MIT, by exception** — <https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK> tag `v2.3.0` (`60f4ea81`, 2026-06-24). Upstream's `docs/license.md` is a binary-only default licence followed by an MIT exception list; on 2026-09-04 that list named all 845 files in the tree, these five among them, and each header carries the grant in its own banner | **Vendored 2026-09-04** at `src/native/third_party/fidelityfx/`: `license.md` verbatim (exception list included) and five headers in upstream's `Kits/FidelityFX/…` layout. **No `signedbin/`, no `.lib`, no source, no `dx12/` backend headers** (no consumer yet). `license-check.ps1` §2d asserts every vendored path is on the exception list and every header carries the grant |
|
||||
| **AMD FidelityFX SDK 3.0 host headers** (`ffx_fsr3.h` and its nine-file include closure: `ffx_interface.h`, `ffx_fsr3upscaler.h`, `ffx_frameinterpolation.h`, `ffx_opticalflow.h`, `ffx_assert.h`, `ffx_types.h`, `ffx_error.h`, `ffx_util.h`, `gpu/fsr3upscaler/ffx_fsr3upscaler_resources.h`) | Declarations only — `FfxFsr3DispatchUpscaleDescription::renderSize` and the type of `ffxFsr3ContextDispatchUpscale` — so the Overlay's hook on the FSR 3.0 **host** DLL (`ffx_fsr3_x64.dll`, Cyberpunk 2077's copy, which upscales through named exports rather than the ffx-api facade) reads the render extent by the vendor's own layout. **Types and `decltype` only: never linked**, and the Overlay defines none of the names the header declares `dllexport` (`hookinventory-check` Pass C reads its export table; the `ffx_fsr3_x64.dll` fixture in `tools/vendor-stubs` is that parser's second positive control) | **MIT** — <https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK> tag `fsr3-v3.0.4` (`55ff22bb`). The root `LICENSE.txt` at that tag is the MIT grant verbatim and every header carries it inline — a different licence *shape* from the `v2.3.0` row above, which is why it is a separate directory and `license-check.ps1` §2e rather than §2d. The tag is the one whose declarations match the module the title ships (twelve `ffxFsr3*` exports); `v1.1.4`, which the docs first named, declares three more and appends fields to the dispatch descriptor | **Vendored 2026-09-05** at `src/native/third_party/fidelityfx-fsr3/`: `LICENSE.txt` verbatim and ten headers in upstream's `sdk/include/FidelityFX/…` layout, each blob sha checked against the upstream tree. **No backends, no `.cpp`, no shaders, no samples.** `license-check.ps1` §2e asserts the root grant and every header's banner, file by file. Same MIT text as the row above, so `legal/licenses/fidelityfx-MIT.txt` is the notice for both |
|
||||
| NVIDIA **NGX** / **Streamline**, AMD **FidelityFX**, Intel **XeSS** **runtimes** (the DLLs themselves) | Not loaded, not linked, not redistributed. We observe the calls a *game* makes to the copies it ships (`docs/17_HOOK_ENGINE.md`). Unchanged by the row above, which vendors **headers** and no runtime | — | **No vendor upscaler code is distributed by FrameLedger** |
|
||||
|
||||
### GPL-3.0 compatibility
|
||||
@@ -98,5 +99,6 @@ All product names, logos, and brands are property of their respective owners and
|
||||
- [ ] MPL-2.0 source-availability note points to upstream LibreHardwareMonitor repository
|
||||
- [x] LHM checked for MPL-2.0 Exhibit B on any depended-upon file — clear as of 0.9.6 / commit `3d331e33`, 2026-08-02
|
||||
- [x] **AMD FidelityFX headers are vendored** (2026-09-04) — five headers, MIT **by exception**: `license-check.ps1` §2d asserts each vendored path against the exception list inside the vendored `license.md` and each header's own banner, file by file. No binary, no source
|
||||
- [x] **AMD FidelityFX SDK 3.0 host headers are vendored** (2026-09-05) — ten headers at tag `fsr3-v3.0.4`, MIT at the root **and** inline: `license-check.ps1` §2e asserts the root grant and every header's banner, file by file, in a directory of its own because the licence shape differs from the row above. No binary, no source, no shaders
|
||||
- [x] **NVAPI is vendored** (2026-08-05) and all nine headers carry their `SPDX-License-Identifier: MIT` blocks unmodified — asserted file by file, not sampled. `license-check.ps1` enforces that this line and the table agree with the filesystem, **in both directions**: vendoring the material while the table still said "Not yet" failed the build, which is how this row came to be flipped
|
||||
- [ ] No Intel IGCL or AMD ADLX material anywhere in the tree (CI grep, see `docs/13_CI_CD.md`)
|
||||
@@ -110,7 +110,7 @@ internal sealed record FfxCensus
|
||||
if (!SawAnything)
|
||||
{
|
||||
return " ffx dispatch census over " + N(Records) + " record(s): no UPSCALE or FRAMEGENERATION dispatch "
|
||||
+ "reached an ffx-api leaf (no FSR identity, no FSR_FG mode)";
|
||||
+ "reached an ffx-api leaf or the FSR 3.0 host facade (no FSR identity, no FSR_FG mode)";
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
@@ -26,7 +26,7 @@ add_library(FrameLedger.Overlay SHARED src/dllmain.cpp)
|
||||
# fails to load in every game that ships no such module, in the loader, silently.
|
||||
# hookinventory-check Pass C reads the built DLL's import AND export tables.
|
||||
target_link_libraries(FrameLedger.Overlay PRIVATE FrameLedger.Shm fl_dxgi_vtable fl_native_flags fl_hostile_env_flags minhook
|
||||
fl_streamline_headers fl_fidelityfx_headers
|
||||
fl_streamline_headers fl_fidelityfx_headers fl_fsr3_host_headers
|
||||
Advapi32 d3d11 d3d12 dxgi)
|
||||
set_target_properties(FrameLedger.Overlay PROPERTIES OUTPUT_NAME "FrameLedger.Overlay")
|
||||
|
||||
|
||||
@@ -202,6 +202,38 @@ static_assert(kFamilyFfxDispatch != kFamilyEvaluateFeature &&
|
||||
"InstallByFamily binds a row by EQUALITY on this value -- a collision would hand a Streamline detour "
|
||||
"body to an AMD export, which is the neighbour's-body defect the installer exists to stop");
|
||||
|
||||
// --- AMD FidelityFX, the FSR 3.0 HOST API (2026-09-05, the route HANDOFF 7c deferred) ---
|
||||
//
|
||||
// Cyberpunk 2077 at FSR 3 upscales through ffx_fsr3_x64.dll's NAMED exports -- the
|
||||
// SDK 1.0.x host API, tag fsr3-v3.0.4 -- while its frame generation goes through the
|
||||
// 1.1.x monolith's ffxDispatch above. Measured 2026-09-04: `FsrFg` printed, `upscaler:
|
||||
// N/A`. One row, ffxFsr3ContextDispatchUpscale, whose descriptor carries renderSize
|
||||
// at an offset the vendored header vouches for; identity is FSR3 as a fact (the 3.0
|
||||
// host hosts nothing else) and the UPSCALE count feeds the SAME drain word the
|
||||
// ffx-api rows feed.
|
||||
//
|
||||
// THE SAME FAMILY VALUE AS THE ffx-api ROWS, ON PURPOSE. The row's UPSCALE goes into
|
||||
// g_ffxSeen's count, which RecordPresent drains into fgEvaluations when Streamline has
|
||||
// never issued a token and no PREPARE ever arrived -- so a row claiming IDENTITY|PARAMS
|
||||
// alone would feed a field its family does not entitle, and every record on a
|
||||
// host-only title would be an honesty violation. The installer's ffx arm binds on the
|
||||
// family and then keys on the MODULE (FfxLeafOf for the four ffxDispatch modules, this
|
||||
// name for the host), exactly as the params arm keys on the symbol -- so the equality
|
||||
// collision the asserts above forbid between DIFFERENT detour bodies is not one here:
|
||||
// one family, one publish point (PublishFfxFamilyIfWhole), one live latch.
|
||||
//
|
||||
// ffxFsr3DispatchFrameGeneration IS NOT A ROW. On the one title that ships the host
|
||||
// DLLs, frame generation is dispatched through the monolith's ffxDispatch (4261
|
||||
// FRAMEGENERATION batches, 2026-09-04) and the count comes from Streamline tokens; the
|
||||
// host's FG export fires per GENERATED batch, so it is not a count producer either.
|
||||
// It becomes a row only if a title appears generating through the host DLL with no
|
||||
// monolith in the census -- `Active (technology not identified)` beside
|
||||
// FL_CENSUS_FFX_FSR3. Pre-committed in 20_OPEN_QUESTIONS §H11.
|
||||
inline constexpr uint32_t kFamilyFsr3Host = kFamilyFfxDispatch;
|
||||
static_assert(kFamilyFsr3Host == kFamilyFfxDispatch,
|
||||
"one family, one publish point, one live latch: the host row shares the ffx-api rows' drain word and "
|
||||
"must share their claims, or fgEvaluations would be fed by a row that does not claim FG_EVALUATIONS");
|
||||
|
||||
// The leaves, in the order dllmain's per-leaf trampoline and latch arrays are indexed.
|
||||
enum FfxLeaf : uint32_t {
|
||||
kFfxLeafMonolith = 0, // amd_fidelityfx_dx12.dll -- SDK 1.1.x, FSR 3.1 only
|
||||
@@ -300,7 +332,14 @@ inline int FfxLeafOf(const wchar_t* module) noexcept {
|
||||
X(L"amd_fidelityfx_dx12.dll", "ffxDispatch", fl::inventory::kFamilyFfxDispatch) \
|
||||
X(L"amd_fidelityfx_upscaler_dx12.dll", "ffxDispatch", fl::inventory::kFamilyFfxDispatch) \
|
||||
X(L"amd_fidelityfx_framegeneration_dx12.dll", "ffxDispatch", fl::inventory::kFamilyFfxDispatch) \
|
||||
X(L"amd_fidelityfx_loader_dx12.dll", "ffxDispatch", fl::inventory::kFamilyFfxDispatch)
|
||||
X(L"amd_fidelityfx_loader_dx12.dll", "ffxDispatch", fl::inventory::kFamilyFfxDispatch) \
|
||||
X(L"ffx_fsr3_x64.dll", "ffxFsr3ContextDispatchUpscale", fl::inventory::kFamilyFsr3Host)
|
||||
|
||||
// The FSR 3.0 host module and the one symbol dllmain's ffx arm keys on for it. Named
|
||||
// constants HERE, for the reason kModuleSlInterposer gives below, and bound to the
|
||||
// table so the row and the arm cannot drift apart.
|
||||
inline constexpr const wchar_t* kModuleFfxFsr3Host = L"ffx_fsr3_x64.dll";
|
||||
inline constexpr const char* kSymbolFfxFsr3DispatchUpscale = "ffxFsr3ContextDispatchUpscale";
|
||||
|
||||
// The module and the two symbols dllmain's params arm keys on: the frame-based
|
||||
// symbol picks the detour, and all three name what "whole" means when the family is
|
||||
@@ -324,6 +363,8 @@ static_assert(InventoryHasRow(kModuleSlInterposer, kSymbolSlSetTag),
|
||||
"the params arm keys on slSetTag by this constant, and the table no longer has that row");
|
||||
static_assert(InventoryHasRow(kModuleSlInterposer, kSymbolSlSetTagForFrame),
|
||||
"the params arm keys on slSetTagForFrame by this constant, and the table no longer has that row");
|
||||
static_assert(InventoryHasRow(kModuleFfxFsr3Host, kSymbolFfxFsr3DispatchUpscale),
|
||||
"the ffx arm keys on the FSR 3.0 host row by these constants, and the table no longer has that row");
|
||||
|
||||
// THE LEAF TABLE AND THE ROWS ARE BOUND TO EACH OTHER AT COMPILE TIME, BOTH WAYS.
|
||||
// A leaf without a row would be a trampoline slot nothing installs into; a row
|
||||
@@ -373,6 +414,13 @@ static_assert(AnyRowNames(kFfxLoaderModule),
|
||||
"amd_fidelityfx_loader_dx12.dll is the game's entry on a loader-shipping title (Dying Light: The "
|
||||
"Beast, KCD2, Wukong measured 2026-09-04: zero dispatches at any leaf export while FSR ran), so "
|
||||
"without a row those titles read N/A");
|
||||
// The host is NOT a leaf: it has no ffxDispatch, its own detour body, its own latch.
|
||||
// FfxLeafOf returning -1 for it is what routes the installer's ffx arm to the host
|
||||
// branch, so a leaf-table entry for it would hand the host the ffxDispatch trampoline.
|
||||
static_assert(FfxLeafOfExact(kModuleFfxFsr3Host) < 0,
|
||||
"the FSR 3.0 host facade is not an ffxDispatch leaf; the installer keys it by module name");
|
||||
static_assert(!FfxDispatchRowExistsFor(kModuleFfxFsr3Host),
|
||||
"the host exports no ffxDispatch; a row claiming one would resolve nothing and install nothing");
|
||||
|
||||
// Does this module speak the Streamline 2 ABI the vendored headers describe?
|
||||
//
|
||||
@@ -442,6 +490,24 @@ inline bool SpeaksFfxApi(HMODULE h) noexcept {
|
||||
GetProcAddress(h, "ffxQuery") != nullptr && GetProcAddress(h, "ffxDispatch") != nullptr;
|
||||
}
|
||||
|
||||
// Does this module speak the FSR 3.0 HOST ABI the vendored fsr3-v3.0.4 headers describe?
|
||||
//
|
||||
// A NAME CHECK, like SpeaksFfxApi's, on four of the twelve ffxFsr3* names the shipped
|
||||
// module exports (docs/vendor-exports.json): the create, the one export hooked, the
|
||||
// frame-generation dispatch and SkipPresent -- the last two being the 3.0 host's own
|
||||
// and exported by no ffx-api module, so a 1.1.x monolith of the wrong NAME cannot pass.
|
||||
// Deliberately not a generation check: 3.0.3, 3.0.4 and 1.1.4 share the descriptor
|
||||
// prefix through renderSize, which is the only field read, and dllmain pins that
|
||||
// offset at compile time; a name a later generation ADDS is not evidence the field
|
||||
// moved. Probe-only names, never resolved into a row, never called; this file because
|
||||
// Pass B exempts exactly this file.
|
||||
inline bool SpeaksFsr3Host(HMODULE h) noexcept {
|
||||
return h != nullptr && GetProcAddress(h, "ffxFsr3ContextCreate") != nullptr &&
|
||||
GetProcAddress(h, "ffxFsr3ContextDispatchUpscale") != nullptr &&
|
||||
GetProcAddress(h, "ffxFsr3DispatchFrameGeneration") != nullptr &&
|
||||
GetProcAddress(h, "ffxFsr3SkipPresent") != nullptr;
|
||||
}
|
||||
|
||||
inline bool SpeaksExpectedAbi(const wchar_t* module, HMODULE h) noexcept {
|
||||
if (module == nullptr) {
|
||||
return false;
|
||||
@@ -449,6 +515,9 @@ inline bool SpeaksExpectedAbi(const wchar_t* module, HMODULE h) noexcept {
|
||||
if (_wcsicmp(module, L"sl.interposer.dll") == 0) {
|
||||
return SpeaksStreamline2(h);
|
||||
}
|
||||
if (_wcsicmp(module, kModuleFfxFsr3Host) == 0) {
|
||||
return SpeaksFsr3Host(h);
|
||||
}
|
||||
// THE AMD ARM, by leaf name, for the same reason the Streamline arm is by name:
|
||||
// the loader also exports all five and is not a leaf, so a prefix test would
|
||||
// approve a module the inventory deliberately does not hook.
|
||||
|
||||
@@ -71,6 +71,19 @@
|
||||
#include <ffx_api.h>
|
||||
#include <ffx_framegeneration.h>
|
||||
#include <ffx_upscale.h>
|
||||
// The FSR 3.0 HOST API (tag fsr3-v3.0.4), the same rule again, for exactly two things:
|
||||
// FfxFsr3DispatchUpscaleDescription::renderSize and the type of the one export hooked.
|
||||
// FFX_API is __declspec(dllexport) with no switch at all at that tag; nothing here
|
||||
// defines or takes the address of a name, so nothing is exported, and Pass C's
|
||||
// forbidden-export pattern already covers ffxFsr3*. A separate tree from ffx-api's
|
||||
// (third_party/fidelityfx-fsr3/README.md), INCLUDED INSIDE A NAMESPACE: the two trees
|
||||
// each define a struct named FfxFrameGenerationConfig, and wrapping the include is the
|
||||
// one way to keep both headers verbatim in one TU. Legal C++: the entry points keep
|
||||
// their C linkage, so fsr3host::ffxFsr3ContextDispatchUpscale names the same function
|
||||
// the module exports, and every struct read here is still the vendor's declaration.
|
||||
namespace fsr3host {
|
||||
#include <FidelityFX/host/ffx_fsr3.h>
|
||||
} // namespace fsr3host
|
||||
|
||||
using namespace fl;
|
||||
|
||||
@@ -849,6 +862,40 @@ PFN_FfxDispatch g_origFfxDispatch[fl::inventory::kFfxLeafCount] = {};
|
||||
std::atomic<uint32_t> g_ffxPatched[fl::inventory::kFfxLeafCount] = {};
|
||||
std::atomic<uint32_t> g_ffxLive{0};
|
||||
|
||||
// --- The FSR 3.0 HOST API: ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale ----------
|
||||
//
|
||||
// The fifth AMD target, and NOT a leaf: a different export with a different signature,
|
||||
// hooked at its own address with its own trampoline and latch, feeding the SAME drain
|
||||
// word as the ffx-api UPSCALE arm -- so the count, the extent and the identity byte all
|
||||
// flow through the paths above unchanged, and PublishFfxFamilyIfWhole is its publish
|
||||
// point. Which source the last UPSCALE came from is recorded in g_ffxUpscaleLeaf as
|
||||
// leaf + 1; the host takes the value past every leaf.
|
||||
//
|
||||
// WHAT IS READ (CLAUDE.md rule 4): renderSize of the descriptor the title passed, and
|
||||
// nothing else -- never the context, never a resource, never the command list.
|
||||
using PFN_FfxFsr3ContextDispatchUpscale = decltype(&fsr3host::ffxFsr3ContextDispatchUpscale);
|
||||
PFN_FfxFsr3ContextDispatchUpscale g_origFfxFsr3DispatchUpscale = nullptr;
|
||||
std::atomic<uint32_t> g_fsr3HostPatched{0};
|
||||
constexpr uint32_t kFfxUpscaleSourceFsr3Host = fl::inventory::kFfxLeafCount + 1u;
|
||||
static_assert(kFfxUpscaleSourceFsr3Host > fl::inventory::kFfxLeafCount,
|
||||
"the host's source value must sit past every leaf's (leaf + 1) so the identity arm can tell them apart");
|
||||
|
||||
// THE ONE OFFSET THE HOST DETOUR DEPENDS ON, PINNED TO A LITERAL. commandList (8) +
|
||||
// seven FfxResource (176 each: a pointer, the 32-byte description, the 4-byte state,
|
||||
// 128 bytes of name, padded to 8) + jitterOffset (8) + motionVectorScale (8). The
|
||||
// prefix through renderSize is identical at fsr3-v3.0.3, fsr3-v3.0.4 and v1.1.4 (1.1.4
|
||||
// appends upscaleSize, flags and frameID AFTER it), and the literal is the point: a
|
||||
// re-vendoring that moved the field fails here rather than reading the wrong bytes off
|
||||
// a descriptor Cyberpunk's 3.0 module actually passed.
|
||||
static_assert(sizeof(fsr3host::FfxDimensions2D) == 8u && offsetof(fsr3host::FfxDimensions2D, height) == 4u,
|
||||
"FfxDimensions2D is two uint32_t");
|
||||
static_assert(offsetof(fsr3host::FfxFsr3DispatchUpscaleDescription, renderSize) == 1256u,
|
||||
"FfxFsr3DispatchUpscaleDescription::renderSize moved -- the vendored tag no longer matches the prefix "
|
||||
"3.0.3 / 3.0.4 / 1.1.4 share, and the detour would read the wrong bytes");
|
||||
static_assert(offsetof(fsr3host::FfxFsr3DispatchUpscaleDescription, renderSize) + sizeof(fsr3host::FfxDimensions2D) <=
|
||||
sizeof(fsr3host::FfxFsr3DispatchUpscaleDescription),
|
||||
"the field read must lie inside the descriptor");
|
||||
|
||||
// WHY THIS PERSISTS RATHER THAN BEING exchange(0)'d LIKE g_slSeen.
|
||||
//
|
||||
// g_slSeen answers "did an upscaler run THIS FRAME", so a sample that outlived
|
||||
@@ -1094,9 +1141,7 @@ static_assert(offsetof(ffxDispatchDescFrameGenerationPrepare, renderSize) + size
|
||||
// The render extent, from an UPSCALE or PREPARE descriptor. Same packing and the same
|
||||
// in-band unknown as NoteTags: a zero or absurd size clears the sample rather than
|
||||
// publishing a resolution nobody rendered at.
|
||||
void NoteFfxExtent(const FfxApiDimensions2D& size) noexcept {
|
||||
const uint64_t w = size.width;
|
||||
const uint64_t h = size.height;
|
||||
void NoteFfxExtent(uint64_t w, uint64_t h) noexcept {
|
||||
if (w == 0 || h == 0 || w > 0xFFFFu || h > 0xFFFFu) {
|
||||
g_ffxExtent.store(0, std::memory_order_release);
|
||||
return;
|
||||
@@ -1104,6 +1149,10 @@ void NoteFfxExtent(const FfxApiDimensions2D& size) noexcept {
|
||||
g_ffxExtent.store(w | (h << 16) | kTagValid, std::memory_order_release);
|
||||
}
|
||||
|
||||
void NoteFfxExtent(const FfxApiDimensions2D& size) noexcept {
|
||||
NoteFfxExtent(size.width, size.height);
|
||||
}
|
||||
|
||||
void ObserveFfxDispatch(uint32_t leaf, const ffxDispatchDescHeader* desc) noexcept {
|
||||
if (desc == nullptr) {
|
||||
return;
|
||||
@@ -1164,6 +1213,20 @@ ffxReturnCode_t Hook_FfxDispatchT(ffxContext* context, const ffxDispatchDescHead
|
||||
return g_origFfxDispatch[Leaf](context, desc);
|
||||
}
|
||||
|
||||
// The FSR 3.0 host detour: the UPSCALE arm of ObserveFfxDispatch, verbatim, on a
|
||||
// descriptor of the host API's shape. Original called exactly once on every path.
|
||||
fsr3host::FfxErrorCode Hook_FfxFsr3ContextDispatchUpscale(fsr3host::FfxFsr3Context* context,
|
||||
const fsr3host::FfxFsr3DispatchUpscaleDescription* desc) {
|
||||
FL_HOOK_GUARD({
|
||||
if (MayObserve() && desc != nullptr) {
|
||||
NoteFfxExtent(desc->renderSize.width, desc->renderSize.height);
|
||||
g_ffxUpscaleLeaf.store(kFfxUpscaleSourceFsr3Host, std::memory_order_relaxed);
|
||||
g_ffxSeen.fetch_add(fl::slseen::kCountOne, std::memory_order_relaxed);
|
||||
}
|
||||
})
|
||||
return g_origFfxFsr3DispatchUpscale(context, desc);
|
||||
}
|
||||
|
||||
void* FfxDispatchDetour(uint32_t leaf) noexcept {
|
||||
switch (leaf) {
|
||||
case fl::inventory::kFfxLeafMonolith:
|
||||
@@ -1432,12 +1495,29 @@ bool InstallByFamily(const wchar_t* module, const char* symbol, uint32_t family)
|
||||
// on a 2.x title, so a family published on the first leaf entitles records the
|
||||
// second leaf is not yet producing.
|
||||
//
|
||||
// A module the leaf table does not know installs NOTHING. fl_hook_inventory.h's
|
||||
// static_asserts make that unreachable for the rows as written; this is the
|
||||
// installer's safe direction for a row somebody adds later.
|
||||
// A module the leaf table does not know is either the FSR 3.0 HOST -- its own
|
||||
// export, its own body, its own latch, the same family and publish point -- or
|
||||
// nothing: fl_hook_inventory.h's static_asserts make the latter unreachable for
|
||||
// the rows as written, and installing nothing is the safe direction for a row
|
||||
// somebody adds later.
|
||||
const int leaf = fl::inventory::FfxLeafOf(module);
|
||||
if (leaf < 0) {
|
||||
return false;
|
||||
if (_wcsicmp(module, fl::inventory::kModuleFfxFsr3Host) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (g_fsr3HostPatched.load(std::memory_order_acquire) != 0) {
|
||||
return true;
|
||||
}
|
||||
void* target = fl::inventory::ResolveScoped(module, symbol);
|
||||
if (target == nullptr) {
|
||||
return false; // not loaded, or a module of the name that does not speak the 3.0 host ABI
|
||||
}
|
||||
if (!PatchTarget(target, reinterpret_cast<void*>(&Hook_FfxFsr3ContextDispatchUpscale),
|
||||
reinterpret_cast<void**>(&g_origFfxFsr3DispatchUpscale))) {
|
||||
return false;
|
||||
}
|
||||
g_fsr3HostPatched.store(1, std::memory_order_release);
|
||||
return true;
|
||||
}
|
||||
const auto slot = static_cast<uint32_t>(leaf);
|
||||
if (g_ffxPatched[slot].load(std::memory_order_acquire) != 0) {
|
||||
@@ -1478,6 +1558,15 @@ void PublishFfxFamilyIfWhole() noexcept {
|
||||
return; // loaded and not yet patched: the family is not whole
|
||||
}
|
||||
}
|
||||
// The FSR 3.0 host is the fifth target under the same rule. On Cyberpunk it lives
|
||||
// beside the 1.1.x monolith, and the family's FsrFg claim comes from the monolith
|
||||
// while the identity comes from the host -- published on whichever patched first,
|
||||
// the other's records would be entitled before they were produced (#110's window).
|
||||
if (g_fsr3HostPatched.load(std::memory_order_acquire) != 0) {
|
||||
anyPatched = true;
|
||||
} else if (fl::inventory::IsModuleLoaded(fl::inventory::kModuleFfxFsr3Host)) {
|
||||
return;
|
||||
}
|
||||
if (anyPatched) {
|
||||
PublishHookFamily(fl::inventory::kFamilyFfxDispatch, g_ffxLive);
|
||||
}
|
||||
@@ -1891,18 +1980,21 @@ void RecordPresent(IDXGISwapChain* sc, UINT syncInterval, UINT flags) noexcept {
|
||||
// it, the honest byte is "FSR, version not named" (fl_shm.h
|
||||
// §FL_UPSCALER_FSR_UNVERSIONED): FSR3 would be right on every non-RDNA4
|
||||
// machine and a fabrication on one, and UNKNOWN would print the very N/A
|
||||
// this arm exists to remove.
|
||||
rec.upscaler = g_ffxUpscaleLeaf.load(std::memory_order_relaxed) == fl::inventory::kFfxLeafMonolith + 1u
|
||||
// this arm exists to remove. The FSR 3.0 HOST (ffx_fsr3_x64.dll, Cyberpunk's
|
||||
// copy) hosts FSR 3.0 and nothing else, so it is FSR3 as a fact too.
|
||||
const uint32_t src = g_ffxUpscaleLeaf.load(std::memory_order_relaxed);
|
||||
rec.upscaler = src == fl::inventory::kFfxLeafMonolith + 1u || src == kFfxUpscaleSourceFsr3Host
|
||||
? static_cast<uint8_t>(FL_UPSCALER_FSR3)
|
||||
: static_cast<uint8_t>(FL_UPSCALER_FSR_UNVERSIONED);
|
||||
} else {
|
||||
// UNKNOWN, AND NEVER `NONE`. FL_UPSCALER_NONE means "a hook ran and
|
||||
// there was genuinely no upscaler" -- the one state fl_shm.h allows
|
||||
// to be aggregated as a negative. This writer hooks Streamline and the
|
||||
// ffx-api leaves and nothing else, so an XeSS, NGX-direct or FSR 3.0
|
||||
// (ffx_fsr3_x64.dll) title evaluates its upscaler somewhere we are not
|
||||
// looking -- and so does an FSR title on a present that drained no
|
||||
// dispatch, which under frame generation is every generated present.
|
||||
// to be aggregated as a negative. This writer hooks Streamline, the
|
||||
// ffx-api leaves and the FSR 3.0 host facade and nothing else, so an XeSS
|
||||
// or NGX-direct title, or an FSR 3.0 title calling ffx_fsr3upscaler_x64.dll
|
||||
// directly, evaluates its upscaler somewhere we are not looking -- and so
|
||||
// does an FSR title on a present that drained no dispatch, which under
|
||||
// frame generation is every generated present.
|
||||
// Reporting NONE would turn "we do not cover that vendor" into a measured
|
||||
// fact about the title. UNKNOWN says the true thing: our coverage is short.
|
||||
//
|
||||
|
||||
@@ -3613,6 +3613,46 @@ TEST_CASE("the SDK 1.1.x monolith is FSR3; with no PREPARE the count falls back
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("the FSR 3.0 host facade: Fsr3 identity and the count from its upscale, alone and beside the 1.1.x "
|
||||
"monolith generating",
|
||||
"[guard][inject][shm][ffx]") {
|
||||
// THE FIFTH AMD TARGET, AND NOT A LEAF: Cyberpunk 2077 at FSR 3 upscales through
|
||||
// ffx_fsr3_x64.dll's NAMED export and generates through the 1.1.x monolith's
|
||||
// ffxDispatch, and the leaf-only build printed `upscaler: N/A` beside `FsrFg`.
|
||||
//
|
||||
// (a) The host ALONE at K = 1 with no PREPARE anywhere: the application-frame count
|
||||
// must come from the host's UPSCALE and read 1.0 -- the double-count control for the
|
||||
// row (a writer that counted the call at two addresses reads 2.0), and the proof that
|
||||
// the host's count reaches fgEvaluations at all (a row claiming IDENTITY|PARAMS alone
|
||||
// would fail the floor here). Identity is FSR3 as a fact -- the 3.0 host hosts
|
||||
// nothing else -- and the census sees the host and NOT the monolith.
|
||||
{
|
||||
FfxObservation obs;
|
||||
REQUIRE(ObserveFfx(1, L"fsr3host", /*prepare=*/false, fl::FL_UPSCALER_FSR3, obs));
|
||||
AssertFfxWindow(obs, 1);
|
||||
|
||||
CHECK((obs.census & fl::FL_CENSUS_FFX_FSR3) != 0u);
|
||||
CHECK((obs.census & fl::FL_CENSUS_AMD_FFX_DX12) == 0u);
|
||||
}
|
||||
|
||||
// (b) Cyberpunk's shape: the host upscales while the monolith prepares (pre-V2, twice
|
||||
// per frame) and, at K = 4, generates. Identity can only have come from the host --
|
||||
// the monolith receives no UPSCALE -- while FsrFg at K = 4 and the count from the
|
||||
// PREPARE latch come from the monolith, and the family is published once BOTH are
|
||||
// patched (a family published on the first would entitle records the other module
|
||||
// was not yet producing).
|
||||
for (const int k : {1, 4}) {
|
||||
CAPTURE(k);
|
||||
FfxObservation obs;
|
||||
REQUIRE(ObserveFfx(k, L"fsr3host+mono", /*prepare=*/k > 1, fl::FL_UPSCALER_FSR3, obs));
|
||||
AssertFfxWindow(obs, k);
|
||||
|
||||
CHECK((obs.census & fl::FL_CENSUS_FFX_FSR3) != 0u);
|
||||
CHECK((obs.census & fl::FL_CENSUS_AMD_FFX_DX12) != 0u);
|
||||
CHECK((obs.census & fl::FL_CENSUS_AMD_FFX_UPSCALER) == 0u);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("the UE5 shape: the two SDK 2.x leaves called directly, no loader in the process",
|
||||
"[guard][inject][shm][ffx]") {
|
||||
// Hell Is Us and Expedition 33 -- the engine plugin compiles the MIT loader in and
|
||||
|
||||
+28
@@ -243,3 +243,31 @@ target_include_directories(fl_fidelityfx_headers SYSTEM INTERFACE
|
||||
# declaration that exports nothing unless something DEFINES it. FrameLedger.Overlay
|
||||
# must never define or take the address of one; hookinventory-check Pass C reads
|
||||
# the built DLL's export table as well as its imports for exactly that.
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# AMD FidelityFX SDK -- the FSR 3.0 HOST API headers (MIT) -- VENDORED, ten files,
|
||||
# at tag fsr3-v3.0.4, in a directory of their own beside the ffx-api tree above.
|
||||
#
|
||||
# WHAT THIS BUYS. Cyberpunk 2077 upscales at FSR 3 through ffx_fsr3_x64.dll's NAMED
|
||||
# exports rather than the ffx-api facade, so the row set above sees its frame
|
||||
# generation (the 1.1.x monolith) and not its upscaler. ffxFsr3ContextDispatchUpscale
|
||||
# takes a descriptor whose renderSize field is at an offset only the vendor's own
|
||||
# header can vouch for; this target makes that read a declaration. The tag is the
|
||||
# one whose declarations match the module the title SHIPS -- twelve ffxFsr3* exports,
|
||||
# fsr3-v3.0.4's exact set -- not the v1.1.4 the docs first named, whose dispatch
|
||||
# struct appends fields after renderSize and declares three exports the module lacks
|
||||
# (third_party/fidelityfx-fsr3/README.md).
|
||||
#
|
||||
# A SEPARATE DIRECTORY BECAUSE THE LICENCE SHAPE DIFFERS: a root LICENSE.txt that IS
|
||||
# the MIT grant, with every header carrying it inline -- not v2.3.0's exception list.
|
||||
# tools/license-check.ps1 §2e asserts that per file; §2d would have walked past it.
|
||||
#
|
||||
# ONE INCLUDE DIRECTORY: the headers include each other as <FidelityFX/host/...>, so
|
||||
# sdk/include is the root and upstream's layout is kept, unmodified.
|
||||
add_library(fl_fsr3_host_headers INTERFACE)
|
||||
target_include_directories(fl_fsr3_host_headers SYSTEM INTERFACE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/fidelityfx-fsr3/sdk/include"
|
||||
)
|
||||
# Never linked, same rule as above. FFX_API here is __declspec(dllexport) with no
|
||||
# switch at all (ffx_types.h at this tag); the Overlay defines none of the names and
|
||||
# Pass C's forbidden-export pattern (^ffx[A-Z]) already covers ffxFsr3*.
|
||||
@@ -0,0 +1,19 @@
|
||||
Copyright © 2023 Advanced Micro Devices, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the “Software”), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
# AMD FidelityFX SDK — FSR 3.0 host API headers (vendored)
|
||||
|
||||
Copied from <https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK>, tag
|
||||
**`fsr3-v3.0.4`** (commit `55ff22bb6981a9b9c087b9465101769fc0acd447`). **Ten headers and the
|
||||
licence file.** A second vendoring directory beside `../fidelityfx/` (tag `v2.3.0`, the ffx-api
|
||||
facade), because the two tags carry two different licence *shapes* and `tools/license-check.ps1`
|
||||
asserts each per file: §2d walks `fidelityfx/Kits/` against the exception list inside its
|
||||
`license.md`; **§2e walks this directory's `sdk/` against the root `LICENSE.txt`**, which at this
|
||||
tag is the MIT grant verbatim, with every header carrying the same grant in its own banner.
|
||||
|
||||
## Why this tag — and why not `v1.1.4`, which three documents named
|
||||
|
||||
The one installed title that ships the FSR 3.0 **host** DLLs is Cyberpunk 2077
|
||||
(`ffx_fsr3_x64.dll`, `ffx_fsr3upscaler_x64.dll`, `ffx_frameinterpolation_x64.dll`,
|
||||
`ffx_opticalflow_x64.dll`, `ffx_backend_dx12_x64.dll`). `docs/vendor-exports.json` records
|
||||
`ffx_fsr3_x64.dll` exporting **twelve** `ffxFsr3*` names: `ContextCreate`, `ContextDestroy`,
|
||||
`ContextDispatchUpscale`, `ContextGenerateReactiveMask`, `DispatchFrameGeneration`,
|
||||
`ConfigureFrameGeneration`, `GetJitterOffset`, `GetJitterPhaseCount`,
|
||||
`GetRenderResolutionFromQualityMode`, `GetUpscaleRatioFromQualityMode`, `ResourceIsNull`,
|
||||
`SkipPresent`. Read off the upstream tags through the GitHub API on 2026-09-05:
|
||||
|
||||
- **`fsr3-v3.0.4`** (and `fsr3-v3.0.3`) declares exactly those twelve. Its
|
||||
`FfxFsr3DispatchUpscaleDescription` ends at `viewSpaceToMetersFactor`.
|
||||
- **`v1.1.4`** declares fifteen — it adds `ContextGetGpuMemoryUsage`,
|
||||
`ContextDispatchFrameGenerationPrepare` and `GetEffectVersion`, none of which the shipped
|
||||
module exports — and its `FfxFsr3DispatchUpscaleDescription` appends `upscaleSize`, `flags`
|
||||
and `frameID` **after `renderSize`**. A detour typed against 1.1.4 would read
|
||||
`enableSharpening`/`sharpness` bytes as an output size on Cyberpunk's 3.0 module.
|
||||
- The prefix through `renderSize` — `commandList`, seven `FfxResource`s, `jitterOffset`,
|
||||
`motionVectorScale`, `renderSize` — is **identical** in 3.0.3, 3.0.4 and 1.1.4, and it is the
|
||||
only field the Overlay reads. `dllmain.cpp` pins `offsetof(FfxFsr3DispatchUpscaleDescription,
|
||||
renderSize)` to a literal so a re-vendoring that moved it fails to compile rather than reading
|
||||
the wrong bytes.
|
||||
|
||||
So the declarations vendored are the ones the shipped module exports, and the corrections to
|
||||
`docs/18_GPU_VENDOR_APIS.md`, `docs/HANDOFF.md` and `docs/20_OPEN_QUESTIONS.md` — all of which
|
||||
said `v1.1.4` — landed with this directory.
|
||||
|
||||
## The include closure, measured — and `<mutex>` is not in it
|
||||
|
||||
Those same documents said the closure was "ten headers reaching `<mutex>` / `<shared_mutex>`
|
||||
through `ffx_types.h`". That is true of **1.1.x**, where `ffx_types.h` includes them behind
|
||||
`#ifndef FFX_MUTEX`. At `fsr3-v3.0.4` **`ffx_types.h` includes `<stdint.h>` and nothing else**,
|
||||
and no file below pulls in the STL or `<windows.h>`:
|
||||
|
||||
```
|
||||
ffx_fsr3.h
|
||||
├── ffx_interface.h
|
||||
│ ├── ffx_assert.h → ffx_types.h, ffx_util.h (→ ffx_types.h)
|
||||
│ ├── ffx_types.h → <stdint.h>
|
||||
│ └── ffx_error.h → ffx_types.h
|
||||
├── ffx_fsr3upscaler.h → ffx_interface.h, ../gpu/fsr3upscaler/ffx_fsr3upscaler_resources.h (defines only)
|
||||
├── ffx_frameinterpolation.h → ffx_interface.h
|
||||
└── ffx_opticalflow.h → ffx_interface.h
|
||||
```
|
||||
|
||||
Ten files, no `ffx_message.h` (that file exists at 1.1.x, not here). The Overlay is built with
|
||||
`_HAS_EXCEPTIONS=0` and no C++ exceptions on hook paths; a closure with no STL in it has nothing
|
||||
to audit for `throw`, which is the property the Streamline closure had to be measured for.
|
||||
|
||||
## `FFX_API` is `__declspec(dllexport)` unconditionally
|
||||
|
||||
`ffx_types.h` defines `FFX_API` as `__declspec(dllexport)` on every non-GCC compiler — there is
|
||||
no import switch at this tag (the `FFX_BUILD_AS_DLL` switch arrives in 1.1.x). That is the same
|
||||
hazard `ffx_api.h`'s `FFX_API_ENTRY` carries and it has the same answer: a declaration exports
|
||||
nothing unless something *defines* it. `FrameLedger.Overlay` includes `ffx_fsr3.h` for types and
|
||||
`decltype` only and defines none of the names; `tools/hookinventory-check.ps1` Pass C reads the
|
||||
built DLL's export table (forbidden pattern `^ffx[A-Z]`) to keep that true, and the
|
||||
`ffx_fsr3_x64.dll` fixture in `tools/vendor-stubs` — which *does* define four of them through the
|
||||
vendor's own macro — is the parser's second positive control.
|
||||
|
||||
## Coexistence with `../fidelityfx/` in one translation unit
|
||||
|
||||
Both trees are included by `dllmain.cpp` and by `hook-harness`. Measured at the first build: the
|
||||
type names are disjoint (`FfxApiResource` / `FfxApiDimensions2D` there, `FfxResource` /
|
||||
`FfxDimensions2D` here) **except one** — both trees define a struct named
|
||||
`FfxFrameGenerationConfig` (2.3.0's `ffx_framegeneration.h`, 3.0.4's `ffx_interface.h`) — and the
|
||||
one macro both define, `FFX_RESOURCE_NAME_SIZE`, is `64` in each, a legal identical redefinition.
|
||||
So the consumers include this tree **inside a namespace** (`namespace fsr3host { #include
|
||||
<FidelityFX/host/ffx_fsr3.h> }`): the headers stay verbatim, the entry points keep their C
|
||||
linkage (a C-linkage function declared in two namespace scopes is one function), and every field
|
||||
the Overlay reads is still the vendor's own declaration, spelled `fsr3host::…`.
|
||||
|
||||
## Unmodified, and checked rather than claimed
|
||||
|
||||
`git hash-object` on each vendored file equals the blob sha the GitHub tree API reports for the
|
||||
same path at the tag. Upstream ships **LF**; `.gitattributes` (`* text=auto eol=crlf`) stores LF
|
||||
in the index and materialises CRLF in the working tree, so `git ls-files -s` agrees with the table
|
||||
below and a checked-out file differs from upstream in line endings only — the same shape as the
|
||||
`../fidelityfx/` tree:
|
||||
|
||||
| File | Blob sha |
|
||||
|---|---|
|
||||
| `LICENSE.txt` | `3c5c80518fc83a2532f8445f925d46677eca7782` |
|
||||
| `sdk/include/FidelityFX/host/ffx_fsr3.h` | `62bf127fcbf0625d057b2f6ff0d72cdee9716f74` |
|
||||
| `sdk/include/FidelityFX/host/ffx_interface.h` | `3a7277afae65bd651d1ae8ea4a356bc122df052c` |
|
||||
| `sdk/include/FidelityFX/host/ffx_fsr3upscaler.h` | `83bee5d9cdf84ed32dd974cc447599d30d62be82` |
|
||||
| `sdk/include/FidelityFX/host/ffx_frameinterpolation.h` | `4a98ad05eee506fed7ed17e79dfece37a6aeca77` |
|
||||
| `sdk/include/FidelityFX/host/ffx_opticalflow.h` | `f18a6ddabb9c89cb8eede03c00d92869ca1a3764` |
|
||||
| `sdk/include/FidelityFX/host/ffx_assert.h` | `11718eca730e0eae6a7b9f6db5070a649bab31ef` |
|
||||
| `sdk/include/FidelityFX/host/ffx_types.h` | `64494df9eff3f14d29f97e9add9d85e83e8a4c07` |
|
||||
| `sdk/include/FidelityFX/host/ffx_error.h` | `d1d466fec4ba3964ce9121850a51cdc42d0aa685` |
|
||||
| `sdk/include/FidelityFX/host/ffx_util.h` | `123cd1969f6307601be8d94e902fe6e5a2b0d77c` |
|
||||
| `sdk/include/FidelityFX/gpu/fsr3upscaler/ffx_fsr3upscaler_resources.h` | `d98cfcc0602c7dd59ece0960fd02dbdaef0bb897` |
|
||||
|
||||
## What is here, and what is not
|
||||
|
||||
Kept in upstream's `sdk/include/FidelityFX/…` layout because the headers include each other by
|
||||
`<FidelityFX/host/…>` path; the CMake target `fl_fsr3_host_headers` adds `sdk/include` as a
|
||||
`SYSTEM` include directory and links nothing.
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| **Here** | the ten-file closure of `ffx_fsr3.h` above, and `LICENSE.txt` |
|
||||
| **Not here** | everything else under `sdk/` — the backends (`ffx_dx12.h`, `ffx_vk.h`), every `.cpp`, every shader, every other effect's host header, the samples and `Kits/`. Nothing is vendored ahead of a consumer (`docs/18_GPU_VENDOR_APIS.md`) |
|
||||
|
||||
## How it is consumed
|
||||
|
||||
**Types and `decltype` only, never linked.** The Overlay reads exactly one field of the argument
|
||||
the title passes to one export — `FfxFsr3DispatchUpscaleDescription::renderSize` on
|
||||
`ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale` — for the upscaler's identity (`FL_UPSCALER_FSR3`)
|
||||
and render extent. Never the context, never a resource, never the command list (CLAUDE.md
|
||||
rule 4). `ffxFsr3DispatchFrameGeneration` and `ffxFsr3SkipPresent` are probe-only names
|
||||
(`SpeaksFsr3Host` in `fl_hook_inventory.h`): checked for existence, never resolved, never called.
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
#ifndef FFX_FSR3UPSCALER_RESOURCES_H
|
||||
#define FFX_FSR3UPSCALER_RESOURCES_H
|
||||
|
||||
#if defined(FFX_CPU) || defined(FFX_GPU)
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_NULL 0
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_OPAQUE_ONLY 1
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_COLOR 2
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_MOTION_VECTORS 3
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_DEPTH 4
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_EXPOSURE 5
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_REACTIVE_MASK 6
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_TRANSPARENCY_AND_COMPOSITION_MASK 7
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_RECONSTRUCTED_PREVIOUS_NEAREST_DEPTH 8
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_DILATED_MOTION_VECTORS 9
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_DILATED_DEPTH 10
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR 11
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LOCK_STATUS 12
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_NEW_LOCKS 13
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREPARED_INPUT_COLOR 14
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LUMA_HISTORY 15
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_DEBUG_OUTPUT 16
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LANCZOS_LUT 17
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SPD_ATOMIC_COUNT 18
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_UPSCALED_OUTPUT 19
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_RCAS_INPUT 20
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LOCK_STATUS_1 21
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LOCK_STATUS_2 22
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR_1 23
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR_2 24
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_REACTIVITY 25
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_TRANSPARENCY_AND_COMPOSITION 26
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTITIER_UPSAMPLE_MAXIMUM_BIAS_LUT 27
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_DILATED_REACTIVE_MASKS 28
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE 29 // same as FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0 29
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_1 30
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_2 31
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_3 32
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_4 33
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_5 34
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_6 35
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_7 36
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_8 37
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_9 38
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_10 39
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_11 40
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_12 41
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_EXPOSURE 42
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_AUTO_EXPOSURE 43
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_AUTOREACTIVE 44
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_AUTOCOMPOSITION_DEPRECATED 45
|
||||
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR 46
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR 47
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR_1 48
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR_1 49
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR_2 50
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR_2 51
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREVIOUS_DILATED_MOTION_VECTORS 52
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LUMA_HISTORY_1 53
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LUMA_HISTORY_2 54
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LOCK_INPUT_LUMA 55
|
||||
|
||||
// Shading change detection mip level setting, value must be in the range [FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0, FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_12]
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_4
|
||||
#define FFX_FSR3UPSCALER_SHADING_CHANGE_MIP_LEVEL (FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE - FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE)
|
||||
|
||||
#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT 56
|
||||
|
||||
#define FFX_FSR3UPSCALER_CONSTANTBUFFER_IDENTIFIER_FSR3UPSCALER 0
|
||||
#define FFX_FSR3UPSCALER_CONSTANTBUFFER_IDENTIFIER_SPD 1
|
||||
#define FFX_FSR3UPSCALER_CONSTANTBUFFER_IDENTIFIER_RCAS 2
|
||||
#define FFX_FSR3UPSCALER_CONSTANTBUFFER_IDENTIFIER_GENREACTIVE 3
|
||||
|
||||
#define FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_TONEMAP 1
|
||||
#define FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP 2
|
||||
#define FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_THRESHOLD 4
|
||||
#define FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX 8
|
||||
|
||||
#endif // #if defined(FFX_CPU) || defined(FFX_GPU)
|
||||
|
||||
#endif //!defined( FFX_FSR3UPSCALER_RESOURCES_H )
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <FidelityFX/host/ffx_types.h>
|
||||
#include <FidelityFX/host/ffx_util.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // #ifdef __cplusplus
|
||||
|
||||
/// @defgroup Asserts Asserts
|
||||
/// Asserts used by FidelityFX SDK functions
|
||||
///
|
||||
/// @ingroup ffxHost
|
||||
|
||||
#ifdef _DEBUG
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifdef DISABLE_FFX_DEBUG_BREAK
|
||||
#define FFX_DEBUG_BREAK \
|
||||
{ \
|
||||
}
|
||||
#else
|
||||
/// Macro to force the debugger to break at this point in the code.
|
||||
///
|
||||
/// @ingroup Asserts
|
||||
#define FFX_DEBUG_BREAK __debugbreak();
|
||||
#endif
|
||||
#else
|
||||
#define FFX_DEBUG_BREAK \
|
||||
{ \
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
// don't allow debug break in release builds.
|
||||
#define FFX_DEBUG_BREAK
|
||||
#endif
|
||||
|
||||
/// A typedef for the callback function for assert printing.
|
||||
///
|
||||
/// This can be used to re-route printing of assert messages from the FFX backend
|
||||
/// to another destination. For example instead of the default behaviour of printing
|
||||
/// the assert messages to the debugger's TTY the message can be re-routed to a
|
||||
/// MessageBox in a GUI application.
|
||||
///
|
||||
/// @param [in] message The message generated by the assert.
|
||||
///
|
||||
/// @ingroup Asserts
|
||||
typedef void (*FfxAssertCallback)(const char* message);
|
||||
|
||||
/// Function to report an assert.
|
||||
///
|
||||
/// @param [in] file The name of the file as a string.
|
||||
/// @param [in] line The index of the line in the file.
|
||||
/// @param [in] condition The boolean condition that was tested.
|
||||
/// @param [in] msg The optional message to print.
|
||||
///
|
||||
/// @returns
|
||||
/// Always returns true.
|
||||
///
|
||||
/// @ingroup Asserts
|
||||
FFX_API bool ffxAssertReport(const char* file, int32_t line, const char* condition, const char* msg);
|
||||
|
||||
/// Provides the ability to set a callback for assert messages.
|
||||
///
|
||||
/// @param [in] callback The callback function that will receive assert messages.
|
||||
///
|
||||
/// @ingroup Asserts
|
||||
FFX_API void ffxAssertSetPrintingCallback(FfxAssertCallback callback);
|
||||
|
||||
#ifdef _DEBUG
|
||||
/// Standard assert macro.
|
||||
///
|
||||
/// @ingroup Asserts
|
||||
#define FFX_ASSERT(condition) \
|
||||
do \
|
||||
{ \
|
||||
if (!(condition) && ffxAssertReport(__FILE__, __LINE__, #condition, NULL)) \
|
||||
FFX_DEBUG_BREAK \
|
||||
} while (0)
|
||||
|
||||
/// Assert macro with message.
|
||||
///
|
||||
/// @ingroup Asserts
|
||||
#define FFX_ASSERT_MESSAGE(condition, msg) \
|
||||
do \
|
||||
{ \
|
||||
if (!(condition) && ffxAssertReport(__FILE__, __LINE__, #condition, msg)) \
|
||||
FFX_DEBUG_BREAK \
|
||||
} while (0)
|
||||
|
||||
/// Assert macro that always fails.
|
||||
///
|
||||
/// @ingroup Asserts
|
||||
#define FFX_ASSERT_FAIL(message) \
|
||||
do \
|
||||
{ \
|
||||
ffxAssertReport(__FILE__, __LINE__, NULL, message); \
|
||||
FFX_DEBUG_BREAK \
|
||||
} while (0)
|
||||
#else
|
||||
// asserts disabled
|
||||
#define FFX_ASSERT(condition) \
|
||||
do \
|
||||
{ \
|
||||
FFX_UNUSED(condition); \
|
||||
} while (0)
|
||||
|
||||
#define FFX_ASSERT_MESSAGE(condition, message) \
|
||||
do \
|
||||
{ \
|
||||
FFX_UNUSED(condition); \
|
||||
FFX_UNUSED(message); \
|
||||
} while (0)
|
||||
|
||||
#define FFX_ASSERT_FAIL(message) \
|
||||
do \
|
||||
{ \
|
||||
FFX_UNUSED(message); \
|
||||
} while (0)
|
||||
#endif // #if _DEBUG
|
||||
|
||||
/// Simple static assert.
|
||||
///
|
||||
/// @ingroup Asserts
|
||||
#define FFX_STATIC_ASSERT(condition) static_assert(condition, #condition)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // #ifdef __cplusplus
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <FidelityFX/host/ffx_types.h>
|
||||
|
||||
/// @defgroup Errors Error Codes
|
||||
/// Error codes returned from FidelityFX SDK functions
|
||||
///
|
||||
/// @ingroup ffxHost
|
||||
|
||||
/// Typedef for error codes returned from functions in the FidelityFX SDK.
|
||||
///
|
||||
/// @ingroup Errors
|
||||
typedef int32_t FfxErrorCode;
|
||||
|
||||
/// Error codes and their meaning
|
||||
///
|
||||
/// @ingroup Errors
|
||||
typedef enum FfxErrorCodes {
|
||||
|
||||
FFX_OK = 0, ///< The operation completed successfully.
|
||||
FFX_ERROR_INVALID_POINTER = 0x80000000, ///< The operation failed due to an invalid pointer.
|
||||
FFX_ERROR_INVALID_ALIGNMENT = 0x80000001, ///< The operation failed due to an invalid alignment.
|
||||
FFX_ERROR_INVALID_SIZE = 0x80000002, ///< The operation failed due to an invalid size.
|
||||
FFX_EOF = 0x80000003, ///< The end of the file was encountered.
|
||||
FFX_ERROR_INVALID_PATH = 0x80000004, ///< The operation failed because the specified path was invalid.
|
||||
FFX_ERROR_EOF = 0x80000005, ///< The operation failed because end of file was reached.
|
||||
FFX_ERROR_MALFORMED_DATA = 0x80000006, ///< The operation failed because of some malformed data.
|
||||
FFX_ERROR_OUT_OF_MEMORY = 0x80000007, ///< The operation failed because it ran out memory.
|
||||
FFX_ERROR_INCOMPLETE_INTERFACE = 0x80000008, ///< The operation failed because the interface was not fully configured.
|
||||
FFX_ERROR_INVALID_ENUM = 0x80000009, ///< The operation failed because of an invalid enumeration value.
|
||||
FFX_ERROR_INVALID_ARGUMENT = 0x8000000a, ///< The operation failed because an argument was invalid.
|
||||
FFX_ERROR_OUT_OF_RANGE = 0x8000000b, ///< The operation failed because a value was out of range.
|
||||
FFX_ERROR_NULL_DEVICE = 0x8000000c, ///< The operation failed because a device was null.
|
||||
FFX_ERROR_BACKEND_API_ERROR = 0x8000000d, ///< The operation failed because the backend API returned an error code.
|
||||
FFX_ERROR_INSUFFICIENT_MEMORY = 0x8000000e, ///< The operation failed because there was not enough memory.
|
||||
|
||||
}FfxErrorCodes;
|
||||
|
||||
/// Helper macro to return error code y from a function when a specific condition, x, is not met.
|
||||
///
|
||||
/// @ingroup Errors
|
||||
#define FFX_RETURN_ON_ERROR(x, y) \
|
||||
if (!(x)) \
|
||||
{ \
|
||||
return (y); \
|
||||
}
|
||||
|
||||
/// Helper macro to return error code x from a function when it is not FFX_OK.
|
||||
///
|
||||
/// @ingroup Errors
|
||||
#define FFX_VALIDATE(x) \
|
||||
{ \
|
||||
FfxErrorCode ret = x; \
|
||||
FFX_RETURN_ON_ERROR(ret == FFX_OK, ret); \
|
||||
}
|
||||
Vendored
+242
@@ -0,0 +1,242 @@
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
// @defgroup FRAMEINTERPOLATION
|
||||
|
||||
#pragma once
|
||||
|
||||
// Include the interface for the backend of the Frameinterpolation API.
|
||||
#include <FidelityFX/host/ffx_interface.h>
|
||||
|
||||
/// FidelityFX Frameinterpolation major version.
|
||||
///
|
||||
/// @ingroup FRAMEINTERPOLATIONFRAMEINTERPOLATION
|
||||
#define FFX_FRAMEINTERPOLATION_VERSION_MAJOR (1)
|
||||
|
||||
/// FidelityFX Frameinterpolation minor version.
|
||||
///
|
||||
/// @ingroup FRAMEINTERPOLATIONFRAMEINTERPOLATION
|
||||
#define FFX_FRAMEINTERPOLATION_VERSION_MINOR (0)
|
||||
|
||||
/// FidelityFX Frameinterpolation patch version.
|
||||
///
|
||||
/// @ingroup FRAMEINTERPOLATIONFRAMEINTERPOLATION
|
||||
#define FFX_FRAMEINTERPOLATION_VERSION_PATCH (1)
|
||||
|
||||
/// FidelityFX Frame Interpolation context count
|
||||
///
|
||||
/// Defines the number of internal effect contexts required by Frame Interpolation
|
||||
///
|
||||
/// @ingroup ffxFrameInterpolation
|
||||
#define FFX_FRAMEINTERPOLATION_CONTEXT_COUNT (1)
|
||||
|
||||
/// The size of the context specified in 32bit values.
|
||||
///
|
||||
/// @ingroup FRAMEINTERPOLATIONFRAMEINTERPOLATION
|
||||
#define FFX_FRAMEINTERPOLATION_CONTEXT_SIZE (FFX_SDK_DEFAULT_CONTEXT_SIZE)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif // #if defined(__cplusplus)
|
||||
|
||||
/// An enumeration of all the passes which constitute the FSR3 algorithm.
|
||||
///
|
||||
/// FSR3 is implemented as a composite of several compute passes each
|
||||
/// computing a key part of the final result. Each call to the
|
||||
/// <c><i>FfxFsr3ScheduleGpuJobFunc</i></c> callback function will
|
||||
/// correspond to a single pass included in <c><i>FfxFsr3Pass</i></c>. For a
|
||||
/// more comprehensive description of each pass, please refer to the FSR3
|
||||
/// reference documentation.
|
||||
///
|
||||
/// Please note in some cases e.g.: <c><i>FFX_FSR3_PASS_ACCUMULATE</i></c>
|
||||
/// and <c><i>FFX_FSR3_PASS_ACCUMULATE_SHARPEN</i></c> either one pass or the
|
||||
/// other will be used (they are mutually exclusive). The choice of which will
|
||||
/// depend on the way the <c><i>FfxFsr3Context</i></c> is created and the
|
||||
/// precise contents of <c><i>FfxFsr3DispatchParamters</i></c> each time a call
|
||||
/// is made to <c><i>ffxFsr3ContextDispatch</i></c>.
|
||||
///
|
||||
/// @ingroup FRAMEINTERPOLATIONFRAMEINTERPOLATION
|
||||
typedef enum FfxFrameInterpolationPass
|
||||
{
|
||||
FFX_FRAMEINTERPOLATION_PASS_SETUP,
|
||||
FFX_FRAMEINTERPOLATION_PASS_RECONSTRUCT_PREV_DEPTH,
|
||||
FFX_FRAMEINTERPOLATION_PASS_GAME_MOTION_VECTOR_FIELD,
|
||||
FFX_FRAMEINTERPOLATION_PASS_OPTICAL_FLOW_VECTOR_FIELD,
|
||||
FFX_FRAMEINTERPOLATION_PASS_DISOCCLUSION_MASK,
|
||||
FFX_FRAMEINTERPOLATION_PASS_INTERPOLATION,
|
||||
FFX_FRAMEINTERPOLATION_PASS_INPAINTING_PYRAMID,
|
||||
FFX_FRAMEINTERPOLATION_PASS_INPAINTING,
|
||||
FFX_FRAMEINTERPOLATION_PASS_GAME_VECTOR_FIELD_INPAINTING_PYRAMID,
|
||||
FFX_FRAMEINTERPOLATION_PASS_DEBUG_VIEW,
|
||||
FFX_FRAMEINTERPOLATION_PASS_COUNT ///< The number of passes performed by FrameInterpolation.
|
||||
} FfxFrameInterpolationPass;
|
||||
|
||||
// forward declarations
|
||||
struct FfxFrameInterpolationContext;
|
||||
|
||||
/// An enumeration of bit flags used when creating a
|
||||
/// <c><i>FfxFrameInterpolationContext</i></c>. See <c><i>FfxFrameInterpolationContextDescription</i></c>.
|
||||
///
|
||||
/// @ingroup FRAMEINTERPOLATIONFRAMEINTERPOLATION
|
||||
typedef enum FfxFrameInterpolationInitializationFlagBits {
|
||||
|
||||
FFX_FRAMEINTERPOLATION_ENABLE_DEPTH_INVERTED = (1<<0), ///< A bit indicating that the input depth buffer data provided is inverted [1..0].
|
||||
FFX_FRAMEINTERPOLATION_ENABLE_DEPTH_INFINITE = (1<<1), ///< A bit indicating that the input depth buffer data provided is using an infinite far plane.
|
||||
FFX_FRAMEINTERPOLATION_ENABLE_TEXTURE1D_USAGE = (1<<2), ///< A bit indicating that the backend should use 1D textures.
|
||||
FFX_FRAMEINTERPOLATION_ENABLE_HDR_COLOR_INPUT = (1<<3) ///< A bit indicating that HDR values are present in the imaging pipeline.
|
||||
} FfxFrameInterpolationInitializationFlagBits;
|
||||
|
||||
/// A structure encapsulating the parameters required to initialize
|
||||
/// FidelityFX Frameinterpolation upscaling.
|
||||
///
|
||||
/// @ingroup FRAMEINTERPOLATION
|
||||
typedef struct FfxFrameInterpolationContextDescription {
|
||||
|
||||
FfxInterface backendInterface; ///< A set of pointers to the backend implementation for FidelityFX SDK
|
||||
|
||||
uint32_t flags; ///< A collection of <c><i>FfxFrameInterpolationInitializationFlagBits</i></c>.
|
||||
FfxDimensions2D maxRenderSize; ///< The maximum size that rendering will be performed at.
|
||||
FfxDimensions2D displaySize; ///< The size of the presentation resolution
|
||||
FfxSurfaceFormat backBufferFormat;
|
||||
} FfxFrameInterpolationContextDescription;
|
||||
|
||||
/// A structure encapsulating the FidelityFX Super Resolution 2 context.
|
||||
///
|
||||
/// This sets up an object which contains all persistent internal data and
|
||||
/// resources that are required by FSR3.
|
||||
///
|
||||
/// The <c><i>FfxFsr3Context</i></c> object should have a lifetime matching
|
||||
/// your use of FSR3. Before destroying the FSR3 context care should be taken
|
||||
/// to ensure the GPU is not accessing the resources created or used by FSR3.
|
||||
/// It is therefore recommended that the GPU is idle before destroying the
|
||||
/// FSR3 context.
|
||||
///
|
||||
/// @ingroup FRAMEINTERPOLATION
|
||||
typedef struct FfxFrameInterpolationContext
|
||||
{
|
||||
uint32_t data[FFX_FRAMEINTERPOLATION_CONTEXT_SIZE]; ///< An opaque set of <c>uint32_t</c> which contain the data for the context.
|
||||
} FfxFrameInterpolationContext;
|
||||
|
||||
|
||||
/// Create a FidelityFX Super Resolution 2 context from the parameters
|
||||
/// programmed to the <c><i>FfxFsr3CreateParams</i></c> structure.
|
||||
///
|
||||
/// The context structure is the main object used to interact with the FSR3
|
||||
/// API, and is responsible for the management of the internal resources used
|
||||
/// by the FSR3 algorithm. When this API is called, multiple calls will be
|
||||
/// made via the pointers contained in the <c><i>callbacks</i></c> structure.
|
||||
/// These callbacks will attempt to retreive the device capabilities, and
|
||||
/// create the internal resources, and pipelines required by FSR3's
|
||||
/// frame-to-frame function. Depending on the precise configuration used when
|
||||
/// creating the <c><i>FfxFsr3Context</i></c> a different set of resources and
|
||||
/// pipelines might be requested via the callback functions.
|
||||
///
|
||||
/// The flags included in the <c><i>flags</i></c> field of
|
||||
/// <c><i>FfxFsr3Context</i></c> how match the configuration of your
|
||||
/// application as well as the intended use of FSR3. It is important that these
|
||||
/// flags are set correctly (as well as a correct programmed
|
||||
/// <c><i>FfxFsr3DispatchDescription</i></c>) to ensure correct operation. It is
|
||||
/// recommended to consult the overview documentation for further details on
|
||||
/// how FSR3 should be integerated into an application.
|
||||
///
|
||||
/// When the <c><i>FfxFsr3Context</i></c> is created, you should use the
|
||||
/// <c><i>ffxFsr3ContextDispatch</i></c> function each frame where FSR3
|
||||
/// upscaling should be applied. See the documentation of
|
||||
/// <c><i>ffxFsr3ContextDispatch</i></c> for more details.
|
||||
///
|
||||
/// The <c><i>FfxFsr3Context</i></c> should be destroyed when use of it is
|
||||
/// completed, typically when an application is unloaded or FSR3 upscaling is
|
||||
/// disabled by a user. To destroy the FSR3 context you should call
|
||||
/// <c><i>ffxFsr3ContextDestroy</i></c>.
|
||||
///
|
||||
/// @param [out] context A pointer to a <c><i>FfxFsr3Context</i></c> structure to populate.
|
||||
/// @param [in] contextDescription A pointer to a <c><i>FfxFsr3ContextDescription</i></c> structure.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either <c><i>context</i></c> or <c><i>contextDescription</i></c> was <c><i>NULL</i></c>.
|
||||
/// @retval
|
||||
/// FFX_ERROR_INCOMPLETE_INTERFACE The operation failed because the <c><i>FfxFsr3ContextDescription.callbacks</i></c> was not fully specified.
|
||||
/// @retval
|
||||
/// FFX_ERROR_BACKEND_API_ERROR The operation failed because of an error returned from the backend.
|
||||
///
|
||||
/// @ingroup FRAMEINTERPOLATION
|
||||
FFX_API FfxErrorCode ffxFrameInterpolationContextCreate(FfxFrameInterpolationContext* context, FfxFrameInterpolationContextDescription* contextDescription);
|
||||
|
||||
typedef enum FfxFrameInterpolationDispatchFlags
|
||||
{
|
||||
FFX_FRAMEINTERPOLATION_DISPATCH_DRAW_DEBUG_TEAR_LINES = (1 << 0), ///< A bit indicating that the debug tear lines will be drawn to the interpolated output.
|
||||
FFX_FRAMEINTERPOLATION_DISPATCH_DRAW_DEBUG_VIEW = (1 << 1), ///< A bit indicating that the interpolated output resource will contain debug views with relevant information.
|
||||
} FfxFrameInterpolationDispatchFlags;
|
||||
|
||||
typedef struct FfxFrameInterpolationDispatchDescription {
|
||||
|
||||
uint32_t flags; ///< combination of FfxFrameInterpolationDispatchFlags
|
||||
FfxCommandList commandList; ///< The <c><i>FfxCommandList</i></c> to record frame interpolation commands into.
|
||||
FfxDimensions2D displaySize; ///< The destination output dimensions
|
||||
FfxDimensions2D renderSize; ///< The dimensions used to render game content, dilatedDepth, dilatedMotionVectors are expected to be of ths size.
|
||||
FfxResource currentBackBuffer; ///< The current presentation color, if currentBackBuffer_HUDLess is not used, this will be used as interpolation source data.
|
||||
FfxResource currentBackBuffer_HUDLess; ///< The current presentation color without HUD content, when use it will be used as interpolation source data.
|
||||
FfxResource output; ///< The output resource where to store the interpolated result.
|
||||
FfxResource dilatedDepth; ///< The dilated depth buffer data (see example computation in the FfxFsr3Upscaler effect)
|
||||
FfxResource dilatedMotionVectors; ///< The dilated motion vector data (see example computation in the FfxFsr3Upscaler effect)
|
||||
FfxResource reconstructPrevNearDepth; ///< The estimated previous frame depth buffer (see example computation in the FfxFsr3Upscaler effect)
|
||||
|
||||
FfxRect2D interpolationRect; ///< The area of the backbuffer that should be used for interpolation in case only a part of the screen is used e.g. due to movie bars
|
||||
|
||||
FfxResource opticalFlowVector; ///< The optical flow motion vectors (see example computation in the FfxOpticalFlow effect)
|
||||
FfxResource opticalFlowSceneChangeDetection; ///< The optical flow scene change detection data
|
||||
FfxDimensions2D opticalFlowBufferSize; ///< The optical flow motion vector resource dimensions
|
||||
FfxFloatCoords2D opticalFlowScale; ///< The optical flow motion vector scale factor, used to scale resoure values into [0.0,1.0] range.
|
||||
int opticalFlowBlockSize; ///< The optical flow block dimension size
|
||||
|
||||
float cameraNear; ///< The distance to the near plane of the camera.
|
||||
float cameraFar; ///< The distance to the far plane of the camera. This is used only used in case of non infinite depth.
|
||||
float cameraFovAngleVertical; ///< The camera angle field of view in the vertical direction (expressed in radians).
|
||||
float viewSpaceToMetersFactor; ///< The unit to scale view space coordinates to meters.
|
||||
|
||||
float frameTimeDelta; ///< The time elapsed since the last frame (expressed in milliseconds).
|
||||
bool reset; ///< A boolean value which when set to true, indicates the camera has moved discontinuously.
|
||||
|
||||
FfxBackbufferTransferFunction backBufferTransferFunction; ///< The transfer function use to convert interpolation source color data to linear RGB.
|
||||
float minMaxLuminance[2]; ///< Min and max luminance values, used when converting HDR colors to linear RGB
|
||||
|
||||
} FfxFrameInterpolationDispatchDescription;
|
||||
|
||||
FFX_API FfxErrorCode ffxFrameInterpolationDispatch(FfxFrameInterpolationContext* context, const FfxFrameInterpolationDispatchDescription* params);
|
||||
|
||||
/// Destroy the FidelityFX Super Resolution context.
|
||||
///
|
||||
/// @param [out] context A pointer to a <c><i>FfxFsr3Context</i></c> structure to destroy.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either <c><i>context</i></c> was <c><i>NULL</i></c>.
|
||||
///
|
||||
/// @ingroup FRAMEINTERPOLATION
|
||||
FFX_API FfxErrorCode ffxFrameInterpolationContextDestroy(FfxFrameInterpolationContext* context);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif // #if defined(__cplusplus)
|
||||
+503
@@ -0,0 +1,503 @@
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
// @defgroup FSR3
|
||||
|
||||
#pragma once
|
||||
|
||||
// Include the interface for the backend of the FSR3 API.
|
||||
#include <FidelityFX/host/ffx_interface.h>
|
||||
#include <FidelityFX/host/ffx_fsr3upscaler.h>
|
||||
#include <FidelityFX/host/ffx_frameinterpolation.h>
|
||||
#include <FidelityFX/host/ffx_opticalflow.h>
|
||||
|
||||
/// FidelityFX Super Resolution 3 major version.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
#define FFX_FSR3_VERSION_MAJOR (3)
|
||||
|
||||
/// FidelityFX Super Resolution 0 minor version.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
#define FFX_FSR3_VERSION_MINOR (0)
|
||||
|
||||
/// FidelityFX Super Resolution 0 patch version.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
#define FFX_FSR3_VERSION_PATCH (4)
|
||||
|
||||
/// FidelityFX Super Resolution 3 context count
|
||||
///
|
||||
/// Defines the number of internal effect contexts required by FSR3 (+1 for proxy swapchain)
|
||||
///
|
||||
/// @ingroup ffxFsr3
|
||||
#define FFX_FSR3_CONTEXT_COUNT (FFX_FSR3UPSCALER_CONTEXT_COUNT + FFX_OPTICALFLOW_CONTEXT_COUNT + FFX_FRAMEINTERPOLATION_CONTEXT_COUNT + 1)
|
||||
|
||||
/// The size of the context specified in 32bit values.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
#define FFX_FSR3_CONTEXT_SIZE (16536)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif // #if defined(__cplusplus)
|
||||
|
||||
///// An enumeration of all the passes which constitute the FSR3 algorithm.
|
||||
/////
|
||||
///// FSR3 is implemented as a composite of several compute passes each
|
||||
///// computing a key part of the final result. Each call to the
|
||||
///// <c><i>FfxFsr3ScheduleGpuJobFunc</i></c> callback function will
|
||||
///// correspond to a single pass included in <c><i>FfxFsr3Pass</i></c>. For a
|
||||
///// more comprehensive description of each pass, please refer to the FSR3
|
||||
///// reference documentation.
|
||||
/////
|
||||
///// Please note in some cases e.g.: <c><i>FFX_FSR3_PASS_ACCUMULATE</i></c>
|
||||
///// and <c><i>FFX_FSR3_PASS_ACCUMULATE_SHARPEN</i></c> either one pass or the
|
||||
///// other will be used (they are mutually exclusive). The choice of which will
|
||||
///// depend on the way the <c><i>FfxFsr3Context</i></c> is created and the
|
||||
///// precise contents of <c><i>FfxFsr3DispatchParamters</i></c> each time a call
|
||||
///// is made to <c><i>ffxFsr3ContextDispatch</i></c>.
|
||||
/////
|
||||
///// @ingroup FSR3
|
||||
//typedef enum FfxFsr3Pass
|
||||
//{
|
||||
// // no special FSR3 pipelines
|
||||
//
|
||||
// FFX_FSR3_PASS_COUNT ///< The number of passes performed by FSR3.
|
||||
//} FfxFsr3Pass;
|
||||
|
||||
/// An enumeration of all the quality modes supported by FidelityFX Super
|
||||
/// Resolution 2 upscaling.
|
||||
///
|
||||
/// In order to provide a consistent user experience across multiple
|
||||
/// applications which implement FSR3. It is strongly recommended that the
|
||||
/// following preset scaling factors are made available through your
|
||||
/// application's user interface.
|
||||
///
|
||||
/// If your application does not expose the notion of preset scaling factors
|
||||
/// for upscaling algorithms (perhaps instead implementing a fixed ratio which
|
||||
/// is immutable) or implementing a more dynamic scaling scheme (such as
|
||||
/// dynamic resolution scaling), then there is no need to use these presets.
|
||||
///
|
||||
/// Please note that <c><i>FFX_FSR3_QUALITY_MODE_ULTRA_PERFORMANCE</i></c> is
|
||||
/// an optional mode which may introduce significant quality degradation in the
|
||||
/// final image. As such it is recommended that you evaluate the final results
|
||||
/// of using this scaling mode before deciding if you should include it in your
|
||||
/// application.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
typedef enum FfxFsr3QualityMode {
|
||||
|
||||
FFX_FSR3_QUALITY_MODE_QUALITY = 1, ///< Perform upscaling with a per-dimension upscaling ratio of 1.5x.
|
||||
FFX_FSR3_QUALITY_MODE_BALANCED = 2, ///< Perform upscaling with a per-dimension upscaling ratio of 1.7x.
|
||||
FFX_FSR3_QUALITY_MODE_PERFORMANCE = 3, ///< Perform upscaling with a per-dimension upscaling ratio of 2.0x.
|
||||
FFX_FSR3_QUALITY_MODE_ULTRA_PERFORMANCE = 4 ///< Perform upscaling with a per-dimension upscaling ratio of 3.0x.
|
||||
} FfxFsr3QualityMode;
|
||||
|
||||
/// An enumeration of bit flags used when creating a
|
||||
/// <c><i>FfxFsr3Context</i></c>. See <c><i>FfxFsr3ContextDescription</i></c>.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
typedef enum FfxFsr3InitializationFlagBits {
|
||||
|
||||
FFX_FSR3_ENABLE_HIGH_DYNAMIC_RANGE = (1<<0), ///< A bit indicating if the input color data provided to all inputs is using a high-dynamic range.
|
||||
FFX_FSR3_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS = (1<<1), ///< A bit indicating if the motion vectors are rendered at display resolution.
|
||||
FFX_FSR3_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION = (1<<2), ///< A bit indicating that the motion vectors have the jittering pattern applied to them.
|
||||
FFX_FSR3_ENABLE_DEPTH_INVERTED = (1<<3), ///< A bit indicating that the input depth buffer data provided is inverted [1..0].
|
||||
FFX_FSR3_ENABLE_DEPTH_INFINITE = (1<<4), ///< A bit indicating that the input depth buffer data provided is using an infinite far plane.
|
||||
FFX_FSR3_ENABLE_AUTO_EXPOSURE = (1<<5), ///< A bit indicating if automatic exposure should be applied to input color data.
|
||||
FFX_FSR3_ENABLE_DYNAMIC_RESOLUTION = (1<<6), ///< A bit indicating that the application uses dynamic resolution scaling.
|
||||
FFX_FSR3_ENABLE_TEXTURE1D_USAGE = (1<<7), ///< A bit indicating that the backend should use 1D textures.
|
||||
FFX_FSR3_ENABLE_DEBUG_CHECKING = (1<<8), ///< A bit indicating that the runtime should check some API values and report issues.
|
||||
FFX_FSR3_ENABLE_UPSCALING_ONLY = (1<<9), ///, A bit indicating that the context will only be used for upscaling
|
||||
FFX_FSR3_ENABLE_HDR_UPSCALE_SDR_FINALOUTPUT = (1<<10), ///, A bit indicating if the input color data provided to UPSCALE is using a high-dynamic range, final output SDR.
|
||||
FFX_FSR3_ENABLE_SDR_UPSCALE_HDR_FINALOUTPUT = (1<<11), ///, A bit indicating if the input color data provided to UPSCALE is using SDR, final output is high-dynamic range.
|
||||
FFX_FSR3_ENABLE_ASYNC_WORKLOAD_SUPPORT = (1<<12),
|
||||
} FfxFsr3InitializationFlagBits;
|
||||
|
||||
typedef enum FfxFsr3FrameGenerationFlags
|
||||
{
|
||||
FFX_FSR3_FRAME_GENERATION_FLAG_DRAW_DEBUG_TEAR_LINES = FFX_FRAMEINTERPOLATION_DISPATCH_DRAW_DEBUG_TEAR_LINES, ///< A bit indicating that the debug tear lines will be drawn to the interpolated output.
|
||||
FFX_FSR3_FRAME_GENERATION_FLAG_DRAW_DEBUG_VIEW = FFX_FRAMEINTERPOLATION_DISPATCH_DRAW_DEBUG_VIEW, ///< A bit indicating that the interpolated output resource will contain debug views with relevant information.
|
||||
} FfxFsr3FrameGenerationFlags;
|
||||
|
||||
/// A structure encapsulating the parameters required to initialize FidelityFX
|
||||
/// Super Resolution 3 upscaling.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
typedef struct FfxFsr3ContextDescription {
|
||||
uint32_t flags; ///< A collection of <c><i>FfxFsr3InitializationFlagBits</i></c>.
|
||||
FfxDimensions2D maxRenderSize; ///< The maximum size that rendering will be performed at.
|
||||
FfxDimensions2D upscaleOutputSize; ///< The size of the presentation resolution targeted by the upscaling process.
|
||||
FfxDimensions2D displaySize; ///< The size of the presentation resolution targeted by the frame interpolation process.
|
||||
FfxInterface backendInterfaceSharedResources; ///< A set of pointers to the backend implementation for FidelityFX SDK
|
||||
FfxInterface backendInterfaceUpscaling; ///< A set of pointers to the backend implementation for FidelityFX SDK
|
||||
FfxInterface backendInterfaceFrameInterpolation; ///< A set of pointers to the backend implementation for FidelityFX SDK
|
||||
FfxFsr3UpscalerMessage fpMessage; ///< A pointer to a function that can recieve messages from the runtime.
|
||||
|
||||
FfxSurfaceFormat backBufferFormat; ///< The format of the swapchain surface
|
||||
|
||||
} FfxFsr3ContextDescription;
|
||||
|
||||
/// A structure encapsulating the parameters for dispatching the various passes
|
||||
/// of FidelityFX Super Resolution 3.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
typedef struct FfxFsr3DispatchUpscaleDescription {
|
||||
|
||||
FfxCommandList commandList; ///< The <c><i>FfxCommandList</i></c> to record FSR2 rendering commands into.
|
||||
FfxResource color; ///< A <c><i>FfxResource</i></c> containing the color buffer for the current frame (at render resolution).
|
||||
FfxResource depth; ///< A <c><i>FfxResource</i></c> containing 32bit depth values for the current frame (at render resolution).
|
||||
FfxResource motionVectors; ///< A <c><i>FfxResource</i></c> containing 2-dimensional motion vectors (at render resolution if <c><i>FFX_FSR2_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS</i></c> is not set).
|
||||
FfxResource exposure; ///< A optional <c><i>FfxResource</i></c> containing a 1x1 exposure value.
|
||||
FfxResource reactive; ///< A optional <c><i>FfxResource</i></c> containing alpha value of reactive objects in the scene.
|
||||
FfxResource transparencyAndComposition; ///< A optional <c><i>FfxResource</i></c> containing alpha value of special objects in the scene.
|
||||
FfxResource upscaleOutput; ///< A <c><i>FfxResource</i></c> containing the output color buffer for the current frame (at presentation resolution).
|
||||
FfxFloatCoords2D jitterOffset; ///< The subpixel jitter offset applied to the camera.
|
||||
FfxFloatCoords2D motionVectorScale; ///< The scale factor to apply to motion vectors.
|
||||
FfxDimensions2D renderSize; ///< The resolution that was used for rendering the input resources.
|
||||
bool enableSharpening; ///< Enable an additional sharpening pass.
|
||||
float sharpness; ///< The sharpness value between 0 and 1, where 0 is no additional sharpness and 1 is maximum additional sharpness.
|
||||
float frameTimeDelta; ///< The time elapsed since the last frame (expressed in milliseconds).
|
||||
float preExposure; ///< The pre exposure value (must be > 0.0f)
|
||||
bool reset; ///< A boolean value which when set to true, indicates the camera has moved discontinuously.
|
||||
float cameraNear; ///< The distance to the near plane of the camera.
|
||||
float cameraFar; ///< The distance to the far plane of the camera. This is used only used in case of non infinite depth.
|
||||
float cameraFovAngleVertical; ///< The camera angle field of view in the vertical direction (expressed in radians).
|
||||
float viewSpaceToMetersFactor; ///< The scale factor to convert view space units to meters
|
||||
} FfxFsr3DispatchUpscaleDescription;
|
||||
|
||||
FFX_API FfxErrorCode ffxFsr3DispatchFrameGeneration(const FfxFrameGenerationDispatchDescription* desc);
|
||||
|
||||
/// A structure encapsulating the parameters for automatic generation of a reactive mask
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
typedef struct FfxFsr3GenerateReactiveDescription {
|
||||
|
||||
FfxCommandList commandList; ///< The <c><i>FfxCommandList</i></c> to record FSR3 rendering commands into.
|
||||
FfxResource colorOpaqueOnly; ///< A <c><i>FfxResource</i></c> containing the opaque only color buffer for the current frame (at render resolution).
|
||||
FfxResource colorPreUpscale; ///< A <c><i>FfxResource</i></c> containing the opaque+translucent color buffer for the current frame (at render resolution).
|
||||
FfxResource outReactive; ///< A <c><i>FfxResource</i></c> containing the surface to generate the reactive mask into.
|
||||
FfxDimensions2D renderSize; ///< The resolution that was used for rendering the input resources.
|
||||
float scale; ///< A value to scale the output
|
||||
float cutoffThreshold; ///< A threshold value to generate a binary reactive mask
|
||||
float binaryValue;
|
||||
uint32_t flags; ///< Flags to determine how to generate the reactive mask
|
||||
} FfxFsr3GenerateReactiveDescription;
|
||||
|
||||
/// A structure encapsulating the FidelityFX Super Resolution 3 context.
|
||||
///
|
||||
/// This sets up an object which contains all persistent internal data and
|
||||
/// resources that are required by FSR3.
|
||||
///
|
||||
/// The <c><i>FfxFsr3Context</i></c> object should have a lifetime matching
|
||||
/// your use of FSR3. Before destroying the FSR3 context care should be taken
|
||||
/// to ensure the GPU is not accessing the resources created or used by FSR3.
|
||||
/// It is therefore recommended that the GPU is idle before destroying the
|
||||
/// FSR3 context.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
typedef struct FfxFsr3Context
|
||||
{
|
||||
uint32_t data[ FFX_FSR3UPSCALER_CONTEXT_SIZE
|
||||
+ FFX_OPTICALFLOW_CONTEXT_SIZE
|
||||
+ FFX_FRAMEINTERPOLATION_CONTEXT_SIZE
|
||||
+ (16536)]; ///< An opaque set of <c>uint32_t</c> which contain the data for the context.
|
||||
} FfxFsr3Context;
|
||||
|
||||
/// Create a FidelityFX Super Resolution 3 context from the parameters
|
||||
/// programmed to the <c><i>FfxFsr3CreateParams</i></c> structure.
|
||||
///
|
||||
/// The context structure is the main object used to interact with the FSR3
|
||||
/// API, and is responsible for the management of the internal resources used
|
||||
/// by the FSR3 algorithm. When this API is called, multiple calls will be
|
||||
/// made via the pointers contained in the <c><i>callbacks</i></c> structure.
|
||||
/// These callbacks will attempt to retreive the device capabilities, and
|
||||
/// create the internal resources, and pipelines required by FSR3's
|
||||
/// frame-to-frame function. Depending on the precise configuration used when
|
||||
/// creating the <c><i>FfxFsr3Context</i></c> a different set of resources and
|
||||
/// pipelines might be requested via the callback functions.
|
||||
///
|
||||
/// The flags included in the <c><i>flags</i></c> field of
|
||||
/// <c><i>FfxFsr3Context</i></c> how match the configuration of your
|
||||
/// application as well as the intended use of FSR3. It is important that these
|
||||
/// flags are set correctly (as well as a correct programmed
|
||||
/// <c><i>FfxFsr3DispatchDescription</i></c>) to ensure correct operation. It is
|
||||
/// recommended to consult the overview documentation for further details on
|
||||
/// how FSR3 should be integerated into an application.
|
||||
///
|
||||
/// When the <c><i>FfxFsr3Context</i></c> is created, you should use the
|
||||
/// <c><i>ffxFsr3ContextDispatch</i></c> function each frame where FSR3
|
||||
/// upscaling should be applied. See the documentation of
|
||||
/// <c><i>ffxFsr3ContextDispatch</i></c> for more details.
|
||||
///
|
||||
/// The <c><i>FfxFsr3Context</i></c> should be destroyed when use of it is
|
||||
/// completed, typically when an application is unloaded or FSR3 upscaling is
|
||||
/// disabled by a user. To destroy the FSR3 context you should call
|
||||
/// <c><i>ffxFsr3ContextDestroy</i></c>.
|
||||
///
|
||||
/// @param [out] context A pointer to a <c><i>FfxFsr3Context</i></c> structure to populate.
|
||||
/// @param [in] contextDescription A pointer to a <c><i>FfxFsr3ContextDescription</i></c> structure.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either <c><i>context</i></c> or <c><i>contextDescription</i></c> was <c><i>NULL</i></c>.
|
||||
/// @retval
|
||||
/// FFX_ERROR_INCOMPLETE_INTERFACE The operation failed because the <c><i>FfxFsr3ContextDescription.callbacks</i></c> was not fully specified.
|
||||
/// @retval
|
||||
/// FFX_ERROR_BACKEND_API_ERROR The operation failed because of an error returned from the backend.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
FFX_API FfxErrorCode ffxFsr3ContextCreate(FfxFsr3Context* context, FfxFsr3ContextDescription* contextDescription);
|
||||
|
||||
|
||||
/// Dispatch the various passes that constitute FidelityFX Super Resolution 3 Upscaling.
|
||||
///
|
||||
/// FSR3 is a composite effect, meaning that it is compromised of multiple
|
||||
/// constituent passes (implemented as one or more clears, copies and compute
|
||||
/// dispatches). The <c><i>ffxFsr3ContextDispatchUpscale</i></c> function is the
|
||||
/// function which (via the use of the functions contained in the
|
||||
/// <c><i>callbacks</i></c> field of the <c><i>FfxFsr3Context</i></c>
|
||||
/// structure) utlimately generates the sequence of graphics API calls required
|
||||
/// each frame.
|
||||
///
|
||||
/// As with the creation of the <c><i>FfxFsr3Context</i></c> correctly
|
||||
/// programming the <c><i>dispatchParams</i></c> is key to ensuring
|
||||
/// the correct operation of FSR3. It is particularly important to ensure that
|
||||
/// camera jitter is correctly applied to your application's projection matrix
|
||||
/// (or camera origin for raytraced applications). FSR3 provides the
|
||||
/// <c><i>ffxFsr3GetJitterPhaseCount</i></c> and
|
||||
/// <c><i>ffxFsr3GetJitterOffset</i></c> entry points to help applications
|
||||
/// correctly compute the camera jitter. Whatever jitter pattern is used by the
|
||||
/// application it should be correctly programmed to the
|
||||
/// <c><i>jitterOffset</i></c> field of the <c><i>dispatchParams</i></c>
|
||||
/// structure. For more guidance on camera jitter please consult the
|
||||
/// documentation for <c><i>ffxFsr3GetJitterOffset</i></c> as well as the
|
||||
/// accompanying overview documentation for FSR3.
|
||||
///
|
||||
/// @param [in] context A pointer to a <c><i>FfxFsr3Context</i></c> structure.
|
||||
/// @param [in] dispatchParams A pointer to a <c><i>FfxFsr3DispatchUpscaleDescription</i></c> structure.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either <c><i>context</i></c> or <c><i>dispatchParams</i></c> was <c><i>NULL</i></c>.
|
||||
/// @retval
|
||||
/// FFX_ERROR_OUT_OF_RANGE The operation failed because <c><i>dispatchParams.renderSize</i></c> was larger than the maximum render resolution.
|
||||
/// @retval
|
||||
/// FFX_ERROR_NULL_DEVICE The operation failed because the device inside the context was <c><i>NULL</i></c>.
|
||||
/// @retval
|
||||
/// FFX_ERROR_BACKEND_API_ERROR The operation failed because of an error returned from the backend.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
FFX_API FfxErrorCode ffxFsr3ContextDispatchUpscale(FfxFsr3Context* context, const FfxFsr3DispatchUpscaleDescription* dispatchParams);
|
||||
|
||||
FFX_API FfxErrorCode ffxFsr3SkipPresent(FfxFsr3Context* context);
|
||||
|
||||
/// A helper function generate a Reactive mask from an opaque only texure and one containing translucent objects.
|
||||
///
|
||||
/// @param [in] context A pointer to a <c><i>FfxFsr3Context</i></c> structure.
|
||||
/// @param [in] params A pointer to a <c><i>FfxFsr3GenerateReactiveDescription</i></c> structure
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
FFX_API FfxErrorCode ffxFsr3ContextGenerateReactiveMask(FfxFsr3Context* context, const FfxFsr3GenerateReactiveDescription* params);
|
||||
|
||||
FFX_API FfxErrorCode ffxFsr3ConfigureFrameGeneration(FfxFsr3Context* context, const FfxFrameGenerationConfig* config);
|
||||
|
||||
/// Destroy the FidelityFX Super Resolution context.
|
||||
///
|
||||
/// @param [out] context A pointer to a <c><i>FfxFsr3Context</i></c> structure to destroy.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either <c><i>context</i></c> was <c><i>NULL</i></c>.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
FFX_API FfxErrorCode ffxFsr3ContextDestroy(FfxFsr3Context* context);
|
||||
|
||||
/// Get the upscale ratio from the quality mode.
|
||||
///
|
||||
/// The following table enumerates the mapping of the quality modes to
|
||||
/// per-dimension scaling ratios.
|
||||
///
|
||||
/// Quality preset | Scale factor
|
||||
/// ----------------------------------------------------- | -------------
|
||||
/// <c><i>FFX_FSR3_QUALITY_MODE_NATIVEAA</i></c> | 1.0x
|
||||
/// <c><i>FFX_FSR3_QUALITY_MODE_QUALITY</i></c> | 1.5x
|
||||
/// <c><i>FFX_FSR3_QUALITY_MODE_BALANCED</i></c> | 1.7x
|
||||
/// <c><i>FFX_FSR3_QUALITY_MODE_PERFORMANCE</i></c> | 2.0x
|
||||
/// <c><i>FFX_FSR3_QUALITY_MODE_ULTRA_PERFORMANCE</i></c> | 3.0x
|
||||
///
|
||||
/// Passing an invalid <c><i>qualityMode</i></c> will return 0.0f.
|
||||
///
|
||||
/// @param [in] qualityMode The quality mode preset.
|
||||
///
|
||||
/// @returns
|
||||
/// The upscaling the per-dimension upscaling ratio for
|
||||
/// <c><i>qualityMode</i></c> according to the table above.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
FFX_API float ffxFsr3GetUpscaleRatioFromQualityMode(FfxFsr3QualityMode qualityMode);
|
||||
|
||||
/// A helper function to calculate the rendering resolution from a target
|
||||
/// resolution and desired quality level.
|
||||
///
|
||||
/// This function applies the scaling factor returned by
|
||||
/// <c><i>ffxFsr3GetUpscaleRatioFromQualityMode</i></c> to each dimension.
|
||||
///
|
||||
/// @param [out] renderWidth A pointer to a <c>uint32_t</c> which will hold the calculated render resolution width.
|
||||
/// @param [out] renderHeight A pointer to a <c>uint32_t</c> which will hold the calculated render resolution height.
|
||||
/// @param [in] displayWidth The target display resolution width.
|
||||
/// @param [in] displayHeight The target display resolution height.
|
||||
/// @param [in] qualityMode The desired quality mode for FSR 2 upscaling.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_INVALID_POINTER Either <c><i>renderWidth</i></c> or <c><i>renderHeight</i></c> was <c>NULL</c>.
|
||||
/// @retval
|
||||
/// FFX_ERROR_INVALID_ENUM An invalid quality mode was specified.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
FFX_API FfxErrorCode ffxFsr3GetRenderResolutionFromQualityMode(
|
||||
uint32_t* renderWidth,
|
||||
uint32_t* renderHeight,
|
||||
uint32_t displayWidth,
|
||||
uint32_t displayHeight,
|
||||
FfxFsr3QualityMode qualityMode);
|
||||
|
||||
/// A helper function to calculate the jitter phase count from display
|
||||
/// resolution.
|
||||
///
|
||||
/// For more detailed information about the application of camera jitter to
|
||||
/// your application's rendering please refer to the
|
||||
/// <c><i>ffxFsr3GetJitterOffset</i></c> function.
|
||||
///
|
||||
/// The table below shows the jitter phase count which this function
|
||||
/// would return for each of the quality presets.
|
||||
///
|
||||
/// Quality preset | Scale factor | Phase count
|
||||
/// ----------------------------------------------------- | ------------- | ---------------
|
||||
/// <c><i>FFX_FSR3_QUALITY_MODE_QUALITY</i></c> | 1.5x | 18
|
||||
/// <c><i>FFX_FSR3_QUALITY_MODE_BALANCED</i></c> | 1.7x | 23
|
||||
/// <c><i>FFX_FSR3_QUALITY_MODE_PERFORMANCE</i></c> | 2.0x | 32
|
||||
/// <c><i>FFX_FSR3_QUALITY_MODE_ULTRA_PERFORMANCE</i></c> | 3.0x | 72
|
||||
/// Custom | [1..n]x | ceil(8*n^2)
|
||||
///
|
||||
/// @param [in] renderWidth The render resolution width.
|
||||
/// @param [in] displayWidth The display resolution width.
|
||||
///
|
||||
/// @returns
|
||||
/// The jitter phase count for the scaling factor between <c><i>renderWidth</i></c> and <c><i>displayWidth</i></c>.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
FFX_API int32_t ffxFsr3GetJitterPhaseCount(int32_t renderWidth, int32_t displayWidth);
|
||||
|
||||
/// A helper function to calculate the subpixel jitter offset.
|
||||
///
|
||||
/// FSR3 relies on the application to apply sub-pixel jittering while rendering.
|
||||
/// This is typically included in the projection matrix of the camera. To make
|
||||
/// the application of camera jitter simple, the FSR3 API provides a small set
|
||||
/// of utility function which computes the sub-pixel jitter offset for a
|
||||
/// particular frame within a sequence of separate jitter offsets. To begin, the
|
||||
/// index within the jitter phase must be computed. To calculate the
|
||||
/// sequence's length, you can call the <c><i>ffxFsr3GetJitterPhaseCount</i></c>
|
||||
/// function. The index should be a value which is incremented each frame modulo
|
||||
/// the length of the sequence computed by <c><i>ffxFsr3GetJitterPhaseCount</i></c>.
|
||||
/// The index within the jitter phase is passed to
|
||||
/// <c><i>ffxFsr3GetJitterOffset</i></c> via the <c><i>index</i></c> parameter.
|
||||
///
|
||||
/// This function uses a Halton(2,3) sequence to compute the jitter offset.
|
||||
/// The ultimate index used for the sequence is <c><i>index</i></c> %
|
||||
/// <c><i>phaseCount</i></c>.
|
||||
///
|
||||
/// It is important to understand that the values returned from the
|
||||
/// <c><i>ffxFsr3GetJitterOffset</i></c> function are in unit pixel space, and
|
||||
/// in order to composite this correctly into a projection matrix we must
|
||||
/// convert them into projection offsets. This is done as per the pseudo code
|
||||
/// listing which is shown below.
|
||||
///
|
||||
/// const int32_t jitterPhaseCount = ffxFsr3GetJitterPhaseCount(renderWidth, displayWidth);
|
||||
///
|
||||
/// float jitterX = 0;
|
||||
/// float jitterY = 0;
|
||||
/// ffxFsr3GetJitterOffset(&jitterX, &jitterY, index, jitterPhaseCount);
|
||||
///
|
||||
/// const float jitterX = 2.0f * jitterX / (float)renderWidth;
|
||||
/// const float jitterY = -2.0f * jitterY / (float)renderHeight;
|
||||
/// const Matrix4 jitterTranslationMatrix = translateMatrix(Matrix3::identity, Vector3(jitterX, jitterY, 0));
|
||||
/// const Matrix4 jitteredProjectionMatrix = jitterTranslationMatrix * projectionMatrix;
|
||||
///
|
||||
/// Jitter should be applied to all rendering. This includes opaque, alpha
|
||||
/// transparent, and raytraced objects. For rasterized objects, the sub-pixel
|
||||
/// jittering values calculated by the <c><i>iffxFsr3GetJitterOffset</i></c>
|
||||
/// function can be applied to the camera projection matrix which is ultimately
|
||||
/// used to perform transformations during vertex shading. For raytraced
|
||||
/// rendering, the sub-pixel jitter should be applied to the ray's origin,
|
||||
/// often the camera's position.
|
||||
///
|
||||
/// Whether you elect to use the <c><i>ffxFsr3GetJitterOffset</i></c> function
|
||||
/// or your own sequence generator, you must program the
|
||||
/// <c><i>jitterOffset</i></c> field of the
|
||||
/// <c><i>FfxFsr3DispatchParameters</i></c> structure in order to inform FSR3
|
||||
/// of the jitter offset that has been applied in order to render each frame.
|
||||
///
|
||||
/// If not using the recommended <c><i>ffxFsr3GetJitterOffset</i></c> function,
|
||||
/// care should be taken that your jitter sequence never generates a null vector;
|
||||
/// that is value of 0 in both the X and Y dimensions.
|
||||
///
|
||||
/// @param [out] outX A pointer to a <c>float</c> which will contain the subpixel jitter offset for the x dimension.
|
||||
/// @param [out] outY A pointer to a <c>float</c> which will contain the subpixel jitter offset for the y dimension.
|
||||
/// @param [in] index The index within the jitter sequence.
|
||||
/// @param [in] phaseCount The length of jitter phase. See <c><i>ffxFsr3GetJitterPhaseCount</i></c>.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_INVALID_POINTER Either <c><i>outX</i></c> or <c><i>outY</i></c> was <c>NULL</c>.
|
||||
/// @retval
|
||||
/// FFX_ERROR_INVALID_ARGUMENT Argument <c><i>phaseCount</i></c> must be greater than 0.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
FFX_API FfxErrorCode ffxFsr3GetJitterOffset(float* outX, float* outY, int32_t index, int32_t phaseCount);
|
||||
|
||||
/// A helper function to check if a resource is
|
||||
/// <c><i>FFX_FSR3_RESOURCE_IDENTIFIER_NULL</i></c>.
|
||||
///
|
||||
/// @param [in] resource A <c><i>FfxResource</i></c>.
|
||||
///
|
||||
/// @returns
|
||||
/// true The <c><i>resource</i></c> was not <c><i>FFX_FSR3_RESOURCE_IDENTIFIER_NULL</i></c>.
|
||||
/// @returns
|
||||
/// false The <c><i>resource</i></c> was <c><i>FFX_FSR3_RESOURCE_IDENTIFIER_NULL</i></c>.
|
||||
///
|
||||
/// @ingroup FSR3
|
||||
FFX_API bool ffxFsr3ResourceIsNull(FfxResource resource);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif // #if defined(__cplusplus)
|
||||
+527
@@ -0,0 +1,527 @@
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
// Include the interface for the backend of the FSR3 API.
|
||||
#include <FidelityFX/host/ffx_interface.h>
|
||||
#include <FidelityFX/gpu/fsr3upscaler/ffx_fsr3upscaler_resources.h>
|
||||
|
||||
/// @defgroup ffxFsr3Upscaler FidelityFX FSR3
|
||||
/// FidelityFX Super Resolution 3 runtime library
|
||||
///
|
||||
/// @ingroup SDKComponents
|
||||
|
||||
/// FidelityFX Super Resolution 3 major version.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
#define FFX_FSR3UPSCALER_VERSION_MAJOR (3)
|
||||
|
||||
/// FidelityFX Super Resolution 3 minor version.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
#define FFX_FSR3UPSCALER_VERSION_MINOR (0)
|
||||
|
||||
/// FidelityFX Super Resolution 3 patch version.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
#define FFX_FSR3UPSCALER_VERSION_PATCH (3)
|
||||
|
||||
/// FidelityFX Super Resolution 3 context count
|
||||
///
|
||||
/// Defines the number of internal effect contexts required by FSR3
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
#define FFX_FSR3UPSCALER_CONTEXT_COUNT 1
|
||||
|
||||
/// The size of the context specified in 32bit values.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
#define FFX_FSR3UPSCALER_CONTEXT_SIZE (FFX_SDK_DEFAULT_CONTEXT_SIZE)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif // #if defined(__cplusplus)
|
||||
|
||||
/// An enumeration of all the passes which constitute the FSR3 algorithm.
|
||||
///
|
||||
/// FSR3 is implemented as a composite of several compute passes each
|
||||
/// computing a key part of the final result. Each call to the
|
||||
/// <c><i>FfxFsr3UpscalerScheduleGpuJobFunc</i></c> callback function will
|
||||
/// correspond to a single pass included in <c><i>FfxFsr3UpscalerPass</i></c>. For a
|
||||
/// more comprehensive description of each pass, please refer to the FSR3
|
||||
/// reference documentation.
|
||||
///
|
||||
/// Please note in some cases e.g.: <c><i>FFX_FSR3UPSCALER_PASS_ACCUMULATE</i></c>
|
||||
/// and <c><i>FFX_FSR3UPSCALER_PASS_ACCUMULATE_SHARPEN</i></c> either one pass or the
|
||||
/// other will be used (they are mutually exclusive). The choice of which will
|
||||
/// depend on the way the <c><i>FfxFsr3UpscalerContext</i></c> is created and the
|
||||
/// precise contents of <c><i>FfxFsr3UpscalerDispatchParamters</i></c> each time a call
|
||||
/// is made to <c><i>ffxFsr3UpscalerContextDispatch</i></c>.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
typedef enum FfxFsr3UpscalerPass
|
||||
{
|
||||
|
||||
FFX_FSR3UPSCALER_PASS_DEPTH_CLIP, ///< A pass which performs depth clipping.
|
||||
FFX_FSR3UPSCALER_PASS_RECONSTRUCT_PREVIOUS_DEPTH, ///< A pass which performs reconstruction of previous frame's depth.
|
||||
FFX_FSR3UPSCALER_PASS_LOCK, ///< A pass which calculates pixel locks.
|
||||
FFX_FSR3UPSCALER_PASS_ACCUMULATE, ///< A pass which performs upscaling.
|
||||
FFX_FSR3UPSCALER_PASS_ACCUMULATE_SHARPEN, ///< A pass which performs upscaling when sharpening is used.
|
||||
FFX_FSR3UPSCALER_PASS_RCAS, ///< A pass which performs sharpening.
|
||||
FFX_FSR3UPSCALER_PASS_COMPUTE_LUMINANCE_PYRAMID, ///< A pass which generates the luminance mipmap chain for the current frame.
|
||||
FFX_FSR3UPSCALER_PASS_GENERATE_REACTIVE, ///< An optional pass to generate a reactive mask.
|
||||
FFX_FSR3UPSCALER_PASS_TCR_AUTOGENERATE, ///< DEPRECATED - NO LONGER SUPPORTED
|
||||
|
||||
FFX_FSR3UPSCALER_PASS_COUNT ///< The number of passes performed by FSR3.
|
||||
} FfxFsr3UpscalerPass;
|
||||
|
||||
/// An enumeration of all the quality modes supported by FidelityFX Super
|
||||
/// Resolution 3 upscaling.
|
||||
///
|
||||
/// In order to provide a consistent user experience across multiple
|
||||
/// applications which implement FSR3. It is strongly recommended that the
|
||||
/// following preset scaling factors are made available through your
|
||||
/// application's user interface.
|
||||
///
|
||||
/// If your application does not expose the notion of preset scaling factors
|
||||
/// for upscaling algorithms (perhaps instead implementing a fixed ratio which
|
||||
/// is immutable) or implementing a more dynamic scaling scheme (such as
|
||||
/// dynamic resolution scaling), then there is no need to use these presets.
|
||||
///
|
||||
/// Please note that <c><i>FFX_FSR3UPSCALER_QUALITY_MODE_ULTRA_PERFORMANCE</i></c> is
|
||||
/// an optional mode which may introduce significant quality degradation in the
|
||||
/// final image. As such it is recommended that you evaluate the final results
|
||||
/// of using this scaling mode before deciding if you should include it in your
|
||||
/// application.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
typedef enum FfxFsr3UpscalerQualityMode {
|
||||
FFX_FSR3UPSCALER_QUALITY_MODE_NATIVEAA = 0, ///< Perform upscaling with a per-dimension upscaling ratio of 1.0x.
|
||||
FFX_FSR3UPSCALER_QUALITY_MODE_QUALITY = 1, ///< Perform upscaling with a per-dimension upscaling ratio of 1.5x.
|
||||
FFX_FSR3UPSCALER_QUALITY_MODE_BALANCED = 2, ///< Perform upscaling with a per-dimension upscaling ratio of 1.7x.
|
||||
FFX_FSR3UPSCALER_QUALITY_MODE_PERFORMANCE = 3, ///< Perform upscaling with a per-dimension upscaling ratio of 2.0x.
|
||||
FFX_FSR3UPSCALER_QUALITY_MODE_ULTRA_PERFORMANCE = 4 ///< Perform upscaling with a per-dimension upscaling ratio of 3.0x.
|
||||
} FfxFsr3UpscalerQualityMode;
|
||||
|
||||
/// An enumeration of bit flags used when creating a
|
||||
/// <c><i>FfxFsr3UpscalerContext</i></c>. See <c><i>FfxFsr3UpscalerContextDescription</i></c>.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
typedef enum FfxFsr3UpscalerInitializationFlagBits {
|
||||
|
||||
FFX_FSR3UPSCALER_ENABLE_HIGH_DYNAMIC_RANGE = (1<<0), ///< A bit indicating if the input color data provided is using a high-dynamic range.
|
||||
FFX_FSR3UPSCALER_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS = (1<<1), ///< A bit indicating if the motion vectors are rendered at display resolution.
|
||||
FFX_FSR3UPSCALER_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION = (1<<2), ///< A bit indicating that the motion vectors have the jittering pattern applied to them.
|
||||
FFX_FSR3UPSCALER_ENABLE_DEPTH_INVERTED = (1<<3), ///< A bit indicating that the input depth buffer data provided is inverted [1..0].
|
||||
FFX_FSR3UPSCALER_ENABLE_DEPTH_INFINITE = (1<<4), ///< A bit indicating that the input depth buffer data provided is using an infinite far plane.
|
||||
FFX_FSR3UPSCALER_ENABLE_AUTO_EXPOSURE = (1<<5), ///< A bit indicating if automatic exposure should be applied to input color data.
|
||||
FFX_FSR3UPSCALER_ENABLE_DYNAMIC_RESOLUTION = (1<<6), ///< A bit indicating that the application uses dynamic resolution scaling.
|
||||
FFX_FSR3UPSCALER_ENABLE_TEXTURE1D_USAGE = (1<<7), ///< A bit indicating that the backend should use 1D textures.
|
||||
FFX_FSR3UPSCALER_ENABLE_DEBUG_CHECKING = (1<<8), ///< A bit indicating that the runtime should check some API values and report issues.
|
||||
} FfxFsr3UpscalerInitializationFlagBits;
|
||||
|
||||
/// Pass a string message
|
||||
///
|
||||
/// Used for debug messages.
|
||||
///
|
||||
/// @param [in] type The type of message.
|
||||
/// @param [in] message A string message to pass.
|
||||
///
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
typedef void(*FfxFsr3UpscalerMessage)(
|
||||
FfxMsgType type,
|
||||
const wchar_t* message);
|
||||
|
||||
/// A structure encapsulating the parameters required to initialize FidelityFX
|
||||
/// Super Resolution 3 upscaling.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
typedef struct FfxFsr3UpscalerContextDescription {
|
||||
|
||||
uint32_t flags; ///< A collection of <c><i>FfxFsr3UpscalerInitializationFlagBits</i></c>.
|
||||
FfxDimensions2D maxRenderSize; ///< The maximum size that rendering will be performed at.
|
||||
FfxDimensions2D displaySize; ///< The size of the presentation resolution targeted by the upscaling process.
|
||||
FfxInterface backendInterface; ///< A set of pointers to the backend implementation for FidelityFX SDK
|
||||
FfxFsr3UpscalerMessage fpMessage; ///< A pointer to a function that can receive messages from the runtime.
|
||||
} FfxFsr3UpscalerContextDescription;
|
||||
|
||||
/// A structure encapsulating the parameters for dispatching the various passes
|
||||
/// of FidelityFX Super Resolution 3.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
typedef struct FfxFsr3UpscalerDispatchDescription {
|
||||
|
||||
FfxCommandList commandList; ///< The <c><i>FfxCommandList</i></c> to record FSR3 rendering commands into.
|
||||
FfxResource color; ///< A <c><i>FfxResource</i></c> containing the color buffer for the current frame (at render resolution).
|
||||
FfxResource depth; ///< A <c><i>FfxResource</i></c> containing 32bit depth values for the current frame (at render resolution).
|
||||
FfxResource motionVectors; ///< A <c><i>FfxResource</i></c> containing 2-dimensional motion vectors (at render resolution if <c><i>FFX_FSR3UPSCALER_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS</i></c> is not set).
|
||||
FfxResource exposure; ///< A optional <c><i>FfxResource</i></c> containing a 1x1 exposure value.
|
||||
FfxResource reactive; ///< A optional <c><i>FfxResource</i></c> containing alpha value of reactive objects in the scene.
|
||||
FfxResource transparencyAndComposition; ///< A optional <c><i>FfxResource</i></c> containing alpha value of special objects in the scene.
|
||||
FfxResource dilatedDepth; ///< A <c><i>FfxResource</i></c> allocated as described in <c><i>FfxFsr3UpscalerSharedResourceDescriptions</i></c> that is used to emit dilated depth and share with following effects.
|
||||
FfxResource dilatedMotionVectors; ///< A <c><i>FfxResource</i></c> allocated as described in <c><i>FfxFsr3UpscalerSharedResourceDescriptions</i></c> that is used to emit dilated motion vectors and share with following effects.
|
||||
FfxResource reconstructedPrevNearestDepth; ///< A <c><i>FfxResource</i></c> allocated as described in <c><i>FfxFsr3UpscalerSharedResourceDescriptions</i></c> that is used to emit reconstructed previous nearest depth and share with following effects.
|
||||
FfxResource output; ///< A <c><i>FfxResource</i></c> containing the output color buffer for the current frame (at presentation resolution).
|
||||
FfxFloatCoords2D jitterOffset; ///< The subpixel jitter offset applied to the camera.
|
||||
FfxFloatCoords2D motionVectorScale; ///< The scale factor to apply to motion vectors.
|
||||
FfxDimensions2D renderSize; ///< The resolution that was used for rendering the input resources.
|
||||
bool enableSharpening; ///< Enable an additional sharpening pass.
|
||||
float sharpness; ///< The sharpness value between 0 and 1, where 0 is no additional sharpness and 1 is maximum additional sharpness.
|
||||
float frameTimeDelta; ///< The time elapsed since the last frame (expressed in milliseconds).
|
||||
float preExposure; ///< The pre exposure value (must be > 0.0f)
|
||||
bool reset; ///< A boolean value which when set to true, indicates the camera has moved discontinuously.
|
||||
float cameraNear; ///< The distance to the near plane of the camera.
|
||||
float cameraFar; ///< The distance to the far plane of the camera.
|
||||
float cameraFovAngleVertical; ///< The camera angle field of view in the vertical direction (expressed in radians).
|
||||
float viewSpaceToMetersFactor; ///< The scale factor to convert view space units to meters
|
||||
} FfxFsr3UpscalerDispatchDescription;
|
||||
|
||||
/// A structure encapsulating the parameters for automatic generation of a reactive mask
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
typedef struct FfxFsr3UpscalerGenerateReactiveDescription {
|
||||
|
||||
FfxCommandList commandList; ///< The <c><i>FfxCommandList</i></c> to record FSR3 rendering commands into.
|
||||
FfxResource colorOpaqueOnly; ///< A <c><i>FfxResource</i></c> containing the opaque only color buffer for the current frame (at render resolution).
|
||||
FfxResource colorPreUpscale; ///< A <c><i>FfxResource</i></c> containing the opaque+translucent color buffer for the current frame (at render resolution).
|
||||
FfxResource outReactive; ///< A <c><i>FfxResource</i></c> containing the surface to generate the reactive mask into.
|
||||
FfxDimensions2D renderSize; ///< The resolution that was used for rendering the input resources.
|
||||
float scale; ///< A value to scale the output
|
||||
float cutoffThreshold; ///< A threshold value to generate a binary reactive mask
|
||||
float binaryValue; ///< A value to set for the binary reactive mask
|
||||
uint32_t flags; ///< Flags to determine how to generate the reactive mask
|
||||
} FfxFsr3UpscalerGenerateReactiveDescription;
|
||||
|
||||
/// A structure encapsulating the resource descriptions for shared resources for this effect.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
typedef struct FfxFsr3UpscalerSharedResourceDescriptions {
|
||||
|
||||
FfxCreateResourceDescription reconstructedPrevNearestDepth; ///< The <c><i>FfxCreateResourceDescription</i></c> for allocating the <c><i>reconstructedPrevNearestDepth</i></c> shared resource.
|
||||
FfxCreateResourceDescription dilatedDepth; ///< The <c><i>FfxCreateResourceDescription</i></c> for allocating the <c><i>dilatedDepth</i></c> shared resource.
|
||||
FfxCreateResourceDescription dilatedMotionVectors; ///< The <c><i>FfxCreateResourceDescription</i></c> for allocating the <c><i>dilatedMotionVectors</i></c> shared resource.
|
||||
} FfxFsr3UpscalerSharedResourceDescriptions;
|
||||
|
||||
/// A structure encapsulating the FidelityFX Super Resolution 3 context.
|
||||
///
|
||||
/// This sets up an object which contains all persistent internal data and
|
||||
/// resources that are required by FSR3.
|
||||
///
|
||||
/// The <c><i>FfxFsr3UpscalerContext</i></c> object should have a lifetime matching
|
||||
/// your use of FSR3. Before destroying the FSR3 context care should be taken
|
||||
/// to ensure the GPU is not accessing the resources created or used by FSR3.
|
||||
/// It is therefore recommended that the GPU is idle before destroying the
|
||||
/// FSR3 context.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
typedef struct FfxFsr3UpscalerContext
|
||||
{
|
||||
uint32_t data[FFX_FSR3UPSCALER_CONTEXT_SIZE]; ///< An opaque set of <c>uint32_t</c> which contain the data for the context.
|
||||
} FfxFsr3UpscalerContext;
|
||||
|
||||
|
||||
/// Create a FidelityFX Super Resolution 3 context from the parameters
|
||||
/// programmed to the <c><i>FfxFsr3UpscalerCreateParams</i></c> structure.
|
||||
///
|
||||
/// The context structure is the main object used to interact with the FSR3
|
||||
/// API, and is responsible for the management of the internal resources used
|
||||
/// by the FSR3 algorithm. When this API is called, multiple calls will be
|
||||
/// made via the pointers contained in the <c><i>callbacks</i></c> structure.
|
||||
/// These callbacks will attempt to retreive the device capabilities, and
|
||||
/// create the internal resources, and pipelines required by FSR3's
|
||||
/// frame-to-frame function. Depending on the precise configuration used when
|
||||
/// creating the <c><i>FfxFsr3UpscalerContext</i></c> a different set of resources and
|
||||
/// pipelines might be requested via the callback functions.
|
||||
///
|
||||
/// The flags included in the <c><i>flags</i></c> field of
|
||||
/// <c><i>FfxFsr3UpscalerContext</i></c> how match the configuration of your
|
||||
/// application as well as the intended use of FSR3. It is important that these
|
||||
/// flags are set correctly (as well as a correct programmed
|
||||
/// <c><i>FfxFsr3UpscalerDispatchDescription</i></c>) to ensure correct operation. It is
|
||||
/// recommended to consult the overview documentation for further details on
|
||||
/// how FSR3 should be integerated into an application.
|
||||
///
|
||||
/// When the <c><i>FfxFsr3UpscalerContext</i></c> is created, you should use the
|
||||
/// <c><i>ffxFsr3UpscalerContextDispatch</i></c> function each frame where FSR3
|
||||
/// upscaling should be applied. See the documentation of
|
||||
/// <c><i>ffxFsr3UpscalerContextDispatch</i></c> for more details.
|
||||
///
|
||||
/// The <c><i>FfxFsr3UpscalerContext</i></c> should be destroyed when use of it is
|
||||
/// completed, typically when an application is unloaded or FSR3 upscaling is
|
||||
/// disabled by a user. To destroy the FSR3 context you should call
|
||||
/// <c><i>ffxFsr3UpscalerContextDestroy</i></c>.
|
||||
///
|
||||
/// @param [out] pContext A pointer to a <c><i>FfxFsr3UpscalerContext</i></c> structure to populate.
|
||||
/// @param [in] pContextDescription A pointer to a <c><i>FfxFsr3UpscalerContextDescription</i></c> structure.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either <c><i>context</i></c> or <c><i>contextDescription</i></c> was <c><i>NULL</i></c>.
|
||||
/// @retval
|
||||
/// FFX_ERROR_INCOMPLETE_INTERFACE The operation failed because the <c><i>FfxFsr3UpscalerContextDescription.callbacks</i></c> was not fully specified.
|
||||
/// @retval
|
||||
/// FFX_ERROR_BACKEND_API_ERROR The operation failed because of an error returned from the backend.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
FFX_API FfxErrorCode ffxFsr3UpscalerContextCreate(FfxFsr3UpscalerContext* pContext, const FfxFsr3UpscalerContextDescription* pContextDescription);
|
||||
|
||||
/// Provides the descriptions for shared resources that must be allocated for this effect.
|
||||
///
|
||||
/// @param [in] context A pointer to a <c><i>FfxFsr3UpscalerContext</i></c> structure.
|
||||
/// @param [out] SharedResources A pointer to a <c><i>FfxFsr3UpscalerSharedResourceDescriptions</i></c> to populate.
|
||||
///
|
||||
/// @returns
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @returns
|
||||
/// Anything else The operation failed.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
FFX_API FfxErrorCode ffxFsr3UpscalerGetSharedResourceDescriptions(FfxFsr3UpscalerContext* context, FfxFsr3UpscalerSharedResourceDescriptions* SharedResources);
|
||||
|
||||
/// Dispatch the various passes that constitute FidelityFX Super Resolution 3.
|
||||
///
|
||||
/// FSR3 is a composite effect, meaning that it is compromised of multiple
|
||||
/// constituent passes (implemented as one or more clears, copies and compute
|
||||
/// dispatches). The <c><i>ffxFsr3UpscalerContextDispatch</i></c> function is the
|
||||
/// function which (via the use of the functions contained in the
|
||||
/// <c><i>callbacks</i></c> field of the <c><i>FfxFsr3UpscalerContext</i></c>
|
||||
/// structure) utlimately generates the sequence of graphics API calls required
|
||||
/// each frame.
|
||||
///
|
||||
/// As with the creation of the <c><i>FfxFsr3UpscalerContext</i></c> correctly
|
||||
/// programming the <c><i>FfxFsr3UpscalerDispatchDescription</i></c> is key to ensuring
|
||||
/// the correct operation of FSR3. It is particularly important to ensure that
|
||||
/// camera jitter is correctly applied to your application's projection matrix
|
||||
/// (or camera origin for raytraced applications). FSR3 provides the
|
||||
/// <c><i>ffxFsr3UpscalerGetJitterPhaseCount</i></c> and
|
||||
/// <c><i>ffxFsr3UpscalerGetJitterOffset</i></c> entry points to help applications
|
||||
/// correctly compute the camera jitter. Whatever jitter pattern is used by the
|
||||
/// application it should be correctly programmed to the
|
||||
/// <c><i>jitterOffset</i></c> field of the <c><i>dispatchDescription</i></c>
|
||||
/// structure. For more guidance on camera jitter please consult the
|
||||
/// documentation for <c><i>ffxFsr3UpscalerGetJitterOffset</i></c> as well as the
|
||||
/// accompanying overview documentation for FSR3.
|
||||
///
|
||||
/// @param [in] pContext A pointer to a <c><i>FfxFsr3UpscalerContext</i></c> structure.
|
||||
/// @param [in] pDispatchDescription A pointer to a <c><i>FfxFsr3UpscalerDispatchDescription</i></c> structure.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either <c><i>context</i></c> or <c><i>dispatchDescription</i></c> was <c><i>NULL</i></c>.
|
||||
/// @retval
|
||||
/// FFX_ERROR_OUT_OF_RANGE The operation failed because <c><i>dispatchDescription.renderSize</i></c> was larger than the maximum render resolution.
|
||||
/// @retval
|
||||
/// FFX_ERROR_NULL_DEVICE The operation failed because the device inside the context was <c><i>NULL</i></c>.
|
||||
/// @retval
|
||||
/// FFX_ERROR_BACKEND_API_ERROR The operation failed because of an error returned from the backend.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
FFX_API FfxErrorCode ffxFsr3UpscalerContextDispatch(FfxFsr3UpscalerContext* pContext, const FfxFsr3UpscalerDispatchDescription* pDispatchDescription);
|
||||
|
||||
/// A helper function generate a Reactive mask from an opaque only texure and one containing translucent objects.
|
||||
///
|
||||
/// @param [in] pContext A pointer to a <c><i>FfxFsr3UpscalerContext</i></c> structure.
|
||||
/// @param [in] pParams A pointer to a <c><i>FfxFsr3UpscalerGenerateReactiveDescription</i></c> structure
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
FFX_API FfxErrorCode ffxFsr3UpscalerContextGenerateReactiveMask(FfxFsr3UpscalerContext* pContext, const FfxFsr3UpscalerGenerateReactiveDescription* pParams);
|
||||
|
||||
/// Destroy the FidelityFX Super Resolution context.
|
||||
///
|
||||
/// @param [out] pContext A pointer to a <c><i>FfxFsr3UpscalerContext</i></c> structure to destroy.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either <c><i>context</i></c> was <c><i>NULL</i></c>.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
FFX_API FfxErrorCode ffxFsr3UpscalerContextDestroy(FfxFsr3UpscalerContext* pContext);
|
||||
|
||||
/// Get the upscale ratio from the quality mode.
|
||||
///
|
||||
/// The following table enumerates the mapping of the quality modes to
|
||||
/// per-dimension scaling ratios.
|
||||
///
|
||||
/// Quality preset | Scale factor
|
||||
/// ----------------------------------------------------- | -------------
|
||||
/// <c><i>FFX_FSR3UPSCALER_QUALITY_MODE_QUALITY</i></c> | 1.5x
|
||||
/// <c><i>FFX_FSR3UPSCALER_QUALITY_MODE_BALANCED</i></c> | 1.7x
|
||||
/// <c><i>FFX_FSR3UPSCALER_QUALITY_MODE_PERFORMANCE</i></c> | 2.0x
|
||||
/// <c><i>FFX_FSR3UPSCALER_QUALITY_MODE_ULTRA_PERFORMANCE</i></c> | 3.0x
|
||||
///
|
||||
/// Passing an invalid <c><i>qualityMode</i></c> will return 0.0f.
|
||||
///
|
||||
/// @param [in] qualityMode The quality mode preset.
|
||||
///
|
||||
/// @returns
|
||||
/// The upscaling the per-dimension upscaling ratio for
|
||||
/// <c><i>qualityMode</i></c> according to the table above.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
FFX_API float ffxFsr3UpscalerGetUpscaleRatioFromQualityMode(FfxFsr3UpscalerQualityMode qualityMode);
|
||||
|
||||
/// A helper function to calculate the rendering resolution from a target
|
||||
/// resolution and desired quality level.
|
||||
///
|
||||
/// This function applies the scaling factor returned by
|
||||
/// <c><i>ffxFsr3UpscalerGetUpscaleRatioFromQualityMode</i></c> to each dimension.
|
||||
///
|
||||
/// @param [out] pRenderWidth A pointer to a <c>uint32_t</c> which will hold the calculated render resolution width.
|
||||
/// @param [out] pRenderHeight A pointer to a <c>uint32_t</c> which will hold the calculated render resolution height.
|
||||
/// @param [in] displayWidth The target display resolution width.
|
||||
/// @param [in] displayHeight The target display resolution height.
|
||||
/// @param [in] qualityMode The desired quality mode for FSR 2 upscaling.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_INVALID_POINTER Either <c><i>renderWidth</i></c> or <c><i>renderHeight</i></c> was <c>NULL</c>.
|
||||
/// @retval
|
||||
/// FFX_ERROR_INVALID_ENUM An invalid quality mode was specified.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
FFX_API FfxErrorCode ffxFsr3UpscalerGetRenderResolutionFromQualityMode(
|
||||
uint32_t* pRenderWidth,
|
||||
uint32_t* pRenderHeight,
|
||||
uint32_t displayWidth,
|
||||
uint32_t displayHeight,
|
||||
FfxFsr3UpscalerQualityMode qualityMode);
|
||||
|
||||
/// A helper function to calculate the jitter phase count from display
|
||||
/// resolution.
|
||||
///
|
||||
/// For more detailed information about the application of camera jitter to
|
||||
/// your application's rendering please refer to the
|
||||
/// <c><i>ffxFsr3UpscalerGetJitterOffset</i></c> function.
|
||||
///
|
||||
/// The table below shows the jitter phase count which this function
|
||||
/// would return for each of the quality presets.
|
||||
///
|
||||
/// Quality preset | Scale factor | Phase count
|
||||
/// ----------------------------------------------------- | ------------- | ---------------
|
||||
/// <c><i>FFX_FSR3UPSCALER_QUALITY_MODE_QUALITY</i></c> | 1.5x | 18
|
||||
/// <c><i>FFX_FSR3UPSCALER_QUALITY_MODE_BALANCED</i></c> | 1.7x | 23
|
||||
/// <c><i>FFX_FSR3UPSCALER_QUALITY_MODE_PERFORMANCE</i></c> | 2.0x | 32
|
||||
/// <c><i>FFX_FSR3UPSCALER_QUALITY_MODE_ULTRA_PERFORMANCE</i></c> | 3.0x | 72
|
||||
/// Custom | [1..n]x | ceil(8*n^2)
|
||||
///
|
||||
/// @param [in] renderWidth The render resolution width.
|
||||
/// @param [in] displayWidth The display resolution width.
|
||||
///
|
||||
/// @returns
|
||||
/// The jitter phase count for the scaling factor between <c><i>renderWidth</i></c> and <c><i>displayWidth</i></c>.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
FFX_API int32_t ffxFsr3UpscalerGetJitterPhaseCount(int32_t renderWidth, int32_t displayWidth);
|
||||
|
||||
/// A helper function to calculate the subpixel jitter offset.
|
||||
///
|
||||
/// FSR3 relies on the application to apply sub-pixel jittering while rendering.
|
||||
/// This is typically included in the projection matrix of the camera. To make
|
||||
/// the application of camera jitter simple, the FSR3 API provides a small set
|
||||
/// of utility function which computes the sub-pixel jitter offset for a
|
||||
/// particular frame within a sequence of separate jitter offsets. To begin, the
|
||||
/// index within the jitter phase must be computed. To calculate the
|
||||
/// sequence's length, you can call the <c><i>ffxFsr3UpscalerGetJitterPhaseCount</i></c>
|
||||
/// function. The index should be a value which is incremented each frame modulo
|
||||
/// the length of the sequence computed by <c><i>ffxFsr3UpscalerGetJitterPhaseCount</i></c>.
|
||||
/// The index within the jitter phase is passed to
|
||||
/// <c><i>ffxFsr3UpscalerGetJitterOffset</i></c> via the <c><i>index</i></c> parameter.
|
||||
///
|
||||
/// This function uses a Halton(2,3) sequence to compute the jitter offset.
|
||||
/// The ultimate index used for the sequence is <c><i>index</i></c> %
|
||||
/// <c><i>phaseCount</i></c>.
|
||||
///
|
||||
/// It is important to understand that the values returned from the
|
||||
/// <c><i>ffxFsr3UpscalerGetJitterOffset</i></c> function are in unit pixel space, and
|
||||
/// in order to composite this correctly into a projection matrix we must
|
||||
/// convert them into projection offsets. This is done as per the pseudo code
|
||||
/// listing which is shown below.
|
||||
///
|
||||
/// const int32_t jitterPhaseCount = ffxFsr3UpscalerGetJitterPhaseCount(renderWidth, displayWidth);
|
||||
///
|
||||
/// float jitterX = 0;
|
||||
/// float jitterY = 0;
|
||||
/// ffxFsr3UpscalerGetJitterOffset(&jitterX, &jitterY, index, jitterPhaseCount);
|
||||
///
|
||||
/// const float jitterX = 2.0f * jitterX / (float)renderWidth;
|
||||
/// const float jitterY = -2.0f * jitterY / (float)renderHeight;
|
||||
/// const Matrix4 jitterTranslationMatrix = translateMatrix(Matrix3::identity, Vector3(jitterX, jitterY, 0));
|
||||
/// const Matrix4 jitteredProjectionMatrix = jitterTranslationMatrix * projectionMatrix;
|
||||
///
|
||||
/// Jitter should be applied to all rendering. This includes opaque, alpha
|
||||
/// transparent, and raytraced objects. For rasterized objects, the sub-pixel
|
||||
/// jittering values calculated by the <c><i>iffxFsr3UpscalerGetJitterOffset</i></c>
|
||||
/// function can be applied to the camera projection matrix which is ultimately
|
||||
/// used to perform transformations during vertex shading. For raytraced
|
||||
/// rendering, the sub-pixel jitter should be applied to the ray's origin,
|
||||
/// often the camera's position.
|
||||
///
|
||||
/// Whether you elect to use the <c><i>ffxFsr3UpscalerGetJitterOffset</i></c> function
|
||||
/// or your own sequence generator, you must program the
|
||||
/// <c><i>jitterOffset</i></c> field of the
|
||||
/// <c><i>FfxFsr3UpscalerDispatchParameters</i></c> structure in order to inform FSR3
|
||||
/// of the jitter offset that has been applied in order to render each frame.
|
||||
///
|
||||
/// If not using the recommended <c><i>ffxFsr3UpscalerGetJitterOffset</i></c> function,
|
||||
/// care should be taken that your jitter sequence never generates a null vector;
|
||||
/// that is value of 0 in both the X and Y dimensions.
|
||||
///
|
||||
/// @param [out] pOutX A pointer to a <c>float</c> which will contain the subpixel jitter offset for the x dimension.
|
||||
/// @param [out] pOutY A pointer to a <c>float</c> which will contain the subpixel jitter offset for the y dimension.
|
||||
/// @param [in] index The index within the jitter sequence.
|
||||
/// @param [in] phaseCount The length of jitter phase. See <c><i>ffxFsr3UpscalerGetJitterPhaseCount</i></c>.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_INVALID_POINTER Either <c><i>outX</i></c> or <c><i>outY</i></c> was <c>NULL</c>.
|
||||
/// @retval
|
||||
/// FFX_ERROR_INVALID_ARGUMENT Argument <c><i>phaseCount</i></c> must be greater than 0.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
FFX_API FfxErrorCode ffxFsr3UpscalerGetJitterOffset(float* pOutX, float* pOutY, int32_t index, int32_t phaseCount);
|
||||
|
||||
/// A helper function to check if a resource is
|
||||
/// <c><i>FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_NULL</i></c>.
|
||||
///
|
||||
/// @param [in] resource A <c><i>FfxResource</i></c>.
|
||||
///
|
||||
/// @returns
|
||||
/// true The <c><i>resource</i></c> was not <c><i>FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_NULL</i></c>.
|
||||
/// @returns
|
||||
/// false The <c><i>resource</i></c> was <c><i>FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_NULL</i></c>.
|
||||
///
|
||||
/// @ingroup ffxFsr3Upscaler
|
||||
FFX_API bool ffxFsr3UpscalerResourceIsNull(FfxResource resource);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif // #if defined(__cplusplus)
|
||||
+465
@@ -0,0 +1,465 @@
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <FidelityFX/host/ffx_assert.h>
|
||||
#include <FidelityFX/host/ffx_types.h>
|
||||
#include <FidelityFX/host/ffx_error.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#define FFX_CPU
|
||||
extern "C" {
|
||||
#endif // #if defined(__cplusplus)
|
||||
|
||||
/// @defgroup Backends Backends
|
||||
/// Core interface declarations and natively supported backends
|
||||
///
|
||||
/// @ingroup ffxSDK
|
||||
|
||||
/// @defgroup FfxInterface FfxInterface
|
||||
/// FidelityFX SDK function signatures and core defines requiring
|
||||
/// overrides for backend implementation.
|
||||
///
|
||||
/// @ingroup Backends
|
||||
FFX_FORWARD_DECLARE(FfxInterface);
|
||||
|
||||
/// FidelityFX SDK major version.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
#define FFX_SDK_VERSION_MAJOR (1)
|
||||
|
||||
/// FidelityFX SDK minor version.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
#define FFX_SDK_VERSION_MINOR (0)
|
||||
|
||||
/// FidelityFX SDK patch version.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
#define FFX_SDK_VERSION_PATCH (1)
|
||||
|
||||
/// Macro to pack a FidelityFX SDK version id together.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
#define FFX_SDK_MAKE_VERSION( major, minor, patch ) ( ( major << 22 ) | ( minor << 12 ) | patch )
|
||||
|
||||
/// Stand in type for FfxPass
|
||||
///
|
||||
/// These will be defined for each effect individually (i.e. FfxFsr2Pass).
|
||||
/// They are used to fetch the proper blob index to build effect shaders
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef uint32_t FfxPass;
|
||||
|
||||
/// Get the SDK version of the backend context.
|
||||
///
|
||||
/// Newer effects may require support that legacy versions of the SDK will not be
|
||||
/// able to provide. A version query is thus required to ensure an effect component
|
||||
/// will always be paired with a backend which will support all needed functionality.
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
///
|
||||
/// @returns
|
||||
/// The SDK version a backend was built with.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxUInt32(*FfxGetSDKVersionFunc)(
|
||||
FfxInterface* backendInterface);
|
||||
|
||||
/// Create and initialize the backend context.
|
||||
///
|
||||
/// The callback function sets up the backend context for rendering.
|
||||
/// It will create or reference the device and create required internal data structures.
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
/// @param [out] effectContextId The context space to be used for the effect in question.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// Anything else The operation failed.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxErrorCode (*FfxCreateBackendContextFunc)(
|
||||
FfxInterface* backendInterface,
|
||||
FfxUInt32* effectContextId);
|
||||
|
||||
/// Get a list of capabilities of the device.
|
||||
///
|
||||
/// When creating an <c><i>FfxEffectContext</i></c> it is desirable for the FFX
|
||||
/// core implementation to be aware of certain characteristics of the platform
|
||||
/// that is being targetted. This is because some optimizations which FFX SDK
|
||||
/// attempts to perform are more effective on certain classes of hardware than
|
||||
/// others, or are not supported by older hardware. In order to avoid cases
|
||||
/// where optimizations actually have the effect of decreasing performance, or
|
||||
/// reduce the breadth of support provided by FFX SDK, the FFX interface queries the
|
||||
/// capabilities of the device to make such decisions.
|
||||
///
|
||||
/// For target platforms with fixed hardware support you need not implement
|
||||
/// this callback function by querying the device, but instead may hardcore
|
||||
/// what features are available on the platform.
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
/// @param [out] outDeviceCapabilities The device capabilities structure to fill out.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// Anything else The operation failed.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxErrorCode(*FfxGetDeviceCapabilitiesFunc)(
|
||||
FfxInterface* backendInterface,
|
||||
FfxDeviceCapabilities* outDeviceCapabilities);
|
||||
|
||||
/// Destroy the backend context and dereference the device.
|
||||
///
|
||||
/// This function is called when the <c><i>FfxEffectContext</i></c> is destroyed.
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
/// @param [in] effectContextId The context space to be used for the effect in question.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// Anything else The operation failed.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxErrorCode(*FfxDestroyBackendContextFunc)(
|
||||
FfxInterface* backendInterface,
|
||||
FfxUInt32 effectContextId);
|
||||
|
||||
/// Create a resource.
|
||||
///
|
||||
/// This callback is intended for the backend to create internal resources.
|
||||
///
|
||||
/// Please note: It is also possible that the creation of resources might
|
||||
/// itself cause additional resources to be created by simply calling the
|
||||
/// <c><i>FfxCreateResourceFunc</i></c> function pointer again. This is
|
||||
/// useful when handling the initial creation of resources which must be
|
||||
/// initialized. The flow in such a case would be an initial call to create the
|
||||
/// CPU-side resource, another to create the GPU-side resource, and then a call
|
||||
/// to schedule a copy render job to move the data between the two. Typically
|
||||
/// this type of function call flow is only seen during the creation of an
|
||||
/// <c><i>FfxEffectContext</i></c>.
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
/// @param [in] createResourceDescription A pointer to a <c><i>FfxCreateResourceDescription</i></c>.
|
||||
/// @param [in] effectContextId The context space to be used for the effect in question.
|
||||
/// @param [out] outResource A pointer to a <c><i>FfxResource</i></c> object.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// Anything else The operation failed.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxErrorCode (*FfxCreateResourceFunc)(
|
||||
FfxInterface* backendInterface,
|
||||
const FfxCreateResourceDescription* createResourceDescription,
|
||||
FfxUInt32 effectContextId,
|
||||
FfxResourceInternal* outResource);
|
||||
|
||||
/// Register a resource in the backend for the current frame.
|
||||
///
|
||||
/// Since the FfxInterface and the backends are not aware how many different
|
||||
/// resources will get passed in over time, it's not safe
|
||||
/// to register all resources simultaneously in the backend.
|
||||
/// Also passed resources may not be valid after the dispatch call.
|
||||
/// As a result it's safest to register them as FfxResourceInternal
|
||||
/// and clear them at the end of the dispatch call.
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
/// @param [in] inResource A pointer to a <c><i>FfxResource</i></c>.
|
||||
/// @param [in] effectContextId The context space to be used for the effect in question.
|
||||
/// @param [out] outResource A pointer to a <c><i>FfxResourceInternal</i></c> object.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// Anything else The operation failed.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxErrorCode(*FfxRegisterResourceFunc)(
|
||||
FfxInterface* backendInterface,
|
||||
const FfxResource* inResource,
|
||||
FfxUInt32 effectContextId,
|
||||
FfxResourceInternal* outResource);
|
||||
|
||||
|
||||
/// Get an FfxResource from an FfxResourceInternal resource.
|
||||
///
|
||||
/// At times it is necessary to create an FfxResource representation
|
||||
/// of an internally created resource in order to register it with a
|
||||
/// child effect context. This function sets up the FfxResource needed
|
||||
/// to register.
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
/// @param [in] resource The <c><i>FfxResourceInternal</i></c> for which to setup an FfxResource.
|
||||
///
|
||||
/// @returns
|
||||
/// An FfxResource built from the internal resource
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxResource(*FfxGetResourceFunc)(
|
||||
FfxInterface* backendInterface,
|
||||
FfxResourceInternal resource);
|
||||
|
||||
/// Unregister all temporary FfxResourceInternal from the backend.
|
||||
///
|
||||
/// Unregister FfxResourceInternal referencing resources passed to
|
||||
/// a function as a parameter.
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
/// @param [in] commandList A pointer to a <c><i>FfxCommandList</i></c> structure.
|
||||
/// @param [in] effectContextId The context space to be used for the effect in question.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// Anything else The operation failed.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxErrorCode(*FfxUnregisterResourcesFunc)(
|
||||
FfxInterface* backendInterface,
|
||||
FfxCommandList commandList,
|
||||
FfxUInt32 effectContextId);
|
||||
|
||||
/// Retrieve a <c><i>FfxResourceDescription</i></c> matching a
|
||||
/// <c><i>FfxResource</i></c> structure.
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
/// @param [in] resource A pointer to a <c><i>FfxResource</i></c> object.
|
||||
///
|
||||
/// @returns
|
||||
/// A description of the resource.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxResourceDescription (*FfxGetResourceDescriptionFunc)(
|
||||
FfxInterface* backendInterface,
|
||||
FfxResourceInternal resource);
|
||||
|
||||
/// Destroy a resource
|
||||
///
|
||||
/// This callback is intended for the backend to release an internal resource.
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
/// @param [in] resource A pointer to a <c><i>FfxResource</i></c> object.
|
||||
/// @param [in] effectContextId The context space to be used for the effect in question.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// Anything else The operation failed.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxErrorCode (*FfxDestroyResourceFunc)(
|
||||
FfxInterface* backendInterface,
|
||||
FfxResourceInternal resource,
|
||||
FfxUInt32 effectContextId);
|
||||
|
||||
/// Create a render pipeline.
|
||||
///
|
||||
/// A rendering pipeline contains the shader as well as resource bindpoints
|
||||
/// and samplers.
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
/// @param [in] pass The identifier for the pass.
|
||||
/// @param [in] pipelineDescription A pointer to a <c><i>FfxPipelineDescription</i></c> describing the pipeline to be created.
|
||||
/// @param [in] effectContextId The context space to be used for the effect in question.
|
||||
/// @param [out] outPipeline A pointer to a <c><i>FfxPipelineState</i></c> structure which should be populated.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// Anything else The operation failed.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxErrorCode (*FfxCreatePipelineFunc)(
|
||||
FfxInterface* backendInterface,
|
||||
FfxEffect effect,
|
||||
FfxPass pass,
|
||||
uint32_t permutationOptions,
|
||||
const FfxPipelineDescription* pipelineDescription,
|
||||
FfxUInt32 effectContextId,
|
||||
FfxPipelineState* outPipeline);
|
||||
|
||||
typedef FfxErrorCode(*FfxGetPermutationBlobByIndexFunc)(FfxEffect effectId,
|
||||
FfxPass passId,
|
||||
FfxBindStage bindStage,
|
||||
uint32_t permutationOptions,
|
||||
FfxShaderBlob* outBlob);
|
||||
|
||||
/// Destroy a render pipeline.
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
/// @param [in] effectContextId The context space to be used for the effect in question.
|
||||
/// @param [out] pipeline A pointer to a <c><i>FfxPipelineState</i></c> structure which should be released.
|
||||
/// @param [in] effectContextId The context space to be used for the effect in question.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// Anything else The operation failed.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxErrorCode (*FfxDestroyPipelineFunc)(
|
||||
FfxInterface* backendInterface,
|
||||
FfxPipelineState* pipeline,
|
||||
FfxUInt32 effectContextId);
|
||||
|
||||
/// Schedule a render job to be executed on the next call of
|
||||
/// <c><i>FfxExecuteGpuJobsFunc</i></c>.
|
||||
///
|
||||
/// Render jobs can perform one of three different tasks: clear, copy or
|
||||
/// compute dispatches.
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
/// @param [in] job A pointer to a <c><i>FfxGpuJobDescription</i></c> structure.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// Anything else The operation failed.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxErrorCode (*FfxScheduleGpuJobFunc)(
|
||||
FfxInterface* backendInterface,
|
||||
const FfxGpuJobDescription* job);
|
||||
|
||||
/// Execute scheduled render jobs on the <c><i>comandList</i></c> provided.
|
||||
///
|
||||
/// The recording of the graphics API commands should take place in this
|
||||
/// callback function, the render jobs which were previously enqueued (via
|
||||
/// callbacks made to <c><i>FfxScheduleGpuJobFunc</i></c>) should be
|
||||
/// processed in the order they were received. Advanced users might choose to
|
||||
/// reorder the rendering jobs, but should do so with care to respect the
|
||||
/// resource dependencies.
|
||||
///
|
||||
/// Depending on the precise contents of <c><i>FfxDispatchDescription</i></c> a
|
||||
/// different number of render jobs might have previously been enqueued (for
|
||||
/// example if sharpening is toggled on and off).
|
||||
///
|
||||
/// @param [in] backendInterface A pointer to the backend interface.
|
||||
/// @param [in] commandList A pointer to a <c><i>FfxCommandList</i></c> structure.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// Anything else The operation failed.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef FfxErrorCode (*FfxExecuteGpuJobsFunc)(
|
||||
FfxInterface* backendInterface,
|
||||
FfxCommandList commandList);
|
||||
|
||||
typedef FfxErrorCode(*FfxPresentCallbackFunc)(const FfxPresentCallbackDescription* params);
|
||||
typedef FfxErrorCode(*FfxFrameGenerationDispatchFunc)(const FfxFrameGenerationDispatchDescription* params);
|
||||
|
||||
typedef struct FfxFrameGenerationConfig
|
||||
{
|
||||
FfxSwapchain swapChain;
|
||||
FfxPresentCallbackFunc presentCallback;
|
||||
FfxFrameGenerationDispatchFunc frameGenerationCallback;
|
||||
bool frameGenerationEnabled;
|
||||
bool allowAsyncWorkloads;
|
||||
FfxResource HUDLessColor;
|
||||
FfxUInt32 flags;
|
||||
bool onlyPresentInterpolated;
|
||||
} FfxFrameGenerationConfig;
|
||||
|
||||
typedef FfxErrorCode (*ffxSwapChainConfigureFrameGenerationFunc)(FfxFrameGenerationConfig const* config);
|
||||
|
||||
/// A structure encapsulating the interface between the core implementation of
|
||||
/// the FfxInterface and any graphics API that it should ultimately call.
|
||||
///
|
||||
/// This set of functions serves as an abstraction layer between FfxInterfae and the
|
||||
/// API used to implement it. While the FidelityFX SDK ships with backends for DirectX12 and
|
||||
/// Vulkan, it is possible to implement your own backend for other platforms
|
||||
/// which sit on top of your engine's own abstraction layer. For details on the
|
||||
/// expectations of what each function should do you should refer the
|
||||
/// description of the following function pointer types:
|
||||
///
|
||||
/// <c><i>FfxCreateDeviceFunc</i></c>
|
||||
/// <c><i>FfxGetDeviceCapabilitiesFunc</i></c>
|
||||
/// <c><i>FfxDestroyDeviceFunc</i></c>
|
||||
/// <c><i>FfxCreateResourceFunc</i></c>
|
||||
/// <c><i>FfxRegisterResourceFunc</i></c>
|
||||
/// <c><i>FfxGetResourceFunc</i></c>
|
||||
/// <c><i>FfxUnregisterResourcesFunc</i></c>
|
||||
/// <c><i>FfxGetResourceDescriptionFunc</i></c>
|
||||
/// <c><i>FfxDestroyResourceFunc</i></c>
|
||||
/// <c><i>FfxCreatePipelineFunc</i></c>
|
||||
/// <c><i>FfxDestroyPipelineFunc</i></c>
|
||||
/// <c><i>FfxScheduleGpuJobFunc</i></c>
|
||||
/// <c><i>FfxExecuteGpuJobsFunc</i></c>
|
||||
///
|
||||
/// Depending on the graphics API that is abstracted by the backend, it may be
|
||||
/// required that the backend is to some extent stateful. To ensure that
|
||||
/// applications retain full control to manage the memory used by the FidelityFX SDK, the
|
||||
/// <c><i>scratchBuffer</i></c> and <c><i>scratchBufferSize</i></c> fields are
|
||||
/// provided. A backend should provide a means of specifying how much scratch
|
||||
/// memory is required for its internal implementation (e.g: via a function
|
||||
/// or constant value). The application is then responsible for allocating that
|
||||
/// memory and providing it when setting up the SDK backend. Backends provided
|
||||
/// with the FidelityFX SDK do not perform dynamic memory allocations, and instead
|
||||
/// sub-allocate all memory from the scratch buffers provided.
|
||||
///
|
||||
/// The <c><i>scratchBuffer</i></c> and <c><i>scratchBufferSize</i></c> fields
|
||||
/// should be populated according to the requirements of each backend. For
|
||||
/// example, if using the DirectX 12 backend you should call the
|
||||
/// <c><i>ffxGetScratchMemorySizeDX12</i></c> function. It is not required
|
||||
/// that custom backend implementations use a scratch buffer.
|
||||
///
|
||||
/// Any functional addition to this interface mandates a version
|
||||
/// bump to ensure full functionality across effects and backends.
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef struct FfxInterface {
|
||||
|
||||
FfxGetSDKVersionFunc fpGetSDKVersion; ///< A callback function to query the SDK version.
|
||||
FfxCreateBackendContextFunc fpCreateBackendContext; ///< A callback function to create and initialize the backend context.
|
||||
FfxGetDeviceCapabilitiesFunc fpGetDeviceCapabilities; ///< A callback function to query device capabilities.
|
||||
FfxDestroyBackendContextFunc fpDestroyBackendContext; ///< A callback function to destroy the backend context. This also dereferences the device.
|
||||
FfxCreateResourceFunc fpCreateResource; ///< A callback function to create a resource.
|
||||
FfxRegisterResourceFunc fpRegisterResource; ///< A callback function to register an external resource.
|
||||
FfxGetResourceFunc fpGetResource; ///< A callback function to convert an internal resource to external resource type
|
||||
FfxUnregisterResourcesFunc fpUnregisterResources; ///< A callback function to unregister external resource.
|
||||
FfxGetResourceDescriptionFunc fpGetResourceDescription; ///< A callback function to retrieve a resource description.
|
||||
FfxDestroyResourceFunc fpDestroyResource; ///< A callback function to destroy a resource.
|
||||
FfxCreatePipelineFunc fpCreatePipeline; ///< A callback function to create a render or compute pipeline.
|
||||
FfxGetPermutationBlobByIndexFunc fpGetPermutationBlobByIndex;
|
||||
FfxDestroyPipelineFunc fpDestroyPipeline; ///< A callback function to destroy a render or compute pipeline.
|
||||
FfxScheduleGpuJobFunc fpScheduleGpuJob; ///< A callback function to schedule a render job.
|
||||
FfxExecuteGpuJobsFunc fpExecuteGpuJobs; ///< A callback function to execute all queued render jobs.
|
||||
ffxSwapChainConfigureFrameGenerationFunc fpSwapChainConfigureFrameGeneration; ///< A callback function to configure swap chain present callback.
|
||||
|
||||
void* scratchBuffer; ///< A preallocated buffer for memory utilized internally by the backend.
|
||||
size_t scratchBufferSize; ///< Size of the buffer pointed to by <c><i>scratchBuffer</i></c>.
|
||||
FfxDevice device; ///< A backend specific device
|
||||
|
||||
} FfxInterface;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif // #if defined(__cplusplus)
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
// @defgroup OpticalFlow
|
||||
|
||||
#pragma once
|
||||
|
||||
// Include the interface for the backend of the OpticalFlow API.
|
||||
#include <FidelityFX/host/ffx_interface.h>
|
||||
|
||||
/// FidelityFX OpticalFlow major version.
|
||||
///
|
||||
/// @ingroup ffxOpticalflow
|
||||
#define FFX_OPTICALFLOW_VERSION_MAJOR (1)
|
||||
|
||||
/// FidelityFX OpticalFlow minor version.
|
||||
///
|
||||
/// @ingroup ffxOpticalflow
|
||||
#define FFX_OPTICALFLOW_VERSION_MINOR (0)
|
||||
|
||||
/// FidelityFX OpticalFlow patch version.
|
||||
///
|
||||
/// @ingroup ffxOpticalflow
|
||||
#define FFX_OPTICALFLOW_VERSION_PATCH (0)
|
||||
|
||||
/// FidelityFX Optical Flow context count
|
||||
///
|
||||
/// Defines the number of internal effect contexts required by Optical Flow
|
||||
///
|
||||
/// @ingroup ffxOpticalFlow
|
||||
#define FFX_OPTICALFLOW_CONTEXT_COUNT (1)
|
||||
|
||||
/// The size of the context specified in 32bit size units.
|
||||
///
|
||||
/// @ingroup ffxOpticalflow
|
||||
#define FFX_OPTICALFLOW_CONTEXT_SIZE (FFX_SDK_DEFAULT_CONTEXT_SIZE)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif // #if defined(__cplusplus)
|
||||
|
||||
/// An enumeration of all the passes which constitute the OpticalFlow algorithm.
|
||||
///
|
||||
/// @ingroup ffxOpticalflow
|
||||
typedef enum FfxOpticalflowPass
|
||||
{
|
||||
FFX_OPTICALFLOW_PASS_PREPARE_LUMA = 0,
|
||||
FFX_OPTICALFLOW_PASS_GENERATE_OPTICAL_FLOW_INPUT_PYRAMID,
|
||||
FFX_OPTICALFLOW_PASS_GENERATE_SCD_HISTOGRAM,
|
||||
FFX_OPTICALFLOW_PASS_COMPUTE_SCD_DIVERGENCE,
|
||||
FFX_OPTICALFLOW_PASS_COMPUTE_OPTICAL_FLOW_ADVANCED_V5,
|
||||
FFX_OPTICALFLOW_PASS_FILTER_OPTICAL_FLOW_V5,
|
||||
FFX_OPTICALFLOW_PASS_SCALE_OPTICAL_FLOW_ADVANCED_V5,
|
||||
|
||||
FFX_OPTICALFLOW_PASS_COUNT
|
||||
} FfxOpticalflowPass;
|
||||
|
||||
/// An enumeration of bit flags used when creating a
|
||||
/// <c><i>FfxOpticalflowContext</i></c>. See <c><i>FfxOpticalflowDispatchDescription</i></c>.
|
||||
///
|
||||
/// @ingroup ffxOpticalflow
|
||||
typedef enum FfxOpticalflowInitializationFlagBits
|
||||
{
|
||||
FFX_OPTICALFLOW_ENABLE_TEXTURE1D_USAGE = (1 << 0),
|
||||
|
||||
} FfxOpticalflowInitializationFlagBits;
|
||||
|
||||
/// A structure encapsulating the parameters required to initialize
|
||||
/// FidelityFX OpticalFlow.
|
||||
///
|
||||
/// @ingroup ffxOpticalflow
|
||||
typedef struct FfxOpticalflowContextDescription {
|
||||
|
||||
FfxInterface backendInterface; ///< A set of pointers to the backend implementation for FidelityFX SDK
|
||||
uint32_t flags; ///< A collection of <c><i>FfxOpticalflowInitializationFlagBits</i></c>.
|
||||
FfxDimensions2D resolution;
|
||||
} FfxOpticalflowContextDescription;
|
||||
|
||||
/// A structure encapsulating the parameters for dispatching the various passes
|
||||
/// of FidelityFX Opticalflow.
|
||||
///
|
||||
/// @ingroup ffxOpticalflow
|
||||
typedef struct FfxOpticalflowDispatchDescription
|
||||
{
|
||||
FfxCommandList commandList; ///< The <c><i>FfxCommandList</i></c> to record rendering commands into.
|
||||
FfxResource color; ///< A <c><i>FfxResource</i></c> containing the input color buffer
|
||||
FfxResource opticalFlowVector; ///< A <c><i>FfxResource</i></c> containing the output motion buffer
|
||||
FfxResource opticalFlowSCD; ///< A <c><i>FfxResource</i></c> containing the output scene change detection buffer
|
||||
bool reset; ///< A boolean value which when set to true, indicates the camera has moved discontinuously.
|
||||
int backbufferTransferFunction;
|
||||
FfxFloatCoords2D minMaxLuminance;
|
||||
} FfxOpticalflowDispatchDescription;
|
||||
|
||||
typedef struct FfxOpticalflowSharedResourceDescriptions {
|
||||
|
||||
FfxCreateResourceDescription opticalFlowVector;
|
||||
FfxCreateResourceDescription opticalFlowSCD;
|
||||
|
||||
} FfxOpticalflowSharedResourceDescriptions;
|
||||
|
||||
/// A structure encapsulating the FidelityFX OpticalFlow context.
|
||||
///
|
||||
/// This sets up an object which contains all persistent internal data and
|
||||
/// resources that are required by OpticalFlow.
|
||||
///
|
||||
/// The <c><i>FfxOpticalflowContext</i></c> object should have a lifetime matching
|
||||
/// your use of OpticalFlow. Before destroying the OpticalFlow context care should be taken
|
||||
/// to ensure the GPU is not accessing the resources created or used by OpticalFlow.
|
||||
/// It is therefore recommended that the GPU is idle before destroying OpticalFlow
|
||||
/// OpticalFlow context.
|
||||
///
|
||||
/// @ingroup ffxOpticalflow
|
||||
typedef struct FfxOpticalflowContext
|
||||
{
|
||||
uint32_t data[FFX_OPTICALFLOW_CONTEXT_SIZE]; ///< An opaque set of <c>uint32_t</c> which contain the data for the context.
|
||||
} FfxOpticalflowContext;
|
||||
|
||||
|
||||
/// Create a FidelityFX OpticalFlow context from the parameters
|
||||
/// programmed to the <c><i>FfxOpticalflowContextDescription</i></c> structure.
|
||||
///
|
||||
/// The context structure is the main object used to interact with the OpticalFlow
|
||||
/// API, and is responsible for the management of the internal resources used
|
||||
/// by the OpticalFlow algorithm. When this API is called, multiple calls will be
|
||||
/// made via the pointers contained in the <c><i>callbacks</i></c> structure.
|
||||
/// These callbacks will attempt to retreive the device capabilities, and
|
||||
/// create the internal resources, and pipelines required by OpticalFlow's
|
||||
/// frame-to-frame function. Depending on the precise configuration used when
|
||||
/// creating the <c><i>FfxOpticalflowContext</i></c> a different set of resources and
|
||||
/// pipelines might be requested via the callback functions.
|
||||
///
|
||||
/// The flags included in the <c><i>flags</i></c> field of
|
||||
/// <c><i>FfxOpticalflowContext</i></c> how match the configuration of your
|
||||
/// application as well as the intended use of OpticalFlow. It is important that these
|
||||
/// flags are set correctly (as well as a correct programmed
|
||||
/// <c><i>FfxOpticalflowContextDescription</i></c>) to ensure correct operation. It is
|
||||
/// recommended to consult the overview documentation for further details on
|
||||
/// how OpticalFlow should be integerated into an application.
|
||||
///
|
||||
/// When the <c><i>FfxOpticalflowContext</i></c> is created, you should use the
|
||||
/// <c><i>ffxOpticalflowContextDispatch</i></c> function each frame where FSR3
|
||||
/// upscaling should be applied. See the documentation of
|
||||
/// <c><i>ffxOpticalflowContextDispatch</i></c> for more details.
|
||||
///
|
||||
/// The <c><i>FfxOpticalflowContext</i></c> should be destroyed when use of it is
|
||||
/// completed, typically when an application is unloaded or OpticalFlow is
|
||||
/// disabled by a user. To destroy the OpticalFlow context you should call
|
||||
/// <c><i>ffxOpticalflowContextDestroy</i></c>.
|
||||
///
|
||||
/// @param [out] context A pointer to a <c><i>FfxOpticalflowContext</i></c> structure to populate.
|
||||
/// @param [in] contextDescription A pointer to a <c><i>FfxOpticalflowContextDescription</i></c> structure.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either <c><i>context</i></c> or <c><i>contextDescription</i></c> was <c><i>NULL</i></c>.
|
||||
/// @retval
|
||||
/// FFX_ERROR_INCOMPLETE_INTERFACE The operation failed because the <c><i>FfxOpticalflowContextDescription.callbacks</i></c> was not fully specified.
|
||||
/// @retval
|
||||
/// FFX_ERROR_BACKEND_API_ERROR The operation failed because of an error returned from the backend.
|
||||
///
|
||||
/// @ingroup ffxOpticalflow
|
||||
FFX_API FfxErrorCode ffxOpticalflowContextCreate(FfxOpticalflowContext* context, FfxOpticalflowContextDescription* contextDescription);
|
||||
|
||||
FFX_API FfxErrorCode ffxOpticalflowGetSharedResourceDescriptions(FfxOpticalflowContext* context, FfxOpticalflowSharedResourceDescriptions* SharedResources);
|
||||
|
||||
FFX_API FfxErrorCode ffxOpticalflowContextDispatch(FfxOpticalflowContext* context, const FfxOpticalflowDispatchDescription* dispatchDescription);
|
||||
|
||||
/// Destroy the FidelityFX OpticalFlow context.
|
||||
///
|
||||
/// @param [out] context A pointer to a <c><i>FfxOpticalflowContext</i></c> structure to destroy.
|
||||
///
|
||||
/// @retval
|
||||
/// FFX_OK The operation completed successfully.
|
||||
/// @retval
|
||||
/// FFX_ERROR_CODE_NULL_POINTER The operation failed because either <c><i>context</i></c> was <c><i>NULL</i></c>.
|
||||
///
|
||||
/// @ingroup ffxOpticalflow
|
||||
FFX_API FfxErrorCode ffxOpticalflowContextDestroy(FfxOpticalflowContext* context);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif // #if defined(__cplusplus)
|
||||
+937
@@ -0,0 +1,937 @@
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
///
|
||||
/// @defgroup ffxSDK SDK
|
||||
/// The FidelityFX SDK
|
||||
///
|
||||
|
||||
/// @defgroup ffxHost Host
|
||||
/// The FidelityFX SDK host (CPU-side) References
|
||||
///
|
||||
/// @ingroup ffxSDK
|
||||
|
||||
/// @defgroup Defines Defines
|
||||
/// Top level defines used by the FidelityFX SDK
|
||||
///
|
||||
/// @ingroup ffxHost
|
||||
|
||||
#if defined (FFX_GCC)
|
||||
/// FidelityFX exported functions
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_API
|
||||
#else
|
||||
/// FidelityFX exported functions
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_API __declspec(dllexport)
|
||||
#endif // #if defined (FFX_GCC)
|
||||
|
||||
#define FFX_SDK_DEFAULT_CONTEXT_SIZE (1024 * 128)
|
||||
|
||||
/// Maximum supported number of simultaneously bound SRVs.
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_MAX_NUM_SRVS 16
|
||||
|
||||
/// Maximum supported number of simultaneously bound UAVs.
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_MAX_NUM_UAVS 16
|
||||
|
||||
/// Maximum number of constant buffers bound.
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_MAX_NUM_CONST_BUFFERS 3
|
||||
|
||||
/// Maximum size of bound constant buffers.
|
||||
#define FFX_MAX_CONST_SIZE 256
|
||||
|
||||
/// Maximum number of characters in a resource name
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_RESOURCE_NAME_SIZE 64
|
||||
|
||||
/// Maximum number of queued frames in the backend
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_MAX_QUEUED_FRAMES (4)
|
||||
|
||||
/// Maximum number of resources per effect context
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_MAX_RESOURCE_COUNT (128)
|
||||
|
||||
/// Maximum number of passes per effect component
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_MAX_PASS_COUNT (50)
|
||||
|
||||
/// Total ring buffer size needed for a single effect context
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_RING_BUFFER_SIZE (FFX_MAX_QUEUED_FRAMES * FFX_MAX_PASS_COUNT * FFX_MAX_RESOURCE_COUNT)
|
||||
|
||||
/// Size of constant buffer entry in the ring buffer table
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_BUFFER_SIZE (768)
|
||||
|
||||
/// Total ring buffer memory size for a single effect context
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_RING_BUFFER_MEM_BLOCK_SIZE (FFX_RING_BUFFER_SIZE * FFX_BUFFER_SIZE)
|
||||
|
||||
/// Maximum number of barriers per flush
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_MAX_BARRIERS (16)
|
||||
|
||||
/// Maximum number of GPU jobs per submission
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_MAX_GPU_JOBS (64)
|
||||
|
||||
/// Maximum number of samplers supported
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define FFX_MAX_SAMPLERS (16)
|
||||
|
||||
/// Maximum number of simultaneous upload jobs
|
||||
///
|
||||
/// @ingroup Defines
|
||||
#define UPLOAD_JOB_COUNT (16)
|
||||
|
||||
// Off by default warnings
|
||||
#pragma warning(disable : 4365 4710 4820 5039)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // #ifdef __cplusplus
|
||||
|
||||
/// @defgroup CPUTypes CPU Types
|
||||
/// CPU side type defines for all commonly used variables
|
||||
///
|
||||
/// @ingroup ffxHost
|
||||
|
||||
/// A typedef for a boolean value.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef bool FfxBoolean;
|
||||
|
||||
/// A typedef for a unsigned 8bit integer.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef uint8_t FfxUInt8;
|
||||
|
||||
/// A typedef for a unsigned 16bit integer.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef uint16_t FfxUInt16;
|
||||
|
||||
/// A typedef for a unsigned 32bit integer.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef uint32_t FfxUInt32;
|
||||
|
||||
/// A typedef for a unsigned 64bit integer.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef uint64_t FfxUInt64;
|
||||
|
||||
/// A typedef for a signed 8bit integer.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef int8_t FfxInt8;
|
||||
|
||||
/// A typedef for a signed 16bit integer.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef int16_t FfxInt16;
|
||||
|
||||
/// A typedef for a signed 32bit integer.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef int32_t FfxInt32;
|
||||
|
||||
/// A typedef for a signed 64bit integer.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef int64_t FfxInt64;
|
||||
|
||||
/// A typedef for a floating point value.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef float FfxFloat32;
|
||||
|
||||
/// A typedef for a 2-dimensional floating point value.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef float FfxFloat32x2[2];
|
||||
|
||||
/// A typedef for a 3-dimensional floating point value.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef float FfxFloat32x3[3];
|
||||
|
||||
/// A typedef for a 4-dimensional floating point value.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef float FfxFloat32x4[4];
|
||||
|
||||
/// A typedef for a 2-dimensional 32bit unsigned integer.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef uint32_t FfxUInt32x2[2];
|
||||
|
||||
/// A typedef for a 3-dimensional 32bit unsigned integer.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef uint32_t FfxUInt32x3[3];
|
||||
|
||||
/// A typedef for a 4-dimensional 32bit unsigned integer.
|
||||
///
|
||||
/// @ingroup CPUTypes
|
||||
typedef uint32_t FfxUInt32x4[4];
|
||||
|
||||
/// @defgroup SDKTypes SDK Types
|
||||
/// Structure and Enumeration definitions used by the FidelityFX SDK
|
||||
///
|
||||
/// @ingroup ffxHost
|
||||
|
||||
|
||||
/// An enumeration of surface formats.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxSurfaceFormat {
|
||||
|
||||
FFX_SURFACE_FORMAT_UNKNOWN, ///< Unknown format
|
||||
FFX_SURFACE_FORMAT_R32G32B32A32_TYPELESS, ///< 32 bit per channel, 4 channel typeless format
|
||||
FFX_SURFACE_FORMAT_R32G32B32A32_UINT, ///< 32 bit per channel, 4 channel uint format
|
||||
FFX_SURFACE_FORMAT_R32G32B32A32_FLOAT, ///< 32 bit per channel, 4 channel float format
|
||||
FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, ///< 16 bit per channel, 4 channel float format
|
||||
FFX_SURFACE_FORMAT_R32G32_FLOAT, ///< 32 bit per channel, 2 channel float format
|
||||
FFX_SURFACE_FORMAT_R8_UINT, ///< 8 bit per channel, 1 channel float format
|
||||
FFX_SURFACE_FORMAT_R32_UINT, ///< 32 bit per channel, 1 channel float format
|
||||
FFX_SURFACE_FORMAT_R10G10B10A2_UNORM, ///< 10 bit per RGB channel with 2 bit alpha, 4 channel unsigned normalized format
|
||||
FFX_SURFACE_FORMAT_R8G8B8A8_TYPELESS, ///< 8 bit per channel, 4 channel float format
|
||||
FFX_SURFACE_FORMAT_R8G8B8A8_UNORM, ///< 8 bit per channel, 4 channel unsigned normalized format
|
||||
FFX_SURFACE_FORMAT_R8G8B8A8_SNORM, ///< 8 bit per channel, 4 channel signed normalized format
|
||||
FFX_SURFACE_FORMAT_R8G8B8A8_SRGB, ///< 8 bit per channel, 4 channel srgb normalized
|
||||
FFX_SURFACE_FORMAT_R11G11B10_FLOAT, ///< 32 bit 3 channel float format
|
||||
FFX_SURFACE_FORMAT_R16G16_FLOAT, ///< 16 bit per channel, 2 channel float format
|
||||
FFX_SURFACE_FORMAT_R16G16_UINT, ///< 16 bit per channel, 2 channel unsigned int format
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, ///< 16 bit per channel, 2 channel signed int format
|
||||
FFX_SURFACE_FORMAT_R16_FLOAT, ///< 16 bit per channel, 1 channel float format
|
||||
FFX_SURFACE_FORMAT_R16_UINT, ///< 16 bit per channel, 1 channel unsigned int format
|
||||
FFX_SURFACE_FORMAT_R16_UNORM, ///< 16 bit per channel, 1 channel unsigned normalized format
|
||||
FFX_SURFACE_FORMAT_R16_SNORM, ///< 16 bit per channel, 1 channel signed normalized format
|
||||
FFX_SURFACE_FORMAT_R8_UNORM, ///< 8 bit per channel, 1 channel unsigned normalized format
|
||||
FFX_SURFACE_FORMAT_R8G8_UNORM, ///< 8 bit per channel, 2 channel unsigned normalized format
|
||||
FFX_SURFACE_FORMAT_R8G8_UINT, ///< 8 bit per channel, 2 channel unsigned integer format
|
||||
FFX_SURFACE_FORMAT_R32_FLOAT ///< 32 bit per channel, 1 channel float format
|
||||
} FfxSurfaceFormat;
|
||||
|
||||
/// An enumeration of resource usage.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxResourceUsage {
|
||||
|
||||
FFX_RESOURCE_USAGE_READ_ONLY = 0, ///< No usage flags indicate a resource is read only.
|
||||
FFX_RESOURCE_USAGE_RENDERTARGET = (1<<0), ///< Indicates a resource will be used as render target.
|
||||
FFX_RESOURCE_USAGE_UAV = (1<<1), ///< Indicates a resource will be used as UAV.
|
||||
FFX_RESOURCE_USAGE_DEPTHTARGET = (1<<2), ///< Indicates a resource will be used as depth target.
|
||||
FFX_RESOURCE_USAGE_INDIRECT = (1<<3), ///< Indicates a resource will be used as indirect argument buffer
|
||||
FFX_RESOURCE_USAGE_ARRAYVIEW = (1<<4), ///< Indicates a resource that will generate array views. Works on 2D and cubemap textures
|
||||
} FfxResourceUsage;
|
||||
|
||||
/// An enumeration of resource states.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxResourceStates {
|
||||
|
||||
FFX_RESOURCE_STATE_COMMON = (1 << 0),
|
||||
FFX_RESOURCE_STATE_UNORDERED_ACCESS = (1 << 1), ///< Indicates a resource is in the state to be used as UAV.
|
||||
FFX_RESOURCE_STATE_COMPUTE_READ = (1 << 2), ///< Indicates a resource is in the state to be read by compute shaders.
|
||||
FFX_RESOURCE_STATE_PIXEL_READ = (1 << 3), ///< Indicates a resource is in the state to be read by pixel shaders.
|
||||
FFX_RESOURCE_STATE_PIXEL_COMPUTE_READ = (FFX_RESOURCE_STATE_PIXEL_READ | FFX_RESOURCE_STATE_COMPUTE_READ), ///< Indicates a resource is in the state to be read by pixel or compute shaders.
|
||||
FFX_RESOURCE_STATE_COPY_SRC = (1 << 4), ///< Indicates a resource is in the state to be used as source in a copy command.
|
||||
FFX_RESOURCE_STATE_COPY_DEST = (1 << 5), ///< Indicates a resource is in the state to be used as destination in a copy command.
|
||||
FFX_RESOURCE_STATE_GENERIC_READ = (FFX_RESOURCE_STATE_COPY_SRC | FFX_RESOURCE_STATE_COMPUTE_READ), ///< Indicates a resource is in generic (slow) read state.
|
||||
FFX_RESOURCE_STATE_INDIRECT_ARGUMENT = (1 << 6), ///< Indicates a resource is in the state to be used as an indirect command argument
|
||||
FFX_RESOURCE_STATE_PRESENT = (1 << 7), ///< Indicates a resource is in the state to be used to present to the swap chain
|
||||
FFX_RESOURCE_STATE_RENDER_TARGET = (1 << 8), ///< Indicates a resource is in the state to be used as render target
|
||||
} FfxResourceStates;
|
||||
|
||||
/// An enumeration of surface dimensions.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxResourceDimension {
|
||||
|
||||
FFX_RESOURCE_DIMENSION_TEXTURE_1D, ///< A resource with a single dimension.
|
||||
FFX_RESOURCE_DIMENSION_TEXTURE_2D, ///< A resource with two dimensions.
|
||||
} FfxResourceDimension;
|
||||
|
||||
/// An enumeration of resource view dimensions.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxResourceViewDimension
|
||||
{
|
||||
FFX_RESOURCE_VIEW_DIMENSION_BUFFER, ///< A resource view on a buffer.
|
||||
FFX_RESOURCE_VIEW_DIMENSION_TEXTURE_1D, ///< A resource view on a single dimension.
|
||||
FFX_RESOURCE_VIEW_DIMENSION_TEXTURE_1D_ARRAY, ///< A resource view on a single dimensional array.
|
||||
FFX_RESOURCE_VIEW_DIMENSION_TEXTURE_2D, ///< A resource view on two dimensions.
|
||||
FFX_RESOURCE_VIEW_DIMENSION_TEXTURE_2D_ARRAY, ///< A resource view on two dimensional array.
|
||||
FFX_RESOURCE_VIEW_DIMENSION_TEXTURE_3D, ///< A resource view on three dimensions.
|
||||
} FfxResourceViewDimension;
|
||||
|
||||
/// An enumeration of surface dimensions.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxResourceFlags {
|
||||
|
||||
FFX_RESOURCE_FLAGS_NONE = 0, ///< No flags.
|
||||
FFX_RESOURCE_FLAGS_ALIASABLE = (1 << 0), ///< A bit indicating a resource does not need to persist across frames.
|
||||
FFX_RESOURCE_FLAGS_UNDEFINED = (1 << 1), ///< Special case flag used internally when importing resources that require additional setup
|
||||
} FfxResourceFlags;
|
||||
|
||||
/// An enumeration of all resource view types.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxResourceViewType {
|
||||
|
||||
FFX_RESOURCE_VIEW_UNORDERED_ACCESS, ///< The resource view is an unordered access view (UAV).
|
||||
FFX_RESOURCE_VIEW_SHADER_READ, ///< The resource view is a shader resource view (SRV).
|
||||
} FfxResourceViewType;
|
||||
|
||||
/// The type of filtering to perform when reading a texture.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxFilterType {
|
||||
|
||||
FFX_FILTER_TYPE_MINMAGMIP_POINT, ///< Point sampling.
|
||||
FFX_FILTER_TYPE_MINMAGMIP_LINEAR, ///< Sampling with interpolation.
|
||||
FFX_FILTER_TYPE_MINMAGLINEARMIP_POINT, ///< Use linear interpolation for minification and magnification; use point sampling for mip-level sampling.
|
||||
} FfxFilterType;
|
||||
|
||||
/// The address mode used when reading a texture.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxAddressMode {
|
||||
|
||||
FFX_ADDRESS_MODE_WRAP, ///< Wrap when reading texture.
|
||||
FFX_ADDRESS_MODE_MIRROR, ///< Mirror when reading texture.
|
||||
FFX_ADDRESS_MODE_CLAMP, ///< Clamp when reading texture.
|
||||
FFX_ADDRESS_MODE_BORDER, ///< Border color when reading texture.
|
||||
FFX_ADDRESS_MODE_MIRROR_ONCE, ///< Mirror once when reading texture.
|
||||
} FfxAddressMode;
|
||||
|
||||
/// An enumeration of all supported shader models.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxShaderModel {
|
||||
|
||||
FFX_SHADER_MODEL_5_1, ///< Shader model 5.1.
|
||||
FFX_SHADER_MODEL_6_0, ///< Shader model 6.0.
|
||||
FFX_SHADER_MODEL_6_1, ///< Shader model 6.1.
|
||||
FFX_SHADER_MODEL_6_2, ///< Shader model 6.2.
|
||||
FFX_SHADER_MODEL_6_3, ///< Shader model 6.3.
|
||||
FFX_SHADER_MODEL_6_4, ///< Shader model 6.4.
|
||||
FFX_SHADER_MODEL_6_5, ///< Shader model 6.5.
|
||||
FFX_SHADER_MODEL_6_6, ///< Shader model 6.6.
|
||||
FFX_SHADER_MODEL_6_7, ///< Shader model 6.7.
|
||||
} FfxShaderModel;
|
||||
|
||||
// An enumeration for different resource types
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxResourceType {
|
||||
|
||||
FFX_RESOURCE_TYPE_BUFFER, ///< The resource is a buffer.
|
||||
FFX_RESOURCE_TYPE_TEXTURE1D, ///< The resource is a 1-dimensional texture.
|
||||
FFX_RESOURCE_TYPE_TEXTURE2D, ///< The resource is a 2-dimensional texture.
|
||||
FFX_RESOURCE_TYPE_TEXTURE_CUBE, ///< The resource is a cube map.
|
||||
FFX_RESOURCE_TYPE_TEXTURE3D, ///< The resource is a 3-dimensional texture.
|
||||
} FfxResourceType;
|
||||
|
||||
/// An enumeration for different heap types
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxHeapType {
|
||||
|
||||
FFX_HEAP_TYPE_DEFAULT = 0, ///< Local memory.
|
||||
FFX_HEAP_TYPE_UPLOAD ///< Heap used for uploading resources.
|
||||
} FfxHeapType;
|
||||
|
||||
/// An enumeration for different render job types
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxGpuJobType {
|
||||
|
||||
FFX_GPU_JOB_CLEAR_FLOAT = 0, ///< The GPU job is performing a floating-point clear.
|
||||
FFX_GPU_JOB_COPY = 1, ///< The GPU job is performing a copy.
|
||||
FFX_GPU_JOB_COMPUTE = 2, ///< The GPU job is performing a compute dispatch.
|
||||
FFX_GPU_JOB_BARRIER = 3, ///< The GPU job is performing a barrier.
|
||||
|
||||
} FfxGpuJobType;
|
||||
|
||||
/// An enumeration for various descriptor types
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxDescriptorType {
|
||||
|
||||
//FFX_DESCRIPTOR_CBV = 0, // All CBVs currently mapped to root signature
|
||||
//FFX_DESCRIPTOR_SAMPLER, // All samplers currently static
|
||||
FFX_DESCRIPTOR_TEXTURE_SRV = 0,
|
||||
FFX_DESCRIPTOR_BUFFER_SRV,
|
||||
FFX_DESCRIPTOR_TEXTURE_UAV,
|
||||
FFX_DESCRIPTOR_BUFFER_UAV,
|
||||
} FfxDescriptiorType;
|
||||
|
||||
/// An enumeration for view binding stages
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxBindStage {
|
||||
|
||||
FFX_BIND_PIXEL_SHADER_STAGE = 1 << 0,
|
||||
FFX_BIND_VERTEX_SHADER_STAGE = 1 << 1,
|
||||
FFX_BIND_COMPUTE_SHADER_STAGE = 1 << 2,
|
||||
|
||||
} FfxBindStage;
|
||||
|
||||
/// An enumeration for barrier types
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxBarrierType
|
||||
{
|
||||
FFX_BARRIER_TYPE_TRANSITION = 0,
|
||||
FFX_BARRIER_TYPE_UAV,
|
||||
} FfxBarrierType;
|
||||
|
||||
/// An enumeration for message types that can be passed
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef enum FfxMsgType {
|
||||
FFX_MESSAGE_TYPE_ERROR = 0,
|
||||
FFX_MESSAGE_TYPE_WARNING = 1,
|
||||
FFX_MESSAGE_TYPE_COUNT
|
||||
} FfxMsgType;
|
||||
|
||||
/// An enumeration of all the effects which constitute the FidelityFX SDK.
|
||||
///
|
||||
/// Dictates what effect shader blobs to fetch for pipeline creation
|
||||
///
|
||||
/// @ingroup FfxInterface
|
||||
typedef enum FfxEffect
|
||||
{
|
||||
|
||||
FFX_EFFECT_FSR2 = 0, ///< FidelityFX Super Resolution v2
|
||||
FFX_EFFECT_FSR1, ///< FidelityFX Super Resolution
|
||||
FFX_EFFECT_SPD, ///< FidelityFX Single Pass Downsampler
|
||||
FFX_EFFECT_BLUR, ///< FidelityFX Blur
|
||||
FFX_EFFECT_CACAO, ///< FidelityFX Combined Adaptive Compute Ambient Occlusion
|
||||
FFX_EFFECT_CAS, ///< FidelityFX Contrast Adaptive Sharpening
|
||||
FFX_EFFECT_DENOISER, ///< FidelityFX Denoiser
|
||||
FFX_EFFECT_LENS, ///< FidelityFX Lens
|
||||
FFX_EFFECT_PARALLEL_SORT, ///< FidelityFX Parallel Sort
|
||||
FFX_EFFECT_SSSR, ///< FidelityFX Stochastic Screen Space Reflections
|
||||
FFX_EFFECT_VARIABLE_SHADING, ///< FidelityFX Variable Shading
|
||||
FFX_EFFECT_LPM, ///< FidelityFX Luma Preserving Mapper
|
||||
FFX_EFFECT_DOF, ///< FidelityFX Depth of Field
|
||||
FFX_EFFECT_CLASSIFIER, ///< FidelityFX Classifier
|
||||
FFX_EFFECT_FSR3UPSCALER, ///< FidelityFX Super Resolution v3
|
||||
FFX_EFFECT_FRAMEINTERPOLATION, ///< FidelityFX Frame Interpolation, part of FidelityFX Super Resolution v3
|
||||
FFX_EFFECT_OPTICALFLOW, ///< FidelityFX Optical Flow, part of FidelityFX Super Resolution v3
|
||||
|
||||
} FfxEffect;
|
||||
|
||||
typedef enum FfxBackbufferTransferFunction {
|
||||
FFX_BACKBUFFER_TRANSFER_FUNCTION_SRGB,
|
||||
FFX_BACKBUFFER_TRANSFER_FUNCTION_PQ,
|
||||
FFX_BACKBUFFER_TRANSFER_FUNCTION_SCRGB
|
||||
} FfxBackbufferTransferFunction;
|
||||
|
||||
/// A typedef representing the graphics device.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef void* FfxDevice;
|
||||
|
||||
typedef void* FfxCommandQueue;
|
||||
|
||||
typedef void* FfxSwapchain;
|
||||
|
||||
/// A typedef representing a command list or command buffer.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef void* FfxCommandList;
|
||||
|
||||
/// A typedef for a root signature.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef void* FfxRootSignature;
|
||||
|
||||
/// A typedef for a command signature, used for indirect workloads
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef void* FfxCommandSignature;
|
||||
|
||||
/// A typedef for a pipeline state object.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef void* FfxPipeline;
|
||||
|
||||
/// A structure encapsulating a collection of device capabilities.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxDeviceCapabilities {
|
||||
|
||||
FfxShaderModel minimumSupportedShaderModel; ///< The minimum shader model supported by the device.
|
||||
uint32_t waveLaneCountMin; ///< The minimum supported wavefront width.
|
||||
uint32_t waveLaneCountMax; ///< The maximum supported wavefront width.
|
||||
bool fp16Supported; ///< The device supports FP16 in hardware.
|
||||
bool raytracingSupported; ///< The device supports ray tracing.
|
||||
} FfxDeviceCapabilities;
|
||||
|
||||
/// A structure encapsulating a 2-dimensional point, using 32bit unsigned integers.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxDimensions2D {
|
||||
|
||||
uint32_t width; ///< The width of a 2-dimensional range.
|
||||
uint32_t height; ///< The height of a 2-dimensional range.
|
||||
} FfxDimensions2D;
|
||||
|
||||
/// A structure encapsulating a 2-dimensional point.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxIntCoords2D {
|
||||
|
||||
int32_t x; ///< The x coordinate of a 2-dimensional point.
|
||||
int32_t y; ///< The y coordinate of a 2-dimensional point.
|
||||
} FfxIntCoords2D;
|
||||
|
||||
/// A structure encapsulating a 2-dimensional rect.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxRect2D
|
||||
{
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
} FfxRect2D;
|
||||
|
||||
/// A structure encapsulating a 2-dimensional set of floating point coordinates.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxFloatCoords2D {
|
||||
|
||||
float x; ///< The x coordinate of a 2-dimensional point.
|
||||
float y; ///< The y coordinate of a 2-dimensional point.
|
||||
} FfxFloatCoords2D;
|
||||
|
||||
/// A structure describing a resource.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxResourceDescription {
|
||||
|
||||
FfxResourceType type; ///< The type of the resource.
|
||||
FfxSurfaceFormat format; ///< The surface format.
|
||||
union {
|
||||
uint32_t width; ///< The width of the texture resource.
|
||||
uint32_t size; ///< The size of the buffer resource.
|
||||
};
|
||||
|
||||
union {
|
||||
uint32_t height; ///< The height of the texture resource.
|
||||
uint32_t stride; ///< The stride of the buffer resource.
|
||||
};
|
||||
|
||||
union {
|
||||
uint32_t depth; ///< The depth of the texture resource.
|
||||
uint32_t alignment; ///< The alignment of the buffer resource.
|
||||
};
|
||||
|
||||
uint32_t mipCount; ///< Number of mips (or 0 for full mipchain).
|
||||
FfxResourceFlags flags; ///< A set of <c><i>FfxResourceFlags</i></c> flags.
|
||||
FfxResourceUsage usage; ///< Resource usage flags.
|
||||
} FfxResourceDescription;
|
||||
|
||||
/// An outward facing structure containing a resource
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxResource {
|
||||
void* resource; ///< pointer to the resource.
|
||||
FfxResourceDescription description;
|
||||
FfxResourceStates state;
|
||||
wchar_t name[FFX_RESOURCE_NAME_SIZE]; ///< (optional) Resource name.
|
||||
} FfxResource;
|
||||
|
||||
/// An internal structure containing a handle to a resource and resource views
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxResourceInternal {
|
||||
int32_t internalIndex; ///< The index of the resource.
|
||||
} FfxResourceInternal;
|
||||
|
||||
/// An internal structure housing all that is needed for backend resource descriptions
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxInternalResourceDescription {
|
||||
|
||||
uint32_t id;
|
||||
const wchar_t* name;
|
||||
FfxResourceType type;
|
||||
FfxResourceUsage usage;
|
||||
FfxSurfaceFormat format;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t mipCount;
|
||||
FfxResourceFlags flags;
|
||||
uint32_t initDataSize;
|
||||
void* initData;
|
||||
} FfxInternalResourceDescription;
|
||||
|
||||
/// A structure defining the view to create
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxViewDescription
|
||||
{
|
||||
bool uavView; ///< Indicates that the view is a UAV.
|
||||
FfxResourceViewDimension viewDimension; ///< The view dimension to map
|
||||
union {
|
||||
int32_t mipLevel; ///< The mip level of the view, (-1) for default
|
||||
int32_t firstElement; ///< The first element of a buffer view, (-1) for default
|
||||
};
|
||||
|
||||
union {
|
||||
int32_t arraySize; ///< The array size of the view, (-1) for full depth/array size
|
||||
int32_t elementCount; ///< The number of elements in a buffer view, (-1) for full depth/array size
|
||||
};
|
||||
|
||||
int32_t firstSlice; ///< The first slice to map to, (-1) for default first slice
|
||||
wchar_t name[64];
|
||||
} FfxViewDescription;
|
||||
|
||||
static FfxViewDescription s_FfxViewDescInit = { false, FFX_RESOURCE_VIEW_DIMENSION_TEXTURE_2D, -1, -1, -1, L"" };
|
||||
|
||||
/// A structure defining a resource bind point
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxResourceBinding
|
||||
{
|
||||
uint32_t slotIndex;
|
||||
uint32_t resourceIdentifier;
|
||||
uint32_t bindCount;
|
||||
wchar_t name[64];
|
||||
}FfxResourceBinding;
|
||||
|
||||
/// A structure encapsulating a single pass of an algorithm.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxPipelineState {
|
||||
|
||||
FfxRootSignature rootSignature; ///< The pipelines rootSignature
|
||||
FfxCommandSignature cmdSignature; ///< The command signature used for indirect workloads
|
||||
FfxPipeline pipeline; ///< The pipeline object
|
||||
uint32_t uavTextureCount; ///< Count of Texture UAVs used in this pipeline
|
||||
uint32_t srvTextureCount; ///< Count of Texture SRVs used in this pipeline
|
||||
uint32_t srvBufferCount; ///< Count of Buffer SRV used in this pipeline
|
||||
uint32_t uavBufferCount; ///< Count of Buffer UAVs used in this pipeline
|
||||
uint32_t constCount; ///< Count of constant buffers used in this pipeline
|
||||
|
||||
FfxResourceBinding uavTextureBindings[FFX_MAX_NUM_UAVS]; ///< Array of ResourceIdentifiers bound as texture UAVs
|
||||
FfxResourceBinding srvTextureBindings[FFX_MAX_NUM_SRVS]; ///< Array of ResourceIdentifiers bound as texture SRVs
|
||||
FfxResourceBinding srvBufferBindings[FFX_MAX_NUM_SRVS]; ///< Array of ResourceIdentifiers bound as buffer SRVs
|
||||
FfxResourceBinding uavBufferBindings[FFX_MAX_NUM_UAVS]; ///< Array of ResourceIdentifiers bound as buffer UAVs
|
||||
FfxResourceBinding constantBufferBindings[FFX_MAX_NUM_CONST_BUFFERS]; ///< Array of ResourceIdentifiers bound as CBs
|
||||
} FfxPipelineState;
|
||||
|
||||
/// A structure containing the data required to create a resource.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxCreateResourceDescription {
|
||||
|
||||
FfxHeapType heapType; ///< The heap type to hold the resource, typically <c><i>FFX_HEAP_TYPE_DEFAULT</i></c>.
|
||||
FfxResourceDescription resourceDescription; ///< A resource description.
|
||||
FfxResourceStates initalState; ///< The initial resource state.
|
||||
uint32_t initDataSize; ///< Size of initial data buffer.
|
||||
void* initData; ///< Buffer containing data to fill the resource.
|
||||
const wchar_t* name; ///< Name of the resource.
|
||||
uint32_t id; ///< Internal resource ID.
|
||||
} FfxCreateResourceDescription;
|
||||
|
||||
/// A structure containing the data required to create sampler mappings
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxSamplerDescription {
|
||||
|
||||
FfxFilterType filter;
|
||||
FfxAddressMode addressModeU;
|
||||
FfxAddressMode addressModeV;
|
||||
FfxAddressMode addressModeW;
|
||||
FfxBindStage stage;
|
||||
} FfxSamplerDescription;
|
||||
|
||||
/// A structure containing the data required to create root constant buffer mappings
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxRootConstantDescription
|
||||
{
|
||||
uint32_t size;
|
||||
FfxBindStage stage;
|
||||
} FfxRootConstantDescription;
|
||||
|
||||
/// A structure containing the description used to create a
|
||||
/// <c><i>FfxPipeline</i></c> structure.
|
||||
///
|
||||
/// A pipeline is the name given to a shader and the collection of state that
|
||||
/// is required to dispatch it. In the context of the FidelityFX SDK and its architecture
|
||||
/// this means that a <c><i>FfxPipelineDescription</i></c> will map to either a
|
||||
/// monolithic object in an explicit API (such as a
|
||||
/// <c><i>PipelineStateObject</i></c> in DirectX 12). Or a shader and some
|
||||
/// ancillary API objects (in something like DirectX 11).
|
||||
///
|
||||
/// The <c><i>contextFlags</i></c> field contains a copy of the flags passed
|
||||
/// to <c><i>ffxContextCreate</i></c> via the <c><i>flags</i></c> field of
|
||||
/// the <c><i>Ffx<Effect>InitializationParams</i></c> structure. These flags are
|
||||
/// used to determine which permutation of a pipeline for a specific
|
||||
/// <c><i>Ffx<Effect>Pass</i></c> should be used to implement the features required
|
||||
/// by each application, as well as to achieve the best performance on specific
|
||||
/// target hardware configurations.
|
||||
///
|
||||
/// When using one of the provided backends for FidelityFX SDK (such as DirectX 12 or
|
||||
/// Vulkan) the data required to create a pipeline is compiled off line and
|
||||
/// included into the backend library that you are using. For cases where the
|
||||
/// backend interface is overridden by providing custom callback function
|
||||
/// implementations care should be taken to respect the contents of the
|
||||
/// <c><i>contextFlags</i></c> field in order to correctly support the options
|
||||
/// provided by the FidelityFX SDK, and achieve best performance.
|
||||
/// ///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxPipelineDescription {
|
||||
|
||||
uint32_t contextFlags; ///< A collection of <c><i>FfxInitializationFlagBits</i></c> which were passed to the context.
|
||||
const FfxSamplerDescription* samplers; ///< A collection of samplers to use when building the root signature for the pipeline
|
||||
size_t samplerCount; ///< Number of samplers to create for the pipeline
|
||||
const FfxRootConstantDescription* rootConstants; ///< A collection of root constant descriptions to use when building the root signature for the pipeline
|
||||
uint32_t rootConstantBufferCount; ///< Number of root constant buffers to create for the pipeline
|
||||
wchar_t name[64]; ///< Pipeline name with which to name the pipeline object
|
||||
FfxBindStage stage; ///< The stage(s) for which this pipeline is being built
|
||||
uint32_t indirectWorkload; ///< Whether this pipeline has an indirect workload
|
||||
FfxSurfaceFormat backbufferFormat; ///< For raster pipelines this contains the backbuffer format
|
||||
} FfxPipelineDescription;
|
||||
|
||||
/// A structure containing the data required to create a barrier
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxBarrierDescription
|
||||
{
|
||||
FfxResourceInternal resource;
|
||||
FfxBarrierType barrierType;
|
||||
FfxResourceStates currentState;
|
||||
FfxResourceStates newState;
|
||||
uint32_t subResourceID;
|
||||
} FfxBarrierDescription;
|
||||
|
||||
|
||||
/// A structure containing a constant buffer.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxConstantBuffer {
|
||||
|
||||
uint32_t num32BitEntries; ///< The size (expressed in 32-bit chunks) stored in data.
|
||||
uint32_t data[FFX_MAX_CONST_SIZE]; ///< Constant buffer data
|
||||
}FfxConstantBuffer;
|
||||
|
||||
/// A structure describing a clear render job.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxClearFloatJobDescription {
|
||||
|
||||
float color[4]; ///< The clear color of the resource.
|
||||
FfxResourceInternal target; ///< The resource to be cleared.
|
||||
} FfxClearFloatJobDescription;
|
||||
|
||||
/// A structure describing a compute render job.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxComputeJobDescription {
|
||||
|
||||
FfxPipelineState pipeline; ///< Compute pipeline for the render job.
|
||||
uint32_t dimensions[3]; ///< Dispatch dimensions.
|
||||
FfxResourceInternal cmdArgument; ///< Dispatch indirect cmd argument buffer
|
||||
uint32_t cmdArgumentOffset; ///< Dispatch indirect offset within the cmd argument buffer
|
||||
FfxResourceInternal srvTextures[FFX_MAX_NUM_SRVS]; ///< SRV texture resources to be bound in the compute job.
|
||||
wchar_t srvTextureNames[FFX_MAX_NUM_SRVS][64];
|
||||
FfxResourceInternal uavTextures[FFX_MAX_NUM_UAVS]; ///< UAV texture resources to be bound in the compute job.
|
||||
uint32_t uavTextureMips[FFX_MAX_NUM_UAVS]; ///< Mip level of UAV texture resources to be bound in the compute job.
|
||||
wchar_t uavTextureNames[FFX_MAX_NUM_UAVS][64];
|
||||
FfxResourceInternal srvBuffers[FFX_MAX_NUM_SRVS]; ///< SRV buffer resources to be bound in the compute job.
|
||||
wchar_t srvBufferNames[FFX_MAX_NUM_SRVS][64];
|
||||
FfxResourceInternal uavBuffers[FFX_MAX_NUM_UAVS]; ///< UAV buffer resources to be bound in the compute job.
|
||||
wchar_t uavBufferNames[FFX_MAX_NUM_UAVS][64];
|
||||
FfxConstantBuffer cbs[FFX_MAX_NUM_CONST_BUFFERS]; ///< Constant buffers to be bound in the compute job.
|
||||
wchar_t cbNames[FFX_MAX_NUM_CONST_BUFFERS][64];
|
||||
} FfxComputeJobDescription;
|
||||
|
||||
typedef struct FfxRasterJobDescription
|
||||
{
|
||||
FfxPipelineState pipeline; ///< Raster pipeline for the render job.
|
||||
uint32_t numVertices;
|
||||
FfxResourceInternal renderTarget;
|
||||
|
||||
FfxResourceInternal srvTextures[FFX_MAX_NUM_SRVS]; ///< SRV resources to be bound in the compute job.
|
||||
wchar_t srvTextureNames[FFX_MAX_NUM_SRVS][64];
|
||||
FfxResourceInternal uavTextures[FFX_MAX_NUM_UAVS]; ///< UAV resources to be bound in the compute job.
|
||||
uint32_t uavTextureMips[FFX_MAX_NUM_UAVS]; ///< Mip level of UAV resources to be bound in the compute job.
|
||||
wchar_t uavTextureNames[FFX_MAX_NUM_UAVS][64];
|
||||
FfxConstantBuffer cbs[FFX_MAX_NUM_CONST_BUFFERS]; ///< Constant buffers to be bound in the compute job.
|
||||
wchar_t cbNames[FFX_MAX_NUM_CONST_BUFFERS][64];
|
||||
} FfxRasterJobDescription;
|
||||
|
||||
/// A structure describing a copy render job.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxCopyJobDescription
|
||||
{
|
||||
FfxResourceInternal src; ///< Source resource for the copy.
|
||||
FfxResourceInternal dst; ///< Destination resource for the copy.
|
||||
} FfxCopyJobDescription;
|
||||
|
||||
/// A structure describing a single render job.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxGpuJobDescription{
|
||||
|
||||
FfxGpuJobType jobType; ///< Type of the job.
|
||||
|
||||
union {
|
||||
FfxClearFloatJobDescription clearJobDescriptor; ///< Clear job descriptor. Valid when <c><i>jobType</i></c> is <c><i>FFX_RENDER_JOB_CLEAR_FLOAT</i></c>.
|
||||
FfxCopyJobDescription copyJobDescriptor; ///< Copy job descriptor. Valid when <c><i>jobType</i></c> is <c><i>FFX_RENDER_JOB_COPY</i></c>.
|
||||
FfxComputeJobDescription computeJobDescriptor; ///< Compute job descriptor. Valid when <c><i>jobType</i></c> is <c><i>FFX_RENDER_JOB_COMPUTE</i></c>.
|
||||
FfxRasterJobDescription rasterJobDescriptor;
|
||||
FfxBarrierDescription barrierDescriptor;
|
||||
};
|
||||
} FfxGpuJobDescription;
|
||||
|
||||
#if defined(POPULATE_SHADER_BLOB_FFX)
|
||||
#undef POPULATE_SHADER_BLOB_FFX
|
||||
#endif // #if defined(POPULATE_SHADER_BLOB_FFX)
|
||||
|
||||
/// Macro definition to copy header shader blob information into its SDK structural representation
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
#define POPULATE_SHADER_BLOB_FFX(info, index) \
|
||||
{ \
|
||||
info[index].blobData, info[index].blobSize, info[index].numConstantBuffers, info[index].numSRVTextures, info[index].numUAVTextures, \
|
||||
info[index].numSRVBuffers, info[index].numUAVBuffers, info[index].numSamplers, info[index].numRTAccelerationStructures, \
|
||||
info[index].constantBufferNames, \
|
||||
info[index].constantBufferBindings, info[index].constantBufferCounts, info[index].srvTextureNames, info[index].srvTextureBindings, \
|
||||
info[index].srvTextureCounts, info[index].uavTextureNames, info[index].uavTextureBindings, info[index].uavTextureCounts, \
|
||||
info[index].srvBufferNames, info[index].srvBufferBindings, info[index].srvBufferCounts, \
|
||||
info[index].uavBufferNames, info[index].uavBufferBindings, info[index].uavBufferCounts, info[index].samplerNames, \
|
||||
info[index].samplerBindings, info[index].samplerCounts, info[index].rtAccelerationStructureNames, info[index].rtAccelerationStructureBindings, \
|
||||
info[index].rtAccelerationStructureCounts \
|
||||
}
|
||||
|
||||
// A single shader blob and a description of its resources.
|
||||
///
|
||||
/// @ingroup SDKTypes
|
||||
typedef struct FfxShaderBlob {
|
||||
|
||||
const uint8_t* data; // A pointer to the blob
|
||||
const uint32_t size; // Size in bytes.
|
||||
|
||||
const uint32_t cbvCount; // Number of CBs.
|
||||
const uint32_t srvTextureCount; // Number of SRV Textures.
|
||||
const uint32_t uavTextureCount; // Number of UAV Textures.
|
||||
const uint32_t srvBufferCount; // Number of SRV Buffers.
|
||||
const uint32_t uavBufferCount; // Number of UAV Buffers.
|
||||
const uint32_t samplerCount; // Number of Samplers.
|
||||
const uint32_t rtAccelStructCount; // Number of RT Acceleration structures.
|
||||
|
||||
// constant buffers
|
||||
const char** boundConstantBufferNames;
|
||||
const uint32_t* boundConstantBuffers; // Pointer to an array of bound ConstantBuffers.
|
||||
const uint32_t* boundConstantBufferCounts; // Pointer to an array of bound ConstantBuffer resource counts
|
||||
|
||||
// srv textures
|
||||
const char** boundSRVTextureNames;
|
||||
const uint32_t* boundSRVTextures; // Pointer to an array of bound SRV resources.
|
||||
const uint32_t* boundSRVTextureCounts; // Pointer to an array of bound SRV resource counts
|
||||
|
||||
// uav textures
|
||||
const char** boundUAVTextureNames;
|
||||
const uint32_t* boundUAVTextures; // Pointer to an array of bound UAV texture resources.
|
||||
const uint32_t* boundUAVTextureCounts; // Pointer to an array of bound UAV texture resource counts
|
||||
|
||||
// srv buffers
|
||||
const char** boundSRVBufferNames;
|
||||
const uint32_t* boundSRVBuffers; // Pointer to an array of bound SRV buffer resources.
|
||||
const uint32_t* boundSRVBufferCounts; // Pointer to an array of bound SRV buffer resource counts
|
||||
|
||||
// uav buffers
|
||||
const char** boundUAVBufferNames;
|
||||
const uint32_t* boundUAVBuffers; // Pointer to an array of bound UAV buffer resources.
|
||||
const uint32_t* boundUAVBufferCounts; // Pointer to an array of bound UAV buffer resource counts
|
||||
|
||||
// samplers
|
||||
const char** boundSamplerNames;
|
||||
const uint32_t* boundSamplers; // Pointer to an array of bound sampler resources.
|
||||
const uint32_t* boundSamplerCounts; // Pointer to an array of bound sampler resource counts
|
||||
|
||||
// rt acceleration structures
|
||||
const char** boundRTAccelerationStructureNames;
|
||||
const uint32_t* boundRTAccelerationStructures; // Pointer to an array of bound UAV buffer resources.
|
||||
const uint32_t* boundRTAccelerationStructureCounts; // Pointer to an array of bound UAV buffer resource counts
|
||||
|
||||
} FfxShaderBlob;
|
||||
|
||||
typedef struct FfxPresentCallbackDescription
|
||||
{
|
||||
FfxDevice device;
|
||||
FfxCommandList commandList;
|
||||
FfxResource currentBackBuffer;
|
||||
FfxResource currentUI;
|
||||
FfxResource outputSwapChainBuffer;
|
||||
bool isInterpolatedFrame;
|
||||
} FfxPresentCallbackDescription;
|
||||
|
||||
typedef struct FfxFrameGenerationDispatchDescription {
|
||||
FfxCommandList commandList;
|
||||
FfxResource presentColor;
|
||||
FfxResource outputs[4];
|
||||
uint32_t numInterpolatedFrames;
|
||||
bool reset;
|
||||
FfxBackbufferTransferFunction backBufferTransferFunction;
|
||||
float minMaxLuminance[2];
|
||||
} FfxFrameGenerationDispatchDescription;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // #ifdef __cplusplus
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <FidelityFX/host/ffx_types.h>
|
||||
|
||||
/// @defgroup Utils Utilities
|
||||
/// Utility Macros used by the FidelityFX SDK
|
||||
///
|
||||
/// @ingroup ffxHost
|
||||
|
||||
/// The value of Pi.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
const float FFX_PI = 3.141592653589793f;
|
||||
|
||||
/// An epsilon value for floating point numbers.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
const float FFX_EPSILON = 1e-06f;
|
||||
|
||||
/// Helper macro to create the version number.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_MAKE_VERSION(major, minor, patch) ((major << 22) | (minor << 12) | patch)
|
||||
|
||||
///< Use this to specify no version.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_UNSPECIFIED_VERSION 0xFFFFAD00
|
||||
|
||||
/// Helper macro to avoid warnings about unused variables.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_UNUSED(x) ((void)(x))
|
||||
|
||||
/// Helper macro to align an integer to the specified power of 2 boundary
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_ALIGN_UP(x, y) (((x) + ((y)-1)) & ~((y)-1))
|
||||
|
||||
/// Helper macro to check if a value is aligned.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_IS_ALIGNED(x) (((x) != 0) && ((x) & ((x)-1)))
|
||||
|
||||
/// Helper macro to compute the rounded-up integer division of two unsigned integers
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_DIVIDE_ROUNDING_UP(x, y) ((x + y - 1) / y)
|
||||
|
||||
/// Helper macro to stringify a value.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_STR(s) FFX_XSTR(s)
|
||||
#define FFX_XSTR(s) #s
|
||||
|
||||
/// Helper macro to forward declare a structure.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_FORWARD_DECLARE(x) typedef struct x x
|
||||
|
||||
/// Helper macro to return the maximum of two values.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_MAXIMUM(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
/// Helper macro to return the minimum of two values.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_MINIMUM(x, y) (((x) < (y)) ? (x) : (y))
|
||||
|
||||
/// Helper macro to do safe free on a pointer.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_SAFE_FREE(x) \
|
||||
if (x) \
|
||||
free(x)
|
||||
|
||||
/// Helper macro to return the abs of an integer value.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_ABSOLUTE(x) (((x) < 0) ? (-(x)) : (x))
|
||||
|
||||
/// Helper macro to return sign of a value.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_SIGN(x) (((x) < 0) ? -1 : 1)
|
||||
|
||||
/// Helper macro to work out the number of elements in an array.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_ARRAY_ELEMENTS(x) (int32_t)((sizeof(x) / sizeof(0 [x])) / ((size_t)(!(sizeof(x) % sizeof(0 [x])))))
|
||||
|
||||
/// The maximum length of a path that can be specified to the FidelityFX API.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_MAXIMUM_PATH (260)
|
||||
|
||||
/// Helper macro to check if the specified key is set in a bitfield.
|
||||
///
|
||||
/// @ingroup Utils
|
||||
#define FFX_CONTAINS_FLAG(options, key) ((options & key) == key)
|
||||
@@ -11,7 +11,7 @@ add_executable(hook-harness main.cpp proxy_swapchain.h)
|
||||
# --probe-upscaler-resolve calls the OVERLAY'S resolver, not a copy of it, or it
|
||||
# would prove a fact about GetProcAddress.
|
||||
target_link_libraries(hook-harness PRIVATE FrameLedger.Shm fl_dxgi_vtable fl_native_flags fl_streamline_headers
|
||||
fl_fidelityfx_headers)
|
||||
fl_fidelityfx_headers fl_fsr3_host_headers)
|
||||
target_include_directories(hook-harness PRIVATE "${CMAKE_SOURCE_DIR}/FrameLedger.Overlay/include")
|
||||
target_compile_definitions(hook-harness PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
|
||||
|
||||
@@ -30,6 +30,8 @@ target_compile_definitions(hook-harness PRIVATE
|
||||
FL_STUB_FFX_UPSCALER=L"$<TARGET_FILE:fl_stub_ffx_upscaler>"
|
||||
FL_STUB_FFX_FG=L"$<TARGET_FILE:fl_stub_ffx_fg>"
|
||||
FL_STUB_FFX_LOADER=L"$<TARGET_FILE:fl_stub_ffx_loader>"
|
||||
# The FSR 3.0 host stand-in (ffx_fsr3_x64.dll), same rule.
|
||||
FL_STUB_FFX_FSR3_HOST=L"$<TARGET_FILE:fl_stub_ffx_fsr3_host>"
|
||||
# Shared with fl_guard_test from src/native/CMakeLists.txt, so the fixture and
|
||||
# the assertion cannot hold different numbers.
|
||||
FL_TAGGED_RENDER_W=${FL_TAGGED_RENDER_W}
|
||||
@@ -39,7 +41,7 @@ target_compile_definitions(hook-harness PRIVATE
|
||||
FL_DXR_DISPATCH_D=${FL_DXR_DISPATCH_D}
|
||||
)
|
||||
add_dependencies(hook-harness fl_stub_sl_interposer fl_stub_sl_common fl_stub_sl_interposer_v1
|
||||
fl_stub_ffx_dx12 fl_stub_ffx_upscaler fl_stub_ffx_fg fl_stub_ffx_loader)
|
||||
fl_stub_ffx_dx12 fl_stub_ffx_upscaler fl_stub_ffx_fg fl_stub_ffx_loader fl_stub_ffx_fsr3_host)
|
||||
|
||||
# WARP + CreateSwapChainForComposition means no GPU and no HWND are needed, so
|
||||
# these run on a hosted CI runner — which is what 20_OPEN_QUESTIONS §H4 said
|
||||
|
||||
@@ -67,13 +67,16 @@
|
||||
// an FSR title does: one UPSCALE and one PREPARE (issued twice,
|
||||
// same frameID) per application frame, one FRAMEGENERATION per
|
||||
// frame at K > 1, then K presents (--presents-per-eval K)
|
||||
// --ffx-topology 1x|2x|ue
|
||||
// --ffx-topology 1x|2x|ue|fsr3host|fsr3host+mono
|
||||
// which vendor shape --hold-presenting-ffx stands in: 2x (default)
|
||||
// is the SDK 2.x pair of effect DLLs behind the LOADER (the game
|
||||
// calls the loader; the loader forwards NOT through the leaves'
|
||||
// exports -- measured), 1x the SDK 1.1.x monolith sending the
|
||||
// pre-V2 PREPARE, ue the UE5 shape: the two effect DLLs called
|
||||
// directly, no loader
|
||||
// directly, no loader; fsr3host the FSR 3.0 HOST DLL alone
|
||||
// (ffx_fsr3_x64.dll!ffxFsr3ContextDispatchUpscale, no PREPARE,
|
||||
// no frame generation), fsr3host+mono Cyberpunk's shape: the host
|
||||
// upscales while the 1.1.x monolith prepares and generates
|
||||
// --ffx-no-prepare drop the PREPARE dispatch: the frame-generation-OFF shape, where
|
||||
// the Overlay must count UPSCALE dispatches instead
|
||||
//
|
||||
@@ -112,6 +115,12 @@
|
||||
#include <ffx_api.h>
|
||||
#include <ffx_framegeneration.h>
|
||||
#include <ffx_upscale.h>
|
||||
// And the FSR 3.0 HOST API (tag fsr3-v3.0.4), for the descriptor the fsr3host
|
||||
// topologies build and the type of the export they call on the host stub. Inside a
|
||||
// namespace, as the Overlay includes it: both trees define FfxFrameGenerationConfig.
|
||||
namespace fsr3host {
|
||||
#include <FidelityFX/host/ffx_fsr3.h>
|
||||
} // namespace fsr3host
|
||||
|
||||
#pragma comment(lib, "d3d11.lib")
|
||||
#pragma comment(lib, "d3d12.lib")
|
||||
@@ -2210,6 +2219,51 @@ bool ProbeFfxResolve() {
|
||||
Check(exportsUp() == 0u && exportsFg() == 0u,
|
||||
"neither leaf's EXPORT was entered by the forward - the loader reached the direct entry, as the real "
|
||||
"one was measured to bypass the leaf exports");
|
||||
|
||||
// THE FSR 3.0 HOST, the fifth module: its own export, resolved by ITS name through
|
||||
// the host ABI arm, and the negatives that keep it from being mistaken for a leaf.
|
||||
std::printf("\n[ffx] the FSR 3.0 host facade: resolved by name through its own ABI arm, and not a leaf\n");
|
||||
const HMODULE host = LoadStubExactly(FL_STUB_FFX_FSR3_HOST);
|
||||
Check(host != nullptr, "the ffx_fsr3_x64.dll host stub loaded from its absolute path");
|
||||
if (host == nullptr) {
|
||||
return false;
|
||||
}
|
||||
Check(fl::inventory::SpeaksFsr3Host(host), "the host stub speaks the four FSR 3.0 host names");
|
||||
Check(!fl::inventory::SpeaksFsr3Host(decoy), "the sl.common.dll decoy does not");
|
||||
Check(!fl::inventory::SpeaksFsr3Host(monolith),
|
||||
"and neither does the 1.1.x monolith - the host's names are its own, so a monolith of the wrong NAME cannot "
|
||||
"pass the host arm");
|
||||
Check(!fl::inventory::SpeaksFfxApi(host), "the host does not speak ffx-api: it exports no ffxDispatch");
|
||||
Check(fl::inventory::SpeaksExpectedAbi(fl::inventory::kModuleFfxFsr3Host, host),
|
||||
"the ABI arm approves the host by its own name");
|
||||
Check(!fl::inventory::SpeaksExpectedAbi(fl::inventory::kModuleFfxFsr3Host, monolith),
|
||||
"and refuses a module of the host's name that does not speak the host ABI");
|
||||
Check(fl::inventory::FfxLeafOf(fl::inventory::kModuleFfxFsr3Host) < 0,
|
||||
"the host is NOT a leaf slot - the installer keys it by module name");
|
||||
void* fromHost =
|
||||
fl::inventory::ResolveScoped(fl::inventory::kModuleFfxFsr3Host, fl::inventory::kSymbolFfxFsr3DispatchUpscale);
|
||||
Check(fromHost != nullptr &&
|
||||
fromHost == reinterpret_cast<void*>(GetProcAddress(host, fl::inventory::kSymbolFfxFsr3DispatchUpscale)),
|
||||
"ResolveScoped returned the host's own ffxFsr3ContextDispatchUpscale");
|
||||
Check(fl::inventory::ResolveScoped(fl::inventory::kModuleFfxFsr3Host, "ffxDispatch") == nullptr,
|
||||
"and the host has no ffxDispatch to resolve");
|
||||
// The non-row, stated at runtime as well as at compile time: the export EXISTS on the
|
||||
// module and no inventory row names it (20_OPEN_QUESTIONS §H11's reversal condition).
|
||||
Check(GetProcAddress(host, "ffxFsr3DispatchFrameGeneration") != nullptr,
|
||||
"the host exports ffxFsr3DispatchFrameGeneration");
|
||||
bool fgIsARow = false;
|
||||
bool hostIsARow = false;
|
||||
#define FL_PROBE_HOST_ROW(mod, sym, family) \
|
||||
if (std::strcmp(sym, "ffxFsr3DispatchFrameGeneration") == 0) { \
|
||||
fgIsARow = true; \
|
||||
} \
|
||||
if (_wcsicmp(mod, fl::inventory::kModuleFfxFsr3Host) == 0) { \
|
||||
hostIsARow = true; \
|
||||
}
|
||||
FL_HOOK_INVENTORY(FL_PROBE_HOST_ROW)
|
||||
#undef FL_PROBE_HOST_ROW
|
||||
Check(hostIsARow, "an FL_HOOK_INVENTORY row names ffx_fsr3_x64.dll");
|
||||
Check(!fgIsARow, "and no row names ffxFsr3DispatchFrameGeneration - deliberately (dllmain.cpp)");
|
||||
return g_failures == 0;
|
||||
}
|
||||
|
||||
@@ -2451,13 +2505,37 @@ int HoldPresentingFg(Gfx& g, int seconds, bool real, int presentsPerEval) {
|
||||
// ---------------------------------------------------------------------------
|
||||
// Which module the fixture calls: 1x = the monolith, 2x = the loader (which forwards to
|
||||
// the two leaves through their DIRECT entry, as measured), ue = the two leaves called
|
||||
// directly with no loader in the process, the UE5 shape.
|
||||
enum class FfxTopology { Monolith, Loader, Ue };
|
||||
// directly with no loader in the process, the UE5 shape, fsr3host = the FSR 3.0 HOST
|
||||
// DLL alone (its named UPSCALE export, no PREPARE, no frame generation -- the K = 1
|
||||
// double-count control for that row), fsr3host+mono = Cyberpunk 2077's measured shape:
|
||||
// the host upscales while the 1.1.x monolith prepares and generates.
|
||||
enum class FfxTopology { Monolith, Loader, Ue, Fsr3Host, Fsr3HostMonolith };
|
||||
|
||||
using PfnFsr3DispatchUpscale = decltype(&fsr3host::ffxFsr3ContextDispatchUpscale);
|
||||
|
||||
int HoldPresentingFfx(Gfx& g, int seconds, bool real, int presentsPerEval, FfxTopology topology, bool prepare) {
|
||||
HMODULE upEntry = nullptr; // where UPSCALE goes
|
||||
HMODULE fgEntry = nullptr; // where PREPARE and FRAMEGENERATION go
|
||||
if (topology == FfxTopology::Monolith) {
|
||||
HMODULE upEntry = nullptr; // where UPSCALE goes (an ffx-api module)
|
||||
HMODULE fgEntry = nullptr; // where PREPARE and FRAMEGENERATION go
|
||||
HMODULE hostEntry = nullptr; // where UPSCALE goes on the FSR 3.0 host topologies
|
||||
if (topology == FfxTopology::Fsr3Host || topology == FfxTopology::Fsr3HostMonolith) {
|
||||
hostEntry = LoadStubExactly(FL_STUB_FFX_FSR3_HOST);
|
||||
if (hostEntry == nullptr) {
|
||||
Check(false, "the ffx_fsr3_x64.dll host stub loaded for the ffx hold");
|
||||
return 1;
|
||||
}
|
||||
if (topology == FfxTopology::Fsr3HostMonolith) {
|
||||
fgEntry = LoadStubExactly(FL_STUB_FFX_DX12);
|
||||
if (fgEntry == nullptr) {
|
||||
Check(false, "the SDK 1.1.x monolith stub loaded beside the host for the ffx hold");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
// The host alone prepares nothing and generates nothing: FSR 3.0's frame
|
||||
// generation lives in ffx_frameinterpolation_x64.dll, which no row hooks. The
|
||||
// count must come from the host's UPSCALE, so PREPARE is off whatever was asked.
|
||||
prepare = false;
|
||||
}
|
||||
} else if (topology == FfxTopology::Monolith) {
|
||||
upEntry = fgEntry = LoadStubExactly(FL_STUB_FFX_DX12);
|
||||
if (upEntry == nullptr) {
|
||||
Check(false, "the SDK 1.1.x monolith stub loaded for the ffx hold");
|
||||
@@ -2489,16 +2567,30 @@ int HoldPresentingFfx(Gfx& g, int seconds, bool real, int presentsPerEval, FfxTo
|
||||
fgEntry = fg;
|
||||
}
|
||||
}
|
||||
auto dispatchUp = reinterpret_cast<PfnFfxDispatch>(reinterpret_cast<void*>(GetProcAddress(upEntry, "ffxDispatch")));
|
||||
auto dispatchFg = reinterpret_cast<PfnFfxDispatch>(reinterpret_cast<void*>(GetProcAddress(fgEntry, "ffxDispatch")));
|
||||
if (dispatchUp == nullptr || dispatchFg == nullptr) {
|
||||
Check(false, "the entry module(s) export ffxDispatch");
|
||||
auto dispatchUp =
|
||||
upEntry != nullptr
|
||||
? reinterpret_cast<PfnFfxDispatch>(reinterpret_cast<void*>(GetProcAddress(upEntry, "ffxDispatch")))
|
||||
: nullptr;
|
||||
auto dispatchFg =
|
||||
fgEntry != nullptr
|
||||
? reinterpret_cast<PfnFfxDispatch>(reinterpret_cast<void*>(GetProcAddress(fgEntry, "ffxDispatch")))
|
||||
: nullptr;
|
||||
auto dispatchHost = hostEntry != nullptr
|
||||
? reinterpret_cast<PfnFsr3DispatchUpscale>(reinterpret_cast<void*>(
|
||||
GetProcAddress(hostEntry, fl::inventory::kSymbolFfxFsr3DispatchUpscale)))
|
||||
: nullptr;
|
||||
if ((upEntry != nullptr && dispatchUp == nullptr) || (fgEntry != nullptr && dispatchFg == nullptr) ||
|
||||
(hostEntry != nullptr && dispatchHost == nullptr)) {
|
||||
Check(false, "the entry module(s) export their dispatch entry point");
|
||||
return 1;
|
||||
}
|
||||
const bool topology2x = topology != FfxTopology::Monolith;
|
||||
const char* topologyName = topology == FfxTopology::Monolith ? "SDK 1.1.x (monolith)"
|
||||
: topology == FfxTopology::Loader ? "SDK 2.x (two leaves behind the loader)"
|
||||
: "UE5 (two leaves, no loader)";
|
||||
// The pre-V2 PREPARE is the 1.1.x monolith's, on both topologies that use it.
|
||||
const bool topology2x = topology == FfxTopology::Loader || topology == FfxTopology::Ue;
|
||||
const char* topologyName = topology == FfxTopology::Monolith ? "SDK 1.1.x (monolith)"
|
||||
: topology == FfxTopology::Loader ? "SDK 2.x (two leaves behind the loader)"
|
||||
: topology == FfxTopology::Ue ? "UE5 (two leaves, no loader)"
|
||||
: topology == FfxTopology::Fsr3Host ? "FSR 3.0 host DLL alone"
|
||||
: "FSR 3.0 host DLL + SDK 1.1.x monolith";
|
||||
|
||||
const int k = presentsPerEval < 1 ? 1 : presentsPerEval;
|
||||
const UINT flags = real ? 0u : DXGI_PRESENT_TEST;
|
||||
@@ -2530,14 +2622,26 @@ int HoldPresentingFfx(Gfx& g, int seconds, bool real, int presentsPerEval, FfxTo
|
||||
gen.header.type = FFX_API_DISPATCH_DESC_TYPE_FRAMEGENERATION;
|
||||
gen.numGeneratedFrames = static_cast<uint32_t>(k - 1);
|
||||
|
||||
// The FSR 3.0 HOST descriptor, from the vendored fsr3-v3.0.4 struct: the same tagged
|
||||
// extent, in the field the Overlay pins at offset 1256. Nothing else is set, and the
|
||||
// stub reads nothing at all, so a record carrying this size proves the Overlay read it
|
||||
// off the argument.
|
||||
fsr3host::FfxFsr3DispatchUpscaleDescription hostUp{};
|
||||
hostUp.renderSize.width = kTaggedRenderW;
|
||||
hostUp.renderSize.height = kTaggedRenderH;
|
||||
|
||||
const ULONGLONG until = GetTickCount64() + static_cast<ULONGLONG>(seconds) * 1000ULL;
|
||||
long long presented = 0;
|
||||
long long frames = 0;
|
||||
uint64_t frameId = 0;
|
||||
while (GetTickCount64() < until) {
|
||||
++frameId;
|
||||
dispatchUp(nullptr, &up.header);
|
||||
if (prepare) {
|
||||
if (dispatchHost != nullptr) {
|
||||
dispatchHost(nullptr, &hostUp);
|
||||
} else {
|
||||
dispatchUp(nullptr, &up.header);
|
||||
}
|
||||
if (prepare && dispatchFg != nullptr) {
|
||||
// TWICE, SAME frameID: the SDK's own sample re-issues the prepare when its
|
||||
// configuration changes, and the vendor's contract is about the INDEX. A
|
||||
// writer that counted calls reads 2.0 at K = 1 here.
|
||||
@@ -2545,7 +2649,7 @@ int HoldPresentingFfx(Gfx& g, int seconds, bool real, int presentsPerEval, FfxTo
|
||||
dispatchFg(nullptr, &prep.header);
|
||||
dispatchFg(nullptr, &prep.header);
|
||||
}
|
||||
if (k > 1) {
|
||||
if (k > 1 && dispatchFg != nullptr) {
|
||||
gen.frameID = frameId;
|
||||
dispatchFg(nullptr, &gen.header);
|
||||
}
|
||||
@@ -2669,9 +2773,11 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
} else if (std::strcmp(argv[i], "--ffx-topology") == 0 && i + 1 < argc) {
|
||||
const char* t = argv[++i];
|
||||
ffxTopology = std::strcmp(t, "1x") == 0 ? FfxTopology::Monolith
|
||||
: std::strcmp(t, "ue") == 0 ? FfxTopology::Ue
|
||||
: FfxTopology::Loader;
|
||||
ffxTopology = std::strcmp(t, "1x") == 0 ? FfxTopology::Monolith
|
||||
: std::strcmp(t, "ue") == 0 ? FfxTopology::Ue
|
||||
: std::strcmp(t, "fsr3host") == 0 ? FfxTopology::Fsr3Host
|
||||
: std::strcmp(t, "fsr3host+mono") == 0 ? FfxTopology::Fsr3HostMonolith
|
||||
: FfxTopology::Loader;
|
||||
} else if (std::strcmp(argv[i], "--ffx-no-prepare") == 0) {
|
||||
ffxPrepare = false;
|
||||
} else if (std::strcmp(argv[i], "--sl-tag-for-frame") == 0) {
|
||||
|
||||
@@ -23,7 +23,7 @@ function(fl_add_vendor_stub target output source)
|
||||
# supply the vendor signatures so the stub and the detour cannot disagree about
|
||||
# the ABI. Both are INTERFACE include targets and link nothing.
|
||||
target_link_libraries(${target} PRIVATE FrameLedger.Shm fl_native_flags fl_streamline_headers
|
||||
fl_fidelityfx_headers)
|
||||
fl_fidelityfx_headers fl_fsr3_host_headers)
|
||||
target_include_directories(${target} PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}/FrameLedger.Overlay/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
@@ -75,3 +75,12 @@ fl_add_vendor_stub(fl_stub_ffx_dx12 "amd_fidelityfx_dx12" stub_amd_fidelityfx_dx
|
||||
fl_add_vendor_stub(fl_stub_ffx_upscaler "amd_fidelityfx_upscaler_dx12" stub_amd_fidelityfx_upscaler_dx12.cpp)
|
||||
fl_add_vendor_stub(fl_stub_ffx_fg "amd_fidelityfx_framegeneration_dx12" stub_amd_fidelityfx_framegeneration_dx12.cpp)
|
||||
fl_add_vendor_stub(fl_stub_ffx_loader "amd_fidelityfx_loader_dx12" stub_amd_fidelityfx_loader_dx12.cpp)
|
||||
|
||||
# --- AMD FidelityFX, the FSR 3.0 HOST API (Cyberpunk 2077's ffx_fsr3_x64.dll) ---
|
||||
#
|
||||
# NOT A LEAF: named exports, the 3.0 host's own descriptor, one row
|
||||
# (ffxFsr3ContextDispatchUpscale). Exports exactly the four names SpeaksFsr3Host
|
||||
# probes for, through the vendored header's own FFX_API (dllexport, no switch) -- and
|
||||
# is therefore hookinventory-check Pass C's SECOND positive control for the export
|
||||
# parser, beside the ffx-api leaf.
|
||||
fl_add_vendor_stub(fl_stub_ffx_fsr3_host "ffx_fsr3_x64" stub_ffx_fsr3_x64.cpp)
|
||||
@@ -0,0 +1,81 @@
|
||||
// A stub that answers to the name `ffx_fsr3_x64.dll` -- the FSR 3.0 HOST DLL Cyberpunk
|
||||
// 2077 ships beside its 1.1.x monolith -- and exports the four names
|
||||
// fl::inventory::SpeaksFsr3Host probes for, one of which is the row the Overlay hooks.
|
||||
//
|
||||
// NOT A LEAF: it exports no ffxDispatch and shares nothing with stub_ffx_leaf.inl. The
|
||||
// one export the Overlay detours takes the host API's own descriptor, whose renderSize
|
||||
// sits 1256 bytes in; the stub reads none of it, so renderW/H in a record can only have
|
||||
// come from the Overlay reading the argument.
|
||||
//
|
||||
// THE SIGNATURES AND THE EXPORT LINKAGE COME FROM THE VENDORED MIT HEADER (tag
|
||||
// fsr3-v3.0.4). FFX_API there is __declspec(dllexport) with no switch, so defining
|
||||
// the function here exports it under exactly the declaration the Overlay's detour is
|
||||
// typed by -- and the same header, included by FrameLedger.Overlay for types only,
|
||||
// exports nothing there because nothing there defines these names. This DLL is Pass C's
|
||||
// second positive control: its export table MUST show ffxFsr3ContextDispatchUpscale.
|
||||
|
||||
#include <FidelityFX/host/ffx_fsr3.h>
|
||||
|
||||
#include "stub_common.h"
|
||||
|
||||
static_assert(
|
||||
fl::stub::InventoryHasRow(fl::inventory::kModuleFfxFsr3Host, fl::inventory::kSymbolFfxFsr3DispatchUpscale),
|
||||
"fl_hook_inventory.h has no ffxFsr3ContextDispatchUpscale row for ffx_fsr3_x64.dll, so this fixture would "
|
||||
"exercise a name the Overlay does not install");
|
||||
static_assert(
|
||||
!fl::stub::InventoryHas("ffxFsr3DispatchFrameGeneration"),
|
||||
"ffxFsr3DispatchFrameGeneration is deliberately NOT a row (dllmain.cpp, fl_hook_inventory.h): on the one "
|
||||
"title that ships the host DLL frame generation goes through the monolith, and the pre-committed reversal "
|
||||
"condition in 20_OPEN_QUESTIONS §H11 has not fired");
|
||||
static_assert(!fl::stub::InventoryHas("ffxFsr3SkipPresent"), "probe-only, never a row");
|
||||
|
||||
namespace {
|
||||
|
||||
volatile LONG g_upscales = 0;
|
||||
volatile LONG g_contexts = 0;
|
||||
|
||||
} // namespace
|
||||
|
||||
extern "C" {
|
||||
|
||||
FFX_API FfxErrorCode ffxFsr3ContextCreate(FfxFsr3Context* context, FfxFsr3ContextDescription* contextDescription) {
|
||||
if (context == nullptr || contextDescription == nullptr) {
|
||||
return FFX_ERROR_INVALID_POINTER;
|
||||
}
|
||||
InterlockedIncrement(&g_contexts);
|
||||
return FFX_OK;
|
||||
}
|
||||
|
||||
// THE ROW'S TARGET. Counts the call and reads nothing of the descriptor.
|
||||
FFX_API FfxErrorCode ffxFsr3ContextDispatchUpscale(FfxFsr3Context* context,
|
||||
const FfxFsr3DispatchUpscaleDescription* dispatchParams) {
|
||||
(void)context;
|
||||
if (dispatchParams == nullptr) {
|
||||
return FFX_ERROR_INVALID_POINTER;
|
||||
}
|
||||
InterlockedIncrement(&g_upscales);
|
||||
return FFX_OK;
|
||||
}
|
||||
|
||||
FFX_API FfxErrorCode ffxFsr3DispatchFrameGeneration(const FfxFrameGenerationDispatchDescription* desc) {
|
||||
return desc != nullptr ? FFX_OK : FFX_ERROR_INVALID_POINTER;
|
||||
}
|
||||
|
||||
FFX_API FfxErrorCode ffxFsr3SkipPresent(FfxFsr3Context* context) {
|
||||
(void)context;
|
||||
return FFX_OK;
|
||||
}
|
||||
|
||||
// FrameLedger-named observer, so nothing here pretends to be part of a vendor API.
|
||||
__declspec(dllexport) unsigned int FlStubFsr3UpscaleCalls() {
|
||||
return static_cast<unsigned int>(InterlockedCompareExchange(&g_upscales, 0, 0));
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID) {
|
||||
if (reason == DLL_PROCESS_ATTACH) {
|
||||
DisableThreadLibraryCalls(module);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -162,7 +162,31 @@ public sealed class FfxReportTests
|
||||
FfxCensus c = FfxCensus.From(stream);
|
||||
|
||||
c.SawAnything.Should().BeFalse();
|
||||
c.Describe().Should().Contain("no UPSCALE or FRAMEGENERATION dispatch reached an ffx-api leaf");
|
||||
c.Describe().Should().Contain("no UPSCALE or FRAMEGENERATION dispatch reached an ffx-api leaf or the FSR 3.0 host facade");
|
||||
FfxCensus.From([]).Describe().Should().Contain("no record claimed FL_MEASURED_UPSCALER");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CyberpunkAtFsr3PrintsFsr3IdentityFromTheHostRouteBesideTheMonolithsFrameGeneration()
|
||||
{
|
||||
// Cyberpunk 2077's measured shape (2026-09-04, §H11): the FSR 3.0 HOST DLL upscales through its
|
||||
// named export while the 1.1.x monolith generates through ffxDispatch. The writer's records are
|
||||
// the same shape as any FSR route's -- identity FSR3 on the present that drained the host's
|
||||
// UPSCALE, FsrFg on the one that drained the monolith's FRAMEGENERATION -- and the report
|
||||
// prints the trio at ×2 with no WARNING. Before the host row this title printed `upscaler: N/A`.
|
||||
List<FlFrameRecord> stream = FfxStream(frames: 50, k: 2, FlUpscaler.Fsr3, fgDispatch: true);
|
||||
|
||||
(MeasuredFacts facts, string text) = Render(stream, Writer(FlRuntimeCensus.FfxFsr3 | FlRuntimeCensus.FfxFsr3Upscaler
|
||||
| FlRuntimeCensus.FfxFrameInterpolation | FlRuntimeCensus.AmdFfxDx12));
|
||||
|
||||
facts.Upscaler.Should().Be("Fsr3");
|
||||
facts.FgMode.Should().Be("FsrFg");
|
||||
facts.FgFactor.Should().BeApproximately(2.0, 0.05);
|
||||
text.Should().Contain("upscaler: Fsr3");
|
||||
text.Should().Contain("frame generation: FsrFg");
|
||||
text.Should().Contain("x2 FG");
|
||||
text.Should().NotContain("WARNING");
|
||||
text.Should().NotContain("upscaler: N/A");
|
||||
FfxCensus.From(stream).Describe().Should().Contain("presents/frame=2.00");
|
||||
}
|
||||
}
|
||||
@@ -503,6 +503,21 @@ elseif ($violations.Count -eq 0) {
|
||||
$violations.Add("Pass C: the export parser did not see ffxDispatch on the leaf fixture $($leafStub.FullName), so it reads nothing - refusing rather than reporting a clean export table nobody parsed")
|
||||
}
|
||||
}
|
||||
# A SECOND positive control, on the other vendor macro: the FSR 3.0 host fixture
|
||||
# defines ffxFsr3ContextDispatchUpscale through fsr3-v3.0.4's FFX_API
|
||||
# (dllexport, no switch). Two fixtures through two macros, so a parser that
|
||||
# happened to see one linkage shape is not taken as seeing exports in general.
|
||||
$hostStub = Get-ChildItem $BuildDir -Recurse -Filter 'ffx_fsr3_x64.dll' -ErrorAction SilentlyContinue |
|
||||
Select-Object -First 1
|
||||
if (-not $hostStub) {
|
||||
$violations.Add("Pass C: the ffx_fsr3_x64.dll host fixture was not found under $BuildDir, so the export parser's second positive control is missing")
|
||||
}
|
||||
else {
|
||||
$hostExports = Get-ExportName (& $dumpbin /nologo /exports $hostStub.FullName 2>&1 | Out-String)
|
||||
if ($hostExports -notcontains 'ffxFsr3ContextDispatchUpscale') {
|
||||
$violations.Add("Pass C: the export parser did not see ffxFsr3ContextDispatchUpscale on the host fixture $($hostStub.FullName)")
|
||||
}
|
||||
}
|
||||
foreach ($bad in (Get-ForbiddenExport $exports)) {
|
||||
$violations.Add("Pass C: FrameLedger.Overlay.dll EXPORTS '$bad' - the vendored headers declare these names __declspec(dllexport), and a definition in the Overlay announces a vendor API it does not implement, from inside somebody else's game")
|
||||
}
|
||||
|
||||
+49
-2
@@ -89,7 +89,14 @@ $vendored = @(
|
||||
# in the tree (845 of 845 on 2026-09-04). §2d below asserts, per vendored
|
||||
# file, that it is on that list and carries the grant inline; this row only
|
||||
# asserts the licence copy exists.
|
||||
@{ Path = 'src/native/third_party/fidelityfx'; Licence = 'fidelityfx-MIT.txt'; Name = 'AMD FidelityFX SDK headers' }
|
||||
@{ Path = 'src/native/third_party/fidelityfx'; Licence = 'fidelityfx-MIT.txt'; Name = 'AMD FidelityFX SDK headers' },
|
||||
|
||||
# AMD FidelityFX SDK -- the FSR 3.0 HOST API headers, tag fsr3-v3.0.4. A
|
||||
# DIFFERENT licence shape from the row above: a root LICENSE.txt that IS the
|
||||
# MIT grant verbatim, with every header carrying it inline -- which is why
|
||||
# the directory is separate and §2e below (not §2d) walks it. The same MIT
|
||||
# text from the same project, so the same legal/licenses copy is the notice.
|
||||
@{ Path = 'src/native/third_party/fidelityfx-fsr3'; Licence = 'fidelityfx-MIT.txt'; Name = 'AMD FidelityFX SDK 3.0 host headers' }
|
||||
)
|
||||
|
||||
$licenceDir = Join-Path $RepoRoot 'legal/licenses'
|
||||
@@ -262,6 +269,43 @@ if (Test-Path $ffxDir) {
|
||||
}
|
||||
}
|
||||
|
||||
# --- 2e. AMD FidelityFX, the FSR 3.0 HOST API at tag fsr3-v3.0.4: MIT at the root
|
||||
# AND inline, asserted file by file ----------------------------------------------
|
||||
#
|
||||
# A DIFFERENT SHAPE FROM §2d, which is why it is a different directory and a
|
||||
# different section rather than a second walk of the same one: at this tag the
|
||||
# root LICENSE.txt IS the MIT grant (no exception list to look a path up in), and
|
||||
# every header carries the same grant in its own banner. So the per-file question
|
||||
# is "does THIS header carry the grant", and the per-directory question is "is the
|
||||
# root grant present" -- both asserted, because a re-sync from a later tag would
|
||||
# bring the 2.x exception-list shape in under this directory's name and §2d would
|
||||
# never look here.
|
||||
$fsr3Dir = Join-Path $RepoRoot 'src/native/third_party/fidelityfx-fsr3'
|
||||
if (Test-Path $fsr3Dir) {
|
||||
$fsr3Licence = Join-Path $fsr3Dir 'LICENSE.txt'
|
||||
if (-not (Test-Path $fsr3Licence)) {
|
||||
$violations.Add('AMD FidelityFX 3.0 host headers are vendored but src/native/third_party/fidelityfx-fsr3/LICENSE.txt is missing — at tag fsr3-v3.0.4 that file IS the MIT grant, so nothing else can stand in for it')
|
||||
}
|
||||
elseif ((Get-Content $fsr3Licence -Raw) -notmatch 'Permission is hereby granted, free of charge') {
|
||||
$violations.Add('src/native/third_party/fidelityfx-fsr3/LICENSE.txt does not contain the MIT permission grant — if upstream changed its licensing model at this tag, re-run docs/18_GPU_VENDOR_APIS.md §Checklist rather than trusting this gate')
|
||||
}
|
||||
|
||||
$sdk = Join-Path $fsr3Dir 'sdk'
|
||||
$fsr3Files = @(if (Test-Path $sdk) { Get-ChildItem $sdk -Recurse -File -ErrorAction SilentlyContinue })
|
||||
if ($fsr3Files.Count -eq 0) {
|
||||
$violations.Add('src/native/third_party/fidelityfx-fsr3/sdk holds no files — a vendoring directory with a licence copy and nothing under it is a claim about nothing')
|
||||
}
|
||||
foreach ($f in $fsr3Files) {
|
||||
$rel = [IO.Path]::GetRelativePath($fsr3Dir, $f.FullName).Replace('\', '/')
|
||||
if ($f.Extension -ne '.h') {
|
||||
$violations.Add("fidelityfx-fsr3/$rel is a $($f.Extension) — only the host API's header declarations are vendored from this tag; binaries, sources, shaders and helpers are excluded (third_party/fidelityfx-fsr3/README.md)")
|
||||
}
|
||||
elseif (-not (Select-String -Path $f.FullName -Pattern 'Permission is hereby granted, free of charge' -Quiet)) {
|
||||
$violations.Add("fidelityfx-fsr3/$rel does not carry the MIT grant in its own banner — every one of the ten did at fsr3-v3.0.4, so this is a file that was not checked")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# --- 2c. The notices file's BUNDLING claim must match the filesystem ---------
|
||||
#
|
||||
# Every other check here is keyed on the directory a component WOULD occupy, so
|
||||
@@ -292,7 +336,10 @@ else {
|
||||
@{ Marker = 'NVIDIA NVAPI SDK'; Path = 'src/native/third_party/nvapi' },
|
||||
@{ Marker = 'Vulkan headers'; Path = 'src/native/third_party/vulkan-headers' },
|
||||
@{ Marker = 'NVIDIA Streamline'; Path = 'src/native/third_party/streamline' },
|
||||
@{ Marker = 'AMD FidelityFX'; Path = 'src/native/third_party/fidelityfx' }
|
||||
@{ Marker = 'AMD FidelityFX'; Path = 'src/native/third_party/fidelityfx' },
|
||||
# A marker the row above cannot satisfy by accident: the two directories are
|
||||
# two claims, and one row must not stand in for both.
|
||||
@{ Marker = 'FidelityFX SDK 3.0 host headers'; Path = 'src/native/third_party/fidelityfx-fsr3' }
|
||||
)
|
||||
foreach ($c in $claims) {
|
||||
$matched = @($rows | Where-Object { $_ -match [regex]::Escape($c.Marker) })
|
||||
|
||||
Reference in new issue
Block a user