Flutter Engine
 
Loading...
Searching...
No Matches
context_mtl_unittests.mm
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
15
16#include <QuartzCore/CAMetalLayer.h>
17#include <memory>
18#include <thread>
19
20#include "gtest/gtest.h"
21
22namespace impeller {
23namespace testing {
24
27
29 auto& context_mtl = ContextMTL::Cast(*GetContext());
30
31 int executed = 0;
32 int failed = 0;
33 context_mtl.StoreTaskForGPU([&]() { executed++; }, [&]() { failed++; });
34
35 context_mtl.FlushTasksAwaitingGPU();
36
37 EXPECT_EQ(executed, 1);
38 EXPECT_EQ(failed, 0);
39}
40
41TEST_P(ContextMTLTest, FlushTaskWithGPULoss) {
42 auto& context_mtl = ContextMTL::Cast(*GetContext());
43
44 int executed = 0;
45 int failed = 0;
46 context_mtl.StoreTaskForGPU([&]() { executed++; }, [&]() { failed++; });
47
48 // If tasks are flushed while the GPU is disabled, then
49 // they should not be executed.
50 SetGPUDisabled(/*disabled=*/true);
51 context_mtl.FlushTasksAwaitingGPU();
52
53 EXPECT_EQ(executed, 0);
54 EXPECT_EQ(failed, 0);
55
56 // Toggling availibility should flush tasks.
57 SetGPUDisabled(/*disabled=*/false);
58
59 EXPECT_EQ(executed, 1);
60 EXPECT_EQ(failed, 0);
61}
62
63} // namespace testing
64} // namespace impeller
static ContextMTL & Cast(Context &base)
TEST_P(AiksTest, DrawAtlasNoColor)
#define INSTANTIATE_METAL_PLAYGROUND_SUITE(playground)