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 <toji@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2023-05-03 00:43:42 +00:00 committed by Dawn LUCI CQ
parent 80cf5e51cc
commit e89f88b600
2 changed files with 34 additions and 3 deletions

View File

@ -20,6 +20,7 @@
#include <vector>
#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<uint32_t, CommandBufferBase* const>(commands, commandCount))) {
return;
}
}

View File

@ -19,6 +19,11 @@
#include "dawn/native/dawn_platform.h"
#include "dawn/native/webgpu_absl_format_autogen.h"
namespace ityp {
template <typename Index, typename Value>
class span;
}
namespace dawn::native {
//
@ -135,6 +140,25 @@ absl::FormatConvertResult<absl::FormatConversionCharSet::kString> AbslFormatConv
const absl::FormatConversionSpec& spec,
absl::FormatSink* s);
template <typename I, typename T>
absl::FormatConvertResult<absl::FormatConversionCharSet::kString> AbslFormatConvert(
const ityp::span<I, T>& 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_