Skip to content

[core-remote] Remove mutexes and other simplifications - #10074

Merged
teoxoy merged 8 commits into
gfx-rs:trunkfrom
sagudev:id-hub
Aug 14, 2026
Merged

[core-remote] Remove mutexes and other simplifications#10074
teoxoy merged 8 commits into
gfx-rs:trunkfrom
sagudev:id-hub

Conversation

@sagudev

@sagudev sagudev commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Connections
Towards #10073

Description
First commit deals with always providing IDs, removing duality of IdentityManager by removing it for global (it only remains in IdentitiyHub which is ID generator/alloc that should live in content process, this type already exisited in servo https://github.com/servo/servo/blob/2b2dcbd1deefbd8011f0076e045f5f988f8e8141/components/script_webgpu/identityhub.rs and in firefox: https://searchfox.org/firefox-main/rev/ee8e457ae20efb27313476fed0bed50571c1199f/gfx/wgpu_bindings/src/client.rs#303)

All other commits deal with removing restriction of send/sync in global as browser impl do not need it and simplification this brings (discussed #9740 (comment)). We replaced all mutexes with RefCell 🎉. For encoders we reuse interior mutability of Registery to get &mut as outlined in #9740 (comment)

Testing
Just refactor

Squash or Rebase?
Rebase

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.

@sagudev
sagudev requested a review from teoxoy August 14, 2026 15:01
@sagudev sagudev changed the title Id hub [core-remote] Remove mutexes and other simplifications Aug 14, 2026
@teoxoy teoxoy self-assigned this Aug 14, 2026
Comment thread wgpu-core-remote/src/global/instance.rs
Comment thread wgpu-core-remote/src/identity.rs
@teoxoy

teoxoy commented Aug 14, 2026

Copy link
Copy Markdown
Member

I think we might be able to eventually get rid of the RefCell as well and have rust's borrow checker making sure we don't try to borrow mutably when we shouldn't. But that's a thing for another day.

…ire ids

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
@sagudev

sagudev commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

I think we might be able to eventually get rid of the RefCell as well and have rust's borrow checker making sure we don't try to borrow mutably when we shouldn't. But that's a thing for another day.

Indeed and I think reusing mutability of Registery to get &mut Encoder is actually first step towards this.

Just throwing idea here so I do not forget: we make whole Hub mutable and then reuse hub mutablitity to get mutable Registery, for each usage we do let Hub { render_passes, bind_groups, .. } = &mut self.hub because otherwise rust will complain mut use while mut use is active.

@teoxoy
teoxoy merged commit 2d6ba33 into gfx-rs:trunk Aug 14, 2026
59 checks passed
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.

2 participants