Skip to content

Support passing MapMode as (potentially invalid) bitflags and pass all mapping tests in deno - #10398

Merged
mergify[bot] merged 14 commits into
gfx-rs:trunkfrom
sagudev:bma
Oct 26, 2026
Merged

mergify[bot] merged 14 commits into
gfx-rs:trunkfrom
sagudev:bma

Conversation

@sagudev

@sagudev sagudev commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

Connections

Towards #10073

spec issue: gpuweb/cts#4708
spec change: gpuweb/gpuweb#10971
CTS change: gpuweb/cts#4713

Description

Similarly as in #10315 we need to pass GPUMapModeFlags as bitflags, so we can do move validation from content process in GPU processes. Ordering of validation checks is important here (https://gpuweb.github.io/gpuweb/#dom-gpubuffer-mapasync):

  1. If any of the following conditions are unsatisfied:

...

Reject p with an AbortError.

  1. If any of the following conditions are unsatisfied:

...
Reject p with an OperationError.

To make it easier to code in downstream consumers which use MapModeFlags we also return resolved MapMode into the callback (instead of returning ()).

Many deno commits is made to make all webgpu:api,validation,buffer,mapping:* tests work. The main thing is that we need to limit scope of OpState refcell borrows to prevent crashes, and drain microtask queue before resolving promise (to get deferred promise behavior). I did try to follow spec to the letter by returning promise object and resolving it from callback in sagudev@1dcc79c, but tokio tasks are not part of deno's event loop so event loop might complete before promise resolves thus no tests are actually done before we are done executing event loop.

Testing

New deno test enabled, and webgpu:api,validation,buffer,mapping:mapAsync,destroyedDevice:* also passes.

Squash or Rebase?

Rebase

LLM Use?

None

Checklist

  • I self-reviewed and fully understand this PR.
  • 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.
  • (If applicable) WebGPU implementations built with wgpu may be affected behaviorally.
  • (If applicable) Validation and feature gates are in place to confine behavioral changes.
  • (If applicable) Tests demonstrate the validation and altered logic works.

@sagudev

This comment was marked as resolved.

@sagudev
sagudev force-pushed the bma branch 3 times, most recently from d053a1f to 2cf1596 Compare September 20, 2026 15:18
@sagudev
sagudev force-pushed the bma branch 2 times, most recently from 95099bc to 2f36193 Compare September 28, 2026 17:49
@sagudev
sagudev force-pushed the bma branch 7 times, most recently from 04c5311 to 60f5694 Compare October 25, 2026 07:03
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
this is important as we need to return Abort error instead of Operation error which is raised on invalid buffer

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>
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 marked this pull request as ready for review October 25, 2026 07:27
@sagudev sagudev changed the title [core] Support passing MapMode as (potentially invalid) bitflags Support passing MapMode as (potentially invalid) bitflags and pass all mapping tests in deno Oct 25, 2026
@sagudev
sagudev requested a review from teoxoy October 25, 2026 11:12
@teoxoy teoxoy self-assigned this Oct 26, 2026

@teoxoy teoxoy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great stuff!

@teoxoy teoxoy added the merge: rebase Merge queue rebases this PR instead of squashing it label Oct 26, 2026
@teoxoy

teoxoy commented Oct 26, 2026

Copy link
Copy Markdown
Member

@Mergifyio queue

@mergify mergify Bot added the queue: queued Set by Mergify while the PR is in the merge queue label Oct 26, 2026
@mergify
mergify Bot merged commit 0c7c121 into gfx-rs:trunk Oct 26, 2026
66 checks passed
@github-project-automation github-project-automation Bot moved this from To triage to Done in Triage Oct 26, 2026
@mergify mergify Bot removed the queue: queued Set by Mergify while the PR is in the merge queue label Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge: rebase Merge queue rebases this PR instead of squashing it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants