Skip to content

Commit

Permalink
[DisplayList] Allow random access to ops through indexing (flutter#54484
Browse files Browse the repository at this point in the history
)

Being able to reorder rendering commands leads to optimization opportunities in the graphics package. A graphics package being fed from a DisplayList either has to take the commands in the order given or implement their own storage format for the rendering data.

With this new dispatching mechanism, the graphics package can both query basic information about the recorded ops and even dispatch them by the index into the list. Query information includes either the "category" of the op (clip/transform/render, etc.) or a specific op type enum. The package can dispatch some categories (or ops) immediately and remember other categories (or ops) along with their state for dispatching later.
  • Loading branch information
flar authored Aug 13, 2024
1 parent ce73a8b commit db034a5
Show file tree
Hide file tree
Showing 8 changed files with 1,355 additions and 463 deletions.
94 changes: 94 additions & 0 deletions display_list/benchmarking/dl_builder_benchmarks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,60 @@ static void BM_DisplayListDispatchDefault(
}
}

static void BM_DisplayListDispatchByIndexDefault(
benchmark::State& state,
DisplayListDispatchBenchmarkType type) {
bool prepare_rtree = NeedPrepareRTree(type);
DisplayListBuilder builder(prepare_rtree);
for (int i = 0; i < 5; i++) {
InvokeAllOps(builder);
}
auto display_list = builder.Build();
DlOpReceiverIgnore receiver;
while (state.KeepRunning()) {
DlIndex end = display_list->GetRecordCount();
for (DlIndex i = 0u; i < end; i++) {
display_list->Dispatch(receiver, i);
}
}
}

static void BM_DisplayListDispatchByIteratorDefault(
benchmark::State& state,
DisplayListDispatchBenchmarkType type) {
bool prepare_rtree = NeedPrepareRTree(type);
DisplayListBuilder builder(prepare_rtree);
for (int i = 0; i < 5; i++) {
InvokeAllOps(builder);
}
auto display_list = builder.Build();
DlOpReceiverIgnore receiver;
while (state.KeepRunning()) {
for (DlIndex i : *display_list) {
display_list->Dispatch(receiver, i);
}
}
}

static void BM_DisplayListDispatchByVectorDefault(
benchmark::State& state,
DisplayListDispatchBenchmarkType type) {
bool prepare_rtree = NeedPrepareRTree(type);
DisplayListBuilder builder(prepare_rtree);
for (int i = 0; i < 5; i++) {
InvokeAllOps(builder);
}
auto display_list = builder.Build();
DlOpReceiverIgnore receiver;
while (state.KeepRunning()) {
std::vector<DlIndex> indices =
display_list->GetCulledIndices(display_list->bounds());
for (DlIndex index : indices) {
display_list->Dispatch(receiver, index);
}
}
}

static void BM_DisplayListDispatchCull(benchmark::State& state,
DisplayListDispatchBenchmarkType type) {
bool prepare_rtree = NeedPrepareRTree(type);
Expand All @@ -236,6 +290,26 @@ static void BM_DisplayListDispatchCull(benchmark::State& state,
}
}

static void BM_DisplayListDispatchByVectorCull(
benchmark::State& state,
DisplayListDispatchBenchmarkType type) {
bool prepare_rtree = NeedPrepareRTree(type);
DisplayListBuilder builder(prepare_rtree);
for (int i = 0; i < 5; i++) {
InvokeAllOps(builder);
}
auto display_list = builder.Build();
SkRect rect = SkRect::MakeLTRB(0, 0, 100, 100);
EXPECT_FALSE(rect.contains(display_list->bounds()));
DlOpReceiverIgnore receiver;
while (state.KeepRunning()) {
std::vector<DlIndex> indices = display_list->GetCulledIndices(rect);
for (DlIndex index : indices) {
display_list->Dispatch(receiver, index);
}
}
}

BENCHMARK_CAPTURE(BM_DisplayListBuilderDefault,
kDefault,
DisplayListBuilderBenchmarkType::kDefault)
Expand Down Expand Up @@ -370,4 +444,24 @@ BENCHMARK_CAPTURE(BM_DisplayListDispatchCull,
DisplayListDispatchBenchmarkType::kCulledWithRtree)
->Unit(benchmark::kMicrosecond);

BENCHMARK_CAPTURE(BM_DisplayListDispatchByIndexDefault,
kDefaultNoRtree,
DisplayListDispatchBenchmarkType::kDefaultNoRtree)
->Unit(benchmark::kMicrosecond);

BENCHMARK_CAPTURE(BM_DisplayListDispatchByIteratorDefault,
kDefaultNoRtree,
DisplayListDispatchBenchmarkType::kDefaultNoRtree)
->Unit(benchmark::kMicrosecond);

BENCHMARK_CAPTURE(BM_DisplayListDispatchByVectorDefault,
kDefaultNoRtree,
DisplayListDispatchBenchmarkType::kDefaultNoRtree)
->Unit(benchmark::kMicrosecond);

BENCHMARK_CAPTURE(BM_DisplayListDispatchByVectorCull,
kCulledWithRtree,
DisplayListDispatchBenchmarkType::kCulledWithRtree)
->Unit(benchmark::kMicrosecond);

} // namespace flutter
Loading

0 comments on commit db034a5

Please sign in to comment.