Skip to content

C-1: resolve clippy warnings in leonida-gpu - #20

Open
yadashtpc-boop wants to merge 1 commit into
ProjectLeonidaL:mainfrom
yadashtpc-boop:fix/clippy-warnings-c1
Open

yadashtpc-boop wants to merge 1 commit into
ProjectLeonidaL:mainfrom
yadashtpc-boop:fix/clippy-warnings-c1

Conversation

@yadashtpc-boop

Copy link
Copy Markdown

Fixes C-1 from TODO.md. Resolves all clippy warnings in leonida-gpu:

  • fpsbox.rs: contains_key + insert -> entry()
  • draw.rs: sort_unstable_by -> sort_unstable_by_key
  • indirect.rs: #[allow(dead_code)] on Rig.depth_written (test rig
    field, pending upstream VIctory 4ab20fc, see C-2)
  • resource.rs: #[allow(dead_code)] on placed_filler_twins (read only
    by the copystat memory log under the diagnostics feature)
  • queue.rs, shadow.rs: manual x % n == 0 -> .is_multiple_of(n)

cargo clippy --workspace --all-targets: no warnings.
cargo test --workspace: all crates pass (leonida-gpu 182 passed,
leonida-shader 215 passed, leonida-hle 98 passed).

Note: indirect::tests::warp_budget_saturates_without_wraparound_and_
preserves_draw_fields (listed in C-2 as possibly fixed by upstream
VIctory 4ab20fc) already passes on this tree.

@ShinniUwU ShinniUwU left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. The six changes are correct and keep behaviour the same, but three things are needed before it can go in:

1. Rebase on main. #19 merged after this was opened and there is one conflict, in crates/leonida-gpu/src/resource.rs. Main added texture_kind and title_texture right after placed_filler_twins, and this PR adds a blank line at the same spot. Keep both sides and drop the extra blank line.

2. Three more is_multiple_of spots. They only show up in the diagnostics build (the second CI step, --all-features). The C-1 row missed them because CI on main stops at the first clippy step. They were already there at this PR's base, so this PR did not introduce them.

// draw.rs:3324
if N.fetch_add(1, std::sync::atomic::Ordering::Relaxed).is_multiple_of(256) {
// watch.rs:481
if !N.fetch_add(1, std::sync::atomic::Ordering::Relaxed).is_multiple_of(2048) {
// watch.rs:872
if N.fetch_add(1, std::sync::atomic::Ordering::Relaxed).is_multiple_of(1024) {

3. Delete the C-1 row from TODO.md. The list's rule is that the pull request finishing an item removes its row.

What I ran

I merged this head (32aad8a) with main (f552464) in a scratch copy, on the pinned 1.98.1 toolchain, and ran the three CI commands:

CI step Result
cargo clippy --workspace --all-targets --locked -- -D warnings passes
same with --all-features fails with the 3 errors above
cargo test --workspace --locked passes (leonida-gpu 185, leonida-shader 215, leonida-hle 100)

With the three fixes from point 2 applied, the --all-features step passes too.

Notes

  • The #[allow(dead_code)] on placed_filler_twins is justified: its only caller is copystat.rs:810, and that module is compiled only with the diagnostics feature.
  • The allow on depth_written is fine, the field is set but never read. Its comment ties it to upstream 4ab20fc, which TODO.md lists as not checked, so I would word that comment as a maybe.
  • Confirmed: indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields passes on the merged tree.
  • CI has not run on this PR yet. The run is waiting for a maintainer to approve it.

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.

2 participants