Skip to content

Enable stencil buffers by default + add configurable option - #21586

Merged
MrJul merged 1 commit into
AvaloniaUI:masterfrom
MrJul:feature/skia-stencil-options
Jun 15, 2026
Merged

MrJul merged 1 commit into
AvaloniaUI:masterfrom
MrJul:feature/skia-stencil-options

Conversation

@MrJul

@MrJul MrJul commented Jun 15, 2026

Copy link
Copy Markdown
Member

What does the pull request do?

This PR introduces a new option SkiaOptions.UseStencilBuffers and enables it by default.

What is the current behavior?

Stencil buffers were disabled on all platforms a long time ago, in #6896, due to issues on macOS.

What is the updated/expected behavior with this PR?

Stencil buffers are enabled again. All platforms have been tested: Windows, macOS (both GL and Metal), X11, Android, iOS, and Browser. There is no visible clipping issue with Skia m119.

Clipping operations on GPUs should be faster, especially when CompositionOptions.UseRegionDirtyRectClipping = true (the sample in #21538 goes from 70ms to 16ms render CPU time per frame).

This PR also adds a new option, SkiaOptions.UseStencilBuffers, so users can explicitly disable it without having to recompile Avalonia. The default is null, which means Avalonia chooses the best behavior depending on the platform (currently: enabled everywhere).

@qwertychouskie

Copy link
Copy Markdown
Contributor

How does this relate to/differ from the AvoidStencilBuffers option mentioned in #21538?

(I haven't been able to locate documentation on all these various different rendering options.)

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0066417-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul
MrJul added this pull request to the merge queue Jun 15, 2026
@MrJul

MrJul commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

How does this relate to/differ from the AvoidStencilBuffers option mentioned in #21538?

They're the same (but with the behavior reversed). This PR exposes Skia's AvoidSencilBuffers setting via SkiaOptions.UseStencilBuffers. Previously, it couldn't be configured directly without recompilation.

Merged via the queue into AvaloniaUI:master with commit 9808817 Jun 15, 2026
11 checks passed
@MrJul
MrJul deleted the feature/skia-stencil-options branch June 15, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants