Handle debug markers commands on command encoder

This CL adds support for InsertDebugMarker, PushDebugGroup, and
PopDebugGroup commands to CommandBuffer backends.

Bug: dawn:44

Change-Id: Iaf075023d3072534fca02b71c0e205cbaa46cd0f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/28602
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
Commit-Queue: Enrico Galli <enrico.galli@intel.com>
This commit is contained in:
Enrico Galli 2020-09-18 23:10:11 +00:00 committed by Commit Bot service account
parent 1da25e5103
commit 6e2415256c
5 changed files with 126 additions and 0 deletions

View File

@ -916,6 +916,44 @@ namespace dawn_native { namespace d3d12 {
break;
}
case Command::InsertDebugMarker: {
InsertDebugMarkerCmd* cmd = mCommands.NextCommand<InsertDebugMarkerCmd>();
const char* label = mCommands.NextData<char>(cmd->length + 1);
if (ToBackend(GetDevice())->GetFunctions()->IsPIXEventRuntimeLoaded()) {
// PIX color is 1 byte per channel in ARGB format
constexpr uint64_t kPIXBlackColor = 0xff000000;
ToBackend(GetDevice())
->GetFunctions()
->pixSetMarkerOnCommandList(commandList, kPIXBlackColor, label);
}
break;
}
case Command::PopDebugGroup: {
mCommands.NextCommand<PopDebugGroupCmd>();
if (ToBackend(GetDevice())->GetFunctions()->IsPIXEventRuntimeLoaded()) {
ToBackend(GetDevice())
->GetFunctions()
->pixEndEventOnCommandList(commandList);
}
break;
}
case Command::PushDebugGroup: {
PushDebugGroupCmd* cmd = mCommands.NextCommand<PushDebugGroupCmd>();
const char* label = mCommands.NextData<char>(cmd->length + 1);
if (ToBackend(GetDevice())->GetFunctions()->IsPIXEventRuntimeLoaded()) {
// PIX color is 1 byte per channel in ARGB format
constexpr uint64_t kPIXBlackColor = 0xff000000;
ToBackend(GetDevice())
->GetFunctions()
->pixBeginEventOnCommandList(commandList, kPIXBlackColor, label);
}
break;
}
default: {
UNREACHABLE();
break;

View File

@ -766,6 +766,34 @@ namespace dawn_native { namespace metal {
return DAWN_UNIMPLEMENTED_ERROR("Waiting for implementation.");
}
case Command::InsertDebugMarker: {
// MTLCommandBuffer does not implement insertDebugSignpost
SkipCommand(&mCommands, type);
break;
}
case Command::PopDebugGroup: {
mCommands.NextCommand<PopDebugGroupCmd>();
if (@available(macos 10.13, *)) {
[commandContext->GetCommands() popDebugGroup];
}
break;
}
case Command::PushDebugGroup: {
PushDebugGroupCmd* cmd = mCommands.NextCommand<PushDebugGroupCmd>();
char* label = mCommands.NextData<char>(cmd->length + 1);
if (@available(macos 10.13, *)) {
NSString* mtlLabel = [[NSString alloc] initWithUTF8String:label];
[commandContext->GetCommands() pushDebugGroup:mtlLabel];
[mtlLabel release];
}
break;
}
default: {
UNREACHABLE();
break;

View File

@ -734,6 +734,15 @@ namespace dawn_native { namespace opengl {
break;
}
case Command::InsertDebugMarker:
case Command::PopDebugGroup:
case Command::PushDebugGroup: {
// Due to lack of linux driver support for GL_EXT_debug_marker
// extension these functions are skipped.
SkipCommand(&mCommands, type);
break;
}
default: {
UNREACHABLE();
break;

View File

@ -774,6 +774,54 @@ namespace dawn_native { namespace vulkan {
break;
}
case Command::InsertDebugMarker: {
if (device->GetDeviceInfo().HasExt(DeviceExt::DebugMarker)) {
InsertDebugMarkerCmd* cmd = mCommands.NextCommand<InsertDebugMarkerCmd>();
const char* label = mCommands.NextData<char>(cmd->length + 1);
VkDebugMarkerMarkerInfoEXT markerInfo{};
markerInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT;
markerInfo.pMarkerName = label;
// Default color to black
markerInfo.color[0] = 0.0;
markerInfo.color[1] = 0.0;
markerInfo.color[2] = 0.0;
markerInfo.color[3] = 1.0;
device->fn.CmdDebugMarkerInsertEXT(commands, &markerInfo);
} else {
SkipCommand(&mCommands, Command::InsertDebugMarker);
}
break;
}
case Command::PopDebugGroup: {
if (device->GetDeviceInfo().HasExt(DeviceExt::DebugMarker)) {
mCommands.NextCommand<PopDebugGroupCmd>();
device->fn.CmdDebugMarkerEndEXT(commands);
} else {
SkipCommand(&mCommands, Command::PopDebugGroup);
}
break;
}
case Command::PushDebugGroup: {
if (device->GetDeviceInfo().HasExt(DeviceExt::DebugMarker)) {
PushDebugGroupCmd* cmd = mCommands.NextCommand<PushDebugGroupCmd>();
const char* label = mCommands.NextData<char>(cmd->length + 1);
VkDebugMarkerMarkerInfoEXT markerInfo{};
markerInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT;
markerInfo.pMarkerName = label;
// Default color to black
markerInfo.color[0] = 0.0;
markerInfo.color[1] = 0.0;
markerInfo.color[2] = 0.0;
markerInfo.color[3] = 1.0;
device->fn.CmdDebugMarkerBeginEXT(commands, &markerInfo);
} else {
SkipCommand(&mCommands, Command::PushDebugGroup);
}
break;
}
default: {
UNREACHABLE();
break;

View File

@ -23,6 +23,9 @@ TEST_P(DebugMarkerTests, NoFailureWithoutDebugToolAttached) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 4, 4);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.PushDebugGroup("Event Start");
encoder.InsertDebugMarker("Marker");
encoder.PopDebugGroup();
{
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.PushDebugGroup("Event Start");