xref: /aosp_15_r20/external/mesa3d/src/tool/pps/pps_producer.cc (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2019-2020 Collabora, Ltd.
3  * Author: Antonio Caggiano <[email protected]>
4  * Author: Robert Beckett <[email protected]>
5  * Author: Corentin Noël <[email protected]>
6  *
7  * SPDX-License-Identifier: MIT
8  */
9 
10 #include <cstdlib>
11 
12 #include "pps_datasource.h"
13 
main(int argc,const char ** argv)14 int main(int argc, const char **argv)
15 {
16    using namespace pps;
17 
18    // Connects to the system tracing service
19    perfetto::TracingInitArgs args;
20    args.backends = perfetto::kSystemBackend;
21    perfetto::Tracing::Initialize(args);
22 
23    std::string driver_name =
24       (argc > 1) ? Driver::find_driver_name(argv[1]) : Driver::default_driver_name();
25    GpuDataSource::register_data_source(driver_name);
26 
27    const auto &driver = Driver::get_supported_drivers().at(driver_name);
28    if (!driver->is_dump_perfcnt_preemptible())
29       make_thread_rt();
30 
31    while (true) {
32       GpuDataSource::wait_started();
33       GpuDataSource::Trace(GpuDataSource::trace_callback);
34    }
35 
36    return EXIT_SUCCESS;
37 }
38