gpu(native): preserve unselected planes in depth/stencil clears #41
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/41"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by shabouwcaw on 2026-11-26T11:08:10Z.
What this changes
Native
ClearDepthStencilViewdiscarded the stencil value and skipped stencil-only clears. Metal also cleared stencil to zero whenever depth was cleared. A depth-only clear between two stencil-tested draws therefore erased the mask and rejected the second draw.Carry independent depth/stencil clear values through the native command list and render pass. Clear only the selected planes, preserve the other plane with Metal's load action, and use the requested stencil value. Test setup that needs both planes initialized now requests both explicitly.
This is a separate, newly reproduced graphics-state defect under ROADMAP §1. No overlapping stencil-clear PR was open when checked. The behavior follows Microsoft's ClearDepthStencilView contract. No claim is made that this explains the brightness logo or black present reports.
How it was tested
On Apple Silicon with the locally installed Metal Shader Converter, using only repository-owned HLSL and synthetic geometry:
8bf47c3, the expected green pixel stayed redThe final tests require depth to actually change, preserve stencil after a stencil-writing draw, and exercise stencil-only and combined clears with values 0, 173 and 255. Exact depth/stencil comparisons select the expected color; subsequent draws with mismatching stencil and depth must both be rejected. Command snapshots are exercised too. GPU waits retain the existing 10-second deadline. All mutations were removed.
All builds ran under
nice, with at most six jobs and the configured local environment:cargo test -j6 --locked -p victory-shader -p victory-hle -p victory -p victory-gpu -p victory-metal -p xtask: 519 passed, 0 failed, 4 ignored, including all seven native graphics-state GPU tests.cargo test -j6 --locked --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory: 267 passed, 0 failed, 4 ignored, including all 16 native-probe tests under Rosetta.cargo clippy -j6 --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings, also with--all-features.cargo run -j6 --locked --quiet -p xtask -- policy: 363 files OK;git diff --checkpassed.NativeListthrough Metal, not a game's COM call sequence. They follow the existing skip convention when the converter is absent; it was present for these runs.Upstream CI run 45807790420 passed on
81dda1d: both Windows Clippy configurations and workspace tests.Native clears are gated to full clears of mip 0 on single-layer, single-sampled 1D or 2D textures. Rectangle counts, nonzero mip slices, array views and unknown dimensions are rejected before recording, for all clear flags; default/null DSV descriptions also require a single-layer, single-sampled 1D or 2D resource. Rectangle and subresource clears remain unsupported.
docs/native-host.mdrecords the behavior and limits.A bridge regression calls the title-facing clear ABI with real resources and descriptor records. It verifies unsupported requests record no command and supported explicit/default views still record depth-only, stencil-only and combined clears. Removing the rectangle guard or view guard independently makes the regression fail. The bridge test also preserves explicit/default TEXTURE1D base-view clears and rejects a default DSV on a multisampled resource for all three clear-flag combinations. The 1D case fails before the fix; removing the sample-count guard makes the default multisampled case fail. On
12762b1, the required local test suite passed (288 passed, 2 ignored), Windows-target Clippy passed with both default and all features, and the asset policy and whitespace checks passed.Checklist
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T11:22:17Z.
Review: CHANGES_REQUESTED
The independent Metal load actions look right, and the new draw tests cover full clears well. Two cases need care now that stencil-only clears are real:
clear_dsv_implstill dropscount/rects. That was already true for depth, but now a stencil-only clear of a small rectangle wipes the whole stencil mask too. Please either honour the rectangles, or keep partial (rect) clears out of the new path.native/glue.rs:~496), so a stencil-only clear of aMipSlice = 1view clears mip 0. Please gate the path on views it can represent, or carry the subresource through.A bridge-level regression test for both cases would be great.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T11:51:49Z.
Review: CHANGES_REQUESTED
The rectangle and mip guards address both earlier requests, and the bridge test covers them. There are two remaining shape cases. Please keep full mip-0 clears for single-layer
TEXTURE1Dviews, which already have height-one Metal backing, and reject a default DSV on a multisampled resource, which currently passes the guard. Both fit in the bridge test.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T12:48:35Z.
Review: APPROVED
Thanks: full mip-0 1D clears are kept and a default DSV on a multisampled resource is refused, both covered in the bridge test. Approved. (Optional: a row for an explicit TEXTURE2D view over a multisampled resource.)