dawn.node: make popErrorScope reject on validation errors.

The semantic of popErrorScope was changed from raising an exception on
validation errors to instead reject the promise.

Bug: dawn:1123
Bug: dawn:1324
Change-Id: I34322d8293e112eb2d1bfea784e2b2d6be33b604
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/85506
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez 2022-04-01 18:18:22 +00:00 committed by Dawn LUCI CQ
parent d78ca49bdb
commit d1cdb61aa1
1 changed files with 5 additions and 9 deletions

View File

@ -454,7 +454,7 @@ namespace wgpu::binding {
auto* ctx = new Context{env, Promise(env, PROMISE_INFO), async_}; auto* ctx = new Context{env, Promise(env, PROMISE_INFO), async_};
auto promise = ctx->promise; auto promise = ctx->promise;
bool ok = device_.PopErrorScope( device_.PopErrorScope(
[](WGPUErrorType type, char const* message, void* userdata) { [](WGPUErrorType type, char const* message, void* userdata) {
auto c = std::unique_ptr<Context>(static_cast<Context*>(userdata)); auto c = std::unique_ptr<Context>(static_cast<Context*>(userdata));
auto env = c->env; auto env = c->env;
@ -465,12 +465,14 @@ namespace wgpu::binding {
case WGPUErrorType::WGPUErrorType_OutOfMemory: case WGPUErrorType::WGPUErrorType_OutOfMemory:
c->promise.Resolve(interop::GPUOutOfMemoryError::Create<OOMError>(env)); c->promise.Resolve(interop::GPUOutOfMemoryError::Create<OOMError>(env));
break; break;
case WGPUErrorType::WGPUErrorType_Unknown:
case WGPUErrorType::WGPUErrorType_DeviceLost:
case WGPUErrorType::WGPUErrorType_Validation: case WGPUErrorType::WGPUErrorType_Validation:
c->promise.Resolve( c->promise.Resolve(
interop::GPUValidationError::Create<ValidationError>(env, message)); interop::GPUValidationError::Create<ValidationError>(env, message));
break; break;
case WGPUErrorType::WGPUErrorType_Unknown:
case WGPUErrorType::WGPUErrorType_DeviceLost:
c->promise.Reject(Errors::OperationError(env, message));
break;
default: default:
c->promise.Reject("unhandled error type"); c->promise.Reject("unhandled error type");
break; break;
@ -478,12 +480,6 @@ namespace wgpu::binding {
}, },
ctx); ctx);
if (ok) {
return promise;
}
delete ctx;
promise.Reject(Errors::OperationError(env));
return promise; return promise;
} }