Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using WasmAbi functions on WebGPU backend #3657

Merged
merged 5 commits into from
Apr 10, 2023

Conversation

grovesNL
Copy link
Collaborator

@grovesNL grovesNL commented Apr 8, 2023

Checklist

  • Run cargo clippy.
  • Run RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections
Fixes #3430

Description
IntoWasmAbi and FromWasmAbi can be problematic for our use case because IntoWasmAbi takes ownership of our type. We could workaround this in different ways, but the most straightforward path right now seems to be to avoid using these entirely and instead not tracking IDs for the WebGPU backend.

We could look at doing this in a few different ways once we internally make some changes to better support multi-threading (e.g., many types will be Arc internally so we could consider some other approaches).

Testing
Tested the WebGPU examples that are known to work (hello-triangle, boids, msaa-line, etc.) in Canary.

@niklaskorz
Copy link
Contributor

niklaskorz commented Apr 8, 2023

Tried it on https://github.com/niklaskorz/linon/tree/dynamic-dispatch-workaround and it works (deployed on https://niklaskorz.github.io/linon/):

grafik

A note though (that might be unrelated to this PR, not sure): using depth textures without a stencil part in the format does not seem to work in Chrome, i.e. using Depth32Float instead of Depth24PlusStencil8 gives this error, even though no stencil ops are actually set in the render pass:

stencilLoadOp is (LoadOp::Load) and stencilStoreOp is (StoreOp::Store) when stencilReadOnly (0) or the attachment ([TextureView of Texture "depth_texture"]) has no stencil aspect.
 - While validating depthStencilAttachment.
 - While encoding [CommandEncoder "encoder"].BeginRenderPass([RenderPassDescriptor "rpass"]).

[Invalid CommandBuffer "encoder"] is invalid.
    at ValidateObject (..<URL>)
    at ValidateSubmit (..<URL>)

localhost/:1 WebGPU: too many warnings, no more warnings will be reported to the console for this GPUDevice.

Edit: ok this is indeed unrelated to this PR but it's an existing bug in wgpu, I'll try to fix it :)

maxammann added a commit to maxammann/maplibre-rs that referenced this pull request Apr 10, 2023
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All seems reasonable, thank you for taking the time to fix this!

Cargo.toml Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamic dispatch layer breaks on web
4 participants