Add Debug Label Functionality For D3D12/Vk Buffers & Textures
Adds a generic SetDebugName utility for D3D12 and Vulkan. Passes down
debug label set by user for buffers and textures to be labeled by the
appropriate backend method.
Bug: dawn:840
Change-Id: I7158b537a6e37fdf733645e6830dc33833ee683e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/61588
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones (Intel) <brandon1.jones@intel.com>
diff --git a/src/dawn_native/vulkan/UtilsVulkan.cpp b/src/dawn_native/vulkan/UtilsVulkan.cpp
index c6952d4..eb46180 100644
--- a/src/dawn_native/vulkan/UtilsVulkan.cpp
+++ b/src/dawn_native/vulkan/UtilsVulkan.cpp
@@ -17,8 +17,10 @@
#include "common/Assert.h"
#include "dawn_native/EnumMaskIterator.h"
#include "dawn_native/Format.h"
+#include "dawn_native/vulkan/DeviceVk.h"
#include "dawn_native/vulkan/Forward.h"
#include "dawn_native/vulkan/TextureVk.h"
+#include "dawn_native/vulkan/VulkanError.h"
namespace dawn_native { namespace vulkan {
@@ -162,4 +164,30 @@
return region;
}
+
+ void SetDebugName(Device* device,
+ VkObjectType objectType,
+ uint64_t objectHandle,
+ const char* prefix,
+ std::string label) {
+ if (device->GetGlobalInfo().HasExt(InstanceExt::DebugUtils)) {
+ VkDebugUtilsObjectNameInfoEXT objectNameInfo;
+ objectNameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
+ objectNameInfo.pNext = nullptr;
+ objectNameInfo.objectType = objectType;
+ objectNameInfo.objectHandle = objectHandle;
+
+ if (label.empty() || !device->IsToggleEnabled(Toggle::UseUserDefinedLabelsInBackend)) {
+ objectNameInfo.pObjectName = prefix;
+ device->fn.SetDebugUtilsObjectNameEXT(device->GetVkDevice(), &objectNameInfo);
+ return;
+ }
+
+ std::string objectName = prefix;
+ objectName += "_";
+ objectName += label;
+ objectNameInfo.pObjectName = objectName.c_str();
+ device->fn.SetDebugUtilsObjectNameEXT(device->GetVkDevice(), &objectNameInfo);
+ }
+ }
}} // namespace dawn_native::vulkan