Skip to content

xgameruntime: Series S by default on GPUs with less than 10 GiB of VRAM - #4821

Closed
DaniSBR1 wants to merge 1 commit into
ProjectLeonida:mainfrom
DaniSBR1:pr-series-s-default
Closed

DaniSBR1 wants to merge 1 commit into
ProjectLeonida:mainfrom
DaniSBR1:pr-series-s-default

Conversation

@DaniSBR1

Copy link
Copy Markdown
Contributor

Claimed in #4683 (#4683 (comment)), new RT item.

Depends on: #3775 (the title reads the console type through the registry value ConsoleMode, which #3775 serves from XSystemGetDeviceType; without it the title's own copy of the function answers PC whatever this returns)

What and why

XSystemGetDeviceType reported Series X (Anaconda) unless LEONIDA_DEVICE_TYPE said otherwise. The package is one executable for both consoles, so the title picks its profile from the console type at run time. On an 8 GB GPU (RX 5700 XT, RTX 3060 Ti, RTX 3070) the Series X profile asks for more than the card holds, and the Series S one is the profile that fits.

  • The rule (runtime/src/device_profile.h, a pure function): Series S (Lockhart, 6) on a GPU with less than 10 GiB of VRAM, which is Series X's GPU-optimal memory. Series X (Anaconda, 7) otherwise, or when the VRAM can't be read, as before.
  • The VRAM: read once, the first time the type is asked for, which can be before the title creates its D3D12 device.
    • It goes through DXGI's DedicatedVideoMemory, not Vulkan as the claim said. gta6rt builds without the Vulkan headers (they're optional in runtime/CMakeLists.txt) and xgameruntime.cpp doesn't use them. On Windows that value is the GPU's largest DEVICE_LOCAL heap, the one the layer's own IDXGIAdapter (dxgi_com.cpp) reports.
    • The GPU is the runtime's: LEONIDA_VK_DEVICE filters by name, software and Microsoft adapters are left out (vulkan_device_rank puts them last), and the one with the most dedicated memory wins. That is the discrete GPU on a machine that also has an iGPU.
  • LEONIDA_DEVICE_TYPE still decides when set. XSystemGetAnalyticsInfo's form follows the type, as it already did for 6. XSystemGetAppMemoryUsageLimit is unchanged.
  • The runtime logs the choice once, for example: [rt] xgameruntime: reporting Xbox Series S: the GPU has 8151 MiB of VRAM, less than 10 GiB (LEONIDA_DEVICE_TYPE=6 or 7 picks Series S or X).
  • runtime/README.md's row for LEONIDA_DEVICE_TYPE gives the new default.

What this doesn't settle: that the title lowers its settings with the Series S type is inferred from the one executable for both consoles, not measured, since the title doesn't boot yet. The type is also the only thing that changes here: the memory the title is told it has stays the PC's RAM.

Tests

RX 5700 XT (8 GB), AMD Adrenalin 26.11.2, Windows 11, MSVC 19.44:

  • xgameruntime_test (133 checks pass):
    • The rule: 4 and 8 GiB give 6, 10 and 16 GiB give 7, and unknown VRAM gives 7.
    • The default on the machine's GPU is 6 or 7, with the analytics form matching it. It printed 6 here: 8151 MiB.
    • LEONIDA_DEVICE_TYPE=7 and =6 still decide, with the form following.
  • tiny_game (the run_tiny_game* tests) checked that the shim answers XSystemGetDeviceType by expecting 7. It now takes 6 or 7. The stub DLL that stands for the host answers 0, so the check still tells the two apart.
  • xgameruntime_user_test and the full ctest pass (173/173). The docs and text tests pass.

No game files were used. AI-assisted (Claude Code).

XSystemGetDeviceType reported Series X (Anaconda) unless LEONIDA_DEVICE_TYPE said otherwise. The package is one
executable for both consoles, so on an 8 GB GPU the Series S profile is the one that fits. With
LEONIDA_DEVICE_TYPE unset it now answers Lockhart (6) on a GPU with less than 10 GiB of VRAM, Series X's
GPU-optimal memory, and Anaconda (7) otherwise or when the VRAM can't be read (runtime/src/device_profile.h).
The VRAM is read once through DXGI's DedicatedVideoMemory (gta6rt builds without the Vulkan headers), for the
GPU the runtime draws with: LEONIDA_VK_DEVICE by name, no software or Microsoft adapter, the most dedicated
memory. The choice is logged once. XSystemGetAnalyticsInfo's form follows; XSystemGetAppMemoryUsageLimit is
unchanged. The title reads the type through the registry value ProjectLeonida#3775 serves.

Tests: xgameruntime_test (the rule, the default on the machine's GPU with the form matching, the override);
tiny_game accepts 6 or 7 from the shim (the stub DLL answers 0). RX 5700 XT (8151 MiB), AMD 26.11.2,
Windows 11: Series S; full ctest 173/173.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Atomic258

Copy link
Copy Markdown
Contributor

Tested head 3b542ffbab2dea1fe930775179d7c20345183b05 on Windows 11 with MSVC 19.44.35230, Ninja, Vulkan SDK 1.4.363.0, RTX 5090 (driver 617.42) and AMD Radeon iGPU.

Configured with cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PROGRAM_PATH=C:/msys64/ucrt64/bin, built with cmake --build runtime/build --target xgameruntime_test, then ran runtime/build/xgameruntime_test.exe in separate processes:

Environment DXGI VRAM reported Default device type Result
Adapter filters unset (RTX 5090) 32187 MiB Series X (7) 133 checks, exit 0
LEONIDA_VK_DEVICE=radeon 485 MiB Series S (6) 133 checks, exit 0
LEONIDA_VK_DEVICE=Microsoft Basic Render Driver, LEONIDA_HOST_ADAPTER=warp 0 MiB (unknown) Series X (7) 133 checks, exit 0

The last row covers the unknown-VRAM fallback, not WARP rendering or WARP selection: this shim excludes software adapters and does not read LEONIDA_HOST_ADAPTER.

Red control: restored only runtime/shims/xgameruntime.cpp from HEAD^, kept the PR test, rebuilt, and reran with LEONIDA_VK_DEVICE=radeon. The stock test still passed (it accepts 6 or 7), but an external assertion requiring XSystemGetDeviceType on this machine's GPU: 6 failed (exit 1; got 7). Restored the PR shim, rebuilt, and confirmed the same assertion passed (exit 0; got 6).

AI-assisted (Devin); no game files.

@ray3242

ray3242 commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Independent verification on a real sub-10 GiB discrete GPU — the case the existing results here (RTX 5090 32 GB, AMD iGPU) could not exercise. PR head 3b542ffb, based directly on current main 98fa503f, built as-is.

Environment (AI-assisted, OpenCode): Windows 11 Pro build 26300, MSVC 19.44.35230, CMake 4.4.4 + Ninja, RelWithDebInfo, Vulkan headers/SDL3 fetched by CMake. GPU: NVIDIA GeForce GTX 1060 6GB, driver 582.78; DXGI DedicatedVideoMemory reports 6031 MiB. No game data, keys or decryption used.

The deciding line:

[rt] xgameruntime: reporting Xbox Series S: the GPU has 6031 MiB of VRAM, less than 10 GiB (LEONIDA_DEVICE_TYPE=6 or 7 picks Series S or X)
XSystemGetDeviceType on this machine's GPU: 6

So the default is XboxScarlettLockhart (6) on a 6 GB NVIDIA card, matching the 8 GB AMD result in the PR description.

Tests:

  • xgameruntime_test.exe -> exit 0, OK (133 checks), including "a GPU with 4 or 8 GiB gets 6", "10 or 16 GiB gets 7", "unknown VRAM keeps 7", default type matching the analytics form, and both LEONIDA_DEVICE_TYPE overrides.
  • xgameruntime_user_test.exe -> exit 0, 0 of 42 checks failed.
  • Full filtered ctest -R "xgameruntime|tiny_game" --output-on-failure: 100% passed, 12/12 (xgameruntime, xgameruntime_user, both gamertag variants, all five run_tiny_game* cases, TLS and EH).

Note (not introduced by this PR): the xgameruntime_test target build emits the four known warnings at xgameruntime_test.cpp:634 (C4456), :669/:553/:573 (C4996); those are BUILD-1384, being handled in #4743.

Depends on: none. Verification only — no competing fix.

@PingasMech

Copy link
Copy Markdown

I tested this head (3b542ffb) together with its dependency #3775 (42f3708d) on an Intel UHD 770, Windows driver 32.0.101.7088. The production shims merged cleanly. The only conflict was in runtime/test/xgameruntime_test.cpp. Keep #4821's VRAM threshold checks and #3775's call to test_console_mode_registry(). With both retained, the Intel run failed 2 of 149 checks. Both failures were Series X assumptions inside the registry test.

Two test changes handled both profiles. Check that the default export is 6 or 7 and that the title-style registry read equals that export. In the raw DWORD check, expect 0x60 for type 6 or 0x64 for type 7. I kept the explicit override checks for types 2 through 8. Default registry assertion · Raw DWORD assertion

Fresh process, device-type override unset Export Title-style registry read Raw ConsoleMode CTest after the two edits
UHD 770 selected 6 6 0x60 149/149
Adapter filter matches nothing (unknown VRAM) 7 7 0x64 149/149

One correction for the PR description and source comment: on this integrated GPU, host DXGI DedicatedVideoMemory was 128 MiB. Vulkan's largest DEVICE_LOCAL heap was 15.85 GiB (17,019,867,136 bytes), exactly equal to host DXGI SharedSystemMemory. I matched the two API results by adapter LUID. These readings fall on opposite sides of the 10 GiB threshold. The PR uses the dedicated DXGI value and selected Series S here. VRAM query

MSVC 19.44, CMake/Ninja Release, focused xgameruntime CTest. AI-assisted, no game files.

@memorypressure

Copy link
Copy Markdown

Reviewed at merge with current main 3faac55 (clean auto-merge; mains offline-impl commits since your base do not touch the device-type path). The pure rule in device_profile.h is correct including the exactly-10 GiB to Series X boundary, the DXGI probe reuses the layers existing GPU filter helpers from vulkan_device_filter.h (verified present on main) rather than duplicating them, and the README row matches the code. The RX 5700 XT observation and the ctest 173/173 claim cannot be reproduced in this CPU-only Linux environment — the windows CI job (pending) covers the DXGI path. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only review).

@airp1ane

Copy link
Copy Markdown
Contributor

Security review (static): untrusted DLL search order when loading dxgi.dll (CWE-427)

  • Finding: In runtime/shims/xgameruntime.cpp (runtime_gpu_vram), dxgi.dll is loaded with plain LoadLibraryW(L"dxgi.dll"):
    const HMODULE dxgi = LoadLibraryW(L"dxgi.dll");
    Because gta6rt.exe runs with its current working directory in the game package folder, LoadLibraryW searches the application directory and working directory before System32, allowing a bundled or planted dxgi.dll to hijack the load.
  • Suggested fix: Restrict the load to System32, matching runtime/shims/d3d12_xs_device.cpp and runtime/src/pe_loader.cpp:
    const HMODULE dxgi = LoadLibraryExW(L"dxgi.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);

(Reviewed at head 3b542ffbab.)


Static security review (AI-assisted, read-only diff audit; no code or game files were executed).

@iliassgm

Copy link
Copy Markdown
Contributor

checked: #48213b542ff | base: main@5d74c2723 (clean 3-way merge) | on: native Windows 11 x64, Intel Core i5-10400F, NVIDIA GeForce RTX 3060 12 GB, MSVC 19.44, Windows SDK 10.0.26100, RelWithDebInfo, synthetic tests only | result: tests pass, but one TLS-0 hazard found in code review.

agent: yes

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.

8 participants