Show encoder in command buffer/render bundle messages
Having labels like [CommandBuffer from CommandEncoder "B"] will provide greater context when developers don't provide labels to every tier of object. Bug: dawn:1746 Change-Id: Ibf72f97e054ff943b33c210e457422466e46a013 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127120 Commit-Queue: Brandon Jones <bajones@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
47dd30117d
commit
1040f0e087
|
@ -29,7 +29,8 @@ CommandBufferBase::CommandBufferBase(CommandEncoder* encoder,
|
||||||
const CommandBufferDescriptor* descriptor)
|
const CommandBufferDescriptor* descriptor)
|
||||||
: ApiObjectBase(encoder->GetDevice(), descriptor->label),
|
: ApiObjectBase(encoder->GetDevice(), descriptor->label),
|
||||||
mCommands(encoder->AcquireCommands()),
|
mCommands(encoder->AcquireCommands()),
|
||||||
mResourceUsages(encoder->AcquireResourceUsages()) {
|
mResourceUsages(encoder->AcquireResourceUsages()),
|
||||||
|
mEncoderLabel(encoder->GetLabel()) {
|
||||||
GetObjectTrackingList()->Track(this);
|
GetObjectTrackingList()->Track(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +48,28 @@ ObjectType CommandBufferBase::GetType() const {
|
||||||
return ObjectType::CommandBuffer;
|
return ObjectType::CommandBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CommandBufferBase::FormatLabel(absl::FormatSink* s) const {
|
||||||
|
s->Append(ObjectTypeAsString(GetType()));
|
||||||
|
|
||||||
|
const std::string& label = GetLabel();
|
||||||
|
if (!label.empty()) {
|
||||||
|
s->Append(absl::StrFormat(" \"%s\"", label));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mEncoderLabel.empty()) {
|
||||||
|
s->Append(absl::StrFormat(" from %s \"%s\"", ObjectTypeAsString(ObjectType::CommandEncoder),
|
||||||
|
mEncoderLabel));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& CommandBufferBase::GetEncoderLabel() const {
|
||||||
|
return mEncoderLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandBufferBase::SetEncoderLabel(std::string encoderLabel) {
|
||||||
|
mEncoderLabel = encoderLabel;
|
||||||
|
}
|
||||||
|
|
||||||
MaybeError CommandBufferBase::ValidateCanUseInSubmitNow() const {
|
MaybeError CommandBufferBase::ValidateCanUseInSubmitNow() const {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#ifndef SRC_DAWN_NATIVE_COMMANDBUFFER_H_
|
#ifndef SRC_DAWN_NATIVE_COMMANDBUFFER_H_
|
||||||
#define SRC_DAWN_NATIVE_COMMANDBUFFER_H_
|
#define SRC_DAWN_NATIVE_COMMANDBUFFER_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "dawn/native/dawn_platform.h"
|
#include "dawn/native/dawn_platform.h"
|
||||||
|
|
||||||
#include "dawn/native/CommandAllocator.h"
|
#include "dawn/native/CommandAllocator.h"
|
||||||
|
@ -37,6 +39,10 @@ class CommandBufferBase : public ApiObjectBase {
|
||||||
static CommandBufferBase* MakeError(DeviceBase* device, const char* label);
|
static CommandBufferBase* MakeError(DeviceBase* device, const char* label);
|
||||||
|
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
void FormatLabel(absl::FormatSink* s) const override;
|
||||||
|
|
||||||
|
const std::string& GetEncoderLabel() const;
|
||||||
|
void SetEncoderLabel(std::string encoderLabel);
|
||||||
|
|
||||||
MaybeError ValidateCanUseInSubmitNow() const;
|
MaybeError ValidateCanUseInSubmitNow() const;
|
||||||
|
|
||||||
|
@ -53,6 +59,8 @@ class CommandBufferBase : public ApiObjectBase {
|
||||||
CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
|
CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label);
|
||||||
|
|
||||||
CommandBufferResourceUsage mResourceUsages;
|
CommandBufferResourceUsage mResourceUsages;
|
||||||
|
|
||||||
|
std::string mEncoderLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool IsCompleteSubresourceCopiedTo(const TextureBase* texture,
|
bool IsCompleteSubresourceCopiedTo(const TextureBase* texture,
|
||||||
|
|
|
@ -1596,7 +1596,10 @@ CommandBufferBase* CommandEncoder::APIFinish(const CommandBufferDescriptor* desc
|
||||||
|
|
||||||
Ref<CommandBufferBase> commandBuffer;
|
Ref<CommandBufferBase> commandBuffer;
|
||||||
if (GetDevice()->ConsumedError(Finish(descriptor), &commandBuffer)) {
|
if (GetDevice()->ConsumedError(Finish(descriptor), &commandBuffer)) {
|
||||||
return CommandBufferBase::MakeError(GetDevice(), descriptor ? descriptor->label : nullptr);
|
CommandBufferBase* errorCommandBuffer =
|
||||||
|
CommandBufferBase::MakeError(GetDevice(), descriptor ? descriptor->label : nullptr);
|
||||||
|
errorCommandBuffer->SetEncoderLabel(this->GetLabel());
|
||||||
|
return errorCommandBuffer;
|
||||||
}
|
}
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
return commandBuffer.Detach();
|
return commandBuffer.Detach();
|
||||||
|
|
|
@ -14,8 +14,10 @@
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
#include "absl/strings/str_format.h"
|
||||||
#include "dawn/native/Device.h"
|
#include "dawn/native/Device.h"
|
||||||
#include "dawn/native/ObjectBase.h"
|
#include "dawn/native/ObjectBase.h"
|
||||||
|
#include "dawn/native/ObjectType_autogen.h"
|
||||||
|
|
||||||
namespace dawn::native {
|
namespace dawn::native {
|
||||||
|
|
||||||
|
@ -99,6 +101,13 @@ const std::string& ApiObjectBase::GetLabel() const {
|
||||||
return mLabel;
|
return mLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApiObjectBase::FormatLabel(absl::FormatSink* s) const {
|
||||||
|
s->Append(ObjectTypeAsString(GetType()));
|
||||||
|
if (!mLabel.empty()) {
|
||||||
|
s->Append(absl::StrFormat(" \"%s\"", mLabel));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ApiObjectBase::SetLabelImpl() {}
|
void ApiObjectBase::SetLabelImpl() {}
|
||||||
|
|
||||||
bool ApiObjectBase::IsAlive() const {
|
bool ApiObjectBase::IsAlive() const {
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
#include "dawn/common/RefCounted.h"
|
#include "dawn/common/RefCounted.h"
|
||||||
#include "dawn/native/Forward.h"
|
#include "dawn/native/Forward.h"
|
||||||
|
|
||||||
|
namespace absl {
|
||||||
|
class FormatSink;
|
||||||
|
}
|
||||||
|
|
||||||
namespace dawn::native {
|
namespace dawn::native {
|
||||||
|
|
||||||
class ApiObjectBase;
|
class ApiObjectBase;
|
||||||
|
@ -85,6 +89,8 @@ class ApiObjectBase : public ObjectBase, public LinkNode<ApiObjectBase> {
|
||||||
virtual ObjectType GetType() const = 0;
|
virtual ObjectType GetType() const = 0;
|
||||||
const std::string& GetLabel() const;
|
const std::string& GetLabel() const;
|
||||||
|
|
||||||
|
virtual void FormatLabel(absl::FormatSink* s) const;
|
||||||
|
|
||||||
// The ApiObjectBase is considered alive if it is tracked in a respective linked list owned
|
// The ApiObjectBase is considered alive if it is tracked in a respective linked list owned
|
||||||
// by the owning device.
|
// by the owning device.
|
||||||
bool IsAlive() const;
|
bool IsAlive() const;
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#ifndef SRC_DAWN_NATIVE_PROGRAMMABLEENCODER_H_
|
#ifndef SRC_DAWN_NATIVE_PROGRAMMABLEENCODER_H_
|
||||||
#define SRC_DAWN_NATIVE_PROGRAMMABLEENCODER_H_
|
#define SRC_DAWN_NATIVE_PROGRAMMABLEENCODER_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "dawn/native/CommandEncoder.h"
|
#include "dawn/native/CommandEncoder.h"
|
||||||
#include "dawn/native/Error.h"
|
#include "dawn/native/Error.h"
|
||||||
#include "dawn/native/Forward.h"
|
#include "dawn/native/Forward.h"
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/strings/str_format.h"
|
||||||
#include "dawn/common/BitSetIterator.h"
|
#include "dawn/common/BitSetIterator.h"
|
||||||
#include "dawn/native/Commands.h"
|
#include "dawn/native/Commands.h"
|
||||||
#include "dawn/native/Device.h"
|
#include "dawn/native/Device.h"
|
||||||
|
@ -38,7 +39,8 @@ RenderBundleBase::RenderBundleBase(RenderBundleEncoder* encoder,
|
||||||
mDepthReadOnly(depthReadOnly),
|
mDepthReadOnly(depthReadOnly),
|
||||||
mStencilReadOnly(stencilReadOnly),
|
mStencilReadOnly(stencilReadOnly),
|
||||||
mDrawCount(encoder->GetDrawCount()),
|
mDrawCount(encoder->GetDrawCount()),
|
||||||
mResourceUsage(std::move(resourceUsage)) {
|
mResourceUsage(std::move(resourceUsage)),
|
||||||
|
mEncoderLabel(encoder->GetLabel()) {
|
||||||
GetObjectTrackingList()->Track(this);
|
GetObjectTrackingList()->Track(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +64,28 @@ ObjectType RenderBundleBase::GetType() const {
|
||||||
return ObjectType::RenderBundle;
|
return ObjectType::RenderBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderBundleBase::FormatLabel(absl::FormatSink* s) const {
|
||||||
|
s->Append(ObjectTypeAsString(GetType()));
|
||||||
|
|
||||||
|
const std::string& label = GetLabel();
|
||||||
|
if (!label.empty()) {
|
||||||
|
s->Append(absl::StrFormat(" \"%s\"", label));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mEncoderLabel.empty()) {
|
||||||
|
s->Append(absl::StrFormat(
|
||||||
|
" from %s \"%s\"", ObjectTypeAsString(ObjectType::RenderBundleEncoder), mEncoderLabel));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& RenderBundleBase::GetEncoderLabel() const {
|
||||||
|
return mEncoderLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderBundleBase::SetEncoderLabel(std::string encoderLabel) {
|
||||||
|
mEncoderLabel = encoderLabel;
|
||||||
|
}
|
||||||
|
|
||||||
CommandIterator* RenderBundleBase::GetCommands() {
|
CommandIterator* RenderBundleBase::GetCommands() {
|
||||||
return &mCommands;
|
return &mCommands;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define SRC_DAWN_NATIVE_RENDERBUNDLE_H_
|
#define SRC_DAWN_NATIVE_RENDERBUNDLE_H_
|
||||||
|
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "dawn/common/Constants.h"
|
#include "dawn/common/Constants.h"
|
||||||
#include "dawn/native/AttachmentState.h"
|
#include "dawn/native/AttachmentState.h"
|
||||||
|
@ -46,6 +47,10 @@ class RenderBundleBase final : public ApiObjectBase {
|
||||||
static RenderBundleBase* MakeError(DeviceBase* device, const char* label);
|
static RenderBundleBase* MakeError(DeviceBase* device, const char* label);
|
||||||
|
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
void FormatLabel(absl::FormatSink* s) const override;
|
||||||
|
|
||||||
|
const std::string& GetEncoderLabel() const;
|
||||||
|
void SetEncoderLabel(std::string encoderLabel);
|
||||||
|
|
||||||
CommandIterator* GetCommands();
|
CommandIterator* GetCommands();
|
||||||
|
|
||||||
|
@ -68,6 +73,7 @@ class RenderBundleBase final : public ApiObjectBase {
|
||||||
bool mStencilReadOnly;
|
bool mStencilReadOnly;
|
||||||
uint64_t mDrawCount;
|
uint64_t mDrawCount;
|
||||||
RenderPassResourceUsage mResourceUsage;
|
RenderPassResourceUsage mResourceUsage;
|
||||||
|
std::string mEncoderLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn::native
|
} // namespace dawn::native
|
||||||
|
|
|
@ -142,7 +142,10 @@ RenderBundleBase* RenderBundleEncoder::APIFinish(const RenderBundleDescriptor* d
|
||||||
|
|
||||||
if (GetDevice()->ConsumedError(FinishImpl(descriptor), &result, "calling %s.Finish(%s).", this,
|
if (GetDevice()->ConsumedError(FinishImpl(descriptor), &result, "calling %s.Finish(%s).", this,
|
||||||
descriptor)) {
|
descriptor)) {
|
||||||
return RenderBundleBase::MakeError(GetDevice(), descriptor ? descriptor->label : nullptr);
|
RenderBundleBase* errorRenderBundle =
|
||||||
|
RenderBundleBase::MakeError(GetDevice(), descriptor ? descriptor->label : nullptr);
|
||||||
|
errorRenderBundle->SetEncoderLabel(this->GetLabel());
|
||||||
|
return errorRenderBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "dawn/native/Texture.h"
|
#include "dawn/native/Texture.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "dawn/common/Assert.h"
|
#include "dawn/common/Assert.h"
|
||||||
#include "dawn/common/Constants.h"
|
#include "dawn/common/Constants.h"
|
||||||
|
@ -865,6 +866,24 @@ ObjectType TextureViewBase::GetType() const {
|
||||||
return ObjectType::TextureView;
|
return ObjectType::TextureView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextureViewBase::FormatLabel(absl::FormatSink* s) const {
|
||||||
|
s->Append(ObjectTypeAsString(GetType()));
|
||||||
|
|
||||||
|
const std::string& label = GetLabel();
|
||||||
|
if (!label.empty()) {
|
||||||
|
s->Append(absl::StrFormat(" \"%s\"", label));
|
||||||
|
}
|
||||||
|
if (IsError()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& textureLabel = mTexture->GetLabel();
|
||||||
|
if (!textureLabel.empty()) {
|
||||||
|
s->Append(" of ");
|
||||||
|
GetTexture()->FormatLabel(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const TextureBase* TextureViewBase::GetTexture() const {
|
const TextureBase* TextureViewBase::GetTexture() const {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
return mTexture.Get();
|
return mTexture.Get();
|
||||||
|
|
|
@ -143,6 +143,7 @@ class TextureViewBase : public ApiObjectBase {
|
||||||
static TextureViewBase* MakeError(DeviceBase* device, const char* label = nullptr);
|
static TextureViewBase* MakeError(DeviceBase* device, const char* label = nullptr);
|
||||||
|
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
void FormatLabel(absl::FormatSink* s) const override;
|
||||||
|
|
||||||
const TextureBase* GetTexture() const;
|
const TextureBase* GetTexture() const;
|
||||||
TextureBase* GetTexture();
|
TextureBase* GetTexture();
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "dawn/native/Format.h"
|
#include "dawn/native/Format.h"
|
||||||
#include "dawn/native/ObjectBase.h"
|
#include "dawn/native/ObjectBase.h"
|
||||||
#include "dawn/native/PerStage.h"
|
#include "dawn/native/PerStage.h"
|
||||||
|
#include "dawn/native/ProgrammableEncoder.h"
|
||||||
#include "dawn/native/ShaderModule.h"
|
#include "dawn/native/ShaderModule.h"
|
||||||
#include "dawn/native/Subresource.h"
|
#include "dawn/native/Subresource.h"
|
||||||
#include "dawn/native/Surface.h"
|
#include "dawn/native/Surface.h"
|
||||||
|
@ -156,36 +157,7 @@ absl::FormatConvertResult<absl::FormatConversionCharSet::kString> AbslFormatConv
|
||||||
if (value->IsError()) {
|
if (value->IsError()) {
|
||||||
s->Append("Invalid ");
|
s->Append("Invalid ");
|
||||||
}
|
}
|
||||||
s->Append(ObjectTypeAsString(value->GetType()));
|
value->FormatLabel(s);
|
||||||
const std::string& label = value->GetLabel();
|
|
||||||
if (!label.empty()) {
|
|
||||||
s->Append(absl::StrFormat(" \"%s\"", label));
|
|
||||||
}
|
|
||||||
s->Append("]");
|
|
||||||
return {true};
|
|
||||||
}
|
|
||||||
|
|
||||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString> AbslFormatConvert(
|
|
||||||
const TextureViewBase* value,
|
|
||||||
const absl::FormatConversionSpec& spec,
|
|
||||||
absl::FormatSink* s) {
|
|
||||||
if (value == nullptr) {
|
|
||||||
s->Append("[null]");
|
|
||||||
return {true};
|
|
||||||
}
|
|
||||||
s->Append("[");
|
|
||||||
if (value->IsError()) {
|
|
||||||
s->Append("Invalid ");
|
|
||||||
}
|
|
||||||
s->Append(ObjectTypeAsString(value->GetType()));
|
|
||||||
const std::string& label = value->GetLabel();
|
|
||||||
if (!label.empty()) {
|
|
||||||
s->Append(absl::StrFormat(" \"%s\"", label));
|
|
||||||
}
|
|
||||||
const std::string& textureLabel = value->GetTexture()->GetLabel();
|
|
||||||
if (!textureLabel.empty()) {
|
|
||||||
s->Append(absl::StrFormat(" of Texture \"%s\"", textureLabel));
|
|
||||||
}
|
|
||||||
s->Append("]");
|
s->Append("]");
|
||||||
return {true};
|
return {true};
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,14 +75,6 @@ absl::FormatConvertResult<absl::FormatConversionCharSet::kString> AbslFormatConv
|
||||||
const absl::FormatConversionSpec& spec,
|
const absl::FormatConversionSpec& spec,
|
||||||
absl::FormatSink* s);
|
absl::FormatSink* s);
|
||||||
|
|
||||||
// Special case for TextureViews, since frequently the texture will be the
|
|
||||||
// thing that's labeled.
|
|
||||||
class TextureViewBase;
|
|
||||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString> AbslFormatConvert(
|
|
||||||
const TextureViewBase* value,
|
|
||||||
const absl::FormatConversionSpec& spec,
|
|
||||||
absl::FormatSink* s);
|
|
||||||
|
|
||||||
class AttachmentState;
|
class AttachmentState;
|
||||||
absl::FormatConvertResult<absl::FormatConversionCharSet::kString> AbslFormatConvert(
|
absl::FormatConvertResult<absl::FormatConversionCharSet::kString> AbslFormatConvert(
|
||||||
const AttachmentState* value,
|
const AttachmentState* value,
|
||||||
|
|
Loading…
Reference in New Issue