gfxstream: hide vkTraceAsyncGOOGLE behind new capset flag

... to make it forward compatible / to make it not crash older
Gfxstream host builds.

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:
Jason Macnak
2025-08-21 19:34:30 +00:00
committed by Marge Bot
parent 46bfb31d7f
commit 2e56f34952
3 changed files with 21 additions and 16 deletions
@@ -104,22 +104,6 @@ uint64_t GeneratePseudoUniqueId() {
}
#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) \
@@ -802,6 +786,24 @@ CoherentMemoryPtr ResourceTracker::freeCoherentMemoryLocked(VkDeviceMemory memor
return nullptr;
}
void ResourceTracker::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);
if (mCaps.vulkanCapset.hasTraceAsyncCommand) {
encoder->vkTraceAsyncGOOGLE(flowId, true /* do lock */);
}
#else
(void)encoder;
#endif // HAVE_PERFETTO
}
VkResult acquireSync(uint64_t syncId, int64_t& osHandle) {
struct VirtGpuExecBuffer exec = {};
struct gfxstreamAcquireSync acquireSync = {};
@@ -885,6 +885,8 @@ class ResourceTracker {
void transformImageMemoryRequirementsForGuestLocked(VkImage image, VkMemoryRequirements* reqs);
CoherentMemoryPtr freeCoherentMemoryLocked(VkDeviceMemory memory, VkDeviceMemory_Info& info);
void EmitGuestAndHostTraceMarker(VkEncoder* encoder);
std::recursive_mutex mLock;
std::optional<const VkPhysicalDeviceMemoryProperties> mCachedPhysicalDeviceMemoryProps;
@@ -106,6 +106,7 @@ struct vulkanCapset {
uint32_t externalSync;
uint32_t virglSupportedFormats[16];
uint32_t vulkanBatchedDescriptorSetUpdate;
uint32_t hasTraceAsyncCommand;
};
struct magmaCapset {