Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
blit_command_vk_unittests.cc
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" // IWYU pragma: keep
9
10namespace impeller {
11namespace testing {
12
14 auto context = MockVulkanContextBuilder().Build();
15 auto pool = context->GetCommandPoolRecycler()->Get();
16 auto encoder = std::make_unique<CommandEncoderFactoryVK>(context)->Create();
18 cmd.source = context->GetResourceAllocator()->CreateTexture({
20 .size = ISize(100, 100),
21 });
22 cmd.destination = context->GetResourceAllocator()->CreateTexture({
24 .size = ISize(100, 100),
25 });
26 bool result = cmd.Encode(*encoder.get());
28 EXPECT_TRUE(encoder->IsTracking(cmd.source));
29 EXPECT_TRUE(encoder->IsTracking(cmd.destination));
30}
31
33 auto context = MockVulkanContextBuilder().Build();
34 auto encoder = std::make_unique<CommandEncoderFactoryVK>(context)->Create();
36 cmd.source = context->GetResourceAllocator()->CreateTexture({
38 .size = ISize(100, 100),
39 });
40 cmd.destination = context->GetResourceAllocator()->CreateBuffer({
41 .size = 1,
42 });
43 bool result = cmd.Encode(*encoder.get());
45 EXPECT_TRUE(encoder->IsTracking(cmd.source));
46 EXPECT_TRUE(encoder->IsTracking(cmd.destination));
47}
48
50 auto context = MockVulkanContextBuilder().Build();
51 auto encoder = std::make_unique<CommandEncoderFactoryVK>(context)->Create();
53 cmd.destination = context->GetResourceAllocator()->CreateTexture({
55 .size = ISize(100, 100),
56 });
57 cmd.source =
58 DeviceBuffer::AsBufferView(context->GetResourceAllocator()->CreateBuffer({
59 .size = 1,
60 }));
61 bool result = cmd.Encode(*encoder.get());
63 EXPECT_TRUE(encoder->IsTracking(cmd.source.buffer));
64 EXPECT_TRUE(encoder->IsTracking(cmd.destination));
65}
66
67TEST(BlitCommandVkTest, BlitGenerateMipmapCommandVK) {
68 auto context = MockVulkanContextBuilder().Build();
69 auto encoder = std::make_unique<CommandEncoderFactoryVK>(context)->Create();
71 cmd.texture = context->GetResourceAllocator()->CreateTexture({
73 .size = ISize(100, 100),
74 .mip_count = 2,
75 });
76 bool result = cmd.Encode(*encoder.get());
78 EXPECT_TRUE(encoder->IsTracking(cmd.texture));
79}
80
81} // namespace testing
82} // namespace impeller
AutoreleasePool pool
#define TEST(S, s, D, expected)
static BufferView AsBufferView(std::shared_ptr< DeviceBuffer > buffer)
Create a buffer view of this entire buffer.
std::shared_ptr< ContextVK > Build()
Create a Vulkan context with Vulkan functions mocked. The caller is given a chance to tinker on the s...
GAsyncResult * result
TSize< int64_t > ISize
Definition size.h:138
#define EXPECT_TRUE(handle)
Definition unit_test.h:685