Run Grand Theft Auto VI from first boot into the world
The title now boots through every first-boot and menu screen at its own 30 fps, drawing with translated shaders, with input, sound, saves and loading served; it reaches the world, where the host GPU path still fails (see "Not working yet"). Loader and runtime - Crash reports unwind properly, name C++ throws and host GPU failures, carry the title's last debug lines and are appended to crashes.log. - Thread notices on our own threads, reentrant late DLL loading, exit in the console's order, relaunch on a launch-new-game request. - Offline guard: the title cannot reach the network (sockets, name lookups, WinHTTP, the media source resolver); by-name lookups and loads follow the import rules. - Every runtime area the title calls is served (networking hint, packages, store, saves, display, UI, speech stubs, user, async pool). Saves persist; an update is one rename and survives a kill at any step. - DirectStorage reads for real: shared worker pool, priorities, zlib and BCPack. BCPack is our own decoder; the format's constant tables ship in crates/victory-formats/src/bcpack-tables.bin (the asset policy's one exception, see docs/asset-policy.md). - GameInput from XInput pads and the keyboard, with a keyboard stand-in pad; console timers (1 ms) for the whole process. - Audio: XMA2 decoding on the emulated contexts, Opus on the decoder queues, the DSP interface as a stub; title memory placed below 2^40. - Console texture layouts (sizes, tiling, detiling) and the layout library's imports. GPU - Draws, mesh dispatches and compute dispatches run on the host with shaders translated at first use and cached on disk; descriptor heaps, views, root signatures, barriers and host texture states; rectangle lists; comparison samplers. - Title memory reaches the host through persistent mirrors that copy only pages written since the last copy; shader-written buffers are copied back. - Presentation with frame pacing per event kind; framerate in the window caption. Shaders - DXIL emission for vertex, pixel, compute and mesh programs from the console's native code, with a differential test suite against the PC compile. World set: mesh 8,191 of 8,506, vertex/pixel 10,617 of 12,346, compute 1,643 of 2,539; utility set complete. Build - Debugging aids (debug logs, frame capture, stack dumps, scripted keys, the host debug layer, the software adapter) exist only with the `diagnostics` feature; `[profile.diag]` keeps that build apart. Not working yet - In the world the host device is removed within seconds (descriptor handling fixes are in, unproven by a surviving run) and frames present black. - 64-bit image atomics, merged geometry stages and the BVH builder's own shaders do not translate; reverb is silent. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
1 parent
bc3070991a
commit
2849477415
107 files changed
+42526
-868
No files matched your search
@@ -1,5 +1,6 @@
|
||||
//! XSystem: the console's identity and sandbox, and how analytics describe
|
||||
//! the device. Fixed values: one offline retail Xbox Series X.
|
||||
//! the device. Fixed values: one offline retail console, the model the user
|
||||
//! chose ([`victory_gpu::console`]).
|
||||
#![allow(clippy::not_unsafe_ptr_arg_deref)]
|
||||
|
||||
use super::xgameruntime::{
|
||||
@@ -40,8 +41,18 @@ const DEVICE_ID: &str = "VkljdG9yeSBvZmZsaW5lIGRldmljZSBpZGVudGl0eSE=";
|
||||
pub static OBJECT: Object = Object::new("system", &VTABLE);
|
||||
pub static ANALYTICS_OBJECT: Object = Object::new("analytics", &ANALYTICS_VTABLE);
|
||||
|
||||
/// The interface as Grand Theft Auto VI (2026) asks for it; it calls the
|
||||
/// same three slots (0x18, 0x20, 0x28) with the same arguments.
|
||||
pub const IID_2026: Guid = Guid::new(
|
||||
0x1861_cf2e,
|
||||
0xe18b,
|
||||
0x4834,
|
||||
[0xa9, 0xf5, 0xb4, 0xa4, 0xe6, 0xef, 0xb4, 0xcf],
|
||||
);
|
||||
|
||||
pub const INTERFACES: &[Interface] = &[
|
||||
(PROVIDER, IID, &OBJECT),
|
||||
(PROVIDER, IID_2026, &OBJECT),
|
||||
(ANALYTICS, ANALYTICS, &ANALYTICS_OBJECT),
|
||||
];
|
||||
|
||||
@@ -96,7 +107,7 @@ extern "system" fn analytics_info(_: This, out: *mut AnalyticsInfo) -> *mut Anal
|
||||
os: OS,
|
||||
hosting_os: OS,
|
||||
family: text("Xbox"),
|
||||
form: text("Xbox Series X"),
|
||||
form: text(victory_gpu::console::current().name()),
|
||||
};
|
||||
// SAFETY: the caller passes room for the struct.
|
||||
unsafe { out.write(info) };
|
||||
@@ -119,6 +130,241 @@ static ANALYTICS_VTABLE: Methods<4> = Methods([
|
||||
analytics_info as *const (), // 0x18
|
||||
]);
|
||||
|
||||
/// The device type is not a runtime call: code linked into the title reads
|
||||
/// `ConsoleMode` from this key (`RegOpenKeyW`, `RegQueryValueExW`) and
|
||||
/// takes a missing value for a PC.
|
||||
#[cfg(windows)]
|
||||
mod device_type {
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::ffi::c_void;
|
||||
|
||||
use victory_gpu::console::{self, Console};
|
||||
|
||||
use crate::modules::files::host;
|
||||
use crate::{HleModule, hle_export};
|
||||
|
||||
type Key = *mut c_void;
|
||||
const LOCAL_MACHINE: Key = 0xffff_ffff_8000_0002_u64 as Key;
|
||||
const KEY: &str = r"Software\Microsoft\Windows NT\CurrentVersion\OEM";
|
||||
const VALUE: &str = "ConsoleMode";
|
||||
const SUCCESS: u32 = 0;
|
||||
const FILE_NOT_FOUND: u32 = 2;
|
||||
const INVALID_PARAMETER: u32 = 87;
|
||||
const MORE_DATA: u32 = 234;
|
||||
const DWORD: u32 = 4;
|
||||
|
||||
/// Stands for the key; never a host handle value.
|
||||
static OEM: u8 = 0;
|
||||
fn oem() -> Key {
|
||||
(&raw const OEM).cast_mut().cast()
|
||||
}
|
||||
|
||||
/// What the title's code maps to each model's device type.
|
||||
pub(super) fn console_mode(console: Console) -> u32 {
|
||||
match console {
|
||||
Console::SeriesX => 0x64,
|
||||
Console::SeriesS => 0x60,
|
||||
}
|
||||
}
|
||||
|
||||
fn is(text: *const u16, expected: &str) -> bool {
|
||||
if text.is_null() {
|
||||
return false;
|
||||
}
|
||||
// SAFETY: the title passes a NUL-terminated string.
|
||||
let text = unsafe {
|
||||
let len = (0..).take_while(|&i| *text.add(i) != 0).count();
|
||||
String::from_utf16_lossy(std::slice::from_raw_parts(text, len))
|
||||
};
|
||||
text.eq_ignore_ascii_case(expected)
|
||||
}
|
||||
|
||||
/// Opens our key for its path; the key has no subkeys. `None`: not
|
||||
/// ours, ask the host.
|
||||
fn open(root: Key, sub: *const u16, out: *mut Key) -> Option<u32> {
|
||||
if root == oem() {
|
||||
return Some(FILE_NOT_FOUND);
|
||||
}
|
||||
if root == LOCAL_MACHINE && is(sub, KEY) && !out.is_null() {
|
||||
// SAFETY: checked non-null; the title passes room for a key.
|
||||
unsafe { out.write(oem()) };
|
||||
return Some(SUCCESS);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
// Our titles import only these registry functions (and `RegOpenKeyExW`
|
||||
// below), so no other call can reach the host with our key.
|
||||
pub extern "system" fn RegOpenKeyW(root: Key, sub: *const u16, out: *mut Key) -> u32 {
|
||||
open(root, sub, out).unwrap_or_else(|| {
|
||||
host!("advapi32.dll", "RegOpenKeyW": extern "system" fn(Key, *const u16, *mut Key) -> u32)(
|
||||
root, sub, out,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
pub extern "system" fn RegOpenKeyExW(
|
||||
root: Key,
|
||||
sub: *const u16,
|
||||
options: u32,
|
||||
access: u32,
|
||||
out: *mut Key,
|
||||
) -> u32 {
|
||||
open(root, sub, out).unwrap_or_else(|| {
|
||||
host!("advapi32.dll", "RegOpenKeyExW": extern "system" fn(
|
||||
Key, *const u16, u32, u32, *mut Key,
|
||||
) -> u32)(root, sub, options, access, out)
|
||||
})
|
||||
}
|
||||
|
||||
pub extern "system" fn RegQueryValueExW(
|
||||
key: Key,
|
||||
name: *const u16,
|
||||
reserved: *mut u32,
|
||||
kind: *mut u32,
|
||||
data: *mut u8,
|
||||
size: *mut u32,
|
||||
) -> u32 {
|
||||
if key != oem() {
|
||||
return host!("advapi32.dll", "RegQueryValueExW": extern "system" fn(
|
||||
Key, *const u16, *mut u32, *mut u32, *mut u8, *mut u32,
|
||||
) -> u32)(key, name, reserved, kind, data, size);
|
||||
}
|
||||
if !is(name, VALUE) {
|
||||
return FILE_NOT_FOUND;
|
||||
}
|
||||
if !data.is_null() && size.is_null() {
|
||||
return INVALID_PARAMETER;
|
||||
}
|
||||
// SAFETY: the title passes valid or null pointers, sized by `size`.
|
||||
unsafe {
|
||||
if !kind.is_null() {
|
||||
kind.write(DWORD);
|
||||
}
|
||||
if size.is_null() {
|
||||
return SUCCESS;
|
||||
}
|
||||
let room = size.read();
|
||||
size.write(4);
|
||||
if data.is_null() {
|
||||
return SUCCESS;
|
||||
}
|
||||
if room < 4 {
|
||||
return MORE_DATA;
|
||||
}
|
||||
data.cast::<u32>()
|
||||
.write_unaligned(console_mode(console::current()));
|
||||
}
|
||||
tracing::debug!(console = console::current().name(), "device type read");
|
||||
SUCCESS
|
||||
}
|
||||
|
||||
pub extern "system" fn RegCloseKey(key: Key) -> u32 {
|
||||
if key == oem() {
|
||||
return SUCCESS;
|
||||
}
|
||||
host!("advapi32.dll", "RegCloseKey": extern "system" fn(Key) -> u32)(key)
|
||||
}
|
||||
|
||||
pub(crate) fn module() -> HleModule {
|
||||
HleModule {
|
||||
name: "device type",
|
||||
dlls: &["advapi32.dll", "api-ms-win-core-registry-*"],
|
||||
exports: vec![
|
||||
hle_export!(RegOpenKeyW),
|
||||
hle_export!(RegOpenKeyExW),
|
||||
hle_export!(RegQueryValueExW),
|
||||
hle_export!(RegCloseKey),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn w(s: &str) -> Vec<u16> {
|
||||
s.encode_utf16().chain([0]).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn titles_read_the_chosen_model() {
|
||||
assert_eq!(console_mode(Console::SeriesX), 0x64);
|
||||
assert_eq!(console_mode(Console::SeriesS), 0x60);
|
||||
let mut key = std::ptr::null_mut();
|
||||
let path = w(&KEY.to_ascii_lowercase());
|
||||
assert_eq!(RegOpenKeyW(LOCAL_MACHINE, path.as_ptr(), &mut key), SUCCESS);
|
||||
let (mut kind, mut value, mut size) = (0, 0u32, 4);
|
||||
let name = w(VALUE);
|
||||
let query = |data: *mut u32, size: *mut u32, kind: *mut u32| {
|
||||
RegQueryValueExW(
|
||||
key,
|
||||
name.as_ptr(),
|
||||
std::ptr::null_mut(),
|
||||
kind,
|
||||
data.cast(),
|
||||
size,
|
||||
)
|
||||
};
|
||||
assert_eq!(query(&mut value, &mut size, &mut kind), SUCCESS);
|
||||
assert_eq!((kind, size), (DWORD, 4));
|
||||
assert_eq!(value, console_mode(console::current()));
|
||||
let mut small = 2;
|
||||
assert_eq!(query(&mut value, &mut small, &mut kind), MORE_DATA);
|
||||
assert_eq!(small, 4);
|
||||
let other = w("Other");
|
||||
assert_eq!(
|
||||
RegQueryValueExW(
|
||||
key,
|
||||
other.as_ptr(),
|
||||
std::ptr::null_mut(),
|
||||
&mut kind,
|
||||
std::ptr::null_mut(),
|
||||
&mut size
|
||||
),
|
||||
FILE_NOT_FOUND
|
||||
);
|
||||
let mut sub = std::ptr::null_mut();
|
||||
assert_eq!(
|
||||
RegOpenKeyExW(key, other.as_ptr(), 0, 1, &mut sub),
|
||||
FILE_NOT_FOUND
|
||||
);
|
||||
assert_eq!(RegCloseKey(key), SUCCESS);
|
||||
let mut again = std::ptr::null_mut();
|
||||
assert_eq!(
|
||||
RegOpenKeyExW(LOCAL_MACHINE, path.as_ptr(), 0, 1, &mut again),
|
||||
SUCCESS
|
||||
);
|
||||
assert_eq!(again, oem());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn other_keys_reach_the_host() {
|
||||
let mut key = std::ptr::null_mut();
|
||||
let path = w(r"Software\Microsoft\Windows NT\CurrentVersion");
|
||||
assert_eq!(RegOpenKeyW(LOCAL_MACHINE, path.as_ptr(), &mut key), SUCCESS);
|
||||
assert_ne!(key, oem());
|
||||
let (mut size, name) = (0, w("ProductName"));
|
||||
assert_eq!(
|
||||
RegQueryValueExW(
|
||||
key,
|
||||
name.as_ptr(),
|
||||
std::ptr::null_mut(),
|
||||
std::ptr::null_mut(),
|
||||
std::ptr::null_mut(),
|
||||
&mut size
|
||||
),
|
||||
SUCCESS
|
||||
);
|
||||
assert!(size > 0);
|
||||
assert_eq!(RegCloseKey(key), SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(windows)]
|
||||
pub(crate) use device_type::module;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in new issue
Block a user