dawn.node: Use ForceLoss when failing device creation on stale adapter
Fixed: 346197748
Change-Id: I64dc8a0bea326fb5c6c8bcee3ed263802abc89a5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/192701
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
diff --git a/src/dawn/node/binding/GPUAdapter.cpp b/src/dawn/node/binding/GPUAdapter.cpp
index e6484ce..c63b1c6 100644
--- a/src/dawn/node/binding/GPUAdapter.cpp
+++ b/src/dawn/node/binding/GPUAdapter.cpp
@@ -195,7 +195,7 @@
auto gpu_device = std::make_unique<GPUDevice>(env, desc, wgpu_device, async_);
if (!valid_) {
- gpu_device->ForceLoss(interop::GPUDeviceLostReason::kUnknown,
+ gpu_device->ForceLoss(wgpu::DeviceLostReason::FailedCreation,
"Device was marked as lost due to a stale adapter.");
}
valid_ = false;
diff --git a/src/dawn/node/binding/GPUDevice.cpp b/src/dawn/node/binding/GPUDevice.cpp
index f8852a3..9776fc8 100644
--- a/src/dawn/node/binding/GPUDevice.cpp
+++ b/src/dawn/node/binding/GPUDevice.cpp
@@ -210,12 +210,12 @@
}
}
-void GPUDevice::ForceLoss(interop::GPUDeviceLostReason reason, const char* message) {
+void GPUDevice::ForceLoss(wgpu::DeviceLostReason reason, const char* message) {
if (lost_promise_.GetState() == interop::PromiseState::Pending) {
- lost_promise_.Resolve(
- interop::GPUDeviceLostInfo::Create<DeviceLostInfo>(env_, reason, message));
+ lost_promise_.Resolve(interop::GPUDeviceLostInfo::Create<DeviceLostInfo>(
+ env_, interop::GPUDeviceLostReason::kUnknown, message));
}
- device_.InjectError(wgpu::ErrorType::DeviceLost, message);
+ device_.ForceLoss(reason, message);
}
interop::Interface<interop::GPUSupportedFeatures> GPUDevice::getFeatures(Napi::Env env) {
diff --git a/src/dawn/node/binding/GPUDevice.h b/src/dawn/node/binding/GPUDevice.h
index a41a871..d39d489 100644
--- a/src/dawn/node/binding/GPUDevice.h
+++ b/src/dawn/node/binding/GPUDevice.h
@@ -46,7 +46,7 @@
std::shared_ptr<AsyncRunner> async);
~GPUDevice();
- void ForceLoss(interop::GPUDeviceLostReason reason, const char* message);
+ void ForceLoss(wgpu::DeviceLostReason reason, const char* message);
// interop::GPUDevice interface compliance
interop::Interface<interop::GPUSupportedFeatures> getFeatures(Napi::Env) override;