Sitelet https://github.com/gpuweb/gpuweb/pull/1316
Skip to content

Add GPUDevice.destroy() - #1316

Merged
kdashg merged 5 commits into
gpuweb:mainfrom
kainino0x:device-destroy
Jan 15, 2021
Merged

kdashg merged 5 commits into
gpuweb:mainfrom
kainino0x:device-destroy

Conversation

@kainino0x

@kainino0x kainino0x commented Dec 16, 2020 •

Copy link
Copy Markdown
Contributor

Like other .destroy() methods, immediately destroys the device and makes it invalid for future use (i.e. lost, though it doesn't fire the .lost promise).

This allows for eager cleanup of an entire device and its resources.


Preview | Diff

@kvark

kvark commented Dec 16, 2020

Copy link
Copy Markdown
Contributor

What about the pending callbacks, e.g. from buffer mapping? Would they be dropped on the ground with this call?

@kainino0x

kainino0x commented Dec 16, 2020 •

Copy link
Copy Markdown
Contributor Author

I think the algorithms for those could probably say e.g. "if the device is lost, reject with ...".

Outstanding asynchronous operations will fail, so implementations can abort them early.

Though maybe we want to put them all in a central location to get rejected (that's more accurate to the implementation).

@Kangz Kangz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM overall

Comment thread spec/index.bs Outdated
It may become [=invalid=] during its lifetime, but it will never become valid again.

Issue: Consider separating "invalid" from "destroyed".
This would let validity be immutable, and only operations involving devices,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Destroying the device would also prevent submitting work on the queue for example.

Comment thread spec/index.bs Outdated

1. Make |this|.{{GPUDevice/[[device]]}} [=invalid=].

Note: This does **not** resolve |this|.{{GPUDevice/lost}}.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the reasoning behind this?

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.

I don't think it's useful to send a signal back to the app in response to it destroying the device. .lost is not a promise you would await in the middle of some logic, so there's no danger in leaving it unresolved forever - its resolution is meant to be a signal to recover from device loss. If we did resolve it on destroy, then apps would have to go out of their way to prevent their own explicit-destroy from triggering recovery logic.

@kainino0x

Copy link
Copy Markdown
Contributor Author

Resolution: propose having .lost fire on destroy(), give it a parameter about why it was lost (naturally or by destroy()).

@github-actions

Copy link
Copy Markdown
Contributor

Previews, as seen at the time of posting this comment:
WebGPU | IDL
WGSL
9507e8e

@github-actions

Copy link
Copy Markdown
Contributor

Previews, as seen at the time of posting this comment:
WebGPU | IDL
WGSL
20f3b90

@kainino0x

Copy link
Copy Markdown
Contributor Author

Resolution: propose having .lost fire on destroy(), give it a parameter about why it was lost (naturally or by destroy()).

Done, PTAL.

@austinEng fyi

@kdashg
kdashg merged commit 2ea89ce into gpuweb:main Jan 15, 2021
@kainino0x
kainino0x deleted the device-destroy branch January 19, 2021 23:36
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
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.

4 participants