Skip to content

Tests: some_ranges in texture_upload wraps its generator instead of overflowing - #2771

Draft
inf1425 wants to merge 1 commit into
xcl-dev:nvidia-devfrom
inf1425:tests/texture-upload-lcg-overflow
Draft

inf1425 wants to merge 1 commit into
xcl-dev:nvidia-devfrom
inf1425:tests/texture-upload-lcg-overflow

Conversation

@inf1425

@inf1425 inf1425 commented Nov 26, 2026 •

Copy link
Copy Markdown

The some_ranges helper in texture_upload's tests advances a linear congruential generator with n = n * 1103515245 + 12345, and n grows without bound. By the third loop pass it exceeds u64, and debug builds (cargo test) panic with "attempt to multiply with overflow". Both GPU tests that use the helper fail on a GPU. CI has no GPU, so they return before reaching it. The step now wraps, as such a generator should. Royalflamejlh reported this in #42 (comment) and proposed exactly this line. This PR applies it.

What is in it

  • crates/xcl/src/hle/d3d12x/texture_upload.rs (in mod tests): n = n.wrapping_mul(1103515245).wrapping_add(12345). Test code only. The helper came in with 73fc616.

Tested

Regression run

  • The change is inside #[cfg(test)] mod tests and never reaches xcl.exe, but scripts/pr_check.py counts any file under crates/xcl/src/ as runtime. Smoke blocks from nvidia-dev and from this head will be added once a title is available, unless a maintainer prefers the test-only label.

main:

PR:

Not tested

  • AMD, other NVIDIA cards, Linux/Wine, a release build, any retail title (smoke run pending).

AI use

  • Claude Code (Claude Opus 5.5) found the overflow, wrote the change and ran the tests. I read every line of the diff.

…verflowing

The helper's linear congruential step `n = n * 1103515245 + 12345`
grows without bound: from the third loop pass it is past u64, and debug
builds (cargo test) panic with "attempt to multiply with overflow".
Both GPU tests that use it failed on a GPU (CI has none, so they return
before reaching it):

- texture_upload::tests::pieces_hold_the_texels_of_their_levels
- texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays

The step now wraps, as such a generator is meant to. Test code only; on
an RTX 4060 Laptop GPU all 8 texture_upload tests pass (3 runs).

Assisted-by: Claude Code (Claude Opus 5.5)
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.

1 participant