d3d12_xs: add multi-event FramePacer TOKEN_ON_TIMEOUT and wire XboxPresentation to device/queue slots (RT-XS-FRAME-PACING-PRESENTX) #402

Manually merged
github merged 4 commits from gh-pr/402/head into gh-pr/402/base 2026-11-26 08:58:04 +00:00
Owner

@⁠Andretuta on GitHub · 2026-11-24 04:43 UTC · original
ubiquitarianism:feat/xs-frame-pacing-presentx → main · +468 −72 · 8 files · 4 commits · merged 2026-11-24 13:44 UTC

Claimed in the coordination issue as: RT-XS-FRAME-PACING-PRESENTX (#14)

What and why

Extends FramePacer and adds the seam that will connect the Xbox device/queue proxies to XboxPresentation:

  • runtime/src/frame_pacer.h: vblank (1) and flip (2) frame events next to origin (0), each with its own offset, and a token-on-timeout wait flag (bit 2) that issues a consecutive token and returns S_FALSE when a finite origin wait times out. These values are provisional definitions of ours; the console constants are unmeasured.
  • runtime/shims/d3d12_xs_device.{h,cpp}: PresentationHandler + set_presentation_handler(device, handler) keep the device proxy free of Vulkan headers. With a handler attached, device slots 78-81 (SetFrameIntervalX, ScheduleFrameEventX, WaitFrameEventX, GetFrameStatisticsX) and the queue's PresentX go to it; the handler is called with its lock held shared, so a detach cannot destroy the presenter mid-call.
    • PresentX defaults to queue slot 30 (XCL's older layout; 32 is the newer one, LEONIDA_XS_PRESENT_X_SLOT). SuspendX/ResumeX slots are unmeasured, so they are routed only when LEONIDA_XS_SUSPEND_X_SLOT / LEONIDA_XS_RESUME_X_SLOT are set; two routes on one slot are refused with a log.
    • GetFrameStatisticsX is a route like 78-80 (LEONIDA_XS_FRAME_STATISTICS_SLOT, default 81). Without a presenter it answers S_FALSE with a zero count instead of reaching PC slot 81 (ID3D12Device13::OpenExistingHeapFromAddress1).
    • One env_slot() parser serves device and queue slots.
  • runtime/shims/xbox_present.{h,cpp}: attach_xbox_presentation / detach_xbox_presentation. Not called by gta6rt yet: the runtime creates no XboxPresentation (only d3d12_boot_movie_test and xbox_present_test do); this is the seam the presenter will use.
  • docs/d3d12_vulkan.md: documents slot 81, the queue routes and their variables.

No longer depends on #359 or #360: it merges with current main and with both on its own.

Tested

  • clang 23 / mingw x64: xs_proxy_mock_test (all checks but the pre-existing kLong allocation-injection ones, which also fail on main under mingw), --env-slots, --env-slots-invalid, frame_pacer_test; docs tests including test_docs_env_vars.

GPUs tested: n/a (CPU-only mock clock and synthetic COM proxy tests)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a)

🤖 Generated with Claude Code

**@⁠Andretuta** on GitHub · 2026-11-24 04:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/402) `ubiquitarianism:feat/xs-frame-pacing-presentx` → `main` · +468 −72 · 8 files · 4 commits · merged 2026-11-24 13:44 UTC Claimed in the coordination issue as: `RT-XS-FRAME-PACING-PRESENTX` (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why Extends `FramePacer` and adds the seam that will connect the Xbox device/queue proxies to `XboxPresentation`: - **`runtime/src/frame_pacer.h`:** vblank (1) and flip (2) frame events next to origin (0), each with its own offset, and a token-on-timeout wait flag (bit 2) that issues a consecutive token and returns `S_FALSE` when a finite origin wait times out. These values are provisional definitions of ours; the console constants are unmeasured. - **`runtime/shims/d3d12_xs_device.{h,cpp}`:** `PresentationHandler` + `set_presentation_handler(device, handler)` keep the device proxy free of Vulkan headers. With a handler attached, device slots 78-81 (`SetFrameIntervalX`, `ScheduleFrameEventX`, `WaitFrameEventX`, `GetFrameStatisticsX`) and the queue's `PresentX` go to it; the handler is called with its lock held shared, so a detach cannot destroy the presenter mid-call. - `PresentX` defaults to queue slot 30 (XCL's older layout; 32 is the newer one, `LEONIDA_XS_PRESENT_X_SLOT`). `SuspendX`/`ResumeX` slots are unmeasured, so they are routed only when `LEONIDA_XS_SUSPEND_X_SLOT` / `LEONIDA_XS_RESUME_X_SLOT` are set; two routes on one slot are refused with a log. - `GetFrameStatisticsX` is a route like 78-80 (`LEONIDA_XS_FRAME_STATISTICS_SLOT`, default 81). Without a presenter it answers `S_FALSE` with a zero count instead of reaching PC slot 81 (`ID3D12Device13::OpenExistingHeapFromAddress1`). - One `env_slot()` parser serves device and queue slots. - **`runtime/shims/xbox_present.{h,cpp}`:** `attach_xbox_presentation` / `detach_xbox_presentation`. Not called by `gta6rt` yet: the runtime creates no `XboxPresentation` (only `d3d12_boot_movie_test` and `xbox_present_test` do); this is the seam the presenter will use. - **`docs/d3d12_vulkan.md`:** documents slot 81, the queue routes and their variables. No longer depends on #359 or #360: it merges with current `main` and with both on its own. ### Tested - clang 23 / mingw x64: `xs_proxy_mock_test` (all checks but the pre-existing `kLong` allocation-injection ones, which also fail on `main` under mingw), `--env-slots`, `--env-slots-invalid`, `frame_pacer_test`; docs tests including `test_docs_env_vars`. GPUs tested: n/a (CPU-only mock clock and synthetic COM proxy tests) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Support origin (0), vblank (1), and flip (2) frame events and
  frame_wait_flag_token_on_timeout (flag 2, returning S_FALSE with a
  fresh consecutive token on timeout) in runtime/src/frame_pacer.h.
- Add a decoupled PresentationHandler interface to d3d12_xs_device.{h,cpp}
  routing device slots 78-81 and queue PresentX/SuspendX/ResumeX slots
  (default 30/31/32, env-overridable via LEONIDA_XS_*_SLOT).
- Add attach_xbox_presentation / detach_xbox_presentation in
  runtime/shims/xbox_present.{h,cpp}.
# Conflicts:
#	runtime/test/xs_proxy_mock_test.cpp
- Queue routes: PresentX defaults to slot 30 (XCL's older layout; 32 is the
  newer one, set with LEONIDA_XS_PRESENT_X_SLOT). SuspendX/ResumeX slots are
  unmeasured, so they are routed only when their variables are set; two
  routes on one slot are refused with a log instead of shadowing each other.
- One env_slot() parser for device and queue slots (no duplicated copy).
- GetFrameStatisticsX is a route like 78-80 (LEONIDA_XS_FRAME_STATISTICS_SLOT,
  default 81). Without a presenter it answers S_FALSE with a zero count
  instead of reaching PC slot 81 (ID3D12Device13::OpenExistingHeapFromAddress1).
- The presentation handler is called with its lock held shared, so a detach
  cannot destroy the presenter under an in-flight call.
- frame_pacer.h: the new event/flag constants are marked provisional again.
- xbox_present.h: attach_xbox_presentation is documented as the seam the
  presenter will use; gta6rt does not create an XboxPresentation yet.

AI-assisted. Tested with clang 23 / mingw x64: xs_proxy_mock_test (all checks
but the pre-existing kLong allocation-injection ones, which also fail on main
under mingw), --env-slots, --env-slots-invalid, frame_pacer_test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
LEONIDA_XS_FRAME_STATISTICS_SLOT, LEONIDA_XS_PRESENT_X_SLOT,
LEONIDA_XS_SUSPEND_X_SLOT and LEONIDA_XS_RESUME_X_SLOT were read by the code
and named in no document (tests/test_docs_env_vars.py failed).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:58:02 +00:00
github manually merged commit d743662615 into gh-pr/402/base 2026-11-26 08:58:04 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.