Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2abd7d5a2 |
No files matched your search
@@ -19,6 +19,20 @@ GitHub release body, so a missing section will mean an empty release note.
|
||||
|
||||
### Added
|
||||
|
||||
- **DXGI's own present counter against the hook's, in the writer state and the report.** On the one shape
|
||||
where `none` is withheld (Streamline ≥ 2.8 with `sl.dlss_g.dll` loaded, Dying Light: The Beast), the
|
||||
open question was whether the closed pacer's generated presents reach DXGI through a body the inline
|
||||
patches miss or are displayed below DXGI. The Overlay now reads `IDXGISwapChain::GetLastPresentCount`
|
||||
on every hooked present of the chain it just saw (rule 4: the same object `GetDesc` is already read
|
||||
from) and publishes `dxgiPresentSamples` and `dxgiPresentsUnseen` (`FlWriterState @48/@52`, from
|
||||
`reserved[]`, no layout bump; mirror, `fl-layout-dump` and the offset asserts updated). The report prints
|
||||
`DXGI present counter: unseen=M over samples=N (r unseen per hooked present)` with the reading, and the
|
||||
withheld qualifier says which side of DXGI the generated presents fall on. `20_OPEN_QUESTIONS` §H5
|
||||
carries the rows written before the run: r ≈ 3 at ×4 means the generated presents ARE DXGI presents
|
||||
and the next PR labels a DXGI-counted Displayed rate; r ≈ 0 means below DXGI and only the kernel and
|
||||
vendor reads remain. The harness's presents are the negative control (`fl_guard` `[fg]`: zero unseen);
|
||||
the positive cannot be fixtured. `hook-harness --probe-frames` now prints the call's cost.
|
||||
|
||||
- **A stall diagnostic in the report, placed against FrameLedger's own touches on the target.** The
|
||||
owner saw Cyberpunk 2077 fall to 1 FPS for about a second under capture (2026-09-05) and the report
|
||||
could say nothing about whose it was. The capture host now records the QPC moment of every guard scan
|
||||
|
||||
@@ -135,7 +135,7 @@ Every hook must be listed here with a purpose. Anything not on this list is not
|
||||
### Presentation
|
||||
| Hook | Purpose |
|
||||
|---|---|
|
||||
| ✅ `IDXGISwapChain::Present`, `Present1` | Frame boundary, QPC, sync interval, present flags. **`DXGI_PRESENT_TEST` calls are dropped without a record** — the occlusion probe submits nothing, and a minimised game emits a stream of them (`07_IPC` §Protocol rules) |
|
||||
| ✅ `IDXGISwapChain::Present`, `Present1` | Frame boundary, QPC, sync interval, present flags. **`DXGI_PRESENT_TEST` calls are dropped without a record** — the occlusion probe submits nothing, and a minimised game emits a stream of them (`07_IPC` §Protocol rules). **Since 2026-09-05 the hook also reads `IDXGISwapChain::GetLastPresentCount` on the chain it just saw** (rule 4: the same COM object `FindOrAdd` already calls `GetDesc` on, no new hook) and publishes `dxgiPresentSamples` / `dxgiPresentsUnseen` — DXGI's count of presents on that chain that this hook never saw, the in-process half of `20_OPEN_QUESTIONS` §H5 Leg 1. One virtual call per hooked present, costed by `hook-harness --probe-frames` |
|
||||
| ✅ `IDXGISwapChain::ResizeBuffers` · ⏳ `ResizeTarget` | Output resolution changes mid-session. `ResizeBuffers` re-reads the swapchain description *after* the original returns; `ResizeTarget` is not hooked |
|
||||
| ⏳ `IDXGISwapChain::SetFullscreenState` | Fullscreen ↔ borderless transitions |
|
||||
| ⏳ `IDXGISwapChain3::SetColorSpace1` | HDR output detection. **`IDXGISwapChain3`, not 4** — 4 adds only `SetHDRMetaData` (`20_OPEN_QUESTIONS` §H9). Unbuilt, which is why `colorSpace` reads `NOT_REPORTED` and `FL_MEASURED_HDR` stays clear. **When it is built, the writer must initialise `colorSpace = FL_COLOR_SPACE_SDR` at swapchain identification** — an SDR title never calls `SetColorSpace1`, so "hook live, no call" would otherwise sit at `NOT_REPORTED` forever and HDR's definite `No` would be unreachable. DXGI documents G22/Rec.709 as the default, which makes SDR a *measured* default rather than an affirmative negative |
|
||||
|
||||
@@ -3288,6 +3288,35 @@ probe never showed a deadlock.
|
||||
> 1.67 overall, `tokens/batch 2.97`): a mixed session, refused as designed rather than averaged. **What is
|
||||
> left on NVIDIA is one thing: `upscaler: N/A` on the NGX-direct titles** — the probe above.
|
||||
>
|
||||
> **BUILT 2026-09-05, late — A1.7 promoted from "not in A1" to the in-process half of Leg 1.** The owner
|
||||
> read that Streamline ≥ 2.8 "needs `sl.interposer.dll` and `sl.common.dll` loaded before an injection
|
||||
> succeeds". Checked against the source, not the claim: the interposer's DXGI proxy
|
||||
> (`source/core/sl.interposer/d3d12/dxgiSwapchain.cpp`) is **byte-for-byte the same file at v2.7.32 and
|
||||
> v2.8.0** — plugins' before-hooks receive `m_base` and may `skip` the base call, exactly as before — and
|
||||
> 2.8's `sl.common` gains `resourceTaggingForFrame.cpp` (the `slSetTagForFrame` route #121 already hooks).
|
||||
> Injection into DL:TB already succeeds (every capture there has `streams=1`, a full `runtime census`, a
|
||||
> tag census), so "loaded before injection" is a launcher's problem, not this hook's. What 2.8 does NOT
|
||||
> show is where its closed `sl.dlss_g` pacer presents. So the Overlay now asks DXGI itself: on every hooked
|
||||
> present it reads `IDXGISwapChain::GetLastPresentCount` on the chain it just saw (rule 4: the same object
|
||||
> `FindOrAdd` already calls `GetDesc` on) and publishes two words on the 1 Hz watchdog —
|
||||
> `dxgiPresentSamples` (hooked presents that read it) and `dxgiPresentsUnseen` (presents DXGI counted
|
||||
> between two hooked ones, beyond the one seen). The report prints
|
||||
> `DXGI present counter: unseen=M over samples=N (r unseen per hooked present)` and the withheld qualifier
|
||||
> carries the reading. The harness's own presents are the negative control (`fl_guard` `[fg]`:
|
||||
> `unseen == 0`, `samples >= drained`); the positive cannot be fixtured — nothing in this repo presents
|
||||
> through a body the inline patches miss — which is why the rows below are written before the run.
|
||||
> Cost: one virtual call per hooked present, measured by `hook-harness --probe-frames` (number in the PR
|
||||
> body); `--probe-cost` is the empty-detour floor and does not include it.
|
||||
>
|
||||
> Leg 1's in-process rows, read off the new line on a DL:TB DLSS FG ×4 capture (r = unseen / samples):
|
||||
>
|
||||
> | Row | Reading | Meaning | Action |
|
||||
> |---|---|---|---|
|
||||
> | **P1-DXGI** | r ≈ 3 (×4) — `unseen ≈ 3 × samples` | the pacer presents on the SAME chain through a body the inline patches do not cover; the generated presents ARE DXGI presents | the next PR promotes `Displayed = hooked + unseen`, labelled **DXGI-counted** (a count DXGI made, not this hook), `presents/batch` from it, and `none` withdraws by count; the pacer's entry is then localised (a second `CDXGISwapChain` class, or a path that bypasses `Present`'s body) at leisure |
|
||||
> | **P3-DXGI** | r ≈ 0 | DXGI counted nothing this hook did not: the generated frames are displayed below DXGI (driver pacing / flip metering) or on an object this hook never saw | the withheld wording stays; no in-process sink exists; only PresentMon (kernel) and the NVAPI corroboration remain, and if PresentMon also reads 1× the frames never were kernel presents |
|
||||
> | **P5-DXGI** | 0 < r < 2.5, or r ≠ 0 with `streams > 1` | a mixed path or a second chain | stop and localise; the number is printed, never averaged into a factor |
|
||||
> | **P2/P4** | r ≈ 0 with ours ≈ 4× tokens, or the count itself moved | as the kernel rows say: not generating, or the title changed | the kernel rows above decide |
|
||||
>
|
||||
> Leg 1's rows (ours = `presents / span`; PM = PresentMon rows / span; C = the counter; ≈ = within 5 %):
|
||||
>
|
||||
> | Row | Reading | Meaning | Action |
|
||||
|
||||
+5
-1
@@ -766,7 +766,11 @@ Cyberpunk 2077 never chains `sl::DLSSOptions`, so 0xFF there is the title's trut
|
||||
populated without an NVIDIA-app override, the identity question has a producer that is not a
|
||||
hook and the owner decides whether `03_METRICS` gains a *driver-reported* rung (§H5 says what
|
||||
that rung may and may not claim). If it is not populated, the answer stays `N/A` and the
|
||||
session goes back to the PresentMon leg.
|
||||
session goes back to the PresentMon leg. **The in-process half of that leg is built (2026-09-05,
|
||||
late): the report's `DXGI present counter:` line on a DL:TB DLSS FG ×4 capture reads off §H5's
|
||||
`P1-DXGI` / `P3-DXGI` rows** — r ≈ 3 and the next PR labels a DXGI-counted Displayed rate, r ≈ 0
|
||||
and only PresentMon and the NVAPI read remain. The owner's "sl.common must be loaded on 2.8" lead
|
||||
was checked against the interposer source and is a launcher's concern, not this hook's (§H5).
|
||||
|
||||
#### 7b. Titles whose upscaler or frame generation is compiled into the executable
|
||||
|
||||
|
||||
@@ -139,6 +139,22 @@ internal sealed record MeasuredFacts
|
||||
/// </summary>
|
||||
public uint SlTagCensus { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="FlWriterState.DxgiPresentsUnseen"/>: presents DXGI's own counter recorded on the hooked chain(s)
|
||||
/// between two consecutive hooked presents, beyond the one the hook saw.
|
||||
/// </summary>
|
||||
public uint DxgiPresentsUnseen { get; init; }
|
||||
|
||||
/// <summary><see cref="FlWriterState.DxgiPresentSamples"/>: hooked presents on which DXGI's counter was read.</summary>
|
||||
public uint DxgiPresentSamples { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Unseen presents per hooked present, or null before the counter was read. <c>0</c> means DXGI counted nothing this
|
||||
/// hook did not; <c>≈ N−1</c> beside a withheld count is a frame-generation pacer presenting on the hooked chain
|
||||
/// through a body the inline patches do not cover — i.e. the generated presents ARE DXGI presents.
|
||||
/// </summary>
|
||||
public double? DxgiUnseenPerHookedPresent => DxgiPresentSamples > 0 ? DxgiPresentsUnseen / (double)DxgiPresentSamples : null;
|
||||
|
||||
/// <summary>
|
||||
/// The title tagged a HUD-less or UI buffer through Streamline on some route — the inputs only DLSS Frame
|
||||
/// Generation consumes (DLSS-G programming guide §5.0). Identity, never a count: the title is FEEDING frame
|
||||
@@ -272,6 +288,8 @@ internal sealed record MeasuredFacts
|
||||
NoneWithheld = withheld,
|
||||
InterposerVersion = modules?.VersionOf(_slInterposerFileName),
|
||||
SlTagCensus = writer.SlTagCensus,
|
||||
DxgiPresentsUnseen = writer.DxgiPresentsUnseen,
|
||||
DxgiPresentSamples = writer.DxgiPresentSamples,
|
||||
UpscalerHookRan = RecordWindow.ClaimedSuffixStart(
|
||||
stream, static r => ((FlMeasured)r.MeasuredMask).HasFlag(FlMeasured.Upscaler)) < stream.Count,
|
||||
FgHookRan = RecordWindow.ClaimedSuffixStart(
|
||||
|
||||
@@ -151,6 +151,14 @@ internal static class SessionReport
|
||||
+ (facts.DlssgInputsTagged
|
||||
? ". The title tagged DLSS-G inputs (HUD-less / UI) through Streamline this session — it is "
|
||||
+ "FEEDING frame generation, which is the identity; the count is still what it is"
|
||||
: "")
|
||||
+ (facts.DxgiUnseenPerHookedPresent is double unseen
|
||||
? unseen >= 0.5
|
||||
? ". DXGI's own counter on this chain saw " + unseen.ToString("0.00", CultureInfo.InvariantCulture)
|
||||
+ " present(s) per hooked present that this hook did not - the generated presents ARE DXGI presents "
|
||||
+ "reaching a body the inline patches do not cover (§H5 row P1-DXGI)"
|
||||
: ". DXGI's own counter on this chain saw nothing this hook did not - whatever generates frames presents "
|
||||
+ "below DXGI or on another object (§H5 row P3)"
|
||||
: "");
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// flag on a shipped one.
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using FrameLedger.Application.AntiCheat;
|
||||
using FrameLedger.Application.Consent;
|
||||
using FrameLedger.Application.Rules;
|
||||
@@ -250,6 +251,27 @@ internal static class Program
|
||||
// frame; a super-resolution-only title tags neither.
|
||||
HostConsole.Line($" Streamline tag census: 0x{result.WriterState.SlTagCensus:X} " +
|
||||
SlTagCensusNames.DescribeRoutes(result.WriterState.SlTagCensus));
|
||||
// DXGI's own present counter against this hook's, on the hooked chain(s): the in-process
|
||||
// answer to whether a pacer's generated presents are DXGI presents this hook misses (§H5).
|
||||
HostConsole.Line(DxgiCounterNote(result.WriterState));
|
||||
}
|
||||
|
||||
/// <summary>DXGI's counter against ours, and what a ratio means; never a count of anything by itself.</summary>
|
||||
private static string DxgiCounterNote(FlWriterState writer)
|
||||
{
|
||||
if (writer.DxgiPresentSamples == 0)
|
||||
{
|
||||
return " DXGI present counter: not read (no hooked present sampled it)";
|
||||
}
|
||||
|
||||
double per = writer.DxgiPresentsUnseen / (double)writer.DxgiPresentSamples;
|
||||
string reading = writer.DxgiPresentsUnseen == 0
|
||||
? "DXGI counted nothing this hook did not: whatever generates frames on this title presents below DXGI or on another object"
|
||||
: per >= 0.5
|
||||
? "DXGI counted presents this hook never saw on the SAME chain - a pacer presenting through a body the inline patches do not cover; the generated presents ARE DXGI presents here and this counter can count them"
|
||||
: "a few presents reached DXGI outside this hook - too few for a pacer, read the number rather than the ratio";
|
||||
return $" DXGI present counter: unseen={writer.DxgiPresentsUnseen} over samples={writer.DxgiPresentSamples} " +
|
||||
$"({per.ToString("0.00", CultureInfo.InvariantCulture)} unseen per hooked present) - {reading}";
|
||||
}
|
||||
|
||||
/// <summary>One line per census-named module the target had loaded, version and path beside it.</summary>
|
||||
|
||||
@@ -547,8 +547,18 @@ public unsafe struct FlWriterState
|
||||
/// </summary>
|
||||
public uint SlTagCensus;
|
||||
|
||||
/// <summary>
|
||||
/// Presents DXGI's own counter (<c>IDXGISwapChain::GetLastPresentCount</c>) recorded between two consecutive
|
||||
/// hooked presents on the same chain, beyond the one the hook saw — presents that reached DXGI through a body
|
||||
/// the inline patches do not cover. Watchdog-published. Took <c>reserved[0]</c> on 2026-09-05.
|
||||
/// </summary>
|
||||
public uint DxgiPresentsUnseen;
|
||||
|
||||
/// <summary>Hooked presents on which the DXGI counter was read. Took <c>reserved[1]</c> on 2026-09-05.</summary>
|
||||
public uint DxgiPresentSamples;
|
||||
|
||||
/// <summary>Must be zero; room for additive fields.</summary>
|
||||
public fixed uint Reserved[4];
|
||||
public fixed uint Reserved[2];
|
||||
|
||||
// WHY THE COUNTERS ARE PUBLISHED AT 1 Hz AND NOT ACCUMULATED HERE PER FRAME: this struct is
|
||||
// region 2, which the Overlay writes on the present path, and the regions are separate cache lines
|
||||
|
||||
@@ -291,12 +291,17 @@ void NoteFault() noexcept {
|
||||
// ---------------------------------------------------------------------------
|
||||
constexpr size_t kMaxSwapChains = 16;
|
||||
|
||||
// The last GetLastPresentCount value read at a hooked present on this chain, and whether
|
||||
// one has been read at all (fl_shm.h §dxgiPresentsUnseen). Per chain, because the
|
||||
// counter is per chain.
|
||||
struct SwapChainSlot {
|
||||
void* ptr = nullptr;
|
||||
uint32_t id = 0;
|
||||
uint16_t outW = 0;
|
||||
uint16_t outH = 0;
|
||||
uint8_t api = FL_API_UNKNOWN;
|
||||
bool haveDxgiCount = false;
|
||||
uint32_t lastDxgiCount = 0;
|
||||
};
|
||||
|
||||
// Ask the device whether it can ray-trace, once, and publish it as FlRtTier.
|
||||
@@ -917,6 +922,11 @@ static_assert(offsetof(fsr3host::FfxFsr3DispatchUpscaleDescription, renderSize)
|
||||
std::atomic<uint32_t> g_slTagTypes{0};
|
||||
std::atomic<uint32_t> g_slTagCensus{0};
|
||||
|
||||
// DXGI's own present counter against ours (fl_shm.h §dxgiPresentsUnseen): hook-local,
|
||||
// watchdog-published, monotonic.
|
||||
std::atomic<uint32_t> g_dxgiUnseen{0};
|
||||
std::atomic<uint32_t> g_dxgiSamples{0};
|
||||
|
||||
void NoteTagTypes(uint32_t typeBits, uint32_t routeShift) noexcept {
|
||||
if (typeBits == 0u) {
|
||||
return;
|
||||
@@ -1442,6 +1452,18 @@ void PublishRuntimeCensus() noexcept {
|
||||
// The tag census, on the same tick and by the same rule: OR-only, from the
|
||||
// process-local word the three tag routes accumulate into, so region 2 takes one
|
||||
// write a second rather than one per tag list (fl_shm.h §slTagCensus).
|
||||
// DXGI's counter against ours, published on the same tick. Monotonic, so a plain store
|
||||
// of the hook-local value is the whole publish.
|
||||
void PublishDxgiPresentCounters() noexcept {
|
||||
if (g_state == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::atomic_ref<uint32_t> unseen{g_state->dxgiPresentsUnseen};
|
||||
std::atomic_ref<uint32_t> samples{g_state->dxgiPresentSamples};
|
||||
unseen.store(g_dxgiUnseen.load(std::memory_order_relaxed), std::memory_order_relaxed);
|
||||
samples.store(g_dxgiSamples.load(std::memory_order_relaxed), std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
void PublishSlTagCensus() noexcept {
|
||||
if (g_state == nullptr) {
|
||||
return;
|
||||
@@ -1856,6 +1878,7 @@ DWORD WINAPI WatchdogThread(LPVOID) noexcept {
|
||||
// appeared this second is both hooked and counted in the same pass.
|
||||
PublishRuntimeCensus();
|
||||
PublishSlTagCensus();
|
||||
PublishDxgiPresentCounters();
|
||||
|
||||
// Supervision loss. guardTicks counts COMPLETED guard evaluations, not
|
||||
// seconds, so a stalled guard loop stops it advancing even while the
|
||||
@@ -1920,6 +1943,29 @@ void RecordPresent(IDXGISwapChain* sc, UINT syncInterval, UINT flags) noexcept {
|
||||
SwapChainSlot* slot = FindOrAdd(sc);
|
||||
PublishAdapterOnce(sc);
|
||||
|
||||
// DXGI'S OWN COUNT OF THIS CHAIN'S PRESENTS, read here on the object the title passed
|
||||
// (the same class of read as GetDesc above), BEFORE this present is forwarded: the
|
||||
// value is therefore the number of presents completed before this one, and the
|
||||
// delta from the previous hooked present on the same chain is 1 + whatever DXGI
|
||||
// counted that this hook never saw -- a pacer presenting through a body the inline
|
||||
// patches do not cover. A delta of exactly 1 every time says DXGI saw nothing more
|
||||
// than we did. DXGI_PRESENT_TEST presents are already filtered above and do not
|
||||
// move this counter (measured, #35), so they cannot read as unseen presents.
|
||||
if (slot != nullptr) {
|
||||
UINT dxgiCount = 0;
|
||||
if (SUCCEEDED(sc->GetLastPresentCount(&dxgiCount))) {
|
||||
if (slot->haveDxgiCount) {
|
||||
const uint32_t delta = dxgiCount - slot->lastDxgiCount;
|
||||
if (delta > 1u) {
|
||||
g_dxgiUnseen.fetch_add(delta - 1u, std::memory_order_relaxed);
|
||||
}
|
||||
}
|
||||
slot->lastDxgiCount = dxgiCount;
|
||||
slot->haveDxgiCount = true;
|
||||
g_dxgiSamples.fetch_add(1u, std::memory_order_relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
FlFrameRecord rec{};
|
||||
rec.qpc = static_cast<uint64_t>(qpc.QuadPart);
|
||||
rec.frameIndex = g_frameIndex++;
|
||||
|
||||
@@ -687,7 +687,21 @@ struct alignas(64) FlWriterState {
|
||||
// no layout bump, refused-before-read by the build-id handshake.
|
||||
uint32_t slTagCensus; // @44
|
||||
|
||||
uint32_t reserved[4]; // @48..63 must be zero; room for additive fields
|
||||
// DXGI'S OWN PRESENT COUNTER AGAINST THIS HOOK'S, on the hooked swapchain(s)
|
||||
// (2026-09-05, 20_OPEN_QUESTIONS §H5 case 3). On every present the hook sees it
|
||||
// reads IDXGISwapChain::GetLastPresentCount on the object the title passed -- the
|
||||
// same class of read as GetDesc in FindOrAdd -- and compares it with the value at
|
||||
// the previous hooked present on the same chain. Exactly one present (the previous
|
||||
// hooked one) is expected in between; every present beyond that is one DXGI
|
||||
// counted and this hook did not. A frame-generation pacer that presents on this
|
||||
// chain through a body the inline patches do not cover shows up here; one that
|
||||
// presents below DXGI, or on another object, does not. Hook-local counters,
|
||||
// watchdog-published (the region-2 cache-line rule above). Took reserved[0..1],
|
||||
// additive, no layout bump.
|
||||
uint32_t dxgiPresentsUnseen; // @48 presents DXGI counted between two hooked presents, beyond the one seen
|
||||
uint32_t dxgiPresentSamples; // @52 hooked presents on which the counter was read
|
||||
|
||||
uint32_t reserved[2]; // @56..63 must be zero; room for additive fields
|
||||
|
||||
// NOTE: there is deliberately no droppedRecords here. The writer has no
|
||||
// reader index and cannot know whether the slot it overwrites was ever
|
||||
@@ -878,7 +892,9 @@ static_assert(offsetof(FlWriterState, rtStateObjectsCreated) == 32);
|
||||
static_assert(offsetof(FlWriterState, rasterPsoCreated) == 36);
|
||||
static_assert(offsetof(FlWriterState, runtimeCensus) == 40);
|
||||
static_assert(offsetof(FlWriterState, slTagCensus) == 44);
|
||||
static_assert(offsetof(FlWriterState, reserved) == 48);
|
||||
static_assert(offsetof(FlWriterState, dxgiPresentsUnseen) == 48);
|
||||
static_assert(offsetof(FlWriterState, dxgiPresentSamples) == 52);
|
||||
static_assert(offsetof(FlWriterState, reserved) == 56);
|
||||
|
||||
static_assert(offsetof(FlControlBlock, pauseRequested) == 0);
|
||||
static_assert(offsetof(FlControlBlock, unhookRequested) == 4);
|
||||
|
||||
@@ -3175,6 +3175,8 @@ namespace {
|
||||
// What one --hold-presenting-fg run yields, drained after the identity hook is live.
|
||||
struct FgObservation {
|
||||
std::uint32_t census = 0;
|
||||
std::uint32_t dxgiUnseen = 0;
|
||||
std::uint32_t dxgiSamples = 0;
|
||||
std::size_t drained = 0;
|
||||
std::uint64_t sigma = 0; // sum of fgEvaluations over the window
|
||||
std::uint32_t hooks = 0;
|
||||
@@ -3278,6 +3280,13 @@ bool ObserveFg(int presentsPerEval, FgObservation& out) {
|
||||
}
|
||||
}
|
||||
out.hooks = st->hooksInstalledMask;
|
||||
// DXGI's counter against ours: published by the watchdog on its 1 Hz tick, so poll for
|
||||
// the samples to reach the window rather than reading the words once (HANDOFF §Traps).
|
||||
for (int i = 0; i < 80 && st->dxgiPresentSamples < out.drained; ++i) {
|
||||
Sleep(50);
|
||||
}
|
||||
out.dxgiUnseen = st->dxgiPresentsUnseen;
|
||||
out.dxgiSamples = st->dxgiPresentSamples;
|
||||
out.census = st->runtimeCensus;
|
||||
out.faults = st->faultCount;
|
||||
|
||||
@@ -3354,6 +3363,14 @@ TEST_CASE("application-frame tokens are COUNTED, and the count tracks the fixtur
|
||||
// is in this process. The second check is the one that matters: it is what
|
||||
// keeps a title with Streamline loaded and no evaluation observed from being
|
||||
// printed as "no frame-generation runtime was loaded".
|
||||
// DXGI'S COUNTER AGAINST OURS, the negative control: this fixture presents only through
|
||||
// the body the inline patch covers, so DXGI must count exactly the presents the hook
|
||||
// saw -- zero unseen -- and the counter must have been read on every hooked present.
|
||||
// A real title where DXGI counts MORE is the §H5 question this word exists to answer.
|
||||
CAPTURE(obs.dxgiUnseen);
|
||||
CAPTURE(obs.dxgiSamples);
|
||||
CHECK(obs.dxgiUnseen == 0u);
|
||||
CHECK(obs.dxgiSamples >= static_cast<std::uint32_t>(obs.drained));
|
||||
CHECK((obs.census & fl::FL_CENSUS_RAN) != 0u);
|
||||
CHECK((obs.census & fl::FL_CENSUS_SL_INTERPOSER) != 0u);
|
||||
CHECK((obs.census & fl::FL_CENSUS_FG_FAMILIES) == 0u);
|
||||
|
||||
@@ -64,7 +64,9 @@ int main() {
|
||||
Field("rasterPsoCreated", offsetof(FlWriterState, rasterPsoCreated), sizeof(uint32_t));
|
||||
Field("runtimeCensus", offsetof(FlWriterState, runtimeCensus), sizeof(uint32_t));
|
||||
Field("slTagCensus", offsetof(FlWriterState, slTagCensus), sizeof(uint32_t));
|
||||
Field("reserved", offsetof(FlWriterState, reserved), sizeof(uint32_t) * 4, true);
|
||||
Field("dxgiPresentsUnseen", offsetof(FlWriterState, dxgiPresentsUnseen), sizeof(uint32_t));
|
||||
Field("dxgiPresentSamples", offsetof(FlWriterState, dxgiPresentSamples), sizeof(uint32_t));
|
||||
Field("reserved", offsetof(FlWriterState, reserved), sizeof(uint32_t) * 2, true);
|
||||
std::printf(" ] },\n");
|
||||
|
||||
std::printf(" \"FlControlBlock\": { \"size\": %zu, \"fields\": [\n", sizeof(FlControlBlock));
|
||||
|
||||
@@ -2715,6 +2715,30 @@ bool ProbeFrameIdentity(Gfx& g) {
|
||||
Check(realIsAFrame, "a real present submits exactly one frame");
|
||||
std::printf(" %d real present(s) moved the counter by %u\n", kReal, afterReal - afterTest);
|
||||
|
||||
// The cost of asking. The Overlay reads this counter on every hooked present
|
||||
// (dllmain RecordPresent, the DXGI-counted diagnostic 20_OPEN_QUESTIONS §H5
|
||||
// A1.7), so the price of one call is part of the present hook's overhead
|
||||
// statement. A measurement, not a check: a threshold here fails on a shared
|
||||
// runner for reasons unrelated to the code (see --probe-cost).
|
||||
{
|
||||
constexpr int kCalls = 20000;
|
||||
LARGE_INTEGER f{};
|
||||
LARGE_INTEGER t0{};
|
||||
LARGE_INTEGER t1{};
|
||||
QueryPerformanceFrequency(&f);
|
||||
UINT sink = 0;
|
||||
QueryPerformanceCounter(&t0);
|
||||
for (int i = 0; i < kCalls; ++i) {
|
||||
g.swapChain1->GetLastPresentCount(&sink);
|
||||
}
|
||||
QueryPerformanceCounter(&t1);
|
||||
const double ns =
|
||||
static_cast<double>(t1.QuadPart - t0.QuadPart) * 1e9 / static_cast<double>(f.QuadPart) / kCalls;
|
||||
std::printf(" GetLastPresentCount costs %.1f ns/call (%d calls, WARP; the Overlay pays this once per hooked "
|
||||
"present)\n",
|
||||
ns, kCalls);
|
||||
}
|
||||
|
||||
// The two together are the contract. Separately, each passes against a
|
||||
// wrong writer: a writer that ignores everything satisfies the first, and
|
||||
// one that counts everything satisfies the second.
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
using System.Diagnostics;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.CaptureHost.Consume;
|
||||
using FrameLedger.Shared;
|
||||
|
||||
namespace FrameLedger.CaptureHost.Tests.Consume;
|
||||
|
||||
/// <summary>
|
||||
/// DXGI's own present counter against the hook's (<c>FlWriterState.dxgiPresentsUnseen / dxgiPresentSamples</c>,
|
||||
/// <c>20_OPEN_QUESTIONS</c> §H5 A1.7): on the withheld shape the ratio names which side of DXGI the generated
|
||||
/// presents fall on, and on every other shape it is a fact with no sentence of its own.
|
||||
/// </summary>
|
||||
public sealed class DxgiPresentCounterTests
|
||||
{
|
||||
private const FlHookFamily _countingHooks =
|
||||
FlHookFamily.Present | FlHookFamily.UpscalerIdentity | FlHookFamily.FgEvaluations;
|
||||
|
||||
private const FlRuntimeCensus _dyingLightAtDlss = FlRuntimeCensus.Ran | FlRuntimeCensus.SlInterposer
|
||||
| FlRuntimeCensus.SlDlss | FlRuntimeCensus.SlDlssG
|
||||
| FlRuntimeCensus.NvngxDlssG;
|
||||
|
||||
private static List<FlFrameRecord> Stream(int appFrames)
|
||||
{
|
||||
List<FlFrameRecord> stream = [];
|
||||
ulong qpc = 1_000_000;
|
||||
ulong step = (ulong)(Stopwatch.Frequency / 60);
|
||||
for (int f = 0; f < appFrames; f++)
|
||||
{
|
||||
stream.Add(new FlFrameRecord
|
||||
{
|
||||
Qpc = qpc,
|
||||
SwapchainId = 1,
|
||||
MeasuredMask = (ushort)(FlMeasured.OutputRes | FlMeasured.PresentArgs | FlMeasured.Fg | FlMeasured.FgCounts),
|
||||
FgEvaluations = 1,
|
||||
FgMode = (byte)FlFgMode.Unknown,
|
||||
});
|
||||
qpc += step;
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
private static RuntimeModuleSet Interposer(string version) => new(
|
||||
[new RuntimeModuleInfo("sl.interposer.dll", @"D:\Games\title\sl.interposer.dll", version.Replace('.', ','),
|
||||
Version.Parse(version))],
|
||||
Snapshots: 1, Unreadable: 0);
|
||||
|
||||
private static (MeasuredFacts Facts, string Text) Render(FlRuntimeCensus census, RuntimeModuleSet? modules,
|
||||
uint unseen, uint samples)
|
||||
{
|
||||
List<FlFrameRecord> stream = Stream(200);
|
||||
var writer = new FlWriterState
|
||||
{
|
||||
HooksInstalledMask = (uint)_countingHooks,
|
||||
RuntimeCensus = (uint)census,
|
||||
DxgiPresentsUnseen = unseen,
|
||||
DxgiPresentSamples = samples,
|
||||
};
|
||||
MeasuredFacts facts = MeasuredFacts.From(stream, writer, Stopwatch.Frequency, 0, 0,
|
||||
FgWindow.From(stream, Stopwatch.Frequency), modules);
|
||||
return (facts, SessionReport.Render(facts));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThreeUnseenPerHookedPresentOnTheWithheldShapeNamesADxgiLevelProducer()
|
||||
{
|
||||
(MeasuredFacts facts, string text) = Render(_dyingLightAtDlss, Interposer("2.8.0.0"), unseen: 600, samples: 200);
|
||||
|
||||
facts.NoneWithheld.Should().NotBeNull();
|
||||
facts.DxgiPresentsUnseen.Should().Be(600u);
|
||||
facts.DxgiPresentSamples.Should().Be(200u);
|
||||
facts.DxgiUnseenPerHookedPresent.Should().BeApproximately(3.0, 0.001);
|
||||
text.Should().Contain("`none` is WITHHELD");
|
||||
text.Should().Contain("DXGI's own counter on this chain saw 3.00 present(s) per hooked present");
|
||||
text.Should().Contain("the generated presents ARE DXGI presents");
|
||||
text.Should().Contain("§H5 row P1-DXGI");
|
||||
text.Should().NotContain("below DXGI");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZeroUnseenOnTheWithheldShapeSaysBelowDxgi()
|
||||
{
|
||||
(MeasuredFacts facts, string text) = Render(_dyingLightAtDlss, Interposer("2.8.0.0"), unseen: 0, samples: 200);
|
||||
|
||||
facts.DxgiUnseenPerHookedPresent.Should().Be(0.0);
|
||||
text.Should().Contain("`none` is WITHHELD");
|
||||
text.Should().Contain("DXGI's own counter on this chain saw nothing this hook did not");
|
||||
text.Should().Contain("§H5 row P3");
|
||||
text.Should().NotContain("ARE DXGI presents");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ACounterNeverReadIsNullAndSaysNothing()
|
||||
{
|
||||
(MeasuredFacts facts, string text) = Render(_dyingLightAtDlss, Interposer("2.8.0.0"), unseen: 0, samples: 0);
|
||||
|
||||
facts.DxgiUnseenPerHookedPresent.Should().BeNull("no hooked present read the counter");
|
||||
text.Should().Contain("`none` is WITHHELD");
|
||||
text.Should().NotContain("DXGI's own counter");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AValidatedNoneCarriesTheFactsButNoDxgiSentence()
|
||||
{
|
||||
// Cyberpunk 2077 on Streamline 2.7.1: `none` by count, never withheld, so the counter is a fact on
|
||||
// MeasuredFacts for the report's `runtime` block and not a sentence in a qualifier this shape does not print.
|
||||
(MeasuredFacts facts, string text) = Render(FlRuntimeCensus.Ran | FlRuntimeCensus.SlInterposer | FlRuntimeCensus.NvngxDlssG,
|
||||
Interposer("2.7.1.0"), unseen: 7, samples: 200);
|
||||
|
||||
facts.NoneWithheld.Should().BeNull();
|
||||
facts.FgMode.Should().Be(MeasuredFacts.FgNone);
|
||||
facts.DxgiUnseenPerHookedPresent.Should().BeApproximately(0.035, 0.001);
|
||||
text.Should().Contain("frame generation: none");
|
||||
text.Should().NotContain("DXGI's own counter");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user