|
11 | 11 | </ItemGroup> |
12 | 12 | <ItemGroup Condition="'$(IsUnoHead)' == 'True' and '$(UnoRuntimeIdentifier)' == 'WebAssembly' and '$(ShouldIncludeNativeSkiaSharp)' == 'True'"> |
13 | 13 | <WasmShellEmccExportedRuntimeMethod Include="GL" /> |
| 14 | + <WasmShellEmccExportedRuntimeMethod Include="WebGPU" /> |
14 | 15 | <!-- Include the emscripten_gl* symbols --> |
15 | 16 | <WasmShellExtraEmccFlags Include="-s USE_WEBGL2=1"/> |
16 | 17 | <!-- Enable GLCtx when threading is available --> |
17 | 18 | <WasmShellExtraEmccFlags Condition="'$(WasmShellEnableThreads)'=='True'" Include="-s OFFSCREEN_FRAMEBUFFER=1" /> |
| 19 | + <WasmShellExtraEmccFlags Include="-s USE_WEBGPU=1"/> |
18 | 20 | </ItemGroup> |
19 | 21 |
|
20 | 22 | <!-- If this is a .NET web assembly app --> |
21 | 23 | <PropertyGroup Condition="('$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true' or '$(UsingMicrosoftNETSdkWebAssembly)' == 'true') and '$(ShouldIncludeNativeSkiaSharp)' == 'True'"> |
22 | 24 | <WasmBuildNative Condition="'$(WasmBuildNative)' == ''">true</WasmBuildNative> |
23 | | - <EmccExtraLDFlags>$(EmccExtraLDFlags) -s USE_WEBGL2=1</EmccExtraLDFlags> |
| 25 | + <!-- |
| 26 | + net8.x (emsdk 3.1.34) uses the built-in `-sUSE_WEBGPU=1`; net9.0+ uses |
| 27 | + Dawn's emdawnwebgpu port, which ships in this NuGet at |
| 28 | + buildTransitive/netstandard1.0/emdawnwebgpu_pkg/. Discriminate on |
| 29 | + $(TargetFramework) directly — $(TargetFrameworkVersion) is populated by a |
| 30 | + later SDK import so it's still empty here. |
| 31 | + --> |
| 32 | + <_SkiaSharpUseEmdawnwebgpu Condition="'$(_SkiaSharpUseEmdawnwebgpu)' == '' and '$(TargetFramework)' != '' and !$(TargetFramework.StartsWith('net8.'))">true</_SkiaSharpUseEmdawnwebgpu> |
| 33 | + <!-- Normalize to forward slashes: emcc parses `-isystem <abs-path>` as one |
| 34 | + shell arg and swallows Windows backslashes. --> |
| 35 | + <_SkiaSharpEmdawnwebgpuPkg>$([System.String]::Copy('$(MSBuildThisFileDirectory)emdawnwebgpu_pkg').Replace('\','/'))</_SkiaSharpEmdawnwebgpuPkg> |
| 36 | + <!-- |
| 37 | + Inline the port's inputs rather than emcc's ports mechanism: that |
| 38 | + compiles into emcc's cache (needs FROZEN_CACHE=0), and the .NET WASM SDK's |
| 39 | + FROZEN_CACHE=1 + parallel compile races on sysroot_install.stamp. Passing |
| 40 | + the include paths, JS libraries, and webgpu.cpp directly replicates the |
| 41 | + port without touching the cache; -sDEFAULT_TO_CXX=1 keeps LINK_AS_CXX on. |
| 42 | + --> |
| 43 | + <_SkiaSharpEmdawnwebgpuFlags Condition="'$(_SkiaSharpUseEmdawnwebgpu)' == 'true'">-s DEFAULT_TO_CXX=1 -isystem $(_SkiaSharpEmdawnwebgpuPkg)/webgpu/include -isystem $(_SkiaSharpEmdawnwebgpuPkg)/webgpu_cpp/include --js-library=$(_SkiaSharpEmdawnwebgpuPkg)/webgpu/src/library_webgpu_enum_tables.js --js-library=$(_SkiaSharpEmdawnwebgpuPkg)/webgpu/src/library_webgpu_generated_struct_info.js --js-library=$(_SkiaSharpEmdawnwebgpuPkg)/webgpu/src/library_webgpu_generated_sig_info.js --js-library=$(_SkiaSharpEmdawnwebgpuPkg)/webgpu/src/library_webgpu.js -std=c++20 $(_SkiaSharpEmdawnwebgpuPkg)/webgpu/src/webgpu.cpp</_SkiaSharpEmdawnwebgpuFlags> |
| 44 | + <EmccExtraLDFlags Condition="'$(_SkiaSharpUseEmdawnwebgpu)' == 'true'">$(EmccExtraLDFlags) -s USE_WEBGL2=1 $(_SkiaSharpEmdawnwebgpuFlags)</EmccExtraLDFlags> |
| 45 | + <EmccExtraLDFlags Condition="'$(_SkiaSharpUseEmdawnwebgpu)' != 'true'">$(EmccExtraLDFlags) -s USE_WEBGL2=1 -s USE_WEBGPU=1</EmccExtraLDFlags> |
24 | 46 | <!-- Pick the threading type: 'mt' for multi-threading or 'st' for single-threading --> |
25 | 47 | <_SkiaSharpNativeBinaryType Condition="'$(WasmEnableThreads)' == 'True'">mt</_SkiaSharpNativeBinaryType> |
26 | 48 | <_SkiaSharpNativeBinaryType Condition="'$(WasmEnableThreads)' != 'True'">st</_SkiaSharpNativeBinaryType> |
|
29 | 51 | <_SkiaSharpNativeBinaryType Condition="'$(WasmEnableSIMD)' != 'True'">$(_SkiaSharpNativeBinaryType)</_SkiaSharpNativeBinaryType> |
30 | 52 | </PropertyGroup> |
31 | 53 | <ItemGroup Condition="('$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true' or '$(UsingMicrosoftNETSdkWebAssembly)' == 'true') and '$(TargetFrameworkVersion)' != '' and '$(ShouldIncludeNativeSkiaSharp)' == 'True'"> |
| 54 | + <!-- SkiaSharp's interop reads Module.WebGPU.{mgr*,importJs*}, so export the |
| 55 | + WebGPU runtime method. --> |
| 56 | + <EmccExportedRuntimeMethod Include="WebGPU" /> |
| 57 | + <!-- emdawnwebgpu allocates refcounted WGPUTexture handles; the managed |
| 58 | + interop releases them via the C ABI's wgpuTextureRelease, so export it |
| 59 | + as Module._wgpuTextureRelease. --> |
| 60 | + <EmccExportedFunction Include="_wgpuTextureRelease" Condition="'$(_SkiaSharpUseEmdawnwebgpu)' == 'true'" /> |
| 61 | + <!-- Skia's DawnBackendContext needs a real WGPUInstance* — the emdawnwebgpu |
| 62 | + port's wgpuCreateInstance returns one. Export it as Module._wgpuCreateInstance |
| 63 | + so the managed WebGPU shim can call it instead of falling back to a fake |
| 64 | + handle (a bogus pointer would hang inside wgpu::Instance::AddRef). --> |
| 65 | + <EmccExportedFunction Include="_wgpuCreateInstance" Condition="'$(_SkiaSharpUseEmdawnwebgpu)' == 'true'" /> |
32 | 66 | <!-- net8.0 --> |
33 | | - <NativeFileReference Include="$(SkiaSharpStaticLibraryPath)\3.1.34\$(_SkiaSharpNativeBinaryType)\*.a" Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0'))" /> |
34 | | - <!-- net9.0 - net10.0 --> |
35 | | - <NativeFileReference Include="$(SkiaSharpStaticLibraryPath)\3.1.56\$(_SkiaSharpNativeBinaryType)\*.a" Condition="$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '9.0')) and $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '11.0'))" /> |
36 | | - <!-- net11.0+ --> |
37 | | - <NativeFileReference Include="$(SkiaSharpStaticLibraryPath)\5.0.6\$(_SkiaSharpNativeBinaryType)\*.a" Condition="$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '11.0'))" /> |
| 67 | + <NativeFileReference Include="$(SkiaSharpStaticLibraryPath)/3.1.34/$(_SkiaSharpNativeBinaryType)/*.a" Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0'))" /> |
| 68 | + <!-- net9.0+ --> |
| 69 | + <NativeFileReference Include="$(SkiaSharpStaticLibraryPath)/3.1.56/$(_SkiaSharpNativeBinaryType)/*.a" Condition="$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '9.0'))" /> |
38 | 70 | </ItemGroup> |
39 | 71 |
|
40 | 72 | <!-- Error when targeting unsupported WASM TFMs --> |
|
0 commit comments