Skip to content

xbox_present: record measured Device (78-81) and Queue (23, 24, 32) vtable slots - #512

Closed
kotekompotek wants to merge 2 commits into
ProjectLeonida:mainfrom
kotekompotek:work/xbox-present-measured-slots
Closed

kotekompotek wants to merge 2 commits into
ProjectLeonida:mainfrom
kotekompotek:work/xbox-present-measured-slots

Conversation

@kotekompotek

Copy link
Copy Markdown
Contributor

Records the measured Xbox GDKX 0-based vtable slots in runtime/shims/xbox_present.h (both in the slot table comment and as inline constexpr unsigned constants in namespace rt::d3d12):

  • ID3D12Device (Xbox): SetFrameIntervalX = 78 (0x270), ScheduleFrameEventX = 79 (0x278), WaitFrameEventX = 80 (0x280), GetFrameStatisticsX = 81 (0x288)
  • ID3D12CommandQueue (Xbox): SuspendX = 23 (0x0b8), ResumeX = 24 (0x0c0), PresentX = 32 (0x100)

Verified locally with cmake --build ... --target xbox_present_test xbox_present_readback_size_test and ctest -R xbox_present (2/2 Passed).

@kawaii-shakal

Copy link
Copy Markdown
Contributor

Review of head 8ec704a99da8e31a2a4cab6c4cc744f30ba822b5.

Environment: Linux (WSL2). I only read the code. The xbox_present shims are Windows-only, so I built nothing.

Findings (needs change):

  1. No provenance for "measured". The PR adds SuspendX = 23, ResumeX = 24 and PresentX = 32 as measured. It does not say which binary, runtime version or method they come from. AGENTS.md asks for the file and offset a claim comes from, or for the claim to be labelled a hypothesis.
  2. The header now contradicts itself. Line 15 still says "The SuspendX/ResumeX slots are not in any public source". The lines after the table still say "The runtime version moves PresentX, so neither value may be assumed; trace the game's slots", but kQueueSlotPresentX = 32 now hard-codes one of the two values.
  3. Other places still say the slots are unknown: runtime/README.md:408 ("PresentX, SuspendX, ResumeX) have unknown slots") and docs/d3d12_command_objects.md:679 and :834 ("No slot or signature"). Either update them with the source or leave the slots as unknown.
  4. Nothing uses the new k*Slot* constants (grep over runtime/ and docs/), so xbox_present_test passing says nothing about whether the values are right.

Plausibility check (reasoning, not executed): the public ID3D12CommandQueue chain ends at slot 18 (GetDesc), so Xbox extensions at 23 and 24 are not ruled out. That does not confirm the values, though.

Not tested: any build or run. The xbox_present targets need Windows/MSVC.


Review written by Claude (Claude Code, Opus 5.5), an AI agent, posted from a contributor's account.

@kawaii-shakal

Copy link
Copy Markdown
Contributor

Re-review of head b9ffaa5159a14ac22c851bd12931aa83769b3cd5. The branch was force-pushed: 8ec704a is gone and the PR is now af9baf0 + b9ffaa5 on d7576d5, so I re-read the full diff against the merge base.

What I re-checked: the diff of runtime/shims/xbox_present.h, runtime/README.md and docs/d3d12_command_objects.md, a grep of the repository for the slot names and the new constants, and the queue proxy in runtime/shims/d3d12_xs_device.cpp. scripts/check_no_game_data.py on the changed files: clean. I did not build anything and did not check the call sites against the executable.

Earlier remarks:

  1. Provenance: partly resolved. The header and the docs now name the binary (retail 1.0.2.1), the method (Capstone disassembly of call sites) and example RVAs: 0x31b17 (+0x0b8), 0x3299b (+0x0c0), 0x28751 (+0x100), 0x1ea6e7 (+0x270). Still missing:
    • How a call at +0x0b8 / +0x0c0 is attributed to SuspendX / ResumeX, and how the receiver is known to be the queue. An offset shows that a slot is called. It does not show which method is in that slot. For example: the queue pointer's origin, the argument count, the call order around suspend/resume, or a string nearby.
    • Which file, by name or by its game/xbox-1.0.2.1.json entry. Device slots 79-81 have no call-site RVA, only slot 78 does. The docs table rows for 79-81 are still cited to XCL only.
    • A way to reproduce it: a script or command, or a docs section with the call sites.
  2. Header contradiction: resolved. One new sentence needs care: "the proxy allows env overrides". At this PR's base (d7576d5) there is no slot override. Current main has them (LEONIDA_XS_PRESENT_X_SLOT, LEONIDA_XS_SUSPEND_X_SLOT, LEONIDA_XS_RESUME_X_SLOT in d3d12_xs_device.cpp, from 2a3e7a2 / ddafa07), with PresentX at queue slot 30 by default. After a rebase the sentence is true, but it should name those variables, and the new constants should agree with what main routes now.
  3. Other places that say the slots are unknown: partly resolved. runtime/README.md:408 and docs/d3d12_command_objects.md:678/679, 832/834 are updated. These still say the slots are unknown or unwired:
    • docs/d3d12_command_objects.md:82 and :717 (lists of what is not measured), and :835 ("No runtime binary and no game executable"), which now contradicts the 1.0.2.1 rows above it.
    • docs/d3d12_xs_surface.md:507 ("No signatures or slots") and :552 (no public SuspendX/ResumeX slot).
    • docs/d3d12_vulkan.md:2939 ("the SuspendX/ResumeX slots still are" guesses) and :3201-3202 ("Nothing here is wired to those slots yet").
    • docs/boot.md:143.
  4. Constants unused: not resolved at this head. kDeviceSlot* / kQueueSlot* are referenced only in xbox_present.h, and at the base the queue proxy serves 19 public slots and refuses the rest. Since then main routes PresentX/SuspendX/ResumeX through xbox_queue_slot_routes(). A rebase should either use those routes or drop the duplicate constants, and the README should describe what the code then does. Removing "refused with a log" / "nothing reaches them yet" fits main, not this PR's base.

Still open: the method attribution in point 1, a rebase onto current main (points 2 and 4), and the stale lines in point 3.

AI-assisted.

@kotekompotek

Copy link
Copy Markdown
Contributor Author

Closing as superseded by merged PR #402 (89e0ea9b5, which wired XboxPresentation slots directly in the codebase) and to keep PRs aligned with repository provenance rules (avoiding unverified external binary RVA claims).

demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
whoalin1 added a commit to whoalin1/leonida-continued that referenced this pull request Nov 25, 2026
Measured on the RDNA2 iGPU (gfx1036, tools/f16_interp_probe.py, 98,304
samples over 12 native draws): the SPI writes P10/P20 for a 16-bit
channel as per-half f16 differences (round to nearest even), the
weighted sum stays f32, and v_interp_p2_f16 narrows toward zero --
the driver's ISA runs the pair inside s_round_mode 0x000c, so the
narrow is toward zero whatever the shader's own MODE writes are.
The rdna2 model explains 98,274 of 98,304 samples; the previous
translation (f32 deltas, nearest-even narrow) explains 62,226.

- Gen.f16_round: f32 -> nearest-f16 value via f16_bits +
  UnpackHalf2x16 (integer-built bits, so no driver folds the round
  trip away, ProjectLeonida#512/ProjectLeonida#513); applied to the P1-P0 / P2-P0 deltas of
  16-bit-channel reads in attribute().
- v_interp_p2_f16 narrows with f16_bits(rtz=True) and keeps the
  SHADER-430 partial-write high half via write_lo16.
- vk_harness: scan both stages for Float16 / StorageInputOutput16 /
  Float64 capabilities (77 when the device lacks them), enable the
  matching Vulkan 1.1/1.2 features, VKH_PC_BYTES to shrink the
  push-constant range for hand-written fixtures, and VKH_SHADER_INFO
  to dump the driver's fragment disassembly.
- tests/semantic/test_interp_f16_round.py: the two telling cases
  (f16 delta overflow to inf; toward-zero vs nearest-even tie).
- tests/semantic/test_interp_p1lv_f16.py: reference oracle updated
  to the measured model (f16 deltas, f32 sum, toward-zero narrow).
- docs/design.md: 16-bit interpolation row records the SHADER-468
  measurements and remaining unverified items.

Co-Authored-By: Devin <noreply@cognition.ai>
whoalin1 added a commit to whoalin1/leonida-continued that referenced this pull request Nov 25, 2026
Measured on the RDNA2 iGPU (gfx1036, tools/f16_interp_probe.py, 98,304
samples over 12 native draws): the SPI writes P10/P20 for a 16-bit
channel as per-half f16 differences (round to nearest even), the
weighted sum stays f32, and v_interp_p2_f16 narrows toward zero --
the driver's ISA runs the pair inside s_round_mode 0x000c, so the
narrow is toward zero whatever the shader's own MODE writes are.
The rdna2 model explains 98,274 of 98,304 samples; the previous
translation (f32 deltas, nearest-even narrow) explains 62,226.

- Gen.f16_round: f32 -> nearest-f16 value via f16_bits +
  UnpackHalf2x16 (integer-built bits, so no driver folds the round
  trip away, ProjectLeonida#512/ProjectLeonida#513); applied to the P1-P0 / P2-P0 deltas of
  16-bit-channel reads in attribute().
- v_interp_p2_f16 narrows with f16_bits(rtz=True) and keeps the
  SHADER-430 partial-write high half via write_lo16.
- vk_harness: scan both stages for Float16 / StorageInputOutput16 /
  Float64 capabilities (77 when the device lacks them), enable the
  matching Vulkan 1.1/1.2 features, VKH_PC_BYTES to shrink the
  push-constant range for hand-written fixtures, and VKH_SHADER_INFO
  to dump the driver's fragment disassembly.
- tests/semantic/test_interp_f16_round.py: the two telling cases
  (f16 delta overflow to inf; toward-zero vs nearest-even tie).
- tests/semantic/test_interp_p1lv_f16.py: reference oracle updated
  to the measured model (f16 deltas, f32 sum, toward-zero narrow).
- docs/design.md: 16-bit interpolation row records the SHADER-468
  measurements and remaining unverified items.

Co-Authored-By: Devin <noreply@cognition.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants