[pr-tests][rendering] darner-formats: pin the full mip chain of a mips: 0 description #387

Manually merged
TrustNo1 merged 1 commit from qnjk/Darner:formats-zero-mips-test into main 2026-12-05 04:50:28 +00:00
Contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: nothing. This is a tests-only change: no production line is edited, so it needs no A/B result and no gameplay run (CONTRIBUTING's rule for tests-only changes).

  • What it pins: Texture::new derives the number of mips when the description asks for the whole chain (mips: 0, the D3D12 default):

    let mips = match desc.mips {
        0 => 32 - desc.width.max(desc.height).max(depth3d).max(1).leading_zeros(),
        n => n,
    };
    

    (crates/darner-formats/src/texture.rs:1618-1621). That count becomes the Desc.mips of every plane (:1622-1632), and every plane's offsets and the returned Texture::size follow from it. No test in the crate ever passed mips: 0 to Texture::new: every Texture::new test uses mips: 1 through RGBA8_TEXTURE, and the only literal mips: 0 in the file is a Desc handed to Layout::new, which rejects it. The two terms a reader would get wrong were pinned only by the comment beside them: the 32 - leading_zeros off-by-one (which changes the mip count, and so the allocation size, of every texture described with mips: 0) and .max(depth3d) (without it a 40-deep volume gets five mips and loses the top of its chain).

  • The new test zero_mips_means_the_full_chain asks for 64x16 and 16x64 flat textures (seven mips each, so the height counts as a side) and a 16x16x64 volume (seven, against the five its face alone would give), and checks that a description naming one mip still gets one.

How it was tested

  • Tested revision: 2efc784 (one commit on f3840d7).
  • Commands and results:
    • cargo test --locked -p darner-formats — 88 passed, 7 ignored, 0 failed.
    • The new test alone: cargo test --locked -p darner-formats --lib zero_mips — 1 passed.
    • cargo clippy --locked -p darner-formats --all-targets -- -D warnings passes.
    • Pure function: no GPU, no title, no fixture, so it runs on a bare runner.
  • Changes a default: no. Tests only.
  • A/B result: not applicable — tests-only change.
  • Gates run on that revision:
    • Gate 1, cargo clippy --workspace --all-targets --locked -- -D warnings: passes.
    • Gate 2, cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passes.
    • Gate 3, cargo test --workspace --locked: not green on this machine, and not because of this change. Three pre-existing failures, each covered by an open pull request: darner-gpu stands still in parallel on the test deadlock #224 describes, and serially it finishes 1772 passed and 1 failed (pipeline::make::tests::a_capped_draw_waits_once_then_drops, which passes on its own) beside the order-dependent watch::tests::ask_once_by_res_splits_reservations_without_refusals and texture::ahead::tests::drain_waits_until_then_callbacks_have_run flakes that #150 is about; darner-shader fails emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders, whose fixture #227 fixes. Every other crate passes, and darner-formats does.
  • Gameplay, when relevant: not applicable — tests-only change, nothing runs differently.
  • Shader wave sizes tested, when relevant: not applicable.
  • Hardware dependence: none.
  • Coverage gaps: the test uses one format (R8G8B8A8_UNORM) and one linear swizzle; how the same count feeds a tiled, compressed or depth/stencil description is covered by the existing layout tests. A mips: 0 description whose width, height and depth_or_array are all 0 is not pinned.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
    • Not applicable: tests-only change, stated at the top of this description.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md. (cargo xtask policy: 555 files ok.)
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #258 changes crates/darner-formats/src/texture.rs (neither touches Texture::new's mip-count branch or the tests beside it). No issue or pull request mentions zero_mips, mips: 0 or the full-chain branch.
  • Replaces or overlaps: none found
## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: nothing. This is a **tests-only** change: no production line is edited, so it needs no A/B result and no gameplay run (CONTRIBUTING's rule for tests-only changes). - What it pins: `Texture::new` derives the number of mips when the description asks for the whole chain (`mips: 0`, the D3D12 default): ```rust let mips = match desc.mips { 0 => 32 - desc.width.max(desc.height).max(depth3d).max(1).leading_zeros(), n => n, }; ``` (`crates/darner-formats/src/texture.rs:1618-1621`). That count becomes the `Desc.mips` of every plane (`:1622-1632`), and every plane's offsets and the returned `Texture::size` follow from it. No test in the crate ever passed `mips: 0` to `Texture::new`: every `Texture::new` test uses `mips: 1` through `RGBA8_TEXTURE`, and the only literal `mips: 0` in the file is a `Desc` handed to `Layout::new`, which rejects it. The two terms a reader would get wrong were pinned only by the comment beside them: the `32 - leading_zeros` off-by-one (which changes the mip count, and so the allocation size, of every texture described with `mips: 0`) and `.max(depth3d)` (without it a 40-deep volume gets five mips and loses the top of its chain). - The new test `zero_mips_means_the_full_chain` asks for 64x16 and 16x64 flat textures (seven mips each, so the height counts as a side) and a 16x16x64 volume (seven, against the five its face alone would give), and checks that a description naming one mip still gets one. ## How it was tested - Tested revision: `2efc784` (one commit on `f3840d7`). - Commands and results: - `cargo test --locked -p darner-formats` — 88 passed, 7 ignored, 0 failed. - The new test alone: `cargo test --locked -p darner-formats --lib zero_mips` — 1 passed. - `cargo clippy --locked -p darner-formats --all-targets -- -D warnings` passes. - Pure function: no GPU, no title, no fixture, so it runs on a bare runner. - Changes a default: no. Tests only. - A/B result: not applicable — tests-only change. - Gates run on that revision: - Gate 1, `cargo clippy --workspace --all-targets --locked -- -D warnings`: passes. - Gate 2, `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passes. - Gate 3, `cargo test --workspace --locked`: **not green on this machine, and not because of this change.** Three pre-existing failures, each covered by an open pull request: `darner-gpu` stands still in parallel on the test deadlock #224 describes, and serially it finishes 1772 passed and 1 failed (`pipeline::make::tests::a_capped_draw_waits_once_then_drops`, which passes on its own) beside the order-dependent `watch::tests::ask_once_by_res_splits_reservations_without_refusals` and `texture::ahead::tests::drain_waits_until_then_callbacks_have_run` flakes that #150 is about; `darner-shader` fails `emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders`, whose fixture #227 fixes. Every other crate passes, and `darner-formats` does. - Gameplay, when relevant: not applicable — tests-only change, nothing runs differently. - Shader wave sizes tested, when relevant: not applicable. - Hardware dependence: none. - Coverage gaps: the test uses one format (R8G8B8A8_UNORM) and one linear swizzle; how the same count feeds a tiled, compressed or depth/stencil description is covered by the existing layout tests. A `mips: 0` description whose `width`, `height` and `depth_or_array` are all 0 is not pinned. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). - Not applicable: tests-only change, stated at the top of this description. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. (`cargo xtask policy`: 555 files ok.) - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #258 changes `crates/darner-formats/src/texture.rs` (neither touches `Texture::new`'s mip-count branch or the tests beside it). No issue or pull request mentions `zero_mips`, `mips: 0` or the full-chain branch. - Replaces or overlaps: none found
No test passed `TextureDesc.mips = 0` to `Texture::new`, though that is
the D3D12 default ("the whole chain") and the branch that derives the
count from the largest side is what every such allocation takes its
offsets and its size from: `32 - largest.leading_zeros()` at
`texture.rs:1618`. An off-by-one there changes the mip count, and so the
size, of every texture described that way, and dropping the `.max(depth3d)`
gives a 40-deep volume five mips instead of six. Both terms were pinned
only by the comment beside them.

The test asks for 64x16 and 16x64 flat textures (seven mips, so the
height counts as a side) and a 16x16x64 volume (seven, against the five
its face alone would give), and checks that a description naming one mip
still gets one. Pure function: no GPU, no title, no fixture.
TrustNo1 manually merged commit 687b968343 into main 2026-12-05 04:50:28 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!387
No description provided.