metal: always set depth bias per draw so zero bias resets prior bias #25

Merged
claytonblythe merged 2 commits from upstream-pr/25 into main 2026-11-26 10:12:52 +00:00
claytonblythe commented 2026-11-26 09:42:48 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by claytonblythe on 2026-11-26T09:42:48Z.


Addresses sticky depth bias in Metal render passes (related to #18).

Summary

  • In crates/victory-metal/src/gfx.rs, setDepthBias_slopeScale_clamp was gated on if r.depth_bias != (0.0, 0.0, 0.0), so a draw with zero depth bias in the same render pass inherited the previous draw's non-zero depth bias.
  • Always calls setDepthBias_slopeScale_clamp per draw (matching setCullMode, setFrontFacingWinding, setTriangleFillMode, and setDepthClipMode).
  • Adds a Metal render regression test depth_bias_resets_between_draws_in_the_same_pass in crates/victory-gpu/src/native/state_tests.rs that fails without this fix.

Testing

  • VICTORY_MSC_DYLIB=... cargo test --target x86_64-apple-darwin -p victory-gpu --lib native::tests::state_tests -- --test-threads=1 (5/5 passed on Metal).
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings (0 warnings).
  • cargo xtask policy (363 files ok).
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6623841597 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/25). Originally posted by [claytonblythe](https://github.com/claytonblythe) on 2026-11-26T09:42:48Z. --- Addresses sticky depth bias in Metal render passes (related to #18). ## Summary - In `crates/victory-metal/src/gfx.rs`, `setDepthBias_slopeScale_clamp` was gated on `if r.depth_bias != (0.0, 0.0, 0.0)`, so a draw with zero depth bias in the same render pass inherited the previous draw's non-zero depth bias. - Always calls `setDepthBias_slopeScale_clamp` per draw (matching `setCullMode`, `setFrontFacingWinding`, `setTriangleFillMode`, and `setDepthClipMode`). - Adds a Metal render regression test `depth_bias_resets_between_draws_in_the_same_pass` in `crates/victory-gpu/src/native/state_tests.rs` that fails without this fix. ## Testing - `VICTORY_MSC_DYLIB=... cargo test --target x86_64-apple-darwin -p victory-gpu --lib native::tests::state_tests -- --test-threads=1` (5/5 passed on Metal). - `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` (0 warnings). - `cargo xtask policy` (363 files ok).
LakshanSivakumar commented 2026-11-26 10:08:07 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T10:08:07Z.

Review: APPROVED


Reviewed and tested merged with current main (a2940ab): full test suite incl. victory-shader, the new depth_bias_resets_between_draws_in_the_same_pass test on Metal, clippy for the Windows target and xtask policy all pass. Thanks!

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6072117339 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/25#pullrequestreview-6072117339). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T10:08:07Z. **Review:** APPROVED --- Reviewed and tested merged with current main (a2940ab): full test suite incl. victory-shader, the new depth_bias_resets_between_draws_in_the_same_pass test on Metal, clippy for the Windows target and xtask policy all pass. Thanks!
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
LakshanSivakumar/Native-Victory-macOS!25
No description provided.