• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FRAME_FILTER_H
17 #define FRAME_FILTER_H
18 #include <vector>
19 #include "common_types.h"
20 #include "double_map.h"
21 #include "filter_base.h"
22 #include "trace_data_cache.h"
23 #include "trace_streamer_filters.h"
24 namespace SysTuning {
25 namespace TraceStreamer {
26 class FrameFilter : private FilterBase {
27 public:
28     FrameFilter(TraceDataCache *dataCache, const TraceStreamerFilters *filter);
29     ~FrameFilter() override;
30     void BeginVsyncEvent(const BytraceLine &line,
31                          uint64_t expectStart,
32                          uint64_t expectEnd,
33                          uint32_t vsyncId,
34                          uint32_t callStackSliceId);
35     bool MarkRSOnDoCompositionEvent(uint32_t itid);
36     bool BeginRSTransactionData(uint32_t currentThreadId, uint32_t frameNum, uint32_t mainThreadId);
37     typedef struct {
38         uint32_t sourceItid;
39         uint32_t frameNum;
40     } FrameMap;
41     bool BeginProcessCommandUni(uint32_t itid, const std::vector<FrameMap> &frame, uint32_t sliceIndex);
42     bool EndVsyncEvent(uint64_t ts, uint32_t itid);
43     bool StartFrameQueue(uint64_t ts, uint32_t itid);
44     bool EndFrameQueue(uint64_t ts, uint32_t itid);
45     bool UpdateVsyncId(const BytraceLine &line, uint32_t vsyncId);
46     void BeginUVTraceEvent(const BytraceLine &line, uint32_t callStackSliceId);
47     void Clear();
UpdateReadySize()48     void UpdateReadySize()
49     {
50         UpdateFrameSliceReadySize();
51     }
52 
53 private:
54     bool UpdateFrameSliceReadySize();
55     void SetMinFrameSliceRow(uint64_t &minFrameSliceRowToBeUpdated);
56 
57 private:
58     class FrameSlice {
59     public:
FrameSlice()60         FrameSlice() {}
61         uint64_t startTs_ = INVALID_UINT64;
62         // @deprecated it will be deleted later
63         uint64_t expectedStartTs_ = INVALID_UINT64;
64         // if a frame experience video lag, is depend on if the real end ts is later then the expected ts, rather then
65         // the dur. noted at 2023/4/6
66         uint64_t expectedEndTs_ = INVALID_UINT64;
67         // @deprecated it will be deleted later
68         uint64_t expectedDur_ = INVALID_UINT64;
69         uint64_t endTs_ = INVALID_UINT64;
70         bool gpuEnd_ = true;
71         TraceStdtype::FrameSlice::FrameSliceType frameType_ = TraceStdtype::FrameSlice::ACTURAL_SLICE;
72         uint32_t vsyncId_ = INVALID_UINT32;
73         uint64_t frameQueueStartTs_ = INVALID_UINT64;
74         bool vsyncEnd_ = false;
75         bool isRsMainThread_ = false;
76         uint32_t frameNum_ = INVALID_UINT32;
77         uint64_t callStackSliceId_ = INVALID_UINT64;
78         uint64_t frameSliceRow_ = INVALID_UINT64;
79         uint64_t frameExpectedSliceRow_ = INVALID_UINT64;
80         std::vector<uint64_t> sourceSlice_ = {};
81         std::vector<uint64_t> sourceExpectedSlice_ = {};
82         uint64_t dstFrameSliceId_ = INVALID_UINT64;
83         uint64_t dstExpectedFrameSliceId_ = INVALID_UINT64;
84         bool isUVTrace_ = false;
85     };
86     std::unordered_map<uint32_t /* tid */, std::vector<std::shared_ptr<FrameSlice>>> vsyncRenderSlice_ = {};
87     std::unordered_map<uint32_t /* tid */, std::unordered_map<uint32_t /* frameNum */, std::shared_ptr<FrameSlice>>>
88         dstRenderSlice_ = {};
89 };
90 } // namespace TraceStreamer
91 } // namespace SysTuning
92 #endif
93