diff --git a/generator/templates/dawn/native/ValidationUtils.cpp b/generator/templates/dawn/native/ValidationUtils.cpp index a5efb01361..9c170b7250 100644 --- a/generator/templates/dawn/native/ValidationUtils.cpp +++ b/generator/templates/dawn/native/ValidationUtils.cpp @@ -29,7 +29,7 @@ namespace {{native_namespace}} { return {}; {% endfor %} default: - return DAWN_FORMAT_VALIDATION_ERROR("Value %i is invalid for {{as_cType(type.name)}}.", static_cast(value)); + return DAWN_VALIDATION_ERROR("Value %i is invalid for {{as_cType(type.name)}}.", static_cast(value)); } } @@ -40,7 +40,7 @@ namespace {{native_namespace}} { if ((value & static_cast<{{namespace}}::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) { return {}; } - return DAWN_FORMAT_VALIDATION_ERROR("Value %i is invalid for {{as_cType(type.name)}}.", static_cast(value)); + return DAWN_VALIDATION_ERROR("Value %i is invalid for {{as_cType(type.name)}}.", static_cast(value)); } {% endfor %} diff --git a/src/dawn/native/BackendConnection.cpp b/src/dawn/native/BackendConnection.cpp index 0c54731d32..8dcd19fd45 100644 --- a/src/dawn/native/BackendConnection.cpp +++ b/src/dawn/native/BackendConnection.cpp @@ -29,7 +29,7 @@ InstanceBase* BackendConnection::GetInstance() const { ResultOrError>> BackendConnection::DiscoverAdapters( const AdapterDiscoveryOptionsBase* options) { - return DAWN_FORMAT_VALIDATION_ERROR("DiscoverAdapters not implemented for this backend."); + return DAWN_VALIDATION_ERROR("DiscoverAdapters not implemented for this backend."); } } // namespace dawn::native diff --git a/src/dawn/native/BindGroupLayout.cpp b/src/dawn/native/BindGroupLayout.cpp index b57cd69e98..ae4f071673 100644 --- a/src/dawn/native/BindGroupLayout.cpp +++ b/src/dawn/native/BindGroupLayout.cpp @@ -48,8 +48,8 @@ MaybeError ValidateStorageTextureViewDimension(wgpu::TextureViewDimension dimens switch (dimension) { case wgpu::TextureViewDimension::Cube: case wgpu::TextureViewDimension::CubeArray: - return DAWN_FORMAT_VALIDATION_ERROR( - "%s texture views cannot be used as storage textures.", dimension); + return DAWN_VALIDATION_ERROR("%s texture views cannot be used as storage textures.", + dimension); case wgpu::TextureViewDimension::e1D: case wgpu::TextureViewDimension::e2D: diff --git a/src/dawn/native/Buffer.cpp b/src/dawn/native/Buffer.cpp index b9b2e3dbb0..3c0f4e1b40 100644 --- a/src/dawn/native/Buffer.cpp +++ b/src/dawn/native/Buffer.cpp @@ -292,10 +292,10 @@ MaybeError BufferBase::ValidateCanUseOnQueueNow() const { switch (mState) { case BufferState::Destroyed: - return DAWN_FORMAT_VALIDATION_ERROR("%s used in submit while destroyed.", this); + return DAWN_VALIDATION_ERROR("%s used in submit while destroyed.", this); case BufferState::Mapped: case BufferState::MappedAtCreation: - return DAWN_FORMAT_VALIDATION_ERROR("%s used in submit while mapped.", this); + return DAWN_VALIDATION_ERROR("%s used in submit while mapped.", this); case BufferState::Unmapped: return {}; } @@ -463,9 +463,9 @@ MaybeError BufferBase::ValidateMapAsync(wgpu::MapMode mode, switch (mState) { case BufferState::Mapped: case BufferState::MappedAtCreation: - return DAWN_FORMAT_VALIDATION_ERROR("%s is already mapped.", this); + return DAWN_VALIDATION_ERROR("%s is already mapped.", this); case BufferState::Destroyed: - return DAWN_FORMAT_VALIDATION_ERROR("%s is destroyed.", this); + return DAWN_VALIDATION_ERROR("%s is destroyed.", this); case BufferState::Unmapped: break; } @@ -540,9 +540,9 @@ MaybeError BufferBase::ValidateUnmap() const { // even if it did not have a mappable usage. return {}; case BufferState::Unmapped: - return DAWN_FORMAT_VALIDATION_ERROR("%s is unmapped.", this); + return DAWN_VALIDATION_ERROR("%s is unmapped.", this); case BufferState::Destroyed: - return DAWN_FORMAT_VALIDATION_ERROR("%s is destroyed.", this); + return DAWN_VALIDATION_ERROR("%s is destroyed.", this); } UNREACHABLE(); } diff --git a/src/dawn/native/CommandBufferStateTracker.cpp b/src/dawn/native/CommandBufferStateTracker.cpp index 3a213fe48b..ebf00ad65c 100644 --- a/src/dawn/native/CommandBufferStateTracker.cpp +++ b/src/dawn/native/CommandBufferStateTracker.cpp @@ -297,7 +297,7 @@ MaybeError CommandBufferStateTracker::CheckMissingAspects(ValidationAspects aspe // because to have invalid aspects one of the above conditions must have failed earlier. // If this is reached, make sure lazy aspects and the error checks above are consistent. UNREACHABLE(); - return DAWN_FORMAT_VALIDATION_ERROR("Index buffer is invalid."); + return DAWN_VALIDATION_ERROR("Index buffer is invalid."); } // TODO(dawn:563): Indicate which slots were not set. @@ -355,7 +355,7 @@ MaybeError CommandBufferStateTracker::CheckMissingAspects(ValidationAspects aspe // because to have invalid aspects one of the above conditions must have failed earlier. // If this is reached, make sure lazy aspects and the error checks above are consistent. UNREACHABLE(); - return DAWN_FORMAT_VALIDATION_ERROR("Bind groups are invalid."); + return DAWN_VALIDATION_ERROR("Bind groups are invalid."); } UNREACHABLE(); diff --git a/src/dawn/native/CommandEncoder.cpp b/src/dawn/native/CommandEncoder.cpp index 9bb8c0dd86..1ac551a0a4 100644 --- a/src/dawn/native/CommandEncoder.cpp +++ b/src/dawn/native/CommandEncoder.cpp @@ -88,7 +88,7 @@ MaybeError ValidateTextureDepthStencilToBufferCopyRestrictions(const ImageCopyTe switch (src.texture->GetFormat().format) { case wgpu::TextureFormat::Depth24Plus: case wgpu::TextureFormat::Depth24PlusStencil8: - return DAWN_FORMAT_VALIDATION_ERROR( + return DAWN_VALIDATION_ERROR( "The depth aspect of %s format %s cannot be selected in a texture to " "buffer copy.", src.texture, src.texture->GetFormat().format); @@ -734,7 +734,7 @@ CommandEncoder::CommandEncoder(DeviceBase* device, ObjectBase::ErrorTag tag) : ApiObjectBase(device, tag), mEncodingContext(device, this), mUsageValidationMode(UsageValidationMode::Default) { - mEncodingContext.HandleError(DAWN_FORMAT_VALIDATION_ERROR("%s is invalid.", this)); + mEncodingContext.HandleError(DAWN_VALIDATION_ERROR("%s is invalid.", this)); } ObjectType CommandEncoder::GetType() const { @@ -1300,7 +1300,7 @@ void CommandEncoder::APIClearBuffer(BufferBase* buffer, uint64_t offset, uint64_ void CommandEncoder::APIInjectValidationError(const char* message) { if (mEncodingContext.CheckCurrentEncoder(this)) { - mEncodingContext.HandleError(DAWN_VALIDATION_ERROR(message)); + mEncodingContext.HandleError(DAWN_MAKE_ERROR(InternalErrorType::Validation, message)); } } diff --git a/src/dawn/native/CommandValidation.cpp b/src/dawn/native/CommandValidation.cpp index d0bdb0c3b0..a3929f31f4 100644 --- a/src/dawn/native/CommandValidation.cpp +++ b/src/dawn/native/CommandValidation.cpp @@ -55,7 +55,7 @@ MaybeError ValidateSyncScopeResourceUsage(const SyncScopeResourceUsage& scope) { bool readOnly = IsSubset(usage, kReadOnlyTextureUsages); bool singleUse = wgpu::HasZeroOrOneBits(usage); if (!readOnly && !singleUse && !error.IsError()) { - error = DAWN_FORMAT_VALIDATION_ERROR( + error = DAWN_VALIDATION_ERROR( "%s usage (%s) includes writable usage and another usage in the same " "synchronization scope.", scope.textures[i], usage); @@ -420,7 +420,7 @@ MaybeError ValidateTextureToTextureCopyCommonRestrictions(const ImageCopyTexture switch (src.texture->GetDimension()) { case wgpu::TextureDimension::e1D: ASSERT(src.mipLevel == 0 && src.origin.z == 0 && dst.origin.z == 0); - return DAWN_FORMAT_VALIDATION_ERROR("Copy is from %s to itself.", src.texture); + return DAWN_VALIDATION_ERROR("Copy is from %s to itself.", src.texture); case wgpu::TextureDimension::e2D: DAWN_INVALID_IF( diff --git a/src/dawn/native/ComputePipeline.cpp b/src/dawn/native/ComputePipeline.cpp index b0b574d043..eca8467798 100644 --- a/src/dawn/native/ComputePipeline.cpp +++ b/src/dawn/native/ComputePipeline.cpp @@ -23,7 +23,7 @@ namespace dawn::native { MaybeError ValidateComputePipelineDescriptor(DeviceBase* device, const ComputePipelineDescriptor* descriptor) { if (descriptor->nextInChain != nullptr) { - return DAWN_FORMAT_VALIDATION_ERROR("nextInChain must be nullptr."); + return DAWN_VALIDATION_ERROR("nextInChain must be nullptr."); } if (descriptor->layout != nullptr) { diff --git a/src/dawn/native/CopyTextureForBrowserHelper.cpp b/src/dawn/native/CopyTextureForBrowserHelper.cpp index f8cece17da..d7890ed7d8 100644 --- a/src/dawn/native/CopyTextureForBrowserHelper.cpp +++ b/src/dawn/native/CopyTextureForBrowserHelper.cpp @@ -242,8 +242,7 @@ MaybeError ValidateCopyTextureFormatConversion(const wgpu::TextureFormat srcForm case wgpu::TextureFormat::RGBA16Float: break; default: - return DAWN_FORMAT_VALIDATION_ERROR("Source texture format (%s) is not supported.", - srcFormat); + return DAWN_VALIDATION_ERROR("Source texture format (%s) is not supported.", srcFormat); } switch (dstFormat) { @@ -262,8 +261,8 @@ MaybeError ValidateCopyTextureFormatConversion(const wgpu::TextureFormat srcForm case wgpu::TextureFormat::RGBA32Float: break; default: - return DAWN_FORMAT_VALIDATION_ERROR("Destination texture format (%s) is not supported.", - dstFormat); + return DAWN_VALIDATION_ERROR("Destination texture format (%s) is not supported.", + dstFormat); } return {}; diff --git a/src/dawn/native/EncodingContext.cpp b/src/dawn/native/EncodingContext.cpp index d22292716e..9b7f36703d 100644 --- a/src/dawn/native/EncodingContext.cpp +++ b/src/dawn/native/EncodingContext.cpp @@ -44,7 +44,7 @@ void EncodingContext::Destroy() { // If we weren't already finished, then we want to handle an error here so that any calls // to Finish after Destroy will return a meaningful error. if (!IsFinished()) { - HandleError(DAWN_FORMAT_VALIDATION_ERROR("Destroyed encoder cannot be finished.")); + HandleError(DAWN_VALIDATION_ERROR("Destroyed encoder cannot be finished.")); } mDestroyed = true; mCurrentEncoder = nullptr; @@ -151,8 +151,8 @@ void EncodingContext::EnsurePassExited(const ApiObjectBase* passEncoder) { if (mCurrentEncoder != mTopLevelEncoder && mCurrentEncoder == passEncoder) { // The current pass encoder is being deleted. Implicitly end the pass with an error. mCurrentEncoder = mTopLevelEncoder; - HandleError(DAWN_FORMAT_VALIDATION_ERROR( - "Command buffer recording ended before %s was ended.", passEncoder)); + HandleError(DAWN_VALIDATION_ERROR("Command buffer recording ended before %s was ended.", + passEncoder)); } } diff --git a/src/dawn/native/EncodingContext.h b/src/dawn/native/EncodingContext.h index 020132e527..3614a09823 100644 --- a/src/dawn/native/EncodingContext.h +++ b/src/dawn/native/EncodingContext.h @@ -80,18 +80,17 @@ class EncodingContext { inline bool CheckCurrentEncoder(const ApiObjectBase* encoder) { if (mDestroyed) { - HandleError( - DAWN_FORMAT_VALIDATION_ERROR("Recording in a destroyed %s.", mCurrentEncoder)); + HandleError(DAWN_VALIDATION_ERROR("Recording in a destroyed %s.", mCurrentEncoder)); return false; } if (DAWN_UNLIKELY(encoder != mCurrentEncoder)) { if (mCurrentEncoder != mTopLevelEncoder) { // The top level encoder was used when a pass encoder was current. - HandleError(DAWN_FORMAT_VALIDATION_ERROR( - "Command cannot be recorded while %s is active.", mCurrentEncoder)); + HandleError(DAWN_VALIDATION_ERROR("Command cannot be recorded while %s is active.", + mCurrentEncoder)); } else { - HandleError(DAWN_FORMAT_VALIDATION_ERROR( - "Recording in an error or already ended %s.", encoder)); + HandleError( + DAWN_VALIDATION_ERROR("Recording in an error or already ended %s.", encoder)); } return false; } diff --git a/src/dawn/native/Error.h b/src/dawn/native/Error.h index 0b71644f27..1f12864681 100644 --- a/src/dawn/native/Error.h +++ b/src/dawn/native/Error.h @@ -43,7 +43,7 @@ using ResultOrError = Result; // return DAWN_MAKE_ERROR(errorType, "My error message"); // // but shorthand version for specific error types are preferred: -// return DAWN_VALIDATION_ERROR("My error message"); +// return DAWN_VALIDATION_ERROR("My error message with details %s", details); // // There are different types of errors that should be used for different purpose: // @@ -71,11 +71,7 @@ using ResultOrError = Result; #define DAWN_MAKE_ERROR(TYPE, MESSAGE) \ ::dawn::native::ErrorData::Create(TYPE, MESSAGE, __FILE__, __func__, __LINE__) -#define DAWN_VALIDATION_ERROR(MESSAGE) DAWN_MAKE_ERROR(InternalErrorType::Validation, MESSAGE) - -// TODO(dawn:563): Rename to DAWN_VALIDATION_ERROR once all message format strings have been -// converted to constexpr. -#define DAWN_FORMAT_VALIDATION_ERROR(...) \ +#define DAWN_VALIDATION_ERROR(...) \ DAWN_MAKE_ERROR(InternalErrorType::Validation, absl::StrFormat(__VA_ARGS__)) #define DAWN_INVALID_IF(EXPR, ...) \ diff --git a/src/dawn/native/ExternalTexture.cpp b/src/dawn/native/ExternalTexture.cpp index a23faa7bdc..42a511b15b 100644 --- a/src/dawn/native/ExternalTexture.cpp +++ b/src/dawn/native/ExternalTexture.cpp @@ -91,7 +91,7 @@ MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device, DAWN_TRY(ValidateExternalTexturePlane(descriptor->plane0)); break; default: - return DAWN_FORMAT_VALIDATION_ERROR( + return DAWN_VALIDATION_ERROR( "The external texture plane (%s) format (%s) is not a supported format " "(%s, %s, %s).", descriptor->plane0, plane0Format, wgpu::TextureFormat::RGBA8Unorm, diff --git a/src/dawn/native/Instance.cpp b/src/dawn/native/Instance.cpp index 78afd8ed8e..4e734ca4f3 100644 --- a/src/dawn/native/Instance.cpp +++ b/src/dawn/native/Instance.cpp @@ -385,7 +385,7 @@ MaybeError InstanceBase::DiscoverAdaptersInternal(const AdapterDiscoveryOptionsB DAWN_TRY(ValidateBackendType(backendType)); if (!GetEnabledBackends()[backendType]) { - return DAWN_FORMAT_VALIDATION_ERROR("%s not supported.", backendType); + return DAWN_VALIDATION_ERROR("%s not supported.", backendType); } EnsureBackendConnection(backendType); diff --git a/src/dawn/native/Pipeline.cpp b/src/dawn/native/Pipeline.cpp index 513bd2ac4c..50a4b9c105 100644 --- a/src/dawn/native/Pipeline.cpp +++ b/src/dawn/native/Pipeline.cpp @@ -42,12 +42,12 @@ MaybeError ValidateProgrammableStage(DeviceBase* device, const EntryPointMetadata& metadata = module->GetEntryPoint(entryPoint); if (!metadata.infringedLimitErrors.empty()) { - std::ostringstream out; - out << "Entry point \"" << entryPoint << "\" infringes limits:\n"; + std::ostringstream limitList; for (const std::string& limit : metadata.infringedLimitErrors) { - out << " - " << limit << "\n"; + limitList << " - " << limit << "\n"; } - return DAWN_VALIDATION_ERROR(out.str()); + return DAWN_VALIDATION_ERROR("Entry point \"%s\" infringes limits:\n%s", entryPoint, + limitList.str()); } DAWN_INVALID_IF(metadata.stage != stage, @@ -81,7 +81,7 @@ MaybeError ValidateProgrammableStage(DeviceBase* device, stageInitializedConstantIdentifiers.insert(constants[i].key); } else { // There are duplicate initializations - return DAWN_FORMAT_VALIDATION_ERROR( + return DAWN_VALIDATION_ERROR( "Pipeline overridable constants \"%s\" is set more than once in %s", constants[i].key, module); } @@ -104,7 +104,7 @@ MaybeError ValidateProgrammableStage(DeviceBase* device, uninitializedConstantsArray.append(identifier); } - return DAWN_FORMAT_VALIDATION_ERROR( + return DAWN_VALIDATION_ERROR( "There are uninitialized pipeline overridable constants in shader module %s, their " "identifiers:[%s]", module, uninitializedConstantsArray); diff --git a/src/dawn/native/ProgrammableEncoder.cpp b/src/dawn/native/ProgrammableEncoder.cpp index 29a0f03c54..ce3140b289 100644 --- a/src/dawn/native/ProgrammableEncoder.cpp +++ b/src/dawn/native/ProgrammableEncoder.cpp @@ -170,7 +170,7 @@ MaybeError ProgrammableEncoder::ValidateSetBindGroup(BindGroupIndex index, static_cast(i), dynamicOffsets[i], bufferBinding.buffer, bufferBinding.buffer->GetSize(), bufferBinding.offset, bufferBinding.size); - return DAWN_FORMAT_VALIDATION_ERROR( + return DAWN_VALIDATION_ERROR( "Dynamic Offset[%u] (%u) is out of bounds of " "%s with a size of %u and a bound range of (offset: %u, size: %u).", static_cast(i), dynamicOffsets[i], bufferBinding.buffer, diff --git a/src/dawn/native/Sampler.cpp b/src/dawn/native/Sampler.cpp index 7e436fc1d7..5d8715795d 100644 --- a/src/dawn/native/Sampler.cpp +++ b/src/dawn/native/Sampler.cpp @@ -46,8 +46,8 @@ MaybeError ValidateSamplerDescriptor(DeviceBase*, const SamplerDescriptor* descr descriptor->magFilter, descriptor->minFilter, descriptor->mipmapFilter, wgpu::FilterMode::Linear, descriptor->maxAnisotropy); } else if (descriptor->maxAnisotropy == 0u) { - return DAWN_FORMAT_VALIDATION_ERROR("Max anisotropy (%f) is less than 1.", - descriptor->maxAnisotropy); + return DAWN_VALIDATION_ERROR("Max anisotropy (%f) is less than 1.", + descriptor->maxAnisotropy); } DAWN_TRY(ValidateFilterMode(descriptor->minFilter)); diff --git a/src/dawn/native/ShaderModule.cpp b/src/dawn/native/ShaderModule.cpp index c9871e8c77..6769f7e4ff 100644 --- a/src/dawn/native/ShaderModule.cpp +++ b/src/dawn/native/ShaderModule.cpp @@ -299,13 +299,12 @@ ResultOrError ParseWGSL(const tint::Source::File* file, outMessages->AddMessages(program.Diagnostics()); } if (!program.IsValid()) { - return DAWN_FORMAT_VALIDATION_ERROR("Tint WGSL reader failure: %s\n", - program.Diagnostics().str()); + return DAWN_VALIDATION_ERROR("Tint WGSL reader failure: %s\n", program.Diagnostics().str()); } return std::move(program); #else - return DAWN_FORMAT_VALIDATION_ERROR("TINT_BUILD_WGSL_READER is not defined."); + return DAWN_VALIDATION_ERROR("TINT_BUILD_WGSL_READER is not defined."); #endif } @@ -317,13 +316,13 @@ ResultOrError ParseSPIRV(const std::vector& spirv, outMessages->AddMessages(program.Diagnostics()); } if (!program.IsValid()) { - return DAWN_FORMAT_VALIDATION_ERROR("Tint SPIR-V reader failure:\nParser: %s\n", - program.Diagnostics().str()); + return DAWN_VALIDATION_ERROR("Tint SPIR-V reader failure:\nParser: %s\n", + program.Diagnostics().str()); } return std::move(program); #else - return DAWN_FORMAT_VALIDATION_ERROR("TINT_BUILD_SPV_READER is not defined."); + return DAWN_VALIDATION_ERROR("TINT_BUILD_SPV_READER is not defined."); #endif } diff --git a/src/dawn/native/Surface.cpp b/src/dawn/native/Surface.cpp index 6822dbbe48..39b0cbb4b3 100644 --- a/src/dawn/native/Surface.cpp +++ b/src/dawn/native/Surface.cpp @@ -162,7 +162,7 @@ MaybeError ValidateSurfaceDescriptor(const InstanceBase* instance, } #endif // defined(DAWN_USE_X11) - return DAWN_FORMAT_VALIDATION_ERROR("Unsupported sType (%s)", descriptor->nextInChain->sType); + return DAWN_VALIDATION_ERROR("Unsupported sType (%s)", descriptor->nextInChain->sType); } // static diff --git a/src/dawn/native/SwapChain.cpp b/src/dawn/native/SwapChain.cpp index 1908929592..60cd62b532 100644 --- a/src/dawn/native/SwapChain.cpp +++ b/src/dawn/native/SwapChain.cpp @@ -35,16 +35,16 @@ class ErrorSwapChain final : public SwapChainBase { wgpu::TextureUsage allowedUsage, uint32_t width, uint32_t height) override { - GetDevice()->ConsumedError(DAWN_FORMAT_VALIDATION_ERROR("%s is an error swapchain.", this)); + GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("%s is an error swapchain.", this)); } TextureViewBase* APIGetCurrentTextureView() override { - GetDevice()->ConsumedError(DAWN_FORMAT_VALIDATION_ERROR("%s is an error swapchain.", this)); + GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("%s is an error swapchain.", this)); return TextureViewBase::MakeError(GetDevice()); } void APIPresent() override { - GetDevice()->ConsumedError(DAWN_FORMAT_VALIDATION_ERROR("%s is an error swapchain.", this)); + GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("%s is an error swapchain.", this)); } }; @@ -301,7 +301,7 @@ void NewSwapChainBase::APIConfigure(wgpu::TextureFormat format, uint32_t width, uint32_t height) { GetDevice()->ConsumedError( - DAWN_FORMAT_VALIDATION_ERROR("Configure is invalid for surface-based swapchains.")); + DAWN_VALIDATION_ERROR("Configure is invalid for surface-based swapchains.")); } TextureViewBase* NewSwapChainBase::APIGetCurrentTextureView() { diff --git a/src/dawn/native/Texture.cpp b/src/dawn/native/Texture.cpp index d170bff2b6..7efbbf802a 100644 --- a/src/dawn/native/Texture.cpp +++ b/src/dawn/native/Texture.cpp @@ -54,7 +54,7 @@ MaybeError ValidateCanViewTextureAs(const DeviceBase* device, if (viewFormat.format == aspectFormat) { return {}; } else { - return DAWN_FORMAT_VALIDATION_ERROR( + return DAWN_VALIDATION_ERROR( "The view format (%s) is not compatible with %s of %s (%s).", viewFormat.format, aspect, format.format, aspectFormat); } @@ -78,7 +78,7 @@ MaybeError ValidateCanViewTextureAs(const DeviceBase* device, // The view format isn't compatible with the format at all. Return an error // that indicates this, in addition to reporting that it's missing from the // list. - return DAWN_FORMAT_VALIDATION_ERROR( + return DAWN_VALIDATION_ERROR( "The texture view format (%s) is not compatible with the " "texture format (%s)." "The formats must be compatible, and the view format " @@ -86,7 +86,7 @@ MaybeError ValidateCanViewTextureAs(const DeviceBase* device, viewFormat.format, format.format); } else { // The view format is compatible, but not in the list. - return DAWN_FORMAT_VALIDATION_ERROR( + return DAWN_VALIDATION_ERROR( "%s was not created with the texture view format (%s) " "in the list of compatible view formats.", texture, viewFormat.format); diff --git a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp index ce83dbefee..9e1b9e9a11 100644 --- a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp +++ b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp @@ -282,8 +282,8 @@ ResultOrError> CompileShaderDXC(const D3DBytecodeCompilationReq ComPtr errors; DAWN_TRY(CheckHRESULT(result->GetErrorBuffer(&errors), "DXC get error buffer")); - return DAWN_FORMAT_VALIDATION_ERROR("DXC compile failed with: %s", - static_cast(errors->GetBufferPointer())); + return DAWN_VALIDATION_ERROR("DXC compile failed with: %s", + static_cast(errors->GetBufferPointer())); } ComPtr compiledShader; @@ -447,15 +447,14 @@ ResultOrError TranslateToHLSL( *remappedEntryPointName = r.entryPointName; } } else { - return DAWN_FORMAT_VALIDATION_ERROR("Transform output missing renamer data."); + return DAWN_VALIDATION_ERROR("Transform output missing renamer data."); } if (r.stage == SingleShaderStage::Vertex) { if (auto* data = transformOutputs.Get()) { *usesVertexOrInstanceIndex = data->has_vertex_or_instance_index; } else { - return DAWN_FORMAT_VALIDATION_ERROR( - "Transform output missing first index offset data."); + return DAWN_VALIDATION_ERROR("Transform output missing first index offset data."); } } diff --git a/src/dawn/native/d3d12/TextureD3D12.cpp b/src/dawn/native/d3d12/TextureD3D12.cpp index 41bc0a099c..1d0e6d4cac 100644 --- a/src/dawn/native/d3d12/TextureD3D12.cpp +++ b/src/dawn/native/d3d12/TextureD3D12.cpp @@ -490,7 +490,7 @@ MaybeError ValidateD3D12VideoTextureCanBeShared(Device* device, DXGI_FORMAT text break; } - return DAWN_FORMAT_VALIDATION_ERROR("DXGI format does not support cross-API sharing."); + return DAWN_VALIDATION_ERROR("DXGI format does not support cross-API sharing."); } // static diff --git a/src/dawn/native/metal/ShaderModuleMTL.mm b/src/dawn/native/metal/ShaderModuleMTL.mm index 5a72f30253..5d4196b8af 100644 --- a/src/dawn/native/metal/ShaderModuleMTL.mm +++ b/src/dawn/native/metal/ShaderModuleMTL.mm @@ -227,7 +227,7 @@ ResultOrError> TranslateToMSL(DeviceBase* device, remappedEntryPointName = r.entryPointName; } } else { - return DAWN_FORMAT_VALIDATION_ERROR("Transform output missing renamer data."); + return DAWN_VALIDATION_ERROR("Transform output missing renamer data."); } tint::writer::msl::Options options; @@ -335,8 +335,8 @@ MaybeError ShaderModule::CreateFunction(const char* entryPointName, error:&error]); if (error != nullptr) { if (error.code != MTLLibraryErrorCompileWarning) { - return DAWN_FORMAT_VALIDATION_ERROR( - "Function compile error: %s", [error.localizedDescription UTF8String]); + return DAWN_VALIDATION_ERROR("Function compile error: %s", + [error.localizedDescription UTF8String]); } } ASSERT(out->function != nil); diff --git a/src/dawn/native/metal/TextureMTL.mm b/src/dawn/native/metal/TextureMTL.mm index a508b656bf..98d4f3150c 100644 --- a/src/dawn/native/metal/TextureMTL.mm +++ b/src/dawn/native/metal/TextureMTL.mm @@ -197,7 +197,7 @@ ResultOrError GetFormatEquivalentToIOSurfaceFormat(uint32_t case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange: return wgpu::TextureFormat::R8BG8Biplanar420Unorm; default: - return DAWN_FORMAT_VALIDATION_ERROR("Unsupported IOSurface format (%x).", format); + return DAWN_VALIDATION_ERROR("Unsupported IOSurface format (%x).", format); } } diff --git a/src/dawn/native/opengl/DeviceGL.cpp b/src/dawn/native/opengl/DeviceGL.cpp index 35ff4efd73..4246d5ff56 100644 --- a/src/dawn/native/opengl/DeviceGL.cpp +++ b/src/dawn/native/opengl/DeviceGL.cpp @@ -299,7 +299,7 @@ ResultOrError> Device::CreateSwapChainImpl( Surface* surface, NewSwapChainBase* previousSwapChain, const SwapChainDescriptor* descriptor) { - return DAWN_FORMAT_VALIDATION_ERROR("New swapchains not implemented."); + return DAWN_VALIDATION_ERROR("New swapchains not implemented."); } ResultOrError> Device::CreateTextureImpl(const TextureDescriptor* descriptor) { return AcquireRef(new Texture(this, descriptor)); @@ -364,7 +364,7 @@ TextureBase* Device::CreateTextureWrappingEGLImage(const ExternalImageDescriptor if (textureDescriptor->size.width != static_cast(width) || textureDescriptor->size.height != static_cast(height) || textureDescriptor->size.depthOrArrayLayers != 1) { - ConsumedError(DAWN_FORMAT_VALIDATION_ERROR( + ConsumedError(DAWN_VALIDATION_ERROR( "EGLImage size (width: %u, height: %u, depth: 1) doesn't match descriptor size %s.", width, height, &textureDescriptor->size)); gl.DeleteTextures(1, &tex); diff --git a/src/dawn/native/opengl/PipelineGL.cpp b/src/dawn/native/opengl/PipelineGL.cpp index 701102c6bc..2226be9d69 100644 --- a/src/dawn/native/opengl/PipelineGL.cpp +++ b/src/dawn/native/opengl/PipelineGL.cpp @@ -82,7 +82,7 @@ MaybeError PipelineGL::InitializeBase(const OpenGLFunctions& gl, if (infoLogLength > 1) { std::vector buffer(infoLogLength); gl.GetProgramInfoLog(mProgram, infoLogLength, nullptr, &buffer[0]); - return DAWN_FORMAT_VALIDATION_ERROR("Program link failed:\n%s", buffer.data()); + return DAWN_VALIDATION_ERROR("Program link failed:\n%s", buffer.data()); } } diff --git a/src/dawn/native/opengl/ShaderModuleGL.cpp b/src/dawn/native/opengl/ShaderModuleGL.cpp index 6c427eeb03..172d4015d9 100644 --- a/src/dawn/native/opengl/ShaderModuleGL.cpp +++ b/src/dawn/native/opengl/ShaderModuleGL.cpp @@ -264,8 +264,8 @@ ResultOrError ShaderModule::CompileShader(const OpenGLFunctions& gl, std::vector buffer(infoLogLength); gl.GetShaderInfoLog(shader, infoLogLength, nullptr, &buffer[0]); gl.DeleteShader(shader); - return DAWN_FORMAT_VALIDATION_ERROR("%s\nProgram compilation failed:\n%s", source, - buffer.data()); + return DAWN_VALIDATION_ERROR("%s\nProgram compilation failed:\n%s", source, + buffer.data()); } } diff --git a/src/dawn/native/vulkan/SwapChainVk.cpp b/src/dawn/native/vulkan/SwapChainVk.cpp index 0a17bafb94..c452488ae7 100644 --- a/src/dawn/native/vulkan/SwapChainVk.cpp +++ b/src/dawn/native/vulkan/SwapChainVk.cpp @@ -225,8 +225,7 @@ ResultOrError CreateVulkanSurface(Adapter* adapter, Surface* surfa break; } - return DAWN_FORMAT_VALIDATION_ERROR("Unsupported surface type (%s) for Vulkan.", - surface->GetType()); + return DAWN_VALIDATION_ERROR("Unsupported surface type (%s) for Vulkan.", surface->GetType()); } VkPresentModeKHR ToVulkanPresentMode(wgpu::PresentMode mode) { diff --git a/src/dawn/native/vulkan/external_memory/MemoryServiceDmaBuf.cpp b/src/dawn/native/vulkan/external_memory/MemoryServiceDmaBuf.cpp index 0729d4713c..2f6445aa7b 100644 --- a/src/dawn/native/vulkan/external_memory/MemoryServiceDmaBuf.cpp +++ b/src/dawn/native/vulkan/external_memory/MemoryServiceDmaBuf.cpp @@ -69,7 +69,7 @@ ResultOrError GetModifierPlaneCount(const VulkanFunctions& fn, if (GetFormatModifierProps(fn, physicalDevice, format, modifier, &props)) { return static_cast(props.drmFormatModifierPlaneCount); } - return DAWN_FORMAT_VALIDATION_ERROR("DRM format modifier not supported."); + return DAWN_VALIDATION_ERROR("DRM format modifier not supported."); } bool IsMultiPlanarVkFormat(VkFormat format) { diff --git a/src/dawn/tests/unittests/ErrorTests.cpp b/src/dawn/tests/unittests/ErrorTests.cpp index 53c06cfebf..524a94d44c 100644 --- a/src/dawn/tests/unittests/ErrorTests.cpp +++ b/src/dawn/tests/unittests/ErrorTests.cpp @@ -22,7 +22,7 @@ namespace dawn::native { namespace { int placeholderSuccess = 0xbeef; -const char* placeholderErrorMessage = "I am an error message :3"; +constexpr const char* placeholderErrorMessage = "I am an error message :3"; // Check returning a success MaybeError with {}; TEST(ErrorTests, Error_Success) {