add support for browser-wasm runtime#20
Conversation
…23178b79465254668eab408)
There was a problem hiding this comment.
Pull Request Overview
This PR refocuses the repository on the browser‐wasm runtime by removing all other platform support, updating project references, and adding a Blazor WebAssembly “HelloTriangleWasm” sample with updated documentation.
- Deletes non‐browser‐wasm runtimes and headers, retaining only Emscripten’s
webgpu.h - Updates project files and solution to include the new
HelloTriangleWasmsample and removes the old desktop example - Revises README for accurate headers, links, and installation instructions
Reviewed Changes
Copilot reviewed 27 out of 48 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| WebGPUGen/WebGPUGen/WebGPUGen.csproj | Removed non‐browser header entries |
| WebGPUGen/WebGPUGen/Program.cs | Updated headerFile path to webgpu.h |
| WebGPUGen/WebGPUGen/Helpers.cs | Adjusted size_t mapping from ulong to uint |
| WebGPUGen/WebGPUGen/Headers/wgpu.h | Deleted the C wrapper in favor of Emscripten’s header |
| WebGPUGen/WebGPUGen.sln | Replaced HelloTriangle project with HelloTriangleWasm |
| WebGPUGen/HelloTriangleWasm/wwwroot/webgpu.js | Added initWebGPU helper to preinitialize the device |
| WebGPUGen/HelloTriangleWasm/wwwroot/index.html | Added <canvas> element and script reference |
| WebGPUGen/HelloTriangleWasm/Pages/Home.razor.cs | Implemented the WebGPU triangle rendering sample |
| WebGPUGen/Evergine.Bindings.WebGPU/WebGPUNative.cs | Added DllImport signatures for Emscripten WebGPU APIs |
| README.md | Updated introduction, installation commands, and license |
Comments suppressed due to low confidence (3)
WebGPUGen/HelloTriangleWasm/wwwroot/index.html:11
- [nitpick] The
<canvas>element has no explicit width/height, which can lead to inconsistent sizing across browsers. Consider addingwidthandheightattributes or CSS rules to define its dimensions.
<link rel="icon" type="image/png" href="favicon.png" />
WebGPUGen/Evergine.Bindings.WebGPU/WebGPUNative.cs:14
- The native signature expects a
WGPUMapModeFlagsenum, but this usesWGPUMapMode. Update the parameter type toWGPUMapModeFlagsto match the C API and avoid mismatches.
public static extern void wgpuBufferMapAsyncWithoutCallback(WGPUBuffer buffer, WGPUMapMode mode, uint offset, uint size, void* userdata);
WebGPUGen/HelloTriangleWasm/Pages/Home.razor.cs:139
- This nested initializer for
alphalacks a constructor and will not compile. Change toalpha = new WGPUBlendComponent { operation = ..., srcFactor = ..., dstFactor = ... }.
alpha = {
| { | ||
| public static char* ToPointer(this string text) | ||
| { | ||
| return (char*)System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(text); |
There was a problem hiding this comment.
Allocating unmanaged memory with StringToHGlobalAnsi without a corresponding free causes a leak. Consider providing a free method (e.g., Marshal.FreeHGlobal) or using a fixed buffer for temporary pointers.
There was a problem hiding this comment.
@jcant0n @davilovick this is interesting. I have searched in Evergine and this pattern is used mostly in Vulkan and WebGPU. It may be interesting to apply what it proposes :-)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
As requested by @jcant0n, this PR deletes every runtime different from browser-wasm, focusing the attention in this last.
It includes the latest findings while testing the preview package at https://github.com/EvergineTeam/Engine/pull/274.
I have also updated README (it had headers which did not match their bodies, a broken link to the license, etc.)