Skip to content

Conversation

@camillol
Copy link
Contributor

Currently, this function creates a new wrapper each time it's called. As a result, what is a single device in JavaScript looks like different devices in C (the handles are different), and there is a new entry in WebGPU.mgrDevice for each call.

With this change, the same handle is returned each time.

Note that each new device wrapper currently also leaks a queue wrapper (see the comment at

// TODO: Release() the device's default queue when the device is freed.
), so this change also reduces the impact of that issue.

Currently, this function creates a new wrapper each time it's called. As
a result, what is a single device in JavaScript looks like different
devices in C (the handles are different), and there is a new entry in
WebGPU.mgrDevice for each call.

With this change, the same handle is returned each time.

Note that each new device wrapper currently also leaks a queue wrapper
(see the comment at
<https://github.com/emscripten-core/emscripten/blob/0c4fba0371abc8c7219dc481a02ea4a464b14641/src/library_webgpu.js#L190>),
so this change also reduces the impact of that issue.
@sbc100 sbc100 requested a review from kainino0x October 21, 2022 04:39
Copy link
Collaborator

@kainino0x kainino0x left a comment

Choose a reason for hiding this comment

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

LGTM!

@kainino0x kainino0x merged commit 8647224 into emscripten-core:main Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants