Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
sampler_library_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 <memory>
6#include "flutter/testing/testing.h" // IWYU pragma: keep
7#include "gtest/gtest.h"
14
15namespace impeller {
16namespace testing {
17
18TEST(SamplerLibraryVK, WorkaroundsCanDisableReadingFromMipLevels) {
19 auto const context = MockVulkanContextBuilder().Build();
20
21 auto library_vk = std::make_shared<SamplerLibraryVK>(
22 context->GetDeviceHolder(), /*max_sampler_anisotropy=*/1u);
23 std::shared_ptr<SamplerLibrary> library = library_vk;
24
27
28 auto sampler = library->GetSampler(desc);
29 EXPECT_EQ(sampler->GetDescriptor().mip_filter, MipFilter::kLinear);
30
31 // Apply mips disabled workaround.
32 library_vk->ApplyWorkarounds(WorkaroundsVK{.broken_mipmap_generation = true});
33
34 sampler = library->GetSampler(desc);
35 EXPECT_EQ(sampler->GetDescriptor().mip_filter, MipFilter::kBase);
36}
37
38TEST(SamplerLibraryVK, MaxAnisotropyIsClampedToTheDeviceLimit) {
39 auto const context = MockVulkanContextBuilder().Build();
40
41 std::shared_ptr<SamplerLibrary> library = std::make_shared<SamplerLibraryVK>(
42 context->GetDeviceHolder(), /*max_sampler_anisotropy=*/4u);
43
48 desc.max_anisotropy = 16;
49
50 auto sampler = library->GetSampler(desc);
51 EXPECT_EQ(sampler->GetDescriptor().max_anisotropy, 4u);
52
53 // Clamped values share a cache entry.
54 desc.max_anisotropy = 8;
55 EXPECT_EQ(library->GetSampler(desc), sampler);
56}
57
58TEST(SamplerLibraryVK, MaxAnisotropyIsDisabledWhenUnsupported) {
59 auto const context = MockVulkanContextBuilder().Build();
60
61 std::shared_ptr<SamplerLibrary> library = std::make_shared<SamplerLibraryVK>(
62 context->GetDeviceHolder(), /*max_sampler_anisotropy=*/1u);
63
68 desc.max_anisotropy = 16;
69
70 auto sampler = library->GetSampler(desc);
71 EXPECT_EQ(sampler->GetDescriptor().max_anisotropy, 1u);
72}
73
74} // namespace testing
75} // namespace impeller
std::shared_ptr< ContextVK > Build()
Create a Vulkan context with Vulkan functions mocked. The caller is given a chance to tinker on the s...
TEST(FrameTimingsRecorderTest, RecordVsync)
@ kLinear
Sample from the two nearest mip levels and linearly interpolate.
@ kBase
The texture is sampled as if it only had a single mipmap level.
std::shared_ptr< ContextGLES > context
A non-exhaustive set of driver specific workarounds.