Skip to content

xgameruntime: add XAccessibility closed caption and high contrast fallback - #85

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
certified-retart:feat/xaccessibility-apis
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
certified-retart:feat/xaccessibility-apis

Conversation

@certified-retart

Copy link
Copy Markdown
Contributor

Summary

Implements offline/fallback support for the GDK XAccessibility closed-caption and high-contrast APIs (XAccessibility.h):

  • crates/xcl/src/hle/xgameruntime/accessibility.rs:
    • Adds ABI-accurate #[repr(C, align(4))] XColor (A, R, G, B) and 28-byte XClosedCaptionProperties structs with explicitly zeroed trailing padding.
    • Implements XClosedCaptionGetProperties, XClosedCaptionSetEnabled (taking u8 at the FFI boundary to normalize any non-zero C/C++ byte safely without Rust bool UB), and XHighContrastGetMode (querying Win32 SystemParametersInfoW(SPI_GETHIGHCONTRAST) and classifying active themes via GetSysColor(COLOR_WINDOW) luminance, returning E_FAIL on OS query failure).
  • crates/xcl/src/hle/xgameruntime/mod.rs:
    • Exports XClosedCaptionGetProperties, XClosedCaptionSetEnabled, and XHighContrastGetMode by name in exports().
  • crates/xcl/src/hle/xgameruntime/api.rs:
    • Adds xcl_xaccessibility_object() and wires None if c == XACCESSIBILITY in QueryApiImpl as a built-in fallback when System32\xgameruntime.dll is not installed (matching the existing XAsync fallback pattern). When Gaming Services is present on the host, QueryApiImpl continues to delegate directly to the native PC runtime so host Windows caption settings, custom high-contrast themes, and XSpeech* remain untouched.

XGameRuntimeIsFeatureAvailable(0) (XAccessibility) already returned true; this ensures titles querying XAccessibility without System32\xgameruntime.dll or importing the functions directly do not hit REGDB_E_CLASSNOTREG / unresolved imports.

Testing

  • Added unit tests covering XColor / XClosedCaptionProperties sizes, alignments, field offsets, raw ARGB byte layout, null-pointer E_INVALIDARG, poisoned-buffer zero-padding verification, non-zero u8 normalization, XHighContrastMode luma classification & OS query, and xcl_xaccessibility_object() COM vtable dispatch (slots 3..=5 + E_NOTIMPL on slot 6).
  • Ran cargo test -p xcl --lib hle::xgameruntime -- --test-threads=2: 44 passed; 0 failed.

DIMASIK1502 pushed a commit to DIMASIK1502/xcl that referenced this pull request Nov 23, 2026
…ist layouts

Unicorn Overlord runs on a newer console D3D12 runtime from its own game OS.
It reports the same SDK version (0x20004) as XDefiant and Minecraft, but some
vtables are laid out differently:

- Command queue: there are two more methods before Signal. Signal is at xcl-dev#16,
  Wait xcl-dev#17, GetTimestampFrequency xcl-dev#18, SignalX xcl-dev#25 and PresentX xcl-dev#32. The
  title's Signal used to land on GetTimestampFrequency, which wrote 100 MHz
  over the fence's vtable, and the game crashed. queue_dispatch now handles
  the title's queue slots from xcl-dev#14. A fence passed to xcl-dev#16 or xcl-dev#17 marks the
  newer layout; the older layout never passes one there.
- Command list: the console methods from CopyTextureRegionX onward sit two
  slots later (xcl-dev#85 instead of xcl-dev#83). The texture uploads used to hit
  SetPredicationBufferX, so every texture stayed zero and the screen showed
  only shapes and gradients. guard::make_layout_split now picks the method
  at each call and leaves the argument registers, xmm ones included,
  untouched.

Also:
- Console-only resource state bits (0x100000 on the 4K display target) are
  masked off when a resource is created. The PC refused the resource and
  the title threw.
- The title commits 2046 of 2048 MB of unified memory at start. XCL's
  per-draw arena now has its own 64 MB pool at the end of window 0, so
  draws are no longer skipped.
- FENCES is a read-write lock. end_title reads it while the title's threads
  are suspended, so a suspended reader no longer blocks it.

Diagnostics:
- XCL_WATCH=rva sets a write watchpoint in the exe; the calling thread is
  armed at once.
- XCL_WATCH_FENCE=n watches the n-th fence.
- The log now shows the device's SDK version, console-only interface
  requests, the title's file opens with their flags, DirectStorage
  requests, unified-memory use, and (in traces) whether title textures hold
  data in memory.

README: Unicorn Overlord is listed as fully playable. Bink's GPU-assisted
mode is no longer listed as missing: it needs no Bink-specific support.
Hull, domain and amplification shaders are dropped from the list too, since
none of the games use them.
@ivall
ivall merged commit 28132e8 into xcl-dev:main Nov 23, 2026
ivall added a commit that referenced this pull request Nov 23, 2026
ivall added a commit that referenced this pull request Nov 23, 2026
The previous commit (9284dcd, titled like this one by mistake) is the follow-up to #86:
placed textures that get memory of their own retry with COMMON when the PC refuses the
title's state, as the past-the-end fallback does, instead of falling back to the overlapping
placement.
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged. Tested on Windows 11 with an RX 9070 (RDNA4): cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with XCL_SPLIT_WAVE64=1; Unicorn Overlord, Minecraft and Fortnite run with this round merged. Thanks!

kacper-serewis pushed a commit to kacper-serewis/xcl that referenced this pull request Nov 24, 2026
KickoffX and the Wait64 mid-list split close, submit and reset the PC
list mid-recording, and set again what the title had set: on the
console a kickoff leaves the list's state as it was (`Bindings`). They
re-applied predication only from `ListState::predication`, which only
xcl-dev#85 SetPredicationBufferX sets; `restore_bindings` had none. So
predication set through xcl-dev#31 SetPredication was lost at a kickoff or a
split, and the draws after it ran unpredicated.

`set_predication_x` records the PC call (buffer, offset with the
buffer's delta, operation) in `Bindings` (none for a null buffer) and
`restore_bindings` issues it again on direct and compute lists. The
last of xcl-dev#31 and xcl-dev#85 is the one in effect, as on the PC list: xcl-dev#31 clears
xcl-dev#85's op (its buffer still goes back to COMMON at Close / KickoffX
through `pred_in_state`), xcl-dev#85 clears the xcl-dev#31 record, and xcl-dev#85's copy
into its predication buffer first disarms a xcl-dev#31 predicate too, so the
copy is not predicated away.

Test: with a delta of 0x200, after xcl-dev#31 at offset 0x10 a restore issues
SetPredication(buf, 0x210, op) on direct and compute lists (none
before); none after xcl-dev#31 with a null buffer or xcl-dev#85 with none; xcl-dev#85
after xcl-dev#31 disarms first and leaves only xcl-dev#85's state.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 6337e42)
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
The layout entry matches the Windows SDK's d3d12.h (IID, parent List9,
SetProgram xcl-dev#84 / DispatchGraph xcl-dev#85 after List9's 84 methods, List11 after
it); a console list object passes List10 QueryInterface on to the PC list
(itself out when supported, E_NOINTERFACE unchanged when not) and forwards
xcl-dev#84 / xcl-dev#85; an adopted PC list gets the List10+ layout while a title's xcl-dev#84 /
xcl-dev#85 stay the console methods (CopyResource with flags, SetPredication with
a buffer). The GPU test skips when the runtime has no List10.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
KickoffX and the Wait64 mid-list split close, submit and reset the PC
list mid-recording, and set again what the title had set: on the
console a kickoff leaves the list's state as it was (`Bindings`). They
re-applied predication only from `ListState::predication`, which only
xcl-dev#85 SetPredicationBufferX sets; `restore_bindings` had none. So
predication set through xcl-dev#31 SetPredication was lost at a kickoff or a
split, and the draws after it ran unpredicated.

`set_predication_x` records the PC call (buffer, offset with the
buffer's delta, operation) in `Bindings` (none for a null buffer) and
`restore_bindings` issues it again on direct and compute lists. The
last of xcl-dev#31 and xcl-dev#85 is the one in effect, as on the PC list: xcl-dev#31 clears
xcl-dev#85's op (its buffer still goes back to COMMON at Close / KickoffX
through `pred_in_state`), xcl-dev#85 clears the xcl-dev#31 record, and xcl-dev#85's copy
into its predication buffer first disarms a xcl-dev#31 predicate too, so the
copy is not predicated away.

Test: with a delta of 0x200, after xcl-dev#31 at offset 0x10 a restore issues
SetPredication(buf, 0x210, op) on direct and compute lists (none
before); none after xcl-dev#31 with a null buffer or xcl-dev#85 with none; xcl-dev#85
after xcl-dev#31 disarms first and leaves only xcl-dev#85's state.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
emirduran707 added a commit to emirduran707/xcl that referenced this pull request Nov 25, 2026
KickoffX and the Wait64 mid-list split close, submit and reset the PC
list mid-recording, and set again what the title had set: on the
console a kickoff leaves the list's state as it was (`Bindings`). They
re-applied predication only from `ListState::predication`, which only
xcl-dev#85 SetPredicationBufferX sets; `restore_bindings` had none. So
predication set through xcl-dev#31 SetPredication was lost at a kickoff or a
split, and the draws after it ran unpredicated.

`set_predication_x` records the PC call (buffer, offset with the
buffer's delta, operation) in `Bindings` (none for a null buffer) and
`restore_bindings` issues it again on direct and compute lists. The
last of xcl-dev#31 and xcl-dev#85 is the one in effect, as on the PC list: xcl-dev#31 clears
xcl-dev#85's op (its buffer still goes back to COMMON at Close / KickoffX
through `pred_in_state`), xcl-dev#85 clears the xcl-dev#31 record, and xcl-dev#85's copy
into its predication buffer first disarms a xcl-dev#31 predicate too, so the
copy is not predicated away.

Test: with a delta of 0x200, after xcl-dev#31 at offset 0x10 a restore issues
SetPredication(buf, 0x210, op) on direct and compute lists (none
before); none after xcl-dev#31 with a null buffer or xcl-dev#85 with none; xcl-dev#85
after xcl-dev#31 disarms first and leaves only xcl-dev#85's state.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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