Skip to content

v0.30.4 — Metal Stencil State Fix

Choose a tag to compare

@kolkov kolkov released this 25 Jun 13:41
fe4e452

Metal: Stencil State Translation + Stencil Pixel Format

Fixes two Metal HAL issues that caused stencil tests to be silently inert on macOS — rounded UI panels rendered as squares, clipped/stencil-masked content vanished.

Fixed

  • Stencil state translationCreateRenderPipeline now translates StencilFront/StencilBack face states (compare function, fail/depth-fail/pass operations) and read/write masks into MTLDepthStencilState. Previously Metal kept its defaults (Always + Keep), silently disabling the stencil test. Vulkan, DX12, and GLES already did this — Metal was the only backend missing it.

  • Stencil attachment pixel format — set stencilAttachmentPixelFormat on the render pipeline descriptor for formats with stencil aspects (Depth24PlusStencil8, Depth32FloatStencil8, Stencil8). Also split depth/stencil format conditionally — Stencil8-only formats no longer incorrectly set depthAttachmentPixelFormat. Matches Rust wgpu-hal Metal pattern.

  • Depth-stencil descriptor leakRelease(depthStencilDesc) after creating the depth-stencil state (descriptor properties copy, so the original can be freed).

Added

  • stencilOperationToMTL — explicit WebGPU → Metal stencil operation mapping. Required because the enum values differ (e.g. WebGPU Invert=4, Metal Invert=5).

Contributors

  • @samyfodil (PR #227) — discovered and fixed Metal stencil state, verified on Apple Silicon M4.

Full Changelog

v0.30.3...v0.30.4