Bug 1932738 - fix(webgpu): prioritize Firefox-unimplemented feature errors over adapter lack-of-support errors r=webgpu-reviewers,teoxoy

Differential Revision: https://phabricator.services.mozilla.com/D229828
This commit is contained in:
Erich Gubler 2024-11-22 14:28:10 +00:00
parent 63fa5e7544
commit 858d3f15e6

View File

@ -342,18 +342,6 @@ already_AddRefed<dom::Promise> Adapter::RequestDevice(
ffi::WGPUFeatures featureBits = 0;
for (const auto requested : aDesc.mRequiredFeatures) {
const bool supportedByAdapter = mFeatures->Features().count(requested);
if (!supportedByAdapter) {
const auto fstr = dom::GetEnumString(requested);
const auto astr = this->LabelOrId();
nsPrintfCString msg(
"`GPUAdapter.requestDevice`: '%s' was requested in "
"`requiredFeatures`, but it is not supported by adapter %s.",
fstr.get(), astr.get());
promise->MaybeRejectWithTypeError(msg);
return;
}
const auto bit = ToWGPUFeatures(requested);
if (!bit) {
const auto featureStr = dom::GetEnumString(requested);
@ -366,6 +354,18 @@ already_AddRefed<dom::Promise> Adapter::RequestDevice(
return;
}
featureBits |= *bit;
const bool supportedByAdapter = mFeatures->Features().count(requested);
if (!supportedByAdapter) {
const auto fstr = dom::GetEnumString(requested);
const auto astr = this->LabelOrId();
nsPrintfCString msg(
"`GPUAdapter.requestDevice`: '%s' was requested in "
"`requiredFeatures`, but it is not supported by adapter %s.",
fstr.get(), astr.get());
promise->MaybeRejectWithTypeError(msg);
return;
}
}
// -