Files
mandy/runtime/shims/console_identity.h
Moriz82 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

50 lines
2.3 KiB
C++

// Which console the title is told it runs on: one setting, two answers.
//
// The title learns its console model two ways. Some code calls XSystemGetDeviceType; GTA VI's own code instead
// reads HKLM\Software\Microsoft\Windows NT\CurrentVersion\OEM, value ConsoleMode (a DWORD), and takes a missing
// value for a PC (docs/runtime_imports.md, "Console identity in the registry"). Both answers come from
// LEONIDA_DEVICE_TYPE through this header so they can never disagree.
//
// The ConsoleMode numbers (0x60 Series S, 0x64 Series X) are what VIctory's xsystem.rs maps (commit 2849477,
// GPL-3.0-or-later); 0x68 for the Scarlett devkit is the value xbox-emulator's xpal and gdk/hook.rs use (commit
// 0284e83, GPL-3.0).
#pragma once
#include <windows.h>
#include <cstdint>
#include <cstdlib>
namespace rt::shims::console_identity {
// XSystemDeviceType, in the order of the public documentation.
enum class DeviceType : uint32_t {
Unknown = 0, Pc = 1, XboxOne = 2, XboxOneS = 3, XboxOneX = 4, XboxOneXDevkit = 5,
XboxScarlettLockhart = 6, XboxScarlettAnaconda = 7, XboxScarlettDevkit = 8,
};
// The device type the title is told: LEONIDA_DEVICE_TYPE=<0..8>, read at every call so a test or a launcher change is
// seen at once. Text that is not a number counts as 0; a number outside 0..8 or an unset variable gives Series X, as
// XSystemGetDeviceType always did (the package is the Xbox Series build).
inline uint32_t configured_device_type() {
char s[16];
const DWORD n = GetEnvironmentVariableA("LEONIDA_DEVICE_TYPE", s, sizeof(s));
if (n > 0 && n < sizeof(s)) {
const int v = std::atoi(s);
if (v >= 0 && v <= 8) return static_cast<uint32_t>(v);
}
return static_cast<uint32_t>(DeviceType::XboxScarlettAnaconda);
}
// The registry's ConsoleMode for a device type. False for the types that have none (Unknown, Pc and the Xbox One
// family): the title takes a missing value for a PC, so the registry shim leaves those to the host registry.
inline bool console_mode_for(uint32_t device_type, DWORD& mode) {
switch (static_cast<DeviceType>(device_type)) {
case DeviceType::XboxScarlettLockhart: mode = 0x60; return true;
case DeviceType::XboxScarlettAnaconda: mode = 0x64; return true;
case DeviceType::XboxScarlettDevkit: mode = 0x68; return true;
default: return false;
}
}
} // namespace rt::shims::console_identity