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
@@ -25,8 +25,9 @@
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
CommandBufferBase::CommandBufferBase(CommandEncoder* encoder, const CommandBufferDescriptor*)
|
||||
: ApiObjectBase(encoder->GetDevice(), kLabelNotImplemented),
|
||||
CommandBufferBase::CommandBufferBase(CommandEncoder* encoder,
|
||||
const CommandBufferDescriptor* descriptor)
|
||||
: ApiObjectBase(encoder->GetDevice(), descriptor->label),
|
||||
mCommands(encoder->AcquireCommands()),
|
||||
mResourceUsages(encoder->AcquireResourceUsages()) {
|
||||
TrackInDevice();
|
||||
|
||||
@@ -466,8 +466,8 @@ namespace dawn_native {
|
||||
|
||||
} // namespace
|
||||
|
||||
CommandEncoder::CommandEncoder(DeviceBase* device, const CommandEncoderDescriptor*)
|
||||
: ApiObjectBase(device, kLabelNotImplemented), mEncodingContext(device, this) {
|
||||
CommandEncoder::CommandEncoder(DeviceBase* device, const CommandEncoderDescriptor* descriptor)
|
||||
: ApiObjectBase(device, descriptor->label), mEncodingContext(device, this) {
|
||||
TrackInDevice();
|
||||
}
|
||||
|
||||
@@ -522,8 +522,13 @@ namespace dawn_native {
|
||||
"encoding %s.BeginComputePass(%s).", this, descriptor);
|
||||
|
||||
if (success) {
|
||||
const ComputePassDescriptor defaultDescriptor = {};
|
||||
if (descriptor == nullptr) {
|
||||
descriptor = &defaultDescriptor;
|
||||
}
|
||||
|
||||
ComputePassEncoder* passEncoder =
|
||||
new ComputePassEncoder(device, this, &mEncodingContext);
|
||||
new ComputePassEncoder(device, descriptor, this, &mEncodingContext);
|
||||
mEncodingContext.EnterPass(passEncoder);
|
||||
return passEncoder;
|
||||
}
|
||||
@@ -627,10 +632,10 @@ namespace dawn_native {
|
||||
"encoding %s.BeginRenderPass(%s).", this, descriptor);
|
||||
|
||||
if (success) {
|
||||
RenderPassEncoder* passEncoder =
|
||||
new RenderPassEncoder(device, this, &mEncodingContext, std::move(usageTracker),
|
||||
std::move(attachmentState), descriptor->occlusionQuerySet,
|
||||
width, height, depthReadOnly, stencilReadOnly);
|
||||
RenderPassEncoder* passEncoder = new RenderPassEncoder(
|
||||
device, descriptor, this, &mEncodingContext, std::move(usageTracker),
|
||||
std::move(attachmentState), descriptor->occlusionQuerySet, width, height,
|
||||
depthReadOnly, stencilReadOnly);
|
||||
mEncodingContext.EnterPass(passEncoder);
|
||||
return passEncoder;
|
||||
}
|
||||
@@ -1041,6 +1046,12 @@ namespace dawn_native {
|
||||
if (device->IsValidationEnabled()) {
|
||||
DAWN_TRY(ValidateFinish());
|
||||
}
|
||||
|
||||
const CommandBufferDescriptor defaultDescriptor = {};
|
||||
if (descriptor == nullptr) {
|
||||
descriptor = &defaultDescriptor;
|
||||
}
|
||||
|
||||
return device->CreateCommandBuffer(this, descriptor);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,9 +111,11 @@ namespace dawn_native {
|
||||
} // namespace
|
||||
|
||||
ComputePassEncoder::ComputePassEncoder(DeviceBase* device,
|
||||
const ComputePassDescriptor* descriptor,
|
||||
CommandEncoder* commandEncoder,
|
||||
EncodingContext* encodingContext)
|
||||
: ProgrammableEncoder(device, encodingContext), mCommandEncoder(commandEncoder) {
|
||||
: ProgrammableEncoder(device, descriptor->label, encodingContext),
|
||||
mCommandEncoder(commandEncoder) {
|
||||
TrackInDevice();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace dawn_native {
|
||||
class ComputePassEncoder final : public ProgrammableEncoder {
|
||||
public:
|
||||
ComputePassEncoder(DeviceBase* device,
|
||||
const ComputePassDescriptor* descriptor,
|
||||
CommandEncoder* commandEncoder,
|
||||
EncodingContext* encodingContext);
|
||||
|
||||
|
||||
@@ -908,6 +908,10 @@ namespace dawn_native {
|
||||
}
|
||||
CommandEncoder* DeviceBase::APICreateCommandEncoder(
|
||||
const CommandEncoderDescriptor* descriptor) {
|
||||
const CommandEncoderDescriptor defaultDescriptor = {};
|
||||
if (descriptor == nullptr) {
|
||||
descriptor = &defaultDescriptor;
|
||||
}
|
||||
return new CommandEncoder(this, descriptor);
|
||||
}
|
||||
ComputePipelineBase* DeviceBase::APICreateComputePipeline(
|
||||
|
||||
@@ -28,8 +28,10 @@
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
ProgrammableEncoder::ProgrammableEncoder(DeviceBase* device, EncodingContext* encodingContext)
|
||||
: ApiObjectBase(device, kLabelNotImplemented),
|
||||
ProgrammableEncoder::ProgrammableEncoder(DeviceBase* device,
|
||||
const char* label,
|
||||
EncodingContext* encodingContext)
|
||||
: ApiObjectBase(device, label),
|
||||
mEncodingContext(encodingContext),
|
||||
mValidationEnabled(device->IsValidationEnabled()) {
|
||||
}
|
||||
|
||||
@@ -30,7 +30,9 @@ namespace dawn_native {
|
||||
// Base class for shared functionality between programmable encoders.
|
||||
class ProgrammableEncoder : public ApiObjectBase {
|
||||
public:
|
||||
ProgrammableEncoder(DeviceBase* device, EncodingContext* encodingContext);
|
||||
ProgrammableEncoder(DeviceBase* device,
|
||||
const char* label,
|
||||
EncodingContext* encodingContext);
|
||||
|
||||
void APIInsertDebugMarker(const char* groupLabel);
|
||||
void APIPopDebugGroup();
|
||||
|
||||
@@ -88,6 +88,7 @@ namespace dawn_native {
|
||||
RenderBundleEncoder::RenderBundleEncoder(DeviceBase* device,
|
||||
const RenderBundleEncoderDescriptor* descriptor)
|
||||
: RenderEncoderBase(device,
|
||||
descriptor->label,
|
||||
&mBundleEncodingContext,
|
||||
device->GetOrCreateAttachmentState(descriptor),
|
||||
descriptor->depthReadOnly,
|
||||
|
||||
@@ -30,11 +30,12 @@
|
||||
namespace dawn_native {
|
||||
|
||||
RenderEncoderBase::RenderEncoderBase(DeviceBase* device,
|
||||
const char* label,
|
||||
EncodingContext* encodingContext,
|
||||
Ref<AttachmentState> attachmentState,
|
||||
bool depthReadOnly,
|
||||
bool stencilReadOnly)
|
||||
: ProgrammableEncoder(device, encodingContext),
|
||||
: ProgrammableEncoder(device, label, encodingContext),
|
||||
mIndirectDrawMetadata(device->GetLimits()),
|
||||
mAttachmentState(std::move(attachmentState)),
|
||||
mDisableBaseVertex(device->IsToggleEnabled(Toggle::DisableBaseVertex)),
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace dawn_native {
|
||||
class RenderEncoderBase : public ProgrammableEncoder {
|
||||
public:
|
||||
RenderEncoderBase(DeviceBase* device,
|
||||
const char* label,
|
||||
EncodingContext* encodingContext,
|
||||
Ref<AttachmentState> attachmentState,
|
||||
bool depthReadOnly,
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace dawn_native {
|
||||
// BeginRenderPassCmd. If we had RenderPassEncoder responsible for recording the
|
||||
// command, then this wouldn't be necessary.
|
||||
RenderPassEncoder::RenderPassEncoder(DeviceBase* device,
|
||||
const RenderPassDescriptor* descriptor,
|
||||
CommandEncoder* commandEncoder,
|
||||
EncodingContext* encodingContext,
|
||||
RenderPassResourceUsageTracker usageTracker,
|
||||
@@ -59,6 +60,7 @@ namespace dawn_native {
|
||||
bool depthReadOnly,
|
||||
bool stencilReadOnly)
|
||||
: RenderEncoderBase(device,
|
||||
descriptor->label,
|
||||
encodingContext,
|
||||
std::move(attachmentState),
|
||||
depthReadOnly,
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace dawn_native {
|
||||
class RenderPassEncoder final : public RenderEncoderBase {
|
||||
public:
|
||||
RenderPassEncoder(DeviceBase* device,
|
||||
const RenderPassDescriptor* descriptor,
|
||||
CommandEncoder* commandEncoder,
|
||||
EncodingContext* encodingContext,
|
||||
RenderPassResourceUsageTracker usageTracker,
|
||||
|
||||
@@ -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