Skip to content

build: Exclude wgpu-core when building the WebGPU-backend samples#9557

Open
andyleiserson wants to merge 2 commits into
gfx-rs:trunkfrom
andyleiserson:jj-push-toum
Open

build: Exclude wgpu-core when building the WebGPU-backend samples#9557
andyleiserson wants to merge 2 commits into
gfx-rs:trunkfrom
andyleiserson:jj-push-toum

Conversation

@andyleiserson
Copy link
Copy Markdown
Contributor

In trying to reproduce the error discussed in #9537 (comment), I found that I was getting a different failure:

panicked at examples/features/src/hello_triangle/mod.rs:127:67:
called `Result::unwrap()` on an `Err` value: CreateSurfaceError { inner: Hal(FailedToCreateSurfaceForAnyBackend({})) }

This was because wgpu-core was being pulled into the sample build for the WebGPU backend because noop appears in the workspace feature list. To fix this, remove noop from the workspace feature list. Also fix some build warnings exposed by that change.

There are two other subtle interactions that appear in the diff:

  • wgpu-examples includes the trace feature. To build without wgpu-core, I've added a direct dependency from wgpu to wgpu-types/trace (normally it is pulled in indirectly via wgpu -> wgpu-core?/trace -> wgpu-types/trace). It would also be possible to fix this by adding a trace feature to wgpu-examples or by removing tracing from the examples entirely.
  • I added --edges no-dev to the wgpu-dependency test because wgpu-examples has a dev-dependency on wgpu-core via wgpu-test. However, this test could previously pass without --edges no-dev, not sure if we might want to maintain that property where it holds for some reason.

Testing
Adds wgpu-examples to the wgpu-dependency test.

Squash or Rebase? Squash

Checklist

  • I self-reviewed and fully understand this PR.
  • WebGPU implementations built with wgpu may be affected behaviorally.
  • Validation and feature gates are in place to confine behavioral changes.
  • Tests demonstrate the validation and altered logic works.
  • CHANGELOG.md entries for the user-facing effects of this change are present.
  • The PR is minimal, and doesn't make sense to land as multiple PRs.
  • Commits are logically scoped and individually reviewable.
  • The PR description has enough context to understand the motivation and solution implemented.

Comment thread wgpu/src/api/buffer.rs
pub unsafe fn as_hal<A: hal::Api>(
&self,
) -> Option<impl Deref<Target = A::Buffer> + WasmNotSendSync> {
) -> Option<impl core::ops::Deref<Target = A::Buffer> + WasmNotSendSync> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This change doesn't seem to have anything to do with this PR? I like it, but it's not in the PR description.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When wgpu_core is removed from the build, the module-scope core::ops::Deref import becomes unused in WebGPU-only builds. I made this change to resolve that warning. (Although I did not check whether the warning is enforced in CI, maybe this configuration is an exception?).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see. In that case, I would consider doing one of these three instead:

#[allow(unused_imports)]
use core::ops::Deref;
#[cfg_attr(not(wgpu_core)), expect(unused_imports))]
use core::ops::Deref;
use core::ops;
// ... use all ops items as ops::Foo 

I would consider all of these superior to making the import style inconsistent in an undocumented way. But that’s my opinion, not wgpu project style.

@cwfitzgerald cwfitzgerald self-assigned this May 20, 2026
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.

3 participants