Mikhail Khokhlov | 785af54 | 2019-12-06 13:45:10 +0000 | [diff] [blame] | 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 | |
| 24 | GraphicsEventModule::GraphicsEventModule(TraceProcessorContext* context) |
| 25 | : parser_(context) { |
| 26 | RegisterForField(TracePacket::kGpuCounterEventFieldNumber, context); |
| 27 | RegisterForField(TracePacket::kGpuRenderStageEventFieldNumber, context); |
| 28 | RegisterForField(TracePacket::kGpuLogFieldNumber, context); |
| 29 | RegisterForField(TracePacket::kGraphicsFrameEventFieldNumber, context); |
| 30 | RegisterForField(TracePacket::kVulkanMemoryEventFieldNumber, context); |
| 31 | } |
| 32 | |
| 33 | GraphicsEventModule::~GraphicsEventModule() = default; |
| 34 | |
| 35 | void GraphicsEventModule::ParsePacket(const TracePacket::Decoder& decoder, |
| 36 | const TimestampedTracePiece& ttp, |
| 37 | uint32_t field_id) { |
| 38 | switch (field_id) { |
| 39 | case TracePacket::kGpuCounterEventFieldNumber: |
| 40 | parser_.ParseGpuCounterEvent(ttp.timestamp, decoder.gpu_counter_event()); |
| 41 | return; |
| 42 | case TracePacket::kGpuRenderStageEventFieldNumber: |
| 43 | parser_.ParseGpuRenderStageEvent(ttp.timestamp, |
| 44 | decoder.gpu_render_stage_event()); |
| 45 | return; |
| 46 | case TracePacket::kGpuLogFieldNumber: |
| 47 | parser_.ParseGpuLog(ttp.timestamp, decoder.gpu_log()); |
| 48 | return; |
| 49 | case TracePacket::kGraphicsFrameEventFieldNumber: |
| 50 | parser_.ParseGraphicsFrameEvent(ttp.timestamp, |
| 51 | decoder.graphics_frame_event()); |
| 52 | return; |
| 53 | case TracePacket::kVulkanMemoryEventFieldNumber: |
| 54 | parser_.ParseVulkanMemoryEvent(ttp.packet_sequence_state, |
| 55 | ttp.packet_sequence_state_generation, |
| 56 | decoder.vulkan_memory_event()); |
| 57 | return; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | } // namespace trace_processor |
| 62 | } // namespace perfetto |