Commit Graph

31 Commits

Author SHA1 Message Date
a0723a9e92 Merge pull request #671 from aslan2142/frame-pacer-bounded-queue
OLD-9189: restore old upstream PR 9189 - FramePacer: at most `latency` frames in flight while armed (mailbox replace)
2026-11-26 00:01:37 +01:00
273b3bdf9d [integration] Linux/Proton and native Windows: boot through the story load (RT-PROTON-STORY-LOAD)
One squashed commit of a fork that was developed on a Linux/Proton machine and
tested on two native Windows machines. On all of them the retail 1.0.2.1
package now launches, shows its launch movie, first-run pages and landing
prompt, runs the story load to its end with the loading slideshow drawing its
artwork, and enters the world phase. A first world frame is not verified yet.
docs/linux_proton.md has the setup, a healthy boot's timeline, the machines
and where it stops.

Runtime: frames in the title's own window; DirectStorage pinned reads,
page-list scatter/gather, BCPack and unshuffle with a locally generated
predictor file; pooled, device-local and deferred image backing for streamed
and placed textures; enhanced barriers into LAYOUT_UNDEFINED; a bindless table
that degrades instead of refusing a submission; a descriptor hash finalizer
(off until a library carries it); directly indexed heap offsets for compute
dispatches and VS/PS/GS draws; title buffer windows outside a fragmented
arena; opt-in device-local copies of streamed buffer views; write-fault
retries under the tracker lock, shared trackers and write-watched title memory
for native Windows; device-loss, compute-input and memory probes.

Translator: loop bounds at structured exits, the eight FidelityFX programs
that use a packed-dot form the disassembler skips, buffer bounds modes per
view kind, a compaction option, the hash finalizer option.

Tools and scripts: Linux boot scripts (Wine/Proton, no network), a Windows
boot script, the paired compute translation script.

No game data. AI-assisted (Claude Code and Codex agents), reviewed and booted
by people on the machines named in docs/linux_proton.md.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 11:42:12 -06:00
b464a2c529 FramePacer: at most latency frames in flight while armed (mailbox replace)
commit_present_token and note_untokened_present appended a slot for every
present, each one period after the last, so presents made with no
WaitFrameEventX between them grew the queue without limit and the next wait
blocked until the first of them was shown: at latency 2, 1000 blank presents
left 1000 frames in flight and the next wait passed 999 periods later.

A present into a full queue now replaces the newest queued frame and takes
its vblank, like a mailbox: the replaced frame is never shown (no display
statistic), the older frames keep their vblanks, and the queue never reaches
further than `latency` vblanks ahead, so the next wait passes when the oldest
frame is shown. A queue longer than a lowered latency is cut back the same
way at the next present. Presents before the event is armed stay unpaced
(old upstream PR 4419), and a frame behind a queued one still cannot be
shown at once.

frame_pacer_test: 1000 untokened presents after one wait at latency 1, 2
and 3, tokened presents beyond the latency (the older ones keep their
vblanks, the replaced one has no display statistic), the one-present-per-wait
cadence, and a lowered latency. xbox_present_test expected the blank present
after a frame at latency 1 to make 2 frames in flight; it is 1 now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 06:13:38 -05:00
a3e45fc751 Merge remote-tracking branch 'origin/pr/9740' 2026-11-23 17:24:46 -05:00
0438ee44fd xbox_present_test: open the trace capture with _wfopen_s, and check the trace-off case
Review notes on #9549: fopen warns C4996 on MSVC and narrows the temp path to
the ANSI code page, so a TEMP outside it left stderr unredirected and the test
failed with counts of 0. The capture now opens the wide path and reports
whether it redirected, which the test expects.

The comment said nothing is written with the trace off; a refused PresentX
under a capture with the trace off now checks it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-23 15:42:08 -06:00
ca9e34bd08 xbox_present_test: compare all three channels of the HDR10 swapchain, not only red
The HDR10 swapchain check compared only red, so errors confined to green or blue could pass. Compare all three
channels within one 10-bit code for either packed format and report the first mismatching sampled pixel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 14:36:47 -07:00
85441c34fb xbox_present: one [d3d12-trace] line per PresentX, with its outcome
The queue proxy's PresentX slot is past the PC chain, so nothing recorded
a present: a --trace-d3d12 run of a frame loop could not say how many
frames were presented, or whether one was refused. XboxPresentation::PresentX
now writes one line per call through d3d12_trace::result (ok or failed).

xbox_present_test captures the trace around a blank present and a refused
three-plane call and checks for exactly those two lines.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-23 15:27:18 -06:00
57c175391d Revert #2490: its console-ABI list proxy breaks run_tiny_frame (please rebase and split)
With it, d3d12_xs reads list slot 48 as the console's IASetVertexBuffers, so the PC-shaped fixture list's
ClearRenderTargetView never runs and Close fails. The branch also changes runtime/src/pe_loader.cpp and carried
committed conflict markers in docs/fssm_crosscheck.md. Its docs rows go with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 04:42:53 -05:00
bad38096fc Merge pull request #4635 from Vonsek
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:16:41 -05:00
ec719d4a58 Merge pull request #4185 from mohamedsaad.lahlou
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:12:06 -05:00
c50a702d2b Merge pull request #3925 from kotorvr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:09:36 -05:00
fa5f26db8e Merge origin/main: DXGI device fields coexist with the console-ABI device state 2026-11-22 20:39:59 -07:00
0cb7f52a0a test(runtime): require complete Xbox present readbacks 2026-11-23 03:33:22 +00:00
7cc353106f d3d12_xs: PC-shaped lists for PC callers, atomic queue layout, S_OK queue tail
Review findings from shdann's Windows run of the new console queue/list
work:

- d3d12_debug_markers (and every GPU harness compiled against the PC
  headers) drove lists through the console-shaped proxy, so PC slots past
  26 — including the PIX markers at 56-58, which have no console
  counterpart — reached unrelated console methods or were dropped.
  create_device_proxy gains console_lists: false hands the real
  (PC-shaped) list back from CreateCommandList. The GPU tests pass false;
  the title path keeps the console default.
- queue_proxy asserted E_NOTIMPL for the queue's console tail, but those
  slots deliberately answer S_OK now — frame pacing flows through them.
  The test's contract is updated; the fence tail stays refused.
- ChildProxy::queue_layout was a plain unsigned char read and written
  from many threads; it is atomic like the device-wide detection it
  caches.

xs_proxy_mock_test and loader_test pass under Wine; the modified test
objects compile clean under clang-cl. The GPU harnesses need a real
adapter — covered by shdann's Windows run.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 18:41:23 -07:00
634a62a2b5 Test that the window presenter retains its Vulkan device 2026-11-23 00:47:31 +01:00
0ee1deff2c d3d12: create_window_presenter looks behind the Xbox device proxy (D3D-414)
A title holds the Xbox-ABI proxy, and create_window_presenter looked up the
layer's device on the pointer it was given, so with the proxy it returned null
and logged nothing. It now resolves the proxy first, as the helpers around it
do, and says on stderr when it is handed a device that is neither.

xbox_present_test creates a presenter from the proxy and presents a blank
frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:27:15 +00:00
fdd6ec2d74 Merge pull request #2626 from throny 2026-11-22 16:59:27 -05:00
5c2cf9074f Merge pull request #3016 from 0xTehuti 2026-11-22 15:14:05 -05:00
b7b1ce8097 Present: a skipped present no longer leaves the old frame for read_back (TEST-378)
VulkanPresenter::submit() skips the present and returns VK_SUCCESS when the
surface is 0x0 (a minimised window, VK_KHR_win32_surface), but it left
captured_ set, so read_back() handed out the frame before it. PresentX then
succeeded and the read-back showed the previous colour: the real-time 60 Hz
loop in xbox_present_test failed its centre-pixel check whenever the window
was minimised mid-loop (Win+D during a CTest run, say). Reproduced on an
RTX 4080 by minimising at frame 10: "got 0,255,0 want 0,0,255", presented
count frozen.

Both skip paths (no swapchain at the start, and an out-of-date acquire whose
recreation finds a 0x0 surface) now clear captured_, so read_back() is false
until a frame is shown again.

The real-time loop accepts a skipped frame only while the window is iconic,
restores the window and checks the rest; a new case minimises the window on
purpose and requires PresentX S_OK, a skipped present that is not read back,
and the right colour after restoring. It fails without the runtime change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:06:51 +01:00
36343d86b1 test: prevent present and swapchain tests from stealing focus (SW_SHOWNOACTIVATE) 2026-11-22 20:07:03 +01:00
d3b774eed5 PresentX planes: tone map shoulder, SDR white query off the present path, review fixes
- Tone map: identity up to 0.8 of SDR white, extended Reinhard shoulder above it, continuous in value and slope, content
  peak maps to 1.0 (SDR-range content is no longer darkened).
- The Windows SDR white level is read by a background thread (about once a second, only while HDR10 is in use);
  PresentX reads an atomic. A failed query keeps the last good value; QueryDisplayConfig retries on
  ERROR_INSUFFICIENT_BUFFER.
- LEONIDA_SDR_EOTF is case-insensitive, unknown or too long values are logged; setters are atomics; <cwchar> for wcscmp.
- Tests: eight-step HDR10 ramp with hand-calculated bytes, curve properties (monotonic, identity below the knee, peak 1,
  slope continuity), HDR10 plane 1 over SDR plane 0 on HDR10 and SDR outputs, hand-calculated 50% overlay bytes, query cost.
- Docs 4.5: shoulder description, query cost, sources marked (KWin claim unverified, vkd3d-proton file partly read, the
  measured 80 nits only covers the SDR fallback path).
- present_compose.inc rebuilt with glslc 2026.4 (reproducible, spirv-val clean).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 19:45:00 +01:00
0963784063 PresentX planes: filter and blend in linear light, selectable SDR EOTF, Windows SDR white level, tone map
- Compose pass decodes every texel to linear (premultiplied) before filtering, converts the plane to the output's linear
  working space (Rec.2020 nits for HDR10, Rec.709 relative to SDR white for SDR), blends there and encodes once.
- SDR EOTF is piecewise sRGB by default (community-sourced Windows behaviour), gamma 2.2 by
  XboxPresentation::set_sdr_eotf or LEONIDA_SDR_EOTF=gamma22.
- SDR white: set_sdr_white_nits override, else DISPLAYCONFIG_SDR_WHITE_LEVEL of the window's output while HDR10 is
  active, else 203 nits (BT.2408).
- HDR10 on an SDR output: extended Reinhard on luminance (white point at the content peak, default 1000 nits) instead of a
  hard clip.
- HDR metadata stays unsent; docs section 4.5 documents the decisions and cites the sources.
- CPU reference model and xbox_present_test updated (linear model, EOTF option, 50% overlay, tone map, white level query).
- present_compose.inc rebuilt with glslc 2026.4 (byte-reproducible, spirv-val clean).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 19:17:24 +01:00
0a3bf1ed91 PresentX planes: enable swapchain_colorspace on the real instance, premultiply before filtering
- create_vulkan_device_standalone now enables VK_EXT_swapchain_colorspace when the loader has it (only the
  test device did), so the HDR10 surface formats can be listed in the real runtime; xbox_present_test checks
  the standalone path (device_has_swapchain_colorspace).
- Straight-alpha planes are bilinearly filtered on premultiplied colour and un-premultiplied after, so a
  transparent texel adds no colour; the CPU model does it independently, plus a transparent-edge case.

Both found in review by Flyander.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:34:38 +01:00
9bf0794813 PresentX planes: review fixes (resize, struct order, overlay flag, ResourceCount)
- Re-prepare the compose target after the acquire/out-of-date retry and check the extent in
  record_planes; xbox_present_test resizes the window between composed presents.
- XboxPresentPlaneParameters follows the public field order exactly (adds ExtendedDescCount,
  pExtendedDescs); implausible placement / unknown filter / extended descs are ignored and
  logged once, not refused.
- Plane 1 is composed only with our overlay flag (SDR/SDR no longer blends by default).
- present_planes rejects a non-positive or NaN SDR white level.
- ResourceCount != 1 is refused with DXGI_ERROR_UNSUPPORTED before either path (found by Flyander).
- Docs: PQ-space filtering, HDR10 swapchain verified on RTX 5080 by JavierBlanco23.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:11:01 +01:00
76262214e8 PresentX planes (M7): compose 1-2 planes on Vulkan with placement, filter, alpha overlay and HDR10/SDR conversion
A plain single plane keeps the old blit. A plane with pDestPlacementBase, a point/linear
ScaleFilter, the HDR10 colour space, or a second overlay plane goes through
VulkanPresenter::present_planes: a compute pass (present_compose.comp, SPIR-V embedded)
into an RGBA16F image that is copied to the swapchain. HDR10 uses an ST.2084 swapchain
when the surface lists one, else is clipped to SDR. An SDR plane 1 next to an HDR10 plane 0
is the GameDVR copy (public HDR sample) unless flagged an overlay. The layouts, flag values
and alpha convention are ours; xbox_present_test checks every case against a CPU model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:51:05 +01:00
f3e6d5a9b4 Merge pull request #1523 from AlxcBTW 2026-11-22 07:38:02 -05:00
2f54b2c171 xbox_present: skip the known sRGB swapchain STORAGE validation VUID
NVIDIA's validation layer checks the presenter's sRGB swapchain as if it requested STORAGE, then reports VUID-VkSwapchainCreateInfoKHR-imageFormat-01778 and its max-layers/max-extent follow-ons. The presenter only requests TRANSFER_DST, plus TRANSFER_SRC for capture, so that is a layer false positive. Count this VUID separately and return the ctest skip code only when it is the sole validation error; any other error, or a mix, still fails.

The matcher is covered by synthetic first-message and follow-on checks in xbox_present_test. On an RX 7900 XTX with validation on, the test remains clean and passes.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 06:03:54 -06:00
c03b573a16 PresentX tear: review fixes
- find_tear_mode rejects a mode whose surface caps lack the swapchain's image usage or extent.
- present_timing: a repeated or stale token is never late.
- percent_scanned is measured at commit, so it agrees with the display time.
- The "no effect" log distinguishes the kill switch from a missing extension or mode.
- LEONIDA_PRESENT_NO_TEAR is read with _dupenv_s: any non-empty value but "0" disables.
- xbox_present_test: the real-time comment is back where it belongs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:00:38 +01:00
6728a00c2a PresentX: implement ImmediateThresholdPercent with VK_KHR/EXT_swapchain_maintenance1
A frame presented after the vblank it was due at is flipped at once (IMMEDIATE, else
FIFO_RELAXED) when the scan would be within the threshold percentage of the screen,
instead of waiting a whole interval. The decision is the pure
leonida::decide_present_sync(late_us, interval_us, threshold); FramePacer reports the
lateness against the vblank after the token's origin and records the tear in
GetFrameStatisticsX (PercentScanned) and immediate_presents().

VulkanPresenter creates a vsync swapchain with FIFO plus the tear mode when the surface
lists it as compatible (VkSurfacePresentModeCompatibilityKHR) and chains
VkSwapchainPresentModeInfoKHR on a tearing present. The device enables the KHR (else EXT)
extension, its feature and the matching instance extensions only where present; without
them the threshold is ignored and logged once, as before. LEONIDA_PRESENT_NO_TEAR=1 turns
it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:54:49 +01:00
daff874493 XboxPresentation: present null/stale/repeated tokens with a log, MSAA gives DXGI_ERROR_UNSUPPORTED, SuspendX never waits on a present; tests and docs
xbox_present_test presents with null, repeated and stale tokens (the present
happens) and refuses never-issued ones, and presents MSAA, integer and BC sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:28:34 +01:00
b7a0232523 runtime: XboxPresentation (PresentX 0/1/2 planes, frame events, Suspend/ResumeX) and xbox_present_test
Provisional struct layouts and constants of ours; real slots unmeasured (TODO
table in the header). The test reads the swapchain image back on a Vulkan
device and runs the frame events on a fake clock, then 30 frames in real time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:28:06 +01:00