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
8 #include "impeller/renderer/backend/vulkan/test/mock_vulkan.h"
9 
10 namespace impeller {
11 namespace 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());
27  EXPECT_TRUE(result);
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());
44  EXPECT_TRUE(result);
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 = context->GetResourceAllocator()
58  ->CreateBuffer({
59  .size = 1,
60  })
61  ->AsBufferView();
62  bool result = cmd.Encode(*encoder.get());
63  EXPECT_TRUE(result);
64  EXPECT_TRUE(encoder->IsTracking(cmd.source.buffer));
65  EXPECT_TRUE(encoder->IsTracking(cmd.destination));
66 }
67 
68 TEST(BlitCommandVkTest, BlitGenerateMipmapCommandVK) {
69  auto context = MockVulkanContextBuilder().Build();
70  auto encoder = std::make_unique<CommandEncoderFactoryVK>(context)->Create();
72  cmd.texture = context->GetResourceAllocator()->CreateTexture({
74  .size = ISize(100, 100),
75  .mip_count = 2,
76  });
77  bool result = cmd.Encode(*encoder.get());
78  EXPECT_TRUE(result);
79  EXPECT_TRUE(encoder->IsTracking(cmd.texture));
80 }
81 
82 } // namespace testing
83 } // namespace impeller
command_encoder_vk.h
impeller::PixelFormat::kR8G8B8A8UNormInt
@ kR8G8B8A8UNormInt
impeller::BlitCopyTextureToTextureCommand::destination
std::shared_ptr< Texture > destination
Definition: blit_command.h:20
impeller::BlitGenerateMipmapCommandVK::Encode
bool Encode(CommandEncoderVK &encoder) const override
Definition: blit_command_vk.cc:248
impeller::BlitCopyBufferToTextureCommandVK
Definition: blit_command_vk.h:47
impeller::BlitCopyTextureToTextureCommandVK::Encode
bool Encode(CommandEncoderVK &encoder) const override
Definition: blit_command_vk.cc:27
impeller::BlitGenerateMipmapCommand::texture
std::shared_ptr< Texture > texture
Definition: blit_command.h:39
impeller::BlitCopyBufferToTextureCommandVK::Encode
bool Encode(CommandEncoderVK &encoder) const override
Definition: blit_command_vk.cc:161
impeller::BlitCopyBufferToTextureCommand::source
BufferView source
Definition: blit_command.h:33
impeller::BufferView::buffer
std::shared_ptr< const Buffer > buffer
Definition: buffer_view.h:14
impeller::testing::TEST
TEST(CanvasRecorder, Save)
Definition: canvas_recorder_unittests.cc:61
blit_command_vk.h
impeller::BlitCopyTextureToBufferCommand::destination
std::shared_ptr< DeviceBuffer > destination
Definition: blit_command.h:27
impeller::BlitCopyTextureToBufferCommandVK::Encode
bool Encode(CommandEncoderVK &encoder) const override
Definition: blit_command_vk.cc:101
impeller::BlitGenerateMipmapCommandVK
Definition: blit_command_vk.h:56
impeller::BlitCopyTextureToTextureCommand::source
std::shared_ptr< Texture > source
Definition: blit_command.h:19
impeller::ISize
TSize< int64_t > ISize
Definition: size.h:138
impeller::BlitCopyTextureToBufferCommandVK
Definition: blit_command_vk.h:38
impeller::BlitCopyTextureToBufferCommand::source
std::shared_ptr< Texture > source
Definition: blit_command.h:26
impeller::BlitCopyTextureToTextureCommandVK
Definition: blit_command_vk.h:28
impeller
Definition: aiks_context.cc:10
impeller::BlitCopyBufferToTextureCommand::destination
std::shared_ptr< Texture > destination
Definition: blit_command.h:34