Skip to content
Merged
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
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ The goal: a console-like experience on PC. The game starts straight into play, h

| ID | Task | Where | Needs |
|----|------|-------|-------|
| C-1 | CI is red on clippy: `resource.rs:2553` (`placed_filler_twins` unused), `indirect.rs:2453` (`depth_written` never read), `fpsbox.rs:174` (`contains_key` then `insert`), `draw.rs:2577` (`sort_unstable_by_key`), `queue.rs:672`, `shadow.rs:2803` and `shadow.rs:3325` (`is_multiple_of`). All in `leonida-gpu`, all inherited from victory-gta6. | `leonida-gpu` | - |
| C-2 | Failing test `indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields`, inherited from victory-gta6. Upstream VIctory `4ab20fc` ("the indirect budget is charged in record order and no longer wraps") may fix it; not checked. | `leonida-gpu` | - |
| C-3 | `cargo fmt --check` reports about 1,420 differences. Run `cargo fmt` once, in a pull request of its own, at a moment when no other pull request is open (it touches almost every file), then add the check to CI. | all | - |
| C-4 | 163 `shortcut:` markers where the code approximates the console (79 in `leonida-gpu`, 55 in `leonida-shader`, 23 in `leonida-hle`, 4 in `leonida-formats`, 2 in `leonida-loader`). Replace them with the console's real behaviour, one per pull request. | all | game |
Expand Down
4 changes: 2 additions & 2 deletions crates/leonida-gpu/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2574,7 +2574,7 @@ impl State {
let draws: u32 = census.1.values().sum();
if draws > 0 {
let mut rects: Vec<([i32; 4], u32)> = census.1.iter().map(|(r, n)| (*r, *n)).collect();
rects.sort_unstable_by(|a, b| b.1.cmp(&a.1));
rects.sort_unstable_by_key(|r| std::cmp::Reverse(r.1));
let scissors: Vec<String> = rects
.iter()
.take(5)
Expand Down Expand Up @@ -3321,7 +3321,7 @@ impl State {
// the record drawn before it.
if (6..=8).contains(&why_not) {
static N: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
if N.fetch_add(1, std::sync::atomic::Ordering::Relaxed) % 256 == 0 {
if N.fetch_add(1, std::sync::atomic::Ordering::Relaxed) .is_multiple_of(256) {
let (last_copy, last_offset) = self.last_indirect;
tracing::info!(
"a window miss (one in 256): cause {why_not}, kind {kind}, stride {stride}, buffer {} offset {offset:#x} ({} left); the command before it on the list: buffer {last_copy} offset \
Expand Down
4 changes: 2 additions & 2 deletions crates/leonida-gpu/src/fpsbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub(crate) fn draw(host: &crate::host::Host, list: &ID3D12GraphicsCommandList, b
made.clear();
}
let key = (tenths, format.0, scale);
if !made.contains_key(&key) {
if let std::collections::hash_map::Entry::Vacant(e) = made.entry(key) {
let (w, h, lit) = bitmap(&text(tenths), scale);
let pitch = (w as usize * bytes).next_multiple_of(D3D12_TEXTURE_DATA_PITCH_ALIGNMENT as usize);
let Some((buffer, data)) = host.shared_buffer((pitch * h as usize) as u64) else {
Expand All @@ -185,7 +185,7 @@ pub(crate) fn draw(host: &crate::host::Host, list: &ID3D12GraphicsCommandList, b
pixel(format, lit[y * w as usize + x], &mut out[at..at + bytes]);
}
}
made.insert(key, Made { buffer, width: w, height: h, pitch: pitch as u32 });
e.insert(Made { buffer, width: w, height: h, pitch: pitch as u32 });
}
let Some(m) = made.get(&key) else {
return;
Expand Down
1 change: 1 addition & 0 deletions crates/leonida-gpu/src/indirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,7 @@ void work() {
heap_pairs: [[Option<ID3D12DescriptorHeap>; 2]; 2],
tables: [D3D12_GPU_DESCRIPTOR_HANDLE; 2],
targets: [D3D12_CPU_DESCRIPTOR_HANDLE; 2],
#[allow(dead_code)] // TODO C-2: pending upstream VIctory 4ab20fc
depth_written: D3D12_CPU_DESCRIPTOR_HANDLE,
depth_tested: D3D12_CPU_DESCRIPTOR_HANDLE,
stamps: ID3D12QueryHeap,
Expand Down
2 changes: 1 addition & 1 deletion crates/leonida-gpu/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ fn send_joined(joined: &mut Joined) {
let sent = JOINED[1].fetch_add(1, Ordering::Relaxed) + 1;
JOINED[2].fetch_add(order.len() as u64, Ordering::Relaxed);
JOINED[3].fetch_add(joined.signals.len() as u64, Ordering::Relaxed);
if sent % 2048 == 0 {
if sent.is_multiple_of(2048) {
let n: Vec<u64> = JOINED.iter().map(|n| n.swap(0, Ordering::Relaxed)).collect();
tracing::info!(
"parts joined (LEONIDA_JOIN_PARTS=1): {} parts went to the host in {} submissions ({:.1} parts, {:.1} lists each), {} signals delivered behind them, {} waits passed for a write of a part not sent yet",
Expand Down
2 changes: 2 additions & 0 deletions crates/leonida-gpu/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2553,10 +2553,12 @@ static PLACED_TWINS: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64

/// See [`PLACED_TWINS`].
#[cfg(windows)]
#[allow(dead_code)] // read by the copystat memory log (diagnostics builds)
pub(crate) fn placed_filler_twins() -> u64 {
PLACED_TWINS.load(std::sync::atomic::Ordering::Relaxed)
}


/// Width, height and format of texture `this` (`None` for a buffer), for
/// `crate::texback`'s kinds.
#[cfg(windows)]
Expand Down
4 changes: 2 additions & 2 deletions crates/leonida-gpu/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2935,7 +2935,7 @@ impl Shadow {
}
OWN_WRITES[1].fetch_add(bytes.len() as u64, Ordering::Relaxed);
let n = OWN_WRITES[0].fetch_add(1, Ordering::Relaxed) + 1;
if n % 16384 == 0 {
if n.is_multiple_of(16384) {
tracing::info!(
"what shaders wrote, stored through views of our own (LEONIDA_BACK_OWN_VIEW=1), since the start: {n} stretches {} MB, {} pages noted current for the copy that wrote them (not copied in again), {} stretches written the old way; with LEONIDA_BACK_OWN_CHECK=1: {} stores the title's address did not show, {} pages noted current whose CPU side differs from title memory, {} of those with the guard clean",
OWN_WRITES[1].load(Ordering::Relaxed) >> 20,
Expand Down Expand Up @@ -3457,7 +3457,7 @@ impl Shadow {
COPY_CHANGED[1].fetch_add(sent as u64, Ordering::Relaxed);
COPY_CHANGED[2].fetch_add(stretches.len() as u64, Ordering::Relaxed);
let calls = COPY_CHANGED[3].fetch_add(1, Ordering::Relaxed) + 1;
if calls % 65536 == 0 {
if calls.is_multiple_of(65536) {
tracing::info!(
"copies in the card's memory, refreshed by what differs (LEONIDA_COPY_CHANGED=1), since the start: {calls} refreshes read {} MB of title memory the title had written to; {} MB of it differed from the copy and went on to the card, in {} stretches",
COPY_CHANGED[0].load(Ordering::Relaxed) >> 20,
Expand Down
4 changes: 2 additions & 2 deletions crates/leonida-gpu/src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ pub(crate) fn writes(start: usize, end: usize, guarded: bool) -> Option<(u64, Ve
fn failed_asking(start: usize, end: usize) {
use windows_sys::Win32::System::Memory::{MEMORY_BASIC_INFORMATION, VirtualQuery};
static N: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
if N.fetch_add(1, std::sync::atomic::Ordering::Relaxed) % 2048 != 0 {
if !N.fetch_add(1, std::sync::atomic::Ordering::Relaxed).is_multiple_of(2048) {
return;
}
// SAFETY: plain data filled in by the query.
Expand Down Expand Up @@ -869,7 +869,7 @@ fn protect_here(g: &mut Guards, from: usize, to: usize) {
#[cfg(feature = "diagnostics")]
{
static N: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
if N.fetch_add(1, std::sync::atomic::Ordering::Relaxed) % 1024 == 0 {
if N.fetch_add(1, std::sync::atomic::Ordering::Relaxed) .is_multiple_of(1024) {
tracing::info!("a block of title memory could not be made read-only (one in 1024): {:#x}: {error}", block * BLOCK);
}
}
Expand Down