From 7a934854106a65e137c0c9f836ddcc7e7178a334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Fri, 1 Oct 2021 08:54:47 +0000 Subject: [PATCH] Improve validation errors in Adapter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Brandon Jones Commit-Queue: François Beaufort --- src/dawn_native/Adapter.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dawn_native/Adapter.cpp b/src/dawn_native/Adapter.cpp index c311df0b0d..61912f4015 100644 --- a/src/dawn_native/Adapter.cpp +++ b/src/dawn_native/Adapter.cpp @@ -121,8 +121,12 @@ namespace dawn_native { MaybeError AdapterBase::CreateDeviceInternal(DeviceBase** result, const DeviceDescriptor* descriptor) { if (descriptor != nullptr) { - if (!SupportsAllRequestedExtensions(descriptor->requiredExtensions)) { - return DAWN_VALIDATION_ERROR("One or more requested extensions are not supported"); + for (const char* extensionStr : descriptor->requiredExtensions) { + 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, reinterpret_cast(descriptor->requiredLimits)->limits)); - if (descriptor->requiredLimits->nextInChain != nullptr) { - return DAWN_VALIDATION_ERROR("Unsupported limit extension struct"); - } + DAWN_INVALID_IF(descriptor->requiredLimits->nextInChain != nullptr, + "nextInChain is not nullptr."); } DAWN_TRY_ASSIGN(*result, CreateDeviceImpl(descriptor));