[Impeller] Add debug names to additional VK objects (flutter/engine#37592)
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "impeller/renderer/backend/vulkan/context_vk.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
@@ -51,6 +52,15 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugUtilsMessengerCallback(
|
||||
|
||||
namespace impeller {
|
||||
|
||||
namespace vk {
|
||||
|
||||
bool HasValidationLayers() {
|
||||
auto capabilities = std::make_unique<CapabilitiesVK>();
|
||||
return capabilities->HasLayer(kKhronosValidationLayerName);
|
||||
}
|
||||
|
||||
} // namespace vk
|
||||
|
||||
static std::set<std::string> kRequiredDeviceExtensions = {
|
||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
||||
#if FML_OS_MACOSX
|
||||
@@ -316,11 +326,9 @@ ContextVK::ContextVK(
|
||||
/// Enable any and all validation as well as debug toggles.
|
||||
///
|
||||
auto has_debug_utils = false;
|
||||
constexpr const char* kKhronosValidationLayerName =
|
||||
"VK_LAYER_KHRONOS_validation";
|
||||
if (capabilities->HasLayer(kKhronosValidationLayerName)) {
|
||||
enabled_layers.push_back(kKhronosValidationLayerName);
|
||||
if (capabilities->HasLayerExtension(kKhronosValidationLayerName,
|
||||
if (vk::HasValidationLayers()) {
|
||||
enabled_layers.push_back(vk::kKhronosValidationLayerName);
|
||||
if (capabilities->HasLayerExtension(vk::kKhronosValidationLayerName,
|
||||
VK_EXT_DEBUG_UTILS_EXTENSION_NAME)) {
|
||||
enabled_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||
has_debug_utils = true;
|
||||
|
||||
@@ -23,6 +23,15 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
namespace vk {
|
||||
|
||||
constexpr const char* kKhronosValidationLayerName =
|
||||
"VK_LAYER_KHRONOS_validation";
|
||||
|
||||
bool HasValidationLayers();
|
||||
|
||||
} // namespace vk
|
||||
|
||||
class ContextVK final : public Context, public BackendCast<ContextVK, Context> {
|
||||
public:
|
||||
static std::shared_ptr<ContextVK> Create(
|
||||
@@ -40,12 +49,23 @@ class ContextVK final : public Context, public BackendCast<ContextVK, Context> {
|
||||
|
||||
template <typename T>
|
||||
bool SetDebugName(T handle, std::string_view label) const {
|
||||
return SetDebugName(*device_, handle, label);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static bool SetDebugName(vk::Device device,
|
||||
T handle,
|
||||
std::string_view label) {
|
||||
if (!vk::HasValidationLayers()) {
|
||||
// No-op if validation layers are not enabled.
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t handle_ptr =
|
||||
reinterpret_cast<uint64_t>(static_cast<typename T::NativeType>(handle));
|
||||
|
||||
std::string label_str = std::string(label);
|
||||
|
||||
auto ret = device_->setDebugUtilsObjectNameEXT(
|
||||
auto ret = device.setDebugUtilsObjectNameEXT(
|
||||
vk::DebugUtilsObjectNameInfoEXT()
|
||||
.setObjectType(T::objectType)
|
||||
.setObjectHandle(handle_ptr)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "impeller/base/promise.h"
|
||||
#include "impeller/base/validation.h"
|
||||
#include "impeller/renderer/backend/vulkan/context_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/formats_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/pipeline_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/shader_function_vk.h"
|
||||
@@ -372,6 +373,8 @@ std::unique_ptr<PipelineCreateInfoVK> PipelineLibraryVK::CreatePipeline(
|
||||
|
||||
vk::UniqueDescriptorSetLayout descriptor_set_layout =
|
||||
std::move(descriptor_set_create_res.value);
|
||||
ContextVK::SetDebugName(device_, descriptor_set_layout.get(),
|
||||
"descriptor_set_layout_" + desc.GetLabel());
|
||||
|
||||
vk::PipelineLayoutCreateInfo pipeline_layout_info;
|
||||
pipeline_layout_info.setSetLayouts(descriptor_set_layout.get());
|
||||
@@ -403,6 +406,11 @@ std::unique_ptr<PipelineCreateInfoVK> PipelineLibraryVK::CreatePipeline(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ContextVK::SetDebugName(device_, *pipeline_layout.value,
|
||||
"pipeline_layout_" + desc.GetLabel());
|
||||
ContextVK::SetDebugName(device_, *pipeline.value,
|
||||
"pipeline_" + desc.GetLabel());
|
||||
|
||||
return std::make_unique<PipelineCreateInfoVK>(
|
||||
std::move(pipeline.value), std::move(render_pass.value()),
|
||||
std::move(pipeline_layout.value), std::move(descriptor_set_layout));
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "impeller/blobcat/blob_library.h"
|
||||
#include "impeller/renderer/backend/vulkan/context_vk.h"
|
||||
#include "impeller/renderer/backend/vulkan/shader_function_vk.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -80,11 +81,15 @@ ShaderLibraryVK::ShaderLibraryVK(
|
||||
const auto stage = ToShaderStage(type);
|
||||
const auto key_name = VKShaderNameToShaderKeyName(name, stage);
|
||||
|
||||
vk::UniqueShaderModule shader_module = std::move(module.value);
|
||||
ContextVK::SetDebugName(device, *shader_module,
|
||||
"shader_module_" + key_name);
|
||||
|
||||
functions[ShaderKey{key_name, stage}] = std::shared_ptr<ShaderFunctionVK>(
|
||||
new ShaderFunctionVK(library_id, //
|
||||
key_name, //
|
||||
stage, //
|
||||
std::move(module.value) //
|
||||
new ShaderFunctionVK(library_id, //
|
||||
key_name, //
|
||||
stage, //
|
||||
std::move(shader_module) //
|
||||
));
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user