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; out = wgpu::QueryType::Occlusion;
return true; return true;
case interop::GPUQueryType::kTimestamp: case interop::GPUQueryType::kTimestamp:
out = wgpu::QueryType::Timestamp; if (HasFeature(wgpu::FeatureName::TimestampQuery)) {
return true; 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(); Napi::Error::New(env, "invalid value for GPUQueryType").ThrowAsJavaScriptException();
return false; return false;

View File

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