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:
parent
2dcbcd1c3f
commit
88aeeae41b
83
dawn.json
83
dawn.json
|
@ -142,7 +142,18 @@
|
|||
]
|
||||
},
|
||||
"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": {
|
||||
"category": "structure",
|
||||
|
@ -167,7 +178,18 @@
|
|||
]
|
||||
},
|
||||
"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": {
|
||||
|
@ -1170,6 +1192,15 @@
|
|||
"category": "object",
|
||||
"tags": ["dawn"],
|
||||
"methods": [
|
||||
{
|
||||
"name": "set label",
|
||||
"returns": "void",
|
||||
"tags": ["dawn"],
|
||||
"_TODO": "needs an upstream equivalent",
|
||||
"args": [
|
||||
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "destroy",
|
||||
"returns": "void"
|
||||
|
@ -1334,7 +1365,18 @@
|
|||
]
|
||||
},
|
||||
"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": {
|
||||
"category": "structure",
|
||||
|
@ -1396,6 +1438,15 @@
|
|||
"query set": {
|
||||
"category": "object",
|
||||
"methods": [
|
||||
{
|
||||
"name": "set label",
|
||||
"returns": "void",
|
||||
"tags": ["dawn"],
|
||||
"_TODO": "needs an upstream equivalent",
|
||||
"args": [
|
||||
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "destroy"
|
||||
}
|
||||
|
@ -1978,7 +2029,18 @@
|
|||
},
|
||||
|
||||
"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": {
|
||||
"category": "structure",
|
||||
|
@ -2400,7 +2462,18 @@
|
|||
]
|
||||
},
|
||||
"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": {
|
||||
"category": "enum",
|
||||
|
|
|
@ -331,7 +331,7 @@ namespace dawn_native {
|
|||
BindGroupBase::BindGroupBase(DeviceBase* device,
|
||||
const BindGroupDescriptor* descriptor,
|
||||
void* bindingDataStart)
|
||||
: ApiObjectBase(device, kLabelNotImplemented),
|
||||
: ApiObjectBase(device, descriptor->label),
|
||||
mLayout(descriptor->layout),
|
||||
mBindingData(mLayout->ComputeBindingDataPointers(bindingDataStart)) {
|
||||
for (BindingIndex i{0}; i < mLayout->GetBindingCount(); ++i) {
|
||||
|
|
|
@ -374,7 +374,7 @@ namespace dawn_native {
|
|||
const BindGroupLayoutDescriptor* descriptor,
|
||||
PipelineCompatibilityToken pipelineCompatibilityToken,
|
||||
ApiObjectBase::UntrackedByDeviceTag tag)
|
||||
: ApiObjectBase(device, kLabelNotImplemented),
|
||||
: ApiObjectBase(device, descriptor->label),
|
||||
mBindingInfo(BindingIndex(descriptor->entryCount)),
|
||||
mPipelineCompatibilityToken(pipelineCompatibilityToken) {
|
||||
std::vector<BindGroupLayoutEntry> sortedBindings(
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace dawn_native {
|
|||
|
||||
ExternalTextureBase::ExternalTextureBase(DeviceBase* device,
|
||||
const ExternalTextureDescriptor* descriptor)
|
||||
: ApiObjectBase(device, kLabelNotImplemented), mState(ExternalTextureState::Alive) {
|
||||
: ApiObjectBase(device, descriptor->label), mState(ExternalTextureState::Alive) {
|
||||
textureViews[0] = descriptor->plane0;
|
||||
TrackInDevice();
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace dawn_native {
|
|||
PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device,
|
||||
const PipelineLayoutDescriptor* descriptor,
|
||||
ApiObjectBase::UntrackedByDeviceTag tag)
|
||||
: ApiObjectBase(device, kLabelNotImplemented) {
|
||||
: ApiObjectBase(device, descriptor->label) {
|
||||
ASSERT(descriptor->bindGroupLayoutCount <= kMaxBindGroups);
|
||||
for (BindGroupIndex group(0); group < BindGroupIndex(descriptor->bindGroupLayoutCount);
|
||||
++group) {
|
||||
|
|
|
@ -101,7 +101,7 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
QuerySetBase::QuerySetBase(DeviceBase* device, const QuerySetDescriptor* descriptor)
|
||||
: ApiObjectBase(device, kLabelNotImplemented),
|
||||
: ApiObjectBase(device, descriptor->label),
|
||||
mQueryType(descriptor->type),
|
||||
mQueryCount(descriptor->count),
|
||||
mState(QuerySetState::Available) {
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace dawn_native {
|
|||
SamplerBase::SamplerBase(DeviceBase* device,
|
||||
const SamplerDescriptor* descriptor,
|
||||
ApiObjectBase::UntrackedByDeviceTag tag)
|
||||
: ApiObjectBase(device, kLabelNotImplemented),
|
||||
: ApiObjectBase(device, descriptor->label),
|
||||
mAddressModeU(descriptor->addressModeU),
|
||||
mAddressModeV(descriptor->addressModeV),
|
||||
mAddressModeW(descriptor->addressModeW),
|
||||
|
|
|
@ -697,7 +697,7 @@ namespace dawn_native {
|
|||
// TextureViewBase
|
||||
|
||||
TextureViewBase::TextureViewBase(TextureBase* texture, const TextureViewDescriptor* descriptor)
|
||||
: ApiObjectBase(texture->GetDevice(), kLabelNotImplemented),
|
||||
: ApiObjectBase(texture->GetDevice(), descriptor->label),
|
||||
mTexture(texture),
|
||||
mFormat(GetDevice()->GetValidInternalFormat(descriptor->format)),
|
||||
mDimension(descriptor->dimension),
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "dawn_native/d3d12/D3D12Error.h"
|
||||
#include "dawn_native/d3d12/DeviceD3D12.h"
|
||||
#include "dawn_native/d3d12/UtilsD3D12.h"
|
||||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
|
@ -46,9 +47,13 @@ namespace dawn_native { namespace d3d12 {
|
|||
queryHeapDesc.Count = std::max(GetQueryCount(), uint32_t(1u));
|
||||
|
||||
ID3D12Device* d3d12Device = ToBackend(GetDevice())->GetD3D12Device();
|
||||
return CheckOutOfMemoryHRESULT(
|
||||
DAWN_TRY(CheckOutOfMemoryHRESULT(
|
||||
d3d12Device->CreateQueryHeap(&queryHeapDesc, IID_PPV_ARGS(&mQueryHeap)),
|
||||
"ID3D12Device::CreateQueryHeap");
|
||||
"ID3D12Device::CreateQueryHeap"));
|
||||
|
||||
SetLabelImpl();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
ID3D12QueryHeap* QuerySet::GetQueryHeap() const {
|
||||
|
@ -62,4 +67,8 @@ namespace dawn_native { namespace d3d12 {
|
|||
mQueryHeap = nullptr;
|
||||
}
|
||||
|
||||
void QuerySet::SetLabelImpl() {
|
||||
SetDebugName(ToBackend(GetDevice()), mQueryHeap.Get(), "Dawn_QuerySet", GetLabel());
|
||||
}
|
||||
|
||||
}} // namespace dawn_native::d3d12
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
// Dawn API
|
||||
void DestroyImpl() override;
|
||||
void SetLabelImpl() override;
|
||||
|
||||
ComPtr<ID3D12QueryHeap> mQueryHeap;
|
||||
};
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "dawn_native/vulkan/DescriptorSetAllocator.h"
|
||||
#include "dawn_native/vulkan/DeviceVk.h"
|
||||
#include "dawn_native/vulkan/FencedDeleter.h"
|
||||
#include "dawn_native/vulkan/UtilsVulkan.h"
|
||||
#include "dawn_native/vulkan/VulkanError.h"
|
||||
|
||||
#include <map>
|
||||
|
@ -138,6 +139,9 @@ namespace dawn_native { namespace vulkan {
|
|||
// counts.
|
||||
mDescriptorSetAllocator =
|
||||
std::make_unique<DescriptorSetAllocator>(this, std::move(descriptorCountPerType));
|
||||
|
||||
SetLabelImpl();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -187,4 +191,9 @@ namespace dawn_native { namespace vulkan {
|
|||
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
|
||||
|
|
|
@ -66,6 +66,9 @@ namespace dawn_native { namespace vulkan {
|
|||
~BindGroupLayout() override;
|
||||
MaybeError Initialize();
|
||||
|
||||
// Dawn API
|
||||
void SetLabelImpl() override;
|
||||
|
||||
VkDescriptorSetLayout mHandle = VK_NULL_HANDLE;
|
||||
|
||||
SlabAllocator<BindGroup> mBindGroupAllocator;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "dawn_native/vulkan/FencedDeleter.h"
|
||||
#include "dawn_native/vulkan/SamplerVk.h"
|
||||
#include "dawn_native/vulkan/TextureVk.h"
|
||||
#include "dawn_native/vulkan/UtilsVulkan.h"
|
||||
#include "dawn_native/vulkan/VulkanError.h"
|
||||
|
||||
namespace dawn_native { namespace vulkan {
|
||||
|
@ -156,6 +157,8 @@ namespace dawn_native { namespace vulkan {
|
|||
// TODO(crbug.com/dawn/855): Batch these updates
|
||||
device->fn.UpdateDescriptorSets(device->GetVkDevice(), numWrites, writes.data(), 0,
|
||||
nullptr);
|
||||
|
||||
SetLabelImpl();
|
||||
}
|
||||
|
||||
BindGroup::~BindGroup() = default;
|
||||
|
@ -168,4 +171,10 @@ namespace dawn_native { namespace vulkan {
|
|||
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
|
||||
|
|
|
@ -42,6 +42,9 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
void DestroyImpl() override;
|
||||
|
||||
// Dawn API
|
||||
void SetLabelImpl() override;
|
||||
|
||||
// The descriptor set in this allocation outlives the BindGroup because it is owned by
|
||||
// the BindGroupLayout which is referenced by the BindGroup.
|
||||
DescriptorSetAllocation mDescriptorSetAllocation;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "dawn_native/vulkan/BindGroupLayoutVk.h"
|
||||
#include "dawn_native/vulkan/DeviceVk.h"
|
||||
#include "dawn_native/vulkan/FencedDeleter.h"
|
||||
#include "dawn_native/vulkan/UtilsVulkan.h"
|
||||
#include "dawn_native/vulkan/VulkanError.h"
|
||||
|
||||
namespace dawn_native { namespace vulkan {
|
||||
|
@ -52,9 +53,13 @@ namespace dawn_native { namespace vulkan {
|
|||
createInfo.pPushConstantRanges = nullptr;
|
||||
|
||||
Device* device = ToBackend(GetDevice());
|
||||
return CheckVkSuccess(
|
||||
DAWN_TRY(CheckVkSuccess(
|
||||
device->fn.CreatePipelineLayout(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
|
||||
"CreatePipelineLayout");
|
||||
"CreatePipelineLayout"));
|
||||
|
||||
SetLabelImpl();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
PipelineLayout::~PipelineLayout() = default;
|
||||
|
@ -70,4 +75,9 @@ namespace dawn_native { namespace vulkan {
|
|||
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
|
||||
|
|
|
@ -39,6 +39,9 @@ namespace dawn_native { namespace vulkan {
|
|||
using PipelineLayoutBase::PipelineLayoutBase;
|
||||
MaybeError Initialize();
|
||||
|
||||
// Dawn API
|
||||
void SetLabelImpl() override;
|
||||
|
||||
VkPipelineLayout mHandle = VK_NULL_HANDLE;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "dawn_native/vulkan/DeviceVk.h"
|
||||
#include "dawn_native/vulkan/FencedDeleter.h"
|
||||
#include "dawn_native/vulkan/UtilsVulkan.h"
|
||||
#include "dawn_native/vulkan/VulkanError.h"
|
||||
#include "dawn_platform/DawnPlatform.h"
|
||||
|
||||
|
@ -85,9 +86,13 @@ namespace dawn_native { namespace vulkan {
|
|||
}
|
||||
|
||||
Device* device = ToBackend(GetDevice());
|
||||
return CheckVkOOMThenSuccess(
|
||||
DAWN_TRY(CheckVkOOMThenSuccess(
|
||||
device->fn.CreateQueryPool(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
|
||||
"vkCreateQueryPool");
|
||||
"vkCreateQueryPool"));
|
||||
|
||||
SetLabelImpl();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -35,7 +35,9 @@ namespace dawn_native { namespace vulkan {
|
|||
using QuerySetBase::QuerySetBase;
|
||||
MaybeError Initialize();
|
||||
|
||||
// Dawn API
|
||||
void DestroyImpl() override;
|
||||
void SetLabelImpl() override;
|
||||
|
||||
VkQueryPool mHandle = VK_NULL_HANDLE;
|
||||
};
|
||||
|
|
|
@ -100,9 +100,13 @@ namespace dawn_native { namespace vulkan {
|
|||
createInfo.maxAnisotropy = 1;
|
||||
}
|
||||
|
||||
return CheckVkSuccess(
|
||||
DAWN_TRY(CheckVkSuccess(
|
||||
device->fn.CreateSampler(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
|
||||
"CreateSampler");
|
||||
"CreateSampler"));
|
||||
|
||||
SetLabelImpl();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Sampler::~Sampler() = default;
|
||||
|
@ -118,4 +122,9 @@ namespace dawn_native { namespace vulkan {
|
|||
return mHandle;
|
||||
}
|
||||
|
||||
void Sampler::SetLabelImpl() {
|
||||
SetDebugName(ToBackend(GetDevice()), VK_OBJECT_TYPE_SAMPLER,
|
||||
reinterpret_cast<uint64_t&>(mHandle), "Dawn_Sampler", GetLabel());
|
||||
}
|
||||
|
||||
}} // namespace dawn_native::vulkan
|
||||
|
|
|
@ -37,6 +37,9 @@ namespace dawn_native { namespace vulkan {
|
|||
using SamplerBase::SamplerBase;
|
||||
MaybeError Initialize(const SamplerDescriptor* descriptor);
|
||||
|
||||
// Dawn API
|
||||
void SetLabelImpl() override;
|
||||
|
||||
VkSampler mHandle = VK_NULL_HANDLE;
|
||||
};
|
||||
|
||||
|
|
|
@ -1293,9 +1293,13 @@ namespace dawn_native { namespace vulkan {
|
|||
createInfo.subresourceRange.layerCount = subresources.layerCount;
|
||||
createInfo.subresourceRange.aspectMask = VulkanAspectMask(subresources.aspects);
|
||||
|
||||
return CheckVkSuccess(
|
||||
DAWN_TRY(CheckVkSuccess(
|
||||
device->fn.CreateImageView(device->GetVkDevice(), &createInfo, nullptr, &*mHandle),
|
||||
"CreateImageView");
|
||||
"CreateImageView"));
|
||||
|
||||
SetLabelImpl();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
TextureView::~TextureView() {
|
||||
|
@ -1314,4 +1318,9 @@ namespace dawn_native { namespace vulkan {
|
|||
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
|
||||
|
|
|
@ -180,6 +180,9 @@ namespace dawn_native { namespace vulkan {
|
|||
using TextureViewBase::TextureViewBase;
|
||||
MaybeError Initialize(const TextureViewDescriptor* descriptor);
|
||||
|
||||
// Dawn API
|
||||
void SetLabelImpl() override;
|
||||
|
||||
VkImageView mHandle = VK_NULL_HANDLE;
|
||||
};
|
||||
|
||||
|
|
|
@ -19,6 +19,72 @@
|
|||
|
||||
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) {
|
||||
DAWN_SKIP_TEST_IF(UsesWire());
|
||||
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) {
|
||||
DAWN_SKIP_TEST_IF(UsesWire());
|
||||
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) {
|
||||
DAWN_SKIP_TEST_IF(UsesWire());
|
||||
std::string label = "test";
|
||||
|
|
Loading…
Reference in New Issue