Repository navigation
feat(webgpu): Render through Silk.NET.WebGPU and add WebGpuCanvasElement - #25494
Conversation
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25494/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-25494/wasm-skia-net9/index.html |
|
The build 239567 found UI Test snapshots differences: Details
|
af63218 to
388339f
Compare
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25494/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-25494/wasm-skia-net9/index.html |
|
The build 239686 found UI Test snapshots differences: Details
|
|
|
388339f to
7955945
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25494/docs/index.html |
|
The build 240149 found UI Test snapshots differences: Details
|
|
|
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]>
7955945 to
c185a35
Compare
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25494/docs/index.html |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 240355 found UI Test snapshots differences: Details
|
|
|
|
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. |
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).IWebGpuDeviceContext,IWebGpuRenderTarget,IWebGpuTextureInteropinUno.UI.Composition.Drawing) now pass Silk.NET'sWebGPUAPI object and typed handles (Instance*,Adapter*,Device*,Queue*,TextureView*).webgpu.h, but the natives we ship (wgpu-native v29 and emdawnwebgpu) implement the stable header. SilkCompat (internal, inUno.UI.Composition.WebGpu.Init) is anINativeContextthat 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.SilkCompat/Generator, not part of any build) replacesgen_webgpu.py. The publicWebGpuInteropraw bindings are removed. wgpu-native's extrawgpu.hfunctions are bound from the loaded library, so the browser link no longer needs the C stubs (wgpu_wasm_stubs.c).WebGpuCanvasElement(feat: Add WebGpuCanvasElement) is the WebGPU counterpart ofGLCanvasElement.IsWebGpuInitializedis false.Uno.WinUI.Graphics3DWebGpu) references onlyUno.UIand Silk.NET.WebGPU. It is brought in by the newWebGpuCanvasUnoFeature, which also adds the WebGPU backend.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 currentfixes 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
Uno.WinUI.Runtime.*packages depend onUno.WinUI.Composition.WebGpu.Init, which carries both.Uno.WinUI.nuspecalso declares Silk.NET.WebGPU for the net10/net11 groups. A library that references onlyUno.WinUIcompiles against the Silk-typed interfaces inUno.UI.Composition.Drawing.Validation so far
Given_Border: 29 passed, 1 inconclusive.Given_ScrollViewer,Given_ItemsRepeater,Given_Visual_DamageandGiven_WebGpuCanvasElement: 189 of 189 passed.PR Checklist ✅
Screenshots Compare Test Runresults.Breaking changes
GLCanvasElement: subclasses now compile against Silk.NET.OpenGL 2.23, which renames some enums. For example,gl.CullFacetakes aTriangleFaceinstead of aCullFaceMode. To migrate, update to the renamed enum types; the calls themselves are unchanged. A migration note formigrating-to-uno-7.mdis still to come.Uno.UI.Composition.Drawing: they now pass Silk.NET types, and the rawWebGpuInteropbindings are gone. These are backend-facing interfaces, not app API.🤖 Generated with Claude Code