You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The WebGPU spec was changed a little while back to return a device which has already been lost rather than a null device if requestDevice fails. This poses some complications for the current wgpuDeviceSetDeviceLostCallback() API in webgpu.h
Since wgpuDeviceSetDeviceLostCallback() cannot be called until a device is acquired, with the updated logic there's no way to set the callback until the device has already been lost. This then necessitates that the lost reason and message be cached if there is not callback set until a callback is eventually set, which would fire immediately upon setting. When attempting to implement this in Dawn I found that the logic was unexpectedly tricky and contained multiple subtle edge cases.
A cleaner alternative would be to pass the device lost callback and userdata in at device creation time as part of the descriptor and remove the wgpuDeviceSetDeviceLostCallback() call entirely. This way the device will be able to use a unified path for handling any device loss at any point in time. Applications that need more flexibility will still be able to build their own message propagation system on top of it, and can probably do it more confidently since this change would remove questions such as "What happens if I set the callback twice?"
The WebGPU spec was changed a little while back to return a device which has already been lost rather than a null device if requestDevice fails. This poses some complications for the current
wgpuDeviceSetDeviceLostCallback()
API in webgpu.hSince
wgpuDeviceSetDeviceLostCallback()
cannot be called until a device is acquired, with the updated logic there's no way to set the callback until the device has already been lost. This then necessitates that the lost reason and message be cached if there is not callback set until a callback is eventually set, which would fire immediately upon setting. When attempting to implement this in Dawn I found that the logic was unexpectedly tricky and contained multiple subtle edge cases.A cleaner alternative would be to pass the device lost callback and userdata in at device creation time as part of the descriptor and remove the
wgpuDeviceSetDeviceLostCallback()
call entirely. This way the device will be able to use a unified path for handling any device loss at any point in time. Applications that need more flexibility will still be able to build their own message propagation system on top of it, and can probably do it more confidently since this change would remove questions such as "What happens if I set the callback twice?"New descriptor would look like this:
Any concerns?
The text was updated successfully, but these errors were encountered: