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:
parent
b0143bcd4c
commit
828f674bf8
49
dawn.json
49
dawn.json
|
@ -466,7 +466,18 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"command buffer": {
|
"command buffer": {
|
||||||
"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"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"command buffer descriptor": {
|
"command buffer descriptor": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
|
@ -601,6 +612,15 @@
|
||||||
{"name": "query set", "type": "query set"},
|
{"name": "query set", "type": "query set"},
|
||||||
{"name": "query index", "type": "uint32_t"}
|
{"name": "query index", "type": "uint32_t"}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "set label",
|
||||||
|
"returns": "void",
|
||||||
|
"tags": ["dawn"],
|
||||||
|
"_TODO": "needs an upstream equivalent",
|
||||||
|
"args": [
|
||||||
|
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -751,6 +771,15 @@
|
||||||
{
|
{
|
||||||
"name": "end pipeline statistics query",
|
"name": "end pipeline statistics query",
|
||||||
"tags": ["upstream"]
|
"tags": ["upstream"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "set label",
|
||||||
|
"returns": "void",
|
||||||
|
"tags": ["dawn"],
|
||||||
|
"_TODO": "needs an upstream equivalent",
|
||||||
|
"args": [
|
||||||
|
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -1634,6 +1663,15 @@
|
||||||
"args": [
|
"args": [
|
||||||
{"name": "descriptor", "type": "render bundle descriptor", "annotation": "const*", "optional": true}
|
{"name": "descriptor", "type": "render bundle descriptor", "annotation": "const*", "optional": true}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "set label",
|
||||||
|
"returns": "void",
|
||||||
|
"tags": ["dawn"],
|
||||||
|
"_TODO": "needs an upstream equivalent",
|
||||||
|
"args": [
|
||||||
|
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -1854,6 +1892,15 @@
|
||||||
{
|
{
|
||||||
"name": "end pipeline statistics query",
|
"name": "end pipeline statistics query",
|
||||||
"tags": ["upstream"]
|
"tags": ["upstream"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "set label",
|
||||||
|
"returns": "void",
|
||||||
|
"tags": ["dawn"],
|
||||||
|
"_TODO": "needs an upstream equivalent",
|
||||||
|
"args": [
|
||||||
|
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -25,8 +25,9 @@
|
||||||
|
|
||||||
namespace dawn_native {
|
namespace dawn_native {
|
||||||
|
|
||||||
CommandBufferBase::CommandBufferBase(CommandEncoder* encoder, const CommandBufferDescriptor*)
|
CommandBufferBase::CommandBufferBase(CommandEncoder* encoder,
|
||||||
: ApiObjectBase(encoder->GetDevice(), kLabelNotImplemented),
|
const CommandBufferDescriptor* descriptor)
|
||||||
|
: ApiObjectBase(encoder->GetDevice(), descriptor->label),
|
||||||
mCommands(encoder->AcquireCommands()),
|
mCommands(encoder->AcquireCommands()),
|
||||||
mResourceUsages(encoder->AcquireResourceUsages()) {
|
mResourceUsages(encoder->AcquireResourceUsages()) {
|
||||||
TrackInDevice();
|
TrackInDevice();
|
||||||
|
|
|
@ -466,8 +466,8 @@ namespace dawn_native {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
CommandEncoder::CommandEncoder(DeviceBase* device, const CommandEncoderDescriptor*)
|
CommandEncoder::CommandEncoder(DeviceBase* device, const CommandEncoderDescriptor* descriptor)
|
||||||
: ApiObjectBase(device, kLabelNotImplemented), mEncodingContext(device, this) {
|
: ApiObjectBase(device, descriptor->label), mEncodingContext(device, this) {
|
||||||
TrackInDevice();
|
TrackInDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,8 +522,13 @@ namespace dawn_native {
|
||||||
"encoding %s.BeginComputePass(%s).", this, descriptor);
|
"encoding %s.BeginComputePass(%s).", this, descriptor);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
|
const ComputePassDescriptor defaultDescriptor = {};
|
||||||
|
if (descriptor == nullptr) {
|
||||||
|
descriptor = &defaultDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
ComputePassEncoder* passEncoder =
|
ComputePassEncoder* passEncoder =
|
||||||
new ComputePassEncoder(device, this, &mEncodingContext);
|
new ComputePassEncoder(device, descriptor, this, &mEncodingContext);
|
||||||
mEncodingContext.EnterPass(passEncoder);
|
mEncodingContext.EnterPass(passEncoder);
|
||||||
return passEncoder;
|
return passEncoder;
|
||||||
}
|
}
|
||||||
|
@ -627,10 +632,10 @@ namespace dawn_native {
|
||||||
"encoding %s.BeginRenderPass(%s).", this, descriptor);
|
"encoding %s.BeginRenderPass(%s).", this, descriptor);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
RenderPassEncoder* passEncoder =
|
RenderPassEncoder* passEncoder = new RenderPassEncoder(
|
||||||
new RenderPassEncoder(device, this, &mEncodingContext, std::move(usageTracker),
|
device, descriptor, this, &mEncodingContext, std::move(usageTracker),
|
||||||
std::move(attachmentState), descriptor->occlusionQuerySet,
|
std::move(attachmentState), descriptor->occlusionQuerySet, width, height,
|
||||||
width, height, depthReadOnly, stencilReadOnly);
|
depthReadOnly, stencilReadOnly);
|
||||||
mEncodingContext.EnterPass(passEncoder);
|
mEncodingContext.EnterPass(passEncoder);
|
||||||
return passEncoder;
|
return passEncoder;
|
||||||
}
|
}
|
||||||
|
@ -1041,6 +1046,12 @@ namespace dawn_native {
|
||||||
if (device->IsValidationEnabled()) {
|
if (device->IsValidationEnabled()) {
|
||||||
DAWN_TRY(ValidateFinish());
|
DAWN_TRY(ValidateFinish());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CommandBufferDescriptor defaultDescriptor = {};
|
||||||
|
if (descriptor == nullptr) {
|
||||||
|
descriptor = &defaultDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
return device->CreateCommandBuffer(this, descriptor);
|
return device->CreateCommandBuffer(this, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,9 +111,11 @@ namespace dawn_native {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ComputePassEncoder::ComputePassEncoder(DeviceBase* device,
|
ComputePassEncoder::ComputePassEncoder(DeviceBase* device,
|
||||||
|
const ComputePassDescriptor* descriptor,
|
||||||
CommandEncoder* commandEncoder,
|
CommandEncoder* commandEncoder,
|
||||||
EncodingContext* encodingContext)
|
EncodingContext* encodingContext)
|
||||||
: ProgrammableEncoder(device, encodingContext), mCommandEncoder(commandEncoder) {
|
: ProgrammableEncoder(device, descriptor->label, encodingContext),
|
||||||
|
mCommandEncoder(commandEncoder) {
|
||||||
TrackInDevice();
|
TrackInDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace dawn_native {
|
||||||
class ComputePassEncoder final : public ProgrammableEncoder {
|
class ComputePassEncoder final : public ProgrammableEncoder {
|
||||||
public:
|
public:
|
||||||
ComputePassEncoder(DeviceBase* device,
|
ComputePassEncoder(DeviceBase* device,
|
||||||
|
const ComputePassDescriptor* descriptor,
|
||||||
CommandEncoder* commandEncoder,
|
CommandEncoder* commandEncoder,
|
||||||
EncodingContext* encodingContext);
|
EncodingContext* encodingContext);
|
||||||
|
|
||||||
|
|
|
@ -908,6 +908,10 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
CommandEncoder* DeviceBase::APICreateCommandEncoder(
|
CommandEncoder* DeviceBase::APICreateCommandEncoder(
|
||||||
const CommandEncoderDescriptor* descriptor) {
|
const CommandEncoderDescriptor* descriptor) {
|
||||||
|
const CommandEncoderDescriptor defaultDescriptor = {};
|
||||||
|
if (descriptor == nullptr) {
|
||||||
|
descriptor = &defaultDescriptor;
|
||||||
|
}
|
||||||
return new CommandEncoder(this, descriptor);
|
return new CommandEncoder(this, descriptor);
|
||||||
}
|
}
|
||||||
ComputePipelineBase* DeviceBase::APICreateComputePipeline(
|
ComputePipelineBase* DeviceBase::APICreateComputePipeline(
|
||||||
|
|
|
@ -28,8 +28,10 @@
|
||||||
|
|
||||||
namespace dawn_native {
|
namespace dawn_native {
|
||||||
|
|
||||||
ProgrammableEncoder::ProgrammableEncoder(DeviceBase* device, EncodingContext* encodingContext)
|
ProgrammableEncoder::ProgrammableEncoder(DeviceBase* device,
|
||||||
: ApiObjectBase(device, kLabelNotImplemented),
|
const char* label,
|
||||||
|
EncodingContext* encodingContext)
|
||||||
|
: ApiObjectBase(device, label),
|
||||||
mEncodingContext(encodingContext),
|
mEncodingContext(encodingContext),
|
||||||
mValidationEnabled(device->IsValidationEnabled()) {
|
mValidationEnabled(device->IsValidationEnabled()) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,9 @@ namespace dawn_native {
|
||||||
// Base class for shared functionality between programmable encoders.
|
// Base class for shared functionality between programmable encoders.
|
||||||
class ProgrammableEncoder : public ApiObjectBase {
|
class ProgrammableEncoder : public ApiObjectBase {
|
||||||
public:
|
public:
|
||||||
ProgrammableEncoder(DeviceBase* device, EncodingContext* encodingContext);
|
ProgrammableEncoder(DeviceBase* device,
|
||||||
|
const char* label,
|
||||||
|
EncodingContext* encodingContext);
|
||||||
|
|
||||||
void APIInsertDebugMarker(const char* groupLabel);
|
void APIInsertDebugMarker(const char* groupLabel);
|
||||||
void APIPopDebugGroup();
|
void APIPopDebugGroup();
|
||||||
|
|
|
@ -88,6 +88,7 @@ namespace dawn_native {
|
||||||
RenderBundleEncoder::RenderBundleEncoder(DeviceBase* device,
|
RenderBundleEncoder::RenderBundleEncoder(DeviceBase* device,
|
||||||
const RenderBundleEncoderDescriptor* descriptor)
|
const RenderBundleEncoderDescriptor* descriptor)
|
||||||
: RenderEncoderBase(device,
|
: RenderEncoderBase(device,
|
||||||
|
descriptor->label,
|
||||||
&mBundleEncodingContext,
|
&mBundleEncodingContext,
|
||||||
device->GetOrCreateAttachmentState(descriptor),
|
device->GetOrCreateAttachmentState(descriptor),
|
||||||
descriptor->depthReadOnly,
|
descriptor->depthReadOnly,
|
||||||
|
|
|
@ -30,11 +30,12 @@
|
||||||
namespace dawn_native {
|
namespace dawn_native {
|
||||||
|
|
||||||
RenderEncoderBase::RenderEncoderBase(DeviceBase* device,
|
RenderEncoderBase::RenderEncoderBase(DeviceBase* device,
|
||||||
|
const char* label,
|
||||||
EncodingContext* encodingContext,
|
EncodingContext* encodingContext,
|
||||||
Ref<AttachmentState> attachmentState,
|
Ref<AttachmentState> attachmentState,
|
||||||
bool depthReadOnly,
|
bool depthReadOnly,
|
||||||
bool stencilReadOnly)
|
bool stencilReadOnly)
|
||||||
: ProgrammableEncoder(device, encodingContext),
|
: ProgrammableEncoder(device, label, encodingContext),
|
||||||
mIndirectDrawMetadata(device->GetLimits()),
|
mIndirectDrawMetadata(device->GetLimits()),
|
||||||
mAttachmentState(std::move(attachmentState)),
|
mAttachmentState(std::move(attachmentState)),
|
||||||
mDisableBaseVertex(device->IsToggleEnabled(Toggle::DisableBaseVertex)),
|
mDisableBaseVertex(device->IsToggleEnabled(Toggle::DisableBaseVertex)),
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace dawn_native {
|
||||||
class RenderEncoderBase : public ProgrammableEncoder {
|
class RenderEncoderBase : public ProgrammableEncoder {
|
||||||
public:
|
public:
|
||||||
RenderEncoderBase(DeviceBase* device,
|
RenderEncoderBase(DeviceBase* device,
|
||||||
|
const char* label,
|
||||||
EncodingContext* encodingContext,
|
EncodingContext* encodingContext,
|
||||||
Ref<AttachmentState> attachmentState,
|
Ref<AttachmentState> attachmentState,
|
||||||
bool depthReadOnly,
|
bool depthReadOnly,
|
||||||
|
|
|
@ -49,6 +49,7 @@ namespace dawn_native {
|
||||||
// BeginRenderPassCmd. If we had RenderPassEncoder responsible for recording the
|
// BeginRenderPassCmd. If we had RenderPassEncoder responsible for recording the
|
||||||
// command, then this wouldn't be necessary.
|
// command, then this wouldn't be necessary.
|
||||||
RenderPassEncoder::RenderPassEncoder(DeviceBase* device,
|
RenderPassEncoder::RenderPassEncoder(DeviceBase* device,
|
||||||
|
const RenderPassDescriptor* descriptor,
|
||||||
CommandEncoder* commandEncoder,
|
CommandEncoder* commandEncoder,
|
||||||
EncodingContext* encodingContext,
|
EncodingContext* encodingContext,
|
||||||
RenderPassResourceUsageTracker usageTracker,
|
RenderPassResourceUsageTracker usageTracker,
|
||||||
|
@ -59,6 +60,7 @@ namespace dawn_native {
|
||||||
bool depthReadOnly,
|
bool depthReadOnly,
|
||||||
bool stencilReadOnly)
|
bool stencilReadOnly)
|
||||||
: RenderEncoderBase(device,
|
: RenderEncoderBase(device,
|
||||||
|
descriptor->label,
|
||||||
encodingContext,
|
encodingContext,
|
||||||
std::move(attachmentState),
|
std::move(attachmentState),
|
||||||
depthReadOnly,
|
depthReadOnly,
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace dawn_native {
|
||||||
class RenderPassEncoder final : public RenderEncoderBase {
|
class RenderPassEncoder final : public RenderEncoderBase {
|
||||||
public:
|
public:
|
||||||
RenderPassEncoder(DeviceBase* device,
|
RenderPassEncoder(DeviceBase* device,
|
||||||
|
const RenderPassDescriptor* descriptor,
|
||||||
CommandEncoder* commandEncoder,
|
CommandEncoder* commandEncoder,
|
||||||
EncodingContext* encodingContext,
|
EncodingContext* encodingContext,
|
||||||
RenderPassResourceUsageTracker usageTracker,
|
RenderPassResourceUsageTracker usageTracker,
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
|
#include "utils/ComboRenderBundleEncoderDescriptor.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/WGPUHelpers.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) {
|
TEST_F(LabelTest, ExternalTexture) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
std::string label = "test";
|
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) {
|
TEST_F(LabelTest, Sampler) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
|
|
Loading…
Reference in New Issue