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
5
#include "
flutter/testing/testing.h
"
6
#include "
impeller/core/device_buffer_descriptor.h
"
7
#include "
impeller/core/formats.h
"
8
#include "
impeller/core/texture_descriptor.h
"
9
#include "
impeller/playground/playground_test.h
"
10
#include "
impeller/renderer/backend/metal/allocator_mtl.h
"
11
#include "
impeller/renderer/backend/metal/context_mtl.h
"
12
#include "
impeller/renderer/backend/metal/formats_mtl.h
"
13
#include "
impeller/renderer/backend/metal/texture_mtl.h
"
14
#include "
impeller/renderer/capabilities.h
"
15
16
#include <QuartzCore/CAMetalLayer.h>
17
#include <memory>
18
#include <thread>
19
20
#include "gtest/gtest.h"
21
22
namespace
impeller
{
23
namespace
testing {
24
25
using
ContextMTLTest
=
PlaygroundTest
;
26
INSTANTIATE_METAL_PLAYGROUND_SUITE
(
ContextMTLTest
);
27
28
TEST_P
(
ContextMTLTest
, FlushTask) {
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
41
TEST_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
allocator_mtl.h
capabilities.h
impeller::BackendCast< ContextMTL, Context >::Cast
static ContextMTL & Cast(Context &base)
Definition
backend_cast.h:13
impeller::PlaygroundTest
Definition
playground_test.h:22
device_buffer_descriptor.h
formats_mtl.h
formats.h
impeller::testing::TEST_P
TEST_P(AiksTest, DrawAtlasNoColor)
Definition
aiks_dl_atlas_unittests.cc:59
impeller
Definition
texture.h:16
playground_test.h
INSTANTIATE_METAL_PLAYGROUND_SUITE
#define INSTANTIATE_METAL_PLAYGROUND_SUITE(playground)
Definition
playground_test.h:68
context_mtl.h
testing.h
texture_descriptor.h
texture_mtl.h
impeller
renderer
backend
metal
context_mtl_unittests.mm
Generated on Thu Nov 6 2025 16:11:23 for Flutter Engine by
1.9.8