| Flutter Impeller |

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 .size = ISize(100, 100),
20 });
21 cmd.destination = context->GetResourceAllocator()->CreateTexture({
22 .size = ISize(100, 100),
23 });
24 bool result = cmd.Encode(*encoder.get());
25 EXPECT_TRUE(result);
26 EXPECT_TRUE(encoder->IsTracking(cmd.source));
27 EXPECT_TRUE(encoder->IsTracking(cmd.destination));
28 }
29
30 TEST(BlitCommandVkTest, BlitCopyTextureToBufferCommandVK) {
31 auto context = MockVulkanContextBuilder().Build();
32 auto encoder = std::make_unique<CommandEncoderFactoryVK>(context)->Create();
33 BlitCopyTextureToBufferCommandVK cmd;
34 cmd.source = context->GetResourceAllocator()->CreateTexture({
35 .size = ISize(100, 100),
36 });
37 cmd.destination = context->GetResourceAllocator()->CreateBuffer({
38 .size = 1,
39 });
40 bool result = cmd.Encode(*encoder.get());
41 EXPECT_TRUE(result);
42 EXPECT_TRUE(encoder->IsTracking(cmd.source));
43 EXPECT_TRUE(encoder->IsTracking(cmd.destination));
44 }
45
46 TEST(BlitCommandVkTest, BlitCopyBufferToTextureCommandVK) {
47 auto context = MockVulkanContextBuilder().Build();
48 auto encoder = std::make_unique<CommandEncoderFactoryVK>(context)->Create();
49 BlitCopyBufferToTextureCommandVK cmd;
50 cmd.destination = context->GetResourceAllocator()->CreateTexture({
51 .size = ISize(100, 100),
52 });
53 cmd.source = context->GetResourceAllocator()
54 ->CreateBuffer({
55 .size = 1,
56 })
57 ->AsBufferView();
58 bool result = cmd.Encode(*encoder.get());
59 EXPECT_TRUE(result);
60 EXPECT_TRUE(encoder->IsTracking(cmd.source.buffer));
61 EXPECT_TRUE(encoder->IsTracking(cmd.destination));
62 }
63
64 TEST(BlitCommandVkTest, BlitGenerateMipmapCommandVK) {
65 auto context = MockVulkanContextBuilder().Build();
66 auto encoder = std::make_unique<CommandEncoderFactoryVK>(context)->Create();
67 BlitGenerateMipmapCommandVK cmd;
68 cmd.texture = context->GetResourceAllocator()->CreateTexture({
69 .size = ISize(100, 100),
70 .mip_count = 2,
71 });
72 bool result = cmd.Encode(*encoder.get());
73 EXPECT_TRUE(result);
74 EXPECT_TRUE(encoder->IsTracking(cmd.texture));
75 }
76
77 } // namespace testing
78 } // namespace impeller
command_encoder_vk.h
impeller::BlitCopyTextureToTextureCommand::destination
std::shared_ptr< Texture > destination
Definition: blit_command.h:19
impeller::BlitGenerateMipmapCommandVK::Encode
bool Encode(CommandEncoderVK &encoder) const override
Definition: blit_command_vk.cc:246
impeller::testing::TEST
TEST(AiksCanvasTest, EmptyCullRect)
Definition: canvas_unittests.cc:17
impeller::BlitCopyBufferToTextureCommandVK
Definition: blit_command_vk.h:46
impeller::BlitCopyTextureToTextureCommandVK::Encode
bool Encode(CommandEncoderVK &encoder) const override
Definition: blit_command_vk.cc:25
impeller::BlitGenerateMipmapCommand::texture
std::shared_ptr< Texture > texture
Definition: blit_command.h:38
impeller::BlitCopyBufferToTextureCommandVK::Encode
bool Encode(CommandEncoderVK &encoder) const override
Definition: blit_command_vk.cc:159
impeller::BlitCopyBufferToTextureCommand::source
BufferView source
Definition: blit_command.h:32
impeller::BufferView::buffer
std::shared_ptr< const Buffer > buffer
Definition: buffer_view.h:14
blit_command_vk.h
impeller::BlitCopyTextureToBufferCommand::destination
std::shared_ptr< DeviceBuffer > destination
Definition: blit_command.h:26
impeller::BlitCopyTextureToBufferCommandVK::Encode
bool Encode(CommandEncoderVK &encoder) const override
Definition: blit_command_vk.cc:99
impeller::BlitGenerateMipmapCommandVK
Definition: blit_command_vk.h:55
impeller::BlitCopyTextureToTextureCommand::source
std::shared_ptr< Texture > source
Definition: blit_command.h:18
impeller::ISize
TSize< int64_t > ISize
Definition: size.h:136
impeller::BlitCopyTextureToBufferCommandVK
Definition: blit_command_vk.h:37
impeller::BlitCopyTextureToBufferCommand::source
std::shared_ptr< Texture > source
Definition: blit_command.h:25
impeller::BlitCopyTextureToTextureCommandVK
Definition: blit_command_vk.h:27
impeller
Definition: aiks_context.cc:10
impeller::BlitCopyBufferToTextureCommand::destination
std::shared_ptr< Texture > destination
Definition: blit_command.h:33