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

Manually merged
github merged 2 commits from gh-pr/25/head into gh-pr/25/base 2026-11-26 14:42:52 +00:00
Owner

@⁠claytonblythe on GitHub · 2026-11-26 09:42 UTC · original
claytonblythe:fix/metal-sticky-depth-bias → main · +28 −3 · 2 files · 2 commits · merged 2026-11-26 10:12 UTC

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).
**@⁠claytonblythe** on GitHub · 2026-11-26 09:42 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/25) `claytonblythe:fix/metal-sticky-depth-bias` → `main` · +28 −3 · 2 files · 2 commits · merged 2026-11-26 10:12 UTC 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).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:42:51 +00:00
github manually merged commit 8ac29fecaa into gh-pr/25/base 2026-11-26 14:42:52 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 10:08 UTC · original · approved these changes

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!

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 10:08 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/25#pullrequestreview-6072117339) · **approved these changes** 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!
This discussion has been locked. Commenting is limited to contributors.
No description provided.