• 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(uint64_t ts, uint32_t itid);
36     bool BeginRSTransactionData(uint64_t ts, uint32_t itid, uint32_t franeNum);
37     typedef struct {
38         uint32_t sourceItid;
39         uint32_t frameNum;
40     } FrameMap;
41     bool BeginProcessCommandUni(uint64_t ts, 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     void Clear();
UpdateReadySize()46     void UpdateReadySize()
47     {
48         UpdateFrameSliceReadySize();
49     }
50 
51 private:
52     bool UpdateFrameSliceReadySize();
53     void SetMinFrameSliceRow(uint64_t &minFrameSliceRowToBeUpdated);
54 
55 private:
56     class FrameSlice {
57     public:
FrameSlice()58         FrameSlice() {}
59         uint64_t startTs_ = INVALID_UINT64;
60         // @deprecated it will be deleted later
61         uint64_t expectedStartTs_ = INVALID_UINT64;
62         // if a frame experience video lag, is depend on if the real end ts is later then the expected ts, rather then
63         // the dur. noted at 2023/4/6
64         uint64_t expectedEndTs_ = INVALID_UINT64;
65         // @deprecated it will be deleted later
66         uint64_t expectedDur_ = INVALID_UINT64;
67         uint64_t endTs_ = INVALID_UINT64;
68         bool gpuEnd_ = true;
69         TraceStdtype::FrameSlice::FrameSliceType frameType_ = TraceStdtype::FrameSlice::ACTURAL_SLICE;
70         uint32_t vsyncId_ = INVALID_UINT32;
71         uint64_t frameQueueStartTs_ = INVALID_UINT64;
72         bool vsyncEnd_ = false;
73         bool isRsMainThread_ = false;
74         uint32_t frameNum_ = INVALID_UINT32;
75         uint64_t callStackSliceId_ = INVALID_UINT64;
76         uint64_t frameSliceRow_ = INVALID_UINT64;
77         uint64_t frameExpectedSliceRow_ = INVALID_UINT64;
78         std::vector<uint64_t> sourceSlice_ = {};
79         std::vector<uint64_t> sourceExpectedSlice_ = {};
80         uint64_t dstFrameSliceId_ = INVALID_UINT64;
81         uint64_t dstExpectedFrameSliceId_ = INVALID_UINT64;
82     };
83     std::unordered_map<uint32_t /* tid */, std::vector<std::shared_ptr<FrameSlice>>> vsyncRenderSlice_ = {};
84     std::unordered_map<uint32_t /* tid */, std::unordered_map<uint32_t /* frameNum */, std::shared_ptr<FrameSlice>>>
85         dstRenderSlice_ = {};
86 };
87 } // namespace TraceStreamer
88 } // namespace SysTuning
89 #endif
90