Skip to content

Commit f4d8c1f

Browse files
committed
Update wgpu-native to [v22.1.0.3](https://github.com/gfx-rs/wgpu-native/releases/tag/v22.1.0.3), regenerate bindings and add Android support.
Update WebGPU samples.
1 parent 50e007e commit f4d8c1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+944
-350
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Checkout
1818
uses: actions/checkout@v4
1919

20-
- name: Setup .NET 8 SDK
20+
- name: Setup .NET SDK
2121
uses: actions/setup-dotnet@v4
2222
with:
2323
global-json-file: ./global.json
@@ -27,4 +27,4 @@ jobs:
2727

2828
- name: Publish to NuGet
2929
if: github.event_name == 'push'
30-
run: dotnet nuget push artifacts/**/*.nupkg -k ${{secrets.NUGET_TOKEN}} --skip-duplicate --source https://api.nuget.org/v3/index.json
30+
run: dotnet nuget push artifacts/package/release/*.nupkg -k ${{secrets.NUGET_TOKEN}} --skip-duplicate --source https://api.nuget.org/v3/index.json

Alimer.Bindings.sln

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "03-DrawIndexedQuad", "sampl
4747
EndProject
4848
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Alimer.Bindings.MeshOptimizer", "src\Alimer.Bindings.MeshOptimizer\Alimer.Bindings.MeshOptimizer.csproj", "{4DEE2D26-7624-4AD9-9AFF-5E34FC5EC1C6}"
4949
EndProject
50+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Alimer.WebGPU.Native", "src\Alimer.WebGPU.Native\Alimer.WebGPU.Native.csproj", "{10BF579F-0E9D-4DD3-AF08-0C301A96377D}"
51+
EndProject
5052
Global
5153
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5254
Debug|Any CPU = Debug|Any CPU
@@ -85,6 +87,10 @@ Global
8587
{4DEE2D26-7624-4AD9-9AFF-5E34FC5EC1C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
8688
{4DEE2D26-7624-4AD9-9AFF-5E34FC5EC1C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
8789
{4DEE2D26-7624-4AD9-9AFF-5E34FC5EC1C6}.Release|Any CPU.Build.0 = Release|Any CPU
90+
{10BF579F-0E9D-4DD3-AF08-0C301A96377D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
91+
{10BF579F-0E9D-4DD3-AF08-0C301A96377D}.Debug|Any CPU.Build.0 = Debug|Any CPU
92+
{10BF579F-0E9D-4DD3-AF08-0C301A96377D}.Release|Any CPU.ActiveCfg = Release|Any CPU
93+
{10BF579F-0E9D-4DD3-AF08-0C301A96377D}.Release|Any CPU.Build.0 = Release|Any CPU
8894
EndGlobalSection
8995
GlobalSection(SolutionProperties) = preSolution
9096
HideSolutionNode = FALSE

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<LangVersion>12.0</LangVersion>
1818
<ImplicitUsings>enable</ImplicitUsings>
1919
<Nullable>enable</Nullable>
20+
<UseArtifactsOutput>true</UseArtifactsOutput>
2021
<!-- Local builds should embed PDBs so we never lose them when a subsequent build occurs. -->
2122
<DebugType Condition=" '$(CI)' != 'true' and '$(TF_BUILD)' != 'true' ">embedded</DebugType>
2223
<Features>strict</Features>
@@ -36,7 +37,6 @@
3637
<PackageLicenseExpression>MIT</PackageLicenseExpression>
3738
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
3839
<PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl>
39-
<PackageOutputPath>$(MSBuildThisFileDirectory)artifacts/</PackageOutputPath>
4040
<ContinuousIntegrationBuild Condition="'$(GITHUB_RUN_ID)' != ''">true</ContinuousIntegrationBuild>
4141
<UseSharedCompilation>true</UseSharedCompilation>
4242
<PackageTags>webgpu game engine game-development gamedev</PackageTags>

Directory.Build.targets

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111

1212
<!-- Settings that are only set for libraries -->
1313
<PropertyGroup Condition="'$(OutputType)' == 'Library'">
14-
<IsTrimmable>true</IsTrimmable>
15-
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
16-
<EnableAotAnalyzer>true</EnableAotAnalyzer>
17-
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
14+
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>
1815
</PropertyGroup>
1916

2017
</Project>

Directory.Packages.props

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
<!-- https://learn.microsoft.com/nuget/consume-packages/central-package-management -->
44
<ItemGroup>
55
<!-- Generator -->
6-
<PackageVersion Include="CppAst" Version="0.20.1" />
6+
<PackageVersion Include="CppAst" Version="0.20.2" />
77

88
<!-- Samples -->
9-
<PackageVersion Include="Alimer.Bindings.SDL" Version="3.5.4" />
9+
<PackageVersion Include="Alimer.Bindings.SDL" Version="3.8.0" />
1010

1111
<!-- Tests -->
12-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
13-
<PackageVersion Include="NUnit" Version="4.1.0" />
14-
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
12+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
13+
<PackageVersion Include="NUnit" Version="4.2.2" />
14+
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
1515
</ItemGroup>
1616

1717
</Project>

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/amerkoleci/Alimer.Bindings/blob/main/LICENSE)
44
[![Build status](https://github.com/amerkoleci/Alimer.Bindings/workflows/Build/badge.svg)](https://github.com/amerkoleci/Alimer.Bindings/actions)
55

6-
Collection of cross platform **.net8.0** bindings.
6+
Collection of cross platform **.net9.0** and **.net8.0** bindings.
77

88
## Bindings
99

1010
| Library | Description | Status | NuGet |
1111
| ------- | ----------- | ------ |------ |
12-
| [wgpu](https://github.com/gfx-rs/wgpu-native) | wgpu bindings version [v0.17.2.1](https://github.com/gfx-rs/wgpu-native/releases/tag/v0.17.2.1) | Done ✔️ | [![NuGet](https://img.shields.io/nuget/v/Alimer.Bindings.WebGPU.svg)](https://www.nuget.org/packages/Alimer.Bindings.WebGPU)|
12+
| [wgpu](https://github.com/gfx-rs/wgpu-native) | wgpu bindings version [v22.1.0.3](https://github.com/gfx-rs/wgpu-native/releases/tag/v22.1.0.3.1) | Done ✔️ | [![NuGet](https://img.shields.io/nuget/v/Alimer.Bindings.WebGPU.svg)](https://www.nuget.org/packages/Alimer.Bindings.WebGPU)|
1313
| [meshoptimizer](https://github.com/zeux/meshoptimizer) | meshoptimizer bindings | Done ✔️ | [![NuGet](https://img.shields.io/nuget/v/Alimer.Bindings.MeshOptimizer.svg)](https://www.nuget.org/packages/Alimer.Bindings.MeshOptimizer)|
1414

1515
## Sponsors

global.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"sdk": {
3-
"version": "8.0.302",
4-
"rollForward": "latestFeature",
5-
"allowPrerelease": false
3+
"version": "9.0.100-preview",
4+
"allowPrerelease": true,
5+
"rollForward": "latestFeature"
66
}
7-
}
7+
}

samples/01-ClearScreen/01-ClearScreen.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<IsPackable>false</IsPackable>
77
<RootNamespace>Alimer.WebGPU.Samples</RootNamespace>

samples/01-ClearScreen/Program.cs

+14-14
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,25 @@ protected override void OnTick()
3434
_graphicsDevice.RenderFrame(OnDraw);
3535
}
3636

37-
private void OnDraw(WGPUCommandEncoder encoder, WGPUTexture target)
37+
private void OnDraw(WGPUCommandEncoder encoder, WGPUTexture target, WGPUTextureView textureView)
3838
{
3939
float g = _green + 0.001f;
4040
if (g > 1.0f)
4141
g = 0.0f;
4242
_green = g;
4343

44-
WGPUTextureView targetView = wgpuTextureCreateView(target, null);
45-
46-
WGPURenderPassColorAttachment renderPassColorAttachment = new();
47-
// The attachment is tighed to the view returned by the swap chain, so that
48-
// the render pass draws directly on screen.
49-
renderPassColorAttachment.view = targetView;
50-
// Not relevant here because we do not use multi-sampling
51-
renderPassColorAttachment.resolveTarget = WGPUTextureView.Null;
52-
renderPassColorAttachment.loadOp = WGPULoadOp.Clear;
53-
renderPassColorAttachment.storeOp = WGPUStoreOp.Store;
54-
renderPassColorAttachment.clearValue = new WGPUColor(1.0f, _green, 0.0f, 1.0f);
44+
WGPURenderPassColorAttachment renderPassColorAttachment = new()
45+
{
46+
// The attachment is tighed to the view returned by the swap chain, so that
47+
// the render pass draws directly on screen.
48+
view = textureView,
49+
depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
50+
// Not relevant here because we do not use multi-sampling
51+
resolveTarget = WGPUTextureView.Null,
52+
loadOp = WGPULoadOp.Clear,
53+
storeOp = WGPUStoreOp.Store,
54+
clearValue = new WGPUColor(1.0f, _green, 0.0f, 1.0f)
55+
};
5556

5657
// Describe a render pass, which targets the texture view
5758
WGPURenderPassDescriptor renderPassDesc = new()
@@ -71,8 +72,7 @@ private void OnDraw(WGPUCommandEncoder encoder, WGPUTexture target)
7172
WGPURenderPassEncoder renderPass = wgpuCommandEncoderBeginRenderPass(encoder, &renderPassDesc);
7273

7374
wgpuRenderPassEncoderEnd(renderPass);
74-
75-
wgpuTextureViewReference(targetView);
75+
wgpuRenderPassEncoderRelease(renderPass);
7676
}
7777
}
7878
}

samples/02-DrawTriangle/02-DrawTriangle.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<IsPackable>false</IsPackable>
77
<RootNamespace>Alimer.WebGPU.Samples</RootNamespace>

samples/02-DrawTriangle/Program.cs

+14-14
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,20 @@ protected override void OnTick()
154154
_graphicsDevice.RenderFrame(OnDraw);
155155
}
156156

157-
private void OnDraw(WGPUCommandEncoder encoder, WGPUTexture target)
157+
private void OnDraw(WGPUCommandEncoder encoder, WGPUTexture target, WGPUTextureView textureView)
158158
{
159-
WGPUTextureView targetView = wgpuTextureCreateView(target, null);
160-
161-
WGPURenderPassColorAttachment renderPassColorAttachment = new();
162-
// The attachment is tighed to the view returned by the swap chain, so that
163-
// the render pass draws directly on screen.
164-
renderPassColorAttachment.view = targetView;
165-
// Not relevant here because we do not use multi-sampling
166-
renderPassColorAttachment.resolveTarget = WGPUTextureView.Null;
167-
renderPassColorAttachment.loadOp = WGPULoadOp.Clear;
168-
renderPassColorAttachment.storeOp = WGPUStoreOp.Store;
169-
renderPassColorAttachment.clearValue = new WGPUColor(0.0, 0.0, 0.0, 1.0);
159+
WGPURenderPassColorAttachment renderPassColorAttachment = new()
160+
{
161+
// The attachment is tighed to the view returned by the swap chain, so that
162+
// the render pass draws directly on screen.
163+
view = textureView,
164+
// Not relevant here because we do not use multi-sampling
165+
resolveTarget = WGPUTextureView.Null,
166+
loadOp = WGPULoadOp.Clear,
167+
storeOp = WGPUStoreOp.Store,
168+
depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
169+
clearValue = new WGPUColor(0.0, 0.0, 0.0, 1.0)
170+
};
170171

171172
// Describe a render pass, which targets the texture view
172173
WGPURenderPassDescriptor renderPassDesc = new()
@@ -191,8 +192,7 @@ private void OnDraw(WGPUCommandEncoder encoder, WGPUTexture target)
191192
wgpuRenderPassEncoderDraw(renderPass, 3);
192193

193194
wgpuRenderPassEncoderEnd(renderPass);
194-
195-
wgpuTextureViewReference(targetView);
195+
wgpuRenderPassEncoderRelease(renderPass);
196196
}
197197
}
198198
}

samples/03-DrawIndexedQuad/03-DrawIndexedQuad.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<IsPackable>false</IsPackable>
77
<RootNamespace>Alimer.WebGPU.Samples</RootNamespace>

samples/03-DrawIndexedQuad/Program.cs

+14-13
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,20 @@ protected override void OnTick()
169169
_graphicsDevice.RenderFrame(OnDraw);
170170
}
171171

172-
private void OnDraw(WGPUCommandEncoder encoder, WGPUTexture target)
172+
private void OnDraw(WGPUCommandEncoder encoder, WGPUTexture target, WGPUTextureView textureView)
173173
{
174-
WGPUTextureView targetView = wgpuTextureCreateView(target, null);
175-
176-
WGPURenderPassColorAttachment renderPassColorAttachment = new();
177-
// The attachment is tighed to the view returned by the swap chain, so that
178-
// the render pass draws directly on screen.
179-
renderPassColorAttachment.view = targetView;
180-
// Not relevant here because we do not use multi-sampling
181-
renderPassColorAttachment.resolveTarget = WGPUTextureView.Null;
182-
renderPassColorAttachment.loadOp = WGPULoadOp.Clear;
183-
renderPassColorAttachment.storeOp = WGPUStoreOp.Store;
184-
renderPassColorAttachment.clearValue = new WGPUColor(0.0, 0.0, 0.0, 1.0);
174+
WGPURenderPassColorAttachment renderPassColorAttachment = new()
175+
{
176+
// The attachment is tighed to the view returned by the swap chain, so that
177+
// the render pass draws directly on screen.
178+
view = textureView,
179+
// Not relevant here because we do not use multi-sampling
180+
resolveTarget = WGPUTextureView.Null,
181+
loadOp = WGPULoadOp.Clear,
182+
storeOp = WGPUStoreOp.Store,
183+
depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
184+
clearValue = new WGPUColor(0.0, 0.0, 0.0, 1.0)
185+
};
185186

186187
// Describe a render pass, which targets the texture view
187188
WGPURenderPassDescriptor renderPassDesc = new()
@@ -207,7 +208,7 @@ private void OnDraw(WGPUCommandEncoder encoder, WGPUTexture target)
207208
wgpuRenderPassEncoderDrawIndexed(renderPass, 6);
208209

209210
wgpuRenderPassEncoderEnd(renderPass);
210-
wgpuTextureViewReference(targetView);
211+
wgpuRenderPassEncoderRelease(renderPass);
211212
}
212213
}
213214
}

samples/Alimer.WebGPU.SampleFramework/Alimer.WebGPU.SampleFramework.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
55
<IsPackable>false</IsPackable>
66
<RootNamespace>Alimer.WebGPU.Samples</RootNamespace>

samples/Alimer.WebGPU.SampleFramework/Application.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright (c) Amer Koleci and Contributors.
22
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
33

4-
using SDL;
5-
using static SDL.SDL;
4+
using SDL3;
5+
using static SDL3.SDL3;
66

77
namespace Alimer.WebGPU.Samples;
88

@@ -13,9 +13,9 @@ public abstract class Application : IDisposable
1313

1414
protected unsafe Application()
1515
{
16-
if (SDL_Init(SDL_InitFlags.Video) != 0)
16+
if (SDL_Init(SDL_InitFlags.Video) == false)
1717
{
18-
var error = SDL_GetErrorString();
18+
var error = SDL_GetError();
1919
throw new Exception($"Failed to start SDL2: {error}");
2020
}
2121

@@ -85,7 +85,7 @@ public unsafe void Run()
8585

8686
private void HandleWindowEvent(in SDL_Event evt)
8787
{
88-
switch ((SDL_EventType)evt.window.type)
88+
switch (evt.window.type)
8989
{
9090
case SDL_EventType.WindowResized:
9191
//_minimized = false;
@@ -114,15 +114,15 @@ protected virtual void OnDraw(int width, int height)
114114
}
115115

116116
//[UnmanagedCallersOnly]
117-
private static void Log_SDL(SDL_LogCategory category, SDL_LogPriority priority, string description)
117+
private static void Log_SDL(SDL_LogCategory category, SDL_LogPriority priority, string? message)
118118
{
119119
if (priority >= SDL_LogPriority.Error)
120120
{
121-
Log.Error($"[{priority}] SDL: {description}");
121+
Log.Error($"[{priority}] SDL: {message}");
122122
}
123123
else
124124
{
125-
Log.Info($"[{priority}] SDL: {description}");
125+
Log.Info($"[{priority}] SDL: {message}");
126126
}
127127
}
128128
}

0 commit comments

Comments
 (0)