diff --git a/Android.bp b/Android.bp index 9493cdb0d0c..130248d543c 100644 --- a/Android.bp +++ b/Android.bp @@ -157,6 +157,8 @@ cc_defaults { "-DHAVE___BUILTIN_CLZ", "-DHAVE___BUILTIN_CLZLL", "-DHAVE___BUILTIN_UNREACHABLE", + "-DHAVE_PERFETTO", + "-DANDROID_LIBPERFETTO", "-DHAVE_PTHREAD=1", "-DHAVE_DLADDR", "-DHAVE_DL_ITERATE_PHDR", diff --git a/meson.build b/meson.build index 3be192356ec..2b7713472cd 100644 --- a/meson.build +++ b/meson.build @@ -2144,14 +2144,22 @@ else pre_args += '-DCUSTOM_SHADER_REPLACEMENT' endif +allow_fallback_for_perfetto = get_option('allow-fallback-for').contains('perfetto') with_perfetto = get_option('perfetto') with_datasources = get_option('datasources') with_any_datasource = with_datasources.length() != 0 if with_perfetto - dep_perfetto = dependency('perfetto', fallback: ['perfetto', 'dep_perfetto']) + dep_perfetto = dependency( + 'perfetto', + fallback: allow_fallback_for_perfetto ? ['perfetto', 'dep_perfetto'] : [], + ) pre_args += '-DHAVE_PERFETTO' endif +if get_option('android-libperfetto').enabled() + pre_args += '-DANDROID_LIBPERFETTO' +endif + with_teflon = get_option('teflon') if with_teflon and with_tests dep_xtensor = dependency('xtensor') diff --git a/meson.options b/meson.options index 51a644ad310..8f588fc682a 100644 --- a/meson.options +++ b/meson.options @@ -51,6 +51,12 @@ option( description : 'Use Android\'s libbacktrace', ) +option( + 'android-libperfetto', + type : 'feature', + description : 'Use Android\'s libperfetto', +) + option( 'dri-drivers-path', type : 'string', @@ -844,9 +850,9 @@ option( option( 'allow-fallback-for', type : 'array', - value : [], + value : ['perfetto'], choices : [ - 'libdrm', + 'libdrm', 'perfetto', ], description : 'Allows the fallback mechanism if the dependency is not available on the system, or too old.' ) diff --git a/src/gallium/targets/lavapipe/Android.bp b/src/gallium/targets/lavapipe/Android.bp index 04cc89a737e..14a542d4701 100644 --- a/src/gallium/targets/lavapipe/Android.bp +++ b/src/gallium/targets/lavapipe/Android.bp @@ -101,6 +101,7 @@ cc_library_shared { "mesa_wsw", "mesa_loader", "libLLVM16_swiftshader", + "libperfetto_client_experimental", ], shared_libs: [ "libzstd", diff --git a/src/gfxstream/guest/vulkan/Android.bp b/src/gfxstream/guest/vulkan/Android.bp index 195a803e0bd..be0badd00c4 100644 --- a/src/gfxstream/guest/vulkan/Android.bp +++ b/src/gfxstream/guest/vulkan/Android.bp @@ -53,6 +53,7 @@ cc_library_shared { "libringbuffer", "libqemupipe.ranchu", "libarect", + "libperfetto_client_experimental", "mesa_gfxstream_aemu", "mesa_gfxstream_guest_android", "mesa_gfxstream_connection_manager", diff --git a/src/gfxstream/guest/vulkan_enc/Android.bp b/src/gfxstream/guest/vulkan_enc/Android.bp index d657c0f7145..f9bce25c6af 100644 --- a/src/gfxstream/guest/vulkan_enc/Android.bp +++ b/src/gfxstream/guest/vulkan_enc/Android.bp @@ -48,6 +48,7 @@ cc_library_static { vendor: true, defaults: [ "mesa_common_defaults", + "mesa_gfxstream_guest_cc_defaults", ], header_libs: [ "mesa_common_headers", diff --git a/src/tool/pps/pps.h b/src/tool/pps/pps.h index 2be10628de4..31ae565c43f 100644 --- a/src/tool/pps/pps.h +++ b/src/tool/pps/pps.h @@ -7,7 +7,16 @@ #pragma once +#ifndef ANDROID_LIBPERFETTO #include +#else +#include +#include +#include +#include +#include +#include +#endif #define PPS_LOG PERFETTO_LOG #define PPS_LOG_IMPORTANT PERFETTO_ILOG diff --git a/src/util/Android.bp b/src/util/Android.bp index 947eb60f1d9..f360771cec4 100644 --- a/src/util/Android.bp +++ b/src/util/Android.bp @@ -101,6 +101,7 @@ cc_library_static { "driconf_static_header", ], static_libs: [ + "libperfetto_client_experimental", "mesa_util_c11", ], shared_libs: [ @@ -138,6 +139,7 @@ cc_library_static { "os_socket.c", "pb_slab.c", "perf/u_trace.c", + "perf/u_perfetto.cc", "u_process.c", "u_qsort.cpp", "rwlock.c", diff --git a/src/util/perf/u_perfetto.cc b/src/util/perf/u_perfetto.cc index 5b91011ff26..e612b333991 100644 --- a/src/util/perf/u_perfetto.cc +++ b/src/util/perf/u_perfetto.cc @@ -23,7 +23,11 @@ #include "u_perfetto.h" +#ifndef ANDROID_LIBPERFETTO #include +#else +#include +#endif #include "c11/threads.h" #include "util/macros.h" diff --git a/src/util/perf/u_perfetto_renderpass.h b/src/util/perf/u_perfetto_renderpass.h index e4b95e6466e..1ad73d51892 100644 --- a/src/util/perf/u_perfetto_renderpass.h +++ b/src/util/perf/u_perfetto_renderpass.h @@ -23,7 +23,11 @@ #include "vulkan/runtime/vk_object.h" -#include "perfetto.h" +#ifndef ANDROID_LIBPERFETTO +#include +#else +#include +#endif #include "util/hash_table.h" #include "util/perf/u_trace.h" diff --git a/src/util/perf/u_trace.py b/src/util/perf/u_trace.py index 7502d60ec3d..8fbd406eb15 100644 --- a/src/util/perf/u_trace.py +++ b/src/util/perf/u_trace.py @@ -673,7 +673,14 @@ perfetto_utils_hdr_template = """\ #ifndef ${guard_name} #define ${guard_name} +#ifndef ANDROID_LIBPERFETTO #include +#else +#include +#include +#include +#include +#endif % for header in HEADERS: #include "${header.hdr}" diff --git a/src/vulkan/wsi/Android.bp b/src/vulkan/wsi/Android.bp index 388a9355666..a06770f64bf 100644 --- a/src/vulkan/wsi/Android.bp +++ b/src/vulkan/wsi/Android.bp @@ -55,7 +55,6 @@ cc_library_static { static_libs: [ "mesa_vulkan_util", "mesa_vulkan_runtime", - "mesa_gfxstream_vulkan_entrypoints", "mesa_util", "libdrm", ],