Skip to content

Add tests for mapping behavior around device.destroy() #4295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kainino0x
Copy link
Collaborator

@kainino0x kainino0x commented Mar 14, 2025

Test mappedAtCreation and mapAsync behavior around device.destroy(). Searching for references to GPUDevice.destroy, I can't seem to find any other tests for this, except for map_detach which I've also enhanced a tiny bit here.
Spec: https://gpuweb.github.io/gpuweb/#dom-gpubuffer-mapasync

This tests the behavior currently written in the spec (modulo uncertainty around gpuweb/gpuweb#5101), but the specced behavior is weird; see gpuweb/gpuweb#5102.

Also fix a bug where some test code was running twice unintentionally.

Issue: None filed except for the spec issue


Requirements for PR author:

  • All missing test coverage is tracked with "TODO" or .unimplemented().
  • New helpers are /** documented */ and new helper files are found in helper_index.txt.
  • Test behaves as expected in a WebGPU implementation. (If not passing, explain above.)
  • Test have be tested with compatibility mode validation enabled and behave as expected. (If not passing, explain above.)

Requirements for reviewer sign-off:

  • Tests are properly located in the test tree.
  • Test descriptions allow a reader to "read only the test plans and evaluate coverage completeness", and accurately reflect the test code.
  • Tests provide complete coverage (including validation control cases). Missing coverage MUST be covered by TODOs.
  • Helpers and types promote readability and maintainability.

When landing this PR, be sure to make any necessary issue status updates.

this.expectDeviceLost('destroyed');

this.expectValidationError(fn, false);
Copy link
Collaborator Author

@kainino0x kainino0x Mar 14, 2025

Choose a reason for hiding this comment

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

Also fix a bug where some test code was running twice unintentionally.

fn is already called below, it should not be called twice. We don't need to capture validation errors anymore because there are never any (and test teardown will check this). (Likely when this test was written, sometimes there were validation errors here.)

@kainino0x kainino0x marked this pull request as draft March 14, 2025 20:00
@kainino0x
Copy link
Collaborator Author

I'll revisit this after the WG discusses gpuweb/gpuweb#5102.

const b1 = t.createBufferTracked({ size: 16, usage, mappedAtCreation: true });
t.expect(b1.mapState === 'mapped', 'b1 before destroy 1');

await t.executeAfterDestroy(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We are still pending this decision right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes.

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