Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exclude = ["tests/fixtures"]
[workspace.package]
version = "0.1.0"
edition = "2024"
rust-version = "1.88"
rust-version = "1.89"
license = "GPL-3.0-or-later"
publish = false

Expand Down
5 changes: 3 additions & 2 deletions PLAY_FACES_FIX.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ setlocal
rem GTA VI with DLSS frame generation and facial mesh relocation enabled.
rem Usage: PLAY_FACES_FIX.cmd [mode 1-6], default mode 1.
set "PS1=%~dp0scripts\play-gta6-framegen.ps1"
set "PSH=pwsh"
set "PSH=powershell"
set "MODE=%~1"
if "%MODE%"=="" set "MODE=1"
if exist "C:\Program Files\PowerShell\7\pwsh.exe" set "PSH=C:\Program Files\PowerShell\7\pwsh.exe"
where pwsh >nul 2>nul && set "PSH=pwsh"
if "%PSH%"=="powershell" if exist "C:\Program Files\PowerShell\7\pwsh.exe" set "PSH=C:\Program Files\PowerShell\7\pwsh.exe"

if not exist "%PS1%" (
echo Not found: %PS1%
Expand Down
3 changes: 2 additions & 1 deletion PLAY_FRAMEGEN.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ if not exist "%PS1%" (
)
if /i not "%~1"=="check" goto :menu
%PSH% -NoProfile -ExecutionPolicy Bypass -File "%PS1%" -Check
set "RC=%errorlevel%"
pause
rem The check's answer is what callers read: a failed check says so.
exit /b %errorlevel%
exit /b %RC%
:menu
set "PICK=%~1"
if not "%PICK%"=="" goto :run
Expand Down
1 change: 1 addition & 0 deletions crates/victory-gpu/src/compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ impl Composer {
/// Each presenter command-list slot owns its own pair of SRVs. The swap
/// chain may have several outstanding presents; the slot is selected by
/// the completion fence, and its descriptors are only overwritten on reuse.
#[allow(clippy::too_many_arguments)]
pub(crate) fn record(
&mut self,
host: &Host,
Expand Down
2 changes: 2 additions & 0 deletions crates/victory-gpu/src/descriptor/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4580,6 +4580,8 @@ impl HostHeap {
/// slot back in the written set, which would have the next pass look at
/// it again for nothing (a title write leaves a buffer slot for later,
/// and the pass's own look makes it).
// (unused since the 11.29.01 merge; the batch's own `mirror_for_pass` is the one called)
#[allow(dead_code)]
pub(crate) fn mirror_for_pass(&self, index: u32, handle: u64) -> Option<View> {
if !crate::asked_for!("VICTORY_HEAP_LOOK_QUIET") {
return self.mirror(index, handle, true);
Expand Down
4 changes: 4 additions & 0 deletions crates/victory-gpu/src/fetchmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub(crate) fn on() -> bool {
/// (rounded up to 16 MiB, so the next fetches fit) unless `tight`, then
/// rounded to 1 MiB, then as small as the bytes allow. Never fewer than
/// `total`.
// (unused since the 11.29.01 merge, with `Host::fetch_buffer`)
#[allow(dead_code)]
pub(crate) fn sizes(total: u64, tight: bool) -> Vec<u64> {
let mut sizes = Vec::with_capacity(3);
if !tight {
Expand All @@ -51,6 +53,8 @@ static COUNTS: [AtomicU64; 3] = [const { AtomicU64::new(0) }; 3];
/// ([`sizes`]) and then, after `pause`, the least once more. The buffer and
/// its size; `None` only when not even the least could be made (the caller
/// skips the fetch, [`skipped`]). With the switch off, the usual size once.
// (unused since the 11.29.01 merge, with `Host::fetch_buffer`)
#[allow(dead_code)]
pub(crate) fn buffer<T>(
total: u64,
tight: bool,
Expand Down
7 changes: 6 additions & 1 deletion crates/victory-gpu/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2963,6 +2963,8 @@ fn scratch_wb(host: &Host) -> bool {
/// Picks a kept chunk of `size` bytes from `spare`: write-combined callers
/// (`wb == false`) only take write-combined chunks; write-back callers prefer
/// write-back chunks and reuse write-combined fallback chunks when none exist.
// (unused since the 11.29.01 merge; its tests still run)
#[allow(dead_code)]
fn take_spare_wb<T>(spare: &mut Spare<T>, size: u64, wb: bool, is_wb: impl Fn(&T) -> bool) -> Option<T> {
spare
.take_if(size, |t| is_wb(t) == wb)
Expand Down Expand Up @@ -12524,7 +12526,7 @@ impl Batch {
if ahead {
crate::watch::ahead_snapshot_into(&mut self.ahead_snap);
}
let ahead_snap = &self.ahead_snap;
// (`self.ahead_snap` is filled above but no longer read here: unused since the 11.29.01 merge.)
FLUSHES[3].fetch_add(spans.len() as u64, Ordering::Relaxed);
// (The textures one to a thread; the copies as `VICTORY_WIDE_CHUNK` says.)
crate::shadow::wide_each_scoped(spans.len() + due.len(), 1, &|lo, hi| {
Expand Down Expand Up @@ -12665,6 +12667,7 @@ impl Batch {
// and any thread woken. (Thousands of them, the heap's buffer views
// once a frame: on the threads, below.)
const FEW: usize = 256;
#[allow(dead_code)] // (unused since the 11.29.01 merge)
const MANY_CHUNK: usize = 8;
let light = crate::watch::light();
let batch = crate::shadow::new_batch();
Expand Down Expand Up @@ -15521,6 +15524,8 @@ impl Host {
/// least after a moment (the card retires what it holds meanwhile).
/// `None` only when not even the least fits: the caller skips the fetch
/// (`crate::fetchmem::skipped`). The buffer, its mapping and its size.
// (unused since the 11.29.01 merge)
#[allow(dead_code)]
fn fetch_buffer(&self, total: u64) -> Option<(ID3D12Resource, usize, u64)> {
crate::fetchmem::buffer(
total,
Expand Down
12 changes: 12 additions & 0 deletions crates/victory-gpu/src/host/card_steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,16 @@ mod late {
pages.as_ref().is_some_and(|p| (from / PAGE..to.div_ceil(PAGE)).any(|page| p.contains(&page)))
}

#[cfg(test)]
pub(super) fn forget(from: usize, to: usize) {
let mut pages = PAGES.lock().unwrap_or_else(|e| e.into_inner());
if let Some(p) = pages.as_mut() {
for page in from / PAGE..to.div_ceil(PAGE) {
p.remove(&page);
}
}
}

/// The submission has landed: what the fills of `sent` (place, length,
/// place in the buffer between) read, in `back`, compared with title
/// memory now.
Expand Down Expand Up @@ -2108,6 +2118,7 @@ mod tests {
// Two pages of memory of our own, page-aligned, as title memory.
let memory = vec![0u8; 4 * 4096];
let page = (memory.as_ptr() as usize).next_multiple_of(4096);
late::forget(page, page + 2 * 4096);
let (kept, changed) = (page, page + 4096 + 64);
// What the card read: the bytes as they were, at 0 and 256 of the
// buffer between.
Expand All @@ -2130,6 +2141,7 @@ mod tests {
fn fills_done_on_the_cpu_are_learned_too() {
let memory = vec![0u8; 4 * 4096];
let page = (memory.as_ptr() as usize).next_multiple_of(4096);
late::forget(page, page + 2 * 4096);
let (kept, changed) = (page + 16, page + 4096 + 0xbd0);
// The upload memory each was filled into: the bytes as they were.
let upload = vec![0u8; 1024];
Expand Down
1 change: 0 additions & 1 deletion crates/victory-gpu/src/host/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ pub(super) const fn glyph(c: u8) -> [u8; 7] {
b'<' => [0b00010, 0b00100, 0b01000, 0b10000, 0b01000, 0b00100, 0b00010],
b'*' => [0, 0b00100, 0b10101, 0b01110, 0b10101, 0b00100, 0],
b':' => [0, 0b01100, 0b01100, 0, 0b01100, 0b01100, 0],
b'%' => [0b11001, 0b11010, 0b00010, 0b00100, 0b01000, 0b01011, 0b10011],
b'_' => [0, 0, 0, 0, 0, 0, 0b11111],
b'=' => [0, 0, 0b11111, 0, 0b11111, 0, 0],
b'(' => [0b00010, 0b00100, 0b01000, 0b01000, 0b01000, 0b00100, 0b00010],
Expand Down
2 changes: 1 addition & 1 deletion crates/victory-gpu/src/host/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fn graph_lit(graphs: &[Vec<f32>], shape: Shape, x: u32, below: u32) -> bool {
return false;
}
if within == GRAPH - 1 {
return x % 2 == 0;
return x.is_multiple_of(2);
}
let Some(samples) = graphs.get(i) else {
return false;
Expand Down
2 changes: 2 additions & 0 deletions crates/victory-gpu/src/host/recycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub(crate) enum Kind {
/// [`super::Host::upload_buffer`].
Upload = 1,
/// [`super::Host::uav_buffer`]: the card's memory.
// (unused since the 11.29.01 merge)
#[allow(dead_code)]
Card = 2,
}

Expand Down
5 changes: 3 additions & 2 deletions crates/victory-gpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ pub use watch::{
title_memory_written, title_placeholder_reserved, use_lazy_views, use_soft_views, writing as kernel_will_write, Remapping,
};

#[doc(hidden)]
pub use watch::set_range_lock;

#[cfg(test)]
mod world_tests {
#[test]
Expand All @@ -276,5 +279,3 @@ mod world_tests {
assert!(!super::world_reached(10_000, 20));
}
}
#[doc(hidden)]
pub use watch::set_range_lock;
2 changes: 1 addition & 1 deletion crates/victory-gpu/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2655,7 +2655,7 @@ mod state {
};
// SAFETY: the title passes a handle or null.
let depth = unsafe { depth.as_ref() }.copied().unwrap_or(0);
with_set_state(this, |list, s| s.set_targets(list, &handles, depth));
with_set_state(this, |list, s| s.set_targets(list, handles, depth));
}
pub(super) extern "system" fn draw(
this: This,
Expand Down
2 changes: 2 additions & 0 deletions crates/victory-gpu/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ mod timing {

/// [`MEMORY`], locked; the wait counted in [`timing::WAIT`] when it was not
/// free at once.
// (unused since the 11.29.01 merge)
#[allow(dead_code)]
fn lock_memory() -> std::sync::MutexGuard<'static, Option<Memory>> {
match MEMORY.try_lock() {
Ok(guard) => guard,
Expand Down
8 changes: 8 additions & 0 deletions crates/victory-gpu/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,11 +836,15 @@ pub(crate) extern "system" fn create_compute_x(

/// The largest part of a console pipeline that is believed (the biggest seen
/// is 127 KiB of code).
// (unused since the 11.29.01 merge, with `create_loose_compute`)
#[allow(dead_code)]
const MAX_LOOSE_PART: usize = 16 << 20;

/// A container holding one `ACCC` part: an `FSPX` of `entries` (kind, data), as
/// the console compiler stores a compute program that another compiler made
/// (`victory_shader::native::fspx_program` reads it back).
// (unused since the 11.29.01 merge outside tests, with `create_loose_compute`)
#[allow(dead_code)]
fn fspx_container(entries: &[(u32, &[u8])]) -> Vec<u8> {
let mut fspx = b"FSPX".to_vec();
fspx.extend(1u32.to_le_bytes());
Expand Down Expand Up @@ -880,6 +884,8 @@ fn fspx_container(entries: &[(u32, &[u8])]) -> Vec<u8> {
///
/// # Safety
/// Every pair names bytes of the title that are mapped.
// (unused since the 11.29.01 merge, with `create_loose_compute`)
#[allow(dead_code)]
unsafe fn loose_compute(desc: &[u64; 11]) -> Option<Vec<u8>> {
let part = |at: usize| -> Option<&[u8]> {
let (address, size) = (desc[at], desc[at + 1] as usize);
Expand All @@ -893,6 +899,8 @@ unsafe fn loose_compute(desc: &[u64; 11]) -> Option<Vec<u8>> {
/// Device method 0x218 `(this, description, iid, out)`: a compute pipeline
/// whose console parts come loose, not in a container. They are put into one
/// and the pipeline goes on as any other.
// (unused since the 11.29.01 merge: no device method slot names it)
#[allow(dead_code)]
pub(crate) extern "system" fn create_loose_compute(
_: This,
desc: *const [u64; 11],
Expand Down
2 changes: 1 addition & 1 deletion crates/victory-gpu/src/pipeline/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ fn load_sharded(
let copies = shards(library);
let at = shard_of(text, copies.len() + 1);
let done = SHARD_LOADS[at].fetch_add(1, Ordering::Relaxed) + 1;
if done % 500 == 0 {
if done.is_multiple_of(500) {
let per: Vec<u64> = (0..=copies.len()).map(|i| SHARD_LOADS[i].load(Ordering::Relaxed)).collect();
tracing::info!(?per, missed = SHARD_MISSES.load(Ordering::Relaxed), "host pipeline library shard loads");
}
Expand Down
2 changes: 2 additions & 0 deletions crates/victory-gpu/src/pipeline/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,8 @@ impl Queue {
Some(prev == NOT_QUEUED)
}

// (unused since the 11.29.01 merge)
#[allow(dead_code)]
fn pop(&mut self, screens_only: bool, slow_limit: usize) -> Option<Arc<Pending>> {
self.pop_in(screens_only, false, slow_limit)
}
Expand Down
6 changes: 5 additions & 1 deletion crates/victory-gpu/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2372,7 +2372,7 @@ pub(crate) fn targets_room_kept(memory: Option<[u64; 4]>) -> u64 {
.and_then(|v| v.trim().parse::<u64>().ok())
.map(|mb| mb.min(8192) << 20)
});
let most = requested.unwrap_or_else(|| match memory {
let most = requested.unwrap_or(match memory {
Some([budget, ..]) if budget <= (8u64 << 30) => 2560 << 20,
_ => 3072 << 20,
});
Expand Down Expand Up @@ -3559,6 +3559,10 @@ fn slot_evict(video: Option<[u64; 4]>, idle_ms: u64, frames: u64, flush: u8) ->
// holds the table: the texture is in use then, and stays.)
let (reset, busy) = crate::descriptor::evict_slots(at, &slots[&at]);
SLOT_EVICT[2].fetch_add(reset, Relaxed);
if busy {
SLOT_EVICT[6].fetch_add(1, Relaxed);
continue;
}
let outcome = {
let all = textures();
if !all.contains(&at) {
Expand Down
2 changes: 1 addition & 1 deletion crates/victory-gpu/src/shader_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use std::path::PathBuf;
use std::sync::{Condvar, Mutex, OnceLock};
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::sync::atomic::{AtomicU64, Ordering};

use victory_pipeline::{Cache, CacheKey, Converter};
use victory_shader::emit::{HostShader, StaticSampler, UserData};
Expand Down
4 changes: 4 additions & 0 deletions crates/victory-gpu/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2804,6 +2804,8 @@ pub(crate) fn wide_each(n: usize, work: impl Fn(usize) + Send + Sync + 'static)
/// nothing and 9,086 of them told so on the threads (session 2026-11-28
/// 00:45): each took its number from one counter all the threads share, and
/// a flush of a few small ones woke as many threads as it had pieces.
// (unused since the 11.29.01 merge; its tests still run)
#[allow(dead_code)]
pub(crate) fn wide_chunk() -> usize {
static CHUNK: std::sync::OnceLock<usize> = std::sync::OnceLock::new();
*CHUNK.get_or_init(|| {
Expand Down Expand Up @@ -6291,6 +6293,8 @@ impl Shadow {
/// Lock-free [`Shadow::nothing_new`] using a pre-snapshotted `ahead` list
/// from [`crate::watch::ahead_snapshot_into`]. Acquires zero locks on the
/// common (no pending shader writes) path.
// (unused since the 11.29.01 merge)
#[allow(dead_code)]
pub(crate) fn nothing_new_with(&self, ahead: &[(usize, usize)], address: usize, len: usize) -> bool {
if self.place.is_some() {
return true;
Expand Down
18 changes: 9 additions & 9 deletions crates/victory-gpu/src/streamline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,12 +1007,10 @@ pub fn highest_shader_model() -> Option<(u32, u32)> {
let mut device: Option<ID3D12Device> = None;
// As the title's device (`host::create`): on the first adapter where
// the card takes none.
if let Some((adapter, ..)) = victory_shader::emit::host::hardware_adapter() {
let _ = D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_11_0, &mut device);
}
let _ = D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_11_0, &mut device);
if device.is_none() {
let adapter = CreateDXGIFactory1::<IDXGIFactory1>().ok()?.EnumAdapters1(0).ok()?;
D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_11_0, &mut device).ok()?;
let fallback = CreateDXGIFactory1::<IDXGIFactory1>().ok()?.EnumAdapters1(0).ok()?;
D3D12CreateDevice(&fallback, D3D_FEATURE_LEVEL_11_0, &mut device).ok()?;
}
device?
};
Expand Down Expand Up @@ -3686,10 +3684,12 @@ mod framegen_tests {
// Multi-frame generation (up to 6X) presents up to 5 synthesized frames per engine
// frame. In DXGI flip-discard mode, at least 8 swap chain buffers are required so that
// the GPU and compositor never run out of back buffers while presenting.
assert!(
crate::host::BUFFERS >= 8,
"swap chain buffer count must be at least 8 to prevent DXGI flip-discard starvation"
);
const {
assert!(
crate::host::BUFFERS >= 8,
"swap chain buffer count must be at least 8 to prevent DXGI flip-discard starvation"
)
};
}

#[test]
Expand Down
2 changes: 2 additions & 0 deletions crates/victory-gpu/src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,8 @@ pub(crate) fn writes(start: usize, end: usize, guarded: bool) -> Option<(u64, Ve
/// whole, or 0) does not hold, using a pre-snapshotted `ahead` list and
/// [`WRITTEN_EPOCHS`]. Acquires zero locks; `false` if something would have to
/// be asked.
// (unused since the 11.29.01 merge)
#[allow(dead_code)]
pub(crate) fn nothing_new_with(
ahead: &[(usize, usize)],
start: usize,
Expand Down
4 changes: 2 additions & 2 deletions crates/victory-hle/src/modules/gameinput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ impl State {
.fold(merged(merged(base_fallback, look), overlay.pad), merged);
let pad = apply_trigger_overrides(pad, overlay.lt_override, overlay.rt_override);
self.update(devices, FALLBACK, Some(Value::Pad(pad)), now, &mut events);
self.update(devices, KEYBOARD, (!pads_only).then(|| Value::Keys(keys)), now, &mut events);
self.update(devices, KEYBOARD, (!pads_only).then_some(Value::Keys(keys)), now, &mut events);
return events;
}
// Counted over the pads actually shown below: an all-zero pad is no
Expand Down Expand Up @@ -873,7 +873,7 @@ impl State {
))
});
self.update(devices, FALLBACK, fallback, now, &mut events);
self.update(devices, KEYBOARD, (!pads_only).then(|| Value::Keys(keys)), now, &mut events);
self.update(devices, KEYBOARD, (!pads_only).then_some(Value::Keys(keys)), now, &mut events);
events
}

Expand Down
13 changes: 7 additions & 6 deletions crates/victory-hle/src/modules/lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,13 @@ pub(crate) fn module() -> HleModule {
}
}

/// Whether `message` is a key, character, raw-input or mouse message (`WM_INPUT`, `WM_KEYFIRST`
/// to `WM_KEYLAST`, `WM_MOUSEFIRST` to `WM_MOUSELAST`).
#[cfg(windows)]
fn keys_or_mouse(message: u32) -> bool {
message == 0x00FF || (0x0100..=0x0109).contains(&message) || (0x0200..=0x020E).contains(&message)
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -1287,9 +1294,3 @@ mod tests {
}
}

/// Whether `message` is a key, character, raw-input or mouse message (`WM_INPUT`, `WM_KEYFIRST`
/// to `WM_KEYLAST`, `WM_MOUSEFIRST` to `WM_MOUSELAST`).
#[cfg(windows)]
fn keys_or_mouse(message: u32) -> bool {
message == 0x00FF || (0x0100..=0x0109).contains(&message) || (0x0200..=0x020E).contains(&message)
}
1 change: 1 addition & 0 deletions crates/victory-loader/src/crash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ pub(crate) fn unwind_into(context: CONTEXT, low: usize, high: usize, frames: &mu
/// pages and faulted, run perfil-barco 28/11). Registers that point into the
/// copied range are moved into the copy; a frame register that points
/// elsewhere ends the walk.
#[cfg(feature = "diagnostics")]
pub(crate) fn unwind_copy(context: CONTEXT, copy: &[u8], len: usize, frames: &mut Vec<u64>) {
let mut aligned = Aligned16(context);
let context = &mut aligned.0;
Expand Down
1 change: 0 additions & 1 deletion crates/victory-shader/src/emit/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,6 @@ mod analysis;
pub use analysis::with_program;
pub use analysis::{lds_clamped, lds_clamped_mesh};
pub(super) use analysis::last_resort_wanted;
pub(in crate::emit) use analysis::lane_regions;
pub(in crate::emit) use analysis::once_per_thread;
use analysis::{CLAMPED, CLAMPED_MESH, lds_mesh_free};
pub(super) use analysis::{
Expand Down
Loading
Loading