node: Throw a TypeError for unsupported GPUQueryTypes

The WebGPU spec requires this so that an extension not being enabled or
not implemented by the browser both behave the same.

Bug: None
Change-Id: I52d991ba63438068d4adaf1391771336186a402a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/112422
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2022-12-05 13:54:44 +00:00 committed by Dawn LUCI CQ
parent 0d6b1fc45f
commit c17b4f9b69
2 changed files with 9 additions and 3 deletions

View File

@ -1609,8 +1609,14 @@ bool Converter::Convert(wgpu::QueryType& out, const interop::GPUQueryType& in) {
out = wgpu::QueryType::Occlusion;
return true;
case interop::GPUQueryType::kTimestamp:
out = wgpu::QueryType::Timestamp;
return true;
if (HasFeature(wgpu::FeatureName::TimestampQuery)) {
out = wgpu::QueryType::Timestamp;
return true;
} else {
Napi::TypeError::New(env, "invalid value for GPUQueryType")
.ThrowAsJavaScriptException();
return false;
}
}
Napi::Error::New(env, "invalid value for GPUQueryType").ThrowAsJavaScriptException();
return false;

View File

@ -472,7 +472,7 @@ interop::Interface<interop::GPURenderBundleEncoder> GPUDevice::createRenderBundl
interop::Interface<interop::GPUQuerySet> GPUDevice::createQuerySet(
Napi::Env env,
interop::GPUQuerySetDescriptor descriptor) {
Converter conv(env);
Converter conv(env, device_);
wgpu::QuerySetDescriptor desc{};
if (!conv(desc.label, descriptor.label) || !conv(desc.type, descriptor.type) ||