From fb4b9a0045caa4f73740d08bf77f086ace5a538b Mon Sep 17 00:00:00 2001 From: David Donaldson Date: Wed, 14 Jun 2023 16:39:30 -0700 Subject: [PATCH] Provide func ptrs for debug marker cmds in capture Some VR applications use debug markers to identify frame boundaries but not all VR devices provide support for VK_EXT_debug_marker. With this change GFXR provides function pointers for the extension's functions in order to capture the debug marker calls and track VR frames. --- framework/decode/vulkan_feature_util.cpp | 1 + layer/trace_layer.cpp | 55 +++++++++++++++++++----- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/framework/decode/vulkan_feature_util.cpp b/framework/decode/vulkan_feature_util.cpp index d490b2900a..16b5558798 100644 --- a/framework/decode/vulkan_feature_util.cpp +++ b/framework/decode/vulkan_feature_util.cpp @@ -43,6 +43,7 @@ GFXRECON_BEGIN_NAMESPACE(feature_util) // no longer there) std::set kIgnorableExtensions = { VK_EXT_TOOLING_INFO_EXTENSION_NAME, + VK_EXT_DEBUG_MARKER_EXTENSION_NAME, }; VkResult GetInstanceLayers(PFN_vkEnumerateInstanceLayerProperties instance_layer_proc, diff --git a/layer/trace_layer.cpp b/layer/trace_layer.cpp index 2bea19d21a..1092fefe8c 100644 --- a/layer/trace_layer.cpp +++ b/layer/trace_layer.cpp @@ -1,6 +1,6 @@ /* ** Copyright (c) 2018-2020 Valve Corporation -** Copyright (c) 2018-2020 LunarG, Inc. +** Copyright (c) 2018-2023 LunarG, Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and associated documentation files (the "Software"), @@ -34,10 +34,12 @@ #include "vulkan/vk_layer.h" +#include #include #include #include #include +#include #include GFXRECON_BEGIN_NAMESPACE(gfxrecon) @@ -52,7 +54,16 @@ const VkLayerProperties kLayerProps = { GFXRECON_PROJECT_VERSION_DESIGNATION }; -const std::vector kDeviceExtensionProps = { VkExtensionProperties{ "VK_EXT_tooling_info", 1 } }; +const std::array kDeviceExtensionProps = { + VkExtensionProperties{ "VK_EXT_tooling_info", 1 }, + VkExtensionProperties{ VK_EXT_DEBUG_MARKER_EXTENSION_NAME, VK_EXT_DEBUG_MARKER_SPEC_VERSION } +}; + +const std::unordered_set kProvidedDeviceFunctions = { "vkCmdDebugMarkerBeginEXT", + "vkCmdDebugMarkerEndEXT", + "vkCmdDebugMarkerInsertEXT", + "vkDebugMarkerSetObjectNameEXT", + "vkDebugMarkerSetObjectTagEXT" }; /// An alphabetical list of device extensions which we do not report upstream if /// other layers or ICDs expose them to us. @@ -301,10 +312,10 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, cons { result = table->GetDeviceProcAddr(device, pName); - if (result != nullptr) + if (result != nullptr || (kProvidedDeviceFunctions.find(pName) != kProvidedDeviceFunctions.end())) { // Only check for a layer implementation of the requested function if it is available from the next - // level. + // level or if we are providing the implementation ourselves. const auto entry = func_table.find(pName); if (entry != func_table.end()) { @@ -390,31 +401,53 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevi return result; } - std::vector downstream_properties(downstream_property_count); + std::vector device_extension_properties(downstream_property_count); result = instance_table->EnumerateDeviceExtensionProperties( - physicalDevice, pLayerName, &downstream_property_count, downstream_properties.data()); + physicalDevice, pLayerName, &downstream_property_count, device_extension_properties.data()); if (result != VK_SUCCESS) { return result; } - remove_extensions(downstream_properties, + remove_extensions(device_extension_properties, kUnsupportedDeviceExtensions, std::end(kUnsupportedDeviceExtensions) - std::begin(kUnsupportedDeviceExtensions)); + // Append the extensions we provide in the list to the caller if they aren't already provided downstream. + if (pLayerName == nullptr) + { + for (auto& provided_prop : kDeviceExtensionProps) + { + bool append_provided_prop = + std::find_if(device_extension_properties.begin(), + device_extension_properties.end(), + [&provided_prop](const VkExtensionProperties& downstream_prop) { + return util::platform::StringCompare(provided_prop.extensionName, + downstream_prop.extensionName, + VK_MAX_EXTENSION_NAME_SIZE) == 0; + }) == device_extension_properties.end(); + if (append_provided_prop) + { + device_extension_properties.push_back(provided_prop); + } + } + } + // Output the reduced count or the reduced extension list: if (pProperties == nullptr) { - *pPropertyCount = static_cast(downstream_properties.size()); + *pPropertyCount = static_cast(device_extension_properties.size()); } else { - if (*pPropertyCount < static_cast(downstream_properties.size())) + if (*pPropertyCount < static_cast(device_extension_properties.size())) { result = VK_INCOMPLETE; } - *pPropertyCount = std::min(*pPropertyCount, static_cast(downstream_properties.size())); - std::copy(downstream_properties.begin(), downstream_properties.begin() + *pPropertyCount, pProperties); + *pPropertyCount = std::min(*pPropertyCount, static_cast(device_extension_properties.size())); + std::copy(device_extension_properties.begin(), + device_extension_properties.begin() + *pPropertyCount, + pProperties); } }