mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-15 16:16:08 +00:00
Add label tracking for several object types (pt 2)
Adds label tracking for: - CommandBuffer - CommandEncoder - ComputePassEncoder - RenderBundleEncoder - RenderPassEncoder It's not clear to me if these structures have labelable equivalents in D3D12 or Vulkan, so no changes were made to the individual backends. Bug: dawn:840 Change-Id: Ib1786ab45466a3d13fbd4c772f8e8af4cc1786af Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70400 Commit-Queue: Brandon Jones <bajones@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
b0143bcd4c
commit
828f674bf8
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <string>
|
||||
#include "tests/unittests/validation/ValidationTest.h"
|
||||
#include "utils/ComboRenderBundleEncoderDescriptor.h"
|
||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
@@ -116,6 +117,101 @@ TEST_F(LabelTest, Buffer) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(LabelTest, CommandBuffer) {
|
||||
DAWN_SKIP_TEST_IF(UsesWire());
|
||||
std::string label = "test";
|
||||
wgpu::CommandBufferDescriptor descriptor;
|
||||
|
||||
// The label should be empty if one was not set.
|
||||
{
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
wgpu::CommandBuffer commandBuffer = encoder.Finish(&descriptor);
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(commandBuffer.Get());
|
||||
ASSERT_TRUE(readbackLabel.empty());
|
||||
}
|
||||
|
||||
// Test setting a label through API
|
||||
{
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
wgpu::CommandBuffer commandBuffer = encoder.Finish(&descriptor);
|
||||
commandBuffer.SetLabel(label.c_str());
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(commandBuffer.Get());
|
||||
ASSERT_EQ(label, readbackLabel);
|
||||
}
|
||||
|
||||
// Test setting a label through the descriptor.
|
||||
{
|
||||
descriptor.label = label.c_str();
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
wgpu::CommandBuffer commandBuffer = encoder.Finish(&descriptor);
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(commandBuffer.Get());
|
||||
ASSERT_EQ(label, readbackLabel);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(LabelTest, CommandEncoder) {
|
||||
DAWN_SKIP_TEST_IF(UsesWire());
|
||||
std::string label = "test";
|
||||
wgpu::CommandEncoderDescriptor descriptor;
|
||||
|
||||
// The label should be empty if one was not set.
|
||||
{
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(&descriptor);
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(encoder.Get());
|
||||
ASSERT_TRUE(readbackLabel.empty());
|
||||
}
|
||||
|
||||
// Test setting a label through API
|
||||
{
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(&descriptor);
|
||||
encoder.SetLabel(label.c_str());
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(encoder.Get());
|
||||
ASSERT_EQ(label, readbackLabel);
|
||||
}
|
||||
|
||||
// Test setting a label through the descriptor.
|
||||
{
|
||||
descriptor.label = label.c_str();
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(&descriptor);
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(encoder.Get());
|
||||
ASSERT_EQ(label, readbackLabel);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(LabelTest, ComputePassEncoder) {
|
||||
DAWN_SKIP_TEST_IF(UsesWire());
|
||||
std::string label = "test";
|
||||
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
|
||||
|
||||
wgpu::ComputePassDescriptor descriptor;
|
||||
|
||||
// The label should be empty if one was not set.
|
||||
{
|
||||
wgpu::ComputePassEncoder encoder = commandEncoder.BeginComputePass(&descriptor);
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(encoder.Get());
|
||||
ASSERT_TRUE(readbackLabel.empty());
|
||||
encoder.EndPass();
|
||||
}
|
||||
|
||||
// Test setting a label through API
|
||||
{
|
||||
wgpu::ComputePassEncoder encoder = commandEncoder.BeginComputePass(&descriptor);
|
||||
encoder.SetLabel(label.c_str());
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(encoder.Get());
|
||||
ASSERT_EQ(label, readbackLabel);
|
||||
encoder.EndPass();
|
||||
}
|
||||
|
||||
// Test setting a label through the descriptor.
|
||||
{
|
||||
descriptor.label = label.c_str();
|
||||
wgpu::ComputePassEncoder encoder = commandEncoder.BeginComputePass(&descriptor);
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(encoder.Get());
|
||||
ASSERT_EQ(label, readbackLabel);
|
||||
encoder.EndPass();
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(LabelTest, ExternalTexture) {
|
||||
DAWN_SKIP_TEST_IF(UsesWire());
|
||||
std::string label = "test";
|
||||
@@ -223,6 +319,78 @@ TEST_F(LabelTest, QuerySet) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(LabelTest, RenderBundleEncoder) {
|
||||
DAWN_SKIP_TEST_IF(UsesWire());
|
||||
std::string label = "test";
|
||||
|
||||
utils::ComboRenderBundleEncoderDescriptor descriptor = {};
|
||||
descriptor.colorFormatsCount = 1;
|
||||
descriptor.cColorFormats[0] = wgpu::TextureFormat::RGBA8Unorm;
|
||||
|
||||
// The label should be empty if one was not set.
|
||||
{
|
||||
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&descriptor);
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(encoder.Get());
|
||||
ASSERT_TRUE(readbackLabel.empty());
|
||||
}
|
||||
|
||||
// Test setting a label through API
|
||||
{
|
||||
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&descriptor);
|
||||
encoder.SetLabel(label.c_str());
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(encoder.Get());
|
||||
ASSERT_EQ(label, readbackLabel);
|
||||
}
|
||||
|
||||
// Test setting a label through the descriptor.
|
||||
{
|
||||
descriptor.label = label.c_str();
|
||||
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&descriptor);
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(encoder.Get());
|
||||
ASSERT_EQ(label, readbackLabel);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(LabelTest, RenderPassEncoder) {
|
||||
DAWN_SKIP_TEST_IF(UsesWire());
|
||||
std::string label = "test";
|
||||
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
|
||||
|
||||
wgpu::TextureDescriptor textureDescriptor;
|
||||
textureDescriptor.size = {1, 1, 1};
|
||||
textureDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||
textureDescriptor.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment;
|
||||
wgpu::Texture texture = device.CreateTexture(&textureDescriptor);
|
||||
|
||||
utils::ComboRenderPassDescriptor descriptor({texture.CreateView()});
|
||||
|
||||
// The label should be empty if one was not set.
|
||||
{
|
||||
wgpu::RenderPassEncoder encoder = commandEncoder.BeginRenderPass(&descriptor);
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(encoder.Get());
|
||||
ASSERT_TRUE(readbackLabel.empty());
|
||||
encoder.EndPass();
|
||||
}
|
||||
|
||||
// Test setting a label through API
|
||||
{
|
||||
wgpu::RenderPassEncoder encoder = commandEncoder.BeginRenderPass(&descriptor);
|
||||
encoder.SetLabel(label.c_str());
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(encoder.Get());
|
||||
ASSERT_EQ(label, readbackLabel);
|
||||
encoder.EndPass();
|
||||
}
|
||||
|
||||
// Test setting a label through the descriptor.
|
||||
{
|
||||
descriptor.label = label.c_str();
|
||||
wgpu::RenderPassEncoder encoder = commandEncoder.BeginRenderPass(&descriptor);
|
||||
std::string readbackLabel = dawn_native::GetObjectLabelForTesting(encoder.Get());
|
||||
ASSERT_EQ(label, readbackLabel);
|
||||
encoder.EndPass();
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(LabelTest, Sampler) {
|
||||
DAWN_SKIP_TEST_IF(UsesWire());
|
||||
std::string label = "test";
|
||||
|
||||
Reference in New Issue
Block a user