[go: up one dir, main page]

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

Upgrade to wgpu 22 #2424

Closed
hannobraun opened this issue Jul 22, 2024 · 5 comments
Closed

Upgrade to wgpu 22 #2424

hannobraun opened this issue Jul 22, 2024 · 5 comments
Labels
good first issue Good for newcomers topic: build Anything relating to the build system. type: development Work to ease development or maintenance, without direct effect on features or bugs

Comments

@hannobraun
Copy link
Owner

This upgrade requires manual intervention. Here's the build failure from the automatic upgrade attempt in #2422:
https://github.com/hannobraun/fornjot/actions/runs/10040783745/job/27747509273?pr=2422

Labeling good first issue Good for newcomers , as this doesn't require a deep knowledge of Fornjot, those build errors don't look too intimidating, and the recent wgpu upgrades haven't been too involved.

@hannobraun hannobraun added good first issue Good for newcomers type: development Work to ease development or maintenance, without direct effect on features or bugs topic: build Anything relating to the build system. labels Jul 22, 2024
@felix91gr
Copy link
Contributor

Lemme try it. If I don't ping back in 24 hours, feel free to assign it to someone else c:

@felix91gr
Copy link
Contributor

Okay, I have a candidate fix. Let me test it and then make a PR

@felix91gr
Copy link
Contributor
felix91gr commented Jul 23, 2024

I might need some advice. Here is what I have for now.

Summary

I have fixes for the 3 build errors that appeared in CI. The three of them, I think, can be dealt with without much fuss.

Further testing does reveal another build error, which I'll describe in the second section.

Fixes for the 3 errors seen in CI

These are the errors, reproduced on my end:

image

The first one is due to the new MemoryHints field that is fed to DeviceDescriptor. I am currently asking for a MemoryUsage profile, on the grounds that it should help with compatibility (I think, I might be wrong on this).

This error is fixed by just adding a memory usage profile.

The second and third errors are due to a new field, cache: Option<PipelineCache> that is now a part of RenderPipelineDescriptor. I have set it to None for now, and can be changed later if more performance is needed.

Those fixes make cargo build, test and clippy all pass without a problem.

The new issue I'm looking at (advice is much appreciated)

I ran just ci locally after applying the fixes above, and this is the error I get:

image

The RUSTFLAGS that were used are the following:

Running RUSTFLAGS="-D warnings" "cargo" "build" "--all-features" "--target" "wasm32-unknown-unknown" "-p" "fj-viewer"

I'm not sure what to do about this error.

Reading the release notes, it looks like enumerate_adapters is now native-only:

image

I'm guessing that means we can't use it on wasm32-unknown-unknown anymore, and hence a different approach to obtaining the adapters is needed. request_adapters, perhaps? I'll take a look at it tomorrow, and see if something clicks about it. I'm pretty sure something will.

@hannobraun
Copy link
Owner Author

Thank you for looking into this, @felix91gr!

My reading matches yours: We need to avoid enumerate_adapters with wasm32-unknown-unknown, and need request_adapter instead. This requires a surface, as part of RequestAdapterOptions, but that's not a problem, since we already have one where we need it.

Looking over the code, I think this shouldn't be too hard to adapt. Let's look at what we're doing:

  1. Use enumerate_adapters to log all adapters before trying to do anything. Should be fine to just slap a #[cfg(not(target = "wasm32-unknown-unknown"))] on there. (Not sure about the specific syntax, but something along those lines should work.
  2. Call Device::from_preferred_adapter, which uses request_adapter internally. This is the main code path and should require no change.
  3. In case of failure, call Device::try_from_all_adapters as a fallback. Since this is just fallback behavior, it should be fine to just slap another #[cfg(not(...))] on there.

So to summarize, the main code path is already alright, and just debug output and fallback in case of errors use the problematic enumerate_adapters. Since, according the the changelog (as highlighted in the screenshot you posted), enumerate_adapters returned an empty Vec all along on WASM, just configuring them out as I suggested should not change any behavior.

@hannobraun
Copy link
Owner Author

Addressed in #2427.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers topic: build Anything relating to the build system. type: development Work to ease development or maintenance, without direct effect on features or bugs
Projects
None yet
Development

No branches or pull requests

2 participants