| Flutter Impeller |

blit_pass_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 "gtest/gtest.h"
6 #include "impeller/base/validation.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/command_buffer.h"
11
12 namespace impeller {
13 namespace testing {
14
15 using BlitPassTest = PlaygroundTest;
16 INSTANTIATE_PLAYGROUND_SUITE(BlitPassTest);
17
18 TEST_P(BlitPassTest, BlitAcrossDifferentPixelFormatsFails) {
19 ScopedValidationDisable scope; // avoid noise in output.
20 auto context = GetContext();
21 auto cmd_buffer = context->CreateCommandBuffer();
22 auto blit_pass = cmd_buffer->CreateBlitPass();
23
24 TextureDescriptor src_desc;
25 src_desc.format = PixelFormat::kA8UNormInt;
26 src_desc.size = {100, 100};
27 src_desc.storage_mode = StorageMode::kHostVisible;
28 auto src = context->GetResourceAllocator()->CreateTexture(src_desc);
29
30 TextureDescriptor dst_format;
31 dst_format.format = PixelFormat::kR8G8B8A8UNormInt;
32 dst_format.size = {100, 100};
33 dst_format.storage_mode = StorageMode::kHostVisible;
34 auto dst = context->GetResourceAllocator()->CreateTexture(dst_format);
35
36 EXPECT_FALSE(blit_pass->AddCopy(src, dst));
37 }
38
39 TEST_P(BlitPassTest, BlitAcrossDifferentSampleCountsFails) {
40 ScopedValidationDisable scope; // avoid noise in output.
41 auto context = GetContext();
42 auto cmd_buffer = context->CreateCommandBuffer();
43 auto blit_pass = cmd_buffer->CreateBlitPass();
44
45 TextureDescriptor src_desc;
46 src_desc.format = PixelFormat::kR8G8B8A8UNormInt;
47 src_desc.sample_count = SampleCount::kCount4;
48 src_desc.size = {100, 100};
49 auto src = context->GetResourceAllocator()->CreateTexture(src_desc);
50
51 TextureDescriptor dst_format;
52 dst_format.format = PixelFormat::kR8G8B8A8UNormInt;
53 dst_format.size = {100, 100};
54 auto dst = context->GetResourceAllocator()->CreateTexture(dst_format);
55
56 EXPECT_FALSE(blit_pass->AddCopy(src, dst));
57 }
58
59 TEST_P(BlitPassTest, BlitPassesForMatchingFormats) {
60 ScopedValidationDisable scope; // avoid noise in output.
61 auto context = GetContext();
62 auto cmd_buffer = context->CreateCommandBuffer();
63 auto blit_pass = cmd_buffer->CreateBlitPass();
64
65 TextureDescriptor src_desc;
66 src_desc.format = PixelFormat::kR8G8B8A8UNormInt;
67 src_desc.size = {100, 100};
68 auto src = context->GetResourceAllocator()->CreateTexture(src_desc);
69
70 TextureDescriptor dst_format;
71 dst_format.format = PixelFormat::kR8G8B8A8UNormInt;
72 dst_format.size = {100, 100};
73 auto dst = context->GetResourceAllocator()->CreateTexture(dst_format);
74
75 EXPECT_TRUE(blit_pass->AddCopy(src, dst));
76 }
77
78 } // namespace testing
79 } // namespace impeller
impeller::PixelFormat::kA8UNormInt
@ kA8UNormInt
impeller::TextureDescriptor::format
PixelFormat format
Definition: texture_descriptor.h:40
impeller::PixelFormat::kR8G8B8A8UNormInt
@ kR8G8B8A8UNormInt
texture_descriptor.h
formats.h
impeller::StorageMode::kHostVisible
@ kHostVisible
impeller::TextureDescriptor::sample_count
SampleCount sample_count
Definition: texture_descriptor.h:44
validation.h
impeller::testing::INSTANTIATE_PLAYGROUND_SUITE
INSTANTIATE_PLAYGROUND_SUITE(AiksTest)
impeller::TextureDescriptor::size
ISize size
Definition: texture_descriptor.h:41
command_buffer.h
impeller::testing::TEST_P
TEST_P(AiksTest, CanRenderMaskBlurHugeSigma)
Definition: aiks_blur_unittests.cc:23
impeller::SampleCount::kCount4
@ kCount4
impeller::TextureDescriptor::storage_mode
StorageMode storage_mode
Definition: texture_descriptor.h:38
impeller::PlaygroundTest
Definition: playground_test.h:23
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:37
impeller::ScopedValidationDisable
Definition: validation.h:38
impeller
Definition: aiks_blur_unittests.cc:20
playground_test.h