Add label tracking for several object types

Adds label tracking for:
 - BindGroup
 - BindGroupLayout
 - PipelineLayout
 - TextureView
 - ExternalTexture
 - Sampler
 - QuerySet

Labels are passed to Vulkan and D3D12 where applicable, though many of
the related structures don't appear to be labelable objects in D3D12.

Bug: dawn:840
Change-Id: Ic7073dc9c02c9fb05bb46f2f8a84e575d5ba5c16
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70180
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
This commit is contained in:
Brandon Jones 2021-11-19 18:26:08 +00:00 committed by Dawn LUCI CQ
parent 2dcbcd1c3f
commit 88aeeae41b
23 changed files with 420 additions and 22 deletions

View File

@ -142,7 +142,18 @@
] ]
}, },
"bind group": { "bind group": {
"category": "object" "category": "object",
"methods": [
{
"name": "set label",
"returns": "void",
"tags": ["dawn"],
"_TODO": "needs an upstream equivalent",
"args": [
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
]
}
]
}, },
"bind group entry": { "bind group entry": {
"category": "structure", "category": "structure",
@ -167,7 +178,18 @@
] ]
}, },
"bind group layout": { "bind group layout": {
"category": "object" "category": "object",
"methods": [
{
"name": "set label",
"returns": "void",
"tags": ["dawn"],
"_TODO": "needs an upstream equivalent",
"args": [
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
]
}
]
}, },
"buffer binding type": { "buffer binding type": {
@ -1170,6 +1192,15 @@
"category": "object", "category": "object",
"tags": ["dawn"], "tags": ["dawn"],
"methods": [ "methods": [
{
"name": "set label",
"returns": "void",
"tags": ["dawn"],
"_TODO": "needs an upstream equivalent",
"args": [
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
]
},
{ {
"name": "destroy", "name": "destroy",
"returns": "void" "returns": "void"
@ -1334,7 +1365,18 @@
] ]
}, },
"pipeline layout": { "pipeline layout": {
"category": "object" "category": "object",
"methods": [
{
"name": "set label",
"returns": "void",
"tags": ["dawn"],
"_TODO": "needs an upstream equivalent",
"args": [
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
]
}
]
}, },
"pipeline layout descriptor": { "pipeline layout descriptor": {
"category": "structure", "category": "structure",
@ -1396,6 +1438,15 @@
"query set": { "query set": {
"category": "object", "category": "object",
"methods": [ "methods": [
{
"name": "set label",
"returns": "void",
"tags": ["dawn"],
"_TODO": "needs an upstream equivalent",
"args": [
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
]
},
{ {
"name": "destroy" "name": "destroy"
} }
@ -1978,7 +2029,18 @@
}, },
"sampler": { "sampler": {
"category": "object" "category": "object",
"methods": [
{
"name": "set label",
"returns": "void",
"tags": ["dawn"],
"_TODO": "needs an upstream equivalent",
"args": [
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
]
}
]
}, },
"sampler descriptor": { "sampler descriptor": {
"category": "structure", "category": "structure",
@ -2400,7 +2462,18 @@
] ]
}, },
"texture view": { "texture view": {
"category": "object" "category": "object",
"methods": [
{
"name": "set label",
"returns": "void",
"tags": ["dawn"],
"_TODO": "needs an upstream equivalent",
"args": [
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
]
}
]
}, },
"texture view dimension": { "texture view dimension": {
"category": "enum", "category": "enum",

View File

@ -331,7 +331,7 @@ namespace dawn_native {
BindGroupBase::BindGroupBase(DeviceBase* device, BindGroupBase::BindGroupBase(DeviceBase* device,
const BindGroupDescriptor* descriptor, const BindGroupDescriptor* descriptor,
void* bindingDataStart) void* bindingDataStart)
: ApiObjectBase(device, kLabelNotImplemented), : ApiObjectBase(device, descriptor->label),
mLayout(descriptor->layout), mLayout(descriptor->layout),
mBindingData(mLayout->ComputeBindingDataPointers(bindingDataStart)) { mBindingData(mLayout->ComputeBindingDataPointers(bindingDataStart)) {
for (BindingIndex i{0}; i < mLayout->GetBindingCount(); ++i) { for (BindingIndex i{0}; i < mLayout->GetBindingCount(); ++i) {

View File

@ -374,7 +374,7 @@ namespace dawn_native {
const BindGroupLayoutDescriptor* descriptor, const BindGroupLayoutDescriptor* descriptor,
PipelineCompatibilityToken pipelineCompatibilityToken, PipelineCompatibilityToken pipelineCompatibilityToken,
ApiObjectBase::UntrackedByDeviceTag tag) ApiObjectBase::UntrackedByDeviceTag tag)
: ApiObjectBase(device, kLabelNotImplemented), : ApiObjectBase(device, descriptor->label),
mBindingInfo(BindingIndex(descriptor->entryCount)), mBindingInfo(BindingIndex(descriptor->entryCount)),
mPipelineCompatibilityToken(pipelineCompatibilityToken) { mPipelineCompatibilityToken(pipelineCompatibilityToken) {
std::vector<BindGroupLayoutEntry> sortedBindings( std::vector<BindGroupLayoutEntry> sortedBindings(

View File

@ -89,7 +89,7 @@ namespace dawn_native {
ExternalTextureBase::ExternalTextureBase(DeviceBase* device, ExternalTextureBase::ExternalTextureBase(DeviceBase* device,
const ExternalTextureDescriptor* descriptor) const ExternalTextureDescriptor* descriptor)
: ApiObjectBase(device, kLabelNotImplemented), mState(ExternalTextureState::Alive) { : ApiObjectBase(device, descriptor->label), mState(ExternalTextureState::Alive) {
textureViews[0] = descriptor->plane0; textureViews[0] = descriptor->plane0;
TrackInDevice(); TrackInDevice();
} }

View File

@ -59,7 +59,7 @@ namespace dawn_native {
PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device, PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device,
const PipelineLayoutDescriptor* descriptor, const PipelineLayoutDescriptor* descriptor,
ApiObjectBase::UntrackedByDeviceTag tag) ApiObjectBase::UntrackedByDeviceTag tag)
: ApiObjectBase(device, kLabelNotImplemented) { : ApiObjectBase(device, descriptor->label) {
ASSERT(descriptor->bindGroupLayoutCount <= kMaxBindGroups); ASSERT(descriptor->bindGroupLayoutCount <= kMaxBindGroups);
for (BindGroupIndex group(0); group < BindGroupIndex(descriptor->bindGroupLayoutCount); for (BindGroupIndex group(0); group < BindGroupIndex(descriptor->bindGroupLayoutCount);
++group) { ++group) {

View File

@ -101,7 +101,7 @@ namespace dawn_native {
} }
QuerySetBase::QuerySetBase(DeviceBase* device, const QuerySetDescriptor* descriptor) QuerySetBase::QuerySetBase(DeviceBase* device, const QuerySetDescriptor* descriptor)
: ApiObjectBase(device, kLabelNotImplemented), : ApiObjectBase(device, descriptor->label),
mQueryType(descriptor->type), mQueryType(descriptor->type),
mQueryCount(descriptor->count), mQueryCount(descriptor->count),
mState(QuerySetState::Available) { mState(QuerySetState::Available) {

View File

@ -72,7 +72,7 @@ namespace dawn_native {
SamplerBase::SamplerBase(DeviceBase* device, SamplerBase::SamplerBase(DeviceBase* device,
const SamplerDescriptor* descriptor, const SamplerDescriptor* descriptor,
ApiObjectBase::UntrackedByDeviceTag tag) ApiObjectBase::UntrackedByDeviceTag tag)
: ApiObjectBase(device, kLabelNotImplemented), : ApiObjectBase(device, descriptor->label),
mAddressModeU(descriptor->addressModeU), mAddressModeU(descriptor->addressModeU),
mAddressModeV(descriptor->addressModeV), mAddressModeV(descriptor->addressModeV),
mAddressModeW(descriptor->addressModeW), mAddressModeW(descriptor->addressModeW),

View File

@ -697,7 +697,7 @@ namespace dawn_native {
// TextureViewBase // TextureViewBase
TextureViewBase::TextureViewBase(TextureBase* texture, const TextureViewDescriptor* descriptor) TextureViewBase::TextureViewBase(TextureBase* texture, const TextureViewDescriptor* descriptor)
: ApiObjectBase(texture->GetDevice(), kLabelNotImplemented), : ApiObjectBase(texture->GetDevice(), descriptor->label),
mTexture(texture), mTexture(texture),
mFormat(GetDevice()->GetValidInternalFormat(descriptor->format)), mFormat(GetDevice()->GetValidInternalFormat(descriptor->format)),
mDimension(descriptor->dimension), mDimension(descriptor->dimension),

View File

@ -16,6 +16,7 @@
#include "dawn_native/d3d12/D3D12Error.h" #include "dawn_native/d3d12/D3D12Error.h"
#include "dawn_native/d3d12/DeviceD3D12.h" #include "dawn_native/d3d12/DeviceD3D12.h"
#include "dawn_native/d3d12/UtilsD3D12.h"
namespace dawn_native { namespace d3d12 { namespace dawn_native { namespace d3d12 {
@ -46,9 +47,13 @@ namespace dawn_native { namespace d3d12 {
queryHeapDesc.Count = std::max(GetQueryCount(), uint32_t(1u)); queryHeapDesc.Count = std::max(GetQueryCount(), uint32_t(1u));
ID3D12Device* d3d12Device = ToBackend(GetDevice())->GetD3D12Device(); ID3D12Device* d3d12Device = ToBackend(GetDevice())->GetD3D12Device();
return CheckOutOfMemoryHRESULT( DAWN_TRY(CheckOutOfMemoryHRESULT(
d3d12Device->CreateQueryHeap(&queryHeapDesc, IID_PPV_ARGS(&mQueryHeap)), d3d12Device->CreateQueryHeap(&queryHeapDesc, IID_PPV_ARGS(&mQueryHeap)),
"ID3D12Device::CreateQueryHeap"); "ID3D12Device::CreateQueryHeap"));
SetLabelImpl();
return {};
} }
ID3D12QueryHeap* QuerySet::GetQueryHeap() const { ID3D12QueryHeap* QuerySet::GetQueryHeap() const {
@ -62,4 +67,8 @@ namespace dawn_native { namespace d3d12 {
mQueryHeap = nullptr; mQueryHeap = nullptr;
} }
void QuerySet::SetLabelImpl() {
SetDebugName(ToBackend(GetDevice()), mQueryHeap.Get(), "Dawn_QuerySet", GetLabel());
}
}} // namespace dawn_native::d3d12 }} // namespace dawn_native::d3d12

View File

@ -36,6 +36,7 @@ namespace dawn_native { namespace d3d12 {
// Dawn API // Dawn API
void DestroyImpl() override; void DestroyImpl() override;
void SetLabelImpl() override;
ComPtr<ID3D12QueryHeap> mQueryHeap; ComPtr<ID3D12QueryHeap> mQueryHeap;
}; };

View File

@ -20,6 +20,7 @@
#include "dawn_native/vulkan/DescriptorSetAllocator.h" #include "dawn_native/vulkan/DescriptorSetAllocator.h"
#include "dawn_native/vulkan/DeviceVk.h" #include "dawn_native/vulkan/DeviceVk.h"
#include "dawn_native/vulkan/FencedDeleter.h" #include "dawn_native/vulkan/FencedDeleter.h"
#include "dawn_native/vulkan/UtilsVulkan.h"
#include "dawn_native/vulkan/VulkanError.h" #include "dawn_native/vulkan/VulkanError.h"
#include <map> #include <map>
@ -138,6 +139,9 @@ namespace dawn_native { namespace vulkan {
// counts. // counts.
mDescriptorSetAllocator = mDescriptorSetAllocator =
std::make_unique<DescriptorSetAllocator>(this, std::move(descriptorCountPerType)); std::make_unique<DescriptorSetAllocator>(this, std::move(descriptorCountPerType));
SetLabelImpl();
return {}; return {};
} }
@ -187,4 +191,9 @@ namespace dawn_native { namespace vulkan {
mDescriptorSetAllocator->FinishDeallocation(completedSerial); mDescriptorSetAllocator->FinishDeallocation(completedSerial);
} }
void BindGroupLayout::SetLabelImpl() {
SetDebugName(ToBackend(GetDevice()), VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT,
reinterpret_cast<uint64_t&>(mHandle), "Dawn_BindGroupLayout", GetLabel());
}
}} // namespace dawn_native::vulkan }} // namespace dawn_native::vulkan

View File

@ -66,6 +66,9 @@ namespace dawn_native { namespace vulkan {
~BindGroupLayout() override; ~BindGroupLayout() override;
MaybeError Initialize(); MaybeError Initialize();
// Dawn API
void SetLabelImpl() override;
VkDescriptorSetLayout mHandle = VK_NULL_HANDLE; VkDescriptorSetLayout mHandle = VK_NULL_HANDLE;
SlabAllocator<BindGroup> mBindGroupAllocator; SlabAllocator<BindGroup> mBindGroupAllocator;

View File

@ -23,6 +23,7 @@
#include "dawn_native/vulkan/FencedDeleter.h" #include "dawn_native/vulkan/FencedDeleter.h"
#include "dawn_native/vulkan/SamplerVk.h" #include "dawn_native/vulkan/SamplerVk.h"
#include "dawn_native/vulkan/TextureVk.h" #include "dawn_native/vulkan/TextureVk.h"
#include "dawn_native/vulkan/UtilsVulkan.h"
#include "dawn_native/vulkan/VulkanError.h" #include "dawn_native/vulkan/VulkanError.h"
namespace dawn_native { namespace vulkan { namespace dawn_native { namespace vulkan {
@ -156,6 +157,8 @@ namespace dawn_native { namespace vulkan {
// TODO(crbug.com/dawn/855): Batch these updates // TODO(crbug.com/dawn/855): Batch these updates
device->fn.UpdateDescriptorSets(device->GetVkDevice(), numWrites, writes.data(), 0, device->fn.UpdateDescriptorSets(device->GetVkDevice(), numWrites, writes.data(), 0,
nullptr); nullptr);
SetLabelImpl();
} }
BindGroup::~BindGroup() = default; BindGroup::~BindGroup() = default;
@ -168,4 +171,10 @@ namespace dawn_native { namespace vulkan {
return mDescriptorSetAllocation.set; return mDescriptorSetAllocation.set;
} }
void BindGroup::SetLabelImpl() {
SetDebugName(ToBackend(GetDevice()), VK_OBJECT_TYPE_DESCRIPTOR_SET,
reinterpret_cast<uint64_t&>(mDescriptorSetAllocation.set), "Dawn_BindGroup",
GetLabel());
}
}} // namespace dawn_native::vulkan }} // namespace dawn_native::vulkan

View File

@ -42,6 +42,9 @@ namespace dawn_native { namespace vulkan {
void DestroyImpl() override; void DestroyImpl() override;
// Dawn API
void SetLabelImpl() override;
// The descriptor set in this allocation outlives the BindGroup because it is owned by // The descriptor set in this allocation outlives the BindGroup because it is owned by
// the BindGroupLayout which is referenced by the BindGroup. // the BindGroupLayout which is referenced by the BindGroup.
DescriptorSetAllocation mDescriptorSetAllocation; DescriptorSetAllocation mDescriptorSetAllocation;

View File

@ -18,6 +18,7 @@
#include "dawn_native/vulkan/BindGroupLayoutVk.h" #include "dawn_native/vulkan/BindGroupLayoutVk.h"
#include "dawn_native/vulkan/DeviceVk.h" #include "dawn_native/vulkan/DeviceVk.h"
#include "dawn_native/vulkan/FencedDeleter.h" #include "dawn_native/vulkan/FencedDeleter.h"
#include "dawn_native/vulkan/UtilsVulkan.h"
#include "dawn_native/vulkan/VulkanError.h" #include "dawn_native/vulkan/VulkanError.h"
namespace dawn_native { namespace vulkan { namespace dawn_native { namespace vulkan {
@ -52,9 +53,13 @@ namespace dawn_native { namespace vulkan {
createInfo.pPushConstantRanges = nullptr; createInfo.pPushConstantRanges = nullptr;
Device* device = ToBackend(GetDevice()); Device* device = ToBackend(GetDevice());
return CheckVkSuccess( DAWN_TRY(CheckVkSuccess(
device->fn.CreatePipelineLayout(device->GetVkDevice(), &createInfo, nullptr, &*mHandle), device->fn.CreatePipelineLayout(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
"CreatePipelineLayout"); "CreatePipelineLayout"));
SetLabelImpl();
return {};
} }
PipelineLayout::~PipelineLayout() = default; PipelineLayout::~PipelineLayout() = default;
@ -70,4 +75,9 @@ namespace dawn_native { namespace vulkan {
return mHandle; return mHandle;
} }
void PipelineLayout::SetLabelImpl() {
SetDebugName(ToBackend(GetDevice()), VK_OBJECT_TYPE_PIPELINE_LAYOUT,
reinterpret_cast<uint64_t&>(mHandle), "Dawn_PipelineLayout", GetLabel());
}
}} // namespace dawn_native::vulkan }} // namespace dawn_native::vulkan

View File

@ -39,6 +39,9 @@ namespace dawn_native { namespace vulkan {
using PipelineLayoutBase::PipelineLayoutBase; using PipelineLayoutBase::PipelineLayoutBase;
MaybeError Initialize(); MaybeError Initialize();
// Dawn API
void SetLabelImpl() override;
VkPipelineLayout mHandle = VK_NULL_HANDLE; VkPipelineLayout mHandle = VK_NULL_HANDLE;
}; };

View File

@ -16,6 +16,7 @@
#include "dawn_native/vulkan/DeviceVk.h" #include "dawn_native/vulkan/DeviceVk.h"
#include "dawn_native/vulkan/FencedDeleter.h" #include "dawn_native/vulkan/FencedDeleter.h"
#include "dawn_native/vulkan/UtilsVulkan.h"
#include "dawn_native/vulkan/VulkanError.h" #include "dawn_native/vulkan/VulkanError.h"
#include "dawn_platform/DawnPlatform.h" #include "dawn_platform/DawnPlatform.h"
@ -85,9 +86,13 @@ namespace dawn_native { namespace vulkan {
} }
Device* device = ToBackend(GetDevice()); Device* device = ToBackend(GetDevice());
return CheckVkOOMThenSuccess( DAWN_TRY(CheckVkOOMThenSuccess(
device->fn.CreateQueryPool(device->GetVkDevice(), &createInfo, nullptr, &*mHandle), device->fn.CreateQueryPool(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
"vkCreateQueryPool"); "vkCreateQueryPool"));
SetLabelImpl();
return {};
} }
VkQueryPool QuerySet::GetHandle() const { VkQueryPool QuerySet::GetHandle() const {
@ -103,4 +108,9 @@ namespace dawn_native { namespace vulkan {
} }
} }
void QuerySet::SetLabelImpl() {
SetDebugName(ToBackend(GetDevice()), VK_OBJECT_TYPE_QUERY_POOL,
reinterpret_cast<uint64_t&>(mHandle), "Dawn_QuerySet", GetLabel());
}
}} // namespace dawn_native::vulkan }} // namespace dawn_native::vulkan

View File

@ -35,7 +35,9 @@ namespace dawn_native { namespace vulkan {
using QuerySetBase::QuerySetBase; using QuerySetBase::QuerySetBase;
MaybeError Initialize(); MaybeError Initialize();
// Dawn API
void DestroyImpl() override; void DestroyImpl() override;
void SetLabelImpl() override;
VkQueryPool mHandle = VK_NULL_HANDLE; VkQueryPool mHandle = VK_NULL_HANDLE;
}; };

View File

@ -100,9 +100,13 @@ namespace dawn_native { namespace vulkan {
createInfo.maxAnisotropy = 1; createInfo.maxAnisotropy = 1;
} }
return CheckVkSuccess( DAWN_TRY(CheckVkSuccess(
device->fn.CreateSampler(device->GetVkDevice(), &createInfo, nullptr, &*mHandle), device->fn.CreateSampler(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
"CreateSampler"); "CreateSampler"));
SetLabelImpl();
return {};
} }
Sampler::~Sampler() = default; Sampler::~Sampler() = default;
@ -118,4 +122,9 @@ namespace dawn_native { namespace vulkan {
return mHandle; return mHandle;
} }
void Sampler::SetLabelImpl() {
SetDebugName(ToBackend(GetDevice()), VK_OBJECT_TYPE_SAMPLER,
reinterpret_cast<uint64_t&>(mHandle), "Dawn_Sampler", GetLabel());
}
}} // namespace dawn_native::vulkan }} // namespace dawn_native::vulkan

View File

@ -37,6 +37,9 @@ namespace dawn_native { namespace vulkan {
using SamplerBase::SamplerBase; using SamplerBase::SamplerBase;
MaybeError Initialize(const SamplerDescriptor* descriptor); MaybeError Initialize(const SamplerDescriptor* descriptor);
// Dawn API
void SetLabelImpl() override;
VkSampler mHandle = VK_NULL_HANDLE; VkSampler mHandle = VK_NULL_HANDLE;
}; };

View File

@ -1293,9 +1293,13 @@ namespace dawn_native { namespace vulkan {
createInfo.subresourceRange.layerCount = subresources.layerCount; createInfo.subresourceRange.layerCount = subresources.layerCount;
createInfo.subresourceRange.aspectMask = VulkanAspectMask(subresources.aspects); createInfo.subresourceRange.aspectMask = VulkanAspectMask(subresources.aspects);
return CheckVkSuccess( DAWN_TRY(CheckVkSuccess(
device->fn.CreateImageView(device->GetVkDevice(), &createInfo, nullptr, &*mHandle), device->fn.CreateImageView(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
"CreateImageView"); "CreateImageView"));
SetLabelImpl();
return {};
} }
TextureView::~TextureView() { TextureView::~TextureView() {
@ -1314,4 +1318,9 @@ namespace dawn_native { namespace vulkan {
return mHandle; return mHandle;
} }
void TextureView::SetLabelImpl() {
SetDebugName(ToBackend(GetDevice()), VK_OBJECT_TYPE_IMAGE_VIEW,
reinterpret_cast<uint64_t&>(mHandle), "Dawn_InternalTextureView", GetLabel());
}
}} // namespace dawn_native::vulkan }} // namespace dawn_native::vulkan

View File

@ -180,6 +180,9 @@ namespace dawn_native { namespace vulkan {
using TextureViewBase::TextureViewBase; using TextureViewBase::TextureViewBase;
MaybeError Initialize(const TextureViewDescriptor* descriptor); MaybeError Initialize(const TextureViewDescriptor* descriptor);
// Dawn API
void SetLabelImpl() override;
VkImageView mHandle = VK_NULL_HANDLE; VkImageView mHandle = VK_NULL_HANDLE;
}; };

View File

@ -19,6 +19,72 @@
class LabelTest : public ValidationTest {}; class LabelTest : public ValidationTest {};
TEST_F(LabelTest, BindGroup) {
DAWN_SKIP_TEST_IF(UsesWire());
std::string label = "test";
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {});
wgpu::BindGroupDescriptor descriptor;
descriptor.layout = layout;
descriptor.entryCount = 0;
descriptor.entries = nullptr;
// The label should be empty if one was not set.
{
wgpu::BindGroup bindGroup = device.CreateBindGroup(&descriptor);
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(bindGroup.Get());
ASSERT_TRUE(readbackLabel.empty());
}
// Test setting a label through API
{
wgpu::BindGroup bindGroup = device.CreateBindGroup(&descriptor);
bindGroup.SetLabel(label.c_str());
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(bindGroup.Get());
ASSERT_EQ(label, readbackLabel);
}
// Test setting a label through the descriptor.
{
descriptor.label = label.c_str();
wgpu::BindGroup bindGroup = device.CreateBindGroup(&descriptor);
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(bindGroup.Get());
ASSERT_EQ(label, readbackLabel);
}
}
TEST_F(LabelTest, BindGroupLayout) {
DAWN_SKIP_TEST_IF(UsesWire());
std::string label = "test";
wgpu::BindGroupLayoutDescriptor descriptor = {};
descriptor.entryCount = 0;
descriptor.entries = nullptr;
// The label should be empty if one was not set.
{
wgpu::BindGroupLayout bindGroupLayout = device.CreateBindGroupLayout(&descriptor);
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(bindGroupLayout.Get());
ASSERT_TRUE(readbackLabel.empty());
}
// Test setting a label through API
{
wgpu::BindGroupLayout bindGroupLayout = device.CreateBindGroupLayout(&descriptor);
bindGroupLayout.SetLabel(label.c_str());
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(bindGroupLayout.Get());
ASSERT_EQ(label, readbackLabel);
}
// Test setting a label through the descriptor.
{
descriptor.label = label.c_str();
wgpu::BindGroupLayout bindGroupLayout = device.CreateBindGroupLayout(&descriptor);
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(bindGroupLayout.Get());
ASSERT_EQ(label, readbackLabel);
}
}
TEST_F(LabelTest, Buffer) { TEST_F(LabelTest, Buffer) {
DAWN_SKIP_TEST_IF(UsesWire()); DAWN_SKIP_TEST_IF(UsesWire());
std::string label = "test"; std::string label = "test";
@ -50,6 +116,142 @@ TEST_F(LabelTest, Buffer) {
} }
} }
TEST_F(LabelTest, ExternalTexture) {
DAWN_SKIP_TEST_IF(UsesWire());
std::string label = "test";
wgpu::TextureDescriptor textureDescriptor;
textureDescriptor.size.width = 1;
textureDescriptor.size.height = 1;
textureDescriptor.size.depthOrArrayLayers = 1;
textureDescriptor.mipLevelCount = 1;
textureDescriptor.sampleCount = 1;
textureDescriptor.dimension = wgpu::TextureDimension::e2D;
textureDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
textureDescriptor.usage =
wgpu::TextureUsage::TextureBinding | wgpu::TextureUsage::RenderAttachment;
wgpu::Texture texture = device.CreateTexture(&textureDescriptor);
wgpu::ExternalTextureDescriptor descriptor;
descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
descriptor.plane0 = texture.CreateView();
// The label should be empty if one was not set.
{
wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&descriptor);
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(externalTexture.Get());
ASSERT_TRUE(readbackLabel.empty());
}
// Test setting a label through API
{
wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&descriptor);
externalTexture.SetLabel(label.c_str());
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(externalTexture.Get());
ASSERT_EQ(label, readbackLabel);
}
// Test setting a label through the descriptor.
{
descriptor.label = label.c_str();
wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&descriptor);
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(externalTexture.Get());
ASSERT_EQ(label, readbackLabel);
}
}
TEST_F(LabelTest, PipelineLayout) {
DAWN_SKIP_TEST_IF(UsesWire());
std::string label = "test";
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {});
wgpu::PipelineLayoutDescriptor descriptor;
descriptor.bindGroupLayoutCount = 1;
descriptor.bindGroupLayouts = &layout;
// The label should be empty if one was not set.
{
wgpu::PipelineLayout pipelineLayout = device.CreatePipelineLayout(&descriptor);
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(pipelineLayout.Get());
ASSERT_TRUE(readbackLabel.empty());
}
// Test setting a label through API
{
wgpu::PipelineLayout pipelineLayout = device.CreatePipelineLayout(&descriptor);
pipelineLayout.SetLabel(label.c_str());
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(pipelineLayout.Get());
ASSERT_EQ(label, readbackLabel);
}
// Test setting a label through the descriptor.
{
descriptor.label = label.c_str();
wgpu::PipelineLayout pipelineLayout = device.CreatePipelineLayout(&descriptor);
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(pipelineLayout.Get());
ASSERT_EQ(label, readbackLabel);
}
}
TEST_F(LabelTest, QuerySet) {
DAWN_SKIP_TEST_IF(UsesWire());
std::string label = "test";
wgpu::QuerySetDescriptor descriptor;
descriptor.type = wgpu::QueryType::Occlusion;
descriptor.count = 1;
// The label should be empty if one was not set.
{
wgpu::QuerySet querySet = device.CreateQuerySet(&descriptor);
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(querySet.Get());
ASSERT_TRUE(readbackLabel.empty());
}
// Test setting a label through API
{
wgpu::QuerySet querySet = device.CreateQuerySet(&descriptor);
querySet.SetLabel(label.c_str());
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(querySet.Get());
ASSERT_EQ(label, readbackLabel);
}
// Test setting a label through the descriptor.
{
descriptor.label = label.c_str();
wgpu::QuerySet querySet = device.CreateQuerySet(&descriptor);
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(querySet.Get());
ASSERT_EQ(label, readbackLabel);
}
}
TEST_F(LabelTest, Sampler) {
DAWN_SKIP_TEST_IF(UsesWire());
std::string label = "test";
wgpu::SamplerDescriptor descriptor;
// The label should be empty if one was not set.
{
wgpu::Sampler sampler = device.CreateSampler(&descriptor);
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(sampler.Get());
ASSERT_TRUE(readbackLabel.empty());
}
// Test setting a label through API
{
wgpu::Sampler sampler = device.CreateSampler(&descriptor);
sampler.SetLabel(label.c_str());
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(sampler.Get());
ASSERT_EQ(label, readbackLabel);
}
// Test setting a label through the descriptor.
{
descriptor.label = label.c_str();
wgpu::Sampler sampler = device.CreateSampler(&descriptor);
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(sampler.Get());
ASSERT_EQ(label, readbackLabel);
}
}
TEST_F(LabelTest, Texture) { TEST_F(LabelTest, Texture) {
DAWN_SKIP_TEST_IF(UsesWire()); DAWN_SKIP_TEST_IF(UsesWire());
std::string label = "test"; std::string label = "test";
@ -87,6 +289,46 @@ TEST_F(LabelTest, Texture) {
} }
} }
TEST_F(LabelTest, TextureView) {
DAWN_SKIP_TEST_IF(UsesWire());
std::string label = "test";
wgpu::TextureDescriptor descriptor;
descriptor.size.width = 1;
descriptor.size.height = 1;
descriptor.size.depthOrArrayLayers = 1;
descriptor.mipLevelCount = 1;
descriptor.sampleCount = 1;
descriptor.dimension = wgpu::TextureDimension::e2D;
descriptor.format = wgpu::TextureFormat::RGBA8Uint;
descriptor.usage = wgpu::TextureUsage::RenderAttachment | wgpu::TextureUsage::TextureBinding;
wgpu::Texture texture = device.CreateTexture(&descriptor);
// The label should be empty if one was not set.
{
wgpu::TextureView textureView = texture.CreateView();
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(textureView.Get());
ASSERT_TRUE(readbackLabel.empty());
}
// Test setting a label through API
{
wgpu::TextureView textureView = texture.CreateView();
textureView.SetLabel(label.c_str());
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(textureView.Get());
ASSERT_EQ(label, readbackLabel);
}
// Test setting a label through the descriptor.
{
wgpu::TextureViewDescriptor viewDescriptor;
viewDescriptor.label = label.c_str();
wgpu::TextureView textureView = texture.CreateView(&viewDescriptor);
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(textureView.Get());
ASSERT_EQ(label, readbackLabel);
}
}
TEST_F(LabelTest, RenderPipeline) { TEST_F(LabelTest, RenderPipeline) {
DAWN_SKIP_TEST_IF(UsesWire()); DAWN_SKIP_TEST_IF(UsesWire());
std::string label = "test"; std::string label = "test";