Retain descriptor labels for error objects

Since these objects are more likely to be included in error messages
it's important that we keep the labels that the developer has given
them.

Bug: dawn:1771
Change-Id: I78f4ccc23ce40d8eeceed8ca7dd563dff949b4fb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128420
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
This commit is contained in:
Brandon Jones 2023-04-20 23:35:14 +00:00 committed by Dawn LUCI CQ
parent 8cc6205bf7
commit 6cb055b6aa
43 changed files with 171 additions and 129 deletions

View File

@ -475,12 +475,12 @@ void BindGroupBase::DeleteThis() {
ApiObjectBase::DeleteThis();
}
BindGroupBase::BindGroupBase(DeviceBase* device, ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag), mBindingData() {}
BindGroupBase::BindGroupBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label)
: ApiObjectBase(device, tag, label), mBindingData() {}
// static
BindGroupBase* BindGroupBase::MakeError(DeviceBase* device) {
return new BindGroupBase(device, ObjectBase::kError);
BindGroupBase* BindGroupBase::MakeError(DeviceBase* device, const char* label) {
return new BindGroupBase(device, ObjectBase::kError, label);
}
ObjectType BindGroupBase::GetType() const {

View File

@ -44,7 +44,7 @@ struct BufferBinding {
class BindGroupBase : public ApiObjectBase {
public:
static BindGroupBase* MakeError(DeviceBase* device);
static BindGroupBase* MakeError(DeviceBase* device, const char* label);
ObjectType GetType() const override;
@ -81,7 +81,7 @@ class BindGroupBase : public ApiObjectBase {
~BindGroupBase() override;
private:
BindGroupBase(DeviceBase* device, ObjectBase::ErrorTag tag);
BindGroupBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
void DeleteThis() override;
Ref<BindGroupLayoutBase> mLayout;

View File

@ -491,8 +491,10 @@ BindGroupLayoutBase::BindGroupLayoutBase(DeviceBase* device,
GetObjectTrackingList()->Track(this);
}
BindGroupLayoutBase::BindGroupLayoutBase(DeviceBase* device, ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag) {}
BindGroupLayoutBase::BindGroupLayoutBase(DeviceBase* device,
ObjectBase::ErrorTag tag,
const char* label)
: ApiObjectBase(device, tag, label) {}
BindGroupLayoutBase::~BindGroupLayoutBase() = default;
@ -504,8 +506,8 @@ void BindGroupLayoutBase::DestroyImpl() {
}
// static
BindGroupLayoutBase* BindGroupLayoutBase::MakeError(DeviceBase* device) {
return new BindGroupLayoutBase(device, ObjectBase::kError);
BindGroupLayoutBase* BindGroupLayoutBase::MakeError(DeviceBase* device, const char* label) {
return new BindGroupLayoutBase(device, ObjectBase::kError, label);
}
ObjectType BindGroupLayoutBase::GetType() const {

View File

@ -61,7 +61,7 @@ class BindGroupLayoutBase : public ApiObjectBase, public CachedObject {
PipelineCompatibilityToken pipelineCompatibilityToken);
~BindGroupLayoutBase() override;
static BindGroupLayoutBase* MakeError(DeviceBase* device);
static BindGroupLayoutBase* MakeError(DeviceBase* device, const char* label = nullptr);
ObjectType GetType() const override;
@ -147,7 +147,7 @@ class BindGroupLayoutBase : public ApiObjectBase, public CachedObject {
}
private:
BindGroupLayoutBase(DeviceBase* device, ObjectBase::ErrorTag tag);
BindGroupLayoutBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
BindingCounts mBindingCounts = {};
ityp::vector<BindingIndex, BindingInfo> mBindingInfo;

View File

@ -177,7 +177,7 @@ BufferBase::BufferBase(DeviceBase* device, const BufferDescriptor* descriptor)
BufferBase::BufferBase(DeviceBase* device,
const BufferDescriptor* descriptor,
ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag),
: ApiObjectBase(device, tag, descriptor->label),
mSize(descriptor->size),
mUsage(descriptor->usage),
mState(BufferState::Unmapped) {

View File

@ -33,12 +33,14 @@ CommandBufferBase::CommandBufferBase(CommandEncoder* encoder,
GetObjectTrackingList()->Track(this);
}
CommandBufferBase::CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag) {}
CommandBufferBase::CommandBufferBase(DeviceBase* device,
ObjectBase::ErrorTag tag,
const char* label)
: ApiObjectBase(device, tag, label) {}
// static
CommandBufferBase* CommandBufferBase::MakeError(DeviceBase* device) {
return new CommandBufferBase(device, ObjectBase::kError);
CommandBufferBase* CommandBufferBase::MakeError(DeviceBase* device, const char* label) {
return new CommandBufferBase(device, ObjectBase::kError, label);
}
ObjectType CommandBufferBase::GetType() const {

View File

@ -34,7 +34,7 @@ class CommandBufferBase : public ApiObjectBase {
public:
CommandBufferBase(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor);
static CommandBufferBase* MakeError(DeviceBase* device);
static CommandBufferBase* MakeError(DeviceBase* device, const char* label);
ObjectType GetType() const override;
@ -50,7 +50,7 @@ class CommandBufferBase : public ApiObjectBase {
CommandIterator mCommands;
private:
CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag);
CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
CommandBufferResourceUsage mResourceUsages;
};

View File

@ -710,8 +710,8 @@ Ref<CommandEncoder> CommandEncoder::Create(DeviceBase* device,
}
// static
CommandEncoder* CommandEncoder::MakeError(DeviceBase* device) {
return new CommandEncoder(device, ObjectBase::kError);
CommandEncoder* CommandEncoder::MakeError(DeviceBase* device, const char* label) {
return new CommandEncoder(device, ObjectBase::kError, label);
}
CommandEncoder::CommandEncoder(DeviceBase* device, const CommandEncoderDescriptor* descriptor)
@ -728,8 +728,8 @@ CommandEncoder::CommandEncoder(DeviceBase* device, const CommandEncoderDescripto
}
}
CommandEncoder::CommandEncoder(DeviceBase* device, ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag),
CommandEncoder::CommandEncoder(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label)
: ApiObjectBase(device, tag, label),
mEncodingContext(device, this),
mUsageValidationMode(UsageValidationMode::Default) {
mEncodingContext.HandleError(DAWN_VALIDATION_ERROR("%s is invalid.", this));
@ -830,7 +830,8 @@ Ref<ComputePassEncoder> CommandEncoder::BeginComputePass(const ComputePassDescri
return passEncoder;
}
return ComputePassEncoder::MakeError(device, this, &mEncodingContext);
return ComputePassEncoder::MakeError(device, this, &mEncodingContext,
descriptor ? descriptor->label : nullptr);
}
RenderPassEncoder* CommandEncoder::APIBeginRenderPass(const RenderPassDescriptor* descriptor) {
@ -1011,14 +1012,16 @@ Ref<RenderPassEncoder> CommandEncoder::BeginRenderPass(const RenderPassDescripto
MaybeError error =
ApplyClearBigIntegerColorValueWithDraw(passEncoder.Get(), descriptor);
if (error.IsError()) {
return RenderPassEncoder::MakeError(device, this, &mEncodingContext);
return RenderPassEncoder::MakeError(device, this, &mEncodingContext,
descriptor ? descriptor->label : nullptr);
}
}
return passEncoder;
}
return RenderPassEncoder::MakeError(device, this, &mEncodingContext);
return RenderPassEncoder::MakeError(device, this, &mEncodingContext,
descriptor ? descriptor->label : nullptr);
}
// This function handles render pass workarounds. Because some cases may require
@ -1627,7 +1630,7 @@ CommandBufferBase* CommandEncoder::APIFinish(const CommandBufferDescriptor* desc
Ref<CommandBufferBase> commandBuffer;
if (GetDevice()->ConsumedError(Finish(descriptor), &commandBuffer)) {
return CommandBufferBase::MakeError(GetDevice());
return CommandBufferBase::MakeError(GetDevice(), descriptor ? descriptor->label : nullptr);
}
ASSERT(!IsError());
return commandBuffer.Detach();

View File

@ -40,7 +40,7 @@ class CommandEncoder final : public ApiObjectBase {
public:
static Ref<CommandEncoder> Create(DeviceBase* device,
const CommandEncoderDescriptor* descriptor);
static CommandEncoder* MakeError(DeviceBase* device);
static CommandEncoder* MakeError(DeviceBase* device, const char* label);
ObjectType GetType() const override;
@ -119,7 +119,7 @@ class CommandEncoder final : public ApiObjectBase {
private:
CommandEncoder(DeviceBase* device, const CommandEncoderDescriptor* descriptor);
CommandEncoder(DeviceBase* device, ObjectBase::ErrorTag tag);
CommandEncoder(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
void DestroyImpl() override;

View File

@ -128,15 +128,18 @@ Ref<ComputePassEncoder> ComputePassEncoder::Create(DeviceBase* device,
ComputePassEncoder::ComputePassEncoder(DeviceBase* device,
CommandEncoder* commandEncoder,
EncodingContext* encodingContext,
ErrorTag errorTag)
: ProgrammableEncoder(device, encodingContext, errorTag), mCommandEncoder(commandEncoder) {}
ErrorTag errorTag,
const char* label)
: ProgrammableEncoder(device, encodingContext, errorTag, label),
mCommandEncoder(commandEncoder) {}
// static
Ref<ComputePassEncoder> ComputePassEncoder::MakeError(DeviceBase* device,
CommandEncoder* commandEncoder,
EncodingContext* encodingContext) {
EncodingContext* encodingContext,
const char* label) {
return AcquireRef(
new ComputePassEncoder(device, commandEncoder, encodingContext, ObjectBase::kError));
new ComputePassEncoder(device, commandEncoder, encodingContext, ObjectBase::kError, label));
}
void ComputePassEncoder::DestroyImpl() {

View File

@ -36,7 +36,8 @@ class ComputePassEncoder final : public ProgrammableEncoder {
EncodingContext* encodingContext);
static Ref<ComputePassEncoder> MakeError(DeviceBase* device,
CommandEncoder* commandEncoder,
EncodingContext* encodingContext);
EncodingContext* encodingContext,
const char* label);
ObjectType GetType() const override;
@ -75,7 +76,8 @@ class ComputePassEncoder final : public ProgrammableEncoder {
ComputePassEncoder(DeviceBase* device,
CommandEncoder* commandEncoder,
EncodingContext* encodingContext,
ErrorTag errorTag);
ErrorTag errorTag,
const char* label);
private:
void DestroyImpl() override;

View File

@ -56,8 +56,10 @@ ComputePipelineBase::ComputePipelineBase(DeviceBase* device,
StreamIn(&mCacheKey, CacheKey::Type::ComputePipeline, device->GetCacheKey());
}
ComputePipelineBase::ComputePipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag)
: PipelineBase(device, tag) {}
ComputePipelineBase::ComputePipelineBase(DeviceBase* device,
ObjectBase::ErrorTag tag,
const char* label)
: PipelineBase(device, tag, label) {}
ComputePipelineBase::~ComputePipelineBase() = default;
@ -69,11 +71,11 @@ void ComputePipelineBase::DestroyImpl() {
}
// static
ComputePipelineBase* ComputePipelineBase::MakeError(DeviceBase* device) {
ComputePipelineBase* ComputePipelineBase::MakeError(DeviceBase* device, const char* label) {
class ErrorComputePipeline final : public ComputePipelineBase {
public:
explicit ErrorComputePipeline(DeviceBase* device)
: ComputePipelineBase(device, ObjectBase::kError) {}
explicit ErrorComputePipeline(DeviceBase* device, const char* label)
: ComputePipelineBase(device, ObjectBase::kError, label) {}
MaybeError Initialize() override {
UNREACHABLE();
@ -81,7 +83,7 @@ ComputePipelineBase* ComputePipelineBase::MakeError(DeviceBase* device) {
}
};
return new ErrorComputePipeline(device);
return new ErrorComputePipeline(device, label);
}
ObjectType ComputePipelineBase::GetType() const {

View File

@ -32,7 +32,7 @@ class ComputePipelineBase : public PipelineBase {
ComputePipelineBase(DeviceBase* device, const ComputePipelineDescriptor* descriptor);
~ComputePipelineBase() override;
static ComputePipelineBase* MakeError(DeviceBase* device);
static ComputePipelineBase* MakeError(DeviceBase* device, const char* label);
ObjectType GetType() const override;
@ -45,7 +45,7 @@ class ComputePipelineBase : public PipelineBase {
void DestroyImpl() override;
private:
ComputePipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag);
ComputePipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
};
} // namespace dawn::native

View File

@ -1107,7 +1107,7 @@ BindGroupBase* DeviceBase::APICreateBindGroup(const BindGroupDescriptor* descrip
Ref<BindGroupBase> result;
if (ConsumedError(CreateBindGroup(descriptor), &result, "calling %s.CreateBindGroup(%s).", this,
descriptor)) {
return BindGroupBase::MakeError(this);
return BindGroupBase::MakeError(this, descriptor ? descriptor->label : nullptr);
}
return result.Detach();
}
@ -1116,7 +1116,7 @@ BindGroupLayoutBase* DeviceBase::APICreateBindGroupLayout(
Ref<BindGroupLayoutBase> result;
if (ConsumedError(CreateBindGroupLayout(descriptor), &result,
"calling %s.CreateBindGroupLayout(%s).", this, descriptor)) {
return BindGroupLayoutBase::MakeError(this);
return BindGroupLayoutBase::MakeError(this, descriptor ? descriptor->label : nullptr);
}
return result.Detach();
}
@ -1133,7 +1133,7 @@ CommandEncoder* DeviceBase::APICreateCommandEncoder(const CommandEncoderDescript
Ref<CommandEncoder> result;
if (ConsumedError(CreateCommandEncoder(descriptor), &result,
"calling %s.CreateCommandEncoder(%s).", this, descriptor)) {
return CommandEncoder::MakeError(this);
return CommandEncoder::MakeError(this, descriptor ? descriptor->label : nullptr);
}
return result.Detach();
}
@ -1145,7 +1145,7 @@ ComputePipelineBase* DeviceBase::APICreateComputePipeline(
Ref<ComputePipelineBase> result;
if (ConsumedError(CreateComputePipeline(descriptor), &result,
"calling %s.CreateComputePipeline(%s).", this, descriptor)) {
return ComputePipelineBase::MakeError(this);
return ComputePipelineBase::MakeError(this, descriptor ? descriptor->label : nullptr);
}
return result.Detach();
}
@ -1176,7 +1176,7 @@ PipelineLayoutBase* DeviceBase::APICreatePipelineLayout(
Ref<PipelineLayoutBase> result;
if (ConsumedError(CreatePipelineLayout(descriptor), &result,
"calling %s.CreatePipelineLayout(%s).", this, descriptor)) {
return PipelineLayoutBase::MakeError(this);
return PipelineLayoutBase::MakeError(this, descriptor ? descriptor->label : nullptr);
}
return result.Detach();
}
@ -1192,7 +1192,7 @@ SamplerBase* DeviceBase::APICreateSampler(const SamplerDescriptor* descriptor) {
Ref<SamplerBase> result;
if (ConsumedError(CreateSampler(descriptor), &result, "calling %s.CreateSampler(%s).", this,
descriptor)) {
return SamplerBase::MakeError(this);
return SamplerBase::MakeError(this, descriptor ? descriptor->label : nullptr);
}
return result.Detach();
}
@ -1223,7 +1223,7 @@ RenderBundleEncoder* DeviceBase::APICreateRenderBundleEncoder(
Ref<RenderBundleEncoder> result;
if (ConsumedError(CreateRenderBundleEncoder(descriptor), &result,
"calling %s.CreateRenderBundleEncoder(%s).", this, descriptor)) {
return RenderBundleEncoder::MakeError(this);
return RenderBundleEncoder::MakeError(this, descriptor ? descriptor->label : nullptr);
}
return result.Detach();
}
@ -1235,7 +1235,7 @@ RenderPipelineBase* DeviceBase::APICreateRenderPipeline(
Ref<RenderPipelineBase> result;
if (ConsumedError(CreateRenderPipeline(descriptor), &result,
"calling %s.CreateRenderPipeline(%s).", this, descriptor)) {
return RenderPipelineBase::MakeError(this);
return RenderPipelineBase::MakeError(this, descriptor ? descriptor->label : nullptr);
}
return result.Detach();
}
@ -1249,7 +1249,7 @@ ShaderModuleBase* DeviceBase::APICreateShaderModule(const ShaderModuleDescriptor
if (ConsumedError(CreateShaderModule(descriptor, compilationMessages.get()), &result,
"calling %s.CreateShaderModule(%s).", this, descriptor)) {
DAWN_ASSERT(result == nullptr);
result = ShaderModuleBase::MakeError(this);
result = ShaderModuleBase::MakeError(this, descriptor ? descriptor->label : nullptr);
}
// Move compilation messages into ShaderModuleBase and emit tint errors and warnings
// after all other operations are finished, even if any of them is failed and result

View File

@ -138,8 +138,10 @@ ExternalTextureBase::ExternalTextureBase(DeviceBase* device,
}
// Error external texture cannot be used in bind group.
ExternalTextureBase::ExternalTextureBase(DeviceBase* device, ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag), mState(ExternalTextureState::Destroyed) {}
ExternalTextureBase::ExternalTextureBase(DeviceBase* device,
ObjectBase::ErrorTag tag,
const char* label)
: ApiObjectBase(device, tag, label), mState(ExternalTextureState::Destroyed) {}
ExternalTextureBase::~ExternalTextureBase() = default;
@ -371,8 +373,8 @@ void ExternalTextureBase::DestroyImpl() {
}
// static
ExternalTextureBase* ExternalTextureBase::MakeError(DeviceBase* device) {
return new ExternalTextureBase(device, ObjectBase::kError);
ExternalTextureBase* ExternalTextureBase::MakeError(DeviceBase* device, const char* label) {
return new ExternalTextureBase(device, ObjectBase::kError, label);
}
BufferBase* ExternalTextureBase::GetParamsBuffer() const {

View File

@ -55,7 +55,7 @@ class ExternalTextureBase : public ApiObjectBase {
const Origin2D& GetVisibleOrigin() const;
MaybeError ValidateCanUseInSubmitNow() const;
static ExternalTextureBase* MakeError(DeviceBase* device);
static ExternalTextureBase* MakeError(DeviceBase* device, const char* label = nullptr);
void APIExpire();
void APIDestroy();
@ -71,7 +71,7 @@ class ExternalTextureBase : public ApiObjectBase {
private:
enum class ExternalTextureState { Active, Expired, Destroyed };
ExternalTextureBase(DeviceBase* device, ObjectBase::ErrorTag tag);
ExternalTextureBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
MaybeError ValidateRefresh();
MaybeError ValidateExpire();

View File

@ -68,7 +68,12 @@ ApiObjectBase::ApiObjectBase(DeviceBase* device, const char* label) : ObjectBase
}
}
ApiObjectBase::ApiObjectBase(DeviceBase* device, ErrorTag tag) : ObjectBase(device, tag) {}
ApiObjectBase::ApiObjectBase(DeviceBase* device, ErrorTag tag, const char* label)
: ObjectBase(device, tag) {
if (label) {
mLabel = label;
}
}
ApiObjectBase::ApiObjectBase(DeviceBase* device, LabelNotImplementedTag tag) : ObjectBase(device) {}

View File

@ -79,7 +79,7 @@ class ApiObjectBase : public ObjectBase, public LinkNode<ApiObjectBase> {
ApiObjectBase(DeviceBase* device, LabelNotImplementedTag tag);
ApiObjectBase(DeviceBase* device, const char* label);
ApiObjectBase(DeviceBase* device, ErrorTag tag);
ApiObjectBase(DeviceBase* device, ErrorTag tag, const char* label = nullptr);
~ApiObjectBase() override;
virtual ObjectType GetType() const = 0;

View File

@ -213,8 +213,8 @@ PipelineBase::PipelineBase(DeviceBase* device,
}
}
PipelineBase::PipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag) {}
PipelineBase::PipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label)
: ApiObjectBase(device, tag, label) {}
PipelineBase::~PipelineBase() = default;

View File

@ -81,7 +81,7 @@ class PipelineBase : public ApiObjectBase, public CachedObject {
PipelineLayoutBase* layout,
const char* label,
std::vector<StageAndDescriptor> stages);
PipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag);
PipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
private:
MaybeError ValidateGetBindGroupLayout(BindGroupIndex group);

View File

@ -74,8 +74,10 @@ PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device,
GetObjectTrackingList()->Track(this);
}
PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device, ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag) {}
PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device,
ObjectBase::ErrorTag tag,
const char* label)
: ApiObjectBase(device, tag, label) {}
PipelineLayoutBase::~PipelineLayoutBase() = default;
@ -87,8 +89,8 @@ void PipelineLayoutBase::DestroyImpl() {
}
// static
PipelineLayoutBase* PipelineLayoutBase::MakeError(DeviceBase* device) {
return new PipelineLayoutBase(device, ObjectBase::kError);
PipelineLayoutBase* PipelineLayoutBase::MakeError(DeviceBase* device, const char* label) {
return new PipelineLayoutBase(device, ObjectBase::kError, label);
}
// static

View File

@ -57,7 +57,7 @@ class PipelineLayoutBase : public ApiObjectBase, public CachedObject {
PipelineLayoutBase(DeviceBase* device, const PipelineLayoutDescriptor* descriptor);
~PipelineLayoutBase() override;
static PipelineLayoutBase* MakeError(DeviceBase* device);
static PipelineLayoutBase* MakeError(DeviceBase* device, const char* label);
static ResultOrError<Ref<PipelineLayoutBase>> CreateDefault(
DeviceBase* device,
std::vector<StageAndDescriptor> stages);
@ -84,7 +84,7 @@ class PipelineLayoutBase : public ApiObjectBase, public CachedObject {
};
protected:
PipelineLayoutBase(DeviceBase* device, ObjectBase::ErrorTag tag);
PipelineLayoutBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
void DestroyImpl() override;
BindGroupLayoutArray mBindGroupLayouts;

View File

@ -37,8 +37,9 @@ ProgrammableEncoder::ProgrammableEncoder(DeviceBase* device,
ProgrammableEncoder::ProgrammableEncoder(DeviceBase* device,
EncodingContext* encodingContext,
ErrorTag errorTag)
: ApiObjectBase(device, errorTag),
ErrorTag errorTag,
const char* label)
: ApiObjectBase(device, errorTag, label),
mEncodingContext(encodingContext),
mValidationEnabled(device->IsValidationEnabled()) {}

View File

@ -53,7 +53,10 @@ class ProgrammableEncoder : public ApiObjectBase {
const uint32_t* dynamicOffsets) const;
// Construct an "error" programmable pass encoder.
ProgrammableEncoder(DeviceBase* device, EncodingContext* encodingContext, ErrorTag errorTag);
ProgrammableEncoder(DeviceBase* device,
EncodingContext* encodingContext,
ErrorTag errorTag,
const char* label);
EncodingContext* mEncodingContext = nullptr;

View File

@ -114,7 +114,9 @@ QuerySetBase::QuerySetBase(DeviceBase* device, const QuerySetDescriptor* descrip
QuerySetBase::QuerySetBase(DeviceBase* device,
const QuerySetDescriptor* descriptor,
ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag), mQueryType(descriptor->type), mQueryCount(descriptor->count) {}
: ApiObjectBase(device, tag, descriptor->label),
mQueryType(descriptor->type),
mQueryCount(descriptor->count) {}
QuerySetBase::~QuerySetBase() {
// Uninitialized or already destroyed

View File

@ -159,7 +159,8 @@ struct SubmittedWorkDone : TrackTaskCallback {
class ErrorQueue : public QueueBase {
public:
explicit ErrorQueue(DeviceBase* device) : QueueBase(device, ObjectBase::kError) {}
explicit ErrorQueue(DeviceBase* device, const char* label)
: QueueBase(device, ObjectBase::kError, label) {}
private:
MaybeError SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) override {
@ -177,7 +178,8 @@ void TrackTaskCallback::SetFinishedSerial(ExecutionSerial serial) {
QueueBase::QueueBase(DeviceBase* device, const QueueDescriptor* descriptor)
: ApiObjectBase(device, descriptor->label) {}
QueueBase::QueueBase(DeviceBase* device, ObjectBase::ErrorTag tag) : ApiObjectBase(device, tag) {}
QueueBase::QueueBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label)
: ApiObjectBase(device, tag, label) {}
QueueBase::~QueueBase() {
ASSERT(mTasksInFlight.Empty());
@ -186,8 +188,8 @@ QueueBase::~QueueBase() {
void QueueBase::DestroyImpl() {}
// static
QueueBase* QueueBase::MakeError(DeviceBase* device) {
return new ErrorQueue(device);
QueueBase* QueueBase::MakeError(DeviceBase* device, const char* label) {
return new ErrorQueue(device, label);
}
ObjectType QueueBase::GetType() const {

View File

@ -49,7 +49,7 @@ class QueueBase : public ApiObjectBase {
public:
~QueueBase() override;
static QueueBase* MakeError(DeviceBase* device);
static QueueBase* MakeError(DeviceBase* device, const char* label);
ObjectType GetType() const override;
@ -84,7 +84,7 @@ class QueueBase : public ApiObjectBase {
protected:
QueueBase(DeviceBase* device, const QueueDescriptor* descriptor);
QueueBase(DeviceBase* device, ObjectBase::ErrorTag tag);
QueueBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
void DestroyImpl() override;
private:

View File

@ -51,12 +51,12 @@ void RenderBundleBase::DestroyImpl() {
}
// static
RenderBundleBase* RenderBundleBase::MakeError(DeviceBase* device) {
return new RenderBundleBase(device, ObjectBase::kError);
RenderBundleBase* RenderBundleBase::MakeError(DeviceBase* device, const char* label) {
return new RenderBundleBase(device, ObjectBase::kError, label);
}
RenderBundleBase::RenderBundleBase(DeviceBase* device, ErrorTag errorTag)
: ApiObjectBase(device, errorTag), mIndirectDrawMetadata(device->GetLimits()) {}
RenderBundleBase::RenderBundleBase(DeviceBase* device, ErrorTag errorTag, const char* label)
: ApiObjectBase(device, errorTag, label), mIndirectDrawMetadata(device->GetLimits()) {}
ObjectType RenderBundleBase::GetType() const {
return ObjectType::RenderBundle;

View File

@ -43,7 +43,7 @@ class RenderBundleBase final : public ApiObjectBase {
RenderPassResourceUsage resourceUsage,
IndirectDrawMetadata indirectDrawMetadata);
static RenderBundleBase* MakeError(DeviceBase* device);
static RenderBundleBase* MakeError(DeviceBase* device, const char* label);
ObjectType GetType() const override;
@ -57,7 +57,7 @@ class RenderBundleBase final : public ApiObjectBase {
const IndirectDrawMetadata& GetIndirectDrawMetadata();
private:
RenderBundleBase(DeviceBase* device, ErrorTag errorTag);
RenderBundleBase(DeviceBase* device, ErrorTag errorTag, const char* label);
void DestroyImpl() override;

View File

@ -108,8 +108,8 @@ RenderBundleEncoder::RenderBundleEncoder(DeviceBase* device,
GetObjectTrackingList()->Track(this);
}
RenderBundleEncoder::RenderBundleEncoder(DeviceBase* device, ErrorTag errorTag)
: RenderEncoderBase(device, &mBundleEncodingContext, errorTag),
RenderBundleEncoder::RenderBundleEncoder(DeviceBase* device, ErrorTag errorTag, const char* label)
: RenderEncoderBase(device, &mBundleEncodingContext, errorTag, label),
mBundleEncodingContext(device, this) {}
void RenderBundleEncoder::DestroyImpl() {
@ -125,8 +125,8 @@ Ref<RenderBundleEncoder> RenderBundleEncoder::Create(
}
// static
RenderBundleEncoder* RenderBundleEncoder::MakeError(DeviceBase* device) {
return new RenderBundleEncoder(device, ObjectBase::kError);
RenderBundleEncoder* RenderBundleEncoder::MakeError(DeviceBase* device, const char* label) {
return new RenderBundleEncoder(device, ObjectBase::kError, label);
}
ObjectType RenderBundleEncoder::GetType() const {
@ -142,7 +142,7 @@ RenderBundleBase* RenderBundleEncoder::APIFinish(const RenderBundleDescriptor* d
if (GetDevice()->ConsumedError(FinishImpl(descriptor), &result, "calling %s.Finish(%s).", this,
descriptor)) {
return RenderBundleBase::MakeError(GetDevice());
return RenderBundleBase::MakeError(GetDevice(), descriptor ? descriptor->label : nullptr);
}
return result;

View File

@ -30,7 +30,7 @@ class RenderBundleEncoder final : public RenderEncoderBase {
public:
static Ref<RenderBundleEncoder> Create(DeviceBase* device,
const RenderBundleEncoderDescriptor* descriptor);
static RenderBundleEncoder* MakeError(DeviceBase* device);
static RenderBundleEncoder* MakeError(DeviceBase* device, const char* label);
ObjectType GetType() const override;
@ -40,7 +40,7 @@ class RenderBundleEncoder final : public RenderEncoderBase {
private:
RenderBundleEncoder(DeviceBase* device, const RenderBundleEncoderDescriptor* descriptor);
RenderBundleEncoder(DeviceBase* device, ErrorTag errorTag);
RenderBundleEncoder(DeviceBase* device, ErrorTag errorTag, const char* label);
void DestroyImpl() override;

View File

@ -47,8 +47,9 @@ RenderEncoderBase::RenderEncoderBase(DeviceBase* device,
RenderEncoderBase::RenderEncoderBase(DeviceBase* device,
EncodingContext* encodingContext,
ErrorTag errorTag)
: ProgrammableEncoder(device, encodingContext, errorTag),
ErrorTag errorTag,
const char* label)
: ProgrammableEncoder(device, encodingContext, errorTag, label),
mIndirectDrawMetadata(device->GetLimits()),
mDisableBaseVertex(device->IsToggleEnabled(Toggle::DisableBaseVertex)),
mDisableBaseInstance(device->IsToggleEnabled(Toggle::DisableBaseInstance)) {}

View File

@ -67,7 +67,10 @@ class RenderEncoderBase : public ProgrammableEncoder {
protected:
// Construct an "error" render encoder base.
RenderEncoderBase(DeviceBase* device, EncodingContext* encodingContext, ErrorTag errorTag);
RenderEncoderBase(DeviceBase* device,
EncodingContext* encodingContext,
ErrorTag errorTag,
const char* label);
void DestroyImpl() override;

View File

@ -102,15 +102,18 @@ Ref<RenderPassEncoder> RenderPassEncoder::Create(DeviceBase* device,
RenderPassEncoder::RenderPassEncoder(DeviceBase* device,
CommandEncoder* commandEncoder,
EncodingContext* encodingContext,
ErrorTag errorTag)
: RenderEncoderBase(device, encodingContext, errorTag), mCommandEncoder(commandEncoder) {}
ErrorTag errorTag,
const char* label)
: RenderEncoderBase(device, encodingContext, errorTag, label),
mCommandEncoder(commandEncoder) {}
// static
Ref<RenderPassEncoder> RenderPassEncoder::MakeError(DeviceBase* device,
CommandEncoder* commandEncoder,
EncodingContext* encodingContext) {
EncodingContext* encodingContext,
const char* label) {
return AcquireRef(
new RenderPassEncoder(device, commandEncoder, encodingContext, ObjectBase::kError));
new RenderPassEncoder(device, commandEncoder, encodingContext, ObjectBase::kError, label));
}
void RenderPassEncoder::DestroyImpl() {

View File

@ -40,7 +40,8 @@ class RenderPassEncoder final : public RenderEncoderBase {
std::function<void()> endCallback = nullptr);
static Ref<RenderPassEncoder> MakeError(DeviceBase* device,
CommandEncoder* commandEncoder,
EncodingContext* encodingContext);
EncodingContext* encodingContext,
const char* label);
ObjectType GetType() const override;
@ -84,7 +85,8 @@ class RenderPassEncoder final : public RenderEncoderBase {
RenderPassEncoder(DeviceBase* device,
CommandEncoder* commandEncoder,
EncodingContext* encodingContext,
ErrorTag errorTag);
ErrorTag errorTag,
const char* label);
private:
void DestroyImpl() override;

View File

@ -730,8 +730,10 @@ RenderPipelineBase::RenderPipelineBase(DeviceBase* device,
StreamIn(&mCacheKey, CacheKey::Type::RenderPipeline, device->GetCacheKey());
}
RenderPipelineBase::RenderPipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag)
: PipelineBase(device, tag) {}
RenderPipelineBase::RenderPipelineBase(DeviceBase* device,
ObjectBase::ErrorTag tag,
const char* label)
: PipelineBase(device, tag, label) {}
RenderPipelineBase::~RenderPipelineBase() = default;
@ -747,11 +749,11 @@ void RenderPipelineBase::DestroyImpl() {
}
// static
RenderPipelineBase* RenderPipelineBase::MakeError(DeviceBase* device) {
RenderPipelineBase* RenderPipelineBase::MakeError(DeviceBase* device, const char* label) {
class ErrorRenderPipeline final : public RenderPipelineBase {
public:
explicit ErrorRenderPipeline(DeviceBase* device)
: RenderPipelineBase(device, ObjectBase::kError) {}
explicit ErrorRenderPipeline(DeviceBase* device, const char* label)
: RenderPipelineBase(device, ObjectBase::kError, label) {}
MaybeError Initialize() override {
UNREACHABLE();
@ -759,7 +761,7 @@ RenderPipelineBase* RenderPipelineBase::MakeError(DeviceBase* device) {
}
};
return new ErrorRenderPipeline(device);
return new ErrorRenderPipeline(device, label);
}
ObjectType RenderPipelineBase::GetType() const {

View File

@ -65,7 +65,7 @@ class RenderPipelineBase : public PipelineBase {
RenderPipelineBase(DeviceBase* device, const RenderPipelineDescriptor* descriptor);
~RenderPipelineBase() override;
static RenderPipelineBase* MakeError(DeviceBase* device);
static RenderPipelineBase* MakeError(DeviceBase* device, const char* label);
ObjectType GetType() const override;
@ -116,7 +116,7 @@ class RenderPipelineBase : public PipelineBase {
void DestroyImpl() override;
private:
RenderPipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag);
RenderPipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
// Vertex state
uint32_t mVertexBufferCount;

View File

@ -89,8 +89,8 @@ SamplerBase::SamplerBase(DeviceBase* device, const SamplerDescriptor* descriptor
GetObjectTrackingList()->Track(this);
}
SamplerBase::SamplerBase(DeviceBase* device, ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag) {}
SamplerBase::SamplerBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label)
: ApiObjectBase(device, tag, label) {}
SamplerBase::~SamplerBase() = default;
@ -102,8 +102,8 @@ void SamplerBase::DestroyImpl() {
}
// static
SamplerBase* SamplerBase::MakeError(DeviceBase* device) {
return new SamplerBase(device, ObjectBase::kError);
SamplerBase* SamplerBase::MakeError(DeviceBase* device, const char* label) {
return new SamplerBase(device, ObjectBase::kError, label);
}
ObjectType SamplerBase::GetType() const {

View File

@ -36,7 +36,7 @@ class SamplerBase : public ApiObjectBase, public CachedObject {
SamplerBase(DeviceBase* device, const SamplerDescriptor* descriptor);
~SamplerBase() override;
static SamplerBase* MakeError(DeviceBase* device);
static SamplerBase* MakeError(DeviceBase* device, const char* label);
ObjectType GetType() const override;
@ -56,7 +56,7 @@ class SamplerBase : public ApiObjectBase, public CachedObject {
void DestroyImpl() override;
private:
SamplerBase(DeviceBase* device, ObjectBase::ErrorTag tag);
SamplerBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
// TODO(cwallez@chromium.org): Store a crypto hash of the items instead?
wgpu::AddressMode mAddressModeU;

View File

@ -1110,8 +1110,8 @@ ShaderModuleBase::ShaderModuleBase(DeviceBase* device, const ShaderModuleDescrip
GetObjectTrackingList()->Track(this);
}
ShaderModuleBase::ShaderModuleBase(DeviceBase* device, ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag), mType(Type::Undefined) {}
ShaderModuleBase::ShaderModuleBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label)
: ApiObjectBase(device, tag, label), mType(Type::Undefined) {}
ShaderModuleBase::~ShaderModuleBase() = default;
@ -1123,8 +1123,8 @@ void ShaderModuleBase::DestroyImpl() {
}
// static
Ref<ShaderModuleBase> ShaderModuleBase::MakeError(DeviceBase* device) {
return AcquireRef(new ShaderModuleBase(device, ObjectBase::kError));
Ref<ShaderModuleBase> ShaderModuleBase::MakeError(DeviceBase* device, const char* label) {
return AcquireRef(new ShaderModuleBase(device, ObjectBase::kError, label));
}
ObjectType ShaderModuleBase::GetType() const {

View File

@ -258,7 +258,7 @@ class ShaderModuleBase : public ApiObjectBase, public CachedObject {
ShaderModuleBase(DeviceBase* device, const ShaderModuleDescriptor* descriptor);
~ShaderModuleBase() override;
static Ref<ShaderModuleBase> MakeError(DeviceBase* device);
static Ref<ShaderModuleBase> MakeError(DeviceBase* device, const char* label);
ObjectType GetType() const override;
@ -292,7 +292,7 @@ class ShaderModuleBase : public ApiObjectBase, public CachedObject {
OwnedCompilationMessages* compilationMessages);
private:
ShaderModuleBase(DeviceBase* device, ObjectBase::ErrorTag tag);
ShaderModuleBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
// The original data in the descriptor for caching.
enum class Type { Undefined, Spirv, Wgsl };

View File

@ -584,7 +584,7 @@ static constexpr Format kUnusedFormat;
TextureBase::TextureBase(DeviceBase* device,
const TextureDescriptor* descriptor,
ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag),
: ApiObjectBase(device, tag, descriptor->label),
mDimension(descriptor->dimension),
mFormat(kUnusedFormat),
mSize(descriptor->size),
@ -796,7 +796,7 @@ TextureViewBase* TextureBase::APICreateView(const TextureViewDescriptor* descrip
Ref<TextureViewBase> result;
if (device->ConsumedError(CreateView(descriptor), &result, "calling %s.CreateView(%s).", this,
descriptor)) {
return TextureViewBase::MakeError(device);
return TextureViewBase::MakeError(device, descriptor ? descriptor->label : nullptr);
}
return result.Detach();
}
@ -849,16 +849,16 @@ TextureViewBase::TextureViewBase(TextureBase* texture, const TextureViewDescript
GetObjectTrackingList()->Track(this);
}
TextureViewBase::TextureViewBase(DeviceBase* device, ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag), mFormat(kUnusedFormat) {}
TextureViewBase::TextureViewBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label)
: ApiObjectBase(device, tag, label), mFormat(kUnusedFormat) {}
TextureViewBase::~TextureViewBase() = default;
void TextureViewBase::DestroyImpl() {}
// static
TextureViewBase* TextureViewBase::MakeError(DeviceBase* device) {
return new TextureViewBase(device, ObjectBase::kError);
TextureViewBase* TextureViewBase::MakeError(DeviceBase* device, const char* label) {
return new TextureViewBase(device, ObjectBase::kError, label);
}
ObjectType TextureViewBase::GetType() const {

View File

@ -140,7 +140,7 @@ class TextureViewBase : public ApiObjectBase {
TextureViewBase(TextureBase* texture, const TextureViewDescriptor* descriptor);
~TextureViewBase() override;
static TextureViewBase* MakeError(DeviceBase* device);
static TextureViewBase* MakeError(DeviceBase* device, const char* label = nullptr);
ObjectType GetType() const override;
@ -160,7 +160,7 @@ class TextureViewBase : public ApiObjectBase {
void DestroyImpl() override;
private:
TextureViewBase(DeviceBase* device, ObjectBase::ErrorTag tag);
TextureViewBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
ApiObjectList* GetObjectTrackingList() override;