Improve validation errors in Adapter

Updates all validation messages in Adapter.cpp to give them better
contextual information.

Bug: dawn:563
Change-Id: I71381f56b51ef69c3064af837fe20d6afa7ce271
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/65581
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Brandon Jones <bajones@google.com>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
This commit is contained in:
François Beaufort 2021-10-01 08:54:47 +00:00 committed by Dawn LUCI CQ
parent 5ad5250a3b
commit 7a93485410
1 changed files with 8 additions and 5 deletions

View File

@ -121,8 +121,12 @@ namespace dawn_native {
MaybeError AdapterBase::CreateDeviceInternal(DeviceBase** result, MaybeError AdapterBase::CreateDeviceInternal(DeviceBase** result,
const DeviceDescriptor* descriptor) { const DeviceDescriptor* descriptor) {
if (descriptor != nullptr) { if (descriptor != nullptr) {
if (!SupportsAllRequestedExtensions(descriptor->requiredExtensions)) { for (const char* extensionStr : descriptor->requiredExtensions) {
return DAWN_VALIDATION_ERROR("One or more requested extensions are not supported"); Extension extensionEnum = mInstance->ExtensionNameToEnum(extensionStr);
DAWN_INVALID_IF(extensionEnum == Extension::InvalidEnum,
"Requested feature %s is unknown.", extensionStr);
DAWN_INVALID_IF(!mSupportedExtensions.IsEnabled(extensionEnum),
"Requested feature %s is disabled.", extensionStr);
} }
} }
@ -131,9 +135,8 @@ namespace dawn_native {
mUseTieredLimits ? ApplyLimitTiers(mLimits.v1) : mLimits.v1, mUseTieredLimits ? ApplyLimitTiers(mLimits.v1) : mLimits.v1,
reinterpret_cast<const RequiredLimits*>(descriptor->requiredLimits)->limits)); reinterpret_cast<const RequiredLimits*>(descriptor->requiredLimits)->limits));
if (descriptor->requiredLimits->nextInChain != nullptr) { DAWN_INVALID_IF(descriptor->requiredLimits->nextInChain != nullptr,
return DAWN_VALIDATION_ERROR("Unsupported limit extension struct"); "nextInChain is not nullptr.");
}
} }
DAWN_TRY_ASSIGN(*result, CreateDeviceImpl(descriptor)); DAWN_TRY_ASSIGN(*result, CreateDeviceImpl(descriptor));