| Flutter Impeller |

capabilities_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"
6 #include "impeller/renderer/capabilities.h"
7
8 #include "gtest/gtest.h"
9
10 namespace impeller {
11 namespace testing {
12
13 #define CAPABILITY_TEST(name, default_value) \
14 TEST(CapabilitiesTest, name) { \
15 auto defaults = CapabilitiesBuilder().Build(); \
16 ASSERT_EQ(defaults->name(), default_value); \
17 auto opposite = CapabilitiesBuilder().Set##name(!default_value).Build(); \
18 ASSERT_EQ(opposite->name(), !default_value); \
19 }
20
21 CAPABILITY_TEST(SupportsOffscreenMSAA, false);
22 CAPABILITY_TEST(SupportsSSBO, false);
23 CAPABILITY_TEST(SupportsTextureToTextureBlits, false);
24 CAPABILITY_TEST(SupportsFramebufferFetch, false);
25 CAPABILITY_TEST(SupportsCompute, false);
26 CAPABILITY_TEST(SupportsComputeSubgroups, false);
27 CAPABILITY_TEST(SupportsReadFromResolve, false);
28 CAPABILITY_TEST(SupportsDecalSamplerAddressMode, false);
29 CAPABILITY_TEST(SupportsDeviceTransientTextures, false);
30 CAPABILITY_TEST(SupportsTriangleFan, false);
31 CAPABILITY_TEST(SupportsExtendedRangeFormats, false);
32 CAPABILITY_TEST(NeedsPartitionedHostBuffer, false);
33
34 TEST(CapabilitiesTest, DefaultColorFormat) {
35 auto defaults = CapabilitiesBuilder().Build();
36 EXPECT_EQ(defaults->GetDefaultColorFormat(), PixelFormat::kUnknown);
37 auto mutated = CapabilitiesBuilder()
38 .SetDefaultColorFormat(PixelFormat::kB10G10R10A10XR)
39 .Build();
40 EXPECT_EQ(mutated->GetDefaultColorFormat(), PixelFormat::kB10G10R10A10XR);
41 }
42
43 TEST(CapabilitiesTest, DefaultStencilFormat) {
44 auto defaults = CapabilitiesBuilder().Build();
45 EXPECT_EQ(defaults->GetDefaultStencilFormat(), PixelFormat::kUnknown);
46 auto mutated = CapabilitiesBuilder()
47 .SetDefaultStencilFormat(PixelFormat::kS8UInt)
48 .Build();
49 EXPECT_EQ(mutated->GetDefaultStencilFormat(), PixelFormat::kS8UInt);
50 }
51
52 TEST(CapabilitiesTest, DefaultDepthStencilFormat) {
53 auto defaults = CapabilitiesBuilder().Build();
54 EXPECT_EQ(defaults->GetDefaultDepthStencilFormat(), PixelFormat::kUnknown);
55 auto mutated = CapabilitiesBuilder()
56 .SetDefaultDepthStencilFormat(PixelFormat::kD32FloatS8UInt)
57 .Build();
58 EXPECT_EQ(mutated->GetDefaultDepthStencilFormat(),
59 PixelFormat::kD32FloatS8UInt);
60 }
61
62 TEST(CapabilitiesTest, DefaultGlyphAtlasFormat) {
63 auto defaults = CapabilitiesBuilder().Build();
64 EXPECT_EQ(defaults->GetDefaultGlyphAtlasFormat(), PixelFormat::kUnknown);
65 auto mutated = CapabilitiesBuilder()
66 .SetDefaultGlyphAtlasFormat(PixelFormat::kA8UNormInt)
67 .Build();
68 EXPECT_EQ(mutated->GetDefaultGlyphAtlasFormat(), PixelFormat::kA8UNormInt);
69 }
70
71 TEST(CapabilitiesTest, MaxRenderPassAttachmentSize) {
72 auto defaults = CapabilitiesBuilder().Build();
73 EXPECT_EQ(defaults->GetMaximumRenderPassAttachmentSize(), ISize(1, 1));
74 auto mutated = CapabilitiesBuilder()
75 .SetMaximumRenderPassAttachmentSize({100, 100})
76 .Build();
77 EXPECT_EQ(mutated->GetMaximumRenderPassAttachmentSize(), ISize(100, 100));
78 }
79
80 TEST(CapabilitiesTest, MinUniformAlignment) {
81 auto defaults = CapabilitiesBuilder().Build();
82 EXPECT_EQ(defaults->GetMinimumUniformAlignment(), 256u);
83 auto mutated = CapabilitiesBuilder().SetMinimumUniformAlignment(16).Build();
84 EXPECT_EQ(mutated->GetMinimumUniformAlignment(), 16u);
85 }
86
87 } // namespace testing
88 } // namespace impeller
capabilities.h
impeller::CapabilitiesBuilder
Definition: capabilities.h:148
impeller::CapabilitiesBuilder::SetDefaultColorFormat
CapabilitiesBuilder & SetDefaultColorFormat(PixelFormat value)
Definition: capabilities.cc:219
impeller::CapabilitiesBuilder::SetMinimumUniformAlignment
CapabilitiesBuilder & SetMinimumUniformAlignment(size_t value)
Definition: capabilities.cc:278
impeller::CapabilitiesBuilder::SetDefaultStencilFormat
CapabilitiesBuilder & SetDefaultStencilFormat(PixelFormat value)
Definition: capabilities.cc:225
impeller::CapabilitiesBuilder::SetMaximumRenderPassAttachmentSize
CapabilitiesBuilder & SetMaximumRenderPassAttachmentSize(ISize size)
Definition: capabilities.cc:266
impeller::CapabilitiesBuilder::SetDefaultGlyphAtlasFormat
CapabilitiesBuilder & SetDefaultGlyphAtlasFormat(PixelFormat value)
Definition: capabilities.cc:255
impeller::CapabilitiesBuilder::Build
std::unique_ptr< Capabilities > Build()
Definition: capabilities.cc:290
impeller::CapabilitiesBuilder::SetDefaultDepthStencilFormat
CapabilitiesBuilder & SetDefaultDepthStencilFormat(PixelFormat value)
Definition: capabilities.cc:231
impeller::testing::CAPABILITY_TEST
CAPABILITY_TEST(SupportsOffscreenMSAA, false)
impeller::testing::TEST
TEST(AllocationSizeTest, CanCreateTypedAllocations)
Definition: allocation_size_unittests.cc:10
impeller
Definition: allocation.cc:12
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::PixelFormat::kA8UNormInt
@ kA8UNormInt
impeller::PixelFormat::kB10G10R10A10XR
@ kB10G10R10A10XR
impeller::PixelFormat::kS8UInt
@ kS8UInt
impeller::PixelFormat::kD32FloatS8UInt
@ kD32FloatS8UInt
impeller::TSize
Definition: size.h:25