Skip to content

fix(gles): Tidy locking in struct Buffer#9505

Open
andyleiserson wants to merge 1 commit intogfx-rs:trunkfrom
andyleiserson:jj-push-wqmu
Open

fix(gles): Tidy locking in struct Buffer#9505
andyleiserson wants to merge 1 commit intogfx-rs:trunkfrom
andyleiserson:jj-push-wqmu

Conversation

@andyleiserson
Copy link
Copy Markdown
Contributor

@andyleiserson andyleiserson commented May 5, 2026

Fixes an issue with #8505.

Rather than use multiple adjacent mutexes and try to reason about protecting access to mapped: Cell<bool> with the GL context lock, puts all of the map state together under a single mutex, and removes the unsafe Send / Sync for struct Buffer.

Testing
Existing tests and keeping the compiler happy.

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-hal/src/gles/mod.rs
struct BufferMapState {
/// True if the GL buffer is actually mapped, i.e. not "fake-mapped" with
/// an empty slice
mapped: Cell<bool>,
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.

This is the key piece in all of this. Cell is not Sync and should not be used here.

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