• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "src/trace_processor/importers/proto/graphics_event_module.h"
18 
19 namespace perfetto {
20 namespace trace_processor {
21 
22 using perfetto::protos::pbzero::TracePacket;
23 
GraphicsEventModule(TraceProcessorContext * context)24 GraphicsEventModule::GraphicsEventModule(TraceProcessorContext* context)
25     : parser_(context),
26       frame_parser_(context),
27       frame_timeline_parser_(context) {
28   RegisterForField(TracePacket::kFrameTimelineEventFieldNumber, context);
29   RegisterForField(TracePacket::kGpuCounterEventFieldNumber, context);
30   RegisterForField(TracePacket::kGpuRenderStageEventFieldNumber, context);
31   RegisterForField(TracePacket::kGpuLogFieldNumber, context);
32   RegisterForField(TracePacket::kGpuMemTotalEventFieldNumber, context);
33   RegisterForField(TracePacket::kGraphicsFrameEventFieldNumber, context);
34   RegisterForField(TracePacket::kVulkanMemoryEventFieldNumber, context);
35   RegisterForField(TracePacket::kVulkanApiEventFieldNumber, context);
36 }
37 
38 GraphicsEventModule::~GraphicsEventModule() = default;
39 
ParsePacket(const TracePacket::Decoder & decoder,const TimestampedTracePiece & ttp,uint32_t field_id)40 void GraphicsEventModule::ParsePacket(const TracePacket::Decoder& decoder,
41                                       const TimestampedTracePiece& ttp,
42                                       uint32_t field_id) {
43   switch (field_id) {
44     case TracePacket::kFrameTimelineEventFieldNumber:
45       frame_timeline_parser_.ParseFrameTimelineEvent(
46           ttp.timestamp, decoder.frame_timeline_event());
47       return;
48     case TracePacket::kGpuCounterEventFieldNumber:
49       parser_.ParseGpuCounterEvent(ttp.timestamp, decoder.gpu_counter_event());
50       return;
51     case TracePacket::kGpuRenderStageEventFieldNumber:
52       parser_.ParseGpuRenderStageEvent(ttp.timestamp,
53                                        ttp.packet_data.sequence_state.get(),
54                                        decoder.gpu_render_stage_event());
55       return;
56     case TracePacket::kGpuLogFieldNumber:
57       parser_.ParseGpuLog(ttp.timestamp, decoder.gpu_log());
58       return;
59     case TracePacket::kGraphicsFrameEventFieldNumber:
60       frame_parser_.ParseGraphicsFrameEvent(ttp.timestamp,
61                                             decoder.graphics_frame_event());
62       return;
63     case TracePacket::kVulkanMemoryEventFieldNumber:
64       PERFETTO_DCHECK(ttp.type == TimestampedTracePiece::Type::kTracePacket);
65       parser_.ParseVulkanMemoryEvent(ttp.packet_data.sequence_state.get(),
66                                      decoder.vulkan_memory_event());
67       return;
68     case TracePacket::kVulkanApiEventFieldNumber:
69       parser_.ParseVulkanApiEvent(ttp.timestamp, decoder.vulkan_api_event());
70       return;
71     case TracePacket::kGpuMemTotalEventFieldNumber:
72       parser_.ParseGpuMemTotalEvent(ttp.timestamp,
73                                     decoder.gpu_mem_total_event());
74       return;
75   }
76 }
77 
78 }  // namespace trace_processor
79 }  // namespace perfetto
80