From e89f88b600b0c64cb95f552fb91fbbf4f2d9b9cf Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Wed, 3 May 2023 00:43:42 +0000 Subject: [PATCH] Add error context on Queue::API* methods Fixed: dawn:1747 Change-Id: Icc8f4dbc6fcf69c117f880b5ef9d54cf256f7062 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131080 Reviewed-by: Brandon Jones Kokoro: Kokoro Commit-Queue: Austin Eng --- src/dawn/native/Queue.cpp | 13 ++++++++++--- src/dawn/native/webgpu_absl_format.h | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/dawn/native/Queue.cpp b/src/dawn/native/Queue.cpp index 18039d05fc..549989975f 100644 --- a/src/dawn/native/Queue.cpp +++ b/src/dawn/native/Queue.cpp @@ -20,6 +20,7 @@ #include #include "dawn/common/Constants.h" +#include "dawn/common/ityp_span.h" #include "dawn/native/Buffer.h" #include "dawn/native/CommandBuffer.h" #include "dawn/native/CommandEncoder.h" @@ -286,7 +287,9 @@ void QueueBase::APIWriteBuffer(BufferBase* buffer, uint64_t bufferOffset, const void* data, size_t size) { - DAWN_UNUSED(GetDevice()->ConsumedError(WriteBuffer(buffer, bufferOffset, data, size))); + DAWN_UNUSED(GetDevice()->ConsumedError(WriteBuffer(buffer, bufferOffset, data, size), + "calling %s.WriteBuffer(%s, %s, (%d bytes))", this, + buffer, bufferOffset, size)); } MaybeError QueueBase::WriteBuffer(BufferBase* buffer, @@ -328,7 +331,9 @@ void QueueBase::APIWriteTexture(const ImageCopyTexture* destination, const TextureDataLayout* dataLayout, const Extent3D* writeSize) { DAWN_UNUSED(GetDevice()->ConsumedError( - WriteTextureInternal(destination, data, dataSize, *dataLayout, writeSize))); + WriteTextureInternal(destination, data, dataSize, *dataLayout, writeSize), + "calling %s.WriteTexture(%s, (%s bytes), %s, %s)", destination, dataSize, dataLayout, + writeSize)); } MaybeError QueueBase::WriteTextureInternal(const ImageCopyTexture* destination, @@ -547,7 +552,9 @@ void QueueBase::SubmitInternal(uint32_t commandCount, CommandBufferBase* const* TRACE_EVENT0(device->GetPlatform(), General, "Queue::Submit"); if (device->IsValidationEnabled()) { - if (device->ConsumedError(ValidateSubmit(commandCount, commands))) { + if (device->ConsumedError( + ValidateSubmit(commandCount, commands), "calling %s.Submit(%s)", this, + ityp::span(commands, commandCount))) { return; } } diff --git a/src/dawn/native/webgpu_absl_format.h b/src/dawn/native/webgpu_absl_format.h index fa1d566bce..1b3bdcb9c4 100644 --- a/src/dawn/native/webgpu_absl_format.h +++ b/src/dawn/native/webgpu_absl_format.h @@ -19,6 +19,11 @@ #include "dawn/native/dawn_platform.h" #include "dawn/native/webgpu_absl_format_autogen.h" +namespace ityp { +template +class span; +} + namespace dawn::native { // @@ -135,6 +140,25 @@ absl::FormatConvertResult AbslFormatConv const absl::FormatConversionSpec& spec, absl::FormatSink* s); +template +absl::FormatConvertResult AbslFormatConvert( + const ityp::span& values, + const absl::FormatConversionSpec& spec, + absl::FormatSink* s) { + s->Append("["); + bool first = true; + for (const auto& v : values) { + if (!first) { + s->Append(absl::StrFormat(", %s", v)); + } else { + s->Append(absl::StrFormat("%s", v)); + } + first = false; + } + s->Append("]"); + return {true}; +} + } // namespace dawn::native #endif // SRC_DAWN_NATIVE_WEBGPU_ABSL_FORMAT_H_