mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 07:28:11 +02:00
gfxstream: add a vkTraceAsyncGOOGLE
... to allow sharing perfetto global flow ids between guest and host so that combined traces can have an arrow between the guest and host render threads to aid debugging. Test: Capture guest and host trace and inspect in perfetto UI Reviewed-by: Aaron Ruby <aruby@qnx.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37410>
This commit is contained in:
parent
8b6107826e
commit
46bfb31d7f
3 changed files with 50 additions and 1 deletions
|
|
@ -791,6 +791,7 @@ custom_decodes = {
|
|||
"vkGetMemoryHostAddressInfoGOOGLE" : emit_global_state_wrapped_decoding,
|
||||
"vkGetBlobGOOGLE" : emit_global_state_wrapped_decoding,
|
||||
"vkGetSemaphoreGOOGLE" : emit_global_state_wrapped_decoding,
|
||||
"vkTraceAsyncGOOGLE" : emit_global_state_wrapped_decoding,
|
||||
|
||||
# Descriptor update templates
|
||||
"vkCreateDescriptorUpdateTemplate" : emit_global_state_wrapped_decoding,
|
||||
|
|
|
|||
|
|
@ -239,7 +239,11 @@ specific entries.
|
|||
<proto><type>VkResult</type> <name>vkGetSemaphoreGOOGLE</name></proto>
|
||||
<param><type>VkDevice</type> <name>device</name></param>
|
||||
<param><type>VkSemaphore</type> <name>semaphore</name></param>
|
||||
<param><type>uint64_t</type> <name>syncId</name></param>
|
||||
<param><type>uint64_t</type> <name>syncId</name></param>
|
||||
</command>
|
||||
<command>
|
||||
<proto><type>void</type> <name>vkTraceAsyncGOOGLE</name></proto>
|
||||
<param><type>uint64_t</type> <name>id</name></param>
|
||||
</command>
|
||||
</commands>
|
||||
<extensions comment="Vulkan extension interface definitions">
|
||||
|
|
@ -280,6 +284,7 @@ specific entries.
|
|||
<command name="vkUpdateDescriptorSetWithTemplateSized2GOOGLE"/>
|
||||
<command name="vkQueueSubmitAsync2GOOGLE"/>
|
||||
<command name="vkGetSemaphoreGOOGLE"/>
|
||||
<command name="vkTraceAsyncGOOGLE"/>
|
||||
</require>
|
||||
</extension>
|
||||
</extensions>
|
||||
|
|
|
|||
|
|
@ -30,11 +30,24 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <random>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#ifdef HAVE_PERFETTO
|
||||
#include <perfetto/tracing.h>
|
||||
|
||||
#define GFXSTREAM_TRACE_DEFAULT_CATEGORY "gfxstream.default"
|
||||
|
||||
PERFETTO_DEFINE_CATEGORIES(
|
||||
perfetto::Category(GFXSTREAM_TRACE_DEFAULT_CATEGORY)
|
||||
.SetDescription("Default events")
|
||||
.SetTags("default"));
|
||||
|
||||
#endif // HAVE_PERFETTO
|
||||
|
||||
#include "vk_util.h"
|
||||
|
||||
#if DETECT_OS_LINUX
|
||||
|
|
@ -78,8 +91,36 @@ static T vk_make_orphan_copy(const T& vk_struct) {
|
|||
return copy;
|
||||
}
|
||||
|
||||
|
||||
namespace gfxstream {
|
||||
namespace vk {
|
||||
namespace {
|
||||
|
||||
#ifdef HAVE_PERFETTO
|
||||
uint64_t GeneratePseudoUniqueId() {
|
||||
thread_local std::mt19937 generator(std::random_device{}());
|
||||
std::uniform_int_distribution<uint64_t> distribution(0, std::numeric_limits<uint64_t>::max());
|
||||
return distribution(generator);
|
||||
}
|
||||
#endif
|
||||
|
||||
void EmitGuestAndHostTraceMarker(VkEncoder* encoder) {
|
||||
#ifdef HAVE_PERFETTO
|
||||
const uint64_t flowId = GeneratePseudoUniqueId();
|
||||
|
||||
TRACE_EVENT_INSTANT(
|
||||
GFXSTREAM_TRACE_DEFAULT_CATEGORY,
|
||||
"vkTraceAsyncGOOGLE",
|
||||
perfetto::Flow::Global(flowId),
|
||||
"flow id", flowId);
|
||||
|
||||
encoder->vkTraceAsyncGOOGLE(flowId, true /* do lock */);
|
||||
#else
|
||||
(void)encoder;
|
||||
#endif // HAVE_PERFETTO
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#define MAKE_HANDLE_MAPPING_FOREACH(type_name, map_impl, map_to_u64_impl, map_from_u64_impl) \
|
||||
void mapHandles_##type_name(type_name* handles, size_t count) override { \
|
||||
|
|
@ -6111,6 +6152,7 @@ VkResult ResourceTracker::on_vkQueueSubmit(void* context, VkResult input_result,
|
|||
uint32_t submitCount, const VkSubmitInfo* pSubmits,
|
||||
VkFence fence) {
|
||||
MESA_TRACE_SCOPE("on_vkQueueSubmit");
|
||||
EmitGuestAndHostTraceMarker((VkEncoder*)context);
|
||||
|
||||
/* From the Vulkan 1.3.204 spec:
|
||||
*
|
||||
|
|
@ -6148,6 +6190,7 @@ VkResult ResourceTracker::on_vkQueueSubmit2(void* context, VkResult input_result
|
|||
uint32_t submitCount, const VkSubmitInfo2* pSubmits,
|
||||
VkFence fence) {
|
||||
MESA_TRACE_SCOPE("on_vkQueueSubmit2");
|
||||
EmitGuestAndHostTraceMarker((VkEncoder*)context);
|
||||
return on_vkQueueSubmitTemplate<VkSubmitInfo2, VkSemaphoreSubmitInfo>(context, input_result, queue, submitCount,
|
||||
pSubmits, fence);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue