Skip to content

feat(webgpu): Render through Silk.NET.WebGPU and add WebGpuCanvasElement - #25494

Merged
ramezgerges merged 5 commits into
unoplatform:masterfrom
ramezgerges:dev/rara/webgpu-silk
Oct 21, 2026
Merged

ramezgerges merged 5 commits into
unoplatform:masterfrom
ramezgerges:dev/rara/webgpu-silk

Conversation

@ramezgerges

Copy link
Copy Markdown
Contributor

GitHub Issue: closes unoplatform/uno-private#2461

PR Type:

✨ Feature

What changed? 🚀

The WebGPU backend renders through Silk.NET.WebGPU 2.23 instead of Uno's own generated bindings (feat(webgpu): Render through Silk.NET.WebGPU).

  • The drawing interfaces between host and renderer (IWebGpuDeviceContext, IWebGpuRenderTarget, IWebGpuTextureInterop in Uno.UI.Composition.Drawing) now pass Silk.NET's WebGPU API object and typed handles (Instance*, Adapter*, Device*, Queue*, TextureView*).
  • Silk.NET 2.23 binds the 2024 webgpu.h, but the natives we ship (wgpu-native v29 and emdawnwebgpu) implement the stable header. SilkCompat (internal, in Uno.UI.Composition.WebGpu.Init) is an INativeContext that bridges the two. Functions whose ABI didn't change pass straight through to the native export. The rest go through translators generated from both headers. On the browser, which has no native addresses, each passthrough gets an [UnmanagedCallersOnly] forwarder.
  • The generator (SilkCompat/Generator, not part of any build) replaces gen_webgpu.py. The public WebGpuInterop raw bindings are removed. wgpu-native's extra wgpu.h functions are bound from the loaded library, so the browser link no longer needs the C stubs (wgpu_wasm_stubs.c).
  • On the browser, the renderer uses the device and render target the host already imported instead of importing them a second time.

WebGpuCanvasElement (feat: Add WebGpuCanvasElement) is the WebGPU counterpart of GLCanvasElement.

  • An inheritor renders with Silk.NET.WebGPU, on the app's own device, into a texture sized to the element in physical pixels. The backend draws that texture with no copy.
  • With any backend other than WebGPU, IsWebGpuInitialized is false.
  • The add-in (Uno.WinUI.Graphics3DWebGpu) references only Uno.UI and Silk.NET.WebGPU. It is brought in by the new WebGpuCanvas UnoFeature, which also adds the WebGPU backend.
  • Includes a rotating-triangle sample and runtime tests.

perf(webgpu): AOT-compile the WebGPU init assembly: every WebGPU call passes through SilkCompat, so it should not run interpreted on WASM.

feat!: Move Silk.NET.OpenGL to 2.23: the WebGPU backend brings Silk.NET.Core 2.23 into every Skia app. Silk.NET packages ship and are tested in lockstep, so the OpenGL add-in moves to the same release.

fix(webgpu): Keep a reused stamp's placement current fixes a bug that is on master too, since 4b1a883. Recordings with identical content (for example, cards from one template) could draw one card twice and leave another blank. The affected cards changed from launch to launch; the SamplesApp home page showed it on desktop and on iOS. Regression test: Given_Border.When_Identical_Border_Is_Inserted_Before_Another_Then_Both_Render, which fails without the fix.

Packaging

  • Every Uno app already receives Silk.NET.WebGPU and Silk.NET.WebGPU.Extensions.WGPU 2.23. All six Uno.WinUI.Runtime.* packages depend on Uno.WinUI.Composition.WebGpu.Init, which carries both.
  • Uno.WinUI.nuspec also declares Silk.NET.WebGPU for the net10/net11 groups. A library that references only Uno.WinUI compiles against the Silk-typed interfaces in Uno.UI.Composition.Drawing.

Validation so far

  • macOS (M2, Metal): WebGPU runtime tests (Border, shapes, canvas): 74 total, 73 passed, 0 failed, 1 inconclusive (Border_AntiAlias).
  • iOS simulator (WebGPU): 66 of 74 passed. The 7 failures (plus 1 inconclusive) all fail on master WebGPU too; 5 are input tests that also fail on Skia.
  • Windows desktop, on the final code:
    • Given_Border: 29 passed, 1 inconclusive.
    • Shapes, Given_ScrollViewer, Given_ItemsRepeater, Given_Visual_Damage and Given_WebGpuCanvasElement: 189 of 189 passed.
  • Windows desktop, before the final rework of the typed interfaces: Vulkan/lavapipe and D3D12/WARP both 73 of 74 passed, 0 failed.
  • WASM and Android: run before the final rework of the typed interfaces (WASM 73/74; Android API-34 identical to master). Not yet re-run on this head.
  • Strict analyzer build: passed on the four renderer/seam projects.

PR Checklist ✅

Breaking changes

  • GLCanvasElement: subclasses now compile against Silk.NET.OpenGL 2.23, which renames some enums. For example, gl.CullFace takes a TriangleFace instead of a CullFaceMode. To migrate, update to the renamed enum types; the calls themselves are unchanged. A migration note for migrating-to-uno-7.md is still to come.
  • WebGPU interfaces in Uno.UI.Composition.Drawing: they now pass Silk.NET types, and the raw WebGpuInterop bindings are gone. These are backend-facing interfaces, not app API.

🤖 Generated with Claude Code

@github-actions github-actions Bot added area/skia ✏️ Categorizes an issue or PR as relevant to Skia area/build Categorizes an issue or PR as relevant to build infrastructure area/automation Categorizes an issue or PR as relevant to project automation kind/documentation area/sdk Categorizes an issue or PR as relevant to the Uno.Sdk labels Oct 14, 2026
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 239567 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • DisplayInformation.png-dark
    • DynamicFont.png-dark
    • DynamicFont.png
    • Examples.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ElementLevelTheme.png-dark
  • skia-windows-screenshots: 2458 changed over 2488

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • AnimatedIconPage.png
    • AppBarButtonWithIconTest.png
    • ApplicationViewMode.png
    • Application_DispatcherShutdownMode.png
    • AppWindowTitleBar Properties.png
    • Attributed_text_FontSize_Changing.png-dark
    • Attributed_text_Supserscript.png
    • AutoBorderStretchwithbottommargin.png
    • AutoBorderStretchwithleftmargin.png-dark
    • AutomationProperties_Name.png-dark
    • AutomationProperties_Name.png
    • AutoSuggestBox_BitmapIcon.png-dark
    • AutoSuggestBox_BitmapIcon.png
    • BadgeNotificationTests.png-dark
    • BadgeNotificationTests.png
    • BasicEnability.png-dark
    • BasicEnability.png
    • Battery.png-dark
    • Battery.png

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 239686 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • DisplayInformation.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • DropDownButtonPage.png-dark
    • Examples.png
  • skia-windows-screenshots: 2458 changed over 2488

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedIconPage.png-dark
    • AppBarButtonTest.png
    • ApplicationViewMode.png-dark
    • Application_DispatcherShutdownMode.png
    • AppWindowPresenters.png-dark
    • ArcSegment.png-dark
    • Attributed_text_Simple.png
    • AuthenticationBroker_Demo.png
    • AutoBorderStretchwithtopmargin.png-dark
    • AutoBorderStretchwithtopmargin.png
    • AutoSizedPathCentered.png-dark
    • AutoSizedPathCentered.png
    • AutoSuggestBox_Keyboard.png-dark
    • AutoSuggestBox_Keyboard.png
    • BasicEnability.png-dark
    • BasicEnability.png
    • BeginTime_MultipleAnimations.png-dark
    • BeginTime_MultipleAnimations.png
    • BitmapIcon_Generic.png-dark
    • BitmapIcon_Generic.png

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 239686 has failed on Uno.UI - CI.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 240149 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • DisplayInformation.png-dark
    • ClipboardTests.png-dark
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • DropDownButtonPage.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • DynamicFont.png-dark
  • skia-windows-screenshots: 2458 changed over 2488

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png-dark
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AnimatedIconPage.png
    • AndroidWindowInsets.png
    • ApplicationViewSizing.png-dark
    • AppBarToggleButtonTest.png
    • AppBarButtonTest.png-dark
    • AnimatedVisualsTestbedPage.png
    • AppWindowFeatures.png-dark
    • ApplicationViewSpanningRectsPage.png
    • AppBarButtonTest.png
    • AppBar_KeyBoard.png-dark
    • AppXamlDefinedResources.png-dark
    • AppWindowFeatures.png
    • AppBarButtonWithIconTest.png-dark
    • Application_DispatcherShutdownMode.png-dark
    • Attributed_text_Simple.png-dark
    • AppXamlDefinedResources.png
    • ApplicationViewMode.png-dark
    • AppWindowTitleBar Properties.png

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 240149 has failed on Uno.UI - CI.

ramezgerges and others added 5 commits October 20, 2026 10:32
The WebGPU backend now makes every WebGPU call through Silk.NET.WebGPU
2.23 instead of Uno's own generated bindings. The host's device context
(IWebGpuDeviceContext) hands the renderer Silk.NET's API and its
Instance*, Adapter*, Device* and Queue*, and the render target a
TextureView*; the renderer uses them directly, with typed handles.

Silk.NET 2.23 binds the 2024 webgpu.h, while the shipped natives
(wgpu-native v29, emdawnwebgpu) implement the stable header. SilkCompat,
an INativeContext in the init assembly, is Silk.NET's function table on
those natives:
- functions whose ABI is unchanged resolve to the native export itself;
- the rest go through translators generated from both headers, plus
  hand-written ones for callbacks and output structs;
- the browser has no native addresses, so each passthrough gets an
  [UnmanagedCallersOnly] forwarder to its [DllImport];
- functions wgpu-native leaves unimplemented (which abort the process)
  are emulated outside the browser.

The stable-header declarations the translators call are emitted by the
same C# generator and are internal to SilkCompat, replacing the public
WebGpuInterop bindings and gen_webgpu.py. Only webgpu.h's functions are
[DllImport]s: wgpu-native's own (wgpu.h) are bound from the loaded
library, so the browser link needs no C stubs for what Dawn lacks.
Passthrough exports are taken from the library the [DllImport]s bound,
so a self-contained app never loads a second wgpu instance. On the
browser the renderer uses the device and render target the host
imported instead of importing them again.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
An element that displays what its inheritor renders with
Silk.NET.WebGPU, on the device the app renders with. It renders into a
texture sized to the element in physical pixels, and the backend draws
it with no copy. It requires the WebGPU backend; with any other,
IsWebGpuInitialized becomes false.

The WebGPU drawing factory implements IWebGpuTextureInterop, which hands
out the backend's Silk.NET API, device and queue and creates the render
textures, so the add-in references only Silk.NET.WebGPU: an API loaded
separately would bind another WebGPU implementation that cannot use the
backend's objects. The context references the device, queue and target
it hands out.

The WebGpuCanvas UnoFeature references the Uno.WinUI.Graphics3DWebGpu
package and adds the WebGPU backend next to the default renderer. A
rotating-triangle sample and runtime tests cover the element's output,
its unavailability on other backends and its teardown on unload.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
It holds SilkCompat, through which every WebGPU call the renderer makes
passes, so interpreting it costs frame time. The StringView-by-value
callbacks that trapped under AOT ("function signature mismatch") are no
longer AOT call sites: SilkCompat receives them as function pointers.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The WebGPU backend brings Silk.NET.Core 2.23, which every Skia app now
receives; Silk.NET's packages ship and are tested in lockstep, so the
OpenGL add-in moves to the same release rather than run 2.16 against a
newer core.

BREAKING CHANGE: GLCanvasElement code compiles against Silk.NET.OpenGL
2.23, which renames some enums, e.g. gl.CullFace takes a TriangleFace
instead of a CullFaceMode.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A stamp reused for another site through the site-uniform fast path
rewrote the uniform but kept the previous site's transform and clip. A
later site still at that placement matched it and rewrote the uniform
the first site's ops read, so identical recordings (e.g. cards of one
template) drew one card twice and left another blank.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 240355 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png-dark
    • Buttons.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ClipboardTests.png-dark
    • DisplayInformation.png-dark
    • DropDownButtonPage.png-dark
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Examples.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
  • skia-windows-screenshots: 2458 changed over 2488

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png
    • AppBarButtonWithIconTest.png
    • ApplicationViewSizing.png-dark
    • AppWindowClosing.png
    • AppWindowPositionAndSize.png
    • Arrange_Performance01.png
    • Attributed_text_Simple.png
    • AutoBorderStretchwithbottommargin.png
    • AutomationPropertiesExtensions_Role.png-dark
    • AutomationPropertiesExtensions_Role.png
    • BadgeNotificationTests.png-dark
    • BadgeNotificationTests.png
    • Basics_Automated.png-dark
    • Basics_Automated.png
    • BindableDrawerLayout_ChangePane.png-dark
    • BindableDrawerLayout_ChangePane.png
    • BitmapImage_vs_SvgImageSource.png-dark
    • BitmapImage_vs_SvgImageSource.png
    • BorderLeftwithmargins.png-dark
    • BorderLeftwithmargins.png

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 240355 has failed on Uno.UI - CI.

@mergify

mergify Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@ramezgerges
ramezgerges merged commit 503f371 into unoplatform:master Oct 21, 2026
54 checks passed
@ramezgerges
ramezgerges deleted the dev/rara/webgpu-silk branch October 21, 2026 13:14
@Jen-Uno Jen-Uno mentioned this pull request Nov 2, 2026
2 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/build Categorizes an issue or PR as relevant to build infrastructure area/sdk Categorizes an issue or PR as relevant to the Uno.Sdk area/skia ✏️ Categorizes an issue or PR as relevant to Skia kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants