Skip to content

Make WriteOnly use only volatile writes.#9809

Draft
kpreid wants to merge 1 commit into
gfx-rs:trunkfrom
kpreid:volatile
Draft

Make WriteOnly use only volatile writes.#9809
kpreid wants to merge 1 commit into
gfx-rs:trunkfrom
kpreid:volatile

Conversation

@kpreid

@kpreid kpreid commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Connections
Part of #8897

Description

  • Replace all pointer write operations performed by WriteOnly with write_volatile().
  • Document that callers obtaining raw pointers from WriteOnly must do the same.

Per discussion in #8897, this is technically necessary for WriteOnly to be sound when used with write-combining memory, because a non-volatile write is permitted to be accompanied by extra reads or writes which might not behave, on write-combining memory, as expected by the optimizer.

There are no const volatile write operations, so we have to remove const fn.

Testing
Tests pass. Documentation reviewed. However, ideally, benchmarks or assembly inspection would assure us that this does not have a large performance regression.

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.

We believe that this is necessary for `WriteOnly` to be sound, because
a non-volatile write is technically permitted to be accompanied by
extra reads or writes.

There are no `const` volatile write operations, so we have to remove
`const fn`.
@kpreid kpreid added the area: api Issues related to API surface label Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: api Issues related to API surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant