Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
impeller
renderer
backend
vulkan
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
6
#include "
impeller/renderer/backend/vulkan/blit_command_vk.h
"
7
#include "
impeller/renderer/backend/vulkan/command_encoder_vk.h
"
8
#include "
impeller/renderer/backend/vulkan/test/mock_vulkan.h
"
9
10
namespace
impeller
{
11
namespace
testing {
12
13
TEST
(BlitCommandVkTest,
BlitCopyTextureToTextureCommandVK
) {
14
auto
context =
MockVulkanContextBuilder
().
Build
();
15
auto
pool
= context->GetCommandPoolRecycler()->Get();
16
auto
encoder
= std::make_unique<CommandEncoderFactoryVK>(context)->Create();
17
BlitCopyTextureToTextureCommandVK
cmd;
18
cmd.source = context->GetResourceAllocator()->CreateTexture({
19
.format =
PixelFormat::kR8G8B8A8UNormInt
,
20
.size =
ISize
(100, 100),
21
});
22
cmd.destination = context->GetResourceAllocator()->CreateTexture({
23
.format =
PixelFormat::kR8G8B8A8UNormInt
,
24
.size =
ISize
(100, 100),
25
});
26
bool
result
= cmd.Encode(*
encoder
.get());
27
EXPECT_TRUE
(
result
);
28
EXPECT_TRUE
(
encoder
->IsTracking(cmd.source));
29
EXPECT_TRUE
(
encoder
->IsTracking(cmd.destination));
30
}
31
32
TEST
(BlitCommandVkTest,
BlitCopyTextureToBufferCommandVK
) {
33
auto
context =
MockVulkanContextBuilder
().
Build
();
34
auto
encoder
= std::make_unique<CommandEncoderFactoryVK>(context)->Create();
35
BlitCopyTextureToBufferCommandVK
cmd;
36
cmd.source = context->GetResourceAllocator()->CreateTexture({
37
.format =
PixelFormat::kR8G8B8A8UNormInt
,
38
.size =
ISize
(100, 100),
39
});
40
cmd.destination = context->GetResourceAllocator()->CreateBuffer({
41
.size = 1,
42
});
43
bool
result
= cmd.Encode(*
encoder
.get());
44
EXPECT_TRUE
(
result
);
45
EXPECT_TRUE
(
encoder
->IsTracking(cmd.source));
46
EXPECT_TRUE
(
encoder
->IsTracking(cmd.destination));
47
}
48
49
TEST
(BlitCommandVkTest,
BlitCopyBufferToTextureCommandVK
) {
50
auto
context =
MockVulkanContextBuilder
().
Build
();
51
auto
encoder
= std::make_unique<CommandEncoderFactoryVK>(context)->Create();
52
BlitCopyBufferToTextureCommandVK
cmd;
53
cmd.destination = context->GetResourceAllocator()->CreateTexture({
54
.format =
PixelFormat::kR8G8B8A8UNormInt
,
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());
62
EXPECT_TRUE
(
result
);
63
EXPECT_TRUE
(
encoder
->IsTracking(cmd.source.buffer));
64
EXPECT_TRUE
(
encoder
->IsTracking(cmd.destination));
65
}
66
67
TEST
(BlitCommandVkTest,
BlitGenerateMipmapCommandVK
) {
68
auto
context =
MockVulkanContextBuilder
().
Build
();
69
auto
encoder
= std::make_unique<CommandEncoderFactoryVK>(context)->Create();
70
BlitGenerateMipmapCommandVK
cmd;
71
cmd.texture = context->GetResourceAllocator()->CreateTexture({
72
.format =
PixelFormat::kR8G8B8A8UNormInt
,
73
.size =
ISize
(100, 100),
74
.mip_count = 2,
75
});
76
bool
result
= cmd.Encode(*
encoder
.get());
77
EXPECT_TRUE
(
result
);
78
EXPECT_TRUE
(
encoder
->IsTracking(cmd.texture));
79
}
80
81
}
// namespace testing
82
}
// namespace impeller
pool
AutoreleasePool pool
Definition
BazelBenchmarkTestRunner.cpp:313
TEST
#define TEST(S, s, D, expected)
Definition
FitsInTest.cpp:15
blit_command_vk.h
impeller::DeviceBuffer::AsBufferView
static BufferView AsBufferView(std::shared_ptr< DeviceBuffer > buffer)
Create a buffer view of this entire buffer.
Definition
device_buffer.cc:18
impeller::testing::MockVulkanContextBuilder
Definition
mock_vulkan.h:59
impeller::testing::MockVulkanContextBuilder::Build
std::shared_ptr< ContextVK > Build()
Create a Vulkan context with Vulkan functions mocked. The caller is given a chance to tinker on the s...
Definition
mock_vulkan.cc:912
command_encoder_vk.h
result
GAsyncResult * result
Definition
fl_text_input_plugin.cc:106
mock_vulkan.h
encoder
Definition
encoder.py:1
impeller
Definition
texture.h:18
impeller::PixelFormat::kR8G8B8A8UNormInt
@ kR8G8B8A8UNormInt
impeller::ISize
TSize< int64_t > ISize
Definition
size.h:138
impeller::BlitCopyBufferToTextureCommandVK
Definition
blit_command_vk.h:48
impeller::BlitCopyTextureToBufferCommandVK
Definition
blit_command_vk.h:39
impeller::BlitCopyTextureToTextureCommandVK
Definition
blit_command_vk.h:30
impeller::BlitGenerateMipmapCommandVK
Definition
blit_command_vk.h:57
EXPECT_TRUE
#define EXPECT_TRUE(handle)
Definition
unit_test.h:685
Generated on Fri Apr 26 2024 06:14:12 for Flutter Engine by
1.9.8